diff options
author | Kohei Yoshida <kohei.yoshida@suse.com> | 2011-11-18 15:26:58 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@suse.com> | 2011-11-18 15:26:58 -0500 |
commit | ab5c5c9d808a5f32d1646de9e1b5cab251b62269 (patch) | |
tree | 7f3c2dcd6977374070e6af9907e8f7d463abc8b3 | |
parent | de171082fc55fd52e35a0d0528d47c1ff89191f9 (diff) |
Fix painting of autofilter buttons.
-rw-r--r-- | sc/source/ui/cctrl/checklistmenu.cxx | 30 | ||||
-rw-r--r-- | sc/source/ui/inc/checklistmenu.hxx | 9 | ||||
-rw-r--r-- | sc/source/ui/inc/gridwin.hxx | 1 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin.cxx | 54 |
4 files changed, 59 insertions, 35 deletions
diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx index ba2e0a31280c..3835ab96cebd 100644 --- a/sc/source/ui/cctrl/checklistmenu.cxx +++ b/sc/source/ui/cctrl/checklistmenu.cxx @@ -104,7 +104,6 @@ ScMenuFloatingWindow::ScMenuFloatingWindow(Window* pParent, ScDocument* pDoc, sa SetFont(maLabelFont); SetText( OUString(RTL_CONSTASCII_USTRINGPARAM("ScMenuFloatingWindow")) ); - SetPopupModeEndHdl( LINK(this, ScMenuFloatingWindow, PopupEndHdl) ); } ScMenuFloatingWindow::~ScMenuFloatingWindow() @@ -112,6 +111,11 @@ ScMenuFloatingWindow::~ScMenuFloatingWindow() EndPopupMode(); } +void ScMenuFloatingWindow::PopupModeEnd() +{ + handlePopupEnd(); +} + void ScMenuFloatingWindow::MouseMove(const MouseEvent& rMEvt) { const Point& rPos = rMEvt.GetPosPixel(); @@ -261,6 +265,11 @@ ScMenuFloatingWindow* ScMenuFloatingWindow::addSubMenuItem(const OUString& rText return aItem.mpSubMenuWin.get(); } +void ScMenuFloatingWindow::handlePopupEnd() +{ + clearSelectedMenuItem(); +} + Size ScMenuFloatingWindow::getMenuSize() const { if (maMenuItems.empty()) @@ -736,12 +745,6 @@ void ScMenuFloatingWindow::terminateAllPopupMenus() mpParentMenu->terminateAllPopupMenus(); } -IMPL_LINK( ScMenuFloatingWindow, PopupEndHdl, void*, EMPTYARG ) -{ - clearSelectedMenuItem(); - return 0; -} - // ============================================================================ ScCheckListMenuWindow::Member::Member() : @@ -773,6 +776,7 @@ ScCheckListMenuWindow::ScCheckListMenuWindow(Window* pParent, ScDocument* pDoc) mnCurTabStop(0), mpExtendedData(NULL), mpOKAction(NULL), + mpPopupEndAction(NULL), maWndSize(200, 330), mePrevToggleAllState(STATE_DONTKNOW) { @@ -1224,4 +1228,16 @@ void ScCheckListMenuWindow::setOKAction(Action* p) mpOKAction.reset(p); } +void ScCheckListMenuWindow::setPopupEndAction(Action* p) +{ + mpPopupEndAction.reset(p); +} + +void ScCheckListMenuWindow::handlePopupEnd() +{ + clearSelectedMenuItem(); + if (mpPopupEndAction) + mpPopupEndAction->execute(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/checklistmenu.hxx b/sc/source/ui/inc/checklistmenu.hxx index 80b180fa358a..34b3be71cbef 100644 --- a/sc/source/ui/inc/checklistmenu.hxx +++ b/sc/source/ui/inc/checklistmenu.hxx @@ -66,6 +66,7 @@ public: explicit ScMenuFloatingWindow(Window* pParent, ScDocument* pDoc, sal_uInt16 nMenuStackLevel = 0); virtual ~ScMenuFloatingWindow(); + virtual void PopupModeEnd(); virtual void MouseMove(const MouseEvent& rMEvt); virtual void MouseButtonDown(const MouseEvent& rMEvt); virtual void MouseButtonUp(const MouseEvent& rMEvt); @@ -90,6 +91,7 @@ public: ScMenuFloatingWindow* getParentMenuWindow() const; protected: + virtual void handlePopupEnd(); Size getMenuSize() const; void drawMenuItem(size_t nPos); @@ -151,8 +153,6 @@ private: */ void terminateAllPopupMenus(); - DECL_LINK( PopupEndHdl, void* ); - private: struct MenuItemData @@ -249,6 +249,10 @@ public: ExtendedData* getExtendedData(); void setOKAction(Action* p); + void setPopupEndAction(Action* p); + +protected: + virtual void handlePopupEnd(); private: struct Member @@ -312,6 +316,7 @@ private: ::std::vector<Member> maMembers; boost::scoped_ptr<ExtendedData> mpExtendedData; boost::scoped_ptr<Action> mpOKAction; + boost::scoped_ptr<Action> mpPopupEndAction; Size maWndSize; /// whole window size. Size maMenuSize; /// size of all menu items combined. diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx index 7793bad09332..899b973295db 100644 --- a/sc/source/ui/inc/gridwin.hxx +++ b/sc/source/ui/inc/gridwin.hxx @@ -341,6 +341,7 @@ public: void DoScenarioMenue( const ScRange& rScenRange ); void LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow); + void RefreshAutoFilterButton(const ScAddress& rPos); void UpdateAutoFilterFromMenu(); void LaunchPageFieldMenu( SCCOL nCol, SCROW nRow ); diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 29d9bd304345..4a0d0c9bbd9c 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -607,13 +607,25 @@ class AutoFilterOKAction : public ScMenuFloatingWindow::Action ScGridWindow* mpWindow; public: AutoFilterOKAction(ScGridWindow* p) : mpWindow(p) {} - virtual void execute() { mpWindow->UpdateAutoFilterFromMenu(); } }; +class AutoFilterPopupEndAction : public ScMenuFloatingWindow::Action +{ + ScGridWindow* mpWindow; + ScAddress maPos; +public: + AutoFilterPopupEndAction(ScGridWindow* p, const ScAddress& rPos) : + mpWindow(p), maPos(rPos) {} + virtual void execute() + { + mpWindow->RefreshAutoFilterButton(maPos); + } +}; + class AddItemToEntry : public std::unary_function<rtl::OUString, void> { ScQueryEntry::QueryItemsType& mrItems; @@ -651,6 +663,8 @@ void ScGridWindow::LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow) mpAutoFilterPopup.reset(new ScCheckListMenuWindow(this, pDoc)); mpAutoFilterPopup->setOKAction(new AutoFilterOKAction(this)); + mpAutoFilterPopup->setPopupEndAction( + new AutoFilterPopupEndAction(this, ScAddress(nCol, nRow, nTab))); std::auto_ptr<AutoFilterData> pData(new AutoFilterData); pData->maPos = ScAddress(nCol, nRow, nTab); @@ -708,6 +722,19 @@ void ScGridWindow::LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow) mpAutoFilterPopup->launch(aCellRect); } +void ScGridWindow::RefreshAutoFilterButton(const ScAddress& rPos) +{ + if (mpFilterButton) + { + bool bFilterActive = IsAutoFilterActive(rPos.Col(), rPos.Row(), rPos.Tab()); + mpFilterButton->setHasHiddenMember(bFilterActive); + mpFilterButton->setPopupPressed(false); + HideCursor(); + mpFilterButton->draw(); + ShowCursor(); + } +} + void ScGridWindow::UpdateAutoFilterFromMenu() { const AutoFilterData* pData = @@ -1980,20 +2007,6 @@ void ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt ) if (nMouseStatus == SC_GM_FILTER) { - if ( pFilterBox && pFilterBox->GetMode() == SC_FILTERBOX_FILTER ) - { - if (mpFilterButton) - { - bool bFilterActive = IsAutoFilterActive( - pFilterBox->GetCol(), pFilterBox->GetRow(), pViewData->GetTabNo() ); - - mpFilterButton->setHasHiddenMember(bFilterActive); - mpFilterButton->setPopupPressed(false); - HideCursor(); - mpFilterButton->draw(); - ShowCursor(); - } - } nMouseStatus = SC_GM_NONE; ReleaseMouse(); return; // da muss nix mehr passieren @@ -2433,17 +2446,6 @@ void ScGridWindow::MouseMove( const MouseEvent& rMEvt ) { nButtonDown = 0; nMouseStatus = SC_GM_NONE; - if ( pFilterBox->GetMode() == SC_FILTERBOX_FILTER ) - { - if (mpFilterButton) - { - mpFilterButton->setHasHiddenMember(false); - mpFilterButton->setPopupPressed(false); - HideCursor(); - mpFilterButton->draw(); - ShowCursor(); - } - } ReleaseMouse(); pFilterBox->MouseButtonDown( MouseEvent( aRelPos, 1, MOUSE_SIMPLECLICK, MOUSE_LEFT ) ); return; |