wxMenu ctor made compatible again
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3058 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -92,7 +92,7 @@ public:
|
|||||||
|
|
||||||
// implementation only
|
// implementation only
|
||||||
wxList& GetMenus() { return m_menus; }
|
wxList& GetMenus() { return m_menus; }
|
||||||
|
|
||||||
void SetInvokingWindow( wxWindow *win );
|
void SetInvokingWindow( wxWindow *win );
|
||||||
void UnsetInvokingWindow( wxWindow *win );
|
void UnsetInvokingWindow( wxWindow *win );
|
||||||
|
|
||||||
@@ -112,9 +112,17 @@ class wxMenu : public wxEvtHandler
|
|||||||
DECLARE_DYNAMIC_CLASS(wxMenu)
|
DECLARE_DYNAMIC_CLASS(wxMenu)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxMenu( const wxString& title = wxEmptyString,
|
#ifdef WXWIN_COMPATIBILITY
|
||||||
const wxFunction func = (wxFunction) NULL,
|
wxMenu( const wxString& title, const wxFunction func)
|
||||||
long style = 0);
|
{
|
||||||
|
Init(title, 0, func);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
wxMenu( const wxString& title = wxEmptyString, long style = 0 )
|
||||||
|
{
|
||||||
|
Init(title, style, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
wxMenu( long style );
|
wxMenu( long style );
|
||||||
~wxMenu();
|
~wxMenu();
|
||||||
|
|
||||||
@@ -172,6 +180,8 @@ public:
|
|||||||
// compatibility: these functions are deprecated
|
// compatibility: these functions are deprecated
|
||||||
bool Enabled(int id) const { return IsEnabled(id); }
|
bool Enabled(int id) const { return IsEnabled(id); }
|
||||||
bool Checked(int id) const { return IsChecked(id); }
|
bool Checked(int id) const { return IsChecked(id); }
|
||||||
|
|
||||||
|
wxFunction m_callback;
|
||||||
#endif // WXWIN_COMPATIBILITY
|
#endif // WXWIN_COMPATIBILITY
|
||||||
|
|
||||||
// implementation
|
// implementation
|
||||||
@@ -186,17 +196,20 @@ public:
|
|||||||
GtkItemFactory *m_factory;
|
GtkItemFactory *m_factory;
|
||||||
|
|
||||||
// used by wxMenuBar
|
// used by wxMenuBar
|
||||||
inline long GetStyle(void) const { return m_style; }
|
long GetStyle(void) const { return m_style; }
|
||||||
private:
|
|
||||||
|
private:
|
||||||
// common code for both constructors:
|
// common code for both constructors:
|
||||||
void Init( const wxString& title,
|
void Init( const wxString& title,
|
||||||
const wxFunction func,
|
long style
|
||||||
long style);
|
#ifdef WXWIN_COMPATIBILITY
|
||||||
|
, const wxFunction func
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
wxString m_title;
|
wxString m_title;
|
||||||
wxList m_items;
|
wxList m_items;
|
||||||
wxWindow *m_invokingWindow;
|
wxWindow *m_invokingWindow;
|
||||||
wxFunction m_callback;
|
|
||||||
wxEvtHandler *m_eventHandler;
|
wxEvtHandler *m_eventHandler;
|
||||||
void *m_clientData;
|
void *m_clientData;
|
||||||
long m_style;
|
long m_style;
|
||||||
|
@@ -92,7 +92,7 @@ public:
|
|||||||
|
|
||||||
// implementation only
|
// implementation only
|
||||||
wxList& GetMenus() { return m_menus; }
|
wxList& GetMenus() { return m_menus; }
|
||||||
|
|
||||||
void SetInvokingWindow( wxWindow *win );
|
void SetInvokingWindow( wxWindow *win );
|
||||||
void UnsetInvokingWindow( wxWindow *win );
|
void UnsetInvokingWindow( wxWindow *win );
|
||||||
|
|
||||||
@@ -112,9 +112,17 @@ class wxMenu : public wxEvtHandler
|
|||||||
DECLARE_DYNAMIC_CLASS(wxMenu)
|
DECLARE_DYNAMIC_CLASS(wxMenu)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxMenu( const wxString& title = wxEmptyString,
|
#ifdef WXWIN_COMPATIBILITY
|
||||||
const wxFunction func = (wxFunction) NULL,
|
wxMenu( const wxString& title, const wxFunction func)
|
||||||
long style = 0);
|
{
|
||||||
|
Init(title, 0, func);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
wxMenu( const wxString& title = wxEmptyString, long style = 0 )
|
||||||
|
{
|
||||||
|
Init(title, style, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
wxMenu( long style );
|
wxMenu( long style );
|
||||||
~wxMenu();
|
~wxMenu();
|
||||||
|
|
||||||
@@ -172,6 +180,8 @@ public:
|
|||||||
// compatibility: these functions are deprecated
|
// compatibility: these functions are deprecated
|
||||||
bool Enabled(int id) const { return IsEnabled(id); }
|
bool Enabled(int id) const { return IsEnabled(id); }
|
||||||
bool Checked(int id) const { return IsChecked(id); }
|
bool Checked(int id) const { return IsChecked(id); }
|
||||||
|
|
||||||
|
wxFunction m_callback;
|
||||||
#endif // WXWIN_COMPATIBILITY
|
#endif // WXWIN_COMPATIBILITY
|
||||||
|
|
||||||
// implementation
|
// implementation
|
||||||
@@ -186,17 +196,20 @@ public:
|
|||||||
GtkItemFactory *m_factory;
|
GtkItemFactory *m_factory;
|
||||||
|
|
||||||
// used by wxMenuBar
|
// used by wxMenuBar
|
||||||
inline long GetStyle(void) const { return m_style; }
|
long GetStyle(void) const { return m_style; }
|
||||||
private:
|
|
||||||
|
private:
|
||||||
// common code for both constructors:
|
// common code for both constructors:
|
||||||
void Init( const wxString& title,
|
void Init( const wxString& title,
|
||||||
const wxFunction func,
|
long style
|
||||||
long style);
|
#ifdef WXWIN_COMPATIBILITY
|
||||||
|
, const wxFunction func
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
wxString m_title;
|
wxString m_title;
|
||||||
wxList m_items;
|
wxList m_items;
|
||||||
wxWindow *m_invokingWindow;
|
wxWindow *m_invokingWindow;
|
||||||
wxFunction m_callback;
|
|
||||||
wxEvtHandler *m_eventHandler;
|
wxEvtHandler *m_eventHandler;
|
||||||
void *m_clientData;
|
void *m_clientData;
|
||||||
long m_style;
|
long m_style;
|
||||||
|
@@ -6,6 +6,8 @@
|
|||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
#include "wx/msw/helpwin.h"
|
#include "wx/msw/helpwin.h"
|
||||||
|
|
||||||
|
#undef wxHelpController
|
||||||
|
#undef sm_classwxHelpController
|
||||||
#define wxHelpController wxWinHelpController
|
#define wxHelpController wxWinHelpController
|
||||||
#define sm_classwxHelpController sm_classwxWinHelpController
|
#define sm_classwxHelpController sm_classwxWinHelpController
|
||||||
#else // !MSW
|
#else // !MSW
|
||||||
|
@@ -129,6 +129,8 @@ protected:
|
|||||||
int m_noItems;
|
int m_noItems;
|
||||||
int m_selected;
|
int m_selected;
|
||||||
|
|
||||||
|
virtual wxSize DoGetBestSize();
|
||||||
|
|
||||||
#if wxUSE_OWNER_DRAWN
|
#if wxUSE_OWNER_DRAWN
|
||||||
// control items
|
// control items
|
||||||
wxListBoxItemsArray m_aItems;
|
wxListBoxItemsArray m_aItems;
|
||||||
|
@@ -36,8 +36,20 @@ class WXDLLEXPORT wxMenu : public wxEvtHandler
|
|||||||
DECLARE_DYNAMIC_CLASS(wxMenu)
|
DECLARE_DYNAMIC_CLASS(wxMenu)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// ctor & dtor
|
// ctors & dtor
|
||||||
wxMenu(const wxString& title = wxEmptyString, const wxFunction func = NULL);
|
#ifdef WXWIN_COMPATIBILITY
|
||||||
|
wxMenu(const wxString& title,
|
||||||
|
const wxFunction func)
|
||||||
|
{
|
||||||
|
Init(title, func);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
wxMenu(const wxString& title = wxEmptyString, long WXUNUSED(style) = 0)
|
||||||
|
{
|
||||||
|
Init(title);
|
||||||
|
}
|
||||||
|
|
||||||
virtual ~wxMenu();
|
virtual ~wxMenu();
|
||||||
|
|
||||||
// construct menu
|
// construct menu
|
||||||
@@ -143,6 +155,13 @@ private:
|
|||||||
#endif // WXWIN_COMPATIBILITY
|
#endif // WXWIN_COMPATIBILITY
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// common part of all ctors
|
||||||
|
void Init(const wxString& title
|
||||||
|
#ifdef WXWIN_COMPATIBILITY
|
||||||
|
, const wxFunction func = NULL
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
bool m_doBreak;
|
bool m_doBreak;
|
||||||
|
|
||||||
// This is used when m_hMenu is NULL because we don't want to
|
// This is used when m_hMenu is NULL because we don't want to
|
||||||
|
@@ -501,15 +501,6 @@ static void gtk_menu_hilight_callback( GtkWidget *widget, wxMenu *menu )
|
|||||||
wxMenuEvent event( wxEVT_MENU_HIGHLIGHT, id );
|
wxMenuEvent event( wxEVT_MENU_HIGHLIGHT, id );
|
||||||
event.SetEventObject( menu );
|
event.SetEventObject( menu );
|
||||||
|
|
||||||
/* wxMSW doesn't call callback here either
|
|
||||||
|
|
||||||
if (menu->m_callback)
|
|
||||||
{
|
|
||||||
(void) (*(menu->m_callback)) (*menu, event);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (menu->GetEventHandler()->ProcessEvent(event))
|
if (menu->GetEventHandler()->ProcessEvent(event))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -646,7 +637,12 @@ wxMenu::wxMenu(long style)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
wxMenu::Init( const wxString& title, const wxFunction func, long style )
|
wxMenu::Init( const wxString& title,
|
||||||
|
long style,
|
||||||
|
#ifdef WXWIN_COMPATIBILITY
|
||||||
|
, const wxFunction func
|
||||||
|
#endif
|
||||||
|
)
|
||||||
{
|
{
|
||||||
m_title = title;
|
m_title = title;
|
||||||
m_items.DeleteContents( TRUE );
|
m_items.DeleteContents( TRUE );
|
||||||
@@ -661,7 +657,10 @@ wxMenu::Init( const wxString& title, const wxFunction func, long style )
|
|||||||
m_menu = gtk_menu_new(); // Do not show!
|
m_menu = gtk_menu_new(); // Do not show!
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef WXWIN_COMPATIBILITY
|
||||||
m_callback = func;
|
m_callback = func;
|
||||||
|
#endif
|
||||||
|
|
||||||
m_eventHandler = this;
|
m_eventHandler = this;
|
||||||
m_clientData = (void*) NULL;
|
m_clientData = (void*) NULL;
|
||||||
|
|
||||||
|
@@ -501,15 +501,6 @@ static void gtk_menu_hilight_callback( GtkWidget *widget, wxMenu *menu )
|
|||||||
wxMenuEvent event( wxEVT_MENU_HIGHLIGHT, id );
|
wxMenuEvent event( wxEVT_MENU_HIGHLIGHT, id );
|
||||||
event.SetEventObject( menu );
|
event.SetEventObject( menu );
|
||||||
|
|
||||||
/* wxMSW doesn't call callback here either
|
|
||||||
|
|
||||||
if (menu->m_callback)
|
|
||||||
{
|
|
||||||
(void) (*(menu->m_callback)) (*menu, event);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (menu->GetEventHandler()->ProcessEvent(event))
|
if (menu->GetEventHandler()->ProcessEvent(event))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -646,7 +637,12 @@ wxMenu::wxMenu(long style)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
wxMenu::Init( const wxString& title, const wxFunction func, long style )
|
wxMenu::Init( const wxString& title,
|
||||||
|
long style,
|
||||||
|
#ifdef WXWIN_COMPATIBILITY
|
||||||
|
, const wxFunction func
|
||||||
|
#endif
|
||||||
|
)
|
||||||
{
|
{
|
||||||
m_title = title;
|
m_title = title;
|
||||||
m_items.DeleteContents( TRUE );
|
m_items.DeleteContents( TRUE );
|
||||||
@@ -661,7 +657,10 @@ wxMenu::Init( const wxString& title, const wxFunction func, long style )
|
|||||||
m_menu = gtk_menu_new(); // Do not show!
|
m_menu = gtk_menu_new(); // Do not show!
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef WXWIN_COMPATIBILITY
|
||||||
m_callback = func;
|
m_callback = func;
|
||||||
|
#endif
|
||||||
|
|
||||||
m_eventHandler = this;
|
m_eventHandler = this;
|
||||||
m_clientData = (void*) NULL;
|
m_clientData = (void*) NULL;
|
||||||
|
|
||||||
|
@@ -650,6 +650,35 @@ bool wxListBox::SetStringSelection (const wxString& s, bool flag)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxSize wxListBox::DoGetBestSize()
|
||||||
|
{
|
||||||
|
// find the widest string
|
||||||
|
int wLine;
|
||||||
|
int wListbox = 0;
|
||||||
|
for ( int i = 0; i < m_noItems; i++ )
|
||||||
|
{
|
||||||
|
wxString str(GetString(i));
|
||||||
|
GetTextExtent(str, &wLine, NULL);
|
||||||
|
if ( wLine > wListbox )
|
||||||
|
wListbox = wLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
// give it some reasonable default value if there are no strings in the
|
||||||
|
// list
|
||||||
|
if ( wListbox == 0 )
|
||||||
|
wListbox = 100;
|
||||||
|
|
||||||
|
// the listbox should be slightly larger than the widest string
|
||||||
|
int cx, cy;
|
||||||
|
wxGetCharSize(GetHWND(), &cx, &cy, &GetFont());
|
||||||
|
|
||||||
|
wListbox += 3*cx;
|
||||||
|
|
||||||
|
int hListbox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy)*(wxMax(m_noItems, 7));
|
||||||
|
|
||||||
|
return wxSize(wListbox, hListbox);
|
||||||
|
}
|
||||||
|
|
||||||
// Is this the right thing? Won't setselection generate a command
|
// Is this the right thing? Won't setselection generate a command
|
||||||
// event too? No! It'll just generate a setselection event.
|
// event too? No! It'll just generate a setselection event.
|
||||||
// But we still can't have this being called whenever a real command
|
// But we still can't have this being called whenever a real command
|
||||||
|
@@ -78,9 +78,13 @@ static const int idMenuTitle = -2;
|
|||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
// Construct a menu with optional title (then use append)
|
// Construct a menu with optional title (then use append)
|
||||||
wxMenu::wxMenu(const wxString& title, const wxFunction func)
|
void wxMenu::Init(const wxString& title
|
||||||
: m_title(title)
|
#ifdef WXWIN_COMPATIBILITY
|
||||||
|
, const wxFunction func
|
||||||
|
#endif
|
||||||
|
)
|
||||||
{
|
{
|
||||||
|
m_title = title;
|
||||||
m_parent = NULL;
|
m_parent = NULL;
|
||||||
m_eventHandler = this;
|
m_eventHandler = this;
|
||||||
m_pInvokingWindow = NULL;
|
m_pInvokingWindow = NULL;
|
||||||
|
Reference in New Issue
Block a user