diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-11-04 17:10:13 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-11-04 17:14:32 +0000 |
commit | f300754bb1c6a347c92bb9548be7a65237176542 (patch) | |
tree | e20edced9821fb8820f0adde86750301feed923c /reportdesign/source/ui/dlg/Condition.cxx | |
parent | 347c2c334589b18cc62af292674bb3df1dd54b71 (diff) |
replace OColorPopup with SvxColorWindow
Change-Id: I1aa06f70016b935bb13a0f6e93234eea10ba8b84
Diffstat (limited to 'reportdesign/source/ui/dlg/Condition.cxx')
-rw-r--r-- | reportdesign/source/ui/dlg/Condition.cxx | 174 |
1 files changed, 30 insertions, 144 deletions
diff --git a/reportdesign/source/ui/dlg/Condition.cxx b/reportdesign/source/ui/dlg/Condition.cxx index 3a216d81ea84..4632306d7b5e 100644 --- a/reportdesign/source/ui/dlg/Condition.cxx +++ b/reportdesign/source/ui/dlg/Condition.cxx @@ -84,144 +84,34 @@ IMPL_LINK( ConditionField, OnFormula, Button*, _pClickedButton, void ) } } -// TO-DO, this is yet another color selector, can it be replaced with SvxColorWindor/SvxColorToolBoxControl ? -#ifndef WB_NO_DIRECTSELECT -#define WB_NO_DIRECTSELECT ((WinBits)0x04000000) -#endif - -#define PALETTE_X 10 -#define PALETTE_Y 10 -#define PALETTE_SIZE (PALETTE_X * PALETTE_Y) -class OColorPopup : public FloatingWindow +ConditionColorWrapper::ConditionColorWrapper(Condition* pControl) + : mxControl(pControl) + , mnSlotId(0) { - DECL_LINK( SelectHdl, ValueSet*, void ); - VclPtr<Condition> m_pCondition; - sal_uInt16 m_nSlotId; -public: - OColorPopup(vcl::Window* _pParent,Condition* _pCondition); - virtual ~OColorPopup() override; - virtual void dispose() override; - VclPtr<ValueSet> m_aColorSet; - - virtual void KeyInput( const KeyEvent& rKEvt ) override; - virtual void Resize() override; - - void StartSelection(); - void SetSlotId(sal_uInt16 _nSlotId); -}; - -OColorPopup::OColorPopup(vcl::Window* _pParent,Condition* _pCondition) -:FloatingWindow(_pParent, WinBits( WB_BORDER | WB_STDFLOATWIN | WB_3DLOOK|WB_DIALOGCONTROL )) -,m_pCondition(_pCondition) -,m_nSlotId(0) -,m_aColorSet( VclPtr<ValueSet>::Create(this, WinBits( WB_ITEMBORDER | WB_NAMEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT)) ) -{ - m_aColorSet->SetHelpId( HID_RPT_POPUP_COLOR_CTRL ); - SetHelpId( HID_RPT_POPUP_COLOR ); - const Size aSize12( 13, 13 ); - short i = 0; - XColorListRef pColorList( XColorList::CreateStdColorList() ); - long nCount = pColorList->Count(); - Color aColWhite( COL_WHITE ); - OUString aStrWhite( ModuleRes(STR_COLOR_WHITE) ); - - if ( nCount > PALETTE_SIZE ) - // Show scrollbar if more than PALLETTE_SIZE colors are available - m_aColorSet->SetStyle( m_aColorSet->GetStyle() | WB_VSCROLL ); - - for ( i = 0; i < nCount; i++ ) - { - const XColorEntry* pEntry = pColorList->GetColor(i); - m_aColorSet->InsertItem( i+1, pEntry->GetColor(), pEntry->GetName() ); - } - - while ( i < PALETTE_SIZE ) - { - // fill empty elements if less then PALLETTE_SIZE colors are available - m_aColorSet->InsertItem( i+1, aColWhite, aStrWhite ); - i++; - } - - m_aColorSet->SetSelectHdl( LINK( this, OColorPopup, SelectHdl ) ); - m_aColorSet->SetColCount( PALETTE_X ); - m_aColorSet->SetLineCount( PALETTE_Y ); - Size aSize = m_aColorSet->CalcWindowSizePixel( aSize12 ); - aSize.Width() += 4; - aSize.Height() += 4; - SetOutputSizePixel( aSize ); - m_aColorSet->Show(); -} - -OColorPopup::~OColorPopup() -{ - disposeOnce(); -} - -void OColorPopup::dispose() -{ - disposeBuilder(); - m_aColorSet.disposeAndClear(); - m_pCondition.clear(); - FloatingWindow::dispose(); -} - -void OColorPopup::KeyInput( const KeyEvent& rKEvt ) -{ - m_aColorSet->KeyInput(rKEvt); } -void OColorPopup::Resize() +void ConditionColorWrapper::dispose() { - Size aSize = GetOutputSizePixel(); - aSize.Width() -= 4; - aSize.Height() -= 4; - m_aColorSet->SetPosSizePixel( Point(2,2), aSize ); + mxControl.clear(); } -void OColorPopup::StartSelection() +void ConditionColorWrapper::operator()(const OUString& /*rCommand*/, const NamedColor& rNamedColor) { - m_aColorSet->StartSelection(); + mxControl->ApplyCommand(mnSlotId, rNamedColor.first); } -void OColorPopup::SetSlotId(sal_uInt16 _nSlotId) -{ - m_nSlotId = _nSlotId; - if ( SID_ATTR_CHAR_COLOR_BACKGROUND == _nSlotId || SID_BACKGROUND_COLOR == _nSlotId ) - { - m_aColorSet->SetStyle( m_aColorSet->GetStyle() | WB_NONEFIELD ); - m_aColorSet->SetText( OUString(ModuleRes( STR_TRANSPARENT )) ); - } -} - -IMPL_LINK_NOARG(OColorPopup, SelectHdl, ValueSet*, void) -{ - sal_uInt16 nItemId = m_aColorSet->GetSelectItemId(); - Color aColor( nItemId == 0 ? Color( COL_TRANSPARENT ) : m_aColorSet->GetItemColor( nItemId ) ); - - /* #i33380# 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. */ - m_aColorSet->SetNoSelection(); - - if ( IsInPopupMode() ) - EndPopupMode(); - - m_pCondition->ApplyCommand( m_nSlotId, aColor ); -} - - // = Condition Condition::Condition( vcl::Window* _pParent, IConditionalFormatAction& _rAction, ::rptui::OReportController& _rController ) - :VclHBox(_pParent) - ,m_rController( _rController ) - ,m_rAction( _rAction ) - ,m_pColorFloat(nullptr) - ,m_pBtnUpdaterFontColor(nullptr) - ,m_pBtnUpdaterBackgroundColor(nullptr) - ,m_nCondIndex( 0 ) - ,m_bInDestruction( false ) + : VclHBox(_pParent) + , m_aColorWrapper(this) + , m_rController(_rController) + , m_rAction(_rAction) + , m_pBtnUpdaterFontColor(nullptr) + , m_pBtnUpdaterBackgroundColor(nullptr) + , m_nCondIndex(0) + , m_bInDestruction(false) { m_pUIBuilder = new VclBuilder(this, getUIRootDir(), "modules/dbreport/ui/conditionwin.ui"); @@ -328,31 +218,27 @@ void Condition::dispose() m_pAddCondition.clear(); m_pRemoveCondition.clear(); m_pColorFloat.disposeAndClear(); + m_aColorWrapper.dispose(); disposeBuilder(); VclHBox::dispose(); } -IMPL_LINK_NOARG( Condition, DropdownClick, ToolBox*, void ) +IMPL_LINK(Condition, DropdownClick, ToolBox*, pToolBox, void) { sal_uInt16 nId( m_pActions->GetCurItemId() ); - if ( !m_pColorFloat ) - m_pColorFloat = VclPtr<OColorPopup>::Create(m_pActions,this); - - sal_uInt16 nTextId = 0; - if (nId == m_nFontColorId) - { - nTextId = STR_CHARCOLOR; - } - else if (nId == m_nBackgroundColorId) - { - nTextId = STR_CHARBACKGROUND; - } - if ( nTextId ) - m_pColorFloat->SetText(OUString(ModuleRes(nTextId))); - m_pColorFloat->SetSlotId(mapToolbarItemToSlotId(nId)); - m_pColorFloat->SetPosPixel(m_pActions->GetItemPopupPosition(nId,m_pColorFloat->GetSizePixel())); - m_pColorFloat->StartPopupMode(m_pActions); - m_pColorFloat->StartSelection(); + m_pColorFloat.disposeAndClear(); + sal_uInt16 nSlotId(mapToolbarItemToSlotId(nId)); + m_aColorWrapper.SetSlotId(nSlotId); + m_pColorFloat = VclPtr<SvxColorWindow>::Create( + OUString() /*m_aCommandURL*/, + m_aPaletteManager, + m_aBorderColorStatus, + nSlotId, + nullptr, + pToolBox, + m_aColorWrapper); + + m_pColorFloat->StartPopupMode(pToolBox, FloatWinPopupFlags::GrabFocus); } IMPL_LINK_NOARG( Condition, OnFormatAction, ToolBox*, void ) |