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 <rtl/ustring.hxx>
24 #include <vcl/dllapi.h>
25 #include <tools/gen.hxx>
26 #include <o3tl/typed_flags_set.hxx>
30 * Specify the overall, whole control
31 * type (as opposed to parts of the
32 * control if it were composite).
35 enum class ControlType
{
36 // for use in general purpose ImplControlValue
38 // Normal PushButton/Command Button
40 // Normal single radio button
42 // Normal single checkbox
44 // Combobox, i.e. a ListBox
45 // that allows data entry by user
47 // Control that allows text entry
49 // Control that allows text entry, but without the usual border
50 // Has to be handled separately, because this one cannot handle
51 // ControlPart::HasBackgroundTexture, which is drawn in the edit box'es
54 // Control that allows text entry
55 // ( some systems distinguish between single and multi line edit boxes )
56 MultilineEditbox
= 32,
57 // Control that pops up a menu,
58 // but does NOT allow data entry
60 // An edit field together with two little
61 // buttons on the side (aka spin field)
63 // Two standalone spin buttons
64 // without an edit field
68 // The border around a tab area,
69 // but without the tabs themselves.
70 // May have a gap at the top for
73 // The background to the tab area
75 // Background of a Tab Pane
77 // Normal scrollbar, including
78 // all parts like slider, buttons
83 // A toolbar control with buttons and a grip
90 // Progress bar for the intro window
91 // (aka splash screen), in case some
92 // wants native progress bar in the
93 // application but not for the splash
94 // 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 actuall 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 // For themes that do not want to have the focus
186 // rectangle part drawn by VCL but take care of the
187 // whole inner control part by themselves
188 // eg, listboxes or comboboxes or spinbuttons
189 HasBackgroundTexture
= 4000,
191 // For scrollbars that have 3 buttons (most KDE themes)
192 HasThreeButtons
= 5000,
194 BackgroundWindow
= 6000,
195 BackgroundDialog
= 6001,
197 //to draw natively the border of frames
200 //to draw natively the focus rects
206 * Specify how a particular part of the control
207 * is to be drawn. Constants are bitwise OR-ed
208 * together to compose a final drawing state.
209 * A _disabled_ state is assumed by the drawing
210 * functions until an ENABLED or HIDDEN is passed
211 * in the ControlState.
213 enum class ControlState
{
221 DOUBLEBUFFERING
= 0x4000, ///< Set when the control is painted using double-buffering via VirtualDevice.
222 CACHING_ALLOWED
= 0x8000, ///< Set when the control is completely visible (i.e. not clipped).
226 template<> struct typed_flags
<ControlState
> : is_typed_flags
<ControlState
, 0xc06f> {};
231 * Identifies the tri-state value options
235 enum class ButtonValue
{
244 * Generic value container for all control parts.
247 class VCL_DLLPUBLIC ImplControlValue
249 friend class SalFrame
;
253 ButtonValue mTristate
; // Tristate value: on, off, mixed
254 long mNumber
; // numeric value
256 ImplControlValue( ControlType i_eType
, long i_nNumber
)
258 , mTristate( ButtonValue::DontKnow
)
259 , mNumber( i_nNumber
)
263 explicit ImplControlValue( ButtonValue nTristate
)
264 : mType( ControlType::Generic
), mTristate(nTristate
), mNumber(0) {}
265 explicit ImplControlValue( long nNumeric
)
266 : mType( ControlType::Generic
), mTristate(ButtonValue::DontKnow
), mNumber( nNumeric
) {}
268 : mType( ControlType::Generic
), mTristate(ButtonValue::DontKnow
), mNumber(0) {}
270 virtual ~ImplControlValue();
272 virtual ImplControlValue
* clone() const;
274 ControlType
getType() const { return mType
; }
276 ButtonValue
getTristateVal() const { return mTristate
; }
277 void setTristateVal( ButtonValue nTristate
) { mTristate
= nTristate
; }
279 long getNumericVal() const { return mNumber
; }
280 void setNumericVal( long nNumeric
) { mNumber
= nNumeric
; }
285 * Value container for scrollbars.
287 class VCL_DLLPUBLIC ScrollbarValue
: public ImplControlValue
294 tools::Rectangle maThumbRect
;
295 tools::Rectangle maButton1Rect
;
296 tools::Rectangle maButton2Rect
;
297 ControlState mnButton1State
;
298 ControlState mnButton2State
;
299 ControlState mnThumbState
;
300 ControlState mnPage1State
;
301 ControlState mnPage2State
;
304 : ImplControlValue( ControlType::Scrollbar
, 0 )
306 mnMin
= 0; mnMax
= 0; mnCur
= 0; mnVisibleSize
= 0;
307 mnButton1State
= ControlState::NONE
; mnButton2State
= ControlState::NONE
;
308 mnThumbState
= ControlState::NONE
; mnPage1State
= ControlState::NONE
; mnPage2State
= ControlState::NONE
;
310 virtual ~ScrollbarValue() override
;
311 virtual ScrollbarValue
* clone() const override
;
314 class VCL_DLLPUBLIC SliderValue
: public ImplControlValue
320 tools::Rectangle maThumbRect
;
321 ControlState mnThumbState
;
324 : ImplControlValue( ControlType::Slider
, 0 )
325 , mnMin( 0 ), mnMax( 0 ), mnCur( 0 ), mnThumbState( ControlState::NONE
)
327 virtual ~SliderValue() override
;
328 virtual SliderValue
* clone() const override
;
333 * Value container for tabitems.
336 /* TABITEM constants are OR-ed together */
337 enum class TabitemFlags
340 LeftAligned
= 0x01, // the tabitem is aligned with the left border of the TabControl
341 RightAligned
= 0x02, // the tabitem is aligned with the right border of the TabControl
342 FirstInGroup
= 0x04, // the tabitem is the first in group of tabitems
343 LastInGroup
= 0x08, // the tabitem is the last in group of tabitems
347 template<> struct typed_flags
<TabitemFlags
> : is_typed_flags
<TabitemFlags
, 0x0f> {};
350 class VCL_DLLPUBLIC TabitemValue
: public ImplControlValue
353 TabitemFlags mnAlignment
;
354 tools::Rectangle maContentRect
;
356 TabitemValue(const tools::Rectangle
&rContentRect
)
357 : ImplControlValue( ControlType::TabItem
, 0 )
358 , mnAlignment(TabitemFlags::NONE
)
359 , maContentRect(rContentRect
)
362 virtual ~TabitemValue() override
;
363 virtual TabitemValue
* clone() const override
;
365 bool isLeftAligned() const { return bool(mnAlignment
& TabitemFlags::LeftAligned
); }
366 bool isRightAligned() const { return bool(mnAlignment
& TabitemFlags::RightAligned
); }
367 bool isBothAligned() const { return isLeftAligned() && isRightAligned(); }
368 bool isNotAligned() const { return !(mnAlignment
& (TabitemFlags::LeftAligned
| TabitemFlags::RightAligned
)); }
369 bool isFirst() const { return bool(mnAlignment
& TabitemFlags::FirstInGroup
); }
370 bool isLast() const { return bool(mnAlignment
& TabitemFlags::LastInGroup
); }
371 const tools::Rectangle
& getContentRect() const { return maContentRect
; }
376 * Value container for spinbuttons to paint both buttons at once.
377 * Note: the other parameters of DrawNativeControl will have no meaning
378 * all parameters for spinbuttons are carried here
380 class VCL_DLLPUBLIC SpinbuttonValue
: public ImplControlValue
383 tools::Rectangle maUpperRect
;
384 tools::Rectangle maLowerRect
;
385 ControlState mnUpperState
;
386 ControlState mnLowerState
;
387 ControlPart mnUpperPart
;
388 ControlPart mnLowerPart
;
391 : ImplControlValue( ControlType::SpinButtons
, 0 )
392 , mnUpperState(ControlState::NONE
)
393 , mnLowerState(ControlState::NONE
)
394 , mnUpperPart(ControlPart::NONE
)
395 , mnLowerPart(ControlPart::NONE
)
399 virtual ~SpinbuttonValue() override
;
400 virtual SpinbuttonValue
* clone() const override
;
405 * Value container for toolbars detailing the grip position
407 class VCL_DLLPUBLIC ToolbarValue
: public ImplControlValue
410 ToolbarValue() : ImplControlValue( ControlType::Toolbar
, 0 )
411 { mbIsTopDockingArea
= false; }
412 virtual ~ToolbarValue() override
;
413 virtual ToolbarValue
* clone() const override
;
414 tools::Rectangle maGripRect
;
415 bool mbIsTopDockingArea
; // indicates that this is the top aligned dockingarea
416 // adjacent to the menubar
421 * Value container for menubars specifying height of adjacent docking area
423 class VCL_DLLPUBLIC MenubarValue
: public ImplControlValue
426 MenubarValue() : ImplControlValue( ControlType::Menubar
, 0 )
427 { maTopDockingAreaHeight
=0; }
428 virtual ~MenubarValue() override
;
429 virtual MenubarValue
* clone() const override
;
430 int maTopDockingAreaHeight
;
435 * Value container for menu items; specifies the rectangle for the whole item which
436 * may be useful when drawing parts with a smaller rectangle.
438 class VCL_DLLPUBLIC MenupopupValue
: public ImplControlValue
441 MenupopupValue( long i_nGutterWidth
, const tools::Rectangle
& i_rItemRect
)
442 : ImplControlValue( ControlType::MenuPopup
, i_nGutterWidth
)
443 , maItemRect( i_rItemRect
)
445 virtual ~MenupopupValue() override
;
446 virtual MenupopupValue
* clone() const override
;
447 tools::Rectangle maItemRect
;
452 * Value container for pushbuttons specifying additional drawing hints
454 class VCL_DLLPUBLIC PushButtonValue
: public ImplControlValue
458 : ImplControlValue( ControlType::Pushbutton
, 0 )
459 , mbBevelButton( false ), mbSingleLine( true ) {}
460 virtual ~PushButtonValue() override
;
461 virtual PushButtonValue
* clone() const override
;
463 bool mbBevelButton
:1;
470 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */