1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef _SV_NATIVEWIDGETS_HXX
21 #define _SV_NATIVEWIDGETS_HXX
23 #include <rtl/ustring.hxx>
24 #include <vcl/dllapi.h>
25 #include <tools/gen.hxx>
29 * Specify the overall, whole control
30 * type (as opposed to parts of the
31 * control if it were composite).
34 typedef sal_uInt32 ControlType
;
36 // for use in general purpose ImplControlValue
37 #define CTRL_GENERIC 0
39 // Normal PushButton/Command Button
40 #define CTRL_PUSHBUTTON 1
42 // Normal single radio button
43 #define CTRL_RADIOBUTTON 2
45 // Normal single checkbox
46 #define CTRL_CHECKBOX 10
48 // Combobox, i.e. a ListBox
49 // that allows data entry by user
50 #define CTRL_COMBOBOX 20
52 // Control that allows text entry
53 #define CTRL_EDITBOX 30
55 // Control that allows text entry, but without the usual border
56 // Has to be handled separately, because this one cannot handle
57 // HAS_BACKGROUND_TEXTURE, which is drawn in the edit box'es
59 #define CTRL_EDITBOX_NOBORDER 31
61 // Control that allows text entry
62 // ( some systems distingish between single and multi line edit boxes )
63 #define CTRL_MULTILINE_EDITBOX 32
65 // Control that pops up a menu,
66 // but does NOT allow data entry
67 #define CTRL_LISTBOX 35
69 // An edit field together with two little
70 // buttons on the side (aka spin field)
71 #define CTRL_SPINBOX 40
73 // Two standalone spin buttons
74 // without an edit field
75 #define CTRL_SPINBUTTONS 45
78 #define CTRL_TAB_ITEM 50
80 // The border around a tab area,
81 // but without the tabs themselves.
82 // May have a gap at the top for
84 #define CTRL_TAB_PANE 55
86 // Background of a Tab Pane
87 #define CTRL_TAB_BODY 56
89 // Normal scrollbar, including
90 // all parts like slider, buttons
91 #define CTRL_SCROLLBAR 60
93 #define CTRL_SLIDER 65
95 // Border around a group of related
96 // items, perhaps also displaying
97 // a label of identification
98 #define CTRL_GROUPBOX 70
101 #define CTRL_FIXEDLINE 80
103 // A toolbar control with buttons and a grip
104 #define CTRL_TOOLBAR 100
107 #define CTRL_MENUBAR 120
109 #define CTRL_MENU_POPUP 121
112 #define CTRL_STATUSBAR 130
113 #define CTRL_PROGRESS 131
114 // Progress bar for the intro window
115 // (aka splash screen), in case some
116 // wants native progress bar in the
117 // application but not for the splash
118 // screen (used in desktop/)
119 #define CTRL_INTROPROGRESS 132
122 #define CTRL_TOOLTIP 140
124 // to draw the implemented theme
125 #define CTRL_WINDOW_BACKGROUND 150
127 //to draw border of frames natively
128 #define CTRL_FRAME 160
130 // for nodes in listviews
131 // used in svtools/source/contnr/svtreebx.cxx
132 #define CTRL_LISTNODE 170
133 // nets between elements of listviews
135 #define CTRL_LISTNET 171
137 #define CTRL_LISTHEADER 172
142 * Uniquely identify a part of a control,
143 * for example the slider of a scroll bar.
146 typedef sal_uInt32 ControlPart
;
148 #define PART_ENTIRE_CONTROL 1
149 #define PART_WINDOW 5 // the static listbox window containing the list
150 #define PART_BUTTON 100
151 #define PART_BUTTON_UP 101
152 #define PART_BUTTON_DOWN 102 // Also for ComboBoxes/ListBoxes
153 #define PART_BUTTON_LEFT 103
154 #define PART_BUTTON_RIGHT 104
155 #define PART_ALL_BUTTONS 105
156 #define PART_SEPARATOR_HORZ 106
157 #define PART_SEPARATOR_VERT 107
158 #define PART_TRACK_HORZ_LEFT 200
159 #define PART_TRACK_VERT_UPPER 201
160 #define PART_TRACK_HORZ_RIGHT 202
161 #define PART_TRACK_VERT_LOWER 203
162 #define PART_TRACK_HORZ_AREA 204
163 #define PART_TRACK_VERT_AREA 205
164 #define PART_THUMB_HORZ 210 // Also used as toolbar grip
165 #define PART_THUMB_VERT 211 // Also used as toolbar grip
166 #define PART_ARROW 220
167 #define PART_MENU_ITEM 250
168 #define PART_MENU_ITEM_CHECK_MARK 251
169 #define PART_MENU_ITEM_RADIO_MARK 252
170 #define PART_MENU_SEPARATOR 253
171 #define PART_MENU_SUBMENU_ARROW 254
174 HACK: for scrollbars in case of thumb rect, page up and page down rect we
175 abuse the HitTestNativeControl interface. All theming engines but aqua
176 are actually able to draw the thumb according to our internal representation.
177 However aqua draws a little outside. The canonical way would be to enhance the
178 HitTestNativeControl passing a ScrollbarValue additionally so all necessary
179 information is available in the call.
181 However since there is only this one small exception we will deviate a little and
182 instead pass the respective rect as control region to allow for a small correction.
184 So all places using HitTestNativeControl on PART_THUMB_HORZ, PART_THUMB_VERT,
185 PART_TRACK_HORZ_LEFT, PART_TRACK_HORZ_RIGHT, PART_TRACK_VERT_UPPER, PART_TRACK_VERT_LOWER
186 do not use the control rectangle as region but the actuall part rectangle, making
187 only small deviations feasible.
190 /** The edit field part of a control, e.g. of the combo box.
192 Currently used just for combo boxes and just for GetNativeControlRegion().
193 It is valid only if GetNativeControlRegion() supports PART_BUTTON_DOWN as
196 #define PART_SUB_EDIT 300
198 // For controls that require the entire background
199 // to be drawn first, and then other pieces over top.
200 // (GTK+ scrollbars for example). Control region passed
201 // in to draw this part is expected to be the entire
202 // area of the control.
203 // A control may respond to one or both.
204 #define PART_DRAW_BACKGROUND_HORZ 1000
205 #define PART_DRAW_BACKGROUND_VERT 1001
207 // GTK+ also draws tabs right->left since there is a
208 // hardcoded 2 pixel overlap between adjacent tabs
209 #define PART_TABS_DRAW_RTL 3000
211 // For themes that do not want to have the focus
212 // rectangle part drawn by VCL but take care of the
213 // whole inner control part by themselves
214 // eg, listboxes or comboboxes or spinbuttons
215 #define HAS_BACKGROUND_TEXTURE 4000
217 // For scrollbars that have 3 buttons (most KDE themes)
218 #define HAS_THREE_BUTTONS 5000
220 #define PART_BACKGROUND_WINDOW 6000
221 #define PART_BACKGROUND_DIALOG 6001
223 //to draw natively the border of frames
224 #define PART_BORDER 7000
228 * Specify how a particular part of the control
229 * is to be drawn. Constants are bitwise OR-ed
230 * together to compose a final drawing state.
231 * A _disabled_ state is assumed by the drawing
232 * functions until an ENABLED or HIDDEN is passed
233 * in the ControlState.
236 typedef sal_uInt32 ControlState
;
238 #define CTRL_STATE_ENABLED 0x0001
239 #define CTRL_STATE_FOCUSED 0x0002
240 #define CTRL_STATE_PRESSED 0x0004
241 #define CTRL_STATE_ROLLOVER 0x0008
242 #define CTRL_STATE_HIDDEN 0x0010
243 #define CTRL_STATE_DEFAULT 0x0020
244 #define CTRL_STATE_SELECTED 0x0040
245 #define CTRL_CACHING_ALLOWED 0x8000 // set when the control is completely visible (i.e. not clipped)
249 * Identifies the tri-state value options
254 BUTTONVALUE_DONTKNOW
,
262 * Generic value container for all control parts.
265 class VCL_DLLPUBLIC ImplControlValue
267 friend class SalFrame
;
271 ButtonValue mTristate
; // Tristate value: on, off, mixed
272 long mNumber
; // numeric value
274 ImplControlValue( ControlType i_eType
, ButtonValue i_eTriState
, long i_nNumber
)
276 , mTristate( i_eTriState
)
277 , mNumber( i_nNumber
)
281 explicit ImplControlValue( ButtonValue nTristate
)
282 : mType( CTRL_GENERIC
), mTristate(nTristate
), mNumber(0) {}
283 explicit ImplControlValue( long nNumeric
)
284 : mType( CTRL_GENERIC
), mTristate(BUTTONVALUE_DONTKNOW
), mNumber( nNumeric
) {}
285 inline ImplControlValue()
286 : mType( CTRL_GENERIC
), mTristate(BUTTONVALUE_DONTKNOW
), mNumber(0) {}
288 virtual ~ImplControlValue();
290 virtual ImplControlValue
* clone() const;
292 ControlType
getType() const { return mType
; }
294 inline ButtonValue
getTristateVal( void ) const { return mTristate
; }
295 inline void setTristateVal( ButtonValue nTristate
) { mTristate
= nTristate
; }
297 inline long getNumericVal( void ) const { return mNumber
; }
298 inline void setNumericVal( long nNumeric
) { mNumber
= nNumeric
; }
303 * Value container for scrollbars.
305 class VCL_DLLPUBLIC ScrollbarValue
: public ImplControlValue
312 Rectangle maThumbRect
;
313 Rectangle maButton1Rect
;
314 Rectangle maButton2Rect
;
315 ControlState mnButton1State
;
316 ControlState mnButton2State
;
317 ControlState mnThumbState
;
318 ControlState mnPage1State
;
319 ControlState mnPage2State
;
321 inline ScrollbarValue()
322 : ImplControlValue( CTRL_SCROLLBAR
, BUTTONVALUE_DONTKNOW
, 0 )
324 mnMin
= 0; mnMax
= 0; mnCur
= 0; mnVisibleSize
= 0;
325 mnButton1State
= 0; mnButton2State
= 0;
326 mnThumbState
= 0; mnPage1State
= 0; mnPage2State
= 0;
328 virtual ~ScrollbarValue();
329 virtual ScrollbarValue
* clone() const;
332 class VCL_DLLPUBLIC SliderValue
: public ImplControlValue
338 Rectangle maThumbRect
;
339 ControlState mnThumbState
;
342 : ImplControlValue( CTRL_SLIDER
, BUTTONVALUE_DONTKNOW
, 0 )
343 , mnMin( 0 ), mnMax( 0 ), mnCur( 0 ), mnThumbState( 0 )
345 virtual ~SliderValue();
346 virtual SliderValue
* clone() const;
351 * Value container for tabitems.
354 /* TABITEM constants are OR-ed together */
355 #define TABITEM_NOTALIGNED 0x000 // the tabitem is an inner item
356 #define TABITEM_LEFTALIGNED 0x001 // the tabitem is aligned with the left border of the TabControl
357 #define TABITEM_RIGHTALIGNED 0x002 // the tabitem is aligned with the right border of the TabControl
358 #define TABITEM_FIRST_IN_GROUP 0x004 // the tabitem is the first in group of tabitems
359 #define TABITEM_LAST_IN_GROUP 0x008 // the tabitem is the last in group of tabitems
361 class VCL_DLLPUBLIC TabitemValue
: public ImplControlValue
364 unsigned int mnAlignment
;
366 inline TabitemValue()
367 : ImplControlValue( CTRL_TAB_ITEM
, BUTTONVALUE_DONTKNOW
, 0 )
371 virtual ~TabitemValue();
372 virtual TabitemValue
* clone() const;
374 sal_Bool
isLeftAligned() const { return (mnAlignment
& TABITEM_LEFTALIGNED
) != 0; }
375 sal_Bool
isRightAligned() const { return (mnAlignment
& TABITEM_RIGHTALIGNED
) != 0; }
376 sal_Bool
isBothAligned() const { return isLeftAligned() && isRightAligned(); }
377 sal_Bool
isNotAligned() const { return (mnAlignment
& (TABITEM_LEFTALIGNED
| TABITEM_RIGHTALIGNED
)) == 0; }
378 sal_Bool
isFirst() const { return (mnAlignment
& TABITEM_FIRST_IN_GROUP
) != 0; }
379 sal_Bool
isLast() const { return (mnAlignment
& TABITEM_LAST_IN_GROUP
) != 0; }
384 * Value container for spinbuttons to paint both buttons at once.
385 * Note: the other parameters of DrawNativeControl will have no meaning
386 * all parameters for spinbuttons are carried here
388 class VCL_DLLPUBLIC SpinbuttonValue
: public ImplControlValue
391 Rectangle maUpperRect
;
392 Rectangle maLowerRect
;
393 ControlState mnUpperState
;
394 ControlState mnLowerState
;
398 inline SpinbuttonValue()
399 : ImplControlValue( CTRL_SPINBUTTONS
, BUTTONVALUE_DONTKNOW
, 0 )
401 mnUpperState
= mnLowerState
= 0;
403 virtual ~SpinbuttonValue();
404 virtual SpinbuttonValue
* clone() const;
409 * Value container for toolbars detailing the grip position
411 class VCL_DLLPUBLIC ToolbarValue
: public ImplControlValue
414 ToolbarValue() : ImplControlValue( CTRL_TOOLBAR
, BUTTONVALUE_DONTKNOW
, 0 )
415 { mbIsTopDockingArea
= sal_False
; }
416 virtual ~ToolbarValue();
417 virtual ToolbarValue
* clone() const;
418 Rectangle maGripRect
;
419 sal_Bool mbIsTopDockingArea
; // indicates that this is the top aligned dockingarea
420 // adjacent to the menubar
425 * Value container for menubars specifying height of adjacent docking area
427 class VCL_DLLPUBLIC MenubarValue
: public ImplControlValue
430 MenubarValue() : ImplControlValue( CTRL_MENUBAR
, BUTTONVALUE_DONTKNOW
, 0 )
431 { maTopDockingAreaHeight
=0; }
432 virtual ~MenubarValue();
433 virtual MenubarValue
* clone() const;
434 int maTopDockingAreaHeight
;
439 * Value container for menu items; specifies the rectangle for the whole item which
440 * may be useful when drawing parts with a smaller rectangle.
442 class VCL_DLLPUBLIC MenupopupValue
: public ImplControlValue
445 MenupopupValue() : ImplControlValue( CTRL_MENU_POPUP
, BUTTONVALUE_DONTKNOW
, 0 )
447 MenupopupValue( long i_nGutterWidth
, const Rectangle
& i_rItemRect
)
448 : ImplControlValue( CTRL_MENU_POPUP
, BUTTONVALUE_DONTKNOW
, i_nGutterWidth
)
449 , maItemRect( i_rItemRect
)
451 virtual ~MenupopupValue();
452 virtual MenupopupValue
* clone() const;
453 Rectangle maItemRect
;
458 * Value container for pushbuttons specifying additional drawing hints
460 class VCL_DLLPUBLIC PushButtonValue
: public ImplControlValue
464 : ImplControlValue( CTRL_PUSHBUTTON
, BUTTONVALUE_DONTKNOW
, 0 )
465 , mbBevelButton( false ), mbSingleLine( true ) {}
466 virtual ~PushButtonValue();
467 virtual PushButtonValue
* clone() const;
469 bool mbBevelButton
:1;
476 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */