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