let menu button launch arbitrary floating windows
and not just menus, this is like how the gtk equivalent can launch popovers Change-Id: I53ae96aab0c51d75405dba15ab8080d7315471e3
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
#include <vcl/button.hxx>
|
#include <vcl/button.hxx>
|
||||||
#include <vcl/dllapi.h>
|
#include <vcl/dllapi.h>
|
||||||
|
|
||||||
|
class FloatingWindow;
|
||||||
class Timer;
|
class Timer;
|
||||||
class PopupMenu;
|
class PopupMenu;
|
||||||
class VclBuilder;
|
class VclBuilder;
|
||||||
@@ -35,6 +36,7 @@ private:
|
|||||||
|
|
||||||
Timer* mpMenuTimer;
|
Timer* mpMenuTimer;
|
||||||
VclPtr<PopupMenu> mpMenu;
|
VclPtr<PopupMenu> mpMenu;
|
||||||
|
VclPtr<FloatingWindow> mpFloatingWindow;
|
||||||
sal_uInt16 mnCurItemId;
|
sal_uInt16 mnCurItemId;
|
||||||
bool mbDelayMenu;
|
bool mbDelayMenu;
|
||||||
Link<MenuButton*,void> maActivateHdl;
|
Link<MenuButton*,void> maActivateHdl;
|
||||||
@@ -70,9 +72,12 @@ public:
|
|||||||
//before being shown
|
//before being shown
|
||||||
void SetDelayMenu(bool bDelay) { mbDelayMenu = bDelay; }
|
void SetDelayMenu(bool bDelay) { mbDelayMenu = bDelay; }
|
||||||
|
|
||||||
void SetPopupMenu( PopupMenu* pNewMenu );
|
void SetPopupMenu(PopupMenu* pNewMenu);
|
||||||
PopupMenu* GetPopupMenu() const { return mpMenu; }
|
PopupMenu* GetPopupMenu() const { return mpMenu; }
|
||||||
|
|
||||||
|
void SetPopover(FloatingWindow* pFloatingWindow);
|
||||||
|
FloatingWindow* GetPopover() const { return mpFloatingWindow; }
|
||||||
|
|
||||||
sal_uInt16 GetCurItemId() const { return mnCurItemId; }
|
sal_uInt16 GetCurItemId() const { return mnCurItemId; }
|
||||||
OString GetCurItemIdent() const;
|
OString GetCurItemIdent() const;
|
||||||
|
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
#include <tools/rc.h>
|
#include <tools/rc.h>
|
||||||
#include <vcl/decoview.hxx>
|
#include <vcl/decoview.hxx>
|
||||||
#include <vcl/event.hxx>
|
#include <vcl/event.hxx>
|
||||||
|
#include <vcl/floatwin.hxx>
|
||||||
#include <vcl/menu.hxx>
|
#include <vcl/menu.hxx>
|
||||||
#include <vcl/timer.hxx>
|
#include <vcl/timer.hxx>
|
||||||
#include <vcl/menubtn.hxx>
|
#include <vcl/menubtn.hxx>
|
||||||
@@ -39,20 +40,29 @@ void MenuButton::ExecuteMenu()
|
|||||||
{
|
{
|
||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
if ( mpMenu )
|
if (!mpMenu && !mpFloatingWindow)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Size aSize = GetSizePixel();
|
||||||
|
SetPressed( true );
|
||||||
|
EndSelection();
|
||||||
|
if (mpMenu)
|
||||||
{
|
{
|
||||||
Point aPos( 0, 1 );
|
Point aPos(0, 1);
|
||||||
Size aSize = GetSizePixel();
|
Rectangle aRect(aPos, aSize );
|
||||||
Rectangle aRect( aPos, aSize );
|
mnCurItemId = mpMenu->Execute(this, aRect, PopupMenuFlags::ExecuteDown);
|
||||||
SetPressed( true );
|
}
|
||||||
EndSelection();
|
else
|
||||||
mnCurItemId = mpMenu->Execute( this, aRect, PopupMenuFlags::ExecuteDown );
|
{
|
||||||
SetPressed( false );
|
Point aPos(GetParent()->OutputToScreenPixel(GetPosPixel()));
|
||||||
if ( mnCurItemId )
|
Rectangle aRect(aPos, aSize );
|
||||||
{
|
mpFloatingWindow->StartPopupMode(aRect, FloatWinPopupFlags::Down | FloatWinPopupFlags::GrabFocus);
|
||||||
Select();
|
}
|
||||||
mnCurItemId = 0;
|
SetPressed(false);
|
||||||
}
|
if (mnCurItemId)
|
||||||
|
{
|
||||||
|
Select();
|
||||||
|
mnCurItemId = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,7 +162,7 @@ void MenuButton::Select()
|
|||||||
maSelectHdl.Call( this );
|
maSelectHdl.Call( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuButton::SetPopupMenu( PopupMenu* pNewMenu )
|
void MenuButton::SetPopupMenu(PopupMenu* pNewMenu)
|
||||||
{
|
{
|
||||||
if (pNewMenu == mpMenu)
|
if (pNewMenu == mpMenu)
|
||||||
return;
|
return;
|
||||||
@@ -160,6 +170,14 @@ void MenuButton::SetPopupMenu( PopupMenu* pNewMenu )
|
|||||||
mpMenu = pNewMenu;
|
mpMenu = pNewMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MenuButton::SetPopover(FloatingWindow* pFloatingWindow)
|
||||||
|
{
|
||||||
|
if (pFloatingWindow == mpFloatingWindow)
|
||||||
|
return;
|
||||||
|
|
||||||
|
mpFloatingWindow = pFloatingWindow;
|
||||||
|
}
|
||||||
|
|
||||||
//class MenuToggleButton ----------------------------------------------------
|
//class MenuToggleButton ----------------------------------------------------
|
||||||
|
|
||||||
MenuToggleButton::MenuToggleButton( vcl::Window* pParent, WinBits nWinBits )
|
MenuToggleButton::MenuToggleButton( vcl::Window* pParent, WinBits nWinBits )
|
||||||
|
Reference in New Issue
Block a user