include/sfx2/tbxctrl.hxx | 6 ++ include/vcl/floatwin.hxx | 13 ++++ sfx2/source/toolbox/tbxitem.cxx | 20 +++++++ svx/UIConfig_svx.mk | 1 svx/source/tbxctrls/colorwindow.hxx | 19 +++--- svx/source/tbxctrls/tbcontrl.cxx | 98 ++++++++++++++++-------------------- svx/uiconfig/ui/colorwindow.ui | 68 ++++++++++++++++++++++++ vcl/source/window/floatwin.cxx | 36 +++++++++++++ 8 files changed, 198 insertions(+), 63 deletions(-)
New commits: commit 01a74e6707ee7b7b2f5494d7a12c45aa3390b0a4 Author: Krisztian Pinter <pin.termina...@gmail.com> Date: Mon Jul 21 16:34:30 2014 +0200 Convert SvxColorWindow_Impl to Widget Layout Change-Id: I8c830de56892fd8eb1c14add25f65c25046d47fd diff --git a/include/sfx2/tbxctrl.hxx b/include/sfx2/tbxctrl.hxx index df4eb2b..d752600 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 62d0086..b65668e 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; @@ -64,7 +67,9 @@ class ToolBox; // - FloatingWindow - -class VCL_DLLPUBLIC FloatingWindow : public SystemWindow +class VCL_DLLPUBLIC FloatingWindow + : public SystemWindow + , public VclBuilderContainer { class ImplData; private: @@ -117,6 +122,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(); @@ -146,6 +152,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 2b4efb0..26c6341 100644 --- a/sfx2/source/toolbox/tbxitem.cxx +++ b/sfx2/source/toolbox/tbxitem.cxx @@ -1200,6 +1200,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 5388669..71036bf 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 086cdef..2f2d318 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 cf6de14..6ede5b2 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -1072,6 +1072,7 @@ void SvxFontNameBox_Impl::Select() #define WB_NO_DIRECTSELECT ((WinBits)0x04000000) #endif + SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand, PaletteManager& rPaletteManager, sal_uInt16 nSlotId, @@ -1079,23 +1080,26 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand, 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 ) { @@ -1108,45 +1112,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() @@ -1155,7 +1157,7 @@ SvxColorWindow_Impl::~SvxColorWindow_Impl() void SvxColorWindow_Impl::KeyInput( const KeyEvent& rKEvt ) { - aColorSet.KeyInput(rKEvt); + mpColorSet->KeyInput(rKEvt); } SfxPopupWindow* SvxColorWindow_Impl::Clone() const @@ -1165,20 +1167,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(); @@ -1202,10 +1204,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; } @@ -1218,21 +1220,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() @@ -1246,11 +1240,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 ) ) @@ -1258,16 +1252,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 0000000..54b8f49 --- /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 5163b51..5e6dec9 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: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits