// implementation only
wxList& GetMenus() { return m_menus; }
-
+
void SetInvokingWindow( wxWindow *win );
void UnsetInvokingWindow( wxWindow *win );
DECLARE_DYNAMIC_CLASS(wxMenu)
public:
- wxMenu( const wxString& title = wxEmptyString,
- const wxFunction func = (wxFunction) NULL,
- long style = 0);
+#ifdef WXWIN_COMPATIBILITY
+ wxMenu( const wxString& title, const wxFunction func)
+ {
+ Init(title, 0, func);
+ }
+#endif
+ wxMenu( const wxString& title = wxEmptyString, long style = 0 )
+ {
+ Init(title, style, NULL);
+ }
+
wxMenu( long style );
~wxMenu();
// compatibility: these functions are deprecated
bool Enabled(int id) const { return IsEnabled(id); }
bool Checked(int id) const { return IsChecked(id); }
+
+ wxFunction m_callback;
#endif // WXWIN_COMPATIBILITY
// implementation
GtkItemFactory *m_factory;
// used by wxMenuBar
- inline long GetStyle(void) const { return m_style; }
- private:
+ long GetStyle(void) const { return m_style; }
+
+private:
// common code for both constructors:
void Init( const wxString& title,
- const wxFunction func,
- long style);
+ long style
+#ifdef WXWIN_COMPATIBILITY
+ , const wxFunction func
+#endif
+ );
wxString m_title;
wxList m_items;
wxWindow *m_invokingWindow;
- wxFunction m_callback;
wxEvtHandler *m_eventHandler;
void *m_clientData;
long m_style;
// implementation only
wxList& GetMenus() { return m_menus; }
-
+
void SetInvokingWindow( wxWindow *win );
void UnsetInvokingWindow( wxWindow *win );
DECLARE_DYNAMIC_CLASS(wxMenu)
public:
- wxMenu( const wxString& title = wxEmptyString,
- const wxFunction func = (wxFunction) NULL,
- long style = 0);
+#ifdef WXWIN_COMPATIBILITY
+ wxMenu( const wxString& title, const wxFunction func)
+ {
+ Init(title, 0, func);
+ }
+#endif
+ wxMenu( const wxString& title = wxEmptyString, long style = 0 )
+ {
+ Init(title, style, NULL);
+ }
+
wxMenu( long style );
~wxMenu();
// compatibility: these functions are deprecated
bool Enabled(int id) const { return IsEnabled(id); }
bool Checked(int id) const { return IsChecked(id); }
+
+ wxFunction m_callback;
#endif // WXWIN_COMPATIBILITY
// implementation
GtkItemFactory *m_factory;
// used by wxMenuBar
- inline long GetStyle(void) const { return m_style; }
- private:
+ long GetStyle(void) const { return m_style; }
+
+private:
// common code for both constructors:
void Init( const wxString& title,
- const wxFunction func,
- long style);
+ long style
+#ifdef WXWIN_COMPATIBILITY
+ , const wxFunction func
+#endif
+ );
wxString m_title;
wxList m_items;
wxWindow *m_invokingWindow;
- wxFunction m_callback;
wxEvtHandler *m_eventHandler;
void *m_clientData;
long m_style;
#ifdef __WXMSW__
#include "wx/msw/helpwin.h"
+ #undef wxHelpController
+ #undef sm_classwxHelpController
#define wxHelpController wxWinHelpController
#define sm_classwxHelpController sm_classwxWinHelpController
#else // !MSW
int m_noItems;
int m_selected;
+ virtual wxSize DoGetBestSize();
+
#if wxUSE_OWNER_DRAWN
// control items
wxListBoxItemsArray m_aItems;
DECLARE_DYNAMIC_CLASS(wxMenu)
public:
- // ctor & dtor
- wxMenu(const wxString& title = wxEmptyString, const wxFunction func = NULL);
+ // ctors & dtor
+#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();
// construct menu
#endif // WXWIN_COMPATIBILITY
private:
+ // common part of all ctors
+ void Init(const wxString& title
+#ifdef WXWIN_COMPATIBILITY
+ , const wxFunction func = NULL
+#endif
+ );
+
bool m_doBreak;
// This is used when m_hMenu is NULL because we don't want to
wxMenuEvent event( wxEVT_MENU_HIGHLIGHT, id );
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))
return;
}
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_items.DeleteContents( TRUE );
m_menu = gtk_menu_new(); // Do not show!
#endif
+#ifdef WXWIN_COMPATIBILITY
m_callback = func;
+#endif
+
m_eventHandler = this;
m_clientData = (void*) NULL;
wxMenuEvent event( wxEVT_MENU_HIGHLIGHT, id );
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))
return;
}
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_items.DeleteContents( TRUE );
m_menu = gtk_menu_new(); // Do not show!
#endif
+#ifdef WXWIN_COMPATIBILITY
m_callback = func;
+#endif
+
m_eventHandler = this;
m_clientData = (void*) NULL;
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
// event too? No! It'll just generate a setselection event.
// But we still can't have this being called whenever a real command
// ---------------------------------------------------------------------------
// Construct a menu with optional title (then use append)
-wxMenu::wxMenu(const wxString& title, const wxFunction func)
- : m_title(title)
+void wxMenu::Init(const wxString& title
+#ifdef WXWIN_COMPATIBILITY
+ , const wxFunction func
+#endif
+ )
{
+ m_title = title;
m_parent = NULL;
m_eventHandler = this;
m_pInvokingWindow = NULL;