Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _SV_NATIVEWIDGETS_HXX
30 : : #define _SV_NATIVEWIDGETS_HXX
31 : :
32 : : #include <rtl/ustring.hxx>
33 : : #include <vcl/dllapi.h>
34 : : #include <tools/gen.hxx>
35 : :
36 : : /* Control Types:
37 : : *
38 : : * Specify the overall, whole control
39 : : * type (as opposed to parts of the
40 : : * control if it were composite).
41 : : */
42 : :
43 : : typedef sal_uInt32 ControlType;
44 : :
45 : : // for use in general purpose ImplControlValue
46 : : #define CTRL_GENERIC 0
47 : :
48 : : // Normal PushButton/Command Button
49 : : #define CTRL_PUSHBUTTON 1
50 : :
51 : : // Normal single radio button
52 : : #define CTRL_RADIOBUTTON 2
53 : :
54 : : // Normal single checkbox
55 : : #define CTRL_CHECKBOX 10
56 : :
57 : : // Combobox, i.e. a ListBox
58 : : // that allows data entry by user
59 : : #define CTRL_COMBOBOX 20
60 : :
61 : : // Control that allows text entry
62 : : #define CTRL_EDITBOX 30
63 : :
64 : : // Control that allows text entry, but without the usual border
65 : : // Has to be handled separately, because this one cannot handle
66 : : // HAS_BACKGROUND_TEXTURE, which is drawn in the edit box'es
67 : : // border window.
68 : : #define CTRL_EDITBOX_NOBORDER 31
69 : :
70 : : // Control that allows text entry
71 : : // ( some systems distingish between single and multi line edit boxes )
72 : : #define CTRL_MULTILINE_EDITBOX 32
73 : :
74 : : // Control that pops up a menu,
75 : : // but does NOT allow data entry
76 : : #define CTRL_LISTBOX 35
77 : :
78 : : // An edit field together with two little
79 : : // buttons on the side (aka spin field)
80 : : #define CTRL_SPINBOX 40
81 : :
82 : : // Two standalone spin buttons
83 : : // without an edit field
84 : : #define CTRL_SPINBUTTONS 45
85 : :
86 : : // A single tab
87 : : #define CTRL_TAB_ITEM 50
88 : :
89 : : // The border around a tab area,
90 : : // but without the tabs themselves.
91 : : // May have a gap at the top for
92 : : // the active tab
93 : : #define CTRL_TAB_PANE 55
94 : :
95 : : // Background of a Tab Pane
96 : : #define CTRL_TAB_BODY 56
97 : :
98 : : // Normal scrollbar, including
99 : : // all parts like slider, buttons
100 : : #define CTRL_SCROLLBAR 60
101 : :
102 : : #define CTRL_SLIDER 65
103 : :
104 : : // Border around a group of related
105 : : // items, perhaps also displaying
106 : : // a label of identification
107 : : #define CTRL_GROUPBOX 70
108 : :
109 : : // A separator line
110 : : #define CTRL_FIXEDLINE 80
111 : :
112 : : // A toolbar control with buttons and a grip
113 : : #define CTRL_TOOLBAR 100
114 : :
115 : : // The menubar
116 : : #define CTRL_MENUBAR 120
117 : : // popup menu
118 : : #define CTRL_MENU_POPUP 121
119 : :
120 : : // The statusbar
121 : : #define CTRL_STATUSBAR 130
122 : : #define CTRL_PROGRESS 131
123 : : // Progress bar for the intro window
124 : : // (aka splash screen), in case some
125 : : // wants native progress bar in the
126 : : // application but not for the splash
127 : : // screen (used in desktop/)
128 : : #define CTRL_INTROPROGRESS 132
129 : :
130 : : // tool tips
131 : : #define CTRL_TOOLTIP 140
132 : :
133 : : // to draw the implemented theme
134 : : #define CTRL_WINDOW_BACKGROUND 150
135 : :
136 : : //to draw border of frames natively
137 : : #define CTRL_FRAME 160
138 : :
139 : : // for nodes in listviews
140 : : // used in svtools/source/contnr/svtreebx.cxx
141 : : #define CTRL_LISTNODE 170
142 : : // nets between elements of listviews
143 : : // with nodes
144 : : #define CTRL_LISTNET 171
145 : : // for list headers
146 : : #define CTRL_LISTHEADER 172
147 : :
148 : :
149 : : /* Control Parts:
150 : : *
151 : : * Uniquely identify a part of a control,
152 : : * for example the slider of a scroll bar.
153 : : */
154 : :
155 : : typedef sal_uInt32 ControlPart;
156 : :
157 : : #define PART_ENTIRE_CONTROL 1
158 : : #define PART_WINDOW 5 // the static listbox window containing the list
159 : : #define PART_BUTTON 100
160 : : #define PART_BUTTON_UP 101
161 : : #define PART_BUTTON_DOWN 102 // Also for ComboBoxes/ListBoxes
162 : : #define PART_BUTTON_LEFT 103
163 : : #define PART_BUTTON_RIGHT 104
164 : : #define PART_ALL_BUTTONS 105
165 : : #define PART_SEPARATOR_HORZ 106
166 : : #define PART_SEPARATOR_VERT 107
167 : : #define PART_TRACK_HORZ_LEFT 200
168 : : #define PART_TRACK_VERT_UPPER 201
169 : : #define PART_TRACK_HORZ_RIGHT 202
170 : : #define PART_TRACK_VERT_LOWER 203
171 : : #define PART_TRACK_HORZ_AREA 204
172 : : #define PART_TRACK_VERT_AREA 205
173 : : #define PART_THUMB_HORZ 210 // Also used as toolbar grip
174 : : #define PART_THUMB_VERT 211 // Also used as toolbar grip
175 : : #define PART_ARROW 220
176 : : #define PART_MENU_ITEM 250
177 : : #define PART_MENU_ITEM_CHECK_MARK 251
178 : : #define PART_MENU_ITEM_RADIO_MARK 252
179 : : #define PART_MENU_SEPARATOR 253
180 : : #define PART_MENU_SUBMENU_ARROW 254
181 : :
182 : : /* #i77549#
183 : : HACK: for scrollbars in case of thumb rect, page up and page down rect we
184 : : abuse the HitTestNativeControl interface. All theming engines but aqua
185 : : are actually able to draw the thumb according to our internal representation.
186 : : However aqua draws a little outside. The canonical way would be to enhance the
187 : : HitTestNativeControl passing a ScrollbarValue additionally so all necessary
188 : : information is available in the call.
189 : : .
190 : : However since there is only this one small exception we will deviate a little and
191 : : instead pass the respective rect as control region to allow for a small correction.
192 : :
193 : : So all places using HitTestNativeControl on PART_THUMB_HORZ, PART_THUMB_VERT,
194 : : PART_TRACK_HORZ_LEFT, PART_TRACK_HORZ_RIGHT, PART_TRACK_VERT_UPPER, PART_TRACK_VERT_LOWER
195 : : do not use the control rectangle as region but the actuall part rectangle, making
196 : : only small deviations feasible.
197 : : */
198 : :
199 : : /** The edit field part of a control, e.g. of the combo box.
200 : :
201 : : Currently used just for combo boxes and just for GetNativeControlRegion().
202 : : It is valid only if GetNativeControlRegion() supports PART_BUTTON_DOWN as
203 : : well.
204 : : */
205 : : #define PART_SUB_EDIT 300
206 : :
207 : : // For controls that require the entire background
208 : : // to be drawn first, and then other pieces over top.
209 : : // (GTK+ scrollbars for example). Control region passed
210 : : // in to draw this part is expected to be the entire
211 : : // area of the control.
212 : : // A control may respond to one or both.
213 : : #define PART_DRAW_BACKGROUND_HORZ 1000
214 : : #define PART_DRAW_BACKGROUND_VERT 1001
215 : :
216 : : // GTK+ also draws tabs right->left since there is a
217 : : // hardcoded 2 pixel overlap between adjacent tabs
218 : : #define PART_TABS_DRAW_RTL 3000
219 : :
220 : : // For themes that do not want to have the focus
221 : : // rectangle part drawn by VCL but take care of the
222 : : // whole inner control part by themselves
223 : : // eg, listboxes or comboboxes or spinbuttons
224 : : #define HAS_BACKGROUND_TEXTURE 4000
225 : :
226 : : // For scrollbars that have 3 buttons (most KDE themes)
227 : : #define HAS_THREE_BUTTONS 5000
228 : :
229 : : #define PART_BACKGROUND_WINDOW 6000
230 : : #define PART_BACKGROUND_DIALOG 6001
231 : :
232 : : //to draw natively the border of frames
233 : : #define PART_BORDER 7000
234 : :
235 : : /* Control State:
236 : : *
237 : : * Specify how a particular part of the control
238 : : * is to be drawn. Constants are bitwise OR-ed
239 : : * together to compose a final drawing state.
240 : : * A _disabled_ state is assumed by the drawing
241 : : * functions until an ENABLED or HIDDEN is passed
242 : : * in the ControlState.
243 : : */
244 : :
245 : : typedef sal_uInt32 ControlState;
246 : :
247 : : #define CTRL_STATE_ENABLED 0x0001
248 : : #define CTRL_STATE_FOCUSED 0x0002
249 : : #define CTRL_STATE_PRESSED 0x0004
250 : : #define CTRL_STATE_ROLLOVER 0x0008
251 : : #define CTRL_STATE_HIDDEN 0x0010
252 : : #define CTRL_STATE_DEFAULT 0x0020
253 : : #define CTRL_STATE_SELECTED 0x0040
254 : : #define CTRL_CACHING_ALLOWED 0x8000 // set when the control is completely visible (i.e. not clipped)
255 : :
256 : : /* ButtonValue:
257 : : *
258 : : * Identifies the tri-state value options
259 : : * that buttons allow
260 : : */
261 : :
262 : : enum ButtonValue {
263 : : BUTTONVALUE_DONTKNOW,
264 : : BUTTONVALUE_ON,
265 : : BUTTONVALUE_OFF,
266 : : BUTTONVALUE_MIXED
267 : : };
268 : :
269 : : /* ImplControlValue:
270 : : *
271 : : * Generic value container for all control parts.
272 : : */
273 : :
274 : 54123 : class VCL_DLLPUBLIC ImplControlValue
275 : : {
276 : : friend class SalFrame;
277 : :
278 : : private:
279 : : ControlType mType;
280 : : ButtonValue mTristate; // Tristate value: on, off, mixed
281 : : long mNumber; // numeric value
282 : : protected:
283 : 25624 : ImplControlValue( ControlType i_eType, ButtonValue i_eTriState, long i_nNumber )
284 : : : mType( i_eType )
285 : : , mTristate( i_eTriState )
286 : 25624 : , mNumber( i_nNumber )
287 : 25624 : {}
288 : :
289 : : public:
290 : 0 : explicit ImplControlValue( ButtonValue nTristate )
291 : 0 : : mType( CTRL_GENERIC ), mTristate(nTristate), mNumber(0) {}
292 : 241 : explicit ImplControlValue( long nNumeric )
293 : 241 : : mType( CTRL_GENERIC ), mTristate(BUTTONVALUE_DONTKNOW), mNumber( nNumeric) {}
294 : 57312 : inline ImplControlValue()
295 : 57312 : : mType( CTRL_GENERIC ), mTristate(BUTTONVALUE_DONTKNOW), mNumber(0) {}
296 : :
297 : : virtual ~ImplControlValue();
298 : :
299 : : virtual ImplControlValue* clone() const;
300 : :
301 : 54123 : ControlType getType() const { return mType; }
302 : :
303 : 0 : inline ButtonValue getTristateVal( void ) const { return mTristate; }
304 : 0 : inline void setTristateVal( ButtonValue nTristate ) { mTristate = nTristate; }
305 : :
306 : 0 : inline long getNumericVal( void ) const { return mNumber; }
307 : 0 : inline void setNumericVal( long nNumeric ) { mNumber = nNumeric; }
308 : : };
309 : :
310 : : /* ScrollbarValue:
311 : : *
312 : : * Value container for scrollbars.
313 : : */
314 : 0 : class VCL_DLLPUBLIC ScrollbarValue : public ImplControlValue
315 : : {
316 : : public:
317 : : long mnMin;
318 : : long mnMax;
319 : : long mnCur;
320 : : long mnVisibleSize;
321 : : Rectangle maThumbRect;
322 : : Rectangle maButton1Rect;
323 : : Rectangle maButton2Rect;
324 : : ControlState mnButton1State;
325 : : ControlState mnButton2State;
326 : : ControlState mnThumbState;
327 : : ControlState mnPage1State;
328 : : ControlState mnPage2State;
329 : :
330 : 24917 : inline ScrollbarValue()
331 [ + - ][ + - ]: 24917 : : ImplControlValue( CTRL_SCROLLBAR, BUTTONVALUE_DONTKNOW, 0 )
[ + - ]
332 : : {
333 : 24917 : mnMin = 0; mnMax = 0; mnCur = 0; mnVisibleSize = 0;
334 : 24917 : mnButton1State = 0; mnButton2State = 0;
335 : 24917 : mnThumbState = 0; mnPage1State = 0; mnPage2State = 0;
336 : 24917 : };
337 : : virtual ~ScrollbarValue();
338 : : virtual ScrollbarValue* clone() const;
339 : : };
340 : :
341 : 0 : class VCL_DLLPUBLIC SliderValue : public ImplControlValue
342 : : {
343 : : public:
344 : : long mnMin;
345 : : long mnMax;
346 : : long mnCur;
347 : : Rectangle maThumbRect;
348 : : ControlState mnThumbState;
349 : :
350 : 0 : SliderValue()
351 : : : ImplControlValue( CTRL_SLIDER, BUTTONVALUE_DONTKNOW, 0 )
352 [ # # ]: 0 : , mnMin( 0 ), mnMax( 0 ), mnCur( 0 ), mnThumbState( 0 )
353 : 0 : {}
354 : : virtual ~SliderValue();
355 : : virtual SliderValue* clone() const;
356 : : };
357 : :
358 : : /* TabitemValue:
359 : : *
360 : : * Value container for tabitems.
361 : : */
362 : :
363 : : /* TABITEM constants are OR-ed together */
364 : : #define TABITEM_NOTALIGNED 0x000 // the tabitem is an inner item
365 : : #define TABITEM_LEFTALIGNED 0x001 // the tabitem is aligned with the left border of the TabControl
366 : : #define TABITEM_RIGHTALIGNED 0x002 // the tabitem is aligned with the right border of the TabControl
367 : : #define TABITEM_FIRST_IN_GROUP 0x004 // the tabitem is the first in group of tabitems
368 : : #define TABITEM_LAST_IN_GROUP 0x008 // the tabitem is the last in group of tabitems
369 : :
370 : 0 : class VCL_DLLPUBLIC TabitemValue : public ImplControlValue
371 : : {
372 : : public:
373 : : unsigned int mnAlignment;
374 : :
375 : 0 : inline TabitemValue()
376 : 0 : : ImplControlValue( CTRL_TAB_ITEM, BUTTONVALUE_DONTKNOW, 0 )
377 : : {
378 : 0 : mnAlignment = 0;
379 : 0 : };
380 : : virtual ~TabitemValue();
381 : : virtual TabitemValue* clone() const;
382 : :
383 : : sal_Bool isLeftAligned() const { return (mnAlignment & TABITEM_LEFTALIGNED) != 0; }
384 : : sal_Bool isRightAligned() const { return (mnAlignment & TABITEM_RIGHTALIGNED) != 0; }
385 : : sal_Bool isBothAligned() const { return isLeftAligned() && isRightAligned(); }
386 : : sal_Bool isNotAligned() const { return (mnAlignment & (TABITEM_LEFTALIGNED | TABITEM_RIGHTALIGNED)) == 0; }
387 : 0 : sal_Bool isFirst() const { return (mnAlignment & TABITEM_FIRST_IN_GROUP) != 0; }
388 : : sal_Bool isLast() const { return (mnAlignment & TABITEM_LAST_IN_GROUP) != 0; }
389 : : };
390 : :
391 : : /* SpinbuttonValue:
392 : : *
393 : : * Value container for spinbuttons to paint both buttons at once.
394 : : * Note: the other parameters of DrawNativeControl will have no meaning
395 : : * all parameters for spinbuttons are carried here
396 : : */
397 : 0 : class VCL_DLLPUBLIC SpinbuttonValue : public ImplControlValue
398 : : {
399 : : public:
400 : : Rectangle maUpperRect;
401 : : Rectangle maLowerRect;
402 : : ControlState mnUpperState;
403 : : ControlState mnLowerState;
404 : : int mnUpperPart;
405 : : int mnLowerPart;
406 : :
407 : 707 : inline SpinbuttonValue()
408 [ + - ][ + - ]: 707 : : ImplControlValue( CTRL_SPINBUTTONS, BUTTONVALUE_DONTKNOW, 0 )
409 : : {
410 : 707 : mnUpperState = mnLowerState = 0;
411 : 707 : };
412 : : virtual ~SpinbuttonValue();
413 : : virtual SpinbuttonValue* clone() const;
414 : : };
415 : :
416 : : /* Toolbarvalue:
417 : : *
418 : : * Value container for toolbars detailing the grip position
419 : : */
420 : 0 : class VCL_DLLPUBLIC ToolbarValue : public ImplControlValue
421 : : {
422 : : public:
423 [ # # ]: 0 : ToolbarValue() : ImplControlValue( CTRL_TOOLBAR, BUTTONVALUE_DONTKNOW, 0 )
424 : 0 : { mbIsTopDockingArea = sal_False; }
425 : : virtual ~ToolbarValue();
426 : : virtual ToolbarValue* clone() const;
427 : : Rectangle maGripRect;
428 : : sal_Bool mbIsTopDockingArea; // indicates that this is the top aligned dockingarea
429 : : // adjacent to the menubar
430 : : };
431 : :
432 : : /* MenubarValue:
433 : : *
434 : : * Value container for menubars specifying height of adjacent docking area
435 : : */
436 : 0 : class VCL_DLLPUBLIC MenubarValue : public ImplControlValue
437 : : {
438 : : public:
439 : 0 : MenubarValue() : ImplControlValue( CTRL_MENUBAR, BUTTONVALUE_DONTKNOW, 0 )
440 : 0 : { maTopDockingAreaHeight=0; }
441 : : virtual ~MenubarValue();
442 : : virtual MenubarValue* clone() const;
443 : : int maTopDockingAreaHeight;
444 : : };
445 : :
446 : : /* MenupopupValue:
447 : : *
448 : : * Value container for menu items; specifies the rectangle for the whole item which
449 : : * may be useful when drawing parts with a smaller rectangle.
450 : : */
451 : 0 : class VCL_DLLPUBLIC MenupopupValue : public ImplControlValue
452 : : {
453 : : public:
454 : : MenupopupValue() : ImplControlValue( CTRL_MENU_POPUP, BUTTONVALUE_DONTKNOW, 0 )
455 : : {}
456 : 0 : MenupopupValue( long i_nGutterWidth, const Rectangle& i_rItemRect )
457 : : : ImplControlValue( CTRL_MENU_POPUP, BUTTONVALUE_DONTKNOW, i_nGutterWidth )
458 : 0 : , maItemRect( i_rItemRect )
459 : 0 : {}
460 : : virtual ~MenupopupValue();
461 : : virtual MenupopupValue* clone() const;
462 : : Rectangle maItemRect;
463 : : };
464 : :
465 : : /* PushButtonValue:
466 : : *
467 : : * Value container for pushbuttons specifying additional drawing hints
468 : : */
469 : 0 : class VCL_DLLPUBLIC PushButtonValue : public ImplControlValue
470 : : {
471 : : public:
472 : 0 : PushButtonValue()
473 : : : ImplControlValue( CTRL_PUSHBUTTON, BUTTONVALUE_DONTKNOW, 0 )
474 : 0 : , mbBevelButton( false ), mbSingleLine( true ) {}
475 : : virtual ~PushButtonValue();
476 : : virtual PushButtonValue* clone() const;
477 : :
478 : : bool mbBevelButton:1;
479 : : bool mbSingleLine:1;
480 : : };
481 : :
482 : :
483 : : #endif
484 : :
485 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|