LibreOffice Module vcl (master) 1
salnativewidgets.hxx
Go to the documentation of this file.
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 <vcl/dllapi.h>
24#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
34enum class ControlType {
35// for use in general purpose ImplControlValue
36 Generic = 0,
37// Normal PushButton/Command Button
38 Pushbutton = 1,
39// Normal single radio button
40 Radiobutton = 2,
41// Normal single checkbox
42 Checkbox = 10,
43// Combobox, i.e. a ListBox
44// that allows data entry by user
45 Combobox = 20,
46// Control that allows text entry
47 Editbox = 30,
48// Control that allows text entry, but without the usual border
49// Has to be handled separately, because this one cannot handle
50// ControlPart::HasBackgroundTexture, which is drawn in the edit box'es
51// border window.
52 EditboxNoBorder = 31,
53// Control that allows text entry
54// ( some systems distinguish between single and multi line edit boxes )
56// Control that pops up a menu,
57// but does NOT allow data entry
58 Listbox = 35,
59// An edit field together with two little
60// buttons on the side (aka spin field)
61 Spinbox = 40,
62// Two standalone spin buttons
63// without an edit field
64 SpinButtons = 45,
65// A single tab
66 TabItem = 50,
67// The border around a tab area,
68// but without the tabs themselves.
69// May have a gap at the top for
70// the active tab
71 TabPane = 55,
72// The background to the tab area
73 TabHeader = 56,
74// Background of a Tab Pane
75 TabBody = 57,
76// Normal scrollbar, including
77// all parts like slider, buttons
78 Scrollbar = 60,
79 Slider = 65,
80// A separator line
81 Fixedline = 80,
82// A toolbar control with buttons and a grip
83 Toolbar = 100,
84// The menubar
85 Menubar = 120,
86// popup menu
87 MenuPopup = 121,
88 Progress = 131,
89// Progress bar for the intro window
90// (aka splash screen), in case some
91// wants native progress bar in the
92// application but not for the splash
93// screen (used in desktop/)
94 IntroProgress = 132,
95// tool tips
96 Tooltip = 140,
97// to draw the implemented theme
98 WindowBackground = 150,
99//to draw border of frames natively
100 Frame = 160,
101// for nodes in listviews
102// used in svtools/source/contnr/svtreebx.cxx
103 ListNode = 170,
104// nets between elements of listviews
105// with nodes
106 ListNet = 171,
107// for list headers
108 ListHeader = 172,
109};
110
111
112/* Control Parts:
113 *
114 * Uniquely identify a part of a control,
115 * for example the slider of a scroll bar.
116 */
117
118enum class ControlPart
119{
120 NONE = 0,
121 Entire = 1,
122 ListboxWindow = 5, // the static listbox window containing the list
123 Button = 100,
124 ButtonUp = 101,
125 ButtonDown = 102, // Also for ComboBoxes/ListBoxes
126 ButtonLeft = 103,
127 ButtonRight = 104,
128 AllButtons = 105,
129 SeparatorHorz = 106,
130 SeparatorVert = 107,
131 TrackHorzLeft = 200,
132 TrackVertUpper = 201,
133 TrackHorzRight = 202,
134 TrackVertLower = 203,
135 TrackHorzArea = 204,
136 TrackVertArea = 205,
137 Arrow = 220,
138 ThumbHorz = 210, // Also used as toolbar grip
139 ThumbVert = 211, // Also used as toolbar grip
140 MenuItem = 250,
141 MenuItemCheckMark = 251,
142 MenuItemRadioMark = 252,
143 Separator = 253,
144 SubmenuArrow = 254,
145
146/* #i77549#
147 HACK: for scrollbars in case of thumb rect, page up and page down rect we
148 abuse the HitTestNativeScrollbar interface. All theming engines but aqua
149 are actually able to draw the thumb according to our internal representation.
150 However aqua draws a little outside. The canonical way would be to enhance the
151 HitTestNativeScrollbar passing a ScrollbarValue additionally so all necessary
152 information is available in the call.
153 .
154 However since there is only this one small exception we will deviate a little and
155 instead pass the respective rect as control region to allow for a small correction.
156
157 So all places using HitTestNativeScrollbar on ControlPart::ThumbHorz, ControlPart::ThumbVert,
158 ControlPart::TrackHorzLeft, ControlPart::TrackHorzRight, ControlPart::TrackVertUpper, ControlPart::TrackVertLower
159 do not use the control rectangle as region but the actual part rectangle, making
160 only small deviations feasible.
161*/
162
169 SubEdit = 300,
170
171// For controls that require the entire background
172// to be drawn first, and then other pieces over top.
173// (GTK+ scrollbars for example). Control region passed
174// in to draw this part is expected to be the entire
175// area of the control.
176// A control may respond to one or both.
177 DrawBackgroundHorz = 1000,
178 DrawBackgroundVert = 1001,
179
180// GTK+ also draws tabs right->left since there is a
181// hardcoded 2 pixel overlap between adjacent tabs
182 TabsDrawRtl = 3000,
183
184// Qt doesn't have a separate header to draw
185 TabPaneWithHeader = 3001,
186
187// For themes that do not want to have the focus
188// rectangle part drawn by VCL but take care of the
189// whole inner control part by themselves
190// eg, listboxes or comboboxes or spinbuttons
192
193// For scrollbars that have 3 buttons (most KDE themes)
194 HasThreeButtons = 5000,
195
196 BackgroundWindow = 6000,
197 BackgroundDialog = 6001,
198
199//to draw natively the border of frames
200 Border = 7000,
201
202//to draw natively the focus rects
203 Focus = 8000
204};
205
206/* Control State:
207 *
208 * Specify how a particular part of the control
209 * is to be drawn. Constants are bitwise OR-ed
210 * together to compose a final drawing state.
211 * A _disabled_ state is assumed by the drawing
212 * functions until an ENABLED or HIDDEN is passed
213 * in the ControlState.
214 */
215enum class ControlState {
216 NONE = 0,
217 ENABLED = 0x0001,
218 FOCUSED = 0x0002,
219 PRESSED = 0x0004,
220 ROLLOVER = 0x0008,
221 DEFAULT = 0x0020,
222 SELECTED = 0x0040
223};
224namespace o3tl
225{
226 template<> struct typed_flags<ControlState> : is_typed_flags<ControlState, 0x006f> {};
227}
228
229/* ButtonValue:
230 *
231 * Identifies the tri-state value options
232 * that buttons allow
233 */
234
235enum class ButtonValue {
236 DontKnow,
237 On,
238 Off,
239 Mixed
240};
241
242/* ImplControlValue:
243 *
244 * Generic value container for all control parts.
245 */
246
248{
249 friend class SalFrame;
250
251 private:
253 ButtonValue mTristate; // Tristate value: on, off, mixed
254 tools::Long mNumber; // numeric value
255 protected:
257 : mType( i_eType )
258 , mTristate( ButtonValue::DontKnow )
259 , mNumber( i_nNumber )
260 {}
261
262 public:
263 explicit ImplControlValue( ButtonValue nTristate )
264 : mType( ControlType::Generic ), mTristate(nTristate), mNumber(0) {}
265 explicit ImplControlValue( tools::Long nNumeric )
266 : mType( ControlType::Generic ), mTristate(ButtonValue::DontKnow), mNumber( nNumeric) {}
268 : mType( ControlType::Generic ), mTristate(ButtonValue::DontKnow), mNumber(0) {}
269
270 virtual ~ImplControlValue();
271
274 ImplControlValue & operator =(ImplControlValue const &) = delete; // due to const mType
275 ImplControlValue & operator =(ImplControlValue &&) = delete; // due to const mType
276
277 virtual ImplControlValue* clone() const;
278
279 ControlType getType() const { return mType; }
280
281 ButtonValue getTristateVal() const { return mTristate; }
282 void setTristateVal( ButtonValue nTristate ) { mTristate = nTristate; }
283
284 tools::Long getNumericVal() const { return mNumber; }
285 void setNumericVal( tools::Long nNumeric ) { mNumber = nNumeric; }
286};
287
288/* ScrollbarValue:
289 *
290 * Value container for scrollbars.
291 */
292class SAL_DLLPUBLIC_RTTI ScrollbarValue final : public ImplControlValue
293{
294 public:
305
308 {
309 mnMin = 0; mnMax = 0; mnCur = 0; mnVisibleSize = 0;
310 mnButton1State = ControlState::NONE; mnButton2State = ControlState::NONE;
311 mnThumbState = ControlState::NONE;
312 };
313 virtual ~ScrollbarValue() override;
314 virtual ScrollbarValue* clone() const override;
315
316 ScrollbarValue(ScrollbarValue const &) = default;
318 ScrollbarValue & operator =(ScrollbarValue const &) = delete; // due to ImplControlValue
319 ScrollbarValue & operator =(ScrollbarValue &&) = delete; // due to ImplControlValue
320};
321
322class SAL_DLLPUBLIC_RTTI SliderValue final : public ImplControlValue
323{
324 public:
330
333 , mnMin( 0 ), mnMax( 0 ), mnCur( 0 ), mnThumbState( ControlState::NONE )
334 {}
335 virtual ~SliderValue() override;
336 virtual SliderValue* clone() const override;
337
338 SliderValue(SliderValue const &) = default;
340 SliderValue & operator =(SliderValue const &) = delete; // due to ImplControlValue
341 SliderValue & operator =(SliderValue &&) = delete; // due to ImplControlValue
342};
343
345{
346public:
349 // increased tab size, so it'll overlab the frame rect when drawing
350 // static value, as there is currently no sane way to return additional data
351 static int m_nOverlap;
352
353 TabPaneValue(const tools::Rectangle &rTabHeaderRect, const tools::Rectangle &rSelectedTabRect)
355 , m_aTabHeaderRect(rTabHeaderRect)
356 , m_aSelectedTabRect(rSelectedTabRect)
357 {
358 }
359 TabPaneValue* clone() const override;
360
361 TabPaneValue(TabPaneValue const &) = default;
363 TabPaneValue & operator =(TabPaneValue const &) = delete;
364 TabPaneValue & operator =(TabPaneValue &&) = delete;
365};
366
367/* TabitemValue:
368 *
369 * Value container for tabitems.
370 */
371
372/* TABITEM constants are OR-ed together */
373enum class TabitemFlags
374{
375 NONE = 0x00,
376 LeftAligned = 0x01, // the tabitem is aligned with the left border of the TabControl
377 RightAligned = 0x02, // the tabitem is aligned with the right border of the TabControl
378 FirstInGroup = 0x04, // the tabitem is the first in group of tabitems
379 LastInGroup = 0x08, // the tabitem is the last in group of tabitems
380};
381namespace o3tl
382{
383 template<> struct typed_flags<TabitemFlags> : is_typed_flags<TabitemFlags, 0x0f> {};
384}
385
386class SAL_DLLPUBLIC_RTTI TabitemValue final : public ImplControlValue
387{
388 public:
391
392 TabitemValue(const tools::Rectangle &rContentRect)
394 , mnAlignment(TabitemFlags::NONE)
395 , maContentRect(rContentRect)
396 {
397 }
398 virtual ~TabitemValue() override;
399 virtual TabitemValue* clone() const override;
400
401 TabitemValue(TabitemValue const &) = default;
403 TabitemValue & operator =(TabitemValue const &) = delete; // due to ImplControlValue
404 TabitemValue & operator =(TabitemValue &&) = delete; // due to ImplControlValue
405
406 bool isLeftAligned() const { return bool(mnAlignment & TabitemFlags::LeftAligned); }
407 bool isRightAligned() const { return bool(mnAlignment & TabitemFlags::RightAligned); }
408 bool isBothAligned() const { return isLeftAligned() && isRightAligned(); }
409 bool isNotAligned() const { return !(mnAlignment & (TabitemFlags::LeftAligned | TabitemFlags::RightAligned)); }
410 bool isFirst() const { return bool(mnAlignment & TabitemFlags::FirstInGroup); }
411 bool isLast() const { return bool(mnAlignment & TabitemFlags::LastInGroup); }
412 const tools::Rectangle& getContentRect() const { return maContentRect; }
413};
414
415/* SpinbuttonValue:
416 *
417 * Value container for spinbuttons to paint both buttons at once.
418 * Note: the other parameters of DrawNativeControl will have no meaning
419 * all parameters for spinbuttons are carried here
420 */
421class SAL_DLLPUBLIC_RTTI SpinbuttonValue final : public ImplControlValue
422{
423 public:
430
433 , mnUpperState(ControlState::NONE)
434 , mnLowerState(ControlState::NONE)
435 , mnUpperPart(ControlPart::NONE)
436 , mnLowerPart(ControlPart::NONE)
437 {
438 }
439
440 virtual ~SpinbuttonValue() override;
441 virtual SpinbuttonValue* clone() const override;
442
445 SpinbuttonValue & operator =(SpinbuttonValue const &) = delete; // due to ImplControlValue
446 SpinbuttonValue & operator =(SpinbuttonValue &&) = delete; // due to ImplControlValue
447};
448
449/* MenupopupValue:
450 *
451 * Value container for menu items; specifies the rectangle for the whole item which
452 * may be useful when drawing parts with a smaller rectangle.
453 */
454class SAL_DLLPUBLIC_RTTI MenupopupValue final : public ImplControlValue
455{
456public:
457 MenupopupValue( tools::Long i_nGutterWidth, const tools::Rectangle& i_rItemRect )
458 : ImplControlValue( ControlType::MenuPopup, i_nGutterWidth )
459 , maItemRect( i_rItemRect )
460 {}
461 virtual ~MenupopupValue() override;
462 virtual MenupopupValue* clone() const override;
463 MenupopupValue(MenupopupValue const &) = default;
465 MenupopupValue & operator =(MenupopupValue const &) = delete; // due to ImplControlValue
466 MenupopupValue & operator =(MenupopupValue &&) = delete; // due to ImplControlValue
468};
469
470/* PushButtonValue:
471 *
472 * Value container for pushbuttons specifying additional drawing hints
473 */
475{
476public:
479 , mbSingleLine(true)
480 , mbIsAction(false)
481 , m_bFlatButton(false)
482 {}
483
484 virtual ~PushButtonValue() override;
485 virtual PushButtonValue* clone() const override;
486
489 PushButtonValue & operator =(PushButtonValue const &) = delete; // due to ImplControlValue
490 PushButtonValue & operator =(PushButtonValue &&) = delete; // due to ImplControlValue
491
492 bool mbSingleLine:1; // only used on OSX
495};
496
497
498#endif
499
500/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@ SubEdit
The edit field part of a control, e.g.
@ HasBackgroundTexture
ControlType
These types are all based on the supported variants vcl/salnativewidgets.hxx and must be kept in-sync...
void setNumericVal(tools::Long nNumeric)
ButtonValue getTristateVal() const
ControlType getType() const
virtual ImplControlValue * clone() const
tools::Long getNumericVal() const
ImplControlValue(tools::Long nNumeric)
ImplControlValue(ButtonValue nTristate)
void setTristateVal(ButtonValue nTristate)
ImplControlValue(ControlType i_eType, tools::Long i_nNumber)
ImplControlValue & operator=(ImplControlValue const &)=delete
ImplControlValue(ImplControlValue &&)=default
ImplControlValue(ImplControlValue const &)=default
MenupopupValue(tools::Long i_nGutterWidth, const tools::Rectangle &i_rItemRect)
MenupopupValue(MenupopupValue &&)=default
tools::Rectangle maItemRect
MenupopupValue(MenupopupValue const &)=default
PushButtonValue(PushButtonValue &&)=default
PushButtonValue(PushButtonValue const &)=default
A SalFrame is a system window (e.g. an X11 window).
Definition: salframe.hxx:115
ControlState mnButton1State
tools::Rectangle maThumbRect
tools::Rectangle maButton1Rect
ControlState mnThumbState
tools::Long mnVisibleSize
ScrollbarValue(ScrollbarValue const &)=default
ControlState mnButton2State
ScrollbarValue(ScrollbarValue &&)=default
tools::Rectangle maButton2Rect
tools::Long mnCur
SliderValue(SliderValue &&)=default
tools::Rectangle maThumbRect
tools::Long mnMax
ControlState mnThumbState
tools::Long mnMin
SliderValue(SliderValue const &)=default
SpinbuttonValue(SpinbuttonValue const &)=default
tools::Rectangle maLowerRect
ControlPart mnLowerPart
tools::Rectangle maUpperRect
ControlState mnUpperState
ControlState mnLowerState
ControlPart mnUpperPart
SpinbuttonValue(SpinbuttonValue &&)=default
TabPaneValue(TabPaneValue &&)=default
static int m_nOverlap
tools::Rectangle m_aTabHeaderRect
TabPaneValue(const tools::Rectangle &rTabHeaderRect, const tools::Rectangle &rSelectedTabRect)
TabPaneValue(TabPaneValue const &)=default
tools::Rectangle m_aSelectedTabRect
TabitemValue(TabitemValue &&)=default
bool isNotAligned() const
bool isLast() const
bool isRightAligned() const
TabitemFlags mnAlignment
bool isBothAligned() const
tools::Rectangle maContentRect
bool isFirst() const
const tools::Rectangle & getContentRect() const
TabitemValue(const tools::Rectangle &rContentRect)
TabitemValue(TabitemValue const &)=default
bool isLeftAligned() const
T * clone(T *const other)
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
NONE
long Long
TabitemFlags