?? menu.h
字號:
///////////////////////////////////////////////////////////////////////////////
// Name: wx/menu.h
// Purpose: wxMenu and wxMenuBar classes
// Author: Vadim Zeitlin
// Modified by:
// Created: 26.10.99
// RCS-ID: $Id: menu.h,v 1.1 2005/03/16 06:49:18 kehc Exp $
// Copyright: (c) wxWindows team
// Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MENU_H_BASE_
#define _WX_MENU_H_BASE_
#if defined(__GNUG__) && !defined(__APPLE__)
#pragma interface "menubase.h"
#endif
#if wxUSE_MENUS
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/list.h" // for "template" list classes
#include "wx/window.h" // base class for wxMenuBar
// also include this one to ensure compatibility with old code which only
// included wx/menu.h
#include "wx/menuitem.h"
class WXDLLEXPORT wxMenu;
class WXDLLEXPORT wxMenuBarBase;
class WXDLLEXPORT wxMenuBar;
class WXDLLEXPORT wxMenuItem;
// pseudo template list classes
WX_DECLARE_EXPORTED_LIST(wxMenu, wxMenuList);
WX_DECLARE_EXPORTED_LIST(wxMenuItem, wxMenuItemList);
// ----------------------------------------------------------------------------
// conditional compilation
// ----------------------------------------------------------------------------
// having callbacks in menus is a wxWin 1.6x feature which should be replaced
// with event tables in wxWin 2.xx code - however provide it because many
// people like it a lot by default
#ifndef wxUSE_MENU_CALLBACK
#if WXWIN_COMPATIBILITY_2
#define wxUSE_MENU_CALLBACK 1
#else
#define wxUSE_MENU_CALLBACK 0
#endif // WXWIN_COMPATIBILITY_2
#endif // !defined(wxUSE_MENU_CALLBACK)
// ----------------------------------------------------------------------------
// wxMenu
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxMenuBase : public wxEvtHandler
{
public:
// create a menu
static wxMenu *New(const wxString& title = wxEmptyString, long style = 0);
// ctors
wxMenuBase(const wxString& title, long style = 0) : m_title(title)
{ Init(style); }
wxMenuBase(long style = 0)
{ Init(style); }
// dtor deletes all the menu items we own
virtual ~wxMenuBase();
// menu construction
// -----------------
// append any kind of item (normal/check/radio/separator)
void Append(int id,
const wxString& text,
const wxString& help = wxEmptyString,
wxItemKind kind = wxITEM_NORMAL)
{
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,
wxMenu *submenu,
const wxString& help = wxEmptyString)
{
DoAppend(wxMenuItem::New((wxMenu *)this, id, text, help,
wxITEM_NORMAL, submenu));
}
// the most generic form of Append() - append anything
void Append(wxMenuItem *item) { DoAppend(item); }
// insert a break in the menu (only works when appending the items, not
// inserting them)
virtual void Break() { }
// 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,
wxItemKind kind = wxITEM_NORMAL)
{
Insert(pos, wxMenuItem::New((wxMenu *)this, id, text, help, kind));
}
// insert a separator
void InsertSeparator(size_t pos)
{
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,
const wxString& text,
wxMenu *submenu,
const wxString& help = wxEmptyString)
{
Insert(pos, wxMenuItem::New((wxMenu *)this, id, text, help,
wxITEM_NORMAL, submenu));
}
// prepend an item to the menu
void Prepend(wxMenuItem *item)
{
Insert(0u, item);
}
// prepend any item to the menu
void Prepend(int id,
const wxString& text,
const wxString& help = wxEmptyString,
wxItemKind kind = wxITEM_NORMAL)
{
Insert(0u, id, text, help, kind);
}
// prepend a separator
void PrependSeparator()
{
InsertSeparator(0u);
}
// 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,
const wxString& help = wxEmptyString)
{
Insert(0u, id, text, submenu, help);
}
// detach an item from the menu, but don't delete it so that it can be
// added back later (but if it's not, the caller is responsible for
// deleting it!)
wxMenuItem *Remove(int id) { return Remove(FindChildItem(id)); }
wxMenuItem *Remove(wxMenuItem *item);
// delete an item from the menu (submenus are not destroyed by this
// function, see Destroy)
bool Delete(int id) { return Delete(FindChildItem(id)); }
bool Delete(wxMenuItem *item);
// delete the item from menu and destroy it (if it's a submenu)
bool Destroy(int id) { return Destroy(FindChildItem(id)); }
bool Destroy(wxMenuItem *item);
// menu items access
// -----------------
// get the items
size_t GetMenuItemCount() const { return m_items.GetCount(); }
const wxMenuItemList& GetMenuItems() const { return m_items; }
wxMenuItemList& GetMenuItems() { return m_items; }
// search
virtual int FindItem(const wxString& item) const;
wxMenuItem* FindItem(int id, wxMenu **menu = NULL) const;
// find by position
wxMenuItem* FindItemByPosition(size_t position) const;
// get/set items attributes
void Enable(int id, bool enable);
bool IsEnabled(int id) const;
void Check(int id, bool check);
bool IsChecked(int id) const;
void SetLabel(int id, const wxString& label);
wxString GetLabel(int id) const;
virtual void SetHelpString(int id, const wxString& helpString);
virtual wxString GetHelpString(int id) const;
// misc accessors
// --------------
// the title
virtual void SetTitle(const wxString& title) { m_title = title; }
const wxString GetTitle() const { return m_title; }
// event handler
void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
wxEvtHandler *GetEventHandler() const { return m_eventHandler; }
// invoking window
void SetInvokingWindow(wxWindow *win) { m_invokingWindow = win; }
wxWindow *GetInvokingWindow() const { return m_invokingWindow; }
// style
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -