Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / vcl / salnativewidgets.hxx
blob98cbc1953f5f9a9dabb4b30835d38a3c952bcaef
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 <rtl/ustring.hxx>
24 #include <vcl/dllapi.h>
25 #include <tools/gen.hxx>
26 #include <o3tl/typed_flags_set.hxx>
28 /* Control Types:
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
37 Generic = 0,
38 // Normal PushButton/Command Button
39 Pushbutton = 1,
40 // Normal single radio button
41 Radiobutton = 2,
42 // Normal single checkbox
43 Checkbox = 10,
44 // Combobox, i.e. a ListBox
45 // that allows data entry by user
46 Combobox = 20,
47 // Control that allows text entry
48 Editbox = 30,
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
52 // border window.
53 EditboxNoBorder = 31,
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
59 Listbox = 35,
60 // An edit field together with two little
61 // buttons on the side (aka spin field)
62 Spinbox = 40,
63 // Two standalone spin buttons
64 // without an edit field
65 SpinButtons = 45,
66 // A single tab
67 TabItem = 50,
68 // The border around a tab area,
69 // but without the tabs themselves.
70 // May have a gap at the top for
71 // the active tab
72 TabPane = 55,
73 // The background to the tab area
74 TabHeader = 56,
75 // Background of a Tab Pane
76 TabBody = 57,
77 // Normal scrollbar, including
78 // all parts like slider, buttons
79 Scrollbar = 60,
80 Slider = 65,
81 // A separator line
82 Fixedline = 80,
83 // A toolbar control with buttons and a grip
84 Toolbar = 100,
85 // The menubar
86 Menubar = 120,
87 // popup menu
88 MenuPopup = 121,
89 Progress = 131,
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/)
95 IntroProgress = 132,
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 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
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 // 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
198 Border = 7000,
200 //to draw natively the focus rects
201 Focus = 8000
204 /* Control State:
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 {
214 NONE = 0,
215 ENABLED = 0x0001,
216 FOCUSED = 0x0002,
217 PRESSED = 0x0004,
218 ROLLOVER = 0x0008,
219 DEFAULT = 0x0020,
220 SELECTED = 0x0040,
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).
224 namespace o3tl
226 template<> struct typed_flags<ControlState> : is_typed_flags<ControlState, 0xc06f> {};
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 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 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; }
283 /* ScrollbarValue:
285 * Value container for scrollbars.
287 class VCL_DLLPUBLIC ScrollbarValue : public ImplControlValue
289 public:
290 long mnMin;
291 long mnMax;
292 long mnCur;
293 long mnVisibleSize;
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;
303 ScrollbarValue()
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
316 public:
317 long mnMin;
318 long mnMax;
319 long mnCur;
320 tools::Rectangle maThumbRect;
321 ControlState mnThumbState;
323 SliderValue()
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;
331 /* TabitemValue:
333 * Value container for tabitems.
336 /* TABITEM constants are OR-ed together */
337 enum class TabitemFlags
339 NONE = 0x00,
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
345 namespace o3tl
347 template<> struct typed_flags<TabitemFlags> : is_typed_flags<TabitemFlags, 0x0f> {};
350 class VCL_DLLPUBLIC TabitemValue : public ImplControlValue
352 public:
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; }
374 /* SpinbuttonValue:
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
382 public:
383 tools::Rectangle maUpperRect;
384 tools::Rectangle maLowerRect;
385 ControlState mnUpperState;
386 ControlState mnLowerState;
387 ControlPart mnUpperPart;
388 ControlPart mnLowerPart;
390 SpinbuttonValue()
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;
403 /* Toolbarvalue:
405 * Value container for toolbars detailing the grip position
407 class VCL_DLLPUBLIC ToolbarValue : public ImplControlValue
409 public:
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
419 /* MenubarValue:
421 * Value container for menubars specifying height of adjacent docking area
423 class VCL_DLLPUBLIC MenubarValue : public ImplControlValue
425 public:
426 MenubarValue() : ImplControlValue( ControlType::Menubar, 0 )
427 { maTopDockingAreaHeight=0; }
428 virtual ~MenubarValue() override;
429 virtual MenubarValue* clone() const override;
430 int maTopDockingAreaHeight;
433 /* MenupopupValue:
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
440 public:
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;
450 /* PushButtonValue:
452 * Value container for pushbuttons specifying additional drawing hints
454 class VCL_DLLPUBLIC PushButtonValue : public ImplControlValue
456 public:
457 PushButtonValue()
458 : ImplControlValue( ControlType::Pushbutton, 0 )
459 , mbBevelButton( false ), mbSingleLine( true ) {}
460 virtual ~PushButtonValue() override;
461 virtual PushButtonValue* clone() const override;
463 bool mbBevelButton:1;
464 bool mbSingleLine:1;
468 #endif
470 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */