Implemented tearoff menus, please see my posting to wxwin-developers.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2812 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -618,7 +618,13 @@ enum wxOrientation
|
|||||||
*/
|
*/
|
||||||
// use native docking
|
// use native docking
|
||||||
#define wxMB_DOCKABLE 0x0001
|
#define wxMB_DOCKABLE 0x0001
|
||||||
|
// make all menus tearoff menus, even if not set on per-menu basis
|
||||||
|
#define wxMB_TEAROFF 0x0002
|
||||||
|
|
||||||
|
/*
|
||||||
|
* wxMenu style flags
|
||||||
|
*/
|
||||||
|
#define wxMENU_TEAROFF 0x0001
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Apply to all panel items
|
* Apply to all panel items
|
||||||
|
@@ -100,6 +100,9 @@ enum wxStockCursor
|
|||||||
wxCURSOR_WAIT,
|
wxCURSOR_WAIT,
|
||||||
wxCURSOR_WATCH,
|
wxCURSOR_WATCH,
|
||||||
wxCURSOR_BLANK,
|
wxCURSOR_BLANK,
|
||||||
|
#ifdef __WXGTK__
|
||||||
|
wxCURSOR_DEFAULT, // standard X11 cursor
|
||||||
|
#endif
|
||||||
#ifdef __X__
|
#ifdef __X__
|
||||||
// Not yet implemented for Windows
|
// Not yet implemented for Windows
|
||||||
wxCURSOR_CROSS_REVERSE,
|
wxCURSOR_CROSS_REVERSE,
|
||||||
|
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
#include "wx/defs.h"
|
#include "wx/defs.h"
|
||||||
|
|
||||||
#if wxUSE_CHOICE
|
|
||||||
|
|
||||||
#include "wx/object.h"
|
#include "wx/object.h"
|
||||||
#include "wx/list.h"
|
#include "wx/list.h"
|
||||||
#include "wx/control.h"
|
#include "wx/control.h"
|
||||||
@@ -99,6 +97,5 @@ public:
|
|||||||
void ApplyWidgetStyle();
|
void ApplyWidgetStyle();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // __GTKCHOICEH__
|
#endif // __GTKCHOICEH__
|
||||||
|
@@ -100,6 +100,7 @@ public:
|
|||||||
GtkItemFactory *m_factory;
|
GtkItemFactory *m_factory;
|
||||||
wxList m_menus;
|
wxList m_menus;
|
||||||
GtkWidget *m_menubar;
|
GtkWidget *m_menubar;
|
||||||
|
long m_style;
|
||||||
};
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -112,7 +113,9 @@ class wxMenu : public wxEvtHandler
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
wxMenu( const wxString& title = wxEmptyString,
|
wxMenu( const wxString& title = wxEmptyString,
|
||||||
const wxFunction func = (wxFunction) NULL );
|
const wxFunction func = (wxFunction) NULL,
|
||||||
|
long style = 0);
|
||||||
|
wxMenu( long style );
|
||||||
~wxMenu();
|
~wxMenu();
|
||||||
|
|
||||||
// operations
|
// operations
|
||||||
@@ -182,7 +185,13 @@ public:
|
|||||||
GtkAccelGroup *m_accel;
|
GtkAccelGroup *m_accel;
|
||||||
GtkItemFactory *m_factory;
|
GtkItemFactory *m_factory;
|
||||||
|
|
||||||
|
// used by wxMenuBar
|
||||||
|
inline long GetStyle(void) const { return m_style; }
|
||||||
private:
|
private:
|
||||||
|
// common code for both constructors:
|
||||||
|
void Init( const wxString& title,
|
||||||
|
const wxFunction func,
|
||||||
|
long style);
|
||||||
|
|
||||||
wxString m_title;
|
wxString m_title;
|
||||||
wxList m_items;
|
wxList m_items;
|
||||||
@@ -190,6 +199,7 @@ private:
|
|||||||
wxFunction m_callback;
|
wxFunction m_callback;
|
||||||
wxEvtHandler *m_eventHandler;
|
wxEvtHandler *m_eventHandler;
|
||||||
void *m_clientData;
|
void *m_clientData;
|
||||||
|
long m_style;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __GTKMENUH__
|
#endif // __GTKMENUH__
|
||||||
|
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
#include "wx/defs.h"
|
#include "wx/defs.h"
|
||||||
|
|
||||||
#if wxUSE_CHOICE
|
|
||||||
|
|
||||||
#include "wx/object.h"
|
#include "wx/object.h"
|
||||||
#include "wx/list.h"
|
#include "wx/list.h"
|
||||||
#include "wx/control.h"
|
#include "wx/control.h"
|
||||||
@@ -99,6 +97,5 @@ public:
|
|||||||
void ApplyWidgetStyle();
|
void ApplyWidgetStyle();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // __GTKCHOICEH__
|
#endif // __GTKCHOICEH__
|
||||||
|
@@ -100,6 +100,7 @@ public:
|
|||||||
GtkItemFactory *m_factory;
|
GtkItemFactory *m_factory;
|
||||||
wxList m_menus;
|
wxList m_menus;
|
||||||
GtkWidget *m_menubar;
|
GtkWidget *m_menubar;
|
||||||
|
long m_style;
|
||||||
};
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -112,7 +113,9 @@ class wxMenu : public wxEvtHandler
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
wxMenu( const wxString& title = wxEmptyString,
|
wxMenu( const wxString& title = wxEmptyString,
|
||||||
const wxFunction func = (wxFunction) NULL );
|
const wxFunction func = (wxFunction) NULL,
|
||||||
|
long style = 0);
|
||||||
|
wxMenu( long style );
|
||||||
~wxMenu();
|
~wxMenu();
|
||||||
|
|
||||||
// operations
|
// operations
|
||||||
@@ -182,7 +185,13 @@ public:
|
|||||||
GtkAccelGroup *m_accel;
|
GtkAccelGroup *m_accel;
|
||||||
GtkItemFactory *m_factory;
|
GtkItemFactory *m_factory;
|
||||||
|
|
||||||
|
// used by wxMenuBar
|
||||||
|
inline long GetStyle(void) const { return m_style; }
|
||||||
private:
|
private:
|
||||||
|
// common code for both constructors:
|
||||||
|
void Init( const wxString& title,
|
||||||
|
const wxFunction func,
|
||||||
|
long style);
|
||||||
|
|
||||||
wxString m_title;
|
wxString m_title;
|
||||||
wxList m_items;
|
wxList m_items;
|
||||||
@@ -190,6 +199,7 @@ private:
|
|||||||
wxFunction m_callback;
|
wxFunction m_callback;
|
||||||
wxEvtHandler *m_eventHandler;
|
wxEvtHandler *m_eventHandler;
|
||||||
void *m_clientData;
|
void *m_clientData;
|
||||||
|
long m_style;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __GTKMENUH__
|
#endif // __GTKMENUH__
|
||||||
|
@@ -149,14 +149,14 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
|||||||
SetIcon(wxICON(mondrian));
|
SetIcon(wxICON(mondrian));
|
||||||
|
|
||||||
// create a menu bar
|
// create a menu bar
|
||||||
wxMenu *menuFile = new wxMenu;
|
wxMenu *menuFile = new wxMenu("File",NULL,wxMENU_TEAROFF);
|
||||||
|
|
||||||
menuFile->Append(Minimal_About, "&About...\tCtrl-A", "Show about dialog");
|
menuFile->Append(Minimal_About, "&About...\tCtrl-A", "Show about dialog");
|
||||||
menuFile->AppendSeparator();
|
menuFile->AppendSeparator();
|
||||||
menuFile->Append(Minimal_Quit, "E&xit\tAlt-X", "Quit this program");
|
menuFile->Append(Minimal_Quit, "E&xit\tAlt-X", "Quit this program");
|
||||||
|
|
||||||
// now append the freshly created menu to the menu bar...
|
// now append the freshly created menu to the menu bar...
|
||||||
wxMenuBar *menuBar = new wxMenuBar;
|
wxMenuBar *menuBar = new wxMenuBar();
|
||||||
menuBar->Append(menuFile, "&File");
|
menuBar->Append(menuFile, "&File");
|
||||||
|
|
||||||
// ... and attach this menu bar to the frame
|
// ... and attach this menu bar to the frame
|
||||||
|
@@ -44,6 +44,8 @@
|
|||||||
// global data
|
// global data
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
extern wxCursor g_globalCursor;
|
||||||
|
|
||||||
wxApp *wxTheApp = (wxApp *) NULL;
|
wxApp *wxTheApp = (wxApp *) NULL;
|
||||||
wxAppInitializerFunction wxApp::m_appInitFn = (wxAppInitializerFunction) NULL;
|
wxAppInitializerFunction wxApp::m_appInitFn = (wxAppInitializerFunction) NULL;
|
||||||
|
|
||||||
@@ -575,8 +577,7 @@ bool wxApp::Initialize()
|
|||||||
|
|
||||||
wxImage::InitStandardHandlers();
|
wxImage::InitStandardHandlers();
|
||||||
|
|
||||||
/* no global cursor under X
|
g_globalCursor = wxCursor(wxCURSOR_DEFAULT);
|
||||||
g_globalCursor = new wxCursor; */
|
|
||||||
|
|
||||||
wxModule::RegisterModules();
|
wxModule::RegisterModules();
|
||||||
if (!wxModule::InitializeModules()) return FALSE;
|
if (!wxModule::InitializeModules()) return FALSE;
|
||||||
|
@@ -64,6 +64,7 @@ wxCursor::wxCursor( int cursorId )
|
|||||||
GdkCursorType gdk_cur = GDK_LEFT_PTR;
|
GdkCursorType gdk_cur = GDK_LEFT_PTR;
|
||||||
switch (cursorId)
|
switch (cursorId)
|
||||||
{
|
{
|
||||||
|
case wxCURSOR_DEFAULT: gdk_cur = GDK_X_CURSOR; break;
|
||||||
case wxCURSOR_HAND: gdk_cur = GDK_HAND1; break;
|
case wxCURSOR_HAND: gdk_cur = GDK_HAND1; break;
|
||||||
case wxCURSOR_CROSS: gdk_cur = GDK_CROSSHAIR; break;
|
case wxCURSOR_CROSS: gdk_cur = GDK_CROSSHAIR; break;
|
||||||
case wxCURSOR_SIZEWE: gdk_cur = GDK_SB_H_DOUBLE_ARROW; break;
|
case wxCURSOR_SIZEWE: gdk_cur = GDK_SB_H_DOUBLE_ARROW; break;
|
||||||
|
@@ -37,6 +37,7 @@ wxMenuBar::wxMenuBar( long style )
|
|||||||
{
|
{
|
||||||
/* the parent window is known after wxFrame::SetMenu() */
|
/* the parent window is known after wxFrame::SetMenu() */
|
||||||
m_needParent = FALSE;
|
m_needParent = FALSE;
|
||||||
|
m_style = style;
|
||||||
|
|
||||||
PreCreation( (wxWindow *) NULL, -1, wxDefaultPosition, wxDefaultSize, style, "menu" );
|
PreCreation( (wxWindow *) NULL, -1, wxDefaultPosition, wxDefaultSize, style, "menu" );
|
||||||
|
|
||||||
@@ -69,6 +70,7 @@ wxMenuBar::wxMenuBar()
|
|||||||
{
|
{
|
||||||
/* the parent window is known after wxFrame::SetMenu() */
|
/* the parent window is known after wxFrame::SetMenu() */
|
||||||
m_needParent = FALSE;
|
m_needParent = FALSE;
|
||||||
|
m_style = 0;
|
||||||
|
|
||||||
PreCreation( (wxWindow *) NULL, -1, wxDefaultPosition, wxDefaultSize, 0, "menu" );
|
PreCreation( (wxWindow *) NULL, -1, wxDefaultPosition, wxDefaultSize, 0, "menu" );
|
||||||
|
|
||||||
@@ -216,7 +218,9 @@ void wxMenuBar::Append( wxMenu *menu, const wxString &title )
|
|||||||
entry.accelerator = (gchar*) NULL;
|
entry.accelerator = (gchar*) NULL;
|
||||||
entry.callback = (GtkItemFactoryCallback) NULL;
|
entry.callback = (GtkItemFactoryCallback) NULL;
|
||||||
entry.callback_action = 0;
|
entry.callback_action = 0;
|
||||||
entry.item_type = "<Branch>";
|
entry.item_type = (m_style & wxMB_TEAROFF || menu->GetStyle() &
|
||||||
|
wxMENU_TEAROFF) ?
|
||||||
|
"<Tearoff>" : "<Branch>";
|
||||||
|
|
||||||
gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */
|
gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */
|
||||||
|
|
||||||
@@ -632,11 +636,23 @@ bool wxMenuItem::IsChecked() const
|
|||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxMenu,wxEvtHandler)
|
IMPLEMENT_DYNAMIC_CLASS(wxMenu,wxEvtHandler)
|
||||||
|
|
||||||
wxMenu::wxMenu( const wxString& title, const wxFunction func )
|
wxMenu::wxMenu( const wxString& title, const wxFunction func, long style )
|
||||||
|
{
|
||||||
|
Init(title, func, style);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxMenu::wxMenu(long style)
|
||||||
|
{
|
||||||
|
Init(wxEmptyString, (wxFunction) NULL, style);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
wxMenu::Init( const wxString& title, const wxFunction func, long style )
|
||||||
{
|
{
|
||||||
m_title = title;
|
m_title = title;
|
||||||
m_items.DeleteContents( TRUE );
|
m_items.DeleteContents( TRUE );
|
||||||
m_invokingWindow = (wxWindow *) NULL;
|
m_invokingWindow = (wxWindow *) NULL;
|
||||||
|
m_style = style;
|
||||||
|
|
||||||
#if (GTK_MINOR_VERSION > 0)
|
#if (GTK_MINOR_VERSION > 0)
|
||||||
m_accel = gtk_accel_group_new();
|
m_accel = gtk_accel_group_new();
|
||||||
@@ -829,7 +845,7 @@ void wxMenu::Append( int id, const wxString &item, wxMenu *subMenu, const wxStri
|
|||||||
entry.path = buf;
|
entry.path = buf;
|
||||||
entry.callback = (GtkItemFactoryCallback) 0;
|
entry.callback = (GtkItemFactoryCallback) 0;
|
||||||
entry.callback_action = 0;
|
entry.callback_action = 0;
|
||||||
entry.item_type = "<Branch>";
|
entry.item_type = (m_style & wxMENU_TEAROFF) ? "<Tearoff>" : "<Branch>";
|
||||||
|
|
||||||
gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */
|
gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */
|
||||||
|
|
||||||
|
@@ -44,6 +44,8 @@
|
|||||||
// global data
|
// global data
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
extern wxCursor g_globalCursor;
|
||||||
|
|
||||||
wxApp *wxTheApp = (wxApp *) NULL;
|
wxApp *wxTheApp = (wxApp *) NULL;
|
||||||
wxAppInitializerFunction wxApp::m_appInitFn = (wxAppInitializerFunction) NULL;
|
wxAppInitializerFunction wxApp::m_appInitFn = (wxAppInitializerFunction) NULL;
|
||||||
|
|
||||||
@@ -575,8 +577,7 @@ bool wxApp::Initialize()
|
|||||||
|
|
||||||
wxImage::InitStandardHandlers();
|
wxImage::InitStandardHandlers();
|
||||||
|
|
||||||
/* no global cursor under X
|
g_globalCursor = wxCursor(wxCURSOR_DEFAULT);
|
||||||
g_globalCursor = new wxCursor; */
|
|
||||||
|
|
||||||
wxModule::RegisterModules();
|
wxModule::RegisterModules();
|
||||||
if (!wxModule::InitializeModules()) return FALSE;
|
if (!wxModule::InitializeModules()) return FALSE;
|
||||||
|
@@ -64,6 +64,7 @@ wxCursor::wxCursor( int cursorId )
|
|||||||
GdkCursorType gdk_cur = GDK_LEFT_PTR;
|
GdkCursorType gdk_cur = GDK_LEFT_PTR;
|
||||||
switch (cursorId)
|
switch (cursorId)
|
||||||
{
|
{
|
||||||
|
case wxCURSOR_DEFAULT: gdk_cur = GDK_X_CURSOR; break;
|
||||||
case wxCURSOR_HAND: gdk_cur = GDK_HAND1; break;
|
case wxCURSOR_HAND: gdk_cur = GDK_HAND1; break;
|
||||||
case wxCURSOR_CROSS: gdk_cur = GDK_CROSSHAIR; break;
|
case wxCURSOR_CROSS: gdk_cur = GDK_CROSSHAIR; break;
|
||||||
case wxCURSOR_SIZEWE: gdk_cur = GDK_SB_H_DOUBLE_ARROW; break;
|
case wxCURSOR_SIZEWE: gdk_cur = GDK_SB_H_DOUBLE_ARROW; break;
|
||||||
|
@@ -37,6 +37,7 @@ wxMenuBar::wxMenuBar( long style )
|
|||||||
{
|
{
|
||||||
/* the parent window is known after wxFrame::SetMenu() */
|
/* the parent window is known after wxFrame::SetMenu() */
|
||||||
m_needParent = FALSE;
|
m_needParent = FALSE;
|
||||||
|
m_style = style;
|
||||||
|
|
||||||
PreCreation( (wxWindow *) NULL, -1, wxDefaultPosition, wxDefaultSize, style, "menu" );
|
PreCreation( (wxWindow *) NULL, -1, wxDefaultPosition, wxDefaultSize, style, "menu" );
|
||||||
|
|
||||||
@@ -69,6 +70,7 @@ wxMenuBar::wxMenuBar()
|
|||||||
{
|
{
|
||||||
/* the parent window is known after wxFrame::SetMenu() */
|
/* the parent window is known after wxFrame::SetMenu() */
|
||||||
m_needParent = FALSE;
|
m_needParent = FALSE;
|
||||||
|
m_style = 0;
|
||||||
|
|
||||||
PreCreation( (wxWindow *) NULL, -1, wxDefaultPosition, wxDefaultSize, 0, "menu" );
|
PreCreation( (wxWindow *) NULL, -1, wxDefaultPosition, wxDefaultSize, 0, "menu" );
|
||||||
|
|
||||||
@@ -216,7 +218,9 @@ void wxMenuBar::Append( wxMenu *menu, const wxString &title )
|
|||||||
entry.accelerator = (gchar*) NULL;
|
entry.accelerator = (gchar*) NULL;
|
||||||
entry.callback = (GtkItemFactoryCallback) NULL;
|
entry.callback = (GtkItemFactoryCallback) NULL;
|
||||||
entry.callback_action = 0;
|
entry.callback_action = 0;
|
||||||
entry.item_type = "<Branch>";
|
entry.item_type = (m_style & wxMB_TEAROFF || menu->GetStyle() &
|
||||||
|
wxMENU_TEAROFF) ?
|
||||||
|
"<Tearoff>" : "<Branch>";
|
||||||
|
|
||||||
gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */
|
gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */
|
||||||
|
|
||||||
@@ -632,11 +636,23 @@ bool wxMenuItem::IsChecked() const
|
|||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxMenu,wxEvtHandler)
|
IMPLEMENT_DYNAMIC_CLASS(wxMenu,wxEvtHandler)
|
||||||
|
|
||||||
wxMenu::wxMenu( const wxString& title, const wxFunction func )
|
wxMenu::wxMenu( const wxString& title, const wxFunction func, long style )
|
||||||
|
{
|
||||||
|
Init(title, func, style);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxMenu::wxMenu(long style)
|
||||||
|
{
|
||||||
|
Init(wxEmptyString, (wxFunction) NULL, style);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
wxMenu::Init( const wxString& title, const wxFunction func, long style )
|
||||||
{
|
{
|
||||||
m_title = title;
|
m_title = title;
|
||||||
m_items.DeleteContents( TRUE );
|
m_items.DeleteContents( TRUE );
|
||||||
m_invokingWindow = (wxWindow *) NULL;
|
m_invokingWindow = (wxWindow *) NULL;
|
||||||
|
m_style = style;
|
||||||
|
|
||||||
#if (GTK_MINOR_VERSION > 0)
|
#if (GTK_MINOR_VERSION > 0)
|
||||||
m_accel = gtk_accel_group_new();
|
m_accel = gtk_accel_group_new();
|
||||||
@@ -829,7 +845,7 @@ void wxMenu::Append( int id, const wxString &item, wxMenu *subMenu, const wxStri
|
|||||||
entry.path = buf;
|
entry.path = buf;
|
||||||
entry.callback = (GtkItemFactoryCallback) 0;
|
entry.callback = (GtkItemFactoryCallback) 0;
|
||||||
entry.callback_action = 0;
|
entry.callback_action = 0;
|
||||||
entry.item_type = "<Branch>";
|
entry.item_type = (m_style & wxMENU_TEAROFF) ? "<Tearoff>" : "<Branch>";
|
||||||
|
|
||||||
gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */
|
gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user