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 INCLUDED_VCL_SALNATIVEWIDGETS_HXX
21 #define INCLUDED_VCL_SALNATIVEWIDGETS_HXX
23 #include <vcl/dllapi.h>
24 #include <tools/gen.hxx>
25 #include <o3tl/typed_flags_set.hxx>
29 * Specify the overall, whole control
30 * type (as opposed to parts of the
31 * control if it were composite).
34 enum class ControlType
{
35 // for use in general purpose ImplControlValue
37 // Normal PushButton/Command Button
39 // Normal single radio button
41 // Normal single checkbox
43 // Combobox, i.e. a ListBox
44 // that allows data entry by user
46 // Control that allows text entry
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
53 // Control that allows text entry
54 // ( some systems distinguish between single and multi line edit boxes )
55 MultilineEditbox
= 32,
56 // Control that pops up a menu,
57 // but does NOT allow data entry
59 // An edit field together with two little
60 // buttons on the side (aka spin field)
62 // Two standalone spin buttons
63 // without an edit field
67 // The border around a tab area,
68 // but without the tabs themselves.
69 // May have a gap at the top for
72 // The background to the tab area
74 // Background of a Tab Pane
76 // Normal scrollbar, including
77 // all parts like slider, buttons
82 // A toolbar control with buttons and a grip
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/)
98 // to draw the implemented theme
99 WindowBackground
= 150,
100 //to draw border of frames natively
102 // for nodes in listviews
103 // used in svtools/source/contnr/svtreebx.cxx
105 // nets between elements of listviews
115 * Uniquely identify a part of a control,
116 * for example the slider of a scroll bar.
119 enum class ControlPart
123 ListboxWindow
= 5, // the static listbox window containing the list
126 ButtonDown
= 102, // Also for ComboBoxes/ListBoxes
133 TrackVertUpper
= 201,
134 TrackHorzRight
= 202,
135 TrackVertLower
= 203,
139 ThumbHorz
= 210, // Also used as toolbar grip
140 ThumbVert
= 211, // Also used as toolbar grip
142 MenuItemCheckMark
= 251,
143 MenuItemRadioMark
= 252,
148 HACK: for scrollbars in case of thumb rect, page up and page down rect we
149 abuse the HitTestNativeScrollbar interface. All theming engines but aqua
150 are actually able to draw the thumb according to our internal representation.
151 However aqua draws a little outside. The canonical way would be to enhance the
152 HitTestNativeScrollbar passing a ScrollbarValue additionally so all necessary
153 information is available in the call.
155 However since there is only this one small exception we will deviate a little and
156 instead pass the respective rect as control region to allow for a small correction.
158 So all places using HitTestNativeScrollbar on ControlPart::ThumbHorz, ControlPart::ThumbVert,
159 ControlPart::TrackHorzLeft, ControlPart::TrackHorzRight, ControlPart::TrackVertUpper, ControlPart::TrackVertLower
160 do not use the control rectangle as region but the actual part rectangle, making
161 only small deviations feasible.
164 /** The edit field part of a control, e.g. of the combo box.
166 Currently used just for combo boxes and just for GetNativeControlRegion().
167 It is valid only if GetNativeControlRegion() supports ControlPart::ButtonDown as
172 // For controls that require the entire background
173 // to be drawn first, and then other pieces over top.
174 // (GTK+ scrollbars for example). Control region passed
175 // in to draw this part is expected to be the entire
176 // area of the control.
177 // A control may respond to one or both.
178 DrawBackgroundHorz
= 1000,
179 DrawBackgroundVert
= 1001,
181 // GTK+ also draws tabs right->left since there is a
182 // hardcoded 2 pixel overlap between adjacent tabs
185 // Qt doesn't have a separate header to draw
186 TabPaneWithHeader
= 3001,
188 // For themes that do not want to have the focus
189 // rectangle part drawn by VCL but take care of the
190 // whole inner control part by themselves
191 // eg, listboxes or comboboxes or spinbuttons
192 HasBackgroundTexture
= 4000,
194 // For scrollbars that have 3 buttons (most KDE themes)
195 HasThreeButtons
= 5000,
197 BackgroundWindow
= 6000,
198 BackgroundDialog
= 6001,
200 //to draw natively the border of frames
203 //to draw natively the focus rects
209 * Specify how a particular part of the control
210 * is to be drawn. Constants are bitwise OR-ed
211 * together to compose a final drawing state.
212 * A _disabled_ state is assumed by the drawing
213 * functions until an ENABLED or HIDDEN is passed
214 * in the ControlState.
216 enum class ControlState
{
227 template<> struct typed_flags
<ControlState
> : is_typed_flags
<ControlState
, 0x006f> {};
232 * Identifies the tri-state value options
236 enum class ButtonValue
{
245 * Generic value container for all control parts.
248 class VCL_DLLPUBLIC ImplControlValue
250 friend class SalFrame
;
254 ButtonValue mTristate
; // Tristate value: on, off, mixed
255 tools::Long mNumber
; // numeric value
257 ImplControlValue( ControlType i_eType
, tools::Long i_nNumber
)
259 , mTristate( ButtonValue::DontKnow
)
260 , mNumber( i_nNumber
)
264 explicit ImplControlValue( ButtonValue nTristate
)
265 : mType( ControlType::Generic
), mTristate(nTristate
), mNumber(0) {}
266 explicit ImplControlValue( tools::Long nNumeric
)
267 : mType( ControlType::Generic
), mTristate(ButtonValue::DontKnow
), mNumber( nNumeric
) {}
269 : mType( ControlType::Generic
), mTristate(ButtonValue::DontKnow
), mNumber(0) {}
271 virtual ~ImplControlValue();
273 ImplControlValue(ImplControlValue
const &) = default;
274 ImplControlValue(ImplControlValue
&&) = default;
275 ImplControlValue
& operator =(ImplControlValue
const &) = delete; // due to const mType
276 ImplControlValue
& operator =(ImplControlValue
&&) = delete; // due to const mType
278 virtual ImplControlValue
* clone() const;
280 ControlType
getType() const { return mType
; }
282 ButtonValue
getTristateVal() const { return mTristate
; }
283 void setTristateVal( ButtonValue nTristate
) { mTristate
= nTristate
; }
285 tools::Long
getNumericVal() const { return mNumber
; }
286 void setNumericVal( tools::Long nNumeric
) { mNumber
= nNumeric
; }
291 * Value container for scrollbars.
293 class SAL_DLLPUBLIC_RTTI ScrollbarValue final
: public ImplControlValue
299 tools::Long mnVisibleSize
;
300 tools::Rectangle maThumbRect
;
301 tools::Rectangle maButton1Rect
;
302 tools::Rectangle maButton2Rect
;
303 ControlState mnButton1State
;
304 ControlState mnButton2State
;
305 ControlState mnThumbState
;
308 : ImplControlValue( ControlType::Scrollbar
, 0 )
310 mnMin
= 0; mnMax
= 0; mnCur
= 0; mnVisibleSize
= 0;
311 mnButton1State
= ControlState::NONE
; mnButton2State
= ControlState::NONE
;
312 mnThumbState
= ControlState::NONE
;
314 virtual ~ScrollbarValue() override
;
315 virtual ScrollbarValue
* clone() const override
;
317 ScrollbarValue(ScrollbarValue
const &) = default;
318 ScrollbarValue(ScrollbarValue
&&) = default;
319 ScrollbarValue
& operator =(ScrollbarValue
const &) = delete; // due to ImplControlValue
320 ScrollbarValue
& operator =(ScrollbarValue
&&) = delete; // due to ImplControlValue
323 class SAL_DLLPUBLIC_RTTI SliderValue final
: public ImplControlValue
329 tools::Rectangle maThumbRect
;
330 ControlState mnThumbState
;
333 : ImplControlValue( ControlType::Slider
, 0 )
334 , mnMin( 0 ), mnMax( 0 ), mnCur( 0 ), mnThumbState( ControlState::NONE
)
336 virtual ~SliderValue() override
;
337 virtual SliderValue
* clone() const override
;
339 SliderValue(SliderValue
const &) = default;
340 SliderValue(SliderValue
&&) = default;
341 SliderValue
& operator =(SliderValue
const &) = delete; // due to ImplControlValue
342 SliderValue
& operator =(SliderValue
&&) = delete; // due to ImplControlValue
345 class VCL_DLLPUBLIC TabPaneValue final
: public ImplControlValue
348 tools::Rectangle m_aTabHeaderRect
;
349 tools::Rectangle m_aSelectedTabRect
;
350 // increased tab size, so it'll overlab the frame rect when drawing
351 // static value, as there is currently no sane way to return additional data
352 static int m_nOverlap
;
354 TabPaneValue(const tools::Rectangle
&rTabHeaderRect
, const tools::Rectangle
&rSelectedTabRect
)
355 : ImplControlValue(ControlType::TabPane
, 0)
356 , m_aTabHeaderRect(rTabHeaderRect
)
357 , m_aSelectedTabRect(rSelectedTabRect
)
360 TabPaneValue
* clone() const override
;
362 TabPaneValue(TabPaneValue
const &) = default;
363 TabPaneValue(TabPaneValue
&&) = default;
364 TabPaneValue
& operator =(TabPaneValue
const &) = delete;
365 TabPaneValue
& operator =(TabPaneValue
&&) = delete;
370 * Value container for tabitems.
373 /* TABITEM constants are OR-ed together */
374 enum class TabitemFlags
377 LeftAligned
= 0x01, // the tabitem is aligned with the left border of the TabControl
378 RightAligned
= 0x02, // the tabitem is aligned with the right border of the TabControl
379 FirstInGroup
= 0x04, // the tabitem is the first in group of tabitems
380 LastInGroup
= 0x08, // the tabitem is the last in group of tabitems
384 template<> struct typed_flags
<TabitemFlags
> : is_typed_flags
<TabitemFlags
, 0x0f> {};
387 /* Tab bar position (relative to content on the tab page). */
388 enum class TabBarPosition
396 class SAL_DLLPUBLIC_RTTI TabitemValue final
: public ImplControlValue
399 TabitemFlags mnAlignment
;
400 tools::Rectangle maContentRect
;
401 TabBarPosition meTabBarPosition
;
403 TabitemValue(const tools::Rectangle
&rContentRect
, TabBarPosition eTabBarPosition
)
404 : ImplControlValue( ControlType::TabItem
, 0 )
405 , mnAlignment(TabitemFlags::NONE
)
406 , maContentRect(rContentRect
)
407 , meTabBarPosition(eTabBarPosition
)
410 virtual ~TabitemValue() override
;
411 virtual TabitemValue
* clone() const override
;
413 TabitemValue(TabitemValue
const &) = default;
414 TabitemValue(TabitemValue
&&) = default;
415 TabitemValue
& operator =(TabitemValue
const &) = delete; // due to ImplControlValue
416 TabitemValue
& operator =(TabitemValue
&&) = delete; // due to ImplControlValue
418 bool isLeftAligned() const { return bool(mnAlignment
& TabitemFlags::LeftAligned
); }
419 bool isRightAligned() const { return bool(mnAlignment
& TabitemFlags::RightAligned
); }
420 bool isBothAligned() const { return isLeftAligned() && isRightAligned(); }
421 bool isNotAligned() const { return !(mnAlignment
& (TabitemFlags::LeftAligned
| TabitemFlags::RightAligned
)); }
422 bool isFirst() const { return bool(mnAlignment
& TabitemFlags::FirstInGroup
); }
423 bool isLast() const { return bool(mnAlignment
& TabitemFlags::LastInGroup
); }
424 const tools::Rectangle
& getContentRect() const { return maContentRect
; }
429 * Value container for spinbuttons to paint both buttons at once.
430 * Note: the other parameters of DrawNativeControl will have no meaning
431 * all parameters for spinbuttons are carried here
433 class SAL_DLLPUBLIC_RTTI SpinbuttonValue final
: public ImplControlValue
436 tools::Rectangle maUpperRect
;
437 tools::Rectangle maLowerRect
;
438 ControlState mnUpperState
;
439 ControlState mnLowerState
;
440 ControlPart mnUpperPart
;
441 ControlPart mnLowerPart
;
444 : ImplControlValue( ControlType::SpinButtons
, 0 )
445 , mnUpperState(ControlState::NONE
)
446 , mnLowerState(ControlState::NONE
)
447 , mnUpperPart(ControlPart::NONE
)
448 , mnLowerPart(ControlPart::NONE
)
452 virtual ~SpinbuttonValue() override
;
453 virtual SpinbuttonValue
* clone() const override
;
455 SpinbuttonValue(SpinbuttonValue
const &) = default;
456 SpinbuttonValue(SpinbuttonValue
&&) = default;
457 SpinbuttonValue
& operator =(SpinbuttonValue
const &) = delete; // due to ImplControlValue
458 SpinbuttonValue
& operator =(SpinbuttonValue
&&) = delete; // due to ImplControlValue
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.
466 class SAL_DLLPUBLIC_RTTI MenupopupValue final
: public ImplControlValue
469 MenupopupValue( tools::Long i_nGutterWidth
, const tools::Rectangle
& i_rItemRect
)
470 : ImplControlValue( ControlType::MenuPopup
, i_nGutterWidth
)
471 , maItemRect( i_rItemRect
)
473 virtual ~MenupopupValue() override
;
474 virtual MenupopupValue
* clone() const override
;
475 MenupopupValue(MenupopupValue
const &) = default;
476 MenupopupValue(MenupopupValue
&&) = default;
477 MenupopupValue
& operator =(MenupopupValue
const &) = delete; // due to ImplControlValue
478 MenupopupValue
& operator =(MenupopupValue
&&) = delete; // due to ImplControlValue
479 tools::Rectangle maItemRect
;
484 * Value container for pushbuttons specifying additional drawing hints
486 class VCL_DLLPUBLIC PushButtonValue final
: public ImplControlValue
490 : ImplControlValue( ControlType::Pushbutton
, 0 )
493 , m_bFlatButton(false)
496 virtual ~PushButtonValue() override
;
497 virtual PushButtonValue
* clone() const override
;
499 PushButtonValue(PushButtonValue
const &) = default;
500 PushButtonValue(PushButtonValue
&&) = default;
501 PushButtonValue
& operator =(PushButtonValue
const &) = delete; // due to ImplControlValue
502 PushButtonValue
& operator =(PushButtonValue
&&) = delete; // due to ImplControlValue
504 bool mbSingleLine
:1; // only used on OSX
506 bool m_bFlatButton
:1;
512 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */