Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef _SV_NATIVEWIDGETS_HXX
21 : #define _SV_NATIVEWIDGETS_HXX
22 :
23 : #include <rtl/ustring.hxx>
24 : #include <vcl/dllapi.h>
25 : #include <tools/gen.hxx>
26 :
27 : /* Control Types:
28 : *
29 : * Specify the overall, whole control
30 : * type (as opposed to parts of the
31 : * control if it were composite).
32 : */
33 :
34 : typedef sal_uInt32 ControlType;
35 :
36 : // for use in general purpose ImplControlValue
37 : #define CTRL_GENERIC 0
38 :
39 : // Normal PushButton/Command Button
40 : #define CTRL_PUSHBUTTON 1
41 :
42 : // Normal single radio button
43 : #define CTRL_RADIOBUTTON 2
44 :
45 : // Normal single checkbox
46 : #define CTRL_CHECKBOX 10
47 :
48 : // Combobox, i.e. a ListBox
49 : // that allows data entry by user
50 : #define CTRL_COMBOBOX 20
51 :
52 : // Control that allows text entry
53 : #define CTRL_EDITBOX 30
54 :
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
58 : // border window.
59 : #define CTRL_EDITBOX_NOBORDER 31
60 :
61 : // Control that allows text entry
62 : // ( some systems distingish between single and multi line edit boxes )
63 : #define CTRL_MULTILINE_EDITBOX 32
64 :
65 : // Control that pops up a menu,
66 : // but does NOT allow data entry
67 : #define CTRL_LISTBOX 35
68 :
69 : // An edit field together with two little
70 : // buttons on the side (aka spin field)
71 : #define CTRL_SPINBOX 40
72 :
73 : // Two standalone spin buttons
74 : // without an edit field
75 : #define CTRL_SPINBUTTONS 45
76 :
77 : // A single tab
78 : #define CTRL_TAB_ITEM 50
79 :
80 : // The border around a tab area,
81 : // but without the tabs themselves.
82 : // May have a gap at the top for
83 : // the active tab
84 : #define CTRL_TAB_PANE 55
85 :
86 : // Background of a Tab Pane
87 : #define CTRL_TAB_BODY 56
88 :
89 : // Normal scrollbar, including
90 : // all parts like slider, buttons
91 : #define CTRL_SCROLLBAR 60
92 :
93 : #define CTRL_SLIDER 65
94 :
95 : // Border around a group of related
96 : // items, perhaps also displaying
97 : // a label of identification
98 : #define CTRL_GROUPBOX 70
99 :
100 : // A separator line
101 : #define CTRL_FIXEDLINE 80
102 :
103 : // A toolbar control with buttons and a grip
104 : #define CTRL_TOOLBAR 100
105 :
106 : // The menubar
107 : #define CTRL_MENUBAR 120
108 : // popup menu
109 : #define CTRL_MENU_POPUP 121
110 :
111 : // The statusbar
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
120 :
121 : // tool tips
122 : #define CTRL_TOOLTIP 140
123 :
124 : // to draw the implemented theme
125 : #define CTRL_WINDOW_BACKGROUND 150
126 :
127 : //to draw border of frames natively
128 : #define CTRL_FRAME 160
129 :
130 : // for nodes in listviews
131 : // used in svtools/source/contnr/svtreebx.cxx
132 : #define CTRL_LISTNODE 170
133 : // nets between elements of listviews
134 : // with nodes
135 : #define CTRL_LISTNET 171
136 : // for list headers
137 : #define CTRL_LISTHEADER 172
138 :
139 :
140 : /* Control Parts:
141 : *
142 : * Uniquely identify a part of a control,
143 : * for example the slider of a scroll bar.
144 : */
145 :
146 : typedef sal_uInt32 ControlPart;
147 :
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
172 :
173 : /* #i77549#
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.
180 : .
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.
183 :
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.
188 : */
189 :
190 : /** The edit field part of a control, e.g. of the combo box.
191 :
192 : Currently used just for combo boxes and just for GetNativeControlRegion().
193 : It is valid only if GetNativeControlRegion() supports PART_BUTTON_DOWN as
194 : well.
195 : */
196 : #define PART_SUB_EDIT 300
197 :
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
206 :
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
210 :
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
216 :
217 : // For scrollbars that have 3 buttons (most KDE themes)
218 : #define HAS_THREE_BUTTONS 5000
219 :
220 : #define PART_BACKGROUND_WINDOW 6000
221 : #define PART_BACKGROUND_DIALOG 6001
222 :
223 : //to draw natively the border of frames
224 : #define PART_BORDER 7000
225 :
226 : /* Control State:
227 : *
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.
234 : */
235 :
236 : typedef sal_uInt32 ControlState;
237 :
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)
246 :
247 : /* ButtonValue:
248 : *
249 : * Identifies the tri-state value options
250 : * that buttons allow
251 : */
252 :
253 : enum ButtonValue {
254 : BUTTONVALUE_DONTKNOW,
255 : BUTTONVALUE_ON,
256 : BUTTONVALUE_OFF,
257 : BUTTONVALUE_MIXED
258 : };
259 :
260 : /* ImplControlValue:
261 : *
262 : * Generic value container for all control parts.
263 : */
264 :
265 28992 : class VCL_DLLPUBLIC ImplControlValue
266 : {
267 : friend class SalFrame;
268 :
269 : private:
270 : ControlType mType;
271 : ButtonValue mTristate; // Tristate value: on, off, mixed
272 : long mNumber; // numeric value
273 : protected:
274 15031 : ImplControlValue( ControlType i_eType, ButtonValue i_eTriState, long i_nNumber )
275 : : mType( i_eType )
276 : , mTristate( i_eTriState )
277 15031 : , mNumber( i_nNumber )
278 15031 : {}
279 :
280 : public:
281 0 : explicit ImplControlValue( ButtonValue nTristate )
282 0 : : mType( CTRL_GENERIC ), mTristate(nTristate), mNumber(0) {}
283 121 : explicit ImplControlValue( long nNumeric )
284 121 : : mType( CTRL_GENERIC ), mTristate(BUTTONVALUE_DONTKNOW), mNumber( nNumeric) {}
285 31472 : inline ImplControlValue()
286 31472 : : mType( CTRL_GENERIC ), mTristate(BUTTONVALUE_DONTKNOW), mNumber(0) {}
287 :
288 : virtual ~ImplControlValue();
289 :
290 : virtual ImplControlValue* clone() const;
291 :
292 28992 : ControlType getType() const { return mType; }
293 :
294 0 : inline ButtonValue getTristateVal( void ) const { return mTristate; }
295 0 : inline void setTristateVal( ButtonValue nTristate ) { mTristate = nTristate; }
296 :
297 0 : inline long getNumericVal( void ) const { return mNumber; }
298 0 : inline void setNumericVal( long nNumeric ) { mNumber = nNumeric; }
299 : };
300 :
301 : /* ScrollbarValue:
302 : *
303 : * Value container for scrollbars.
304 : */
305 0 : class VCL_DLLPUBLIC ScrollbarValue : public ImplControlValue
306 : {
307 : public:
308 : long mnMin;
309 : long mnMax;
310 : long mnCur;
311 : long mnVisibleSize;
312 : Rectangle maThumbRect;
313 : Rectangle maButton1Rect;
314 : Rectangle maButton2Rect;
315 : ControlState mnButton1State;
316 : ControlState mnButton2State;
317 : ControlState mnThumbState;
318 : ControlState mnPage1State;
319 : ControlState mnPage2State;
320 :
321 14667 : inline ScrollbarValue()
322 14667 : : ImplControlValue( CTRL_SCROLLBAR, BUTTONVALUE_DONTKNOW, 0 )
323 : {
324 14667 : mnMin = 0; mnMax = 0; mnCur = 0; mnVisibleSize = 0;
325 14667 : mnButton1State = 0; mnButton2State = 0;
326 14667 : mnThumbState = 0; mnPage1State = 0; mnPage2State = 0;
327 14667 : };
328 : virtual ~ScrollbarValue();
329 : virtual ScrollbarValue* clone() const;
330 : };
331 :
332 0 : 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 :
341 0 : SliderValue()
342 : : ImplControlValue( CTRL_SLIDER, BUTTONVALUE_DONTKNOW, 0 )
343 0 : , mnMin( 0 ), mnMax( 0 ), mnCur( 0 ), mnThumbState( 0 )
344 0 : {}
345 : virtual ~SliderValue();
346 : virtual SliderValue* clone() const;
347 : };
348 :
349 : /* TabitemValue:
350 : *
351 : * Value container for tabitems.
352 : */
353 :
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
360 :
361 0 : class VCL_DLLPUBLIC TabitemValue : public ImplControlValue
362 : {
363 : public:
364 : unsigned int mnAlignment;
365 :
366 0 : inline TabitemValue()
367 0 : : ImplControlValue( CTRL_TAB_ITEM, BUTTONVALUE_DONTKNOW, 0 )
368 : {
369 0 : mnAlignment = 0;
370 0 : };
371 : virtual ~TabitemValue();
372 : virtual TabitemValue* clone() const;
373 :
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 0 : sal_Bool isFirst() const { return (mnAlignment & TABITEM_FIRST_IN_GROUP) != 0; }
379 : sal_Bool isLast() const { return (mnAlignment & TABITEM_LAST_IN_GROUP) != 0; }
380 : };
381 :
382 : /* SpinbuttonValue:
383 : *
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
387 : */
388 0 : class VCL_DLLPUBLIC SpinbuttonValue : public ImplControlValue
389 : {
390 : public:
391 : Rectangle maUpperRect;
392 : Rectangle maLowerRect;
393 : ControlState mnUpperState;
394 : ControlState mnLowerState;
395 : int mnUpperPart;
396 : int mnLowerPart;
397 :
398 364 : inline SpinbuttonValue()
399 364 : : ImplControlValue( CTRL_SPINBUTTONS, BUTTONVALUE_DONTKNOW, 0 )
400 : {
401 364 : mnUpperState = mnLowerState = 0;
402 364 : };
403 : virtual ~SpinbuttonValue();
404 : virtual SpinbuttonValue* clone() const;
405 : };
406 :
407 : /* Toolbarvalue:
408 : *
409 : * Value container for toolbars detailing the grip position
410 : */
411 0 : class VCL_DLLPUBLIC ToolbarValue : public ImplControlValue
412 : {
413 : public:
414 0 : ToolbarValue() : ImplControlValue( CTRL_TOOLBAR, BUTTONVALUE_DONTKNOW, 0 )
415 0 : { 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
421 : };
422 :
423 : /* MenubarValue:
424 : *
425 : * Value container for menubars specifying height of adjacent docking area
426 : */
427 0 : class VCL_DLLPUBLIC MenubarValue : public ImplControlValue
428 : {
429 : public:
430 0 : MenubarValue() : ImplControlValue( CTRL_MENUBAR, BUTTONVALUE_DONTKNOW, 0 )
431 0 : { maTopDockingAreaHeight=0; }
432 : virtual ~MenubarValue();
433 : virtual MenubarValue* clone() const;
434 : int maTopDockingAreaHeight;
435 : };
436 :
437 : /* MenupopupValue:
438 : *
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.
441 : */
442 0 : class VCL_DLLPUBLIC MenupopupValue : public ImplControlValue
443 : {
444 : public:
445 : MenupopupValue() : ImplControlValue( CTRL_MENU_POPUP, BUTTONVALUE_DONTKNOW, 0 )
446 : {}
447 0 : MenupopupValue( long i_nGutterWidth, const Rectangle& i_rItemRect )
448 : : ImplControlValue( CTRL_MENU_POPUP, BUTTONVALUE_DONTKNOW, i_nGutterWidth )
449 0 : , maItemRect( i_rItemRect )
450 0 : {}
451 : virtual ~MenupopupValue();
452 : virtual MenupopupValue* clone() const;
453 : Rectangle maItemRect;
454 : };
455 :
456 : /* PushButtonValue:
457 : *
458 : * Value container for pushbuttons specifying additional drawing hints
459 : */
460 0 : class VCL_DLLPUBLIC PushButtonValue : public ImplControlValue
461 : {
462 : public:
463 0 : PushButtonValue()
464 : : ImplControlValue( CTRL_PUSHBUTTON, BUTTONVALUE_DONTKNOW, 0 )
465 0 : , mbBevelButton( false ), mbSingleLine( true ) {}
466 : virtual ~PushButtonValue();
467 : virtual PushButtonValue* clone() const;
468 :
469 : bool mbBevelButton:1;
470 : bool mbSingleLine:1;
471 : };
472 :
473 :
474 : #endif
475 :
476 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|