Bump version to 6.4-15
[LibreOffice.git] / include / vcl / salnativewidgets.hxx
blob4ae64ace4602aa014d4b1a7053a0df01378e587e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
27 /* Control Types:
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
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 )
55 MultilineEditbox = 32,
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,
112 /* Control Parts:
114 * Uniquely identify a part of a control,
115 * for example the slider of a scroll bar.
118 enum class ControlPart
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,
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.
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.
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.
163 /** The edit field part of a control, e.g. of the combo box.
165 Currently used just for combo boxes and just for GetNativeControlRegion().
166 It is valid only if GetNativeControlRegion() supports ControlPart::ButtonDown as
167 well.
169 SubEdit = 300,
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,
180 // GTK+ also draws tabs right->left since there is a
181 // hardcoded 2 pixel overlap between adjacent tabs
182 TabsDrawRtl = 3000,
184 // Qt doesn't have a separate header to draw
185 TabPaneWithHeader = 3001,
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
191 HasBackgroundTexture = 4000,
193 // For scrollbars that have 3 buttons (most KDE themes)
194 HasThreeButtons = 5000,
196 BackgroundWindow = 6000,
197 BackgroundDialog = 6001,
199 //to draw natively the border of frames
200 Border = 7000,
202 //to draw natively the focus rects
203 Focus = 8000
206 /* Control State:
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.
215 enum class ControlState {
216 NONE = 0,
217 ENABLED = 0x0001,
218 FOCUSED = 0x0002,
219 PRESSED = 0x0004,
220 ROLLOVER = 0x0008,
221 DEFAULT = 0x0020,
222 SELECTED = 0x0040
224 namespace o3tl
226 template<> struct typed_flags<ControlState> : is_typed_flags<ControlState, 0x006f> {};
229 /* ButtonValue:
231 * Identifies the tri-state value options
232 * that buttons allow
235 enum class ButtonValue {
236 DontKnow,
238 Off,
239 Mixed
242 /* ImplControlValue:
244 * Generic value container for all control parts.
247 class VCL_DLLPUBLIC ImplControlValue
249 friend class SalFrame;
251 private:
252 ControlType const mType;
253 ButtonValue mTristate; // Tristate value: on, off, mixed
254 long mNumber; // numeric value
255 protected:
256 ImplControlValue( ControlType i_eType, long i_nNumber )
257 : mType( i_eType )
258 , mTristate( ButtonValue::DontKnow )
259 , mNumber( i_nNumber )
262 public:
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) {}
267 ImplControlValue()
268 : mType( ControlType::Generic ), mTristate(ButtonValue::DontKnow), mNumber(0) {}
270 virtual ~ImplControlValue();
272 ImplControlValue(ImplControlValue const &) = default;
273 ImplControlValue(ImplControlValue &&) = default;
274 ImplControlValue & operator =(ImplControlValue const &) = delete; // due to const mType
275 ImplControlValue & operator =(ImplControlValue &&) = delete; // due to const mType
277 virtual ImplControlValue* clone() const;
279 ControlType getType() const { return mType; }
281 ButtonValue getTristateVal() const { return mTristate; }
282 void setTristateVal( ButtonValue nTristate ) { mTristate = nTristate; }
284 long getNumericVal() const { return mNumber; }
285 void setNumericVal( long nNumeric ) { mNumber = nNumeric; }
288 /* ScrollbarValue:
290 * Value container for scrollbars.
292 class SAL_DLLPUBLIC_RTTI ScrollbarValue final : public ImplControlValue
294 public:
295 long mnMin;
296 long mnMax;
297 long mnCur;
298 long mnVisibleSize;
299 tools::Rectangle maThumbRect;
300 tools::Rectangle maButton1Rect;
301 tools::Rectangle maButton2Rect;
302 ControlState mnButton1State;
303 ControlState mnButton2State;
304 ControlState mnThumbState;
306 ScrollbarValue()
307 : ImplControlValue( ControlType::Scrollbar, 0 )
309 mnMin = 0; mnMax = 0; mnCur = 0; mnVisibleSize = 0;
310 mnButton1State = ControlState::NONE; mnButton2State = ControlState::NONE;
311 mnThumbState = ControlState::NONE;
313 virtual ~ScrollbarValue() override;
314 virtual ScrollbarValue* clone() const override;
316 ScrollbarValue(ScrollbarValue const &) = default;
317 ScrollbarValue(ScrollbarValue &&) = default;
318 ScrollbarValue & operator =(ScrollbarValue const &) = delete; // due to ImplControlValue
319 ScrollbarValue & operator =(ScrollbarValue &&) = delete; // due to ImplControlValue
322 class SAL_DLLPUBLIC_RTTI SliderValue final : public ImplControlValue
324 public:
325 long mnMin;
326 long mnMax;
327 long mnCur;
328 tools::Rectangle maThumbRect;
329 ControlState mnThumbState;
331 SliderValue()
332 : ImplControlValue( ControlType::Slider, 0 )
333 , mnMin( 0 ), mnMax( 0 ), mnCur( 0 ), mnThumbState( ControlState::NONE )
335 virtual ~SliderValue() override;
336 virtual SliderValue* clone() const override;
338 SliderValue(SliderValue const &) = default;
339 SliderValue(SliderValue &&) = default;
340 SliderValue & operator =(SliderValue const &) = delete; // due to ImplControlValue
341 SliderValue & operator =(SliderValue &&) = delete; // due to ImplControlValue
344 class VCL_DLLPUBLIC TabPaneValue final : public ImplControlValue
346 public:
347 tools::Rectangle m_aTabHeaderRect;
348 tools::Rectangle m_aSelectedTabRect;
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;
353 TabPaneValue(const tools::Rectangle &rTabHeaderRect, const tools::Rectangle &rSelectedTabRect)
354 : ImplControlValue(ControlType::TabPane, 0)
355 , m_aTabHeaderRect(rTabHeaderRect)
356 , m_aSelectedTabRect(rSelectedTabRect)
359 TabPaneValue* clone() const override;
361 TabPaneValue(TabPaneValue const &) = default;
362 TabPaneValue(TabPaneValue &&) = default;
363 TabPaneValue & operator =(TabPaneValue const &) = delete;
364 TabPaneValue & operator =(TabPaneValue &&) = delete;
367 /* TabitemValue:
369 * Value container for tabitems.
372 /* TABITEM constants are OR-ed together */
373 enum class TabitemFlags
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
381 namespace o3tl
383 template<> struct typed_flags<TabitemFlags> : is_typed_flags<TabitemFlags, 0x0f> {};
386 class SAL_DLLPUBLIC_RTTI TabitemValue final : public ImplControlValue
388 public:
389 TabitemFlags mnAlignment;
390 tools::Rectangle maContentRect;
392 TabitemValue(const tools::Rectangle &rContentRect)
393 : ImplControlValue( ControlType::TabItem, 0 )
394 , mnAlignment(TabitemFlags::NONE)
395 , maContentRect(rContentRect)
398 virtual ~TabitemValue() override;
399 virtual TabitemValue* clone() const override;
401 TabitemValue(TabitemValue const &) = default;
402 TabitemValue(TabitemValue &&) = default;
403 TabitemValue & operator =(TabitemValue const &) = delete; // due to ImplControlValue
404 TabitemValue & operator =(TabitemValue &&) = delete; // due to ImplControlValue
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; }
415 /* SpinbuttonValue:
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
421 class SAL_DLLPUBLIC_RTTI SpinbuttonValue final : public ImplControlValue
423 public:
424 tools::Rectangle maUpperRect;
425 tools::Rectangle maLowerRect;
426 ControlState mnUpperState;
427 ControlState mnLowerState;
428 ControlPart mnUpperPart;
429 ControlPart mnLowerPart;
431 SpinbuttonValue()
432 : ImplControlValue( ControlType::SpinButtons, 0 )
433 , mnUpperState(ControlState::NONE)
434 , mnLowerState(ControlState::NONE)
435 , mnUpperPart(ControlPart::NONE)
436 , mnLowerPart(ControlPart::NONE)
440 virtual ~SpinbuttonValue() override;
441 virtual SpinbuttonValue* clone() const override;
443 SpinbuttonValue(SpinbuttonValue const &) = default;
444 SpinbuttonValue(SpinbuttonValue &&) = default;
445 SpinbuttonValue & operator =(SpinbuttonValue const &) = delete; // due to ImplControlValue
446 SpinbuttonValue & operator =(SpinbuttonValue &&) = delete; // due to ImplControlValue
449 /* Toolbarvalue:
451 * Value container for toolbars detailing the grip position
453 class VCL_DLLPUBLIC ToolbarValue final : public ImplControlValue
455 public:
456 ToolbarValue() : ImplControlValue( ControlType::Toolbar, 0 )
457 { mbIsTopDockingArea = false; }
458 virtual ~ToolbarValue() override;
459 virtual ToolbarValue* clone() const override;
461 ToolbarValue(ToolbarValue const &) = default;
462 ToolbarValue(ToolbarValue &&) = default;
463 ToolbarValue & operator =(ToolbarValue const &) = delete; // due to ImplControlValue
464 ToolbarValue & operator =(ToolbarValue &&) = delete; // due to ImplControlValue
466 tools::Rectangle maGripRect;
467 bool mbIsTopDockingArea; // indicates that this is the top aligned dockingarea
468 // adjacent to the menubar, only used on Windows
471 /* MenubarValue:
473 * Value container for menubars specifying height of adjacent docking area
475 class MenubarValue final : public ImplControlValue
477 public:
478 MenubarValue() : ImplControlValue( ControlType::Menubar, 0 )
479 { maTopDockingAreaHeight=0; }
480 virtual ~MenubarValue() override;
481 virtual MenubarValue* clone() const override;
482 MenubarValue(MenubarValue const &) = default;
483 MenubarValue(MenubarValue &&) = default;
484 MenubarValue & operator =(MenubarValue const &) = delete; // due to ImplControlValue
485 MenubarValue & operator =(MenubarValue &&) = delete; // due to ImplControlValue
486 int maTopDockingAreaHeight;
489 /* MenupopupValue:
491 * Value container for menu items; specifies the rectangle for the whole item which
492 * may be useful when drawing parts with a smaller rectangle.
494 class SAL_DLLPUBLIC_RTTI MenupopupValue final : public ImplControlValue
496 public:
497 MenupopupValue( long i_nGutterWidth, const tools::Rectangle& i_rItemRect )
498 : ImplControlValue( ControlType::MenuPopup, i_nGutterWidth )
499 , maItemRect( i_rItemRect )
501 virtual ~MenupopupValue() override;
502 virtual MenupopupValue* clone() const override;
503 MenupopupValue(MenupopupValue const &) = default;
504 MenupopupValue(MenupopupValue &&) = default;
505 MenupopupValue & operator =(MenupopupValue const &) = delete; // due to ImplControlValue
506 MenupopupValue & operator =(MenupopupValue &&) = delete; // due to ImplControlValue
507 tools::Rectangle maItemRect;
510 /* PushButtonValue:
512 * Value container for pushbuttons specifying additional drawing hints
514 class VCL_DLLPUBLIC PushButtonValue final : public ImplControlValue
516 public:
517 PushButtonValue()
518 : ImplControlValue( ControlType::Pushbutton, 0 )
519 , mbBevelButton(false)
520 , mbSingleLine(true)
521 , mbIsAction(false)
524 virtual ~PushButtonValue() override;
525 virtual PushButtonValue* clone() const override;
527 PushButtonValue(PushButtonValue const &) = default;
528 PushButtonValue(PushButtonValue &&) = default;
529 PushButtonValue & operator =(PushButtonValue const &) = delete; // due to ImplControlValue
530 PushButtonValue & operator =(PushButtonValue &&) = delete; // due to ImplControlValue
532 bool mbBevelButton:1; // only used on OSX
533 bool mbSingleLine:1; // only used on OSX
534 bool mbIsAction:1;
538 #endif
540 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */