tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / include / vcl / salnativewidgets.hxx
blob68fae745e757b803abdec176570342f358625e6c
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 LevelBar = 133,
96 // tool tips
97 Tooltip = 140,
98 // to draw the implemented theme
99 WindowBackground = 150,
100 //to draw border of frames natively
101 Frame = 160,
102 // for nodes in listviews
103 // used in svtools/source/contnr/svtreebx.cxx
104 ListNode = 170,
105 // nets between elements of listviews
106 // with nodes
107 ListNet = 171,
108 // for list headers
109 ListHeader = 172,
113 /* Control Parts:
115 * Uniquely identify a part of a control,
116 * for example the slider of a scroll bar.
119 enum class ControlPart
121 NONE = 0,
122 Entire = 1,
123 ListboxWindow = 5, // the static listbox window containing the list
124 Button = 100,
125 ButtonUp = 101,
126 ButtonDown = 102, // Also for ComboBoxes/ListBoxes
127 ButtonLeft = 103,
128 ButtonRight = 104,
129 AllButtons = 105,
130 SeparatorHorz = 106,
131 SeparatorVert = 107,
132 TrackHorzLeft = 200,
133 TrackVertUpper = 201,
134 TrackHorzRight = 202,
135 TrackVertLower = 203,
136 TrackHorzArea = 204,
137 TrackVertArea = 205,
138 Arrow = 220,
139 ThumbHorz = 210, // Also used as toolbar grip
140 ThumbVert = 211, // Also used as toolbar grip
141 MenuItem = 250,
142 MenuItemCheckMark = 251,
143 MenuItemRadioMark = 252,
144 Separator = 253,
145 SubmenuArrow = 254,
147 /* #i77549#
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
168 well.
170 SubEdit = 300,
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
183 TabsDrawRtl = 3000,
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
201 Border = 7000,
203 //to draw natively the focus rects
204 Focus = 8000
207 /* Control State:
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 {
217 NONE = 0,
218 ENABLED = 0x0001,
219 FOCUSED = 0x0002,
220 PRESSED = 0x0004,
221 ROLLOVER = 0x0008,
222 DEFAULT = 0x0020,
223 SELECTED = 0x0040
225 namespace o3tl
227 template<> struct typed_flags<ControlState> : is_typed_flags<ControlState, 0x006f> {};
230 /* ButtonValue:
232 * Identifies the tri-state value options
233 * that buttons allow
236 enum class ButtonValue {
237 DontKnow,
239 Off,
240 Mixed
243 /* ImplControlValue:
245 * Generic value container for all control parts.
248 class VCL_DLLPUBLIC ImplControlValue
250 friend class SalFrame;
252 private:
253 ControlType mType;
254 ButtonValue mTristate; // Tristate value: on, off, mixed
255 tools::Long mNumber; // numeric value
256 protected:
257 ImplControlValue( ControlType i_eType, tools::Long i_nNumber )
258 : mType( i_eType )
259 , mTristate( ButtonValue::DontKnow )
260 , mNumber( i_nNumber )
263 public:
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) {}
268 ImplControlValue()
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; }
289 /* ScrollbarValue:
291 * Value container for scrollbars.
293 class SAL_DLLPUBLIC_RTTI ScrollbarValue final : public ImplControlValue
295 public:
296 tools::Long mnMin;
297 tools::Long mnMax;
298 tools::Long mnCur;
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;
307 ScrollbarValue()
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
325 public:
326 tools::Long mnMin;
327 tools::Long mnMax;
328 tools::Long mnCur;
329 tools::Rectangle maThumbRect;
330 ControlState mnThumbState;
332 SliderValue()
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
347 public:
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;
368 /* TabitemValue:
370 * Value container for tabitems.
373 /* TABITEM constants are OR-ed together */
374 enum class TabitemFlags
376 NONE = 0x00,
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
382 namespace o3tl
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
390 Top,
391 Left,
392 Right,
393 Bottom
396 class SAL_DLLPUBLIC_RTTI TabitemValue final : public ImplControlValue
398 public:
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; }
427 /* SpinbuttonValue:
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
435 public:
436 tools::Rectangle maUpperRect;
437 tools::Rectangle maLowerRect;
438 ControlState mnUpperState;
439 ControlState mnLowerState;
440 ControlPart mnUpperPart;
441 ControlPart mnLowerPart;
443 SpinbuttonValue()
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
461 /* MenupopupValue:
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
468 public:
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;
482 /* PushButtonValue:
484 * Value container for pushbuttons specifying additional drawing hints
486 class VCL_DLLPUBLIC PushButtonValue final : public ImplControlValue
488 public:
489 PushButtonValue()
490 : ImplControlValue( ControlType::Pushbutton, 0 )
491 , mbSingleLine(true)
492 , mbIsAction(false)
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
505 bool mbIsAction:1;
506 bool m_bFlatButton:1;
510 #endif
512 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */