File: menuitem.h

package info (click to toggle)
wxwidgets3.0 3.0.5.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 120,464 kB
  • sloc: cpp: 896,633; makefile: 52,303; ansic: 21,971; sh: 5,713; python: 2,940; xml: 1,534; perl: 264; javascript: 33
file content (126 lines) | stat: -rw-r--r-- 4,092 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
///////////////////////////////////////////////////////////////////////////////
// Name:        wx/univ/menuitem.h
// Purpose:     wxMenuItem class for wxUniversal
// Author:      Vadim Zeitlin
// Modified by:
// Created:     05.05.01
// Copyright:   (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
// Licence:     wxWindows licence
///////////////////////////////////////////////////////////////////////////////

#ifndef _WX_UNIV_MENUITEM_H_
#define _WX_UNIV_MENUITEM_H_

// ----------------------------------------------------------------------------
// wxMenuItem implements wxMenuItemBase
// ----------------------------------------------------------------------------

class WXDLLIMPEXP_CORE wxMenuItem : public wxMenuItemBase
{
public:
    // ctor & dtor
    wxMenuItem(wxMenu *parentMenu = NULL,
               int id = wxID_SEPARATOR,
               const wxString& name = wxEmptyString,
               const wxString& help = wxEmptyString,
               wxItemKind kind = wxITEM_NORMAL,
               wxMenu *subMenu = NULL);
    virtual ~wxMenuItem();

    // override base class virtuals to update the item appearance on screen
    virtual void SetItemLabel(const wxString& text);
    virtual void SetCheckable(bool checkable);

    virtual void Enable(bool enable = true);
    virtual void Check(bool check = true);

    // we add some extra functions which are also available under MSW from
    // wxOwnerDrawn class - they will be moved to wxMenuItemBase later
    // hopefully
    void SetBitmaps(const wxBitmap& bmpChecked,
                    const wxBitmap& bmpUnchecked = wxNullBitmap);
    void SetBitmap(const wxBitmap& bmp) { SetBitmaps(bmp); }
    const wxBitmap& GetBitmap(bool checked = true) const
      { return checked ? m_bmpChecked : m_bmpUnchecked; }

    void SetDisabledBitmap( const wxBitmap& bmpDisabled )
      { m_bmpDisabled = bmpDisabled; }
    const wxBitmap& GetDisabledBitmap() const
      { return m_bmpDisabled; }

    // mark item as belonging to the given radio group
    void SetAsRadioGroupStart();
    void SetRadioGroupStart(int start);
    void SetRadioGroupEnd(int end);

    // wxUniv-specific methods for implementation only starting from here

    // get the accel index of our label or -1 if none
    int GetAccelIndex() const { return m_indexAccel; }

    // get the accel string (displayed to the right of the label)
    const wxString& GetAccelString() const { return m_strAccel; }

    // set/get the y coord and the height of this item: note that it must be
    // set first and retrieved later, the item doesn't calculate it itself
    void SetGeometry(wxCoord y, wxCoord height)
    {
        m_posY = y;
        m_height = height;
    }

    wxCoord GetPosition() const
    {
        wxASSERT_MSG( m_posY != wxDefaultCoord, wxT("must call SetHeight first!") );

        return m_posY;
    }

    wxCoord GetHeight() const
    {
        wxASSERT_MSG( m_height != wxDefaultCoord, wxT("must call SetHeight first!") );

        return m_height;
    }

protected:
    // notify the menu about the change in this item
    inline void NotifyMenu();

    // set the accel index and string from text
    void UpdateAccelInfo();

    // the bitmaps (may be invalid, then they're not used)
    wxBitmap m_bmpChecked,
             m_bmpUnchecked,
             m_bmpDisabled;

    // the positions of the first and last items of the radio group this item
    // belongs to or -1: start is the radio group start and is valid for all
    // but first radio group items (m_isRadioGroupStart == false), end is valid
    // only for the first one
    union
    {
        int start;
        int end;
    } m_radioGroup;

    // does this item start a radio group?
    bool m_isRadioGroupStart;

    // the position of the accelerator in our label, -1 if none
    int m_indexAccel;

    // the accel string (i.e. "Ctrl-Q" or "Alt-F1")
    wxString m_strAccel;

    // the position and height of the displayed item
    wxCoord m_posY,
            m_height;

private:
    DECLARE_DYNAMIC_CLASS(wxMenuItem)
};

#endif // _WX_UNIV_MENUITEM_H_