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