#99226# allow keyboard-triggered column context menu / allow column width to be set via context menu
This commit is contained in:
parent
99252473dd
commit
43dee38e18
3 changed files with 129 additions and 52 deletions
|
@ -2,9 +2,9 @@
|
|||
*
|
||||
* $RCSfile: SelectionBrowseBox.cxx,v $
|
||||
*
|
||||
* $Revision: 1.40 $
|
||||
* $Revision: 1.41 $
|
||||
*
|
||||
* last change: $Author: oj $ $Date: 2002-04-23 07:54:45 $
|
||||
* last change: $Author: fs $ $Date: 2002-05-24 12:58:56 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
|
@ -133,6 +133,9 @@
|
|||
#ifndef _DBAUI_SQLMESSAGE_HXX_
|
||||
#include "sqlmessage.hxx"
|
||||
#endif
|
||||
#ifndef DBAUI_TOOLS_HXX
|
||||
#include "UITools.hxx"
|
||||
#endif
|
||||
|
||||
using namespace ::svt;
|
||||
using namespace ::dbaui;
|
||||
|
@ -1129,36 +1132,44 @@ void OSelectionBrowseBox::RemoveField(sal_uInt16 nId, sal_Bool bActivate)
|
|||
invalidateUndoRedo();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void OSelectionBrowseBox::adjustSelectionMode( sal_Bool _bClickedOntoHeader, sal_Bool _bClickedOntoHandleCol )
|
||||
{
|
||||
// wenn ein Header selectiert wird, muß die selection angezeigt werden, sonst nicht)
|
||||
if ( _bClickedOntoHeader )
|
||||
{
|
||||
if (0 == GetSelectColumnCount() )
|
||||
// wenn es schon eine selektierte Spalte gibt, bin ich schon im richtigen Modus
|
||||
if ( BROWSER_HIDESELECT == ( m_nMode & BROWSER_HIDESELECT ) )
|
||||
{
|
||||
m_nMode &= ~BROWSER_HIDESELECT;
|
||||
m_nMode |= BROWSER_MULTISELECTION;
|
||||
SetMode( m_nMode );
|
||||
}
|
||||
}
|
||||
else if ( BROWSER_HIDESELECT != ( m_nMode & BROWSER_HIDESELECT ) )
|
||||
{
|
||||
if ( GetSelectColumnCount() != 0 )
|
||||
SetNoSelection();
|
||||
|
||||
if ( _bClickedOntoHandleCol )
|
||||
{
|
||||
m_nMode |= BROWSER_HIDESELECT;
|
||||
m_nMode &= ~BROWSER_MULTISELECTION;
|
||||
SetMode( m_nMode );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void OSelectionBrowseBox::MouseButtonDown(const BrowserMouseEvent& rEvt)
|
||||
{
|
||||
DBG_CHKTHIS(OSelectionBrowseBox,NULL);
|
||||
if( rEvt.IsLeft() )
|
||||
{
|
||||
sal_Bool bOnHeader = rEvt.GetRow() < 0 && rEvt.GetColumnId() != HANDLE_ID;
|
||||
// wenn ein Header selectiert wird, muß die selection angezeigt werden, sonst nicht)
|
||||
if (bOnHeader)
|
||||
{
|
||||
if (GetSelectColumnCount() == 0)
|
||||
// wenn es schon eine selektierte Spalte gibt, bin ich schon im richtigen Modus
|
||||
if ((m_nMode & BROWSER_HIDESELECT) == BROWSER_HIDESELECT)
|
||||
{
|
||||
m_nMode &= ~BROWSER_HIDESELECT;
|
||||
m_nMode |= BROWSER_MULTISELECTION;
|
||||
SetMode(m_nMode);
|
||||
}
|
||||
}
|
||||
else if (!((m_nMode & BROWSER_HIDESELECT) == BROWSER_HIDESELECT))
|
||||
{
|
||||
if (GetSelectColumnCount() != 0)
|
||||
SetNoSelection();
|
||||
if (rEvt.GetColumnId() == HANDLE_ID)
|
||||
{
|
||||
m_nMode |= BROWSER_HIDESELECT;
|
||||
m_nMode &= ~BROWSER_MULTISELECTION;
|
||||
SetMode(m_nMode);
|
||||
}
|
||||
}
|
||||
sal_Bool bOnHandle = HANDLE_ID == rEvt.GetColumnId();
|
||||
sal_Bool bOnHeader = ( rEvt.GetRow() < 0 ) && !bOnHandle;
|
||||
adjustSelectionMode( bOnHeader, bOnHandle );
|
||||
}
|
||||
EditBrowseBox::MouseButtonDown(rEvt);
|
||||
}
|
||||
|
@ -1695,6 +1706,17 @@ void OSelectionBrowseBox::Fill()
|
|||
AppendNewCol(DEFAULT_QUERY_COLS - nColCount);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Size OSelectionBrowseBox::CalcOptimalSize( const Size& _rAvailable )
|
||||
{
|
||||
Size aReturn( _rAvailable.Width(), GetTitleHeight() );
|
||||
|
||||
aReturn.Height() += ( m_nVisibleCount ? m_nVisibleCount : 15 ) * GetDataRowHeight();
|
||||
aReturn.Height() += 40; // just some space
|
||||
|
||||
return aReturn;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void OSelectionBrowseBox::Command(const CommandEvent& rEvt)
|
||||
{
|
||||
|
@ -1703,28 +1725,47 @@ void OSelectionBrowseBox::Command(const CommandEvent& rEvt)
|
|||
{
|
||||
case COMMAND_CONTEXTMENU:
|
||||
{
|
||||
Point aMenuPos( rEvt.GetMousePosPixel() );
|
||||
|
||||
if (!rEvt.IsMouseEvent())
|
||||
{
|
||||
EditBrowseBox::Command(rEvt);
|
||||
return;
|
||||
if ( 1 == GetSelectColumnCount() )
|
||||
{
|
||||
sal_uInt16 nSelId = GetColumnId( FirstSelectedColumn() );
|
||||
::Rectangle aColRect( GetFieldRectPixel( 0, nSelId, sal_False ) );
|
||||
|
||||
aMenuPos = aColRect.TopCenter();
|
||||
}
|
||||
else
|
||||
{
|
||||
EditBrowseBox::Command(rEvt);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Point aPoint(rEvt.GetMousePosPixel());
|
||||
sal_uInt16 nColId = GetColumnAtXPosPixel(rEvt.GetMousePosPixel().X());
|
||||
long nRow = GetRowAtYPosPixel(rEvt.GetMousePosPixel().Y());
|
||||
sal_uInt16 nColId = GetColumnAtXPosPixel( aMenuPos.X() );
|
||||
long nRow = GetRowAtYPosPixel( aMenuPos.Y() );
|
||||
|
||||
if (nRow < 0 && nColId > HANDLE_ID && IsColumnSelected(nColId) )
|
||||
if (nRow < 0 && nColId > HANDLE_ID )
|
||||
{
|
||||
if ( !IsColumnSelected( nColId ) )
|
||||
{
|
||||
adjustSelectionMode( sal_True /* clicked onto a header */ , sal_False /* not onto the handle col */ );
|
||||
SelectColumnId( nColId );
|
||||
}
|
||||
|
||||
if (!static_cast<OQueryController*>(getDesignView()->getController())->isReadOnly())
|
||||
{
|
||||
PopupMenu aContextMenu(ModuleRes(RID_QUERYCOLPOPUPMENU));
|
||||
aContextMenu.EnableItem(ID_QUERY_EDIT_JOINCONNECTION,FALSE);
|
||||
aContextMenu.RemoveDisabledEntries();
|
||||
switch (aContextMenu.Execute(this, aPoint))
|
||||
PopupMenu aContextMenu( ModuleRes( RID_QUERYCOLPOPUPMENU ) );
|
||||
switch (aContextMenu.Execute(this, aMenuPos))
|
||||
{
|
||||
case SID_DELETE: // Aussch
|
||||
case SID_DELETE:
|
||||
RemoveField(nColId);
|
||||
break;
|
||||
|
||||
case ID_BROWSER_COLWIDTH:
|
||||
adjustBrowseBoxColumnWidth( this, nColId );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1738,7 +1779,7 @@ void OSelectionBrowseBox::Command(const CommandEvent& rEvt)
|
|||
aContextMenu.CheckItem( ID_QUERY_ALIASNAME, m_bVisibleRow[BROW_COLUMNALIAS_ROW]);
|
||||
aContextMenu.CheckItem( ID_QUERY_DISTINCT, static_cast<OQueryController*>(getDesignView()->getController())->isDistinct());
|
||||
|
||||
switch (aContextMenu.Execute(this, aPoint))
|
||||
switch (aContextMenu.Execute(this, aMenuPos))
|
||||
{
|
||||
case ID_QUERY_FUNCTION:
|
||||
SetRowVisible(BROW_FUNCTION_ROW, !IsRowVisible(BROW_FUNCTION_ROW));
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
*
|
||||
* $RCSfile: SelectionBrowseBox.hxx,v $
|
||||
*
|
||||
* $Revision: 1.14 $
|
||||
* $Revision: 1.15 $
|
||||
*
|
||||
* last change: $Author: oj $ $Date: 2002-04-23 07:54:45 $
|
||||
* last change: $Author: fs $ $Date: 2002-05-24 12:58:56 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
|
@ -173,6 +173,8 @@ namespace dbaui
|
|||
void SetRowVisible(sal_uInt16 _nWhich, sal_Bool _bVis);
|
||||
|
||||
void SetReadOnly(sal_Bool bRO);
|
||||
// calculate an optimal size. Basically, this takes into account the number of visible rows.
|
||||
Size CalcOptimalSize( const Size& _rAvailable );
|
||||
|
||||
// can the current content be cut
|
||||
sal_Bool isCutAllowed();
|
||||
|
@ -185,6 +187,7 @@ namespace dbaui
|
|||
|
||||
void Fill();
|
||||
void PreFill();
|
||||
|
||||
/** GetCellText returns the text at the given position
|
||||
@param _nRow
|
||||
the number of the row
|
||||
|
@ -240,8 +243,6 @@ namespace dbaui
|
|||
|
||||
virtual sal_uInt16 GetDefaultColumnWidth(const String& rName) const;
|
||||
|
||||
|
||||
|
||||
void stopTimer();
|
||||
void startTimer();
|
||||
|
||||
|
@ -264,6 +265,8 @@ namespace dbaui
|
|||
void setTextCellContext(const OTableFieldDescRef& _rEntry,const String& _sText,ULONG _nHelpId);
|
||||
void invalidateUndoRedo();
|
||||
OTableFieldDescRef getEntry(OTableFields::size_type _nPos);
|
||||
|
||||
void adjustSelectionMode( sal_Bool _bClickedOntoHeader, sal_Bool _bClickedOntoHandleCol );
|
||||
};
|
||||
}
|
||||
#endif // DBAUI_QUERYDESIGN_OSELECTIONBROWSEBOX_HXX
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
*
|
||||
* $RCSfile: TEditControl.cxx,v $
|
||||
*
|
||||
* $Revision: 1.26 $
|
||||
* $Revision: 1.27 $
|
||||
*
|
||||
* last change: $Author: oj $ $Date: 2002-03-21 11:28:20 $
|
||||
* last change: $Author: fs $ $Date: 2002-05-24 12:53:56 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
|
@ -130,6 +130,9 @@
|
|||
#ifndef _SOT_STORAGE_HXX
|
||||
#include <sot/storage.hxx>
|
||||
#endif
|
||||
#ifndef DBAUI_TOOLS_HXX
|
||||
#include "UITools.hxx"
|
||||
#endif
|
||||
|
||||
using namespace ::dbaui;
|
||||
using namespace ::comphelper;
|
||||
|
@ -1522,22 +1525,52 @@ void OTableEditorCtrl::Command(const CommandEvent& rEvt)
|
|||
{
|
||||
case COMMAND_CONTEXTMENU:
|
||||
{
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Falls kein MouseEvent, an Basisklasse weiterleiten
|
||||
Point aMenuPos( rEvt.GetMousePosPixel() );
|
||||
if (!rEvt.IsMouseEvent())
|
||||
{
|
||||
OTableRowView::Command(rEvt);
|
||||
return;
|
||||
if ( 1 == GetSelectColumnCount() )
|
||||
{
|
||||
sal_uInt16 nSelId = GetColumnId( FirstSelectedColumn() );
|
||||
::Rectangle aColRect( GetFieldRectPixel( 0, nSelId, sal_False ) );
|
||||
|
||||
aMenuPos = aColRect.TopCenter();
|
||||
}
|
||||
else
|
||||
{
|
||||
OTableRowView::Command(rEvt);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Kontextmenu einblenden
|
||||
if( !IsReadOnly() )
|
||||
{
|
||||
sal_uInt16 nColId = GetColumnAtXPosPixel(rEvt.GetMousePosPixel().X());
|
||||
long nRow = GetRowAtYPosPixel(rEvt.GetMousePosPixel().Y());
|
||||
sal_uInt16 nColId = GetColumnAtXPosPixel(aMenuPos.X());
|
||||
long nRow = GetRowAtYPosPixel(aMenuPos.Y());
|
||||
|
||||
if ( nColId == HANDLE_ID )
|
||||
if ( HANDLE_ID != nColId )
|
||||
{
|
||||
if ( nRow < 0 )
|
||||
{ // hit the header
|
||||
if ( 3 != nColId )
|
||||
{ // 3 would mean the last column, and this last column is auto-sized
|
||||
if ( !IsColumnSelected( nColId ) )
|
||||
SelectColumnId( nColId );
|
||||
|
||||
PopupMenu aContextMenu( ModuleRes( RID_QUERYCOLPOPUPMENU ) );
|
||||
aContextMenu.EnableItem( SID_DELETE, sal_False );
|
||||
aContextMenu.RemoveDisabledEntries(sal_True, sal_True);
|
||||
switch ( aContextMenu.Execute( this, aMenuPos ) )
|
||||
{
|
||||
case ID_BROWSER_COLWIDTH:
|
||||
adjustBrowseBoxColumnWidth( this, nColId );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PopupMenu aContextMenu(ModuleRes(RID_TABLEDESIGNROWPOPUPMENU));
|
||||
long nSelectRowCount = GetSelectRowCount();
|
||||
|
@ -1558,7 +1591,7 @@ void OTableEditorCtrl::Command(const CommandEvent& rEvt)
|
|||
// Alle Aktionen, die die Zeilenzahl veraendern, muessen asynchron
|
||||
// ausgefuehrt werden->sonst Probleme zwischen Kontextmenu u. Browser
|
||||
m_nDataPos = GetCurRow();
|
||||
switch (aContextMenu.Execute(this, rEvt.GetMousePosPixel()))
|
||||
switch (aContextMenu.Execute(this, aMenuPos))
|
||||
{
|
||||
case SID_CUT:
|
||||
Cut();
|
||||
|
|
Loading…
Reference in a new issue