LCOV - code coverage report
Current view: top level - libreoffice/solver/unxlngi6.pro/inc/svtools - ruler.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 7 20 35.0 %
Date: 2012-12-17 Functions: 7 20 35.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10