diff options
author | Krisztian Pinter <pin.terminator@gmail.com> | 2014-07-21 16:34:30 +0200 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2014-09-17 10:19:40 +0200 |
commit | 65973c5eedc0da72fffca300239a149bd7fc1aa4 (patch) | |
tree | 13b8c13a5b7ceb32c1f200aa3e7a37d53d4b81ce /svx | |
parent | a1a52ee9fa916b4c0cc2493338ace2374c4d9563 (diff) |
Convert SvxColorWindow_Impl to Widget Layout
Change-Id: I8c830de56892fd8eb1c14add25f65c25046d47fd
Diffstat (limited to 'svx')
-rw-r--r-- | svx/UIConfig_svx.mk | 1 | ||||
-rw-r--r-- | svx/source/tbxctrls/colorwindow.hxx | 17 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbcontrl.cxx | 99 | ||||
-rw-r--r-- | svx/uiconfig/ui/colorwindow.ui | 68 |
4 files changed, 124 insertions, 61 deletions
diff --git a/svx/UIConfig_svx.mk b/svx/UIConfig_svx.mk index f313408bbee4..2e3cc8eb0780 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/datanavigator \ svx/uiconfig/ui/deleteheaderdialog \ diff --git a/svx/source/tbxctrls/colorwindow.hxx b/svx/source/tbxctrls/colorwindow.hxx index 702cf87ad3d7..df574d87993b 100644 --- a/svx/source/tbxctrls/colorwindow.hxx +++ b/svx/source/tbxctrls/colorwindow.hxx @@ -34,16 +34,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 theSlotId; + SvxColorValueSet* mpColorSet; + Size maWindowSize; + ComboBox* mpPaletteComboBox; + PushButton* mpButtonPicker; + OUString maCommand; + Link maSelectedLink; - const sal_uInt16 nButtonWidth; - const sal_uInt16 nButtonHeight; - PaletteManager& mrPaletteManager; + 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 f3bfbe5ef0a9..7031229a2fda 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -999,28 +999,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, pParentWindow, + "palette_popup_window", "svx/ui/colorwindow.ui", + rFrame ), + 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 ) { @@ -1033,45 +1038,43 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand, SfxItemState eState = aQueryStatus.QueryState( pDummy ); if( (SfxItemState::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() @@ -1080,7 +1083,7 @@ SvxColorWindow_Impl::~SvxColorWindow_Impl() void SvxColorWindow_Impl::KeyInput( const KeyEvent& rKEvt ) { - aColorSet.KeyInput(rKEvt); + mpColorSet->KeyInput(rKEvt); } SfxPopupWindow* SvxColorWindow_Impl::Clone() const @@ -1090,20 +1093,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(); @@ -1127,10 +1130,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; } @@ -1143,21 +1146,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() @@ -1171,11 +1166,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 ( SfxItemState::DEFAULT <= eState ) { - aColorSet.SetNoSelection(); + mpColorSet->SetNoSelection(); Color aColor; if ( pState->ISA( SvxColorItem ) ) @@ -1183,16 +1178,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> |