]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/tbar95.h
removed unsecure wxTmpnam() function (patch by Francesco Montorsi)
[wxWidgets.git] / include / wx / msw / tbar95.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/tbar95.h
3 // Purpose: wxToolBar (Windows 95 toolbar) class
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_MSW_TBAR95_H_
13 #define _WX_MSW_TBAR95_H_
14
15 #if wxUSE_TOOLBAR
16
17 #include "wx/dynarray.h"
18 #include "wx/imaglist.h"
19
20 class WXDLLEXPORT wxToolBar : public wxToolBarBase
21 {
22 public:
23 // ctors and dtor
24 wxToolBar() { Init(); }
25
26 wxToolBar(wxWindow *parent,
27 wxWindowID id,
28 const wxPoint& pos = wxDefaultPosition,
29 const wxSize& size = wxDefaultSize,
30 long style = wxNO_BORDER | wxTB_HORIZONTAL,
31 const wxString& name = wxToolBarNameStr)
32 {
33 Init();
34
35 Create(parent, id, pos, size, style, name);
36 }
37
38 bool Create(wxWindow *parent,
39 wxWindowID id,
40 const wxPoint& pos = wxDefaultPosition,
41 const wxSize& size = wxDefaultSize,
42 long style = wxNO_BORDER | wxTB_HORIZONTAL,
43 const wxString& name = wxToolBarNameStr);
44
45 virtual ~wxToolBar();
46
47 // override/implement base class virtuals
48 virtual wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y) const;
49
50 virtual bool Realize();
51
52 virtual void SetToolBitmapSize(const wxSize& size);
53 virtual wxSize GetToolSize() const;
54
55 virtual void SetRows(int nRows);
56
57 virtual void SetToolNormalBitmap(int id, const wxBitmap& bitmap);
58 virtual void SetToolDisabledBitmap(int id, const wxBitmap& bitmap);
59
60 // implementation only from now on
61 // -------------------------------
62
63 virtual void SetWindowStyleFlag(long style);
64
65 virtual bool MSWCommand(WXUINT param, WXWORD id);
66 virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
67
68 void OnMouseEvent(wxMouseEvent& event);
69 void OnSysColourChanged(wxSysColourChangedEvent& event);
70 void OnEraseBackground(wxEraseEvent& event);
71
72 void SetFocus() {}
73
74 static WXHBITMAP MapBitmap(WXHBITMAP bitmap, int width, int height);
75
76 // override WndProc mainly to process WM_SIZE
77 virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
78
79 virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
80
81 protected:
82 // common part of all ctors
83 void Init();
84
85 // create the native toolbar control
86 bool MSWCreateToolbar(const wxPoint& pos, const wxSize& size);
87
88 // recreate the control completely
89 void Recreate();
90
91 // implement base class pure virtuals
92 virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool);
93 virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool);
94
95 virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable);
96 virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle);
97 virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle);
98
99 virtual wxToolBarToolBase *CreateTool(int id,
100 const wxString& label,
101 const wxBitmap& bmpNormal,
102 const wxBitmap& bmpDisabled,
103 wxItemKind kind,
104 wxObject *clientData,
105 const wxString& shortHelp,
106 const wxString& longHelp);
107
108 virtual wxToolBarToolBase *CreateTool(wxControl *control,
109 const wxString& label);
110
111 // return the appropriate size and flags for the toolbar control
112 virtual wxSize DoGetBestSize() const;
113
114 // handlers for various events
115 bool HandleSize(WXWPARAM wParam, WXLPARAM lParam);
116 bool HandlePaint(WXWPARAM wParam, WXLPARAM lParam);
117 void HandleMouseMove(WXWPARAM wParam, WXLPARAM lParam);
118
119 // should be called whenever the toolbar size changes
120 void UpdateSize();
121
122 // create m_disabledImgList (but doesn't fill it), set it to NULL if it is
123 // unneeded
124 void CreateDisabledImageList();
125
126 // get the Windows toolbar style of this control
127 long GetMSWToolbarStyle() const;
128
129
130 // the big bitmap containing all bitmaps of the toolbar buttons
131 WXHBITMAP m_hBitmap;
132
133 // the image list with disabled images, may be NULL if we use
134 // system-provided versions of them
135 wxImageList *m_disabledImgList;
136
137 // the total number of toolbar elements
138 size_t m_nButtons;
139
140 // the tool the cursor is in
141 wxToolBarToolBase *m_pInTool;
142
143 private:
144 DECLARE_EVENT_TABLE()
145 DECLARE_DYNAMIC_CLASS(wxToolBar)
146 DECLARE_NO_COPY_CLASS(wxToolBar)
147 };
148
149 #endif // wxUSE_TOOLBAR
150
151 #endif // _WX_MSW_TBAR95_H_
152