1. implemented radio menu items for wxGTK
2. changed (in most cases blindly) code for all the others 3. added wx/features.h 4. update wxMenu[Item] docs ---------------------------------------------------------------------- Committing in . Modified Files: distrib/msw/tmake/filelist.txt docs/changes.txt docs/latex/wx/menu.tex docs/latex/wx/menuitem.tex include/wx/defs.h include/wx/menu.h include/wx/menuitem.h include/wx/gtk/menu.h include/wx/gtk/menuitem.h include/wx/mac/menuitem.h include/wx/motif/menuitem.h include/wx/msw/menuitem.h include/wx/os2/MENUITEM.H include/wx/univ/menuitem.h samples/menu/menu.cpp src/common/menucmn.cpp src/gtk/menu.cpp src/mac/menuitem.cpp src/motif/menuitem.cpp src/msw/menuitem.cpp src/os2/MENUITEM.CPP src/univ/menu.cpp Added Files: include/wx/features.h ---------------------------------------------------------------------- git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14674 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -35,6 +35,9 @@
|
||||
#endif // Unix/!Unix
|
||||
#endif
|
||||
|
||||
// include the feature test macros
|
||||
#include "wx/features.h"
|
||||
|
||||
// suppress some Visual C++ warnings
|
||||
#ifdef __VISUALC__
|
||||
# pragma warning(disable:4201) // nonstandard extension used: nameless struct/union
|
||||
@@ -1276,6 +1279,16 @@ enum wxBorder
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// menu and toolbar item kinds
|
||||
enum wxItemKind
|
||||
{
|
||||
wxItem_Separator = -1,
|
||||
wxItem_Normal,
|
||||
wxItem_Check,
|
||||
wxItem_Radio,
|
||||
wxItem_Max
|
||||
};
|
||||
|
||||
// hit test results
|
||||
enum wxHitTest
|
||||
{
|
||||
|
24
include/wx/features.h
Normal file
24
include/wx/features.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/features.h
|
||||
// Purpose: test macros for the features which might be available in some
|
||||
// wxWindows ports but not others
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 18.03.02
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2002 Vadim Zeitlin <vadim@wxwindows.org>
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_FEATURES_H_
|
||||
#define _WX_FEATURES_H_
|
||||
|
||||
// radio menu items are currently only implemented in wxGTK
|
||||
#if defined(__WXGTK__) // || defined(__WXMSW__)
|
||||
#define wxHAS_RADIO_MENU_ITEMS
|
||||
#else
|
||||
#undef wxHAS_RADIO_MENU_ITEMS
|
||||
#endif
|
||||
|
||||
#endif // _WX_FEATURES_H_
|
||||
|
@@ -107,6 +107,10 @@ private:
|
||||
// common part of Append and Insert
|
||||
bool GtkAppend(wxMenuItem *item);
|
||||
|
||||
// if the last menu item was a radio one, this field contains its path,
|
||||
// otherwise it is empty
|
||||
wxString m_pathLastRadio;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxMenu)
|
||||
};
|
||||
|
||||
|
@@ -27,7 +27,7 @@ public:
|
||||
int id = wxID_SEPARATOR,
|
||||
const wxString& text = wxEmptyString,
|
||||
const wxString& help = wxEmptyString,
|
||||
bool isCheckable = FALSE,
|
||||
wxItemKind kind = wxItem_Normal,
|
||||
wxMenu *subMenu = (wxMenu *)NULL);
|
||||
~wxMenuItem();
|
||||
|
||||
|
@@ -107,6 +107,10 @@ private:
|
||||
// common part of Append and Insert
|
||||
bool GtkAppend(wxMenuItem *item);
|
||||
|
||||
// if the last menu item was a radio one, this field contains its path,
|
||||
// otherwise it is empty
|
||||
wxString m_pathLastRadio;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxMenu)
|
||||
};
|
||||
|
||||
|
@@ -27,7 +27,7 @@ public:
|
||||
int id = wxID_SEPARATOR,
|
||||
const wxString& text = wxEmptyString,
|
||||
const wxString& help = wxEmptyString,
|
||||
bool isCheckable = FALSE,
|
||||
wxItemKind kind = wxItem_Normal,
|
||||
wxMenu *subMenu = (wxMenu *)NULL);
|
||||
~wxMenuItem();
|
||||
|
||||
|
@@ -43,7 +43,7 @@ public:
|
||||
int id = wxID_SEPARATOR,
|
||||
const wxString& name = wxEmptyString,
|
||||
const wxString& help = wxEmptyString,
|
||||
bool isCheckable = FALSE,
|
||||
wxItemKind kind = wxItem_Normal,
|
||||
wxMenu *subMenu = (wxMenu *)NULL);
|
||||
virtual ~wxMenuItem();
|
||||
|
||||
|
@@ -75,18 +75,34 @@ public:
|
||||
// menu construction
|
||||
// -----------------
|
||||
|
||||
// append a normal item to the menu
|
||||
// append any kind of item (normal/check/radio/separator)
|
||||
void Append(int id,
|
||||
const wxString& text,
|
||||
const wxString& help = wxEmptyString,
|
||||
bool isCheckable = FALSE)
|
||||
wxItemKind kind = wxItem_Normal)
|
||||
{
|
||||
DoAppend(wxMenuItem::New((wxMenu *)this, id, text, help, isCheckable));
|
||||
DoAppend(wxMenuItem::New((wxMenu *)this, id, text, help, kind));
|
||||
}
|
||||
|
||||
// append a separator to the menu
|
||||
void AppendSeparator() { Append(wxID_SEPARATOR, wxEmptyString); }
|
||||
|
||||
// append a check item
|
||||
void AppendCheckItem(int id,
|
||||
const wxString& text,
|
||||
const wxString& help = wxEmptyString)
|
||||
{
|
||||
Append(id, text, help, wxItem_Check);
|
||||
}
|
||||
|
||||
// append a radio item
|
||||
void AppendRadioItem(int id,
|
||||
const wxString& text,
|
||||
const wxString& help = wxEmptyString)
|
||||
{
|
||||
Append(id, text, help, wxItem_Radio);
|
||||
}
|
||||
|
||||
// append a submenu
|
||||
void Append(int id,
|
||||
const wxString& text,
|
||||
@@ -105,13 +121,15 @@ public:
|
||||
|
||||
// insert an item before given position
|
||||
bool Insert(size_t pos, wxMenuItem *item);
|
||||
|
||||
// insert an item before given position
|
||||
void Insert(size_t pos,
|
||||
int id,
|
||||
const wxString& text,
|
||||
const wxString& help = wxEmptyString,
|
||||
bool isCheckable = FALSE)
|
||||
wxItemKind kind = wxItem_Normal)
|
||||
{
|
||||
Insert(pos, wxMenuItem::New((wxMenu *)this, id, text, help, isCheckable));
|
||||
Insert(pos, wxMenuItem::New((wxMenu *)this, id, text, help, kind));
|
||||
}
|
||||
|
||||
// insert a separator
|
||||
@@ -120,6 +138,24 @@ public:
|
||||
Insert(pos, wxMenuItem::New((wxMenu *)this));
|
||||
}
|
||||
|
||||
// insert a check item
|
||||
void InsertCheckItem(size_t pos,
|
||||
int id,
|
||||
const wxString& text,
|
||||
const wxString& help = wxEmptyString)
|
||||
{
|
||||
Insert(pos, id, text, help, wxItem_Check);
|
||||
}
|
||||
|
||||
// insert a radio item
|
||||
void InsertRadioItem(size_t pos,
|
||||
int id,
|
||||
const wxString& text,
|
||||
const wxString& help = wxEmptyString)
|
||||
{
|
||||
Insert(pos, id, text, help, wxItem_Radio);
|
||||
}
|
||||
|
||||
// insert a submenu
|
||||
void Insert(size_t pos,
|
||||
int id,
|
||||
@@ -136,21 +172,38 @@ public:
|
||||
Insert(0u, item);
|
||||
}
|
||||
|
||||
// prepend any item to the menu
|
||||
void Prepend(int id,
|
||||
const wxString& text,
|
||||
const wxString& help = wxEmptyString,
|
||||
bool isCheckable = FALSE)
|
||||
wxItemKind kind = wxItem_Normal)
|
||||
{
|
||||
Insert(0u, id, text, help, isCheckable);
|
||||
Insert(0u, id, text, help, kind);
|
||||
}
|
||||
|
||||
// insert a separator
|
||||
// prepend a separator
|
||||
void PrependSeparator()
|
||||
{
|
||||
InsertSeparator(0u);
|
||||
}
|
||||
|
||||
// insert a submenu
|
||||
// prepend a check item
|
||||
void PrependCheckItem(int id,
|
||||
const wxString& text,
|
||||
const wxString& help = wxEmptyString)
|
||||
{
|
||||
InsertCheckItem(0u, id, text, help);
|
||||
}
|
||||
|
||||
// prepend a radio item
|
||||
void PrependRadioItem(int id,
|
||||
const wxString& text,
|
||||
const wxString& help = wxEmptyString)
|
||||
{
|
||||
InsertRadioItem(0u, id, text, help);
|
||||
}
|
||||
|
||||
// prepend a submenu
|
||||
void Prepend(int id,
|
||||
const wxString& text,
|
||||
wxMenu *submenu,
|
||||
@@ -241,8 +294,51 @@ public:
|
||||
void SetParent(wxMenu *parent) { m_menuParent = parent; }
|
||||
wxMenu *GetParent() const { return m_menuParent; }
|
||||
|
||||
#if WXWIN_COMPATIBILITY
|
||||
// implementation only from now on
|
||||
// -------------------------------
|
||||
|
||||
// unlike FindItem(), this function doesn't recurse but only looks through
|
||||
// our direct children and also may return the index of the found child if
|
||||
// pos != NULL
|
||||
wxMenuItem *FindChildItem(int id, size_t *pos = NULL) const;
|
||||
|
||||
// called to generate a wxCommandEvent, return TRUE if it was processed,
|
||||
// FALSE otherwise
|
||||
//
|
||||
// the checked parameter may have boolean value or -1 for uncheckable items
|
||||
bool SendEvent(int id, int checked = -1);
|
||||
|
||||
// compatibility: these functions are deprecated, use the new ones instead
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// use the versions taking wxItem_XXX now instead, they're more readable
|
||||
// and allow adding the radio items as well
|
||||
void Append(int id,
|
||||
const wxString& text,
|
||||
const wxString& help,
|
||||
bool isCheckable)
|
||||
{
|
||||
Append(id, text, help, isCheckable ? wxItem_Check : wxItem_Normal);
|
||||
}
|
||||
|
||||
void Insert(size_t pos,
|
||||
int id,
|
||||
const wxString& text,
|
||||
const wxString& help,
|
||||
bool isCheckable)
|
||||
{
|
||||
Insert(pos, id, text, help, isCheckable ? wxItem_Check : wxItem_Normal);
|
||||
}
|
||||
|
||||
void Prepend(int id,
|
||||
const wxString& text,
|
||||
const wxString& help,
|
||||
bool isCheckable)
|
||||
{
|
||||
Insert(0u, id, text, help, isCheckable);
|
||||
}
|
||||
|
||||
#if WXWIN_COMPATIBILITY
|
||||
bool Enabled(int id) const { return IsEnabled(id); }
|
||||
bool Checked(int id) const { return IsChecked(id); }
|
||||
|
||||
@@ -260,17 +356,6 @@ public:
|
||||
wxFunction m_callback;
|
||||
#endif // wxUSE_MENU_CALLBACK
|
||||
|
||||
// unlike FindItem(), this function doesn't recurse but only looks through
|
||||
// our direct children and also may return the index of the found child if
|
||||
// pos != NULL
|
||||
wxMenuItem *FindChildItem(int id, size_t *pos = NULL) const;
|
||||
|
||||
// called to generate a wxCommandEvent, return TRUE if it was processed,
|
||||
// FALSE otherwise
|
||||
//
|
||||
// the checked parameter may have boolean value or -1 for uncheckable items
|
||||
bool SendEvent(int id, int checked = -1);
|
||||
|
||||
protected:
|
||||
// virtuals to override in derived classes
|
||||
// ---------------------------------------
|
||||
|
@@ -41,7 +41,7 @@ public:
|
||||
int id = wxID_SEPARATOR,
|
||||
const wxString& text = wxEmptyString,
|
||||
const wxString& help = wxEmptyString,
|
||||
bool isCheckable = FALSE,
|
||||
wxItemKind kind = wxItem_Normal,
|
||||
wxMenu *subMenu = (wxMenu *)NULL);
|
||||
|
||||
// destruction: wxMenuItem will delete its submenu
|
||||
@@ -69,8 +69,10 @@ public:
|
||||
static wxString GetLabelFromText(const wxString& text);
|
||||
|
||||
// what kind of menu item we are
|
||||
virtual void SetCheckable(bool checkable) { m_isCheckable = checkable; }
|
||||
bool IsCheckable() const { return m_isCheckable; }
|
||||
wxItemKind GetKind() const { return m_kind; }
|
||||
|
||||
virtual void SetCheckable(bool checkable) { m_kind = wxItem_Check; }
|
||||
bool IsCheckable() const { return m_kind == wxItem_Check; }
|
||||
|
||||
bool IsSubMenu() const { return m_subMenu != NULL; }
|
||||
void SetSubMenu(wxMenu *menu) { m_subMenu = menu; }
|
||||
@@ -105,18 +107,34 @@ public:
|
||||
void SetName(const wxString& str) { SetText(str); }
|
||||
const wxString& GetName() const { return GetText(); }
|
||||
|
||||
static wxMenuItem *New(wxMenu *parentMenu,
|
||||
int id,
|
||||
const wxString& text,
|
||||
const wxString& help,
|
||||
bool isCheckable,
|
||||
wxMenu *subMenu = (wxMenu *)NULL)
|
||||
{
|
||||
return New(parentMenu, id, text, help,
|
||||
isCheckable ? wxItem_Check : wxItem_Normal, subMenu);
|
||||
}
|
||||
|
||||
protected:
|
||||
int m_id; // numeric id of the item >= 0 or -1
|
||||
wxMenu *m_parentMenu, // the menu we belong to
|
||||
*m_subMenu; // our sub menu or NULL
|
||||
wxString m_text, // label of the item
|
||||
m_help; // the help string for the item
|
||||
bool m_isCheckable; // can be checked?
|
||||
wxItemKind m_kind; // seperator/normal/check/radio item?
|
||||
bool m_isChecked; // is checked?
|
||||
bool m_isEnabled; // is enabled?
|
||||
|
||||
// some compilers need a default constructor here, do not remove
|
||||
wxMenuItemBase() { }
|
||||
// this ctor is for the derived classes only, we're never created directly
|
||||
wxMenuItemBase(wxMenu *parentMenu = (wxMenu *)NULL,
|
||||
int id = wxID_SEPARATOR,
|
||||
const wxString& text = wxEmptyString,
|
||||
const wxString& help = wxEmptyString,
|
||||
wxItemKind kind = wxItem_Normal,
|
||||
wxMenu *subMenu = (wxMenu *)NULL);
|
||||
|
||||
private:
|
||||
// and, if we have one ctor, compiler won't generate a default copy one, so
|
||||
|
@@ -29,11 +29,11 @@ class wxMenuItem : public wxMenuItemBase
|
||||
public:
|
||||
// ctor & dtor
|
||||
wxMenuItem(wxMenu *parentMenu = (wxMenu *)NULL,
|
||||
int id = wxID_SEPARATOR,
|
||||
const wxString& text = wxEmptyString,
|
||||
const wxString& help = wxEmptyString,
|
||||
bool isCheckable = FALSE,
|
||||
wxMenu *subMenu = (wxMenu *)NULL);
|
||||
int id = wxID_SEPARATOR,
|
||||
const wxString& text = wxEmptyString,
|
||||
const wxString& help = wxEmptyString,
|
||||
wxItemKind kind = wxItem_Normal,
|
||||
wxMenu *subMenu = (wxMenu *)NULL);
|
||||
~wxMenuItem();
|
||||
|
||||
// accessors (some more are inherited from wxOwnerDrawn or are below)
|
||||
|
@@ -39,7 +39,7 @@ public:
|
||||
int id = wxID_SEPARATOR,
|
||||
const wxString& name = wxEmptyString,
|
||||
const wxString& help = wxEmptyString,
|
||||
bool isCheckable = FALSE,
|
||||
wxItemKind kind = wxItem_Normal,
|
||||
wxMenu *subMenu = (wxMenu *)NULL);
|
||||
virtual ~wxMenuItem();
|
||||
|
||||
|
@@ -47,7 +47,7 @@ public:
|
||||
,int nId = wxID_SEPARATOR
|
||||
,const wxString& rStrName = ""
|
||||
,const wxString& rWxHelp = ""
|
||||
,bool bCheckable = FALSE
|
||||
,wxItemKind kind = wxItem_Normal
|
||||
,wxMenu* pSubMenu = NULL
|
||||
);
|
||||
virtual ~wxMenuItem();
|
||||
|
@@ -28,7 +28,7 @@ public:
|
||||
int id = wxID_SEPARATOR,
|
||||
const wxString& name = wxEmptyString,
|
||||
const wxString& help = wxEmptyString,
|
||||
bool isCheckable = FALSE,
|
||||
wxItemKind kind = wxItem_Normal,
|
||||
wxMenu *subMenu = (wxMenu *)NULL);
|
||||
virtual ~wxMenuItem();
|
||||
|
||||
|
Reference in New Issue
Block a user