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