]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/menuitem.h
Separate label with wx mnemonics (&) and with gtk mnemonics (_) into m_text and m_gtk...
[wxWidgets.git] / include / wx / gtk / menuitem.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: menuitem.h
3 // Purpose: wxMenuItem class
4 // Author: Robert Roebling
5 // RCS-ID: $Id$
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
9
10 #ifndef _WX_GTKMENUITEM_H_
11 #define _WX_GTKMENUITEM_H_
12
13 #include "wx/bitmap.h"
14
15 //-----------------------------------------------------------------------------
16 // wxMenuItem
17 //-----------------------------------------------------------------------------
18
19 class WXDLLIMPEXP_CORE wxMenuItem : public wxMenuItemBase
20 {
21 public:
22 wxMenuItem(wxMenu *parentMenu = (wxMenu *)NULL,
23 int id = wxID_SEPARATOR,
24 const wxString& text = wxEmptyString,
25 const wxString& help = wxEmptyString,
26 wxItemKind kind = wxITEM_NORMAL,
27 wxMenu *subMenu = (wxMenu *)NULL);
28 virtual ~wxMenuItem();
29
30 // implement base class virtuals
31 virtual void SetItemLabel( const wxString& str );
32 virtual void Enable( bool enable = true );
33 virtual void Check( bool check = true );
34 virtual bool IsChecked() const;
35 virtual void SetBitmap(const wxBitmap& bitmap) { m_bitmap = bitmap; }
36 virtual const wxBitmap& GetBitmap() const { return m_bitmap; }
37
38 #if wxUSE_ACCEL
39 virtual wxAcceleratorEntry *GetAccel() const;
40 #endif // wxUSE_ACCEL
41
42 // implementation
43 void SetMenuItem(GtkWidget *menuItem) { m_menuItem = menuItem; }
44 GtkWidget *GetMenuItem() const { return m_menuItem; }
45
46 // splits given string in the label, doing & => _ translation, which is returned,
47 // and in the hotkey which is used to set given pointer
48 static wxString GTKProcessMenuItemLabel(const wxString& str, wxString *hotKey);
49
50 wxString GetGtkItemLabel() { return m_gtkText; }
51
52 #if WXWIN_COMPATIBILITY_2_8
53 // compatibility only, don't use in new code
54 wxDEPRECATED(
55 wxMenuItem(wxMenu *parentMenu,
56 int id,
57 const wxString& text,
58 const wxString& help,
59 bool isCheckable,
60 wxMenu *subMenu = NULL)
61 );
62 #endif
63
64 private:
65 // common part of all ctors
66 void Init(const wxString& text);
67
68 // DoSetText() transforms the accel mnemonics in our label from MSW/wxWin
69 // style to GTK+ and is called from ctor and SetText()
70 void DoSetText(const wxString& text);
71
72 wxString m_gtkText; // m_text after conversion to GTK mnemonics
73 wxString m_hotKey;
74 wxBitmap m_bitmap; // Bitmap for menuitem, if any
75
76 GtkWidget *m_menuItem; // GtkMenuItem
77
78 DECLARE_DYNAMIC_CLASS(wxMenuItem)
79 };
80
81 #endif // _WX_GTKMENUITEM_H_