]> git.saurik.com Git - wxWidgets.git/blame - include/wx/motif/menu.h
Committing in .
[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
JS
14
15#ifdef __GNUG__
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 wxMenu(const wxString& title, const wxFunction func)
51 : wxMenuBase(title)
ee31c392 52 {
4a539480 53 Init();
83df96d6 54
c71830c3 55 Callback(func);
ee31c392 56 }
83df96d6 57
c71830c3
VZ
58 //// Motif-specific
59 WXWidget GetButtonWidget() const { return m_buttonWidget; }
60 void SetButtonWidget(WXWidget buttonWidget) { m_buttonWidget = buttonWidget; }
83df96d6 61
c71830c3 62 WXWidget GetMainWidget() const { return m_menuWidget; }
83df96d6 63
c71830c3
VZ
64 int GetId() const { return m_menuId; }
65 void SetId(int id) { m_menuId = id; }
83df96d6 66
c71830c3
VZ
67 void SetMenuBar(wxMenuBar* menuBar) { m_menuBar = menuBar; }
68 wxMenuBar* GetMenuBar() const { return m_menuBar; }
83df96d6 69
c71830c3
VZ
70 void CreatePopup(WXWidget logicalParent, int x, int y);
71 void DestroyPopup();
72 void ShowPopup(int x, int y);
73 void HidePopup();
83df96d6 74
c71830c3 75 WXWidget CreateMenu(wxMenuBar *menuBar, WXWidget parent, wxMenu *topMenu,
83df96d6
JS
76 const wxString& title = wxEmptyString,
77 bool isPulldown = FALSE);
78
c71830c3
VZ
79 // For popups, need to destroy, then recreate menu for a different (or
80 // possibly same) window, since the parent may change.
81 void DestroyMenu(bool full);
82 WXWidget FindMenuItem(int id, wxMenuItem **it = NULL) const;
83df96d6 83
c71830c3
VZ
84 const wxColour& GetBackgroundColour() const { return m_backgroundColour; }
85 const wxColour& GetForegroundColour() const { return m_foregroundColour; }
86 const wxFont& GetFont() const { return m_font; }
83df96d6 87
c71830c3
VZ
88 void SetBackgroundColour(const wxColour& colour);
89 void SetForegroundColour(const wxColour& colour);
90 void SetFont(const wxFont& colour);
91 void ChangeFont(bool keepOriginalSize = FALSE);
83df96d6 92
c71830c3 93 WXWidget GetHandle() const { return m_menuWidget; }
83df96d6 94
c71830c3 95 bool IsTearOff() const { return (m_style & wxMENU_TEAROFF) != 0; }
83df96d6 96
c71830c3
VZ
97public:
98 // Motif-specific data
99 int m_numColumns;
100 WXWidget m_menuWidget;
101 WXWidget m_popupShell; // For holding the popup shell widget
102 WXWidget m_buttonWidget; // The actual string, so we can grey it etc.
103 int m_menuId;
104 wxMenu* m_topLevelMenu ;
105 bool m_ownedByMenuBar;
106 wxColour m_foregroundColour;
107 wxColour m_backgroundColour;
108 wxFont m_font;
83df96d6 109
ee31c392
VZ
110private:
111 // common code for both constructors:
c71830c3 112 void Init();
83df96d6 113
c71830c3 114 DECLARE_DYNAMIC_CLASS(wxMenu)
9b6dbb09
JS
115};
116
117// ----------------------------------------------------------------------------
9874b4ee 118// Menu Bar
9b6dbb09 119// ----------------------------------------------------------------------------
ee31c392 120
9874b4ee 121class wxMenuBar : public wxMenuBarBase
9b6dbb09 122{
ee31c392 123public:
9874b4ee
VZ
124 wxMenuBar() { Init(); }
125 wxMenuBar(long WXUNUSED(style)) { Init(); }
ee31c392 126 wxMenuBar(int n, wxMenu *menus[], const wxString titles[]);
9874b4ee 127 virtual ~wxMenuBar();
83df96d6 128
9874b4ee
VZ
129 // implement base class (pure) virtuals
130 // ------------------------------------
83df96d6 131
9874b4ee
VZ
132 virtual bool Append( wxMenu *menu, const wxString &title );
133 virtual bool Insert(size_t pos, wxMenu *menu, const wxString& title);
134 virtual wxMenu *Replace(size_t pos, wxMenu *menu, const wxString& title);
135 virtual wxMenu *Remove(size_t pos);
83df96d6 136
9874b4ee 137 virtual int FindMenuItem(const wxString& menuString,
83df96d6 138 const wxString& itemString) const;
9874b4ee 139 virtual wxMenuItem* FindItem( int id, wxMenu **menu = NULL ) const;
83df96d6 140
9874b4ee
VZ
141 virtual void EnableTop( size_t pos, bool flag );
142 virtual void SetLabelTop( size_t pos, const wxString& label );
143 virtual wxString GetLabelTop( size_t pos ) const;
83df96d6 144
9874b4ee
VZ
145 // implementation only from now on
146 // -------------------------------
83df96d6 147
ee31c392
VZ
148 wxFrame* GetMenuBarFrame() const { return m_menuBarFrame; }
149 void SetMenuBarFrame(wxFrame* frame) { m_menuBarFrame = frame; }
150 WXWidget GetMainWidget() const { return m_mainWidget; }
151 void SetMainWidget(WXWidget widget) { m_mainWidget = widget; }
83df96d6 152
ee31c392
VZ
153 // Create menubar
154 bool CreateMenuBar(wxFrame* frame);
83df96d6 155
ee31c392
VZ
156 // Destroy menubar, but keep data structures intact so we can recreate it.
157 bool DestroyMenuBar();
83df96d6 158
ee31c392
VZ
159 const wxColour& GetBackgroundColour() const { return m_backgroundColour; }
160 const wxColour& GetForegroundColour() const { return m_foregroundColour; }
161 const wxFont& GetFont() const { return m_font; }
83df96d6 162
9874b4ee
VZ
163 virtual bool SetBackgroundColour(const wxColour& colour);
164 virtual bool SetForegroundColour(const wxColour& colour);
165 virtual bool SetFont(const wxFont& colour);
ee31c392 166 void ChangeFont(bool keepOriginalSize = FALSE);
83df96d6 167
ee31c392 168public:
9874b4ee
VZ
169 // common part of all ctors
170 void Init();
83df96d6 171
9874b4ee
VZ
172 wxArrayString m_titles;
173 wxFrame *m_menuBarFrame;
83df96d6 174
9874b4ee 175 WXWidget m_mainWidget;
83df96d6 176
9874b4ee
VZ
177 wxColour m_foregroundColour;
178 wxColour m_backgroundColour;
179 wxFont m_font;
83df96d6 180
9874b4ee 181 DECLARE_DYNAMIC_CLASS(wxMenuBar)
9b6dbb09
JS
182};
183
9874b4ee 184#endif // _WX_MOTIF_MENU_H_