LibreOffice Module vcl (master)  1
salnativewidgets.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_VCL_SALNATIVEWIDGETS_HXX
21 #define INCLUDED_VCL_SALNATIVEWIDGETS_HXX
22 
23 #include <vcl/dllapi.h>
24 #include <tools/gen.hxx>
25 #include <o3tl/typed_flags_set.hxx>
26 
27 /* Control Types:
28  *
29  * Specify the overall, whole control
30  * type (as opposed to parts of the
31  * control if it were composite).
32  */
33 
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,
109 };
110 
111 
112 /* Control Parts:
113  *
114  * Uniquely identify a part of a control,
115  * for example the slider of a scroll bar.
116  */
117 
118 enum class ControlPart
119 {
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,
145 
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.
153  .
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.
156 
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.
161 */
162 
169  SubEdit = 300,
170 
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,
179 
180 // GTK+ also draws tabs right->left since there is a
181 // hardcoded 2 pixel overlap between adjacent tabs
182  TabsDrawRtl = 3000,
183 
184 // Qt doesn't have a separate header to draw
185  TabPaneWithHeader = 3001,
186 
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,
192 
193 // For scrollbars that have 3 buttons (most KDE themes)
194  HasThreeButtons = 5000,
195 
196  BackgroundWindow = 6000,
197  BackgroundDialog = 6001,
198 
199 //to draw natively the border of frames
200  Border = 7000,
201 
202 //to draw natively the focus rects
203  Focus = 8000
204 };
205 
206 /* Control State:
207  *
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.
214  */
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,
223  DOUBLEBUFFERING = 0x4000,
224  CACHING_ALLOWED = 0x8000,
225 };
226 namespace o3tl
227 {
228  template<> struct typed_flags<ControlState> : is_typed_flags<ControlState, 0xc06f> {};
229 }
230 
231 /* ButtonValue:
232  *
233  * Identifies the tri-state value options
234  * that buttons allow
235  */
236 
237 enum class ButtonValue {
238  DontKnow,
239  On,
240  Off,
241  Mixed
242 };
243 
244 /* ImplControlValue:
245  *
246  * Generic value container for all control parts.
247  */
248 
250 {
251  friend class SalFrame;
252 
253  private:
255  ButtonValue mTristate; // Tristate value: on, off, mixed
256  long mNumber; // numeric value
257  protected:
258  ImplControlValue( ControlType i_eType, long i_nNumber )
259  : mType( i_eType )
260  , mTristate( ButtonValue::DontKnow )
261  , mNumber( i_nNumber )
262  {}
263 
264  public:
265  explicit ImplControlValue( ButtonValue nTristate )
266  : mType( ControlType::Generic ), mTristate(nTristate), mNumber(0) {}
267  explicit ImplControlValue( long nNumeric )
268  : mType( ControlType::Generic ), mTristate(ButtonValue::DontKnow), mNumber( nNumeric) {}
270  : mType( ControlType::Generic ), mTristate(ButtonValue::DontKnow), mNumber(0) {}
271 
272  virtual ~ImplControlValue();
273 
274  ImplControlValue(ImplControlValue const &) = default;
275  ImplControlValue(ImplControlValue &&) = default;
276  ImplControlValue & operator =(ImplControlValue const &) = delete; // due to const mType
277  ImplControlValue & operator =(ImplControlValue &&) = delete; // due to const mType
278 
279  virtual ImplControlValue* clone() const;
280 
281  ControlType getType() const { return mType; }
282 
283  ButtonValue getTristateVal() const { return mTristate; }
284  void setTristateVal( ButtonValue nTristate ) { mTristate = nTristate; }
285 
286  long getNumericVal() const { return mNumber; }
287  void setNumericVal( long nNumeric ) { mNumber = nNumeric; }
288 };
289 
290 /* ScrollbarValue:
291  *
292  * Value container for scrollbars.
293  */
295 {
296  public:
297  long mnMin;
298  long mnMax;
299  long mnCur;
307 
310  {
311  mnMin = 0; mnMax = 0; mnCur = 0; mnVisibleSize = 0;
312  mnButton1State = ControlState::NONE; mnButton2State = ControlState::NONE;
313  mnThumbState = ControlState::NONE;
314  };
315  virtual ~ScrollbarValue() override;
316  virtual ScrollbarValue* clone() const override;
317 
318  ScrollbarValue(ScrollbarValue const &) = default;
319  ScrollbarValue(ScrollbarValue &&) = default;
320  ScrollbarValue & operator =(ScrollbarValue const &) = delete; // due to ImplControlValue
321  ScrollbarValue & operator =(ScrollbarValue &&) = delete; // due to ImplControlValue
322 };
323 
325 {
326  public:
327  long mnMin;
328  long mnMax;
329  long mnCur;
332 
335  , mnMin( 0 ), mnMax( 0 ), mnCur( 0 ), mnThumbState( ControlState::NONE )
336  {}
337  virtual ~SliderValue() override;
338  virtual SliderValue* clone() const override;
339 
340  SliderValue(SliderValue const &) = default;
341  SliderValue(SliderValue &&) = default;
342  SliderValue & operator =(SliderValue const &) = delete; // due to ImplControlValue
343  SliderValue & operator =(SliderValue &&) = delete; // due to ImplControlValue
344 };
345 
347 {
348 public:
351  // increased tab size, so it'll overlab the frame rect when drawing
352  // static value, as there is currently no sane way to return additional data
353  static int m_nOverlap;
354 
355  TabPaneValue(const tools::Rectangle &rTabHeaderRect, const tools::Rectangle &rSelectedTabRect)
357  , m_aTabHeaderRect(rTabHeaderRect)
358  , m_aSelectedTabRect(rSelectedTabRect)
359  {
360  }
361  TabPaneValue* clone() const override;
362 
363  TabPaneValue(TabPaneValue const &) = default;
364  TabPaneValue(TabPaneValue &&) = default;
365  TabPaneValue & operator =(TabPaneValue const &) = delete;
366  TabPaneValue & operator =(TabPaneValue &&) = delete;
367 };
368 
369 /* TabitemValue:
370  *
371  * Value container for tabitems.
372  */
373 
374 /* TABITEM constants are OR-ed together */
375 enum class TabitemFlags
376 {
377  NONE = 0x00,
378  LeftAligned = 0x01, // the tabitem is aligned with the left border of the TabControl
379  RightAligned = 0x02, // the tabitem is aligned with the right border of the TabControl
380  FirstInGroup = 0x04, // the tabitem is the first in group of tabitems
381  LastInGroup = 0x08, // the tabitem is the last in group of tabitems
382 };
383 namespace o3tl
384 {
385  template<> struct typed_flags<TabitemFlags> : is_typed_flags<TabitemFlags, 0x0f> {};
386 }
387 
389 {
390  public:
393 
394  TabitemValue(const tools::Rectangle &rContentRect)
396  , mnAlignment(TabitemFlags::NONE)
397  , maContentRect(rContentRect)
398  {
399  }
400  virtual ~TabitemValue() override;
401  virtual TabitemValue* clone() const override;
402 
403  TabitemValue(TabitemValue const &) = default;
404  TabitemValue(TabitemValue &&) = default;
405  TabitemValue & operator =(TabitemValue const &) = delete; // due to ImplControlValue
406  TabitemValue & operator =(TabitemValue &&) = delete; // due to ImplControlValue
407 
408  bool isLeftAligned() const { return bool(mnAlignment & TabitemFlags::LeftAligned); }
409  bool isRightAligned() const { return bool(mnAlignment & TabitemFlags::RightAligned); }
410  bool isBothAligned() const { return isLeftAligned() && isRightAligned(); }
411  bool isNotAligned() const { return !(mnAlignment & (TabitemFlags::LeftAligned | TabitemFlags::RightAligned)); }
412  bool isFirst() const { return bool(mnAlignment & TabitemFlags::FirstInGroup); }
413  bool isLast() const { return bool(mnAlignment & TabitemFlags::LastInGroup); }
414  const tools::Rectangle& getContentRect() const { return maContentRect; }
415 };
416 
417 /* SpinbuttonValue:
418  *
419  * Value container for spinbuttons to paint both buttons at once.
420  * Note: the other parameters of DrawNativeControl will have no meaning
421  * all parameters for spinbuttons are carried here
422  */
424 {
425  public:
432 
435  , mnUpperState(ControlState::NONE)
436  , mnLowerState(ControlState::NONE)
437  , mnUpperPart(ControlPart::NONE)
438  , mnLowerPart(ControlPart::NONE)
439  {
440  }
441 
442  virtual ~SpinbuttonValue() override;
443  virtual SpinbuttonValue* clone() const override;
444 
445  SpinbuttonValue(SpinbuttonValue const &) = default;
446  SpinbuttonValue(SpinbuttonValue &&) = default;
447  SpinbuttonValue & operator =(SpinbuttonValue const &) = delete; // due to ImplControlValue
448  SpinbuttonValue & operator =(SpinbuttonValue &&) = delete; // due to ImplControlValue
449 };
450 
451 /* Toolbarvalue:
452  *
453  * Value container for toolbars detailing the grip position
454  */
456 {
457 public:
459  { mbIsTopDockingArea = false; }
460  virtual ~ToolbarValue() override;
461  virtual ToolbarValue* clone() const override;
462 
463  ToolbarValue(ToolbarValue const &) = default;
464  ToolbarValue(ToolbarValue &&) = default;
465  ToolbarValue & operator =(ToolbarValue const &) = delete; // due to ImplControlValue
466  ToolbarValue & operator =(ToolbarValue &&) = delete; // due to ImplControlValue
467 
469  bool mbIsTopDockingArea; // indicates that this is the top aligned dockingarea
470  // adjacent to the menubar, only used on Windows
471 };
472 
473 /* MenubarValue:
474  *
475  * Value container for menubars specifying height of adjacent docking area
476  */
478 {
479 public:
481  { maTopDockingAreaHeight=0; }
482  virtual ~MenubarValue() override;
483  virtual MenubarValue* clone() const override;
484  MenubarValue(MenubarValue const &) = default;
485  MenubarValue(MenubarValue &&) = default;
486  MenubarValue & operator =(MenubarValue const &) = delete; // due to ImplControlValue
487  MenubarValue & operator =(MenubarValue &&) = delete; // due to ImplControlValue
489 };
490 
491 /* MenupopupValue:
492  *
493  * Value container for menu items; specifies the rectangle for the whole item which
494  * may be useful when drawing parts with a smaller rectangle.
495  */
497 {
498 public:
499  MenupopupValue( long i_nGutterWidth, const tools::Rectangle& i_rItemRect )
500  : ImplControlValue( ControlType::MenuPopup, i_nGutterWidth )
501  , maItemRect( i_rItemRect )
502  {}
503  virtual ~MenupopupValue() override;
504  virtual MenupopupValue* clone() const override;
505  MenupopupValue(MenupopupValue const &) = default;
506  MenupopupValue(MenupopupValue &&) = default;
507  MenupopupValue & operator =(MenupopupValue const &) = delete; // due to ImplControlValue
508  MenupopupValue & operator =(MenupopupValue &&) = delete; // due to ImplControlValue
510 };
511 
512 /* PushButtonValue:
513  *
514  * Value container for pushbuttons specifying additional drawing hints
515  */
517 {
518 public:
521  , mbBevelButton(false)
522  , mbSingleLine(true)
523  , mbIsAction(false)
524  {}
525 
526  virtual ~PushButtonValue() override;
527  virtual PushButtonValue* clone() const override;
528 
529  PushButtonValue(PushButtonValue const &) = default;
530  PushButtonValue(PushButtonValue &&) = default;
531  PushButtonValue & operator =(PushButtonValue const &) = delete; // due to ImplControlValue
532  PushButtonValue & operator =(PushButtonValue &&) = delete; // due to ImplControlValue
533 
534  bool mbBevelButton:1; // only used on OSX
535  bool mbSingleLine:1; // only used on OSX
536  bool mbIsAction:1;
537 };
538 
539 
540 #endif
541 
542 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const tools::Rectangle & getContentRect() const
tools::Rectangle m_aTabHeaderRect
TabitemFlags
ControlType getType() const
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
tools::Rectangle maButton2Rect
void setTristateVal(ButtonValue nTristate)
ControlPart mnLowerPart
tools::Rectangle maLowerRect
tools::Rectangle maUpperRect
ControlState mnButton2State
Set when the control is painted using double-buffering via VirtualDevice.
TabitemFlags mnAlignment
bool isFirst() const
bool isLeftAligned() const
ControlType const mType
bool isLast() const
ControlPart mnUpperPart
tools::Rectangle maItemRect
ControlState mnUpperState
tools::Rectangle maContentRect
NONE
Set when the control is completely visible (i.e. not clipped).
virtual ImplControlValue * clone() const
bool isRightAligned() const
The edit field part of a control, e.g.
tools::Rectangle maButton1Rect
ControlState mnLowerState
ImplControlValue(ButtonValue nTristate)
bool isBothAligned() const
ControlState mnButton1State
tools::Rectangle m_aSelectedTabRect
tools::Rectangle maThumbRect
TabitemValue(const tools::Rectangle &rContentRect)
ControlState mnThumbState
ControlType
These types are all based on the supported variants vcl/salnativewidgets.hxx and must be kept in-sync...
A SalFrame is a system window (e.g. an X11 window).
Definition: salframe.hxx:112
TabPaneValue(const tools::Rectangle &rTabHeaderRect, const tools::Rectangle &rSelectedTabRect)
ControlState mnThumbState
ImplControlValue(long nNumeric)
void setNumericVal(long nNumeric)
ButtonValue getTristateVal() const
static int m_nOverlap
T * clone(T *const other)
tools::Rectangle maGripRect
long getNumericVal() const
MenupopupValue(long i_nGutterWidth, const tools::Rectangle &i_rItemRect)
tools::Rectangle maThumbRect
bool isNotAligned() const
ImplControlValue(ControlType i_eType, long i_nNumber)
ImplControlValue & operator=(ImplControlValue const &)=delete