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:
@@ -807,6 +807,7 @@ encconv.h WXH Base
|
|||||||
event.h WXH Base
|
event.h WXH Base
|
||||||
expr.h WXH
|
expr.h WXH
|
||||||
fdrepdlg.h WXH
|
fdrepdlg.h WXH
|
||||||
|
features.h WXH Base
|
||||||
ffile.h WXH Base
|
ffile.h WXH Base
|
||||||
file.h WXH Base
|
file.h WXH Base
|
||||||
fileconf.h WXH Base
|
fileconf.h WXH Base
|
||||||
|
@@ -107,6 +107,7 @@ Unix (Base/GUI):
|
|||||||
|
|
||||||
All (GUI):
|
All (GUI):
|
||||||
|
|
||||||
|
- implemented radio menu items
|
||||||
- significantly improved native font support
|
- significantly improved native font support
|
||||||
- wxImage::ComputeHistogram() now uses wxImageHistogram instead of type-unsafe
|
- wxImage::ComputeHistogram() now uses wxImageHistogram instead of type-unsafe
|
||||||
wxHashTable
|
wxHashTable
|
||||||
|
@@ -77,7 +77,7 @@ and recreation of internal data structures.
|
|||||||
\membersection{wxMenu::Append}\label{wxmenuappend}
|
\membersection{wxMenu::Append}\label{wxmenuappend}
|
||||||
|
|
||||||
\func{void}{Append}{\param{int}{ id}, \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""},\rtfsp
|
\func{void}{Append}{\param{int}{ id}, \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""},\rtfsp
|
||||||
\param{const bool}{ checkable = FALSE}}
|
\param{wxItemKind}{ kind = wxItem\_Normal}}
|
||||||
|
|
||||||
Adds a string item to the end of the menu.
|
Adds a string item to the end of the menu.
|
||||||
|
|
||||||
@@ -101,7 +101,8 @@ such as bitmaps and fonts.
|
|||||||
|
|
||||||
\docparam{menu}{Pull-right submenu.}
|
\docparam{menu}{Pull-right submenu.}
|
||||||
|
|
||||||
\docparam{checkable}{If TRUE, this item is checkable.}
|
\docparam{kind}{May be {\tt wxItem\_Separator}, {\tt wxItem\_Normal},
|
||||||
|
{\tt wxItem\_Check} or {\tt wxItem\_Radio}}
|
||||||
|
|
||||||
\docparam{helpString}{An optional help string associated with the item.
|
\docparam{helpString}{An optional help string associated with the item.
|
||||||
By default, \helpref{wxFrame::OnMenuHighlight}{wxframeonmenuhighlight} displays
|
By default, \helpref{wxFrame::OnMenuHighlight}{wxframeonmenuhighlight} displays
|
||||||
@@ -118,6 +119,8 @@ creation of a menu or menubar.
|
|||||||
\wxheading{See also}
|
\wxheading{See also}
|
||||||
|
|
||||||
\helpref{wxMenu::AppendSeparator}{wxmenuappendseparator},\rtfsp
|
\helpref{wxMenu::AppendSeparator}{wxmenuappendseparator},\rtfsp
|
||||||
|
\helpref{wxMenu::AppendCheckItem}{wxmenuappendcheckitem},\rtfsp
|
||||||
|
\helpref{wxMenu::AppendRadioItem}{wxmenuappendradioitem},\rtfsp
|
||||||
\helpref{wxMenu::Insert}{wxmenuinsert},\rtfsp
|
\helpref{wxMenu::Insert}{wxmenuinsert},\rtfsp
|
||||||
\helpref{wxMenu::SetLabel}{wxmenusetlabel}, \helpref{wxMenu::GetHelpString}{wxmenugethelpstring},\rtfsp
|
\helpref{wxMenu::SetLabel}{wxmenusetlabel}, \helpref{wxMenu::GetHelpString}{wxmenugethelpstring},\rtfsp
|
||||||
\helpref{wxMenu::SetHelpString}{wxmenusethelpstring}, \helpref{wxMenuItem}{wxmenuitem}
|
\helpref{wxMenu::SetHelpString}{wxmenusethelpstring}, \helpref{wxMenuItem}{wxmenuitem}
|
||||||
@@ -131,6 +134,35 @@ implements the following methods:\par
|
|||||||
\end{twocollist}}
|
\end{twocollist}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
\membersection{wxMenu::AppendCheckItem}\label{wxmenuappendcheckitem}
|
||||||
|
|
||||||
|
\func{void}{AppendCheckItem}{\param{int}{ id},\rtfsp
|
||||||
|
\param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
|
||||||
|
|
||||||
|
Adds a checkable item to the end of the menu.
|
||||||
|
|
||||||
|
\wxheading{See also}
|
||||||
|
|
||||||
|
\helpref{wxMenu::Append}{wxmenuappend},\rtfsp
|
||||||
|
\helpref{wxMenu::InsertCheckItem}{wxmenuinsertcheckitem}
|
||||||
|
|
||||||
|
\membersection{wxMenu::AppendRadioItem}\label{wxmenuappendradioitem}
|
||||||
|
|
||||||
|
\func{void}{AppendRadioItem}{\param{int}{ id},\rtfsp
|
||||||
|
\param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
|
||||||
|
|
||||||
|
Adds a radio item to the end of the menu. All consequent radio items form a
|
||||||
|
group and when an item in the group is checked, all the others are
|
||||||
|
automatically unchecked.
|
||||||
|
|
||||||
|
{\bf NB:} Currently only implemented under Windows and GTK, use
|
||||||
|
{\tt #if wxHAS\_RADIO\_MENU\_ITEMS} to test for availability of this feature.
|
||||||
|
|
||||||
|
\wxheading{See also}
|
||||||
|
|
||||||
|
\helpref{wxMenu::Append}{wxmenuappend},\rtfsp
|
||||||
|
\helpref{wxMenu::InsertRadioItem}{wxmenuinsertradioitem}
|
||||||
|
|
||||||
\membersection{wxMenu::AppendSeparator}\label{wxmenuappendseparator}
|
\membersection{wxMenu::AppendSeparator}\label{wxmenuappendseparator}
|
||||||
|
|
||||||
\func{void}{AppendSeparator}{\void}
|
\func{void}{AppendSeparator}{\void}
|
||||||
@@ -139,7 +171,8 @@ Adds a separator to the end of the menu.
|
|||||||
|
|
||||||
\wxheading{See also}
|
\wxheading{See also}
|
||||||
|
|
||||||
\helpref{wxMenu::Append}{wxmenuappend}
|
\helpref{wxMenu::Append}{wxmenuappend},\rtfsp
|
||||||
|
\helpref{wxMenu::InsertSeparator}{wxmenuinsertseparator}
|
||||||
|
|
||||||
\membersection{wxMenu::Break}\label{wxmenubreak}
|
\membersection{wxMenu::Break}\label{wxmenubreak}
|
||||||
|
|
||||||
@@ -329,13 +362,53 @@ This is relevant only to popup menus.
|
|||||||
|
|
||||||
\func{bool}{Insert}{\param{size\_t }{pos}, \param{wxMenuItem *}{item}}
|
\func{bool}{Insert}{\param{size\_t }{pos}, \param{wxMenuItem *}{item}}
|
||||||
|
|
||||||
|
\func{void}{Insert}{\param{size\_t }{pos}, \param{int}{ id},\rtfsp
|
||||||
|
\param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""},\rtfsp
|
||||||
|
\param{wxItemKind}{ kind = wxItem\_Normal}}
|
||||||
|
|
||||||
Inserts the given {\it item} before the position {\it pos}. Inserting the item
|
Inserts the given {\it item} before the position {\it pos}. Inserting the item
|
||||||
at the position \helpref{GetMenuItemCount}{wxmenugetmenuitemcount} is the same
|
at the position \helpref{GetMenuItemCount}{wxmenugetmenuitemcount} is the same
|
||||||
as appending it.
|
as appending it.
|
||||||
|
|
||||||
\wxheading{See also}
|
\wxheading{See also}
|
||||||
|
|
||||||
\helpref{wxMenu::Append}{wxmenuappend}
|
\helpref{wxMenu::Append}{wxmenuappend},\rtfsp
|
||||||
|
\helpref{wxMenu::Prepend}{wxmenuprepend}
|
||||||
|
|
||||||
|
\membersection{wxMenu::InsertCheckItem}\label{wxmenuinsertcheckitem}
|
||||||
|
|
||||||
|
\func{void}{InsertCheckItem}{\param{size\_t }{pos}, \param{int}{ id},\rtfsp
|
||||||
|
\param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
|
||||||
|
|
||||||
|
Inserts a checkable item at the given position.
|
||||||
|
|
||||||
|
\wxheading{See also}
|
||||||
|
|
||||||
|
\helpref{wxMenu::Insert}{wxmenuinsert},\rtfsp
|
||||||
|
\helpref{wxMenu::AppendCheckItem}{wxmenuappendcheckitem}
|
||||||
|
|
||||||
|
\membersection{wxMenu::InsertRadioItem}\label{wxmenuinsertradioitem}
|
||||||
|
|
||||||
|
\func{void}{InsertRadioItem}{\param{size\_t }{pos}, \param{int}{ id},\rtfsp
|
||||||
|
\param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
|
||||||
|
|
||||||
|
Inserts a radio item at the given position.
|
||||||
|
|
||||||
|
\wxheading{See also}
|
||||||
|
|
||||||
|
\helpref{wxMenu::Insert}{wxmenuinsert},\rtfsp
|
||||||
|
\helpref{wxMenu::AppendRadioItem}{wxmenuappendradioitem}
|
||||||
|
|
||||||
|
\membersection{wxMenu::InsertSeparator}\label{wxmenuinsertseparator}
|
||||||
|
|
||||||
|
\func{void}{InsertSeparator}{\param{size\_t }{pos}}
|
||||||
|
|
||||||
|
Inserts a separator at the given position.
|
||||||
|
|
||||||
|
\wxheading{See also}
|
||||||
|
|
||||||
|
\helpref{wxMenu::Insert}{wxmenuinsert},\rtfsp
|
||||||
|
\helpref{wxMenu::AppendSeparator}{wxmenuappendseparator}
|
||||||
|
|
||||||
\membersection{wxMenu::IsChecked}\label{wxmenuischecked}
|
\membersection{wxMenu::IsChecked}\label{wxmenuischecked}
|
||||||
|
|
||||||
@@ -373,6 +446,56 @@ TRUE if the menu item is enabled, FALSE otherwise.
|
|||||||
|
|
||||||
\helpref{wxMenu::Enable}{wxmenuenable}
|
\helpref{wxMenu::Enable}{wxmenuenable}
|
||||||
|
|
||||||
|
\membersection{wxMenu::Prepend}\label{wxmenuprepend}
|
||||||
|
|
||||||
|
\func{bool}{Prepend}{\param{size\_t }{pos}, \param{wxMenuItem *}{item}}
|
||||||
|
|
||||||
|
\func{void}{Prepend}{\param{int}{ id},\rtfsp
|
||||||
|
\param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""},\rtfsp
|
||||||
|
\param{wxItemKind}{ kind = wxItem\_Normal}}
|
||||||
|
|
||||||
|
Inserts the given {\it item} at the position $0$.
|
||||||
|
|
||||||
|
\wxheading{See also}
|
||||||
|
|
||||||
|
\helpref{wxMenu::Append}{wxmenuappend},\rtfsp
|
||||||
|
\helpref{wxMenu::Inserts}{wxmenuinsert}
|
||||||
|
|
||||||
|
\membersection{wxMenu::PrependCheckItem}\label{wxmenuprependcheckitem}
|
||||||
|
|
||||||
|
\func{void}{PrependCheckItem}{\param{int}{ id},\rtfsp
|
||||||
|
\param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
|
||||||
|
|
||||||
|
Inserts a checkable item at the position $0$.
|
||||||
|
|
||||||
|
\wxheading{See also}
|
||||||
|
|
||||||
|
\helpref{wxMenu::Prepend}{wxmenuprepend},\rtfsp
|
||||||
|
\helpref{wxMenu::AppendCheckItem}{wxmenuappendcheckitem}
|
||||||
|
|
||||||
|
\membersection{wxMenu::PrependRadioItem}\label{wxmenuprependradioitem}
|
||||||
|
|
||||||
|
\func{void}{PrependRadioItem}{\param{int}{ id},\rtfsp
|
||||||
|
\param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
|
||||||
|
|
||||||
|
Inserts a radio item at the position $0$.
|
||||||
|
|
||||||
|
\wxheading{See also}
|
||||||
|
|
||||||
|
\helpref{wxMenu::Prepend}{wxmenuprepend},\rtfsp
|
||||||
|
\helpref{wxMenu::AppendRadioItem}{wxmenuappendradioitem}
|
||||||
|
|
||||||
|
\membersection{wxMenu::PrependSeparator}\label{wxmenuprependseparator}
|
||||||
|
|
||||||
|
\func{void}{PrependSeparator}{\param{size\_t }{pos}}
|
||||||
|
|
||||||
|
Inserts a separator at the position $0$.
|
||||||
|
|
||||||
|
\wxheading{See also}
|
||||||
|
|
||||||
|
\helpref{wxMenu::Prepend}{wxmenuprepend},\rtfsp
|
||||||
|
\helpref{wxMenu::AppendSeparator}{wxmenuappendseparator}
|
||||||
|
|
||||||
\membersection{wxMenu::Remove}\label{wxmenuremove}
|
\membersection{wxMenu::Remove}\label{wxmenuremove}
|
||||||
|
|
||||||
\func{wxMenuItem *}{Remove}{\param{int }{id}}
|
\func{wxMenuItem *}{Remove}{\param{int }{id}}
|
||||||
|
@@ -1,8 +1,11 @@
|
|||||||
\section{\class{wxMenuItem}}\label{wxmenuitem}
|
\section{\class{wxMenuItem}}\label{wxmenuitem}
|
||||||
|
|
||||||
A menu item represents an item in a popup menu. Note that the majority of this
|
A menu item represents an item in a menu. Note that you usually don't have to
|
||||||
class is only implemented under Windows so far, but everything except fonts, colours and
|
deal with it directly as \helpref{wxMenu}{wxmenu} methods usually construct an
|
||||||
bitmaps can be achieved via wxMenu on all platforms.
|
object of this class for you.
|
||||||
|
|
||||||
|
Also please note that the methods related to fonts and bitmaps are currently
|
||||||
|
only implemented for Windows.
|
||||||
|
|
||||||
\wxheading{Derived from}
|
\wxheading{Derived from}
|
||||||
|
|
||||||
@@ -23,7 +26,7 @@ wxOwnerDrawn (Windows only)\\
|
|||||||
|
|
||||||
\func{}{wxMenuItem}{\param{wxMenu*}{ parentMenu = NULL}, \param{int}{ id = ID\_SEPARATOR},
|
\func{}{wxMenuItem}{\param{wxMenu*}{ parentMenu = NULL}, \param{int}{ id = ID\_SEPARATOR},
|
||||||
\param{const wxString\& }{text = ""}, \param{const wxString\& }{helpString = ""},
|
\param{const wxString\& }{text = ""}, \param{const wxString\& }{helpString = ""},
|
||||||
\param{bool }{checkable = FALSE}, \param{wxMenu*}{ subMenu = NULL}, }
|
\param{wxItemKind }{kind = wxItem\_Normal}, \param{wxMenu*}{ subMenu = NULL}, }
|
||||||
|
|
||||||
Constructs a wxMenuItem object.
|
Constructs a wxMenuItem object.
|
||||||
|
|
||||||
@@ -37,7 +40,8 @@ Constructs a wxMenuItem object.
|
|||||||
|
|
||||||
\docparam{helpString}{Optional help string that will be shown on the status bar.}
|
\docparam{helpString}{Optional help string that will be shown on the status bar.}
|
||||||
|
|
||||||
\docparam{checkable}{TRUE if this menu item is checkable.}
|
\docparam{kind}{May be {\tt wxItem\_Separator}, {\tt wxItem\_Normal},
|
||||||
|
{\tt wxItem\_Check} or {\tt wxItem\_Radio}}
|
||||||
|
|
||||||
\docparam{subMenu}{If non-NULL, indicates that the menu item is a submenu.}
|
\docparam{subMenu}{If non-NULL, indicates that the menu item is a submenu.}
|
||||||
|
|
||||||
@@ -95,6 +99,13 @@ Returns the help string associated with the menu item.
|
|||||||
|
|
||||||
Returns the menu item identifier.
|
Returns the menu item identifier.
|
||||||
|
|
||||||
|
\membersection{wxMenuItem::GetKind}\label{wxmenuitemgetkind}
|
||||||
|
|
||||||
|
\constfunc{wxItemKind}{GetKind}{\void}
|
||||||
|
|
||||||
|
Returns the item kind, one of {\tt wxItem\_Separator}, {\tt wxItem\_Normal},
|
||||||
|
{\tt wxItem\_Check} or {\tt wxItem\_Radio}.
|
||||||
|
|
||||||
\membersection{wxMenuItem::GetLabel}\label{wxmenuitemgetlabel}
|
\membersection{wxMenuItem::GetLabel}\label{wxmenuitemgetlabel}
|
||||||
|
|
||||||
\constfunc{wxString}{GetLabel}{\void}
|
\constfunc{wxString}{GetLabel}{\void}
|
||||||
|
@@ -35,6 +35,9 @@
|
|||||||
#endif // Unix/!Unix
|
#endif // Unix/!Unix
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// include the feature test macros
|
||||||
|
#include "wx/features.h"
|
||||||
|
|
||||||
// suppress some Visual C++ warnings
|
// suppress some Visual C++ warnings
|
||||||
#ifdef __VISUALC__
|
#ifdef __VISUALC__
|
||||||
# pragma warning(disable:4201) // nonstandard extension used: nameless struct/union
|
# pragma warning(disable:4201) // nonstandard extension used: nameless struct/union
|
||||||
@@ -1276,6 +1279,16 @@ enum wxBorder
|
|||||||
// constants
|
// constants
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// menu and toolbar item kinds
|
||||||
|
enum wxItemKind
|
||||||
|
{
|
||||||
|
wxItem_Separator = -1,
|
||||||
|
wxItem_Normal,
|
||||||
|
wxItem_Check,
|
||||||
|
wxItem_Radio,
|
||||||
|
wxItem_Max
|
||||||
|
};
|
||||||
|
|
||||||
// hit test results
|
// hit test results
|
||||||
enum wxHitTest
|
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
|
// common part of Append and Insert
|
||||||
bool GtkAppend(wxMenuItem *item);
|
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)
|
DECLARE_DYNAMIC_CLASS(wxMenu)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -27,7 +27,7 @@ public:
|
|||||||
int id = wxID_SEPARATOR,
|
int id = wxID_SEPARATOR,
|
||||||
const wxString& text = wxEmptyString,
|
const wxString& text = wxEmptyString,
|
||||||
const wxString& help = wxEmptyString,
|
const wxString& help = wxEmptyString,
|
||||||
bool isCheckable = FALSE,
|
wxItemKind kind = wxItem_Normal,
|
||||||
wxMenu *subMenu = (wxMenu *)NULL);
|
wxMenu *subMenu = (wxMenu *)NULL);
|
||||||
~wxMenuItem();
|
~wxMenuItem();
|
||||||
|
|
||||||
|
@@ -107,6 +107,10 @@ private:
|
|||||||
// common part of Append and Insert
|
// common part of Append and Insert
|
||||||
bool GtkAppend(wxMenuItem *item);
|
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)
|
DECLARE_DYNAMIC_CLASS(wxMenu)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -27,7 +27,7 @@ public:
|
|||||||
int id = wxID_SEPARATOR,
|
int id = wxID_SEPARATOR,
|
||||||
const wxString& text = wxEmptyString,
|
const wxString& text = wxEmptyString,
|
||||||
const wxString& help = wxEmptyString,
|
const wxString& help = wxEmptyString,
|
||||||
bool isCheckable = FALSE,
|
wxItemKind kind = wxItem_Normal,
|
||||||
wxMenu *subMenu = (wxMenu *)NULL);
|
wxMenu *subMenu = (wxMenu *)NULL);
|
||||||
~wxMenuItem();
|
~wxMenuItem();
|
||||||
|
|
||||||
|
@@ -43,7 +43,7 @@ public:
|
|||||||
int id = wxID_SEPARATOR,
|
int id = wxID_SEPARATOR,
|
||||||
const wxString& name = wxEmptyString,
|
const wxString& name = wxEmptyString,
|
||||||
const wxString& help = wxEmptyString,
|
const wxString& help = wxEmptyString,
|
||||||
bool isCheckable = FALSE,
|
wxItemKind kind = wxItem_Normal,
|
||||||
wxMenu *subMenu = (wxMenu *)NULL);
|
wxMenu *subMenu = (wxMenu *)NULL);
|
||||||
virtual ~wxMenuItem();
|
virtual ~wxMenuItem();
|
||||||
|
|
||||||
|
@@ -75,18 +75,34 @@ public:
|
|||||||
// menu construction
|
// menu construction
|
||||||
// -----------------
|
// -----------------
|
||||||
|
|
||||||
// append a normal item to the menu
|
// append any kind of item (normal/check/radio/separator)
|
||||||
void Append(int id,
|
void Append(int id,
|
||||||
const wxString& text,
|
const wxString& text,
|
||||||
const wxString& help = wxEmptyString,
|
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
|
// append a separator to the menu
|
||||||
void AppendSeparator() { Append(wxID_SEPARATOR, wxEmptyString); }
|
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
|
// append a submenu
|
||||||
void Append(int id,
|
void Append(int id,
|
||||||
const wxString& text,
|
const wxString& text,
|
||||||
@@ -105,13 +121,15 @@ public:
|
|||||||
|
|
||||||
// insert an item before given position
|
// insert an item before given position
|
||||||
bool Insert(size_t pos, wxMenuItem *item);
|
bool Insert(size_t pos, wxMenuItem *item);
|
||||||
|
|
||||||
|
// insert an item before given position
|
||||||
void Insert(size_t pos,
|
void Insert(size_t pos,
|
||||||
int id,
|
int id,
|
||||||
const wxString& text,
|
const wxString& text,
|
||||||
const wxString& help = wxEmptyString,
|
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
|
// insert a separator
|
||||||
@@ -120,6 +138,24 @@ public:
|
|||||||
Insert(pos, wxMenuItem::New((wxMenu *)this));
|
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
|
// insert a submenu
|
||||||
void Insert(size_t pos,
|
void Insert(size_t pos,
|
||||||
int id,
|
int id,
|
||||||
@@ -136,21 +172,38 @@ public:
|
|||||||
Insert(0u, item);
|
Insert(0u, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// prepend any item to the menu
|
||||||
void Prepend(int id,
|
void Prepend(int id,
|
||||||
const wxString& text,
|
const wxString& text,
|
||||||
const wxString& help = wxEmptyString,
|
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()
|
void PrependSeparator()
|
||||||
{
|
{
|
||||||
InsertSeparator(0u);
|
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,
|
void Prepend(int id,
|
||||||
const wxString& text,
|
const wxString& text,
|
||||||
wxMenu *submenu,
|
wxMenu *submenu,
|
||||||
@@ -241,8 +294,51 @@ public:
|
|||||||
void SetParent(wxMenu *parent) { m_menuParent = parent; }
|
void SetParent(wxMenu *parent) { m_menuParent = parent; }
|
||||||
wxMenu *GetParent() const { return m_menuParent; }
|
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
|
// 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 Enabled(int id) const { return IsEnabled(id); }
|
||||||
bool Checked(int id) const { return IsChecked(id); }
|
bool Checked(int id) const { return IsChecked(id); }
|
||||||
|
|
||||||
@@ -260,17 +356,6 @@ public:
|
|||||||
wxFunction m_callback;
|
wxFunction m_callback;
|
||||||
#endif // wxUSE_MENU_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:
|
protected:
|
||||||
// virtuals to override in derived classes
|
// virtuals to override in derived classes
|
||||||
// ---------------------------------------
|
// ---------------------------------------
|
||||||
|
@@ -41,7 +41,7 @@ public:
|
|||||||
int id = wxID_SEPARATOR,
|
int id = wxID_SEPARATOR,
|
||||||
const wxString& text = wxEmptyString,
|
const wxString& text = wxEmptyString,
|
||||||
const wxString& help = wxEmptyString,
|
const wxString& help = wxEmptyString,
|
||||||
bool isCheckable = FALSE,
|
wxItemKind kind = wxItem_Normal,
|
||||||
wxMenu *subMenu = (wxMenu *)NULL);
|
wxMenu *subMenu = (wxMenu *)NULL);
|
||||||
|
|
||||||
// destruction: wxMenuItem will delete its submenu
|
// destruction: wxMenuItem will delete its submenu
|
||||||
@@ -69,8 +69,10 @@ public:
|
|||||||
static wxString GetLabelFromText(const wxString& text);
|
static wxString GetLabelFromText(const wxString& text);
|
||||||
|
|
||||||
// what kind of menu item we are
|
// what kind of menu item we are
|
||||||
virtual void SetCheckable(bool checkable) { m_isCheckable = checkable; }
|
wxItemKind GetKind() const { return m_kind; }
|
||||||
bool IsCheckable() const { return m_isCheckable; }
|
|
||||||
|
virtual void SetCheckable(bool checkable) { m_kind = wxItem_Check; }
|
||||||
|
bool IsCheckable() const { return m_kind == wxItem_Check; }
|
||||||
|
|
||||||
bool IsSubMenu() const { return m_subMenu != NULL; }
|
bool IsSubMenu() const { return m_subMenu != NULL; }
|
||||||
void SetSubMenu(wxMenu *menu) { m_subMenu = menu; }
|
void SetSubMenu(wxMenu *menu) { m_subMenu = menu; }
|
||||||
@@ -105,18 +107,34 @@ public:
|
|||||||
void SetName(const wxString& str) { SetText(str); }
|
void SetName(const wxString& str) { SetText(str); }
|
||||||
const wxString& GetName() const { return GetText(); }
|
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:
|
protected:
|
||||||
int m_id; // numeric id of the item >= 0 or -1
|
int m_id; // numeric id of the item >= 0 or -1
|
||||||
wxMenu *m_parentMenu, // the menu we belong to
|
wxMenu *m_parentMenu, // the menu we belong to
|
||||||
*m_subMenu; // our sub menu or NULL
|
*m_subMenu; // our sub menu or NULL
|
||||||
wxString m_text, // label of the item
|
wxString m_text, // label of the item
|
||||||
m_help; // the help string for 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_isChecked; // is checked?
|
||||||
bool m_isEnabled; // is enabled?
|
bool m_isEnabled; // is enabled?
|
||||||
|
|
||||||
// some compilers need a default constructor here, do not remove
|
// this ctor is for the derived classes only, we're never created directly
|
||||||
wxMenuItemBase() { }
|
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:
|
private:
|
||||||
// and, if we have one ctor, compiler won't generate a default copy one, so
|
// and, if we have one ctor, compiler won't generate a default copy one, so
|
||||||
|
@@ -29,11 +29,11 @@ class wxMenuItem : public wxMenuItemBase
|
|||||||
public:
|
public:
|
||||||
// ctor & dtor
|
// ctor & dtor
|
||||||
wxMenuItem(wxMenu *parentMenu = (wxMenu *)NULL,
|
wxMenuItem(wxMenu *parentMenu = (wxMenu *)NULL,
|
||||||
int id = wxID_SEPARATOR,
|
int id = wxID_SEPARATOR,
|
||||||
const wxString& text = wxEmptyString,
|
const wxString& text = wxEmptyString,
|
||||||
const wxString& help = wxEmptyString,
|
const wxString& help = wxEmptyString,
|
||||||
bool isCheckable = FALSE,
|
wxItemKind kind = wxItem_Normal,
|
||||||
wxMenu *subMenu = (wxMenu *)NULL);
|
wxMenu *subMenu = (wxMenu *)NULL);
|
||||||
~wxMenuItem();
|
~wxMenuItem();
|
||||||
|
|
||||||
// accessors (some more are inherited from wxOwnerDrawn or are below)
|
// accessors (some more are inherited from wxOwnerDrawn or are below)
|
||||||
|
@@ -39,7 +39,7 @@ public:
|
|||||||
int id = wxID_SEPARATOR,
|
int id = wxID_SEPARATOR,
|
||||||
const wxString& name = wxEmptyString,
|
const wxString& name = wxEmptyString,
|
||||||
const wxString& help = wxEmptyString,
|
const wxString& help = wxEmptyString,
|
||||||
bool isCheckable = FALSE,
|
wxItemKind kind = wxItem_Normal,
|
||||||
wxMenu *subMenu = (wxMenu *)NULL);
|
wxMenu *subMenu = (wxMenu *)NULL);
|
||||||
virtual ~wxMenuItem();
|
virtual ~wxMenuItem();
|
||||||
|
|
||||||
|
@@ -47,7 +47,7 @@ public:
|
|||||||
,int nId = wxID_SEPARATOR
|
,int nId = wxID_SEPARATOR
|
||||||
,const wxString& rStrName = ""
|
,const wxString& rStrName = ""
|
||||||
,const wxString& rWxHelp = ""
|
,const wxString& rWxHelp = ""
|
||||||
,bool bCheckable = FALSE
|
,wxItemKind kind = wxItem_Normal
|
||||||
,wxMenu* pSubMenu = NULL
|
,wxMenu* pSubMenu = NULL
|
||||||
);
|
);
|
||||||
virtual ~wxMenuItem();
|
virtual ~wxMenuItem();
|
||||||
|
@@ -28,7 +28,7 @@ public:
|
|||||||
int id = wxID_SEPARATOR,
|
int id = wxID_SEPARATOR,
|
||||||
const wxString& name = wxEmptyString,
|
const wxString& name = wxEmptyString,
|
||||||
const wxString& help = wxEmptyString,
|
const wxString& help = wxEmptyString,
|
||||||
bool isCheckable = FALSE,
|
wxItemKind kind = wxItem_Normal,
|
||||||
wxMenu *subMenu = (wxMenu *)NULL);
|
wxMenu *subMenu = (wxMenu *)NULL);
|
||||||
virtual ~wxMenuItem();
|
virtual ~wxMenuItem();
|
||||||
|
|
||||||
|
@@ -88,6 +88,10 @@ protected:
|
|||||||
void OnGetLabelMenu(wxCommandEvent& event);
|
void OnGetLabelMenu(wxCommandEvent& event);
|
||||||
void OnSetLabelMenu(wxCommandEvent& event);
|
void OnSetLabelMenu(wxCommandEvent& event);
|
||||||
|
|
||||||
|
void OnTestNormal(wxCommandEvent& event);
|
||||||
|
void OnTestCheck(wxCommandEvent& event);
|
||||||
|
void OnTestRadio(wxCommandEvent& event);
|
||||||
|
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
void OnContextMenu(wxContextMenuEvent& event)
|
void OnContextMenu(wxContextMenuEvent& event)
|
||||||
{ ShowContextMenu(ScreenToClient(event.GetPosition())); }
|
{ ShowContextMenu(ScreenToClient(event.GetPosition())); }
|
||||||
@@ -174,7 +178,13 @@ enum
|
|||||||
Menu_Menu_SetLabel,
|
Menu_Menu_SetLabel,
|
||||||
Menu_Menu_GetInfo,
|
Menu_Menu_GetInfo,
|
||||||
|
|
||||||
Menu_Dummy_First = 400,
|
Menu_Test_Normal = 400,
|
||||||
|
Menu_Test_Check,
|
||||||
|
Menu_Test_Radio1,
|
||||||
|
Menu_Test_Radio2,
|
||||||
|
Menu_Test_Radio3,
|
||||||
|
|
||||||
|
Menu_Dummy_First = 500,
|
||||||
Menu_Dummy_Second,
|
Menu_Dummy_Second,
|
||||||
Menu_Dummy_Third,
|
Menu_Dummy_Third,
|
||||||
Menu_Dummy_Fourth,
|
Menu_Dummy_Fourth,
|
||||||
@@ -218,6 +228,12 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
|||||||
EVT_MENU(Menu_Menu_SetLabel, MyFrame::OnSetLabelMenuItem)
|
EVT_MENU(Menu_Menu_SetLabel, MyFrame::OnSetLabelMenuItem)
|
||||||
EVT_MENU(Menu_Menu_GetInfo, MyFrame::OnGetMenuItemInfo)
|
EVT_MENU(Menu_Menu_GetInfo, MyFrame::OnGetMenuItemInfo)
|
||||||
|
|
||||||
|
EVT_MENU(Menu_Test_Normal, MyFrame::OnTestNormal)
|
||||||
|
EVT_MENU(Menu_Test_Check, MyFrame::OnTestCheck)
|
||||||
|
EVT_MENU(Menu_Test_Radio1, MyFrame::OnTestRadio)
|
||||||
|
EVT_MENU(Menu_Test_Radio2, MyFrame::OnTestRadio)
|
||||||
|
EVT_MENU(Menu_Test_Radio3, MyFrame::OnTestRadio)
|
||||||
|
|
||||||
EVT_MENU_RANGE(Menu_Dummy_First, Menu_Dummy_Last, MyFrame::OnDummy)
|
EVT_MENU_RANGE(Menu_Dummy_First, Menu_Dummy_Last, MyFrame::OnDummy)
|
||||||
|
|
||||||
EVT_UPDATE_UI(Menu_Menu_Check, MyFrame::OnUpdateCheckMenuItemUI)
|
EVT_UPDATE_UI(Menu_Menu_Check, MyFrame::OnUpdateCheckMenuItemUI)
|
||||||
@@ -335,6 +351,15 @@ MyFrame::MyFrame()
|
|||||||
menuMenu->Append(Menu_Menu_GetInfo, "Get menu item in&fo\tAlt-F",
|
menuMenu->Append(Menu_Menu_GetInfo, "Get menu item in&fo\tAlt-F",
|
||||||
"Show the state of the last menu item");
|
"Show the state of the last menu item");
|
||||||
|
|
||||||
|
wxMenu *testMenu = new wxMenu;
|
||||||
|
testMenu->Append(Menu_Test_Normal, "&Normal item");
|
||||||
|
testMenu->AppendSeparator();
|
||||||
|
testMenu->AppendCheckItem(Menu_Test_Check, "&Check item");
|
||||||
|
testMenu->AppendSeparator();
|
||||||
|
testMenu->AppendRadioItem(Menu_Test_Radio1, "Radio item &1");
|
||||||
|
testMenu->AppendRadioItem(Menu_Test_Radio2, "Radio item &2");
|
||||||
|
testMenu->AppendRadioItem(Menu_Test_Radio3, "Radio item &3");
|
||||||
|
|
||||||
wxMenu *helpMenu = new wxMenu;
|
wxMenu *helpMenu = new wxMenu;
|
||||||
helpMenu->Append(Menu_Help_About, "&About\tF1", "About menu sample");
|
helpMenu->Append(Menu_Help_About, "&About\tF1", "About menu sample");
|
||||||
|
|
||||||
@@ -343,6 +368,7 @@ MyFrame::MyFrame()
|
|||||||
menuBar->Append(fileMenu, "&File");
|
menuBar->Append(fileMenu, "&File");
|
||||||
menuBar->Append(menubarMenu, "Menu&bar");
|
menuBar->Append(menubarMenu, "Menu&bar");
|
||||||
menuBar->Append(menuMenu, "&Menu");
|
menuBar->Append(menuMenu, "&Menu");
|
||||||
|
menuBar->Append(testMenu, "&Test");
|
||||||
menuBar->Append(helpMenu, "&Help");
|
menuBar->Append(helpMenu, "&Help");
|
||||||
|
|
||||||
// these items should be initially checked
|
// these items should be initially checked
|
||||||
@@ -750,6 +776,23 @@ void MyFrame::ShowContextMenu(const wxPoint& pos)
|
|||||||
#endif // 0
|
#endif // 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyFrame::OnTestNormal(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
wxLogMessage(_T("Normal item selected"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyFrame::OnTestCheck(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
wxLogMessage(_T("Check item %schecked"),
|
||||||
|
event.IsChecked() ? _T("") : _T("un"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyFrame::OnTestRadio(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
wxLogMessage(_T("Radio item %d selected"),
|
||||||
|
event.GetId() - Menu_Test_Radio1 + 1);
|
||||||
|
}
|
||||||
|
|
||||||
void MyFrame::LogMenuOpenOrClose(const wxMenuEvent& event, const wxChar *what)
|
void MyFrame::LogMenuOpenOrClose(const wxMenuEvent& event, const wxChar *what)
|
||||||
{
|
{
|
||||||
wxLogStatus(this, _T("A %smenu has been %s."),
|
wxLogStatus(this, _T("A %smenu has been %s."),
|
||||||
|
@@ -55,6 +55,25 @@ WX_DEFINE_LIST(wxMenuItemList);
|
|||||||
// wxMenuItem
|
// wxMenuItem
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxMenuItemBase::wxMenuItemBase(wxMenu *parentMenu,
|
||||||
|
int id,
|
||||||
|
const wxString& text,
|
||||||
|
const wxString& help,
|
||||||
|
wxItemKind kind,
|
||||||
|
wxMenu *subMenu)
|
||||||
|
: m_text(text),
|
||||||
|
m_help(help)
|
||||||
|
{
|
||||||
|
wxASSERT_MSG( parentMenu != NULL, wxT("menuitem should have a menu") );
|
||||||
|
|
||||||
|
m_parentMenu = parentMenu;
|
||||||
|
m_subMenu = subMenu;
|
||||||
|
m_isEnabled = TRUE;
|
||||||
|
m_isChecked = FALSE;
|
||||||
|
m_id = id;
|
||||||
|
m_kind = kind;
|
||||||
|
}
|
||||||
|
|
||||||
wxMenuItemBase::~wxMenuItemBase()
|
wxMenuItemBase::~wxMenuItemBase()
|
||||||
{
|
{
|
||||||
delete m_subMenu;
|
delete m_subMenu;
|
||||||
|
@@ -699,27 +699,20 @@ wxMenuItem *wxMenuItemBase::New(wxMenu *parentMenu,
|
|||||||
int id,
|
int id,
|
||||||
const wxString& name,
|
const wxString& name,
|
||||||
const wxString& help,
|
const wxString& help,
|
||||||
bool isCheckable,
|
wxItemKind kind,
|
||||||
wxMenu *subMenu)
|
wxMenu *subMenu)
|
||||||
{
|
{
|
||||||
return new wxMenuItem(parentMenu, id, name, help, isCheckable, subMenu);
|
return new wxMenuItem(parentMenu, id, name, help, kind, subMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMenuItem::wxMenuItem(wxMenu *parentMenu,
|
wxMenuItem::wxMenuItem(wxMenu *parentMenu,
|
||||||
int id,
|
int id,
|
||||||
const wxString& text,
|
const wxString& text,
|
||||||
const wxString& help,
|
const wxString& help,
|
||||||
bool isCheckable,
|
wxItemKind kind,
|
||||||
wxMenu *subMenu)
|
wxMenu *subMenu)
|
||||||
|
: wxMenuItemBase(parentMenu, id, text, help, kind, subMenu)
|
||||||
{
|
{
|
||||||
m_id = id;
|
|
||||||
m_isCheckable = isCheckable;
|
|
||||||
m_isChecked = FALSE;
|
|
||||||
m_isEnabled = TRUE;
|
|
||||||
m_subMenu = subMenu;
|
|
||||||
m_parentMenu = parentMenu;
|
|
||||||
m_help = help;
|
|
||||||
|
|
||||||
m_labelWidget = (GtkWidget *) NULL;
|
m_labelWidget = (GtkWidget *) NULL;
|
||||||
m_menuItem = (GtkWidget *) NULL;
|
m_menuItem = (GtkWidget *) NULL;
|
||||||
|
|
||||||
@@ -948,6 +941,11 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
|
|||||||
bool appended = FALSE;
|
bool appended = FALSE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if GTK_CHECK_VERSION(1, 2, 0)
|
||||||
|
// is this a radio item?
|
||||||
|
bool isRadio = FALSE;
|
||||||
|
#endif // GTK+ >= 1.2
|
||||||
|
|
||||||
if ( mitem->IsSeparator() )
|
if ( mitem->IsSeparator() )
|
||||||
{
|
{
|
||||||
#if GTK_CHECK_VERSION(1, 2, 0)
|
#if GTK_CHECK_VERSION(1, 2, 0)
|
||||||
@@ -1046,16 +1044,52 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
|
|||||||
/* local buffer in multibyte form */
|
/* local buffer in multibyte form */
|
||||||
char buf[200];
|
char buf[200];
|
||||||
strcpy( buf, "/" );
|
strcpy( buf, "/" );
|
||||||
strcat( buf, text.mb_str() );
|
strncat( buf, text.mb_str(), WXSIZEOF(buf) - 2 );
|
||||||
|
buf[WXSIZEOF(buf) - 1] = '\0';
|
||||||
|
|
||||||
GtkItemFactoryEntry entry;
|
GtkItemFactoryEntry entry;
|
||||||
entry.path = buf;
|
entry.path = buf;
|
||||||
entry.callback = (GtkItemFactoryCallback) gtk_menu_clicked_callback;
|
entry.callback = (GtkItemFactoryCallback) gtk_menu_clicked_callback;
|
||||||
entry.callback_action = 0;
|
entry.callback_action = 0;
|
||||||
if ( mitem->IsCheckable() )
|
|
||||||
entry.item_type = (char *)"<CheckItem>";
|
wxString pathRadio;
|
||||||
else
|
const char *item_type;
|
||||||
entry.item_type = (char *)"<Item>";
|
switch ( mitem->GetKind() )
|
||||||
|
{
|
||||||
|
case wxItem_Check:
|
||||||
|
item_type = "<CheckItem>";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxItem_Radio:
|
||||||
|
if ( m_pathLastRadio.empty() )
|
||||||
|
{
|
||||||
|
// start of a new radio group
|
||||||
|
item_type = "<RadioItem>";
|
||||||
|
m_pathLastRadio = buf + 1;
|
||||||
|
}
|
||||||
|
else // continue the radio group
|
||||||
|
{
|
||||||
|
pathRadio = m_pathLastRadio;
|
||||||
|
pathRadio.Replace("_", "");
|
||||||
|
pathRadio.Prepend("<main>/");
|
||||||
|
item_type = pathRadio;
|
||||||
|
}
|
||||||
|
|
||||||
|
// remember that this one was a radio item to avoid resetting
|
||||||
|
// m_pathLastRadio below
|
||||||
|
isRadio = TRUE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
wxFAIL_MSG( _T("unexpected menu item kind") );
|
||||||
|
// fall through
|
||||||
|
|
||||||
|
case wxItem_Normal:
|
||||||
|
item_type = "<Item>";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
entry.item_type = (char *)item_type; // cast needed for GTK+
|
||||||
entry.accelerator = (gchar*) NULL;
|
entry.accelerator = (gchar*) NULL;
|
||||||
|
|
||||||
#if wxUSE_ACCEL
|
#if wxUSE_ACCEL
|
||||||
@@ -1105,6 +1139,13 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
|
|||||||
|
|
||||||
mitem->SetMenuItem(menuItem);
|
mitem->SetMenuItem(menuItem);
|
||||||
|
|
||||||
|
#if GTK_CHECK_VERSION(1, 2, 0)
|
||||||
|
if ( !isRadio )
|
||||||
|
{
|
||||||
|
m_pathLastRadio.clear();
|
||||||
|
}
|
||||||
|
#endif // GTK+ >= 1.2
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -699,27 +699,20 @@ wxMenuItem *wxMenuItemBase::New(wxMenu *parentMenu,
|
|||||||
int id,
|
int id,
|
||||||
const wxString& name,
|
const wxString& name,
|
||||||
const wxString& help,
|
const wxString& help,
|
||||||
bool isCheckable,
|
wxItemKind kind,
|
||||||
wxMenu *subMenu)
|
wxMenu *subMenu)
|
||||||
{
|
{
|
||||||
return new wxMenuItem(parentMenu, id, name, help, isCheckable, subMenu);
|
return new wxMenuItem(parentMenu, id, name, help, kind, subMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMenuItem::wxMenuItem(wxMenu *parentMenu,
|
wxMenuItem::wxMenuItem(wxMenu *parentMenu,
|
||||||
int id,
|
int id,
|
||||||
const wxString& text,
|
const wxString& text,
|
||||||
const wxString& help,
|
const wxString& help,
|
||||||
bool isCheckable,
|
wxItemKind kind,
|
||||||
wxMenu *subMenu)
|
wxMenu *subMenu)
|
||||||
|
: wxMenuItemBase(parentMenu, id, text, help, kind, subMenu)
|
||||||
{
|
{
|
||||||
m_id = id;
|
|
||||||
m_isCheckable = isCheckable;
|
|
||||||
m_isChecked = FALSE;
|
|
||||||
m_isEnabled = TRUE;
|
|
||||||
m_subMenu = subMenu;
|
|
||||||
m_parentMenu = parentMenu;
|
|
||||||
m_help = help;
|
|
||||||
|
|
||||||
m_labelWidget = (GtkWidget *) NULL;
|
m_labelWidget = (GtkWidget *) NULL;
|
||||||
m_menuItem = (GtkWidget *) NULL;
|
m_menuItem = (GtkWidget *) NULL;
|
||||||
|
|
||||||
@@ -948,6 +941,11 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
|
|||||||
bool appended = FALSE;
|
bool appended = FALSE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if GTK_CHECK_VERSION(1, 2, 0)
|
||||||
|
// is this a radio item?
|
||||||
|
bool isRadio = FALSE;
|
||||||
|
#endif // GTK+ >= 1.2
|
||||||
|
|
||||||
if ( mitem->IsSeparator() )
|
if ( mitem->IsSeparator() )
|
||||||
{
|
{
|
||||||
#if GTK_CHECK_VERSION(1, 2, 0)
|
#if GTK_CHECK_VERSION(1, 2, 0)
|
||||||
@@ -1046,16 +1044,52 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
|
|||||||
/* local buffer in multibyte form */
|
/* local buffer in multibyte form */
|
||||||
char buf[200];
|
char buf[200];
|
||||||
strcpy( buf, "/" );
|
strcpy( buf, "/" );
|
||||||
strcat( buf, text.mb_str() );
|
strncat( buf, text.mb_str(), WXSIZEOF(buf) - 2 );
|
||||||
|
buf[WXSIZEOF(buf) - 1] = '\0';
|
||||||
|
|
||||||
GtkItemFactoryEntry entry;
|
GtkItemFactoryEntry entry;
|
||||||
entry.path = buf;
|
entry.path = buf;
|
||||||
entry.callback = (GtkItemFactoryCallback) gtk_menu_clicked_callback;
|
entry.callback = (GtkItemFactoryCallback) gtk_menu_clicked_callback;
|
||||||
entry.callback_action = 0;
|
entry.callback_action = 0;
|
||||||
if ( mitem->IsCheckable() )
|
|
||||||
entry.item_type = (char *)"<CheckItem>";
|
wxString pathRadio;
|
||||||
else
|
const char *item_type;
|
||||||
entry.item_type = (char *)"<Item>";
|
switch ( mitem->GetKind() )
|
||||||
|
{
|
||||||
|
case wxItem_Check:
|
||||||
|
item_type = "<CheckItem>";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxItem_Radio:
|
||||||
|
if ( m_pathLastRadio.empty() )
|
||||||
|
{
|
||||||
|
// start of a new radio group
|
||||||
|
item_type = "<RadioItem>";
|
||||||
|
m_pathLastRadio = buf + 1;
|
||||||
|
}
|
||||||
|
else // continue the radio group
|
||||||
|
{
|
||||||
|
pathRadio = m_pathLastRadio;
|
||||||
|
pathRadio.Replace("_", "");
|
||||||
|
pathRadio.Prepend("<main>/");
|
||||||
|
item_type = pathRadio;
|
||||||
|
}
|
||||||
|
|
||||||
|
// remember that this one was a radio item to avoid resetting
|
||||||
|
// m_pathLastRadio below
|
||||||
|
isRadio = TRUE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
wxFAIL_MSG( _T("unexpected menu item kind") );
|
||||||
|
// fall through
|
||||||
|
|
||||||
|
case wxItem_Normal:
|
||||||
|
item_type = "<Item>";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
entry.item_type = (char *)item_type; // cast needed for GTK+
|
||||||
entry.accelerator = (gchar*) NULL;
|
entry.accelerator = (gchar*) NULL;
|
||||||
|
|
||||||
#if wxUSE_ACCEL
|
#if wxUSE_ACCEL
|
||||||
@@ -1105,6 +1139,13 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
|
|||||||
|
|
||||||
mitem->SetMenuItem(menuItem);
|
mitem->SetMenuItem(menuItem);
|
||||||
|
|
||||||
|
#if GTK_CHECK_VERSION(1, 2, 0)
|
||||||
|
if ( !isRadio )
|
||||||
|
{
|
||||||
|
m_pathLastRadio.clear();
|
||||||
|
}
|
||||||
|
#endif // GTK+ >= 1.2
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -175,23 +175,15 @@ int wxMenuItem::MacBuildMenuString(StringPtr outMacItemText, SInt16 *outMacShort
|
|||||||
// ctor & dtor
|
// ctor & dtor
|
||||||
// -----------
|
// -----------
|
||||||
|
|
||||||
wxMenuItem::wxMenuItem(wxMenu *pParentMenu, int id,
|
wxMenuItem::wxMenuItem(wxMenu *pParentMenu,
|
||||||
const wxString& text, const wxString& strHelp,
|
int id,
|
||||||
bool bCheckable,
|
const wxString& text,
|
||||||
|
const wxString& strHelp,
|
||||||
|
wxItemKind kind,
|
||||||
wxMenu *pSubMenu)
|
wxMenu *pSubMenu)
|
||||||
|
: wxMenuItemBase(pParentMenu, id, text, strHelp, kind, pSubMenu)
|
||||||
{
|
{
|
||||||
wxASSERT( pParentMenu != NULL );
|
// VZ: what about translations?? (FIXME)
|
||||||
|
|
||||||
m_parentMenu = pParentMenu;
|
|
||||||
m_subMenu = pSubMenu;
|
|
||||||
m_isEnabled = TRUE;
|
|
||||||
m_isChecked = FALSE;
|
|
||||||
m_id = id;
|
|
||||||
m_text = text;
|
|
||||||
m_isCheckable = bCheckable;
|
|
||||||
m_help = strHelp;
|
|
||||||
|
|
||||||
|
|
||||||
if ( m_text == "E&xit" ||m_text == "Exit" ||m_text.Left(5) == "Exit\t" || m_text.Left(6) == "E&xit\t" )
|
if ( m_text == "E&xit" ||m_text == "Exit" ||m_text.Left(5) == "Exit\t" || m_text.Left(6) == "E&xit\t" )
|
||||||
{
|
{
|
||||||
m_text = "Quit\tCtrl+Q" ;
|
m_text = "Quit\tCtrl+Q" ;
|
||||||
@@ -348,8 +340,8 @@ wxMenuItem *wxMenuItemBase::New(wxMenu *parentMenu,
|
|||||||
int id,
|
int id,
|
||||||
const wxString& name,
|
const wxString& name,
|
||||||
const wxString& help,
|
const wxString& help,
|
||||||
bool isCheckable,
|
wxItemKind kind,
|
||||||
wxMenu *subMenu)
|
wxMenu *subMenu)
|
||||||
{
|
{
|
||||||
return new wxMenuItem(parentMenu, id, name, help, isCheckable, subMenu);
|
return new wxMenuItem(parentMenu, id, name, help, kind, subMenu);
|
||||||
}
|
}
|
||||||
|
@@ -175,23 +175,15 @@ int wxMenuItem::MacBuildMenuString(StringPtr outMacItemText, SInt16 *outMacShort
|
|||||||
// ctor & dtor
|
// ctor & dtor
|
||||||
// -----------
|
// -----------
|
||||||
|
|
||||||
wxMenuItem::wxMenuItem(wxMenu *pParentMenu, int id,
|
wxMenuItem::wxMenuItem(wxMenu *pParentMenu,
|
||||||
const wxString& text, const wxString& strHelp,
|
int id,
|
||||||
bool bCheckable,
|
const wxString& text,
|
||||||
|
const wxString& strHelp,
|
||||||
|
wxItemKind kind,
|
||||||
wxMenu *pSubMenu)
|
wxMenu *pSubMenu)
|
||||||
|
: wxMenuItemBase(pParentMenu, id, text, strHelp, kind, pSubMenu)
|
||||||
{
|
{
|
||||||
wxASSERT( pParentMenu != NULL );
|
// VZ: what about translations?? (FIXME)
|
||||||
|
|
||||||
m_parentMenu = pParentMenu;
|
|
||||||
m_subMenu = pSubMenu;
|
|
||||||
m_isEnabled = TRUE;
|
|
||||||
m_isChecked = FALSE;
|
|
||||||
m_id = id;
|
|
||||||
m_text = text;
|
|
||||||
m_isCheckable = bCheckable;
|
|
||||||
m_help = strHelp;
|
|
||||||
|
|
||||||
|
|
||||||
if ( m_text == "E&xit" ||m_text == "Exit" ||m_text.Left(5) == "Exit\t" || m_text.Left(6) == "E&xit\t" )
|
if ( m_text == "E&xit" ||m_text == "Exit" ||m_text.Left(5) == "Exit\t" || m_text.Left(6) == "E&xit\t" )
|
||||||
{
|
{
|
||||||
m_text = "Quit\tCtrl+Q" ;
|
m_text = "Quit\tCtrl+Q" ;
|
||||||
@@ -348,8 +340,8 @@ wxMenuItem *wxMenuItemBase::New(wxMenu *parentMenu,
|
|||||||
int id,
|
int id,
|
||||||
const wxString& name,
|
const wxString& name,
|
||||||
const wxString& help,
|
const wxString& help,
|
||||||
bool isCheckable,
|
wxItemKind kind,
|
||||||
wxMenu *subMenu)
|
wxMenu *subMenu)
|
||||||
{
|
{
|
||||||
return new wxMenuItem(parentMenu, id, name, help, isCheckable, subMenu);
|
return new wxMenuItem(parentMenu, id, name, help, kind, subMenu);
|
||||||
}
|
}
|
||||||
|
@@ -62,7 +62,7 @@ static void wxMenuItemDisarmCallback(Widget w, XtPointer clientData, XtPointer p
|
|||||||
// dynamic classes implementation
|
// dynamic classes implementation
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject)
|
IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject)
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxMenuItem
|
// wxMenuItem
|
||||||
@@ -71,23 +71,14 @@ static void wxMenuItemDisarmCallback(Widget w, XtPointer clientData, XtPointer p
|
|||||||
// ctor & dtor
|
// ctor & dtor
|
||||||
// -----------
|
// -----------
|
||||||
|
|
||||||
wxMenuItem::wxMenuItem(wxMenu *pParentMenu, int id,
|
wxMenuItem::wxMenuItem(wxMenu *pParentMenu,
|
||||||
const wxString& strName, const wxString& strHelp,
|
int id,
|
||||||
bool bCheckable,
|
const wxString& strName,
|
||||||
|
const wxString& strHelp,
|
||||||
|
wxItemKind kind,
|
||||||
wxMenu *pSubMenu)
|
wxMenu *pSubMenu)
|
||||||
|
: wxMenuItemBase(pParentMenu, id, strName, strHelp, kind, pSubMenu)
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( pParentMenu != NULL, wxT("menuitem should have a menu") );
|
|
||||||
|
|
||||||
// common init
|
|
||||||
m_parentMenu = pParentMenu;
|
|
||||||
m_subMenu = pSubMenu;
|
|
||||||
m_id = id;
|
|
||||||
m_isEnabled = TRUE;
|
|
||||||
m_isChecked = FALSE;
|
|
||||||
m_help = strHelp;
|
|
||||||
m_isCheckable = bCheckable;
|
|
||||||
m_text = strName;
|
|
||||||
|
|
||||||
// Motif-specific
|
// Motif-specific
|
||||||
m_menuBar = NULL;
|
m_menuBar = NULL;
|
||||||
m_buttonWidget = (WXWidget) NULL;
|
m_buttonWidget = (WXWidget) NULL;
|
||||||
@@ -170,10 +161,10 @@ wxMenuItem *wxMenuItemBase::New(wxMenu *parentMenu,
|
|||||||
int id,
|
int id,
|
||||||
const wxString& name,
|
const wxString& name,
|
||||||
const wxString& help,
|
const wxString& help,
|
||||||
bool isCheckable,
|
wxItemKind kind,
|
||||||
wxMenu *subMenu)
|
wxMenu *subMenu)
|
||||||
{
|
{
|
||||||
return new wxMenuItem(parentMenu, id, name, help, isCheckable, subMenu);
|
return new wxMenuItem(parentMenu, id, name, help, kind, subMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -85,10 +85,11 @@ wxMenuItem::wxMenuItem(wxMenu *pParentMenu,
|
|||||||
int id,
|
int id,
|
||||||
const wxString& text,
|
const wxString& text,
|
||||||
const wxString& strHelp,
|
const wxString& strHelp,
|
||||||
bool bCheckable,
|
wxItemKind kind,
|
||||||
wxMenu *pSubMenu)
|
wxMenu *pSubMenu)
|
||||||
|
: wxMenuItemBase(pParentMenu, id, text, strHelp, kind, pSubMenu)
|
||||||
#if wxUSE_OWNER_DRAWN
|
#if wxUSE_OWNER_DRAWN
|
||||||
: wxOwnerDrawn(GetLabelFromText(text), bCheckable)
|
, wxOwnerDrawn(GetLabelFromText(text), kind == wxItem_Check)
|
||||||
#endif // owner drawn
|
#endif // owner drawn
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( pParentMenu != NULL, wxT("a menu item should have a parent") );
|
wxASSERT_MSG( pParentMenu != NULL, wxT("a menu item should have a parent") );
|
||||||
@@ -108,15 +109,6 @@ wxMenuItem::wxMenuItem(wxMenu *pParentMenu,
|
|||||||
// tell the owner drawing code to to show the accel string as well
|
// tell the owner drawing code to to show the accel string as well
|
||||||
SetAccelString(text.AfterFirst(_T('\t')));
|
SetAccelString(text.AfterFirst(_T('\t')));
|
||||||
#endif // wxUSE_OWNER_DRAWN
|
#endif // wxUSE_OWNER_DRAWN
|
||||||
|
|
||||||
m_parentMenu = pParentMenu;
|
|
||||||
m_subMenu = pSubMenu;
|
|
||||||
m_isEnabled = TRUE;
|
|
||||||
m_isChecked = FALSE;
|
|
||||||
m_id = id;
|
|
||||||
m_text = text;
|
|
||||||
m_isCheckable = bCheckable;
|
|
||||||
m_help = strHelp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMenuItem::~wxMenuItem()
|
wxMenuItem::~wxMenuItem()
|
||||||
@@ -170,7 +162,7 @@ void wxMenuItem::Enable(bool enable)
|
|||||||
|
|
||||||
void wxMenuItem::Check(bool check)
|
void wxMenuItem::Check(bool check)
|
||||||
{
|
{
|
||||||
wxCHECK_RET( m_isCheckable, wxT("only checkable items may be checked") );
|
wxCHECK_RET( IsCheckable(), wxT("only checkable items may be checked") );
|
||||||
|
|
||||||
if ( m_isChecked == check )
|
if ( m_isChecked == check )
|
||||||
return;
|
return;
|
||||||
@@ -256,10 +248,10 @@ wxMenuItem *wxMenuItemBase::New(wxMenu *parentMenu,
|
|||||||
int id,
|
int id,
|
||||||
const wxString& name,
|
const wxString& name,
|
||||||
const wxString& help,
|
const wxString& help,
|
||||||
bool isCheckable,
|
wxItemKind kind,
|
||||||
wxMenu *subMenu)
|
wxMenu *subMenu)
|
||||||
{
|
{
|
||||||
return new wxMenuItem(parentMenu, id, name, help, isCheckable, subMenu);
|
return new wxMenuItem(parentMenu, id, name, help, kind, subMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // wxUSE_MENUS
|
#endif // wxUSE_MENUS
|
||||||
|
@@ -110,11 +110,12 @@ wxMenuItem::wxMenuItem(
|
|||||||
, int nId
|
, int nId
|
||||||
, const wxString& rText
|
, const wxString& rText
|
||||||
, const wxString& rStrHelp
|
, const wxString& rStrHelp
|
||||||
, bool bCheckable
|
, wxItemKind kind
|
||||||
, wxMenu* pSubMenu
|
, wxMenu* pSubMenu
|
||||||
)
|
)
|
||||||
|
: wxMenuItemBase(pParentMenu, nId, rText, rStrHelp, kind, pSubMenu)
|
||||||
#if wxUSE_OWNER_DRAWN
|
#if wxUSE_OWNER_DRAWN
|
||||||
: wxOwnerDrawn( TextToLabel(rText)
|
, wxOwnerDrawn( TextToLabel(rText)
|
||||||
,bCheckable
|
,bCheckable
|
||||||
)
|
)
|
||||||
#endif // owner drawn
|
#endif // owner drawn
|
||||||
@@ -139,14 +140,8 @@ wxMenuItem::wxMenuItem(
|
|||||||
#undef SYS_COLOR
|
#undef SYS_COLOR
|
||||||
#endif // wxUSE_OWNER_DRAWN
|
#endif // wxUSE_OWNER_DRAWN
|
||||||
|
|
||||||
m_parentMenu = pParentMenu;
|
|
||||||
m_subMenu = pSubMenu;
|
|
||||||
m_isEnabled = TRUE;
|
|
||||||
m_isChecked = FALSE;
|
|
||||||
m_id = nId;
|
|
||||||
m_text = TextToLabel(rText);
|
m_text = TextToLabel(rText);
|
||||||
m_isCheckable = bCheckable;
|
|
||||||
m_help = rStrHelp;
|
|
||||||
memset(&m_vMenuData, '\0', sizeof(m_vMenuData));
|
memset(&m_vMenuData, '\0', sizeof(m_vMenuData));
|
||||||
m_vMenuData.id= nId;
|
m_vMenuData.id= nId;
|
||||||
} // end of wxMenuItem::wxMenuItem
|
} // end of wxMenuItem::wxMenuItem
|
||||||
@@ -236,7 +231,7 @@ void wxMenuItem::Check(
|
|||||||
{
|
{
|
||||||
bool bOk;
|
bool bOk;
|
||||||
|
|
||||||
wxCHECK_RET( m_isCheckable, wxT("only checkable items may be checked") );
|
wxCHECK_RET( IsCheckable(), wxT("only checkable items may be checked") );
|
||||||
if (m_isChecked == bCheck)
|
if (m_isChecked == bCheck)
|
||||||
return;
|
return;
|
||||||
if (bCheck)
|
if (bCheck)
|
||||||
@@ -359,7 +354,7 @@ wxMenuItem* wxMenuItemBase::New(
|
|||||||
, int nId
|
, int nId
|
||||||
, const wxString& rName
|
, const wxString& rName
|
||||||
, const wxString& rHelp
|
, const wxString& rHelp
|
||||||
, bool bIsCheckable
|
, wxItemKind kind
|
||||||
, wxMenu* pSubMenu
|
, wxMenu* pSubMenu
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -367,7 +362,7 @@ wxMenuItem* wxMenuItemBase::New(
|
|||||||
,nId
|
,nId
|
||||||
,rName
|
,rName
|
||||||
,rHelp
|
,rHelp
|
||||||
,bIsCheckable
|
,kind
|
||||||
,pSubMenu
|
,pSubMenu
|
||||||
);
|
);
|
||||||
} // end of wxMenuItemBase::New
|
} // end of wxMenuItemBase::New
|
||||||
|
@@ -1397,20 +1397,10 @@ wxMenuItem::wxMenuItem(wxMenu *parentMenu,
|
|||||||
int id,
|
int id,
|
||||||
const wxString& text,
|
const wxString& text,
|
||||||
const wxString& help,
|
const wxString& help,
|
||||||
bool isCheckable,
|
wxItemKind kind,
|
||||||
wxMenu *subMenu)
|
wxMenu *subMenu)
|
||||||
|
: wxMenuItemBase(parentMenu, id, text, help, kind, subMenu)
|
||||||
{
|
{
|
||||||
m_id = id;
|
|
||||||
m_parentMenu = parentMenu;
|
|
||||||
m_subMenu = subMenu;
|
|
||||||
|
|
||||||
m_text = text;
|
|
||||||
m_help = help;
|
|
||||||
|
|
||||||
m_isCheckable = isCheckable;
|
|
||||||
m_isEnabled = TRUE;
|
|
||||||
m_isChecked = FALSE;
|
|
||||||
|
|
||||||
m_posY =
|
m_posY =
|
||||||
m_height = -1;
|
m_height = -1;
|
||||||
|
|
||||||
@@ -1474,7 +1464,7 @@ void wxMenuItem::SetText(const wxString& text)
|
|||||||
|
|
||||||
void wxMenuItem::SetCheckable(bool checkable)
|
void wxMenuItem::SetCheckable(bool checkable)
|
||||||
{
|
{
|
||||||
if ( checkable != m_isCheckable )
|
if ( checkable != IsCheckable() )
|
||||||
{
|
{
|
||||||
wxMenuItemBase::SetCheckable(checkable);
|
wxMenuItemBase::SetCheckable(checkable);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user