blob: 2242c2a41f7cca2f17181e0cc37561839ee98d23 [file] [log] [blame]
george82b3a4d652005-07-26 10:22:56 +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
george82454b1b12005-07-28 07:04:23 +000019// -=- ToolBar control class.
george82b3a4d652005-07-26 10:22:56 +000020
21#include <windows.h>
22#include <commctrl.h>
23#include <assert.h>
24
george82454b1b12005-07-28 07:04:23 +000025namespace rfb {
george82b3a4d652005-07-26 10:22:56 +000026
george82454b1b12005-07-28 07:04:23 +000027 namespace win32 {
george82b3a4d652005-07-26 10:22:56 +000028
george82454b1b12005-07-28 07:04:23 +000029 class ToolBar {
30 public:
31 ToolBar();
32 virtual ~ToolBar();
george82b3a4d652005-07-26 10:22:56 +000033
george82454b1b12005-07-28 07:04:23 +000034 // 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);
george82b3a4d652005-07-26 10:22:56 +000039
george82454b1b12005-07-28 07:04:23 +000040 // -=- Button images operations
george82b3a4d652005-07-26 10:22:56 +000041
george82454b1b12005-07-28 07:04:23 +000042 // 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);
george82b3a4d652005-07-26 10:22:56 +000047
george82454b1b12005-07-28 07:04:23 +000048 // 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);
george82b3a4d652005-07-26 10:22:56 +000052
george82454b1b12005-07-28 07:04:23 +000053 // 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);
george82b3a4d652005-07-26 10:22:56 +000057
george82454b1b12005-07-28 07:04:23 +000058 // -=- Button operations
george82b3a4d652005-07-26 10:22:56 +000059
george82454b1b12005-07-28 07:04:23 +000060 // 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);
george82b3a4d652005-07-26 10:22:56 +000063
george82454b1b12005-07-28 07:04:23 +000064 // addNButton() adds nButtons buttons to a toolbar.
65 bool addNButton(int nButtons, LPTBBUTTON tbb);
george82b3a4d652005-07-26 10:22:56 +000066
george82454b1b12005-07-28 07:04:23 +000067 // deleteButton() removes a button from the toolbar.
68 bool deleteButton(int nIndex);
george82b3a4d652005-07-26 10:22:56 +000069
george82454b1b12005-07-28 07:04:23 +000070 // insertButton() inserts a button in a toolbar control by index.
71 bool insertButton(int nIndex, LPTBBUTTON tbb);
george82b3a4d652005-07-26 10:22:56 +000072
george82454b1b12005-07-28 07:04:23 +000073 // 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);
george82b3a4d652005-07-26 10:22:56 +000076
george82454b1b12005-07-28 07:04:23 +000077 // getButtonsHeight() retrieves the height of the toolbar buttons.
78 int getButtonsHeight();
george82b3a4d652005-07-26 10:22:56 +000079
george82454b1b12005-07-28 07:04:23 +000080 // getButtonsWidth() retrieves the width of the toolbar buttons.
81 int getButtonsWidth();
george82b3a4d652005-07-26 10:22:56 +000082
george82454b1b12005-07-28 07:04:23 +000083 // setButtonInfo() sets the information for an existing button
84 // in a toolbar.
85 bool setButtonInfo(int idButton, TBBUTTONINFO* ptbbi);
george82b3a4d652005-07-26 10:22:56 +000086
george82454b1b12005-07-28 07:04:23 +000087 // checkButton() checks or unchecks a given button in a toolbar control.
88 bool checkButton(int idButton, bool check);
george82b3a4d652005-07-26 10:22:56 +000089
george82454b1b12005-07-28 07:04:23 +000090 // 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);
george82b3a4d652005-07-26 10:22:56 +000099
george82454b1b12005-07-28 07:04:23 +0000100 // 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);
george82b3a4d652005-07-26 10:22:56 +0000103
george82d27bba02005-11-05 04:48:46 +0000104 // -=- ToolBar operations
george82b3a4d652005-07-26 10:22:56 +0000105
george82454b1b12005-07-28 07:04:23 +0000106 // autoSize() resizes the toolbar window.
107 void autoSize();
george82b3a4d652005-07-26 10:22:56 +0000108
george82454b1b12005-07-28 07:04:23 +0000109 // getHandle() returns handle to a toolbar window.
110 HWND getHandle() { return hwndToolBar; }
george82b3a4d652005-07-26 10:22:56 +0000111
george82454b1b12005-07-28 07:04:23 +0000112 // getHeight() returns the toolbar window height.
113 int getHeight();
114
george82d27bba02005-11-05 04:48:46 +0000115 // show() displays the toolbar window.
116 void show();
117
118 // hide() hides the toolbar window.
119 void hide();
120
george821a557d92005-11-05 04:54:51 +0000121 // isVisible() check the toolbar window on visible.
122 bool isVisible();
123
george82454b1b12005-07-28 07:04:23 +0000124 protected:
125 HWND hwndToolBar;
126 HWND parentHwnd;
127 int tbID;
128 };
129
130 }; // win32
131
132}; // rfb