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