summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrisztian Pinter <pin.terminator@gmail.com>2014-07-21 16:34:30 +0200
committerKrisztian Pinter <pin.terminator@gmail.com>2014-07-25 17:19:24 +0200
commit0e2891031a3d628211193466097136296932c513 (patch)
tree12a626a50d2c0b20114f38877e3b9822562b88b9
parentec8cad53209564c92e2d49cc2fa61cbbb58ed18c (diff)
Convert SvxColorWindow_Impl to Widget Layout
Change-Id: I8c830de56892fd8eb1c14add25f65c25046d47fd
-rw-r--r--include/sfx2/tbxctrl.hxx6
-rw-r--r--include/vcl/floatwin.hxx13
-rw-r--r--sfx2/source/toolbox/tbxitem.cxx20
-rw-r--r--svx/UIConfig_svx.mk1
-rw-r--r--svx/source/tbxctrls/colorwindow.hxx19
-rw-r--r--svx/source/tbxctrls/tbcontrl.cxx99
-rw-r--r--svx/uiconfig/ui/colorwindow.ui68
-rw-r--r--vcl/source/window/floatwin.cxx36
8 files changed, 199 insertions, 63 deletions
diff --git a/include/sfx2/tbxctrl.hxx b/include/sfx2/tbxctrl.hxx
index 2c7d81a2ec79..a5f78a11a343 100644
--- a/include/sfx2/tbxctrl.hxx
+++ b/include/sfx2/tbxctrl.hxx
@@ -148,6 +148,12 @@ public:
SfxPopupWindow( sal_uInt16 nId,
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame,
Window* pParentWindow,
+ const OString& rID,
+ const OUString& rUIXMLDescription,
+ WinBits nBits );
+ SfxPopupWindow( sal_uInt16 nId,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame,
+ Window* pParentWindow,
const ResId &rId );
virtual ~SfxPopupWindow();
diff --git a/include/vcl/floatwin.hxx b/include/vcl/floatwin.hxx
index 45aefab68c5e..507ce0d569ac 100644
--- a/include/vcl/floatwin.hxx
+++ b/include/vcl/floatwin.hxx
@@ -21,8 +21,11 @@
#define INCLUDED_VCL_FLOATWIN_HXX
#include <tools/solar.h>
+#include <vcl/builder.hxx>
#include <vcl/dllapi.h>
#include <vcl/syswin.hxx>
+#include <vcl/window.hxx>
+#include <vcl/layout.hxx>
class ToolBox;
@@ -70,7 +73,9 @@ enum HitTest
// - FloatingWindow -
-class VCL_DLLPUBLIC FloatingWindow : public SystemWindow
+class VCL_DLLPUBLIC FloatingWindow
+ : public SystemWindow
+ , public VclBuilderContainer
{
class ImplData;
private:
@@ -120,6 +125,7 @@ public:
public:
explicit FloatingWindow( Window* pParent, WinBits nStyle = WB_STDFLOATWIN );
+ explicit FloatingWindow( Window* pParent, const OString& rID, const OUString& rUIXMLDescription, WinBits nStyle = WB_STDFLOATWIN );
explicit FloatingWindow( Window* pParent, const ResId& );
virtual ~FloatingWindow();
@@ -149,6 +155,11 @@ public:
bool GrabsFocus() const { return mbGrabFocus; }
static Point CalcFloatingPosition( Window* pWindow, const Rectangle& rRect, sal_uLong nFlags, sal_uInt16& rArrangeIndex );
+
+ virtual void SetPosSizePixel(const Point& rNewPos, const Size& rNewSize) SAL_OVERRIDE;
+ virtual void SetPosPixel(const Point& rNewPos) SAL_OVERRIDE;
+ virtual void SetSizePixel(const Size& rNewSize) SAL_OVERRIDE;
+ virtual Size GetOptimalSize() const SAL_OVERRIDE;
};
#endif // INCLUDED_VCL_FLOATWIN_HXX
diff --git a/sfx2/source/toolbox/tbxitem.cxx b/sfx2/source/toolbox/tbxitem.cxx
index d4152af0f4b4..a5971f5d854d 100644
--- a/sfx2/source/toolbox/tbxitem.cxx
+++ b/sfx2/source/toolbox/tbxitem.cxx
@@ -1181,6 +1181,26 @@ SfxPopupWindow::SfxPopupWindow(
((SystemWindow *)pWindow)->GetTaskPaneList()->AddWindow( this );
}
+
+SfxPopupWindow::SfxPopupWindow(
+ sal_uInt16 nId,
+ const Reference< XFrame >& rFrame,
+ Window* pParentWindow,
+ const OString& rID,
+ const OUString& rUIXMLDescription,
+ WinBits nBits ) :
+ FloatingWindow( pParentWindow, rID, rUIXMLDescription, nBits )
+ , m_bFloating( false )
+ , m_bCascading( false )
+ , m_nId( nId )
+ , m_xFrame( rFrame )
+ , m_pStatusListener( 0 )
+{
+ Window* pWindow = GetTopMostParentSystemWindow( this );
+ if ( pWindow )
+ ((SystemWindow *)pWindow)->GetTaskPaneList()->AddWindow( this );
+}
+
SfxPopupWindow::SfxPopupWindow(
sal_uInt16 nId,
const Reference< XFrame >& rFrame,
diff --git a/svx/UIConfig_svx.mk b/svx/UIConfig_svx.mk
index 1d9d2668c4f4..13134a497695 100644
--- a/svx/UIConfig_svx.mk
+++ b/svx/UIConfig_svx.mk
@@ -20,6 +20,7 @@ $(eval $(call gb_UIConfig_add_uifiles,svx,\
svx/uiconfig/ui/asianphoneticguidedialog \
svx/uiconfig/ui/chineseconversiondialog \
svx/uiconfig/ui/chinesedictionary \
+ svx/uiconfig/ui/colorwindow \
svx/uiconfig/ui/compressgraphicdialog \
svx/uiconfig/ui/deleteheaderdialog \
svx/uiconfig/ui/deletefooterdialog \
diff --git a/svx/source/tbxctrls/colorwindow.hxx b/svx/source/tbxctrls/colorwindow.hxx
index 086cdef64282..2f2d3183e2d9 100644
--- a/svx/source/tbxctrls/colorwindow.hxx
+++ b/svx/source/tbxctrls/colorwindow.hxx
@@ -41,16 +41,15 @@ class SvxColorWindow_Impl : public SfxPopupWindow
using FloatingWindow::StateChanged;
private:
- const sal_uInt16 theSlotId;
- SvxColorValueSet aColorSet;
- ComboBox aPaletteComboBox;
- PushButton aButtonPicker;
- OUString maCommand;
- Link maSelectedLink;
-
- const sal_uInt16 nButtonWidth;
- const sal_uInt16 nButtonHeight;
- PaletteManager& mrPaletteManager;
+ const sal_uInt16 theSlotId;
+ SvxColorValueSet* mpColorSet;
+ Size maWindowSize;
+ ComboBox* mpPaletteComboBox;
+ PushButton* mpButtonPicker;
+ OUString maCommand;
+ Link maSelectedLink;
+
+ PaletteManager& mrPaletteManager;
DECL_LINK( SelectHdl, void * );
DECL_LINK( SelectPaletteHdl, void *);
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index d8210d28143e..01a0ebbfd7d2 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -1015,28 +1015,33 @@ void SvxFontNameBox_Impl::Select()
#define WB_NO_DIRECTSELECT ((WinBits)0x04000000)
#endif
+
SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand,
PaletteManager& rPaletteManager,
sal_uInt16 nSlotId,
const Reference< XFrame >& rFrame,
const OUString& rWndTitle,
Window* pParentWindow ):
- SfxPopupWindow( nSlotId, rFrame, pParentWindow, WinBits( WB_STDPOPUP | WB_OWNERDRAWDECORATION ) ),
+
+ SfxPopupWindow( nSlotId, rFrame, pParentWindow,
+ "palette_popup_window", "svx/ui/colorwindow.ui",
+ WinBits( WB_STDPOPUP | WB_OWNERDRAWDECORATION ) ),
+ maWindowSize( 250, 350 ),
theSlotId( nSlotId ),
- aColorSet ( this, WinBits( WB_ITEMBORDER | WB_NAMEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT) ),
- aPaletteComboBox( this, WinBits( WB_BORDER | WB_DROPDOWN | WB_AUTOSIZE) ),
- aButtonPicker( this ),
maCommand( rCommand ),
- nButtonWidth ( 28 ),
- nButtonHeight( 28 ),
mrPaletteManager( rPaletteManager )
{
+ get(mpPaletteComboBox, "palette_list_combobox");
+ get(mpButtonPicker, "color_picker_button");
+ get(mpColorSet, "colorset");
+
+ mpColorSet->SetStyle( WinBits(WB_ITEMBORDER | WB_NAMEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT) );
if ( SID_ATTR_CHAR_COLOR_BACKGROUND == theSlotId || SID_BACKGROUND_COLOR == theSlotId )
{
- aColorSet.SetStyle( aColorSet.GetStyle() | WB_NONEFIELD );
- aColorSet.SetText( SVX_RESSTR( RID_SVXSTR_TRANSPARENT ) );
- aColorSet.SetAccessibleName( SVX_RESSTR( RID_SVXSTR_BACKGROUND ) );
+ mpColorSet->SetStyle( mpColorSet->GetStyle() | WB_NONEFIELD );
+ mpColorSet->SetText( SVX_RESSTR( RID_SVXSTR_TRANSPARENT ) );
+ mpColorSet->SetAccessibleName( SVX_RESSTR( RID_SVXSTR_BACKGROUND ) );
}
else if ( SID_ATTR_CHAR_COLOR == theSlotId || SID_ATTR_CHAR_COLOR2 == theSlotId || SID_EXTRUSION_3D_COLOR == theSlotId )
{
@@ -1049,45 +1054,43 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand,
SfxItemState eState = aQueryStatus.QueryState( pDummy );
if( (SFX_ITEM_DEFAULT > eState) || ( SID_EXTRUSION_3D_COLOR == theSlotId ) )
{
- aColorSet.SetStyle( aColorSet.GetStyle() | WB_NONEFIELD );
- aColorSet.SetText( SVX_RESSTR( RID_SVXSTR_AUTOMATIC ) );
- aColorSet.SetAccessibleName( SVX_RESSTR( RID_SVXSTR_TEXTCOLOR ) );
+ mpColorSet->SetStyle( mpColorSet->GetStyle() | WB_NONEFIELD );
+ mpColorSet->SetText( SVX_RESSTR( RID_SVXSTR_AUTOMATIC ) );
+ mpColorSet->SetAccessibleName( SVX_RESSTR( RID_SVXSTR_TEXTCOLOR ) );
}
}
else if ( SID_FRAME_LINECOLOR == theSlotId )
{
- aColorSet.SetAccessibleName( SVX_RESSTR( RID_SVXSTR_FRAME_COLOR ) );
+ mpColorSet->SetAccessibleName( SVX_RESSTR( RID_SVXSTR_FRAME_COLOR ) );
}
else
{
- aColorSet.SetAccessibleName( SVX_RESSTR( RID_SVXSTR_LINECOLOR ) );
+ mpColorSet->SetAccessibleName( SVX_RESSTR( RID_SVXSTR_LINECOLOR ) );
}
- aPaletteComboBox.SetSelectHdl( LINK( this, SvxColorWindow_Impl, SelectPaletteHdl ) );
- aPaletteComboBox.AdaptDropDownLineCountToMaximum();
- aPaletteComboBox.Show();
+ mpPaletteComboBox->SetStyle( mpPaletteComboBox->GetStyle() | WB_BORDER | WB_AUTOSIZE );
+ mpPaletteComboBox->SetSelectHdl( LINK( this, SvxColorWindow_Impl, SelectPaletteHdl ) );
+ mpPaletteComboBox->AdaptDropDownLineCountToMaximum();
std::vector<OUString> aPaletteList = mrPaletteManager.GetPaletteList();
+ mpPaletteComboBox->SetText( aPaletteList[ mrPaletteManager.GetPalette() ] );
for( std::vector<OUString>::iterator it = aPaletteList.begin(); it != aPaletteList.end(); ++it )
{
- aPaletteComboBox.InsertEntry( *it );
+ mpPaletteComboBox->InsertEntry( *it );
}
- aPaletteComboBox.SetText( aPaletteList[ mrPaletteManager.GetPalette() ] );
- aButtonPicker.SetText("P");
- aButtonPicker.SetClickHdl( LINK( this, SvxColorWindow_Impl, OpenPickerClickHdl ) );
- aButtonPicker.Show();
+ mpButtonPicker->SetClickHdl( LINK( this, SvxColorWindow_Impl, OpenPickerClickHdl ) );
- aColorSet.Show();
-
- aColorSet.SetSelectHdl( LINK( this, SvxColorWindow_Impl, SelectHdl ) );
+ mpColorSet->SetSelectHdl( LINK( this, SvxColorWindow_Impl, SelectHdl ) );
SetHelpId( HID_POPUP_COLOR );
- aColorSet.SetHelpId( HID_POPUP_COLOR_CTRL );
+ mpColorSet->SetHelpId( HID_POPUP_COLOR_CTRL );
SetText( rWndTitle );
-
AddStatusListener( OUString( ".uno:ColorTableState" ));
AddStatusListener( maCommand );
- mrPaletteManager.ReloadColorSet(aColorSet);
+ mrPaletteManager.ReloadColorSet(*mpColorSet);
+ mpPaletteComboBox->Show();
+ mpButtonPicker->Show();
+ mpColorSet->Show();
}
SvxColorWindow_Impl::~SvxColorWindow_Impl()
@@ -1096,7 +1099,7 @@ SvxColorWindow_Impl::~SvxColorWindow_Impl()
void SvxColorWindow_Impl::KeyInput( const KeyEvent& rKEvt )
{
- aColorSet.KeyInput(rKEvt);
+ mpColorSet->KeyInput(rKEvt);
}
SfxPopupWindow* SvxColorWindow_Impl::Clone() const
@@ -1106,20 +1109,20 @@ SfxPopupWindow* SvxColorWindow_Impl::Clone() const
IMPL_LINK_NOARG(SvxColorWindow_Impl, SelectHdl)
{
- sal_uInt16 nItemId = aColorSet.GetSelectItemId();
+ sal_uInt16 nItemId = mpColorSet->GetSelectItemId();
Color aColor;
if ( !nItemId && ( SID_ATTR_CHAR_COLOR_BACKGROUND == theSlotId || SID_BACKGROUND_COLOR == theSlotId ) )
aColor = COL_TRANSPARENT;
else if ( !nItemId && (SID_ATTR_CHAR_COLOR == theSlotId || SID_ATTR_CHAR_COLOR2 == theSlotId || SID_EXTRUSION_3D_COLOR == theSlotId) )
aColor = COL_AUTO;
else
- aColor = aColorSet.GetItemColor( nItemId );
+ aColor = mpColorSet->GetItemColor( nItemId );
SvxColorItem aColorItem( aColor, theSlotId );
/* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() calls.
This instance may be deleted in the meantime (i.e. when a dialog is opened
while in Dispatch()), accessing members will crash in this case. */
- aColorSet.SetNoSelection();
+ mpColorSet->SetNoSelection();
if ( IsInPopupMode() )
EndPopupMode();
@@ -1143,10 +1146,10 @@ IMPL_LINK_NOARG(SvxColorWindow_Impl, SelectHdl)
IMPL_LINK_NOARG(SvxColorWindow_Impl, SelectPaletteHdl)
{
- OUString sSrchTxt = aPaletteComboBox.GetText();
- sal_Int32 nPos = aPaletteComboBox.GetEntryPos( sSrchTxt );
+ OUString sSrchTxt = mpPaletteComboBox->GetText();
+ sal_Int32 nPos = mpPaletteComboBox->GetEntryPos( sSrchTxt );
mrPaletteManager.SetPalette( nPos );
- mrPaletteManager.ReloadColorSet(aColorSet);
+ mrPaletteManager.ReloadColorSet(*mpColorSet);
Resize();
return 0;
}
@@ -1159,21 +1162,13 @@ IMPL_LINK_NOARG(SvxColorWindow_Impl, OpenPickerClickHdl)
void SvxColorWindow_Impl::Resize()
{
- const Size aSize(this->GetOutputSizePixel());
- aColorSet.SetPosSizePixel( Point(2, nButtonHeight + 2), Size(aSize.Width() - 4, aSize.Height() - 6 - nButtonHeight) );
-
- const Size aNewSize(aColorSet.layoutAllVisible(mrPaletteManager.GetColorCount()));
- aColorSet.SetOutputSizePixel(aNewSize);
-
- SetOutputSizePixel(Size(aNewSize.Width() + 4, aNewSize.Height() + 4 + nButtonHeight));
-
- aPaletteComboBox.SetPosSizePixel(Point(2, 0), Size(aNewSize.Width() - nButtonWidth, nButtonHeight));
- aButtonPicker.SetPosSizePixel(Point(aNewSize.Width() + 4 - nButtonWidth, 0), Size(nButtonWidth, nButtonHeight));
+ mpColorSet->layoutAllVisible(mrPaletteManager.GetColorCount());
+ SetOutputSizePixel(maWindowSize);
}
void SvxColorWindow_Impl::StartSelection()
{
- aColorSet.StartSelection();
+ mpColorSet->StartSelection();
}
bool SvxColorWindow_Impl::Close()
@@ -1187,11 +1182,11 @@ void SvxColorWindow_Impl::StateChanged( sal_uInt16 nSID, SfxItemState eState, co
{
if (( nSID == SID_COLOR_TABLE ) && ( pState->ISA( SvxColorListItem )))
{
- mrPaletteManager.ReloadColorSet(aColorSet);
+ mrPaletteManager.ReloadColorSet(*mpColorSet);
}
else if ( SFX_ITEM_DEFAULT <= eState )
{
- aColorSet.SetNoSelection();
+ mpColorSet->SetNoSelection();
Color aColor;
if ( pState->ISA( SvxColorItem ) )
@@ -1199,16 +1194,16 @@ void SvxColorWindow_Impl::StateChanged( sal_uInt16 nSID, SfxItemState eState, co
else if ( pState->ISA( XLineColorItem ) )
aColor = ((const XLineColorItem*)pState)->GetColorValue();
- for ( size_t i = 1; i <= aColorSet.GetItemCount(); ++i )
+ for ( size_t i = 1; i <= mpColorSet->GetItemCount(); ++i )
{
- if ( aColor == aColorSet.GetItemColor(i) )
+ if ( aColor == mpColorSet->GetItemColor(i) )
{
- aColorSet.SelectItem(i);
+ mpColorSet->SelectItem(i);
return;
}
}
if ( aColor == COL_AUTO || aColor == COL_TRANSPARENT )
- aColorSet.SelectItem(0);
+ mpColorSet->SelectItem(0);
}
}
}
diff --git a/svx/uiconfig/ui/colorwindow.ui b/svx/uiconfig/ui/colorwindow.ui
new file mode 100644
index 000000000000..54b8f49ca057
--- /dev/null
+++ b/svx/uiconfig/ui/colorwindow.ui
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.16.1 -->
+<interface>
+ <requires lib="gtk+" version="3.10"/>
+ <object class="GtkWindow" id="palette_popup_window">
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkBox" id="box1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkBox" id="box2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkComboBox" id="palette_list_combobox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="has_entry">True</property>
+ <child internal-child="entry">
+ <object class="GtkEntry" id="combobox-entry">
+ <property name="can_focus">False</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="color_picker_button">
+ <property name="label">Palette</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="svxlo-SvxColorValueSet" id="colorset">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/vcl/source/window/floatwin.cxx b/vcl/source/window/floatwin.cxx
index a77c38f56a49..178843f02d25 100644
--- a/vcl/source/window/floatwin.cxx
+++ b/vcl/source/window/floatwin.cxx
@@ -152,6 +152,13 @@ FloatingWindow::FloatingWindow( Window* pParent, WinBits nStyle ) :
ImplInit( pParent, nStyle );
}
+FloatingWindow::FloatingWindow( Window* pParent, const OString& rID, const OUString& rUIXMLDescription, WinBits nStyle ) :
+ SystemWindow( WINDOW_FLOATINGWINDOW )
+{
+ ImplInit( pParent, nStyle );
+ m_pUIBuilder = new VclBuilder(this, getUIRootDir(), rUIXMLDescription, rID);
+}
+
FloatingWindow::FloatingWindow( Window* pParent, const ResId& rResId ) :
SystemWindow( WINDOW_FLOATINGWINDOW )
{
@@ -815,4 +822,33 @@ void FloatingWindow::AddPopupModeWindow( Window* pWindow )
mpFirstPopupModeWin = pWindow;
}
+
+Size FloatingWindow::GetOptimalSize() const
+{
+ if (isLayoutEnabled(this))
+ return VclContainer::getLayoutRequisition(*GetWindow(WINDOW_FIRSTCHILD));
+ return getLegacyBestSizeForChildren(*this);
+}
+
+void FloatingWindow::SetPosSizePixel(const Point& rAllocPos, const Size& rAllocation)
+{
+ Window::SetPosSizePixel(rAllocPos, rAllocation);
+ if (isLayoutEnabled(this))
+ VclContainer::setLayoutAllocation(*GetWindow(WINDOW_FIRSTCHILD), Point(0, 0), rAllocation);
+}
+
+void FloatingWindow::SetSizePixel(const Size& rAllocation)
+{
+ Window::SetSizePixel(rAllocation);
+ if (isLayoutEnabled(this))
+ VclContainer::setLayoutAllocation(*GetWindow(WINDOW_FIRSTCHILD), Point(0, 0), rAllocation);
+}
+
+void FloatingWindow::SetPosPixel(const Point& rAllocPos)
+{
+ Window::SetPosPixel(rAllocPos);
+ if (isLayoutEnabled(this))
+ VclContainer::setLayoutAllocation(*GetWindow(WINDOW_FIRSTCHILD), Point(0, 0), GetOutputSizePixel());
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */