Kaydet (Commit) aa708712 authored tarafından Caolán McNamara's avatar Caolán McNamara

convert selection menu to .ui

Change-Id: Ie4cf80202c333600ce027c78aa3c379ef33f4f80
Reviewed-on: https://gerrit.libreoffice.org/36449Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst a4d1ed6b
......@@ -251,7 +251,6 @@
#define RID_SVXSTR_OVERWRITE_TEXT (RID_SVX_START + 212)
// Strings for the selection mode
#define RID_SVXMENU_SELECTION (RID_SVX_START + 213)
#define RID_SVXBMP_SELECTION (RID_SVX_START + 215)
#define RID_SVXSTR_XMLSEC_SIG_OK (RID_SVX_START + 222)
......
......@@ -69,6 +69,7 @@ $(eval $(call gb_UIConfig_add_uifiles,svx,\
svx/uiconfig/ui/rulermenu \
svx/uiconfig/ui/safemodedialog \
svx/uiconfig/ui/savemodifieddialog \
svx/uiconfig/ui/selectionmenu \
svx/uiconfig/ui/sidebararea \
svx/uiconfig/ui/sidebarshadow \
svx/uiconfig/ui/sidebargraphic \
......
......@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <vcl/builder.hxx>
#include <vcl/menu.hxx>
#include <vcl/status.hxx>
#include <svl/intitem.hxx>
......@@ -32,42 +33,48 @@
SFX_IMPL_STATUSBAR_CONTROL(SvxSelectionModeControl, SfxUInt16Item);
/// Popup menu to select the selection type
class SelectionTypePopup : public PopupMenu
class SelectionTypePopup
{
VclBuilder m_aBuilder;
VclPtr<PopupMenu> m_xMenu;
static sal_uInt16 id_to_state(const OString& rIdent);
sal_uInt16 state_to_id(sal_uInt16 nState) const;
public:
explicit SelectionTypePopup( sal_uInt16 nCurrent );
explicit SelectionTypePopup(sal_uInt16 nCurrent);
OUString GetItemTextForState(sal_uInt16 nState) { return m_xMenu->GetItemText(state_to_id(nState)); }
sal_uInt16 GetState() const { return id_to_state(m_xMenu->GetCurItemIdent()); }
sal_uInt16 Execute(vcl::Window* pWindow, const Point& rPopupPos) { return m_xMenu->Execute(pWindow, rPopupPos); }
};
/// Item id's cannot start from 0, so we need to convert
static sal_uInt16 id_to_state( sal_uInt16 nId )
sal_uInt16 SelectionTypePopup::id_to_state(const OString& rIdent)
{
switch ( nId )
{
default: // fall through
case SELECTION_STANDARD: return 0;
case SELECTION_EXTENDED: return 1;
case SELECTION_ADDED: return 2;
case SELECTION_BLOCK: return 3;
}
if (rIdent == "block")
return 3;
else if (rIdent == "adding")
return 2;
else if (rIdent == "extending")
return 1;
else // fall through
return 0;
}
/// Item id's cannot start from 0, so we need to convert
static sal_uInt16 state_to_id( sal_uInt16 nState )
sal_uInt16 SelectionTypePopup::state_to_id(sal_uInt16 nState) const
{
switch ( nState )
switch (nState)
{
default: // fall through
case 0: return SELECTION_STANDARD;
case 1: return SELECTION_EXTENDED;
case 2: return SELECTION_ADDED;
case 3: return SELECTION_BLOCK;
case 0: return m_xMenu->GetItemId("standard");
case 1: return m_xMenu->GetItemId("extending");
case 2: return m_xMenu->GetItemId("adding");
case 3: return m_xMenu->GetItemId("block");
}
}
SelectionTypePopup::SelectionTypePopup( sal_uInt16 nCurrent )
: PopupMenu( ResId( RID_SVXMENU_SELECTION, DIALOG_MGR() ) )
SelectionTypePopup::SelectionTypePopup(sal_uInt16 nCurrent)
: m_aBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "svx/ui/selectionmenu.ui", "")
, m_xMenu(m_aBuilder.get_menu("menu"))
{
CheckItem( state_to_id( nCurrent ) );
m_xMenu->CheckItem(state_to_id(nCurrent));
}
SvxSelectionModeControl::SvxSelectionModeControl( sal_uInt16 _nSlotId,
......@@ -89,20 +96,19 @@ void SvxSelectionModeControl::StateChanged( sal_uInt16, SfxItemState eState,
const SfxUInt16Item* pItem = static_cast<const SfxUInt16Item*>(pState);
mnState = pItem->GetValue();
ScopedVclPtrInstance<SelectionTypePopup> aPop( mnState );
GetStatusBar().SetQuickHelpText( GetId(), aPop->GetItemText( state_to_id( mnState ) ) );
SelectionTypePopup aPop(mnState);
GetStatusBar().SetQuickHelpText(GetId(), aPop.GetItemTextForState(mnState));
}
}
bool SvxSelectionModeControl::MouseButtonDown( const MouseEvent& rEvt )
{
ScopedVclPtrInstance<SelectionTypePopup> aPop( mnState );
SelectionTypePopup aPop(mnState);
StatusBar& rStatusbar = GetStatusBar();
if ( aPop->Execute( &rStatusbar, rEvt.GetPosPixel() ) )
if (aPop.Execute(&rStatusbar, rEvt.GetPosPixel()))
{
sal_uInt16 nNewState = id_to_state( aPop->GetCurItemId() );
sal_uInt16 nNewState = aPop.GetState();
if ( nNewState != mnState )
{
mnState = nNewState;
......
......@@ -30,11 +30,6 @@
#define PSZ_FUNC_SELECTION_COUNT 13
#define PSZ_FUNC_NONE 16
#define SELECTION_STANDARD 1
#define SELECTION_EXTENDED 2
#define SELECTION_ADDED 3
#define SELECTION_BLOCK 4
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -36,38 +36,6 @@ String RID_SVXSTR_OVERWRITE_TEXT
Text [ en-US ] = "Overwrite" ;
};
// Selection type menu
Menu RID_SVXMENU_SELECTION
{
ItemList =
{
MenuItem
{
Identifier = SELECTION_STANDARD ;
RadioCheck = TRUE ;
Text [ en-US ] = "Standard selection" ;
};
MenuItem
{
Identifier = SELECTION_EXTENDED ;
RadioCheck = TRUE ;
Text [ en-US ] = "Extending selection" ;
};
MenuItem
{
Identifier = SELECTION_ADDED ;
RadioCheck = TRUE ;
Text [ en-US ] = "Adding selection" ;
};
MenuItem
{
Identifier = SELECTION_BLOCK ;
RadioCheck = TRUE ;
Text [ en-US ] = "Block selection" ;
};
};
};
Bitmap RID_SVXBMP_SELECTION
{
File = "selection_10x22.png" ;
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<interface>
<requires lib="gtk+" version="3.10"/>
<object class="GtkMenu" id="menu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkRadioMenuItem" id="standard">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Standard selection</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkRadioMenuItem" id="extending">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Extending selection</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkRadioMenuItem" id="adding">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Adding selection</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkRadioMenuItem" id="block">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Block selection</property>
<property name="use_underline">True</property>
</object>
</child>
</object>
</interface>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment