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