]> git.saurik.com Git - wxWidgets.git/blame - include/wx/motif/menu.h
fix DLL export declaration (adv, not core)
[wxWidgets.git] / include / wx / motif / menu.h
CommitLineData
9b6dbb09 1/////////////////////////////////////////////////////////////////////////////
925f7740 2// Name: wx/motif/menu.h
9b6dbb09
JS
3// Purpose: wxMenu, wxMenuBar classes
4// Author: Julian Smart
5// Modified by:
6// Created: 17/09/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
65571936 9// Licence: wxWindows licence
9b6dbb09
JS
10/////////////////////////////////////////////////////////////////////////////
11
9874b4ee
VZ
12#ifndef _WX_MOTIF_MENU_H_
13#define _WX_MOTIF_MENU_H_
9b6dbb09 14
9874b4ee 15#include "wx/colour.h"
94b49b93 16#include "wx/font.h"
a9711a4d 17#include "wx/arrstr.h"
9b6dbb09 18
94c7b088 19class WXDLLIMPEXP_CORE wxFrame;
9b6dbb09
JS
20
21// ----------------------------------------------------------------------------
22// Menu
23// ----------------------------------------------------------------------------
9874b4ee 24
94c7b088 25class WXDLLIMPEXP_CORE wxMenu : public wxMenuBase
9b6dbb09 26{
9b6dbb09 27public:
c71830c3
VZ
28 // ctors & dtor
29 wxMenu(const wxString& title, long style = 0)
30 : wxMenuBase(title, style) { Init(); }
925f7740 31
c71830c3 32 wxMenu(long style = 0) : wxMenuBase(style) { Init(); }
925f7740 33
c71830c3 34 virtual ~wxMenu();
925f7740 35
c71830c3 36 // implement base class virtuals
9add9367
RD
37 virtual wxMenuItem* DoAppend(wxMenuItem *item);
38 virtual wxMenuItem* DoInsert(size_t pos, wxMenuItem *item);
39 virtual wxMenuItem* DoRemove(wxMenuItem *item);
925f7740 40
c71830c3 41 virtual void Break();
925f7740 42
c71830c3 43 virtual void SetTitle(const wxString& title);
925f7740 44
c71830c3 45 bool ProcessCommand(wxCommandEvent& event);
925f7740 46
c71830c3
VZ
47 //// Motif-specific
48 WXWidget GetButtonWidget() const { return m_buttonWidget; }
49 void SetButtonWidget(WXWidget buttonWidget) { m_buttonWidget = buttonWidget; }
925f7740 50
c71830c3 51 WXWidget GetMainWidget() const { return m_menuWidget; }
925f7740 52
c71830c3
VZ
53 int GetId() const { return m_menuId; }
54 void SetId(int id) { m_menuId = id; }
925f7740 55
c71830c3
VZ
56 void SetMenuBar(wxMenuBar* menuBar) { m_menuBar = menuBar; }
57 wxMenuBar* GetMenuBar() const { return m_menuBar; }
925f7740 58
c71830c3
VZ
59 void CreatePopup(WXWidget logicalParent, int x, int y);
60 void DestroyPopup();
61 void ShowPopup(int x, int y);
62 void HidePopup();
925f7740 63
c71830c3 64 WXWidget CreateMenu(wxMenuBar *menuBar, WXWidget parent, wxMenu *topMenu,
51c9a5db 65 size_t index, const wxString& title = wxEmptyString,
96be256b 66 bool isPulldown = false);
925f7740 67
c71830c3
VZ
68 // For popups, need to destroy, then recreate menu for a different (or
69 // possibly same) window, since the parent may change.
70 void DestroyMenu(bool full);
71 WXWidget FindMenuItem(int id, wxMenuItem **it = NULL) const;
925f7740 72
c71830c3
VZ
73 const wxColour& GetBackgroundColour() const { return m_backgroundColour; }
74 const wxColour& GetForegroundColour() const { return m_foregroundColour; }
75 const wxFont& GetFont() const { return m_font; }
925f7740 76
c71830c3
VZ
77 void SetBackgroundColour(const wxColour& colour);
78 void SetForegroundColour(const wxColour& colour);
79 void SetFont(const wxFont& colour);
96be256b 80 void ChangeFont(bool keepOriginalSize = false);
925f7740 81
c71830c3 82 WXWidget GetHandle() const { return m_menuWidget; }
925f7740 83
c71830c3 84 bool IsTearOff() const { return (m_style & wxMENU_TEAROFF) != 0; }
7e1bcfa8
MB
85
86 void DestroyWidgetAndDetach();
c71830c3
VZ
87public:
88 // Motif-specific data
89 int m_numColumns;
90 WXWidget m_menuWidget;
91 WXWidget m_popupShell; // For holding the popup shell widget
92 WXWidget m_buttonWidget; // The actual string, so we can grey it etc.
93 int m_menuId;
94 wxMenu* m_topLevelMenu ;
95 bool m_ownedByMenuBar;
96 wxColour m_foregroundColour;
97 wxColour m_backgroundColour;
98 wxFont m_font;
925f7740 99
ee31c392
VZ
100private:
101 // common code for both constructors:
c71830c3 102 void Init();
925f7740 103
c71830c3 104 DECLARE_DYNAMIC_CLASS(wxMenu)
9b6dbb09
JS
105};
106
107// ----------------------------------------------------------------------------
9874b4ee 108// Menu Bar
9b6dbb09 109// ----------------------------------------------------------------------------
ee31c392 110
94c7b088 111class WXDLLIMPEXP_CORE wxMenuBar : public wxMenuBarBase
9b6dbb09 112{
ee31c392 113public:
9874b4ee
VZ
114 wxMenuBar() { Init(); }
115 wxMenuBar(long WXUNUSED(style)) { Init(); }
294ea16d
VZ
116 wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style = 0);
117 wxMenuBar(size_t n, wxMenu *menus[], const wxArrayString& titles, long style = 0);
9874b4ee 118 virtual ~wxMenuBar();
925f7740 119
9874b4ee
VZ
120 // implement base class (pure) virtuals
121 // ------------------------------------
925f7740 122
9874b4ee
VZ
123 virtual bool Append( wxMenu *menu, const wxString &title );
124 virtual bool Insert(size_t pos, wxMenu *menu, const wxString& title);
125 virtual wxMenu *Replace(size_t pos, wxMenu *menu, const wxString& title);
126 virtual wxMenu *Remove(size_t pos);
925f7740 127
9874b4ee 128 virtual int FindMenuItem(const wxString& menuString,
83df96d6 129 const wxString& itemString) const;
9874b4ee 130 virtual wxMenuItem* FindItem( int id, wxMenu **menu = NULL ) const;
925f7740 131
9874b4ee
VZ
132 virtual void EnableTop( size_t pos, bool flag );
133 virtual void SetLabelTop( size_t pos, const wxString& label );
134 virtual wxString GetLabelTop( size_t pos ) const;
925f7740 135
9874b4ee
VZ
136 // implementation only from now on
137 // -------------------------------
925f7740 138
ee31c392
VZ
139 wxFrame* GetMenuBarFrame() const { return m_menuBarFrame; }
140 void SetMenuBarFrame(wxFrame* frame) { m_menuBarFrame = frame; }
141 WXWidget GetMainWidget() const { return m_mainWidget; }
142 void SetMainWidget(WXWidget widget) { m_mainWidget = widget; }
925f7740 143
ee31c392
VZ
144 // Create menubar
145 bool CreateMenuBar(wxFrame* frame);
925f7740 146
ee31c392
VZ
147 // Destroy menubar, but keep data structures intact so we can recreate it.
148 bool DestroyMenuBar();
925f7740 149
ee31c392
VZ
150 const wxColour& GetBackgroundColour() const { return m_backgroundColour; }
151 const wxColour& GetForegroundColour() const { return m_foregroundColour; }
152 const wxFont& GetFont() const { return m_font; }
925f7740 153
9874b4ee
VZ
154 virtual bool SetBackgroundColour(const wxColour& colour);
155 virtual bool SetForegroundColour(const wxColour& colour);
156 virtual bool SetFont(const wxFont& colour);
96be256b 157 void ChangeFont(bool keepOriginalSize = false);
925f7740 158
ee31c392 159public:
9874b4ee
VZ
160 // common part of all ctors
161 void Init();
925f7740 162
9874b4ee
VZ
163 wxArrayString m_titles;
164 wxFrame *m_menuBarFrame;
925f7740 165
9874b4ee 166 WXWidget m_mainWidget;
925f7740 167
9874b4ee
VZ
168 wxColour m_foregroundColour;
169 wxColour m_backgroundColour;
170 wxFont m_font;
925f7740 171
9874b4ee 172 DECLARE_DYNAMIC_CLASS(wxMenuBar)
9b6dbb09
JS
173};
174
9874b4ee 175#endif // _WX_MOTIF_MENU_H_