blob: 2242c2a41f7cca2f17181e0cc37561839ee98d23 [file] [log] [blame]
Constantin Kaplinsky729598c2006-05-25 05:12:25 +00001/* Copyright (C) 2004 TightVNC Team. All Rights Reserved.
2 *
3 * This is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This software is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 * USA.
17 */
18
19// -=- ToolBar control class.
20
21#include <windows.h>
22#include <commctrl.h>
23#include <assert.h>
24
25namespace rfb {
26
27 namespace win32 {
28
29 class ToolBar {
30 public:
31 ToolBar();
32 virtual ~ToolBar();
33
34 // create() creates a windows toolbar. dwStyle is a combination of
35 // the toolbar control and button styles. It returns TRUE if successful,
36 // or FALSE otherwise.
37 bool create(int tbID, HWND parentHwnd,
38 DWORD dwStyle = WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT);
39
40 // -=- Button images operations
41
42 // addBitmap() adds one or more images from resources to
43 // the list of button images available for a toolbar.
44 // Returns the index of the first new image if successful,
45 // or -1 otherwise.
46 int addBitmap(int nButtons, UINT bitmapID);
47
48 // addSystemBitmap() adds the system-defined button bitmaps to the list
49 // of the toolbar button specifying by stdBitmapID. Returns the index of
50 // the first new image if successful, or -1 otherwise.
51 int addSystemBitmap(UINT stdBitmapID);
52
53 // setBitmapSize() sets the size of the bitmapped images to be added
54 // to a toolbar. It returns TRUE if successful, or FALSE otherwise.
55 // You must call it before addBitmap().
56 bool setBitmapSize(int width, int height);
57
58 // -=- Button operations
59
60 // addButton() adds one button.
61 bool addButton(int iBitmap, int idCommand, BYTE state=TBSTATE_ENABLED,
62 BYTE style=TBSTYLE_BUTTON, UINT dwData=0, int iString=0);
63
64 // addNButton() adds nButtons buttons to a toolbar.
65 bool addNButton(int nButtons, LPTBBUTTON tbb);
66
67 // deleteButton() removes a button from the toolbar.
68 bool deleteButton(int nIndex);
69
70 // insertButton() inserts a button in a toolbar control by index.
71 bool insertButton(int nIndex, LPTBBUTTON tbb);
72
73 // getButtonInfo() retrieves extended information about a toolbar's
74 // button. It returns index of the button if successful, or -1 otherwise.
75 int getButtonInfo(int idButton, TBBUTTONINFO *btnInfo);
76
77 // getButtonsHeight() retrieves the height of the toolbar buttons.
78 int getButtonsHeight();
79
80 // getButtonsWidth() retrieves the width of the toolbar buttons.
81 int getButtonsWidth();
82
83 // setButtonInfo() sets the information for an existing button
84 // in a toolbar.
85 bool setButtonInfo(int idButton, TBBUTTONINFO* ptbbi);
86
87 // checkButton() checks or unchecks a given button in a toolbar control.
88 bool checkButton(int idButton, bool check);
89
90 // enableButton() enables or disables the specified button
91 // in the toolbar.
92 bool enableButton(int idButton, bool enable);
93
94 // pressButton() presses or releases the specified button in the toolbar.
95 bool pressButton(int idButton, bool press);
96
97 // getButtonRect() gets the bounding rectangle of a button in a toolbar.
98 bool getButtonRect(int nIndex, LPRECT buttonRect);
99
100 // setButtonSize() sets the size of the buttons to be added to a toolbar.
101 // Button size must be largen the button bitmap.
102 bool setButtonSize(int width, int height);
103
104 // -=- ToolBar operations
105
106 // autoSize() resizes the toolbar window.
107 void autoSize();
108
109 // getHandle() returns handle to a toolbar window.
110 HWND getHandle() { return hwndToolBar; }
111
112 // getHeight() returns the toolbar window height.
113 int getHeight();
114
115 // show() displays the toolbar window.
116 void show();
117
118 // hide() hides the toolbar window.
119 void hide();
120
121 // isVisible() check the toolbar window on visible.
122 bool isVisible();
123
124 protected:
125 HWND hwndToolBar;
126 HWND parentHwnd;
127 int tbID;
128 };
129
130 }; // win32
131
132}; // rfb