Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _RULER_HXX
30 : : #define _RULER_HXX
31 : :
32 : : #include "svtools/svtdllapi.h"
33 : : #include <tools/link.hxx>
34 : : #include <vcl/window.hxx>
35 : : #include <vcl/virdev.hxx>
36 : : #include <vcl/field.hxx>
37 : :
38 : : class MouseEvent;
39 : : class TrackingEvent;
40 : : class DataChangedEvent;
41 : :
42 : : /*************************************************************************
43 : :
44 : : Description
45 : : ============
46 : :
47 : : class Ruler
48 : :
49 : : This class is used for displaying a ruler, but it can also be used
50 : : for setting or moving tabs and margins.
51 : :
52 : : --------------------------------------------------------------------------
53 : :
54 : : WinBits
55 : :
56 : : WB_HORZ ruler is displayed horizontally
57 : : WB_VERT ruler is displayed vertically
58 : : WB_3DLOOK 3D look
59 : : WB_BORDER border at the bottom/right margin
60 : : WB_EXTRAFIELD Field in the upper left corner for
61 : : displaying and selecting tabs, origin of coordinates, ...
62 : : WB_RIGHT_ALIGNED Marks the vertical ruler as right aligned
63 : :
64 : : --------------------------------------------------------------------------
65 : :
66 : : All ruler parameters are set in pixel units. This way double conversions
67 : : and rounding errors are avoided and the ruler displays the margins
68 : : at their actual position in the document. Because of this, the application can,
69 : : for example in tables, do its own roundings and the positions on the ruler will
70 : : still match those in the document. However, for the ruler to know how the
71 : : document is displayed on the screen, some additional values have to be configured
72 : :
73 : : SetWinPos() sets the offset of the ruler's edit window. In doing so,
74 : : the width of the window can also be configured. If there is a 0 among the
75 : : values passed to the function, the position/width is automatically set to
76 : : the width of the ruler.
77 : :
78 : : SetPagePos() sets the offset of the page relative to the edit window and the
79 : : width of the page. If there is a 0 among the values passed to the function,
80 : : the position/width is automatically set as if the page filled the whole edit window.
81 : :
82 : : SetBorderPos() sets the offset of the border. The position is relative to
83 : : the upper/left margin of the window. This is needed when there are a horizontal
84 : : and a vertical ruler visible at the same time. Example:
85 : : aHRuler.SetBorderPos( aVRuler.GetSizePixel().Width()-1 );
86 : :
87 : : SetNullOffset() sets the origin relative to the page.
88 : :
89 : : All the other values (margins, indentation, tabs, ...) refer to the origin,
90 : : which is set with SetNullOffset().
91 : :
92 : : The values are computed as described below:
93 : :
94 : : - WinPos (if both windows have the same parent)
95 : :
96 : : Point aHRulerPos = aHRuler.GetPosPixel();
97 : : Point aEditWinPos = aEditWin.GetPosPixel();
98 : : aHRuler.SetWinPos( aEditWinPos().X() - aHRulerPos.X() );
99 : :
100 : : - PagePos
101 : :
102 : : Point aPagePos = aEditWin.LogicToPixel( aEditWin.GetPagePos() );
103 : : aHRuler.SetPagePos( aPagePos().X() );
104 : :
105 : : - All other values
106 : :
107 : : Add the logical values, recompute as position and subtract the
108 : : previously saved pixel positions (of PagePos and Null Offset).
109 : :
110 : : --------------------------------------------------------------------------
111 : :
112 : : SetUnit() and SetZoom() configure which unit is used to display
113 : : the values on the ruler. The following units are accepted:
114 : :
115 : : FUNIT_MM
116 : : FUNIT_CM (Default)
117 : : FUNIT_M
118 : : FUNIT_KM
119 : : FUNIT_INCH
120 : : FUNIT_FOOT
121 : : FUNIT_MILE
122 : : FUNIT_POINT
123 : : FUNIT_PICA
124 : :
125 : : --------------------------------------------------------------------------
126 : :
127 : : SetMargin1() sets the upper/left margin and SetMargin2() sets the
128 : : bottom/right margin. If these methods are called whithout arguments,
129 : : no margins are displayed. Otherwise, the following arguments can be passed:
130 : :
131 : : long nPos - offset in pixels relative to the origin
132 : : sal_uInt16 nStyle - bit style:
133 : : RULER_MARGIN_SIZEABLE
134 : : margin size can be changed
135 : :
136 : : The following bits can be set in addition
137 : : to these styles:
138 : : RULER_STYLE_INVISIBLE
139 : :
140 : :
141 : : SetBorders() sets an array of margins. To do this, an array of type RulerBorder
142 : : has to be passed. In the array, the following values have to be initialized:
143 : :
144 : : long nPos - offset in pixels relative to the origin
145 : : long nWidth - column spacing in pixels (can also be 0, for example,
146 : : for table columns)
147 : : sal_uInt16 nStyle - bit style:
148 : : RULER_BORDER_SIZEABLE
149 : : Column spacing can be changed. This flag should
150 : : only be set if the size of the spacing is changed,
151 : : not that of a cell.
152 : : RULER_BORDER_MOVEABLE
153 : : Column spacing/border can be moved. Whenever
154 : : table borders are to be moved, this flag should
155 : : be set instead of SIZEABLE (SIZEABLE indicates
156 : : that the size of a spacing, not that of a single
157 : : cell can be changed).
158 : : RULER_BORDER_VARIABLE
159 : : Not all of the column spacings are equal
160 : : RULER_BORDER_TABLE
161 : : Table border. Whenever this style ist set, the column
162 : : width must be 0.
163 : : RULER_BORDER_SNAP
164 : : Auxiliary line. Whenever this style is set, the
165 : : column width must be 0.
166 : : RULER_BORDER_MARGIN
167 : : Margin. Whenever this style is set, the column
168 : : width must be 0.
169 : :
170 : : The following bits can be set in addition
171 : : to these styles:
172 : : RULER_STYLE_INVISIBLE
173 : :
174 : : SetIndents() sets an array of indents. This method may only be used for horizontal
175 : : rulers. A Ruler Indent must be passed as an argument, with the following values
176 : : initialized:
177 : :
178 : : long nPos - offset relative to the origin in pixels
179 : : sal_uInt16 nStyle - bit style:
180 : : RULER_INDENT_TOP (indent of the first line)
181 : : RULER_INDENT_BOTTOM (left/right indent)
182 : : RULER_INDENT_BORDER (Vertical line that shows the border distance)
183 : : The following bits can be set in addition
184 : : to these styles:
185 : : RULER_STYLE_DONTKNOW (for old position or for
186 : : ambiguity)
187 : : RULER_STYLE_INVISIBLE
188 : :
189 : : SetTabs() sets an array of tabs. This method may only be used for horizontal rulers.
190 : : An array of type RulerTab must be passed as an argument, with the following values
191 : : initialized:
192 : :
193 : : long nPos - offset relative to the origin in pixels
194 : : sal_uInt16 nStyle - bit style:
195 : : RULER_TAB_DEFAULT (can't be selected)
196 : : RULER_TAB_LEFT
197 : : RULER_TAB_CENTER
198 : : RULER_TAB_RIGHT
199 : : RULER_TAB_DECIMAL
200 : : The following bits can be set in addition
201 : : to these styles:
202 : : RULER_STYLE_DONTKNOW (for old position of for
203 : : ambiguity)
204 : : RULER_STYLE_INVISIBLE
205 : :
206 : : SetLines() displays position lines in the ruler. An array of type RulerLine must be passed, with
207 : : the following values initialized:
208 : :
209 : : long nPos - offset relative to the origin in pixels
210 : : sal_uInt16 nStyle - bit style (has to be 0 currently)
211 : :
212 : : --------------------------------------------------------------------------
213 : :
214 : : If the user should also be able to change the margins tabs, borders, ...
215 : : in the ruler, a bit more effort is necessary. In this case, the StartDrag(),
216 : : Drag() and EndDrag() methods have to be overridden. For the StartDrag() method
217 : : it is possible to prevent dragging by returning FALSE. In the drag handler,
218 : : the drag position must be queried and the values must be moved to the new
219 : : position. This is done by calling the particular Set methods. While in the
220 : : drag handler, the values are just cached and only afterward the ruler is redrawn.
221 : : All the handlers can also be set as links with the particular Set..Hdl() methods.
222 : :
223 : : - StartDrag()
224 : : Is called when dragging is started. If FALSE is returned, the dragging.
225 : : won't be executed. If TRUE is returned, the dragging will be permitted.
226 : : If the handler isn't overridden, FALSE will be returned.
227 : :
228 : : - EndDrag()
229 : : Is called at the end of dragging.
230 : :
231 : : - Drag()
232 : : Is called when dragging takes place.
233 : :
234 : : - Click()
235 : : This handler is called when no element has been clicked on.
236 : : The position can be queried with GetClickPos(). This way it is possible
237 : : to, for example, ser tabs in the ruler. After calling the click handler,
238 : : the drag, if any, is immediately triggered. This makes it possible to
239 : : set a new tab in the click handler and then immediately move it.
240 : :
241 : : - DoubleClick()
242 : : This handler is called when a double-click has been performed outside
243 : : the special panel. The methods GetClickType(), GetClickAryPos() and
244 : : GetClickPos() can be used to query what has been clicked on.
245 : : This way you can, for example, show the tab dialog when a double-click
246 : : is performed on a tab.
247 : :
248 : : In the drag handler it is possible to query what has been dragged and where
249 : : it has been dragged. There are the following query methods:
250 : :
251 : : - GetDragType()
252 : : Returns what has been dragged.
253 : : RULER_TYPE_MARGIN1
254 : : RULER_TYPE_MARGIN2
255 : : RULER_TYPE_BORDER
256 : : RULER_TYPE_INDENT
257 : : RULER_TYPE_TAB
258 : :
259 : : - GetDragPos()
260 : : Returns the pixel position to which the user has moved the mouse
261 : : relative to the set zero-offset.
262 : :
263 : : - GetDragAryPos()
264 : : Liefert den Index im Array zurueck, wenn ein Border, Indent oder ein
265 : : Tab gedragt wird. Achtung: Es wird die Array-Position waehrend des
266 : : gesammten Drag-Vorgangs von dem Item im Array was vor dem Drag gesetzt
267 : : war zurueckgeben. Dadurch ist es zum Beispiel auch moeglich, einen
268 : : Tab nicht mehr anzuzeigen, wenn die Maus nach unten/rechts aus dem
269 : : Lineal gezogen wird.
270 : :
271 : : - GetDragSize()
272 : : Wenn Borders gedragt werden, kann hierueber abgefragt werden, ob
273 : : die Groesse bzw. welche Seite oder die Position geaendert werden soll.
274 : : RULER_DRAGSIZE_MOVE oder 0 - Move
275 : : RULER_DRAGSIZE_1 - Linke/obere Kante
276 : : RULER_DRAGSIZE_2 - Rechte/untere Kante
277 : :
278 : : - IsDragDelete()
279 : : Mit dieser Methode kann abgefragt werden, ob beim Draggen die
280 : : Maus unten/rechts aus dem Fenster gezogen wurde. Damit kann
281 : : zum Beispiel festgestellt werden, ob der Benutzer einen Tab
282 : : loeschen will.
283 : :
284 : : - IsDragCanceled()
285 : : Mit dieser Methode kann im EndDrag-Handler abgefragt werden,
286 : : ob die Aktion abgebrochen wurde, indem der Anwender die
287 : : Maus oben/links vom Fenster losgelassen hat oder ESC gedrueckt
288 : : hat. In diesem Fall werden die Werte nicht uebernommen. Wird
289 : : waehrend des Draggings die Maus oben/links aus dem Fenster
290 : : gezogen, werden automatisch die alten Werte dargestellt, ohne das
291 : : der Drag-Handler gerufen wird.
292 : : Falls der Benutzer jedoch den Wert auf die alte Position
293 : : zurueckgeschoben hat, liefert die Methode trotzdem sal_False. Falls
294 : : dies vermieden werden soll, muss sich die Applikation im StartDrag-
295 : : Handler den alten Wert merken und im EndDrag-Handler den Wert
296 : : vergleichen.
297 : :
298 : : - GetDragScroll()
299 : : Mit dieser Methode kann abgefragt werden, ob gescrollt werden
300 : : soll. Es wird einer der folgenden Werte zurueckgegeben:
301 : : RULER_SCROLL_NO - Drag-Position befindet sich
302 : : an keinem Rand und somit
303 : : muss nicht gescrollt werden.
304 : : RULER_SCROLL_1 - Drag-Position befindet sich
305 : : am linken/oberen Rand und
306 : : somit sollte das Programm evt.
307 : : ein Srcoll ausloesen.
308 : : RULER_SCROLL_2 - Drag-Position befindet sich
309 : : am rechten/unteren Rand und
310 : : somit sollte das Programm evt.
311 : : ein Srcoll ausloesen.
312 : :
313 : : - GetDragModifier()
314 : : Liefert die Modifier-Tasten zurueck, die beim Starten des Drag-
315 : : Vorgangs gedrueckt waren. Siehe MouseEvent.
316 : :
317 : : - GetClickPos()
318 : : Liefert die Pixel-Position bezogen auf den eingestellten Null-Offset
319 : : zurueck, wo der Anwender die Maus gedrueckt hat.
320 : :
321 : : - GetClickType()
322 : : Liefert zurueck, was per DoubleClick betaetigt wird:
323 : : RULER_TYPE_DONTKNOW (kein Element im Linealbereich)
324 : : RULER_TYPE_OUTSIDE (ausserhalb des Linealbereichs)
325 : : RULER_TYPE_MARGIN1 (nur Margin1-Kante)
326 : : RULER_TYPE_MARGIN2 (nur Margin2-Kante)
327 : : RULER_TYPE_BORDER (Border: GetClickAryPos())
328 : : RULER_TYPE_INDENT (Einzug: GetClickAryPos())
329 : : RULER_TYPE_TAB (Tab: GetClickAryPos())
330 : :
331 : : - GetClickAryPos()
332 : : Liefert den Index im Array zurueck, wenn ein Border, Indent oder ein
333 : : Tab per DoubleClick betaetigt wird.
334 : :
335 : : - GetType()
336 : : Mit dieser Methode kann man einen HitTest durchfuehren, um
337 : : gegebenenfalls ueber das Abfangen des MouseButtonDown-Handlers
338 : : auch ueber die rechte Maustaste etwas auf ein Item anzuwenden. Als
339 : : Paramter ueber gibt man die Fensterposition und gegebenenfalls
340 : : einen Pointer auf einen sal_uInt16, um die Array-Position eines
341 : : Tabs, Indent oder Borders mitzubekommen. Als Type werden folgende
342 : : Werte zurueckgegeben:
343 : : RULER_TYPE_DONTKNOW (kein Element im Linealbereich)
344 : : RULER_TYPE_OUTSIDE (ausserhalb des Linealbereichs)
345 : : RULER_TYPE_MARGIN1 (nur Margin1-Kante)
346 : : RULER_TYPE_MARGIN2 (nur Margin2-Kante)
347 : : RULER_TYPE_BORDER (Border: GetClickAryPos())
348 : : RULER_TYPE_INDENT (Einzug: GetClickAryPos())
349 : : RULER_TYPE_TAB (Tab: GetClickAryPos())
350 : :
351 : : Wenn der Drag-Vorgang abgebrochen werden soll, kann der Drag-Vorgang
352 : : mit CancelDrag() abgebrochen werden. Folgende Methoden gibt es fuer die
353 : : Drag-Steuerung:
354 : :
355 : : - IsDrag()
356 : : Liefert sal_True zurueck, wenn sich das Lineal im Drag-Vorgang befindet.
357 : :
358 : : - CancelDrag()
359 : : Bricht den Drag-Vorgang ab, falls einer durchgefuehrt wird. Dabei
360 : : werden die alten Werte wieder hergestellt und der Drag und der
361 : : EndDrag-Handler gerufen.
362 : :
363 : : Um vom Dokument ein Drag auszuloesen, gibt es folgende Methoden:
364 : :
365 : : - StartDocDrag()
366 : : Dieser Methode werden der MouseEvent vom Dokumentfenster und
367 : : was gedragt werden soll uebergeben. Wenn als DragType
368 : : RULER_TYPE_DONTKNOW uebergeben wird, bestimmt das Lineal, was
369 : : verschoben werden soll. Bei den anderen, wird der Drag nur dann
370 : : gestartet, wenn auch an der uebergebenen Position ein entsprechendes
371 : : Element gefunden wurde. Dies ist zun Beispiel dann notwendig, wenn
372 : : zum Beispiel Einzuege und Spalten an der gleichen X-Position liegen.
373 : : Der Rueckgabewert gibt an, ob der Drag ausgeloest wurde. Wenn ein
374 : : Drag ausgeloest wird, uebernimmt das Lineal die normale Drag-Steuerung
375 : : und verhaelt sich dann so, wie als wenn direkt in das Lineal geklickt
376 : : wurde. So captured das Lineal die Mouse und uebernimmt auch die
377 : : Steuerung des Cancel (ueber Tastatur, oder wenn die Mouse ueber
378 : : oder links vom Lineal ruasgeschoben wird). Auch alle Handler werden
379 : : gerufen (inkl. des StartDrag-Handlers). Wenn ein MouseEvent mit
380 : : Click-Count 2 uebergeben wird auch der DoubleClick-Handler
381 : : entsprechend gerufen.
382 : :
383 : : --------------------------------------------------------------------------
384 : :
385 : : Fuer das Extra-Feld kann der Inhalt bestimmt werden und es gibt Handler,
386 : : womit man bestimmte Aktionen abfangen kann.
387 : :
388 : : - ExtraDown()
389 : : Dieser Handler wird gerufen, wenn im Extra-Feld die Maus
390 : : gedrueckt wird.
391 : :
392 : : - SetExtraType()
393 : : Mit dieser Methode kann festgelegt werden, was im ExtraFeld
394 : : dargestellt werden soll.
395 : : - ExtraType Was im Extrafeld dargestellt werden soll
396 : : RULER_EXTRA_DONTKNOW (Nichts)
397 : : RULER_EXTRA_NULLOFFSET (Koordinaaten-Kreuz)
398 : : RULER_EXTRA_TAB (Tab)
399 : : - sal_uInt16 nStyle Bitfeld als Style:
400 : : RULER_STYLE_HIGHLIGHT (selektiert)
401 : : RULER_TAB_... (ein Tab-Style)
402 : :
403 : : - GetExtraClick()
404 : : Liefert die Anzahl der Mausclicks zurueck. Dadurch ist es zum
405 : : Beispiel auch moeglich, auch durch einen DoubleClick im Extrafeld
406 : : eine Aktion auszuloesen.
407 : :
408 : : - GetExtraModifier()
409 : : Liefert die Modifier-Tasten zurueck, die beim Klicken in das Extra-
410 : : Feld gedrueckt waren. Siehe MouseEvent.
411 : :
412 : : --------------------------------------------------------------------------
413 : :
414 : : Weitere Hilfsfunktionen:
415 : :
416 : : - static Ruler::DrawTab()
417 : : Mit dieser Methode kann ein Tab auf einem OutputDevice ausgegeben
418 : : werden. Dadurch ist es moeglich, auch in Dialogen die Tabs so
419 : : anzuzeigen, wie Sie im Lineal gemalt werden.
420 : :
421 : : Diese Methode gibt den Tab zentriert an der uebergebenen Position
422 : : aus. Die Groesse der Tabs kann ueber die Defines RULER_TAB_WIDTH und
423 : : RULER_TAB_HEIGHT bestimmt werden.
424 : :
425 : : --------------------------------------------------------------------------
426 : :
427 : : Tips zur Benutzung des Lineals:
428 : :
429 : : - Bei dem Lineal muss weder im Drag-Modus noch sonst das Setzen der Werte
430 : : in SetUpdateMode() geklammert werden. Denn das Lineal sorgt von sich
431 : : aus dafuer, das wenn mehrere Werte gesetzt werden, diese automatisch
432 : : zusammengefast werden und flackerfrei ausgegeben werden.
433 : :
434 : : - Initial sollten beim Lineal zuerst die Groessen, Positionen und Werte
435 : : gesetzt werden, bevor es angezeigt wird. Dies ist deshalb wichtig, da
436 : : ansonsten viele Werte unnoetig berechnet werden.
437 : :
438 : : - Wenn das Dokumentfenster, in dem sich das Lineal befindet aktiv bzw.
439 : : deaktiv wird, sollten die Methoden Activate() und Deactivate() vom
440 : : Lineal gerufen werden. Denn je nach Einstellungen und System wird die
441 : : Anzeige entsprechend umgeschaltet.
442 : :
443 : : - Zum Beispiel sollte beim Drag von Tabs und Einzuegen nach Moeglichkeit die
444 : : alten Positionen noch mit angezeigt werden. Dazu sollte zusaetzlich beim
445 : : Setzen der Tabs und Einzuege als erstes im Array die alten Positionen
446 : : eingetragen werden und mit dem Style RULER_STYLE_DONTKNOW verknuepft
447 : : werden. Danach sollte im Array die restlichen Werte eingetragen werden.
448 : :
449 : : - Bei mehreren markierten Absaetzen und Tabellen-Zellen, sollten die Tabs
450 : : und Einzuege in grau von der ersten Zelle, bzw. vom ersten Absatz
451 : : angezeigt werden. Dies kann man auch ueber den Style RULER_STYLE_DONTKNOW
452 : : erreichen.
453 : :
454 : : - Die Bemassungspfeile sollten immer dann angezeigt, wenn beim Drag die
455 : : Alt-Taste (WW-Like) gedrueckt wird. Vielleicht sollte diese Einstellung
456 : : auch immer vornehmbar sein und vielleicht beim Drag immer die
457 : : Bemassungspfeile dargestellt werden. Bei allen Einstellung sollten die
458 : : Werte immer auf ein vielfaches eines Wertes gerundet werden, da die
459 : : Bildschirmausloesung sehr ungenau ist.
460 : :
461 : : - DoppelKlicks sollten folgendermassen behandelt werden (GetClickType()):
462 : : - RULER_TYPE_DONTKNOW
463 : : RULER_TYPE_MARGIN1
464 : : RULER_TYPE_MARGIN2
465 : : Wenn die Bedingunden GetClickPos() <= GetMargin1() oder
466 : : GetClickPos() >= GetMargin2() oder der Type gleich
467 : : RULER_TYPE_MARGIN1 oder RULER_TYPE_MARGIN2 ist, sollte
468 : : ein SeitenDialog angezeigt werden, wo der Focus auf dem
469 : : entsprechenden Rand steht
470 : : - RULER_TYPE_BORDER
471 : : Es sollte ein Spalten- oder Tabellen-Dialog angezeigt werden,
472 : : wo der Focus auf der entsprechenden Spalte steht, die mit
473 : : GetClickAryPos() abgefragt werden kann.
474 : : - RULER_TYPE_INDENT
475 : : Es sollte der Dialog angezeigt werden, wo die Einzuege eingestellt
476 : : werden koennen. Dabei sollte der Focus auf dem Einzug stehen, der
477 : : mit GetClickAryPos() ermittelt werden kann.
478 : : - RULER_TYPE_TAB
479 : : Es sollte ein TabDialog angezeigt werden, wo der Tab selektiert
480 : : sein sollte, der ueber GetClickAryPos() abgefragt werden kann.
481 : :
482 : : *************************************************************************/
483 : :
484 : : // -----------
485 : : // - WinBits -
486 : : // -----------
487 : :
488 : : #define WB_EXTRAFIELD ((WinBits)0x00004000)
489 : : #define WB_RIGHT_ALIGNED ((WinBits)0x00008000)
490 : : #define WB_STDRULER WB_HORZ
491 : :
492 : : // ---------------
493 : : // - Ruler-Types -
494 : : // ---------------
495 : :
496 : : struct ImplRulerHitTest;
497 : :
498 : : // --------------
499 : : // - Ruler-Type -
500 : : // --------------
501 : :
502 : : enum RulerType { RULER_TYPE_DONTKNOW, RULER_TYPE_OUTSIDE,
503 : : RULER_TYPE_MARGIN1, RULER_TYPE_MARGIN2,
504 : : RULER_TYPE_BORDER, RULER_TYPE_INDENT, RULER_TYPE_TAB };
505 : :
506 : : enum RulerExtra { RULER_EXTRA_DONTKNOW,
507 : : RULER_EXTRA_NULLOFFSET, RULER_EXTRA_TAB };
508 : :
509 : : #define RULER_STYLE_HIGHLIGHT ((sal_uInt16)0x8000)
510 : : #define RULER_STYLE_DONTKNOW ((sal_uInt16)0x4000)
511 : : #define RULER_STYLE_INVISIBLE ((sal_uInt16)0x2000)
512 : :
513 : : #define RULER_DRAGSIZE_MOVE 0
514 : : #define RULER_DRAGSIZE_1 1
515 : : #define RULER_DRAGSIZE_2 2
516 : :
517 : : #define RULER_MOUSE_BORDERMOVE 5
518 : : #define RULER_MOUSE_BORDERWIDTH 5
519 : : #define RULER_MOUSE_MARGINWIDTH 3
520 : :
521 : : #define RULER_SCROLL_NO 0
522 : : #define RULER_SCROLL_1 1
523 : : #define RULER_SCROLL_2 2
524 : :
525 : : // ---------------
526 : : // - RulerMargin -
527 : : // ---------------
528 : :
529 : : #define RULER_MARGIN_SIZEABLE ((sal_uInt16)0x0001)
530 : :
531 : : // ---------------
532 : : // - RulerBorder -
533 : : // ---------------
534 : :
535 : : #define RULER_BORDER_SIZEABLE ((sal_uInt16)0x0001)
536 : : #define RULER_BORDER_MOVEABLE ((sal_uInt16)0x0002)
537 : : #define RULER_BORDER_VARIABLE ((sal_uInt16)0x0004)
538 : : #define RULER_BORDER_TABLE ((sal_uInt16)0x0008)
539 : : #define RULER_BORDER_SNAP ((sal_uInt16)0x0010)
540 : : #define RULER_BORDER_MARGIN ((sal_uInt16)0x0020)
541 : :
542 : : struct RulerBorder
543 : : {
544 : : long nPos;
545 : : long nWidth;
546 : : sal_uInt16 nStyle;
547 : : //minimum/maximum position, supported for table borders/rows
548 : : long nMinPos;
549 : : long nMaxPos;
550 : : };
551 : :
552 : : // ---------------
553 : : // - RulerIndent -
554 : : // ---------------
555 : :
556 : : #define RULER_INDENT_TOP ((sal_uInt16)0x0000)
557 : : #define RULER_INDENT_BOTTOM ((sal_uInt16)0x0001)
558 : : #define RULER_INDENT_BORDER ((sal_uInt16)0x0002)
559 : : #define RULER_INDENT_STYLE ((sal_uInt16)0x000F)
560 : :
561 : : struct RulerIndent
562 : : {
563 : : long nPos;
564 : : sal_uInt16 nStyle;
565 : : };
566 : :
567 : : // ------------
568 : : // - RulerTab -
569 : : // ------------
570 : :
571 : : #define RULER_TAB_LEFT ((sal_uInt16)0x0000)
572 : : #define RULER_TAB_RIGHT ((sal_uInt16)0x0001)
573 : : #define RULER_TAB_DECIMAL ((sal_uInt16)0x0002)
574 : : #define RULER_TAB_CENTER ((sal_uInt16)0x0003)
575 : : #define RULER_TAB_DEFAULT ((sal_uInt16)0x0004)
576 : : #define RULER_TAB_STYLE ((sal_uInt16)0x000F)
577 : : #define RULER_TAB_RTL ((sal_uInt16)0x0010)
578 : :
579 : : struct RulerTab
580 : : {
581 : : long nPos;
582 : : sal_uInt16 nStyle;
583 : : };
584 : :
585 : : #define RULER_TAB_WIDTH 7
586 : : #define RULER_TAB_HEIGHT 6
587 : :
588 : : // -------------
589 : : // - RulerLine -
590 : : // -------------
591 : :
592 : : struct RulerLine
593 : : {
594 : : long nPos;
595 : : sal_uInt16 nStyle;
596 : : };
597 : :
598 : : class ImplRulerData;
599 : : // ---------
600 : : // - Ruler -
601 : : // ---------
602 : :
603 : : class SVT_DLLPUBLIC Ruler : public Window
604 : : {
605 : : private:
606 : : VirtualDevice maVirDev;
607 : : MapMode maMapMode;
608 : : long mnBorderOff;
609 : : long mnWinOff;
610 : : long mnWinWidth;
611 : : long mnWidth;
612 : : long mnHeight;
613 : : long mnVirOff;
614 : : long mnVirWidth;
615 : : long mnVirHeight;
616 : : long mnBorderWidth;
617 : : long mnStartDragPos;
618 : : long mnDragPos;
619 : : sal_uLong mnUpdateEvtId;
620 : : ImplRulerData* mpSaveData;
621 : : ImplRulerData* mpData;
622 : : ImplRulerData* mpDragData;
623 : : Rectangle maExtraRect;
624 : : WinBits mnWinStyle;
625 : : sal_uInt16 mnUnitIndex;
626 : : sal_uInt16 mnDragAryPos;
627 : : sal_uInt16 mnDragSize;
628 : : sal_uInt16 mnDragScroll;
629 : : sal_uInt16 mnDragModifier;
630 : : sal_uInt16 mnExtraStyle;
631 : : sal_uInt16 mnExtraClicks;
632 : : sal_uInt16 mnExtraModifier;
633 : : long mnCharWidth;
634 : : long mnLineHeight;
635 : :
636 : : RulerExtra meExtraType;
637 : : RulerType meDragType;
638 : : MapUnit meSourceUnit;
639 : : FieldUnit meUnit;
640 : : Fraction maZoom;
641 : : sal_Bool mbCalc;
642 : : sal_Bool mbFormat;
643 : : sal_Bool mbDrag;
644 : : sal_Bool mbDragDelete;
645 : : sal_Bool mbDragCanceled;
646 : : sal_Bool mbAutoWinWidth;
647 : : sal_Bool mbActive;
648 : : sal_uInt8 mnUpdateFlags;
649 : : Link maStartDragHdl;
650 : : Link maDragHdl;
651 : : Link maEndDragHdl;
652 : : Link maClickHdl;
653 : : Link maDoubleClickHdl;
654 : : Link maExtraDownHdl;
655 : :
656 : : #ifdef _SV_RULER_CXX
657 : : SVT_DLLPRIVATE void ImplVDrawLine( long nX1, long nY1, long nX2, long nY2 );
658 : : SVT_DLLPRIVATE void ImplVDrawRect( long nX1, long nY1, long nX2, long nY2 );
659 : : SVT_DLLPRIVATE void ImplVDrawText( long nX, long nY, const String& rText, long nMin = LONG_MIN, long nMax = LONG_MAX );
660 : :
661 : : SVT_DLLPRIVATE void ImplDrawTicks( long nMin, long nMax, long nStart, long nCenter );
662 : : SVT_DLLPRIVATE void ImplDrawBorders( long nMin, long nMax, long nVirTop, long nVirBottom );
663 : : SVT_DLLPRIVATE void ImplDrawIndent( const Polygon& rPoly, sal_uInt16 nStyle );
664 : : SVT_DLLPRIVATE void ImplDrawIndents( long nMin, long nMax, long nVirTop, long nVirBottom );
665 : : SVT_DLLPRIVATE void ImplDrawTab( OutputDevice* pDevice, const Point& rPos, sal_uInt16 nStyle );
666 : : SVT_DLLPRIVATE void ImplDrawTabs( long nMin, long nMax, long nVirTop, long nVirBottom );
667 : : using Window::ImplInit;
668 : : SVT_DLLPRIVATE void ImplInit( WinBits nWinBits );
669 : : SVT_DLLPRIVATE void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
670 : : SVT_DLLPRIVATE void ImplCalc();
671 : : SVT_DLLPRIVATE void ImplFormat();
672 : : SVT_DLLPRIVATE void ImplInitExtraField( sal_Bool bUpdate );
673 : : SVT_DLLPRIVATE void ImplInvertLines( sal_Bool bErase = sal_False );
674 : : SVT_DLLPRIVATE void ImplDraw();
675 : : SVT_DLLPRIVATE void ImplDrawExtra( sal_Bool bPaint = sal_False );
676 : : SVT_DLLPRIVATE void ImplUpdate( sal_Bool bMustCalc = sal_False );
677 : : using Window::ImplHitTest;
678 : : SVT_DLLPRIVATE sal_Bool ImplHitTest( const Point& rPos,
679 : : ImplRulerHitTest* pHitTest,
680 : : sal_Bool bRequiredStyle = sal_False,
681 : : sal_uInt16 nRequiredStyle = 0 ) const;
682 : : SVT_DLLPRIVATE sal_Bool ImplDocHitTest( const Point& rPos, RulerType eDragType, ImplRulerHitTest* pHitTest ) const;
683 : : SVT_DLLPRIVATE sal_Bool ImplStartDrag( ImplRulerHitTest* pHitTest, sal_uInt16 nModifier );
684 : : SVT_DLLPRIVATE void ImplDrag( const Point& rPos );
685 : : SVT_DLLPRIVATE void ImplEndDrag();
686 : : DECL_DLLPRIVATE_LINK( ImplUpdateHdl, void* );
687 : : #endif
688 : :
689 : : // Forbidden and not implemented.
690 : : Ruler (const Ruler &);
691 : : Ruler & operator= (const Ruler &);
692 : :
693 : : public:
694 : : Ruler( Window* pParent, WinBits nWinStyle = WB_STDRULER );
695 : : virtual ~Ruler();
696 : :
697 : : virtual void MouseButtonDown( const MouseEvent& rMEvt );
698 : : virtual void MouseMove( const MouseEvent& rMEvt );
699 : : virtual void Tracking( const TrackingEvent& rTEvt );
700 : : virtual void Paint( const Rectangle& rRect );
701 : : virtual void Resize();
702 : : virtual void StateChanged( StateChangedType nStateChange );
703 : : virtual void DataChanged( const DataChangedEvent& rDCEvt );
704 : :
705 : : virtual long StartDrag();
706 : : virtual void Drag();
707 : : virtual void EndDrag();
708 : : virtual void Click();
709 : : virtual void DoubleClick();
710 : : virtual void ExtraDown();
711 : :
712 : : void Activate();
713 : : void Deactivate();
714 : : sal_Bool IsActive() const { return mbActive; }
715 : :
716 : : void SetWinPos( long nOff = 0, long nWidth = 0 );
717 : : long GetWinOffset() const { return mnWinOff; }
718 : : long GetWinWidth() const { return mnWinWidth; }
719 : : void SetPagePos( long nOff = 0, long nWidth = 0 );
720 : : long GetPageOffset() const;
721 : : void SetBorderPos( long nOff = 0 );
722 : : long GetBorderOffset() const { return mnBorderOff; }
723 : 0 : Rectangle GetExtraRect() const { return maExtraRect; }
724 : :
725 : : void SetUnit( FieldUnit eNewUnit );
726 : 4 : FieldUnit GetUnit() const { return meUnit; }
727 : : void SetZoom( const Fraction& rNewZoom );
728 : : Fraction GetZoom() const { return maZoom; }
729 : :
730 : 208 : void SetSourceUnit( MapUnit eNewUnit ) { meSourceUnit = eNewUnit; }
731 : : MapUnit GetSourceUnit() const { return meSourceUnit; }
732 : :
733 : : void SetExtraType( RulerExtra eNewExtraType, sal_uInt16 nStyle = 0 );
734 : : RulerExtra GetExtraType() const { return meExtraType; }
735 : : sal_uInt16 GetExtraStyle() const { return mnExtraStyle; }
736 : : sal_uInt16 GetExtraClicks() const { return mnExtraClicks; }
737 : : sal_uInt16 GetExtraModifier() const { return mnExtraModifier; }
738 : :
739 : : sal_Bool StartDocDrag( const MouseEvent& rMEvt,
740 : : RulerType eDragType = RULER_TYPE_DONTKNOW );
741 : 0 : RulerType GetDragType() const { return meDragType; }
742 : 0 : long GetDragPos() const { return mnDragPos; }
743 : 0 : sal_uInt16 GetDragAryPos() const { return mnDragAryPos; }
744 : 0 : sal_uInt16 GetDragSize() const { return mnDragSize; }
745 : 0 : sal_Bool IsDragDelete() const { return mbDragDelete; }
746 : 0 : sal_Bool IsDragCanceled() const { return mbDragCanceled; }
747 : : sal_uInt16 GetDragScroll() const { return mnDragScroll; }
748 : 0 : sal_uInt16 GetDragModifier() const { return mnDragModifier; }
749 : 26922 : sal_Bool IsDrag() const { return mbDrag; }
750 : : void CancelDrag();
751 : 0 : long GetClickPos() const { return mnDragPos; }
752 : 0 : RulerType GetClickType() const { return meDragType; }
753 : : sal_uInt16 GetClickAryPos() const { return mnDragAryPos; }
754 : : using Window::GetType;
755 : : RulerType GetType( const Point& rPos,
756 : : sal_uInt16* pAryPos = NULL ) const;
757 : :
758 : : void SetNullOffset( long nPos );
759 : : long GetNullOffset() const;
760 : 11253 : void SetMargin1() { SetMargin1( 0, RULER_STYLE_INVISIBLE ); }
761 : : void SetMargin1( long nPos, sal_uInt16 nMarginStyle = RULER_MARGIN_SIZEABLE );
762 : : long GetMargin1() const;
763 : 11253 : void SetMargin2() { SetMargin2( 0, RULER_STYLE_INVISIBLE ); }
764 : : void SetMargin2( long nPos, sal_uInt16 nMarginStyle = RULER_MARGIN_SIZEABLE );
765 : : long GetMargin2() const;
766 : :
767 : : void SetLines( sal_uInt16 n = 0, const RulerLine* pLineAry = NULL );
768 : :
769 : : void SetBorders( sal_uInt16 n = 0, const RulerBorder* pBrdAry = NULL );
770 : :
771 : : void SetIndents( sal_uInt16 n = 0, const RulerIndent* pIndentAry = NULL );
772 : :
773 : : void SetTabs( sal_uInt16 n = 0, const RulerTab* pTabAry = NULL );
774 : : sal_uInt16 GetTabCount() const;
775 : : const RulerTab* GetTabs() const;
776 : :
777 : : static void DrawTab( OutputDevice* pDevice,
778 : : const Point& rPos, sal_uInt16 nStyle );
779 : :
780 : : void SetStyle( WinBits nStyle );
781 : 23021 : WinBits GetStyle() const { return mnWinStyle; }
782 : :
783 : : void SetStartDragHdl( const Link& rLink ) { maStartDragHdl = rLink; }
784 : 0 : const Link& GetStartDragHdl() const { return maStartDragHdl; }
785 : : void SetDragHdl( const Link& rLink ) { maDragHdl = rLink; }
786 : : const Link& GetDragHdl() const { return maDragHdl; }
787 : : void SetEndDragHdl( const Link& rLink ) { maEndDragHdl = rLink; }
788 : : const Link& GetEndDragHdl() const { return maEndDragHdl; }
789 : : void SetClickHdl( const Link& rLink ) { maClickHdl = rLink; }
790 : : const Link& GetClickHdl() const { return maClickHdl; }
791 : 1318 : void SetDoubleClickHdl( const Link& rLink ) { maDoubleClickHdl = rLink; }
792 : : const Link& GetDoubleClickHdl() const { return maDoubleClickHdl; }
793 : : void SetExtraDownHdl( const Link& rLink ) { maExtraDownHdl = rLink; }
794 : : const Link& GetExtraDownHdl() const { return maExtraDownHdl; }
795 : :
796 : : //set text direction right-to-left
797 : : void SetTextRTL(sal_Bool bRTL);
798 : :
799 : 1318 : void SetCharWidth( long nWidth ) { mnCharWidth = nWidth ; }
800 : 1318 : void SetLineHeight( long nHeight ) { mnLineHeight = nHeight ; }
801 : :
802 : : void DrawTicks();
803 : : };
804 : :
805 : : #endif // _RULER_HXX
806 : :
807 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|