LibreOffice Module svtools (master) 1
ruler.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#pragma once
21
22#include <memory>
23#include <map>
24#include <vector>
25#include <svtools/svtdllapi.h>
26#include <rtl/ref.hxx>
27#include <tools/fldunit.hxx>
28#include <tools/link.hxx>
29#include <tools/fract.hxx>
30#include <vcl/window.hxx>
31#include <vcl/glyphitem.hxx>
32
33class MouseEvent;
34class TrackingEvent;
37
38/*************************************************************************
39
40Description
41============
42
43class Ruler
44
45This class is used for displaying a ruler, but it can also be used
46for setting or moving tabs and margins.
47
48--------------------------------------------------------------------------
49
50WinBits
51
52WB_HORZ ruler is displayed horizontally
53WB_VERT ruler is displayed vertically
54WB_3DLOOK 3D look
55WB_BORDER border at the bottom/right margin
56WB_EXTRAFIELD Field in the upper left corner for
57 displaying and selecting tabs, origin of coordinates, ...
58WB_RIGHT_ALIGNED Marks the vertical ruler as right aligned
59
60--------------------------------------------------------------------------
61
62All ruler parameters are set in pixel units. This way double conversions
63and rounding errors are avoided and the ruler displays the margins
64at their actual position in the document. Because of this, the application can,
65for example in tables, do its own roundings and the positions on the ruler will
66still match those in the document. However, for the ruler to know how the
67document is displayed on the screen, some additional values have to be configured
68
69SetWinPos() sets the offset of the ruler's edit window. In doing so,
70the width of the window can also be configured. If there is a 0 among the
71values passed to the function, the position/width is automatically set to
72the width of the ruler.
73
74SetPagePos() sets the offset of the page relative to the edit window and the
75width of the page. If there is a 0 among the values passed to the function,
76the position/width is automatically set as if the page filled the whole edit window.
77
78SetBorderPos() sets the offset of the border. The position is relative to
79the upper/left margin of the window. This is needed when there are a horizontal
80and a vertical ruler visible at the same time. Example:
81 aHRuler.SetBorderPos( aVRuler.GetSizePixel().Width()-1 );
82
83SetNullOffset() sets the origin relative to the page.
84
85All the other values (margins, indentation, tabs, ...) refer to the origin,
86which is set with SetNullOffset().
87
88The values are computed as described below:
89
90- WinPos (if both windows have the same parent)
91
92 Point aHRulerPos = aHRuler.GetPosPixel();
93 Point aEditWinPos = aEditWin.GetPosPixel();
94 aHRuler.SetWinPos( aEditWinPos().X() - aHRulerPos.X() );
95
96- PagePos
97
98 Point aPagePos = aEditWin.LogicToPixel( aEditWin.GetPagePos() );
99 aHRuler.SetPagePos( aPagePos().X() );
100
101- All other values
102
103 Add the logical values, recompute as position and subtract the
104 previously saved pixel positions (of PagePos and Null Offset).
105
106--------------------------------------------------------------------------
107
108SetUnit() and SetZoom() configure which unit is used to display
109the values on the ruler. The following units are accepted:
110
111 FieldUnit::MM
112 FieldUnit::CM (Default)
113 FieldUnit::M
114 FieldUnit::KM
115 FieldUnit::INCH
116 FieldUnit::FOOT
117 FieldUnit::MILE
118 FieldUnit::POINT
119 FieldUnit::PICA
120
121--------------------------------------------------------------------------
122
123SetMargin1() sets the upper/left margin and SetMargin2() sets the
124bottom/right margin. If these methods are called without arguments,
125no margins are displayed. Otherwise, the following arguments can be passed:
126
127 long nPos - offset in pixels relative to the origin
128 sal_uInt16 nStyle - bit style:
129 RULER_MARGIN_SIZEABLE
130 margin size can be changed
131
132 The following bits can be set in addition
133 to these styles:
134 RULER_STYLE_INVISIBLE
135
136
137SetBorders() sets an array of margins. To do this, an array of type RulerBorder
138has to be passed. In the array, the following values have to be initialized:
139
140 long nPos - offset in pixels relative to the origin
141 long nWidth - column spacing in pixels (can also be 0, for example,
142 for table columns)
143 sal_uInt16 nStyle - bit style:
144 RulerBorderStyle::Sizeable
145 Column spacing can be changed. This flag should
146 only be set if the size of the spacing is changed,
147 not that of a cell.
148 RulerBorderStyle::Moveable
149 Column spacing/border can be moved. Whenever
150 table borders are to be moved, this flag should
151 be set instead of SIZEABLE (SIZEABLE indicates
152 that the size of a spacing, not that of a single
153 cell can be changed).
154 RulerBorderStyle::Variable
155 Not all of the column spacings are equal
156 RulerBorderStyle::Table
157 Table border. Whenever this style is set, the column
158 width must be 0.
159 RulerBorderStyle::Snap
160 Auxiliary line. Whenever this style is set, the
161 column width must be 0.
162 RulerBorderStyle::Margin
163 Margin. Whenever this style is set, the column
164 width must be 0.
165
166 The following bits can be set in addition
167 to these styles:
168 RULER_STYLE_INVISIBLE
169
170SetIndents() sets an array of indents. This method may only be used for horizontal
171rulers. A Ruler Indent must be passed as an argument, with the following values
172initialized:
173
174 long nPos - offset relative to the origin in pixels
175 sal_uInt16 nStyle - bit style:
176 RulerIndentStyle::Top (indent of the first line)
177 RulerIndentStyle::Bottom (left/right indent)
178 RulerIndentStyle::Border (Vertical line that shows the border distance)
179 The following bits can be set in addition
180 to these styles:
181 RULER_STYLE_DONTKNOW (for old position or for
182 ambiguity)
183 RULER_STYLE_INVISIBLE
184
185SetTabs() sets an array of tabs. This method may only be used for horizontal rulers.
186An array of type RulerTab must be passed as an argument, with the following values
187initialized:
188
189 long nPos - offset relative to the origin in pixels
190 sal_uInt16 nStyle - bit style:
191 RULER_TAB_DEFAULT (can't be selected)
192 RULER_TAB_LEFT
193 RULER_TAB_CENTER
194 RULER_TAB_RIGHT
195 RULER_TAB_DECIMAL
196 The following bits can be set in addition
197 to these styles:
198 RULER_STYLE_DONTKNOW (for old position of for
199 ambiguity)
200 RULER_STYLE_INVISIBLE
201
202SetLines() displays position lines in the ruler. An array of type RulerLine must be passed, with
203the following values initialized:
204
205 long nPos - offset relative to the origin in pixels
206 sal_uInt16 nStyle - bit style (has to be 0 currently)
207
208--------------------------------------------------------------------------
209
210If the user should also be able to change the margins tabs, borders, ...
211in the ruler, a bit more effort is necessary. In this case, the StartDrag(),
212Drag() and EndDrag() methods have to be overridden. For the StartDrag() method
213it is possible to prevent dragging by returning FALSE. In the drag handler,
214the drag position must be queried and the values must be moved to the new
215position. This is done by calling the particular Set methods. While in the
216drag handler, the values are just cached and only afterward the ruler is redrawn.
217All the handlers can also be set as links with the particular Set..Hdl() methods.
218
219 - StartDrag()
220 Is called when dragging is started. If FALSE is returned, the dragging.
221 won't be executed. If TRUE is returned, the dragging will be permitted.
222 If the handler isn't overridden, FALSE will be returned.
223
224 - EndDrag()
225 Is called at the end of dragging.
226
227 - Drag()
228 Is called when dragging takes place.
229
230 - Click()
231 This handler is called when no element has been clicked on.
232 The position can be queried with GetClickPos(). This way it is possible
233 to, for example, ser tabs in the ruler. After calling the click handler,
234 the drag, if any, is immediately triggered. This makes it possible to
235 set a new tab in the click handler and then immediately move it.
236
237 - DoubleClick()
238 This handler is called when a double-click has been performed outside
239 the special panel. The methods GetClickType(), GetClickAryPos() and
240 GetClickPos() can be used to query what has been clicked on.
241 This way you can, for example, show the tab dialog when a double-click
242 is performed on a tab.
243
244In the drag handler it is possible to query what has been dragged and where
245it has been dragged. There are the following query methods:
246
247 - GetDragType()
248 Returns what has been dragged.
249 RulerType::Margin1
250 RulerType::Margin2
251 RulerType::Border
252 RulerType::Indent
253 RulerType::Tab
254
255 - GetDragPos()
256 Returns the pixel position to which the user has moved the mouse
257 relative to the set zero-offset.
258
259 - GetDragAryPos()
260 Returns the index in the array if a border, an indent or a tab
261 is being dragged. Attention: During a drag process, the array position
262 of the item that has been set before the drag is returned.
263 Therefore, it is for example also possible, to no longer show a tab
264 if the mouse is dragged out of the ruler in bottom/right direction.
265
266 - GetDragSize()
267 If Borders are dragged, this can be used to query whether the size
268 resp. which side or the position should be changed.
269 RulerDragSize::Move or 0 - Move
270 RulerDragSize::N1 - left/upper border
271 RulerDragSize::N2 - right/bottom border
272
273 - IsDragDelete()
274 This method can be used to query whether the mouse has been
275 moved out of the window at the bottom/right while dragging.
276 By this, it can for example be determined whether the user
277 wants to delete a tab.
278
279 - IsDragCanceled()
280 Using this Handler, it can be queried in the EndDrag handler
281 whether the action was canceled by the user releasing the
282 mouse at the top/left of the window or by pressing ESC.
283 In this case, the values are not applied. If during the
284 dragging, the mouse is dragged out of the window at the
285 top/left, the old values are displayed automatically without
286 the Drag handler being called.
287 But if the user has moved the value to the old position, the
288 method returns 'false' nevertheless.
289 If this should be avoided, the application must remember the
290 old value in the StartDrag handler and compare the value in the
291 EndDrag handler.
292
293 - GetDragModifier()
294 Returns the modifier keys that were pressed when the Drag process
295 was started. See MouseEvent.
296
297 - GetClickPos()
298 Returns the pixel position at which the user has pressed the mouse
299 with respect to the configured null-offset.
300
301 - GetClickType()
302 Returns what is applied by double click:
303 RulerType::DontKnow (no element in the ruler area)
304 RulerType::Outside (outside of the ruler area)
305 RulerType::Margin1 (only Margin1 border)
306 RulerType::Margin2 (only Margin2 border)
307 RulerType::Border (Border: GetClickAryPos())
308 RulerType::Indent (indent: GetClickAryPos())
309 RulerType::Tab (Tab: GetClickAryPos())
310
311 - GetClickAryPos()
312 Returns the index in the array if a Border, an Indent or a Tab
313 is applied via DoubleClick.
314
315 - GetType()
316 This method can be used to carry out a HitTest,
317 in order to possibly also apply sth to an Item using the right
318 mouse button by catching the MouseButtonDown handler. As
319 parameters, the window position and possibly a pointer to a
320 sal_uInt16 are passed, in order to determine the array position
321 of a Tab, an Indent, or a Border. The following values are
322 returned as type:
323 RulerType::DontKnow (no element in the ruler area)
324 RulerType::Outside (outside of the ruler area)
325 RulerType::Margin1 (only Margin1 border)
326 RulerType::Margin2 (only Margin2 border)
327 RulerType::Border (Border: GetClickAryPos())
328 RulerType::Indent (indent: GetClickAryPos())
329 RulerType::Tab (Tab: GetClickAryPos())
330
331If the drag process should be canceled, this can be done using CancelDrag().
332There are the following methods for controlling the Drag:
333
334 - IsDrag()
335 Returns 'true' if the ruler is in a drag process.
336
337 - CancelDrag()
338 Cancels the drag process, if one is being carried out. During this,
339 the old values are restored and the Drag and the EndDrag handlers
340 are called.
341
342In order to trigger a Drag from the document, there are the following
343methods:
344
345 - StartDocDrag()
346 This method is passed the MouseEvent of the document window
347 and what should be dragged. If RulerType::DontKnow is passed
348 as DragType, the ruler decides what should be dragged. In case
349 of the other types, the Drag is only started if a respective
350 element was found at the given position.
351 This is for example necessary if indents and columns are located
352 at the same X position.
353 The return value indicates whether the Drag has been triggered.
354 If a Drag is triggered, the ruler takes over the normal drag
355 control and behaves as if the ruler had been clicked directly.
356 Thus, the ruler captures the mouse and also takes over control
357 of the Cancel (via keyboard, or if the mouse is moved outside
358 of the ruler above it or left of it). All handlers are called,
359 too (including the StartDrag handler). If a MouseEvent with
360 ClickCount 2 is passed, the DoubleClick handler is also called,
361 respectively.
362
363--------------------------------------------------------------------------
364
365For the extra field, the content can be determined and there are handlers
366that can be used to handle specific actions.
367
368 - ExtraDown()
369 This handler is called when the mouse is pressed in the extra field.
370
371 - SetExtraType()
372 With this method, it can be defined what should be displayed in
373 the extra field.
374 - ExtraType what should be displayed in the extra field
375 RulerExtra::DontKnow (nothing)
376 RulerExtra::NullOffset (coordinate axes)
377 RulerExtra::Tab (Tab)
378 - sal_uInt16 nStyle bit field as style:
379 RULER_STYLE_HIGHLIGHT (selected)
380 RULER_TAB_... (a Tab style)
381
382 - GetExtraClick()
383 Returns the number of mouse clicks. By this, it is for example
384 also possible to trigger an action by a DoubleClick in the
385 extra field.
386
387 - GetExtraModifier()
388 Returns the modifier keys that were pressed when the extra field
389 was clicked. See MouseEvent.
390
391--------------------------------------------------------------------------
392
393Further helper functions:
394
395- static Ruler::DrawTab()
396 With this method, a Tab can be output on an OutputDevice.
397 By this, it is also possible to show the Tabs in dialogs like
398 they are drawn in the ruler.
399
400 This method outputs the Tab centred at the given position. The size
401 of the tabs can be defined by the defines RULER_TAB_WIDTH and
402 RULER_TAB_HEIGHT.
403
404--------------------------------------------------------------------------
405
406Tips for the use of the ruler:
407
408- For the ruler, neither in the Drag mode nor elsewhere, the setting
409 of the values must be bracketed in SetUpdateMode(). The ruler itself
410 takes care that, if multiple values are set, they are automatically
411 grouped together and output flicker-free.
412
413- Initially, the sizes, positions and values should be set first for the
414 ruler, before it is displayed. This is important because otherwise
415 many values are calculated unnecessarily.
416
417- When the document window, in which the ruler resides, becomes active
418 resp. unactive, the methods Activate() and Deactivate() should be
419 called by the ruler. That is so because the display is switched according
420 to the settings and the system.
421
422- For example, while dragging Tabs and Indents, the old positions should
423 also be shown if possible. For that, while setting the Tabs and Indents,
424 the old positions should be inserted first into the array in addition
425 and be linked with the style RULER_STYLE_DONTKNOW. After that, the
426 remaining values should be set in the array.
427
428- In case of multiple selected paragraphs and table cells, the Tabs and
429 Indents should be displayed in grey in front of the first cell resp.
430 the first paragraph. This can also be achieved by the style
431 RULER_STYLE_DONTKNOW.
432
433- The measuring arrow should always be shown when the Alt key (WW-Like)
434 is pressed during the drag. Maybe, this setting should be configurable
435 always and possibly the measuring arrows always be shown while
436 dragging. For all settings, the values should always be rounded to the
437 multiple of one value because the screen resolution is very imprecise.
438
439- DoubleClicks should be handled in the following way (GetClickType()):
440 - RulerType::DontKnow
441 RulerType::Margin1
442 RulerType::Margin2
443 If the conditions GetClickPos() <= GetMargin1() or
444 GetClickPos() >= GetMargin2() are met or the type is equal to
445 RulerType::Margin1 or RulerType::Margin2, a side dialog should
446 be displayed in which the focus is at the respective border.
447 - RulerType::Border
448 A column or table dialog should be shown in which the focus
449 is at the respective column that can be queried using
450 GetClickAryPos().
451 - RulerType::Indent
452 The dialog, in which the indents can be configured, should be
453 shown. In this, the focus should be on the indent which can
454 be queried using GetClickAryPos().
455 - RulerType::Tab
456 A TabDialog should be displayed in which the Tab, that can be
457 queried using GetClickAryPos(), should be selected.
458
459*************************************************************************/
460
461
462constexpr WinBits WB_EXTRAFIELD = 0x00004000;
463constexpr WinBits WB_RIGHT_ALIGNED = 0x00008000;
464constexpr auto WB_STDRULER = WB_HORZ;
465
466
469 Border, Indent, Tab };
470
472
473constexpr sal_uInt16 RULER_STYLE_HIGHLIGHT = 0x8000;
474constexpr sal_uInt16 RULER_STYLE_DONTKNOW = 0x4000;
475constexpr sal_uInt16 RULER_STYLE_INVISIBLE = 0x2000;
476
477enum class RulerDragSize {
478 Move,
479 N1,
480 N2
481};
482
483constexpr auto RULER_MOUSE_BORDERMOVE = 5;
484constexpr auto RULER_MOUSE_BORDERWIDTH = 5;
485constexpr auto RULER_MOUSE_MARGINWIDTH = 3;
486
487
489 NONE = 0x0000,
490 Sizeable = 0x0001,
491 Invisible = 0x0002
492};
493namespace o3tl {
494 template<> struct typed_flags<RulerMarginStyle> : is_typed_flags<RulerMarginStyle, 0x0003> {};
495}
496
497
499 Sizeable = 0x0001,
500 Moveable = 0x0002,
501 Variable = 0x0004,
502 Invisible = 0x0008
503};
504namespace o3tl {
505 template<> struct typed_flags<RulerBorderStyle> : is_typed_flags<RulerBorderStyle, 0x000f> {};
506}
507
509{
513 tools::Long nMinPos; //minimum/maximum position, supported for table borders/rows
515};
516
518 Top, Bottom
519};
520
522{
526};
527
528
529constexpr sal_uInt16 RULER_TAB_LEFT = 0x0000;
530constexpr sal_uInt16 RULER_TAB_RIGHT = 0x0001;
531constexpr sal_uInt16 RULER_TAB_CENTER = 0x0002;
532constexpr sal_uInt16 RULER_TAB_DECIMAL = 0x0003;
533constexpr sal_uInt16 RULER_TAB_DEFAULT = 0x0004;
534constexpr sal_uInt16 RULER_TAB_STYLE = 0x000F;
535constexpr sal_uInt16 RULER_TAB_RTL = 0x0010;
536
538{
540 sal_uInt16 nStyle;
541};
542
543
545{
547};
548
549
551{
554 sal_uInt16 nAryPos;
556 bool bSize;
559
561 : nPos(0)
563 , nAryPos(0)
565 , bSize(false)
566 , bSizeBar(false)
567 , bExpandTest( false )
568 {}
569};
570
571
573{
574 MapUnit eMapUnit; // MAP_UNIT for calculation
575 tools::Long nTickUnit; // Unit divider
576 double nTick1; // Minimal step
577 double nTick2; // Tick quarter unit
578 double nTick3; // Tick half unit
579 double nTick4; // Tick whole unit
580 char aUnitStr[8]; // Unit string
581};
582
583
584// Data for drawing ruler tabstops
586{
587 sal_uInt16 DPIScaleFactor;
588 sal_uInt16 width;
589 sal_uInt16 height;
590 sal_uInt16 height2;
591 sal_uInt16 width2;
592 sal_uInt16 cwidth;
593 sal_uInt16 cwidth2;
594 sal_uInt16 cwidth3;
595 sal_uInt16 cwidth4;
596 sal_uInt16 dheight;
597 sal_uInt16 dheight2;
598 sal_uInt16 dwidth;
599 sal_uInt16 dwidth2;
600 sal_uInt16 dwidth3;
601 sal_uInt16 dwidth4;
602 sal_uInt16 textoff;
603};
604
605
606class ImplRulerData;
607
609{
610private:
624 std::unique_ptr<ImplRulerData> mpSaveData;
626 std::unique_ptr<ImplRulerData> mpDragData;
629 sal_uInt16 mnUnitIndex;
630 sal_uInt16 mnDragAryPos;
632 sal_uInt16 mnDragModifier;
633 sal_uInt16 mnExtraStyle;
636
641 bool mbCalc;
643 bool mbDrag;
649
651
653
654 std::unique_ptr<RulerSelection> mxCurrentHitTest;
655 std::unique_ptr<RulerSelection> mxPreviousHitTest;
656
658
659 std::map<OUString, SalLayoutGlyphs> maTextGlyphs;
660
661 SVT_DLLPRIVATE void ImplVDrawLine(vcl::RenderContext& rRenderContext, tools::Long nX1, tools::Long nY1, tools::Long nX2, tools::Long nY2 );
662 SVT_DLLPRIVATE void ImplVDrawRect(vcl::RenderContext& rRenderContext, tools::Long nX1, tools::Long nY1, tools::Long nX2, tools::Long nY2 );
663 SVT_DLLPRIVATE void ImplVDrawText(vcl::RenderContext& rRenderContext, tools::Long nX, tools::Long nY, const OUString& rText,
664 tools::Long nMin = LONG_MIN, tools::Long nMax = LONG_MAX );
665
666 SVT_DLLPRIVATE void ImplDrawTicks(vcl::RenderContext& rRenderContext,
667 tools::Long nMin, tools::Long nMax, tools::Long nStart, tools::Long nVirTop, tools::Long nVirBottom);
668 SVT_DLLPRIVATE void ImplDrawBorders(vcl::RenderContext& rRenderContext,
669 tools::Long nMin, tools::Long nMax, tools::Long nVirTop, tools::Long nVirBottom);
670 SVT_DLLPRIVATE static void ImplDrawIndent(vcl::RenderContext& rRenderContext,
671 const tools::Polygon& rPoly, bool bIsHit);
672 SVT_DLLPRIVATE void ImplDrawIndents(vcl::RenderContext& rRenderContext,
673 tools::Long nMin, tools::Long nMax, tools::Long nVirTop, tools::Long nVirBottom);
674 SVT_DLLPRIVATE void ImplDrawTab(vcl::RenderContext& rRenderContext, const Point& rPos, sal_uInt16 nStyle);
675 SVT_DLLPRIVATE void ImplDrawTabs(vcl::RenderContext& rRenderContext,
676 tools::Long nMin, tools::Long nMax, tools::Long nVirTop, tools::Long nVirBottom);
677
678 using Window::ImplInit;
679 SVT_DLLPRIVATE void ImplInit( WinBits nWinBits );
680 SVT_DLLPRIVATE void ImplInitSettings( bool bFont, bool bForeground, bool bBackground );
681 SVT_DLLPRIVATE void ImplCalc();
682 SVT_DLLPRIVATE void ImplFormat(vcl::RenderContext const & rRenderContext);
683 SVT_DLLPRIVATE void ImplInitExtraField( bool bUpdate );
684 SVT_DLLPRIVATE void ImplInvertLines(vcl::RenderContext& rRenderContext);
685 SVT_DLLPRIVATE void ImplDraw(vcl::RenderContext& rRenderContext);
686 SVT_DLLPRIVATE void ImplDrawExtra(vcl::RenderContext& rRenderContext);
687 SVT_DLLPRIVATE void ImplUpdate( bool bMustCalc = false );
688
689 virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
690
691 SVT_DLLPRIVATE bool ImplDoHitTest( const Point& rPosition,
692 RulerSelection* pHitTest,
693 bool bRequiredStyle = false,
694 RulerIndentStyle nRequiredStyle = RulerIndentStyle::Top ) const;
695 SVT_DLLPRIVATE bool ImplDocHitTest( const Point& rPos, RulerType eDragType, RulerSelection* pHitTest ) const;
696 SVT_DLLPRIVATE bool ImplStartDrag( RulerSelection const * pHitTest, sal_uInt16 nModifier );
697 SVT_DLLPRIVATE void ImplDrag( const Point& rPos );
698 SVT_DLLPRIVATE void ImplEndDrag();
699
700 Ruler (const Ruler &) = delete;
701 Ruler& operator= (const Ruler &) = delete;
702
703protected:
704 tools::Long GetRulerVirHeight() const { return mnVirHeight;}
705 const MapMode& GetCurrentMapMode() const { return maMapMode; }
706 const RulerUnitData& GetCurrentRulerUnit() const;
707
708public:
709 Ruler( vcl::Window* pParent, WinBits nWinStyle = WB_STDRULER );
710 virtual ~Ruler() override;
711 virtual void dispose() override;
712
713 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
714 virtual void MouseMove( const MouseEvent& rMEvt ) override;
715 virtual void Tracking( const TrackingEvent& rTEvt ) override;
716 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
717 virtual void Resize() override;
718 virtual void StateChanged( StateChangedType nStateChange ) override;
719 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
720
721 virtual bool StartDrag();
722 virtual void Drag();
723 virtual void EndDrag();
724 virtual void Click();
725 void DoubleClick();
726 virtual void ExtraDown();
727
728 void Activate() override;
729 void Deactivate() override;
730
731 void SetWinPos( tools::Long nOff, tools::Long nWidth = 0 );
732 tools::Long GetWinOffset() const { return mnWinOff; }
733 void SetPagePos( tools::Long nOff = 0, tools::Long nWidth = 0 );
734 tools::Long GetPageOffset() const;
735 void SetBorderPos( tools::Long nOff = 0 );
736 tools::Long GetBorderOffset() const { return mnBorderOff; }
737 const tools::Rectangle& GetExtraRect() const { return maExtraRect; }
738
739 void SetUnit( FieldUnit eNewUnit );
740 FieldUnit GetUnit() const { return meUnit; }
741 void SetZoom( const Fraction& rNewZoom );
742
743 void SetExtraType( RulerExtra eNewExtraType, sal_uInt16 nStyle = 0 );
744
745 bool StartDocDrag( const MouseEvent& rMEvt,
746 RulerType eDragType );
747 RulerType GetDragType() const { return meDragType; }
748 tools::Long GetDragPos() const { return mnDragPos; }
749 sal_uInt16 GetDragAryPos() const { return mnDragAryPos; }
750 RulerDragSize GetDragSize() const { return mnDragSize; }
751 bool IsDragDelete() const { return mbDragDelete; }
752 bool IsDragCanceled() const { return mbDragCanceled; }
753 sal_uInt16 GetDragModifier() const { return mnDragModifier; }
754 bool IsDrag() const { return mbDrag; }
755 void CancelDrag();
756 tools::Long GetClickPos() const { return mnDragPos; }
757 RulerType GetClickType() const { return meDragType; }
758
759 const RulerSelection& GetHoverSelection() const { return maHoverSelection; }
760
761 RulerType GetRulerType( const Point& rPos, sal_uInt16* pAryPos = nullptr );
762
763 void SetNullOffset( tools::Long nPos );
764 tools::Long GetNullOffset() const;
766 void SetMargin1( tools::Long nPos, RulerMarginStyle nMarginStyle = RulerMarginStyle::Sizeable );
767 tools::Long GetMargin1() const;
769 void SetMargin2( tools::Long nPos, RulerMarginStyle nMarginStyle = RulerMarginStyle::Sizeable );
770 tools::Long GetMargin2() const;
771
772 void SetLeftFrameMargin( tools::Long nPos );
773 void SetRightFrameMargin( tools::Long nPos );
774 void SetLines( sal_uInt32 n = 0, const RulerLine* pLineAry = nullptr );
775 void SetBorders( sal_uInt32 n = 0, const RulerBorder* pBrdAry = nullptr );
776 void SetIndents( sal_uInt32 n = 0, const RulerIndent* pIndentAry = nullptr );
777
778 void SetTabs( sal_uInt32 n = 0, const RulerTab* pTabAry = nullptr );
779 const std::vector<RulerTab>& GetTabs() const;
780
781 static void DrawTab(vcl::RenderContext& rRenderContext, const Color &rFillColor,
782 const Point& rPos, sal_uInt16 nStyle);
783
784 void SetStyle( WinBits nStyle );
785 WinBits GetStyle() const { return mnWinStyle; }
786
787 void SetDoubleClickHdl( const Link<Ruler*,void>& rLink ) { maDoubleClickHdl = rLink; }
788
789 void SetTextRTL(bool bRTL);
790 bool GetTextRTL() const;
791 void SetCharWidth( tools::Long nWidth ) { mnCharWidth = nWidth ; }
792 void SetLineHeight( tools::Long nHeight ) { mnLineHeight = nHeight ; }
793
794 void DrawTicks();
795
796 virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
797};
798
799/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: ruler.hxx:609
tools::Long mnVirWidth
Definition: ruler.hxx:619
tools::Long mnBorderOff
Definition: ruler.hxx:613
bool mbActive
Definition: ruler.hxx:647
RulerExtra meExtraType
Definition: ruler.hxx:637
Fraction maZoom
Definition: ruler.hxx:640
sal_uInt8 mnUpdateFlags
Definition: ruler.hxx:648
const MapMode & GetCurrentMapMode() const
Definition: ruler.hxx:705
bool mbFormat
Definition: ruler.hxx:642
sal_uInt16 GetDragModifier() const
Definition: ruler.hxx:753
RulerDragSize mnDragSize
Definition: ruler.hxx:631
sal_uInt16 mnDragModifier
Definition: ruler.hxx:632
bool IsDragCanceled() const
Definition: ruler.hxx:752
RulerType GetDragType() const
Definition: ruler.hxx:747
bool mbDragCanceled
Definition: ruler.hxx:645
bool IsDrag() const
Definition: ruler.hxx:754
const RulerSelection & GetHoverSelection() const
Definition: ruler.hxx:759
std::unique_ptr< RulerSelection > mxPreviousHitTest
Definition: ruler.hxx:655
tools::Long mnDragPos
Definition: ruler.hxx:623
bool mbDragDelete
Definition: ruler.hxx:644
ScopedVclPtr< VirtualDevice > maVirDev
Definition: ruler.hxx:611
tools::Long GetBorderOffset() const
Definition: ruler.hxx:736
bool mbDrag
Definition: ruler.hxx:643
void SetMargin2()
Definition: ruler.hxx:768
tools::Long GetClickPos() const
Definition: ruler.hxx:756
bool IsDragDelete() const
Definition: ruler.hxx:751
Ruler(const Ruler &)=delete
tools::Long mnWidth
Definition: ruler.hxx:616
FieldUnit meUnit
Definition: ruler.hxx:639
WinBits GetStyle() const
Definition: ruler.hxx:785
tools::Long mnVirHeight
Definition: ruler.hxx:620
tools::Long mnWinWidth
Definition: ruler.hxx:615
std::unique_ptr< RulerSelection > mxCurrentHitTest
Definition: ruler.hxx:654
tools::Long mnHeight
Definition: ruler.hxx:617
std::unique_ptr< ImplRulerData > mpDragData
Definition: ruler.hxx:626
void SetLineHeight(tools::Long nHeight)
Definition: ruler.hxx:792
Link< Ruler *, void > maDoubleClickHdl
Definition: ruler.hxx:652
rtl::Reference< SvtRulerAccessible > mxAccContext
Definition: ruler.hxx:657
tools::Long mnStartDragPos
Definition: ruler.hxx:622
tools::Long mnBorderWidth
Definition: ruler.hxx:621
tools::Long mnWinOff
Definition: ruler.hxx:614
ImplRulerData * mpData
Definition: ruler.hxx:625
void SetMargin1()
Definition: ruler.hxx:765
RulerDragSize GetDragSize() const
Definition: ruler.hxx:750
const tools::Rectangle & GetExtraRect() const
Definition: ruler.hxx:737
void SetCharWidth(tools::Long nWidth)
Definition: ruler.hxx:791
RulerSelection maHoverSelection
Definition: ruler.hxx:650
RulerType GetClickType() const
Definition: ruler.hxx:757
void SetDoubleClickHdl(const Link< Ruler *, void > &rLink)
Definition: ruler.hxx:787
FieldUnit GetUnit() const
Definition: ruler.hxx:740
tools::Rectangle maExtraRect
Definition: ruler.hxx:627
tools::Long GetRulerVirHeight() const
Definition: ruler.hxx:704
tools::Long mnVirOff
Definition: ruler.hxx:618
std::map< OUString, SalLayoutGlyphs > maTextGlyphs
Definition: ruler.hxx:659
sal_uInt16 mnDragAryPos
Definition: ruler.hxx:630
sal_uInt16 mnExtraStyle
Definition: ruler.hxx:633
tools::Long GetWinOffset() const
Definition: ruler.hxx:732
sal_uInt16 GetDragAryPos() const
Definition: ruler.hxx:749
MapMode maMapMode
Definition: ruler.hxx:612
bool mbAutoWinWidth
Definition: ruler.hxx:646
tools::Long mnLineHeight
Definition: ruler.hxx:635
sal_uInt16 mnUnitIndex
Definition: ruler.hxx:629
bool mbCalc
Definition: ruler.hxx:641
tools::Long mnCharWidth
Definition: ruler.hxx:634
WinBits mnWinStyle
Definition: ruler.hxx:628
tools::Long GetDragPos() const
Definition: ruler.hxx:748
std::unique_ptr< ImplRulerData > mpSaveData
Definition: ruler.hxx:624
RulerType meDragType
Definition: ruler.hxx:638
VclReferenceBase & operator=(const VclReferenceBase &)=delete
virtual void dispose() override
void SetStyle(WinBits nStyle)
virtual void StateChanged(StateChangedType nStateChange)
virtual void Tracking(const TrackingEvent &rTEvt)
virtual void Resize()
virtual void MouseButtonDown(const MouseEvent &rMEvt)
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible()
void SetZoom(const Fraction &rZoom)
virtual void MouseMove(const MouseEvent &rMEvt)
virtual void Deactivate()
virtual void DataChanged(const DataChangedEvent &rDCEvt)
virtual void ApplySettings(vcl::RenderContext &rRenderContext)
virtual void Activate()
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, SystemParentData *pSystemParentData)
FieldUnit
MapUnit
NONE
Invisible
long Long
constexpr auto RULER_MOUSE_BORDERMOVE
Definition: ruler.hxx:483
constexpr sal_uInt16 RULER_STYLE_DONTKNOW
Definition: ruler.hxx:474
RulerDragSize
Definition: ruler.hxx:477
constexpr sal_uInt16 RULER_TAB_STYLE
Definition: ruler.hxx:534
constexpr auto WB_STDRULER
Definition: ruler.hxx:464
constexpr sal_uInt16 RULER_TAB_CENTER
Definition: ruler.hxx:531
constexpr auto RULER_MOUSE_BORDERWIDTH
Definition: ruler.hxx:484
constexpr WinBits WB_EXTRAFIELD
Definition: ruler.hxx:462
RulerIndentStyle
Definition: ruler.hxx:517
RulerMarginStyle
Definition: ruler.hxx:488
constexpr sal_uInt16 RULER_TAB_DEFAULT
Definition: ruler.hxx:533
constexpr sal_uInt16 RULER_TAB_RIGHT
Definition: ruler.hxx:530
constexpr sal_uInt16 RULER_STYLE_HIGHLIGHT
Definition: ruler.hxx:473
constexpr sal_uInt16 RULER_STYLE_INVISIBLE
Definition: ruler.hxx:475
RulerExtra
Definition: ruler.hxx:471
constexpr sal_uInt16 RULER_TAB_RTL
Definition: ruler.hxx:535
constexpr sal_uInt16 RULER_TAB_LEFT
Definition: ruler.hxx:529
constexpr WinBits WB_RIGHT_ALIGNED
Definition: ruler.hxx:463
RulerType
Definition: ruler.hxx:467
constexpr auto RULER_MOUSE_MARGINWIDTH
Definition: ruler.hxx:485
constexpr sal_uInt16 RULER_TAB_DECIMAL
Definition: ruler.hxx:532
RulerBorderStyle
Definition: ruler.hxx:498
tools::Long nMinPos
Definition: ruler.hxx:513
tools::Long nMaxPos
Definition: ruler.hxx:514
tools::Long nPos
Definition: ruler.hxx:510
tools::Long nWidth
Definition: ruler.hxx:511
RulerBorderStyle nStyle
Definition: ruler.hxx:512
RulerIndentStyle nStyle
Definition: ruler.hxx:524
bool bInvisible
Definition: ruler.hxx:525
tools::Long nPos
Definition: ruler.hxx:523
tools::Long nPos
Definition: ruler.hxx:546
bool bSizeBar
Definition: ruler.hxx:557
tools::Long nPos
Definition: ruler.hxx:552
RulerDragSize mnDragSize
Definition: ruler.hxx:555
sal_uInt16 nAryPos
Definition: ruler.hxx:554
bool bExpandTest
Definition: ruler.hxx:558
RulerType eType
Definition: ruler.hxx:553
sal_uInt16 dwidth
Definition: ruler.hxx:598
sal_uInt16 dwidth3
Definition: ruler.hxx:600
sal_uInt16 dwidth4
Definition: ruler.hxx:601
sal_uInt16 width2
Definition: ruler.hxx:591
sal_uInt16 cwidth2
Definition: ruler.hxx:593
sal_uInt16 textoff
Definition: ruler.hxx:602
sal_uInt16 cwidth
Definition: ruler.hxx:592
sal_uInt16 height
Definition: ruler.hxx:589
sal_uInt16 cwidth3
Definition: ruler.hxx:594
sal_uInt16 dwidth2
Definition: ruler.hxx:599
sal_uInt16 width
Definition: ruler.hxx:588
sal_uInt16 height2
Definition: ruler.hxx:590
sal_uInt16 cwidth4
Definition: ruler.hxx:595
sal_uInt16 DPIScaleFactor
Definition: ruler.hxx:587
sal_uInt16 dheight2
Definition: ruler.hxx:597
sal_uInt16 dheight
Definition: ruler.hxx:596
tools::Long nPos
Definition: ruler.hxx:539
sal_uInt16 nStyle
Definition: ruler.hxx:540
double nTick2
Definition: ruler.hxx:577
tools::Long nTickUnit
Definition: ruler.hxx:575
MapUnit eMapUnit
Definition: ruler.hxx:574
double nTick1
Definition: ruler.hxx:576
char aUnitStr[8]
Definition: ruler.hxx:580
double nTick4
Definition: ruler.hxx:579
double nTick3
Definition: ruler.hxx:578
#define SVT_DLLPUBLIC
Definition: svtdllapi.h:27
#define SVT_DLLPRIVATE
Definition: svtdllapi.h:29
unsigned char sal_uInt8
StateChangedType
sal_Int64 WinBits
WinBits const WB_HORZ