1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ruler.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
35 #include <tools/debug.hxx>
36 #include <vcl/svapp.hxx>
37 #include <tools/poly.hxx>
39 #include <vcl/i18nhelp.hxx>
44 // =======================================================================
47 #define RULER_TEXTOFF 2
48 #define RULER_RESIZE_OFF 4
49 #define RULER_LINE_WIDTH 7
50 #define RULER_MIN_SIZE 3
52 #define RULER_TICK1_WIDTH 1
53 #define RULER_TICK2_WIDTH 3
54 #define RULER_TICK3_WIDTH 5
56 #define RULER_VAR_SIZE 8
58 #define RULER_TAB_HEIGHT2 2
59 #define RULER_TAB_WIDTH2 2
60 #define RULER_TAB_CWIDTH 8
61 #define RULER_TAB_CWIDTH2 4
62 #define RULER_TAB_CWIDTH3 4
63 #define RULER_TAB_CWIDTH4 2
64 #define RULER_TAB_DHEIGHT 4
65 #define RULER_TAB_DHEIGHT2 1
66 #define RULER_TAB_DWIDTH 5
67 #define RULER_TAB_DWIDTH2 3
68 #define RULER_TAB_DWIDTH3 3
69 #define RULER_TAB_DWIDTH4 1
71 #define RULER_UPDATE_LINES 0x01
72 #define RULER_UPDATE_DRAW 0x02
74 #define RULER_CLIP 150
76 // =======================================================================
78 #define RULER_UNIT_MM 0
79 #define RULER_UNIT_CM 1
80 #define RULER_UNIT_M 2
81 #define RULER_UNIT_KM 3
82 #define RULER_UNIT_INCH 4
83 #define RULER_UNIT_FOOT 5
84 #define RULER_UNIT_MILE 6
85 #define RULER_UNIT_POINT 7
86 #define RULER_UNIT_PICA 8
87 #define RULER_UNIT_CHAR 9
88 #define RULER_UNIT_LINE 10
89 #define RULER_UNIT_COUNT 11
101 RulerBorder
* pBorders
;
102 RulerIndent
* pIndents
;
117 USHORT nMargin1Style
;
118 USHORT nMargin2Style
;
126 ImplRulerData
& operator=( const ImplRulerData
& rData
);
131 struct ImplRulerUnitData
133 MapUnit eMapUnit
; // MAP_UNIT zum Umrechnen
134 long nTickUnit
; // Teiler fuer Einheit
135 long nTick1
; // Schrittweite
136 long nTick2
; // Tick fuer halbe Werte
137 long nTick3
; // Tick fuer Zahlenausgabe
138 long n100THMM
; // Teiler fuer Einheit
139 USHORT nUnitDigits
; // Anzahl Nachkommastellen
140 sal_Char aUnitStr
[8]; // Einheiten-String
143 static ImplRulerUnitData aImplRulerUnitTab
[RULER_UNIT_COUNT
] =
145 { MAP_100TH_MM
, 100, 25, 50, 100, 100, 3, " mm" }, // MM
146 { MAP_100TH_MM
, 1000, 250, 500, 1000, 1000, 3, " cm" }, // CM
147 { MAP_MM
, 1000, 250, 500, 1000, 10000, 4, " m" }, // M
148 { MAP_CM
, 100000, 25000, 50000, 100000, 100000, 6, " km" }, // KM
149 { MAP_100TH_INCH
, 100, 10, 50, 100, 2540, 3, "\"" }, // INCH
150 { MAP_100TH_INCH
, 1200, 120, 600, 1200, 30480, 3, "'" }, // FOOT
151 { MAP_10TH_INCH
, 633600, 63360, 316800, 633600, 1609344, 4, " miles" }, // MILE
152 { MAP_POINT
, 1, 12, 12, 36, 353, 2, " pt" }, // POINT
153 { MAP_100TH_MM
, 423, 423, 423, 846, 423, 3, " pi" }, // PICA
154 { MAP_100TH_MM
, 371, 371, 371, 743, 371, 3, " ch" }, // CHAR
155 { MAP_100TH_MM
, 551, 551, 551, 1102, 551, 3, " li" } // LINE
158 // =======================================================================
160 struct ImplRulerHitTest
170 bExpandTest( FALSE
) {}
173 // =======================================================================
175 ImplRulerData::ImplRulerData()
177 memset( this, 0, sizeof( ImplRulerData
) );
179 // PageBreite == EditWinBreite
180 bAutoPageWidth
= TRUE
;
183 // -----------------------------------------------------------------------
185 ImplRulerData::~ImplRulerData()
194 // -----------------------------------------------------------------------
196 ImplRulerData
& ImplRulerData::operator=( const ImplRulerData
& rData
)
204 memcpy( this, &rData
, sizeof( ImplRulerData
) );
208 pLines
= new RulerLine
[nLines
];
209 memcpy( pLines
, rData
.pLines
, nLines
*sizeof( RulerLine
) );
214 pArrows
= new RulerArrow
[nArrows
];
215 memcpy( pArrows
, rData
.pArrows
, nArrows
*sizeof( RulerArrow
) );
218 if ( rData
.pBorders
)
220 pBorders
= new RulerBorder
[nBorders
];
221 memcpy( pBorders
, rData
.pBorders
, nBorders
*sizeof( RulerBorder
) );
224 if ( rData
.pIndents
)
226 pIndents
= new RulerIndent
[nIndents
];
227 memcpy( pIndents
, rData
.pIndents
, nIndents
*sizeof( RulerIndent
) );
232 pTabs
= new RulerTab
[nTabs
];
233 memcpy( pTabs
, rData
.pTabs
, nTabs
*sizeof( RulerTab
) );
239 // =======================================================================
241 void Ruler::ImplInit( WinBits nWinBits
)
243 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
245 // Default WinBits setzen
246 if ( !(nWinBits
& WB_VERT
) )
250 // --- RTL --- no UI mirroring for horizontal rulers, because
251 // the document is also not mirrored
255 // Variablen initialisieren
256 mnWinStyle
= nWinBits
; // Window-Style
257 mnBorderOff
= 0; // Border-Offset
258 mnWinOff
= 0; // EditWinOffset
259 mnWinWidth
= 0; // EditWinWidth
260 mnWidth
= 0; // Fensterbreite
261 mnHeight
= 0; // Fensterhoehe
262 mnVirOff
= 0; // Offset des VirtualDeice vom linke/oberen Rand
263 mnVirWidth
= 0; // Breite bzw. Hoehe vom VirtualDevice
264 mnVirHeight
= 0; // Hoehe bzw. Breite vom VirtualDevice
265 mnDragPos
= 0; // Drag-Position (NullPunkt)
266 mnUpdateEvtId
= 0; // Noch kein Update-Event verschickt
267 mnDragAryPos
= 0; // Drag-Array-Index
268 mnDragSize
= 0; // Wird beim Draggen die Groesse geaendert
269 mnDragScroll
= 0; // Soll beim Draggen gescrollt werden
270 mnDragModifier
= 0; // Modifier-Tasten beim Draggen
271 mnExtraStyle
= 0; // Style des Extra-Feldes
272 mnExtraClicks
= 0; // Click-Anzahl fuer Extra-Feld
273 mnExtraModifier
= 0; // Modifier-Tasten beim Click im Extrafeld
276 mbCalc
= TRUE
; // Muessen Pagebreiten neu berechnet werden
277 mbFormat
= TRUE
; // Muss neu ausgegeben werden
278 mbDrag
= FALSE
; // Sind wir im Drag-Modus
279 mbDragDelete
= FALSE
; // Wird Maus beim Draggen unten rausgezogen
280 mbDragCanceled
= FALSE
; // Wurde Dragging abgebrochen
281 mbAutoWinWidth
= TRUE
; // EditWinBreite == RulerBreite
282 mbActive
= TRUE
; // Ist Lineal aktiv
283 mnUpdateFlags
= 0; // Was soll im Update-Handler upgedatet werden
284 mpData
= mpSaveData
; // Wir zeigen auf die normalen Daten
285 meExtraType
= RULER_EXTRA_DONTKNOW
; // Was im ExtraFeld dargestellt wird
286 meDragType
= RULER_TYPE_DONTKNOW
; // Gibt an, was gedragt wird
288 // Units initialisieren
289 mnUnitIndex
= RULER_UNIT_CM
;
291 maZoom
= Fraction( 1, 1 );
292 meSourceUnit
= MAP_100TH_MM
;
294 // Border-Breiten berechnen
295 if ( nWinBits
& WB_BORDER
)
297 if ( !(rStyleSettings
.GetOptions() & STYLE_OPTION_MONO
) )
305 // Einstellungen setzen
306 ImplInitSettings( TRUE
, TRUE
, TRUE
);
308 // Default-Groesse setzen
309 long nDefHeight
= GetTextHeight() + RULER_OFF
*2 + RULER_TEXTOFF
*2 + mnBorderWidth
;
311 if ( nWinBits
& WB_HORZ
)
312 aDefSize
.Height() = nDefHeight
;
314 aDefSize
.Width() = nDefHeight
;
315 SetOutputSizePixel( aDefSize
);
318 // -----------------------------------------------------------------------
320 Ruler::Ruler( Window
* pParent
, WinBits nWinStyle
) :
321 Window( pParent
, nWinStyle
& WB_3DLOOK
),
323 maMapMode( MAP_100TH_MM
),
324 mpSaveData(new ImplRulerData
),
326 mpDragData(new ImplRulerData
)
328 ImplInit( nWinStyle
);
331 // -----------------------------------------------------------------------
336 Application::RemoveUserEvent( mnUpdateEvtId
);
341 // -----------------------------------------------------------------------
343 void Ruler::ImplVDrawLine( long nX1
, long nY1
, long nX2
, long nY2
)
345 if ( nX1
< -RULER_CLIP
)
348 if ( nX2
< -RULER_CLIP
)
351 long nClip
= mnVirWidth
+RULER_CLIP
;
359 if ( mnWinStyle
& WB_HORZ
)
360 maVirDev
.DrawLine( Point( nX1
, nY1
), Point( nX2
, nY2
) );
362 maVirDev
.DrawLine( Point( nY1
, nX1
), Point( nY2
, nX2
) );
365 // -----------------------------------------------------------------------
367 void Ruler::ImplVDrawRect( long nX1
, long nY1
, long nX2
, long nY2
)
369 if ( nX1
< -RULER_CLIP
)
372 if ( nX2
< -RULER_CLIP
)
375 long nClip
= mnVirWidth
+RULER_CLIP
;
383 if ( mnWinStyle
& WB_HORZ
)
384 maVirDev
.DrawRect( Rectangle( nX1
, nY1
, nX2
, nY2
) );
386 maVirDev
.DrawRect( Rectangle( nY1
, nX1
, nY2
, nX2
) );
389 // -----------------------------------------------------------------------
391 void Ruler::ImplVDrawText( long nX
, long nY
, const String
& rText
)
393 if ( (nX
> -RULER_CLIP
) && (nX
< mnVirWidth
+RULER_CLIP
) )
395 if ( mnWinStyle
& WB_HORZ
)
396 maVirDev
.DrawText( Point( nX
, nY
), rText
);
398 maVirDev
.DrawText( Point( nY
, nX
), rText
);
402 // -----------------------------------------------------------------------
404 void Ruler::ImplInvertLines( BOOL bErase
)
407 if ( mpData
->nLines
&& mbActive
&& !mbDrag
&& !mbFormat
&&
408 !(mnUpdateFlags
& RULER_UPDATE_LINES
) )
411 long nNullWinOff
= mpData
->nNullVirOff
+mnVirOff
;
412 long nRulX1
= mpData
->nRulVirOff
+mnVirOff
;
413 long nRulX2
= nRulX1
+mpData
->nRulWidth
;
414 long nY
= (RULER_OFF
*2)+mnVirHeight
-1;
416 // Rectangle berechnen
418 if ( mnWinStyle
& WB_HORZ
)
424 for ( USHORT i
= 0; i
< mpData
->nLines
; i
++ )
426 n
= mpData
->pLines
[i
].nPos
+nNullWinOff
;
427 if ( (n
>= nRulX1
) && (n
< nRulX2
) )
429 if ( mnWinStyle
& WB_HORZ
)
441 Rectangle aTempRect
= aRect
;
442 if ( mnWinStyle
& WB_HORZ
)
443 aTempRect
.Bottom() = RULER_OFF
-1;
445 aTempRect
.Right() = RULER_OFF
-1;
447 if ( mnWinStyle
& WB_HORZ
)
449 aTempRect
.Bottom() = aRect
.Bottom();
450 aTempRect
.Top() = aTempRect
.Bottom()-RULER_OFF
+1;
454 aTempRect
.Right() = aRect
.Right();
455 aTempRect
.Left() = aTempRect
.Right()-RULER_OFF
+1;
465 // -----------------------------------------------------------------------
467 void Ruler::ImplDrawTicks( long nMin
, long nMax
, long nStart
, long nCenter
)
471 long nTick3
= aImplRulerUnitTab
[mnUnitIndex
].nTick3
;
472 long nTickCount
= aImplRulerUnitTab
[mnUnitIndex
].nTick1
;
473 Size aPixSize
= maVirDev
.LogicToPixel( Size( nTick3
, nTick3
), maMapMode
);
477 BOOL bNoTicks
= FALSE
;
482 if ( mnUnitIndex
== RULER_UNIT_CHAR
)
484 if ( mnCharWidth
== 0 )
486 nTick3
= mnCharWidth
*2;
487 nTickCount
= mnCharWidth
;
488 nTickUnit
= mnCharWidth
;
489 nTick2
= mnCharWidth
;
491 else if ( mnUnitIndex
== RULER_UNIT_LINE
)
493 if ( mnLineHeight
== 0 )
495 nTick3
= mnLineHeight
*2;
496 nTickCount
= mnLineHeight
;
497 nTickUnit
= mnLineHeight
;
498 nTick2
= mnLineHeight
;
500 aPixSize
= maVirDev
.LogicToPixel( Size( nTick3
, nTick3
), maMapMode
);
502 // Groessenvorberechnung
503 BOOL bVertRight
= FALSE
;
504 if ( mnWinStyle
& WB_HORZ
)
505 nTickWidth
= aPixSize
.Width();
508 Font aFont
= GetFont();
509 if ( mnWinStyle
& WB_RIGHT_ALIGNED
)
511 aFont
.SetOrientation( 2700 );
515 aFont
.SetOrientation( 900 );
516 maVirDev
.SetFont( aFont
);
517 nTickWidth
= aPixSize
.Height();
519 long nMaxWidth
= maVirDev
.PixelToLogic( Size( mpData
->nPageWidth
, 0 ), maMapMode
).Width();
523 if (( mnUnitIndex
== RULER_UNIT_CHAR
) || ( mnUnitIndex
== RULER_UNIT_LINE
))
524 nMaxWidth
/= nTickUnit
;
526 nMaxWidth
/= aImplRulerUnitTab
[mnUnitIndex
].nTickUnit
;
527 UniString
aNumStr( UniString::CreateFromInt32( nMaxWidth
) );
528 long nTxtWidth
= GetTextWidth( aNumStr
);
529 if ( (nTxtWidth
*2) > nTickWidth
)
532 long nOrgTick3
= nTick3
;
534 while ( nTickWidth
< nTxtWidth
+nTextOff
)
536 long nOldMulti
= nMulti
;
539 else if ( nMulti
< 10 )
541 else if ( nMulti
< 100 )
543 else if ( nMulti
< 1000 )
547 // Ueberlauf, dann geben wir nichts aus, da wir bei so einem
548 // unsinnigen Massstab sowieso nichts vernuenftiges anzeigen
550 if ( nMulti
< nOldMulti
)
557 nTick3
= nOrgTick3
* nMulti
;
558 aPixSize
= maVirDev
.LogicToPixel( Size( nTick3
, nTick3
), maMapMode
);
559 if ( mnWinStyle
& WB_HORZ
)
560 nTickWidth
= aPixSize
.Width();
562 nTickWidth
= aPixSize
.Height();
567 maVirDev
.SetLineColor( GetSettings().GetStyleSettings().GetWindowTextColor() );
572 long nTxtHeight2
= GetTextHeight()/2;
573 while ( ((nStart
-n
) >= nMin
) || ((nStart
+n
) <= nMax
) )
580 // Nur 0 malen, wenn Margin1 nicht gleich dem NullPunkt ist
581 if ( (mpData
->nMargin1Style
& RULER_STYLE_INVISIBLE
) || (mpData
->nMargin1
!= 0) )
583 aNumStr
= (sal_Unicode
)'0';
584 nTxtWidth2
= maVirDev
.GetTextWidth( aNumStr
)/2;
585 if ( (mnWinStyle
& WB_HORZ
)^mpData
->bTextRTL
)
586 nX
= nStart
-nTxtWidth2
;
588 nX
= nStart
+nTxtWidth2
;
589 long n_Y
= bVertRight
? nCenter
+nTxtHeight2
: nCenter
-nTxtHeight2
;
590 ImplVDrawText( nX
, n_Y
, aNumStr
);
596 aPixSize
= maVirDev
.LogicToPixel( Size( nTick
, nTick
), maMapMode
);
598 if ( mnWinStyle
& WB_HORZ
)
599 n
= aPixSize
.Width();
601 n
= aPixSize
.Height();
603 // Tick3 - Ausgabe (Text)
604 if ( !(nTick
% nTick3
) )
606 //aNumStr = UniString::CreateFromInt32( nTick / aImplRulerUnitTab[mnUnitIndex].nTickUnit );
607 if ( ( mnUnitIndex
== RULER_UNIT_CHAR
) || ( mnUnitIndex
== RULER_UNIT_LINE
) )
608 aNumStr
= UniString::CreateFromInt32( nTick
/ nTickUnit
);
610 aNumStr
= UniString::CreateFromInt32( nTick
/ aImplRulerUnitTab
[mnUnitIndex
].nTickUnit
);
611 nTxtWidth2
= GetTextWidth( aNumStr
)/2;
614 //different orientation needs a different starting position
615 nY
= bVertRight
? nCenter
+nTxtHeight2
: nCenter
-nTxtHeight2
;
618 if ( mnWinStyle
& WB_HORZ
)
622 ImplVDrawText( nX
, nY
, aNumStr
);
627 if ( mnWinStyle
& WB_HORZ
)
631 ImplVDrawText( nX
, nY
, aNumStr
);
634 // Tick/Tick2 - Ausgabe (Striche)
638 if ( ( mnUnitIndex
!= RULER_UNIT_CHAR
) && ( mnUnitIndex
!= RULER_UNIT_LINE
) )
639 nTick2
= aImplRulerUnitTab
[mnUnitIndex
].nTick2
;
640 if ( !(nTick
% nTick2
) )
641 nTickWidth
= RULER_TICK2_WIDTH
;
643 nTickWidth
= RULER_TICK1_WIDTH
;
644 long nT1
= nCenter
-(nTickWidth
/2);
645 long nT2
= nT1
+nTickWidth
-1;
650 ImplVDrawLine( nT
, nT1
, nT
, nT2
);
653 ImplVDrawLine( nT
, nT1
, nT
, nT2
);
656 // #i49017# with some zoom factors the value nTick can overflow
657 if( ((ULONG
)nTick
+ (ULONG
)nTickCount
) > (ULONG
)LONG_MAX
)
664 // -----------------------------------------------------------------------
666 void Ruler::ImplDrawArrows( long nCenter
)
678 long nTxtHeight2
= GetTextHeight()/2;
680 const vcl::I18nHelper
& rI18nHelper
= GetSettings().GetLocaleI18nHelper();
682 maVirDev
.SetLineColor( GetSettings().GetStyleSettings().GetWindowTextColor() );
683 for ( i
= 0; i
< mpData
->nArrows
; i
++ )
685 n1
= mpData
->pArrows
[i
].nPos
+mpData
->nNullVirOff
+1;
686 n2
= n1
+mpData
->pArrows
[i
].nWidth
-2;
689 nLogWidth
= mpData
->pArrows
[i
].nLogWidth
;
690 if ( meSourceUnit
== MAP_TWIP
)
692 if ( nLogWidth
>= 100000 )
693 nLogWidth
= (nLogWidth
*254)/144;
695 nLogWidth
= (nLogWidth
*2540)/1440;
697 if ( nLogWidth
>= 1000000 )
698 nLogWidth
= (nLogWidth
/ aImplRulerUnitTab
[mnUnitIndex
].n100THMM
) * 1000;
700 nLogWidth
= (nLogWidth
*1000) / aImplRulerUnitTab
[mnUnitIndex
].n100THMM
;
701 aStr
= rI18nHelper
.GetNum( nLogWidth
, aImplRulerUnitTab
[mnUnitIndex
].nUnitDigits
, TRUE
, FALSE
);
703 // Einheit an den String haengen
705 aStr2
.AppendAscii( aImplRulerUnitTab
[mnUnitIndex
].aUnitStr
);
707 // Textbreite ermitteln
709 nTxtWidth
= GetTextWidth( aStr2
);
710 if ( nTxtWidth
< mpData
->pArrows
[i
].nWidth
-10 )
714 nTxtWidth
= GetTextWidth( aStr
);
715 if ( nTxtWidth
> mpData
->pArrows
[i
].nWidth
-10 )
719 // Ist genuegen Platz fuer Einheiten-String vorhanden
722 n3
= n1
+ ((n2
-n1
)/2) - 1;
723 if ( mnWinStyle
& WB_HORZ
)
727 if ( mnWinStyle
& WB_HORZ
)
729 n4
= n3
+ nTxtWidth
+ 2;
730 ImplVDrawLine( n1
, nCenter
, n3
, nCenter
);
731 ImplVDrawLine( n4
, nCenter
, n2
, nCenter
);
735 n4
= n3
- nTxtWidth
- 2;
736 ImplVDrawLine( n1
, nCenter
, n4
, nCenter
);
737 ImplVDrawLine( n3
, nCenter
, n2
, nCenter
);
739 ImplVDrawText( n3
, nCenter
-nTxtHeight2
, aStr
);
742 ImplVDrawLine( n1
, nCenter
, n2
, nCenter
);
743 ImplVDrawLine( n1
+1, nCenter
-1, n1
+1, nCenter
+1 );
744 ImplVDrawLine( n1
+2, nCenter
-2, n1
+2, nCenter
+2 );
745 ImplVDrawLine( n2
-1, nCenter
-1, n2
-1, nCenter
+1 );
746 ImplVDrawLine( n2
-2, nCenter
-2, n2
-2, nCenter
+2 );
750 // -----------------------------------------------------------------------
752 void Ruler::ImplDrawBorders( long nMin
, long nMax
, long nVirTop
, long nVirBottom
)
754 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
762 for ( i
= 0; i
< mpData
->nBorders
; i
++ )
764 if ( mpData
->pBorders
[i
].nStyle
& RULER_STYLE_INVISIBLE
)
767 n1
= mpData
->pBorders
[i
].nPos
+mpData
->nNullVirOff
;
768 n2
= n1
+mpData
->pBorders
[i
].nWidth
;
770 if ( ((n1
>= nMin
) && (n1
<= nMax
)) || ((n2
>= nMin
) && (n2
<= nMax
)) )
774 maVirDev
.SetLineColor();
775 if ( !(rStyleSettings
.GetOptions() & STYLE_OPTION_MONO
) )
776 maVirDev
.SetFillColor( rStyleSettings
.GetFaceColor() );
778 maVirDev
.SetFillColor( rStyleSettings
.GetWindowColor() );
779 ImplVDrawRect( n1
, nVirTop
, n2
, nVirBottom
);
780 if ( !(rStyleSettings
.GetOptions() & STYLE_OPTION_MONO
) )
782 maVirDev
.SetLineColor( rStyleSettings
.GetLightColor() );
783 ImplVDrawLine( n1
+1, nVirTop
, n1
+1, nVirBottom
);
784 ImplVDrawLine( n1
, nVirTop
, n2
, nVirTop
);
785 maVirDev
.SetLineColor( rStyleSettings
.GetShadowColor() );
786 ImplVDrawLine( n1
, nVirTop
, n1
, nVirBottom
);
787 ImplVDrawLine( n1
, nVirBottom
, n2
, nVirBottom
);
788 ImplVDrawLine( n2
-1, nVirTop
, n2
-1, nVirBottom
);
789 maVirDev
.SetLineColor( rStyleSettings
.GetWindowTextColor() );
790 ImplVDrawLine( n2
, nVirTop
, n2
, nVirBottom
);
794 maVirDev
.SetLineColor( rStyleSettings
.GetWindowTextColor() );
795 ImplVDrawLine( n1
, nVirTop
, n1
, nVirBottom
);
796 ImplVDrawLine( n2
, nVirTop
, n2
, nVirBottom
);
799 if ( mpData
->pBorders
[i
].nStyle
& RULER_BORDER_VARIABLE
)
801 if ( n2
-n1
> RULER_VAR_SIZE
+4 )
803 nTemp1
= n1
+ (((n2
-n1
+1)-RULER_VAR_SIZE
) / 2);
804 nTemp2
= nVirTop
+ (((nVirBottom
-nVirTop
+1)-RULER_VAR_SIZE
) / 2);
805 long nTemp3
= nTemp1
+RULER_VAR_SIZE
-1;
806 long nTemp4
= nTemp2
+RULER_VAR_SIZE
-1;
807 long nTempY
= nTemp2
;
808 if ( !(rStyleSettings
.GetOptions() & STYLE_OPTION_MONO
) )
809 maVirDev
.SetLineColor( rStyleSettings
.GetLightColor() );
811 maVirDev
.SetLineColor( rStyleSettings
.GetWindowTextColor() );
812 while ( nTempY
<= nTemp4
)
814 ImplVDrawLine( nTemp1
, nTempY
, nTemp3
, nTempY
);
817 if ( !(rStyleSettings
.GetOptions() & STYLE_OPTION_MONO
) )
820 maVirDev
.SetLineColor( rStyleSettings
.GetShadowColor() );
821 while ( nTempY
<= nTemp4
)
823 ImplVDrawLine( nTemp1
, nTempY
, nTemp3
, nTempY
);
830 if ( mpData
->pBorders
[i
].nStyle
& RULER_BORDER_SIZEABLE
)
832 if ( n2
-n1
> RULER_VAR_SIZE
+10 )
834 if ( !(rStyleSettings
.GetOptions() & STYLE_OPTION_MONO
) )
836 maVirDev
.SetLineColor( rStyleSettings
.GetShadowColor() );
837 ImplVDrawLine( n1
+4, nVirTop
+3, n1
+4, nVirBottom
-3 );
838 ImplVDrawLine( n2
-5, nVirTop
+3, n2
-5, nVirBottom
-3 );
839 maVirDev
.SetLineColor( rStyleSettings
.GetLightColor() );
840 ImplVDrawLine( n1
+5, nVirTop
+3, n1
+5, nVirBottom
-3 );
841 ImplVDrawLine( n2
-4, nVirTop
+3, n2
-4, nVirBottom
-3 );
845 maVirDev
.SetLineColor( rStyleSettings
.GetWindowTextColor() );
846 ImplVDrawLine( n1
+4, nVirTop
+3, n1
+4, nVirBottom
-3 );
847 ImplVDrawLine( n2
-4, nVirTop
+3, n2
-4, nVirBottom
-3 );
855 if ( !(rStyleSettings
.GetOptions() & STYLE_OPTION_MONO
) )
856 maVirDev
.SetLineColor( rStyleSettings
.GetShadowColor() );
858 maVirDev
.SetLineColor( rStyleSettings
.GetWindowTextColor() );
859 if ( mpData
->pBorders
[i
].nStyle
& RULER_BORDER_SNAP
)
860 ImplVDrawLine( n
, nVirTop
, n
, nVirBottom
);
861 else if ( mpData
->pBorders
[i
].nStyle
& RULER_BORDER_MARGIN
)
862 ImplVDrawLine( n
, nVirTop
, n
, nVirBottom
);
865 ImplVDrawLine( n
-1, nVirTop
, n
-1, nVirBottom
);
866 ImplVDrawLine( n
+1, nVirTop
, n
+1, nVirBottom
);
867 maVirDev
.SetLineColor();
868 maVirDev
.SetFillColor( rStyleSettings
.GetWindowColor() );
869 ImplVDrawRect( n
, nVirTop
, n
, nVirBottom
);
876 // -----------------------------------------------------------------------
878 void Ruler::ImplDrawIndent( const Polygon
& rPoly
, USHORT nStyle
)
880 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
883 USHORT nIndentStyle
= nStyle
& RULER_INDENT_STYLE
;
885 if ( nStyle
& RULER_STYLE_INVISIBLE
)
888 if ( nStyle
& RULER_STYLE_DONTKNOW
)
890 maVirDev
.SetLineColor( rStyleSettings
.GetShadowColor() );
891 maVirDev
.SetFillColor( rStyleSettings
.GetFaceColor() );
895 maVirDev
.SetLineColor( rStyleSettings
.GetDarkShadowColor() );
896 maVirDev
.SetFillColor( rStyleSettings
.GetFaceColor() );
899 maVirDev
.DrawPolygon( rPoly
);
901 if ( !(rStyleSettings
.GetOptions() & STYLE_OPTION_MONO
) && !(nStyle
& RULER_STYLE_DONTKNOW
) )
903 if ( nIndentStyle
== RULER_INDENT_BOTTOM
)
905 maVirDev
.SetLineColor( rStyleSettings
.GetLightColor() );
906 aPos1
= rPoly
.GetPoint( 2 );
908 aPos2
= rPoly
.GetPoint( 1 );
910 maVirDev
.DrawLine( aPos2
, aPos1
);
913 aPos1
= rPoly
.GetPoint( 0 );
915 maVirDev
.DrawLine( aPos2
, aPos1
);
916 maVirDev
.SetLineColor( rStyleSettings
.GetShadowColor() );
917 aPos2
= rPoly
.GetPoint( 4 );
919 maVirDev
.DrawLine( aPos1
, aPos2
);
921 aPos1
= rPoly
.GetPoint( 3 );
923 maVirDev
.DrawLine( aPos2
, aPos1
);
925 aPos2
= rPoly
.GetPoint( 2 );
928 maVirDev
.DrawLine( aPos2
, aPos1
);
932 maVirDev
.SetLineColor( rStyleSettings
.GetLightColor() );
933 aPos1
= rPoly
.GetPoint( 2 );
936 aPos2
= rPoly
.GetPoint( 3 );
938 maVirDev
.DrawLine( aPos1
, aPos2
);
939 aPos2
= rPoly
.GetPoint( 1 );
941 maVirDev
.DrawLine( aPos1
, aPos2
);
944 aPos1
= rPoly
.GetPoint( 0 );
946 maVirDev
.DrawLine( aPos2
, aPos1
);
947 maVirDev
.SetLineColor( rStyleSettings
.GetShadowColor() );
948 aPos2
= rPoly
.GetPoint( 4 );
950 maVirDev
.DrawLine( aPos1
, aPos2
);
952 aPos1
= rPoly
.GetPoint( 3 );
954 maVirDev
.DrawLine( aPos2
, aPos1
);
957 maVirDev
.SetLineColor( rStyleSettings
.GetDarkShadowColor() );
958 maVirDev
.SetFillColor();
959 maVirDev
.DrawPolygon( rPoly
);
963 // -----------------------------------------------------------------------
965 void Ruler::ImplDrawIndents( long nMin
, long nMax
, long nVirTop
, long nVirBottom
)
969 long nIndentHeight
= (mnVirHeight
/2) - 1;
970 long nIndentWidth2
= nIndentHeight
-3;
973 for ( j
= 0; j
< mpData
->nIndents
; j
++ )
975 if ( mpData
->pIndents
[j
].nStyle
& RULER_STYLE_INVISIBLE
)
978 USHORT nStyle
= mpData
->pIndents
[j
].nStyle
;
979 USHORT nIndentStyle
= nStyle
& RULER_INDENT_STYLE
;
981 n
= mpData
->pIndents
[j
].nPos
+mpData
->nNullVirOff
;
983 if ( (n
>= nMin
) && (n
<= nMax
) )
985 if(nIndentStyle
== RULER_INDENT_BORDER
)
987 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
988 maVirDev
.SetLineColor( rStyleSettings
.GetShadowColor() );
989 ImplVDrawLine( n
, nVirTop
, n
, nVirBottom
);
991 else if ( nIndentStyle
== RULER_INDENT_BOTTOM
)
993 aPoly
.SetPoint( Point( n
+0, nVirBottom
-nIndentHeight
), 0 );
994 aPoly
.SetPoint( Point( n
-nIndentWidth2
, nVirBottom
-3 ), 1 );
995 aPoly
.SetPoint( Point( n
-nIndentWidth2
, nVirBottom
), 2 );
996 aPoly
.SetPoint( Point( n
+nIndentWidth2
, nVirBottom
), 3 );
997 aPoly
.SetPoint( Point( n
+nIndentWidth2
, nVirBottom
-3 ), 4 );
1001 aPoly
.SetPoint( Point( n
+0, nVirTop
+nIndentHeight
), 0 );
1002 aPoly
.SetPoint( Point( n
-nIndentWidth2
, nVirTop
+3 ), 1 );
1003 aPoly
.SetPoint( Point( n
-nIndentWidth2
, nVirTop
), 2 );
1004 aPoly
.SetPoint( Point( n
+nIndentWidth2
, nVirTop
), 3 );
1005 aPoly
.SetPoint( Point( n
+nIndentWidth2
, nVirTop
+3 ), 4 );
1008 if(0 == (mnWinStyle
& WB_HORZ
))
1011 for(USHORT i
= 0; i
< 5; i
++)
1014 Point
aSet(nVirBottom
- aTmp
.Y(), aTmp
.X());
1018 if(RULER_INDENT_BORDER
!= nIndentStyle
)
1019 ImplDrawIndent( aPoly
, nStyle
);
1024 // -----------------------------------------------------------------------
1026 static void ImplCenterTabPos( Point
& rPos
, USHORT nTabStyle
)
1028 BOOL bRTL
= 0 != (nTabStyle
& RULER_TAB_RTL
);
1029 nTabStyle
&= RULER_TAB_STYLE
;
1030 rPos
.Y() += RULER_TAB_HEIGHT
/2;
1031 if ( (!bRTL
&& nTabStyle
== RULER_TAB_LEFT
) ||( bRTL
&& nTabStyle
== RULER_TAB_RIGHT
))
1032 rPos
.X() -= RULER_TAB_WIDTH
/2;
1033 else if ( (!bRTL
&& nTabStyle
== RULER_TAB_RIGHT
) ||( bRTL
&& nTabStyle
== RULER_TAB_LEFT
))
1034 rPos
.X() += RULER_TAB_WIDTH
/2;
1037 // -----------------------------------------------------------------------
1038 void lcl_RotateRect_Impl(Rectangle
& rRect
, const long nReference
, BOOL bRightAligned
)
1040 if(!rRect
.IsEmpty())
1042 Rectangle
aTmp(rRect
);
1043 rRect
.Top() = aTmp
.Left();
1044 rRect
.Bottom() = aTmp
.Right();
1045 rRect
.Left() = aTmp
.Top();
1046 rRect
.Right() = aTmp
.Bottom();
1049 long nRef
= 2 * nReference
;
1050 rRect
.Left() = nRef
- rRect
.Left();
1051 rRect
.Right() = nRef
- rRect
.Right();
1055 // -----------------------------------------------------------------------
1057 static void ImplDrawRulerTab( OutputDevice
* pDevice
,
1058 const Point
& rPos
, USHORT nStyle
, WinBits nWinBits
)
1060 if ( nStyle
& RULER_STYLE_INVISIBLE
)
1063 USHORT nTabStyle
= nStyle
& RULER_TAB_STYLE
;
1064 BOOL bRTL
= 0 != (nStyle
& RULER_TAB_RTL
);
1065 Rectangle aRect1
, aRect2
, aRect3
;
1067 if ( nTabStyle
== RULER_TAB_DEFAULT
)
1069 aRect1
.Left() = rPos
.X() - RULER_TAB_DWIDTH2
+ 1 ;
1070 aRect1
.Top() = rPos
.Y() - RULER_TAB_DHEIGHT2
+ 1 ;
1071 aRect1
.Right() = rPos
.X() - RULER_TAB_DWIDTH2
+ RULER_TAB_DWIDTH
;
1072 aRect1
.Bottom() = rPos
.Y();
1073 aRect2
.Left() = rPos
.X() - RULER_TAB_DWIDTH2
+ RULER_TAB_DWIDTH3
;
1074 aRect2
.Top() = rPos
.Y() - RULER_TAB_DHEIGHT
+ 1;
1075 aRect2
.Right() = rPos
.X() - RULER_TAB_DWIDTH2
+ RULER_TAB_DWIDTH3
+ RULER_TAB_DWIDTH4
- 1;
1076 aRect2
.Bottom() = rPos
.Y();
1079 else if ( (!bRTL
&& nTabStyle
== RULER_TAB_LEFT
) ||( bRTL
&& nTabStyle
== RULER_TAB_RIGHT
))
1081 aRect1
.Left() = rPos
.X();
1082 aRect1
.Top() = rPos
.Y() - RULER_TAB_HEIGHT2
+ 1;
1083 aRect1
.Right() = rPos
.X() + RULER_TAB_WIDTH
- 1;
1084 aRect1
.Bottom() = rPos
.Y();
1085 aRect2
.Left() = rPos
.X();
1086 aRect2
.Top() = rPos
.Y() - RULER_TAB_HEIGHT
+ 1;
1087 aRect2
.Right() = rPos
.X() + RULER_TAB_WIDTH2
- 1;
1088 aRect2
.Bottom() = rPos
.Y();
1090 else if ( (!bRTL
&& nTabStyle
== RULER_TAB_RIGHT
) ||( bRTL
&& nTabStyle
== RULER_TAB_LEFT
))
1092 aRect1
.Left() = rPos
.X() - RULER_TAB_WIDTH
+ 1;
1093 aRect1
.Top() = rPos
.Y() - RULER_TAB_HEIGHT2
+ 1;
1094 aRect1
.Right() = rPos
.X();
1095 aRect1
.Bottom() = rPos
.Y();
1096 aRect2
.Left() = rPos
.X() - RULER_TAB_WIDTH2
+ 1;
1097 aRect2
.Top() = rPos
.Y() - RULER_TAB_HEIGHT
+ 1;
1098 aRect2
.Right() = rPos
.X();
1099 aRect2
.Bottom() = rPos
.Y();
1103 aRect1
.Left() = rPos
.X() - RULER_TAB_CWIDTH2
+ 1;
1104 aRect1
.Top() = rPos
.Y() - RULER_TAB_HEIGHT2
+ 1;
1105 aRect1
.Right() = rPos
.X() - RULER_TAB_CWIDTH2
+ RULER_TAB_CWIDTH
;
1106 aRect1
.Bottom() = rPos
.Y();
1107 aRect2
.Left() = rPos
.X() - RULER_TAB_CWIDTH2
+ RULER_TAB_CWIDTH3
;
1108 aRect2
.Top() = rPos
.Y() - RULER_TAB_HEIGHT
+ 1;
1109 aRect2
.Right() = rPos
.X() - RULER_TAB_CWIDTH2
+ RULER_TAB_CWIDTH3
+ RULER_TAB_CWIDTH4
- 1;
1110 aRect2
.Bottom() = rPos
.Y();
1112 if ( nTabStyle
== RULER_TAB_DECIMAL
)
1114 aRect3
.Left() = rPos
.X() - RULER_TAB_CWIDTH2
+ RULER_TAB_CWIDTH
- 1;
1115 aRect3
.Top() = rPos
.Y() - RULER_TAB_HEIGHT
+ 1 + 1;
1116 aRect3
.Right() = rPos
.X() - RULER_TAB_CWIDTH2
+ RULER_TAB_CWIDTH
;
1117 aRect3
.Bottom()= rPos
.Y() - RULER_TAB_HEIGHT
+ 1 + 2 ;
1120 if( 0 == (nWinBits
&WB_HORZ
) )
1122 BOOL bRightAligned
= 0 != (nWinBits
&WB_RIGHT_ALIGNED
);
1123 lcl_RotateRect_Impl(aRect1
, rPos
.Y(), bRightAligned
);
1124 lcl_RotateRect_Impl(aRect2
, rPos
.Y(), bRightAligned
);
1125 lcl_RotateRect_Impl(aRect3
, rPos
.Y(), bRightAligned
);
1127 pDevice
->DrawRect( aRect1
);
1128 pDevice
->DrawRect( aRect2
);
1129 if(!aRect2
.IsEmpty())
1130 pDevice
->DrawRect( aRect3
);
1134 // -----------------------------------------------------------------------
1136 void Ruler::ImplDrawTab( OutputDevice
* pDevice
, const Point
& rPos
, USHORT nStyle
)
1138 if ( nStyle
& RULER_STYLE_INVISIBLE
)
1141 pDevice
->SetLineColor();
1142 if ( nStyle
& RULER_STYLE_DONTKNOW
)
1143 pDevice
->SetFillColor( GetSettings().GetStyleSettings().GetFaceColor() );
1145 pDevice
->SetFillColor( GetSettings().GetStyleSettings().GetWindowTextColor() );
1147 if(mpData
->bTextRTL
)
1148 nStyle
|= RULER_TAB_RTL
;
1149 ImplDrawRulerTab( pDevice
, rPos
, nStyle
, GetStyle());
1152 // -----------------------------------------------------------------------
1154 void Ruler::ImplDrawTabs( long nMin
, long nMax
, long nVirTop
, long nVirBottom
)
1156 for ( USHORT i
= 0; i
< mpData
->nTabs
; i
++ )
1158 if ( mpData
->pTabs
[i
].nStyle
& RULER_STYLE_INVISIBLE
)
1162 n
= mpData
->pTabs
[i
].nPos
;
1163 n
+= +mpData
->nNullVirOff
;
1164 long nTopBottom
= GetStyle() & WB_RIGHT_ALIGNED
? nVirTop
: nVirBottom
;
1165 if ( (n
>= nMin
) && (n
<= nMax
) )
1166 ImplDrawTab( &maVirDev
, Point( n
, nTopBottom
), mpData
->pTabs
[i
].nStyle
);
1170 // -----------------------------------------------------------------------
1172 void Ruler::ImplInitSettings( BOOL bFont
,
1173 BOOL bForeground
, BOOL bBackground
)
1175 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
1180 aFont
= rStyleSettings
.GetToolFont();
1181 if ( IsControlFont() )
1182 aFont
.Merge( GetControlFont() );
1183 SetZoomedPointFont( aFont
);
1186 if ( bForeground
|| bFont
)
1189 if ( IsControlForeground() )
1190 aColor
= GetControlForeground();
1192 aColor
= rStyleSettings
.GetWindowTextColor();
1193 SetTextColor( aColor
);
1200 if ( IsControlBackground() )
1201 aColor
= GetControlBackground();
1203 aColor
= rStyleSettings
.GetFaceColor();
1204 SetBackground( aColor
);
1207 maVirDev
.SetSettings( GetSettings() );
1208 maVirDev
.SetBackground( GetBackground() );
1209 Font aFont
= GetFont();
1210 if ( mnWinStyle
& WB_VERT
)
1211 aFont
.SetOrientation( 900 );
1212 maVirDev
.SetFont( aFont
);
1213 maVirDev
.SetTextColor( GetTextColor() );
1214 maVirDev
.SetTextFillColor( GetTextFillColor() );
1217 // -----------------------------------------------------------------------
1219 void Ruler::ImplCalc()
1222 mpData
->nRulVirOff
= mnWinOff
+ mpData
->nPageOff
;
1223 if ( mpData
->nRulVirOff
> mnVirOff
)
1224 mpData
->nRulVirOff
-= mnVirOff
;
1226 mpData
->nRulVirOff
= 0;
1227 long nRulWinOff
= mpData
->nRulVirOff
+mnVirOff
;
1229 // Nicht sichtbaren Bereich der Page berechnen
1230 long nNotVisPageWidth
;
1231 if ( mpData
->nPageOff
< 0 )
1233 nNotVisPageWidth
= -(mpData
->nPageOff
);
1234 if ( nRulWinOff
< mnWinOff
)
1235 nNotVisPageWidth
-= mnWinOff
-nRulWinOff
;
1238 nNotVisPageWidth
= 0;
1241 if ( mnWinStyle
& WB_HORZ
)
1243 if ( mbAutoWinWidth
)
1244 mnWinWidth
= mnWidth
- mnVirOff
;
1245 if ( mpData
->bAutoPageWidth
)
1246 mpData
->nPageWidth
= mnWinWidth
;
1247 mpData
->nRulWidth
= Min( mnWinWidth
, mpData
->nPageWidth
-nNotVisPageWidth
);
1248 if ( nRulWinOff
+mpData
->nRulWidth
> mnWidth
)
1249 mpData
->nRulWidth
= mnWidth
-nRulWinOff
;
1253 if ( mbAutoWinWidth
)
1254 mnWinWidth
= mnHeight
- mnVirOff
;
1255 if ( mpData
->bAutoPageWidth
)
1256 mpData
->nPageWidth
= mnWinWidth
;
1257 mpData
->nRulWidth
= Min( mnWinWidth
, mpData
->nPageWidth
-nNotVisPageWidth
);
1258 if ( nRulWinOff
+mpData
->nRulWidth
> mnHeight
)
1259 mpData
->nRulWidth
= mnHeight
-nRulWinOff
;
1265 // -----------------------------------------------------------------------
1267 void Ruler::ImplFormat()
1269 // Wenn schon formatiert ist, brauchen wir es nicht nochmal
1273 // Wenn Fenster noch keine Groesse hat, brauchen wir noch nichts machen
1277 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
1278 long nP1
; // Pixel-Position von Page1
1279 long nP2
; // Pixel-Position von Page2
1280 long nM1
; // Pixel-Position von Margin1
1281 long nM2
; // Pixel-Position von Margin2
1282 long nVirTop
; // Obere/Linke-Kante bei Ausgabe
1283 long nVirBottom
; // Untere/Rechte-Kante bei Ausgabe
1284 long nVirLeft
; // Linke/Obere-Kante bei Ausgabe
1285 long nVirRight
; // Rechte/Untere-Kante bei Ausgabe
1286 long nNullVirOff
; // Fuer schnellere Berechnung
1291 mpData
->nNullVirOff
= mnWinOff
+mpData
->nPageOff
+mpData
->nNullOff
-mnVirOff
;
1292 nNullVirOff
= mpData
->nNullVirOff
;
1293 nVirLeft
= mpData
->nRulVirOff
;
1294 nVirRight
= nVirLeft
+mpData
->nRulWidth
-1;
1296 nVirBottom
= mnVirHeight
-1;
1298 if ( !IsReallyVisible() )
1302 BOOL b3DLook
= !(rStyleSettings
.GetOptions() & STYLE_OPTION_MONO
);
1304 // VirtualDevice initialisieren
1305 if ( mnWinStyle
& WB_HORZ
)
1307 aVirDevSize
.Width() = mnVirWidth
;
1308 aVirDevSize
.Height() = mnVirHeight
;
1312 aVirDevSize
.Height() = mnVirWidth
;
1313 aVirDevSize
.Width() = mnVirHeight
;
1315 if ( aVirDevSize
!= maVirDev
.GetOutputSizePixel() )
1316 maVirDev
.SetOutputSizePixel( aVirDevSize
, TRUE
);
1320 // Raender berechnen
1321 if ( !(mpData
->nMargin1Style
& RULER_STYLE_INVISIBLE
) )
1323 nM1
= mpData
->nMargin1
+nNullVirOff
;
1324 if ( mpData
->bAutoPageWidth
)
1327 if ( nM1
< nVirLeft
)
1331 nP1
= nNullVirOff
-mpData
->nNullOff
;
1338 if ( !(mpData
->nMargin2Style
& RULER_STYLE_INVISIBLE
) )
1340 nM2
= mpData
->nMargin2
+nNullVirOff
;
1341 if ( mpData
->bAutoPageWidth
)
1344 if ( nM2
> nVirRight
)
1348 nP2
= nNullVirOff
-mpData
->nNullOff
+mpData
->nPageWidth
;
1358 // Obere/untere Kante ausgeben
1360 maVirDev
.SetLineColor( rStyleSettings
.GetShadowColor() );
1362 maVirDev
.SetLineColor( rStyleSettings
.GetWindowTextColor() );
1363 ImplVDrawLine( nVirLeft
, nVirTop
, nM1
- 1, nVirTop
); //top left line
1364 ImplVDrawLine( nM2
+1, nVirTop
, nP2
-1, nVirTop
); //top right line
1366 // Jetzt wird zwischen dem Schatten ausgegeben
1370 // Margin1, Margin2 und Zwischenraum ausgeben
1371 maVirDev
.SetLineColor();
1373 maVirDev
.SetFillColor( rStyleSettings
.GetFaceColor() );
1375 maVirDev
.SetFillColor( rStyleSettings
.GetWindowColor() );
1376 if ( nM1
> nVirLeft
)
1377 ImplVDrawRect( nP1
, nVirTop
, nM1
-1, nVirBottom
); //left gray rectangle
1379 ImplVDrawRect( nM2
+1, nVirTop
, nP2
, nVirBottom
); //right gray rectangle
1382 maVirDev
.SetFillColor( rStyleSettings
.GetWindowColor() );
1383 ImplVDrawRect( nM1
, nVirTop
, nM2
-1, nVirBottom
); //center rectangle
1387 maVirDev
.SetLineColor( rStyleSettings
.GetShadowColor() );
1388 if ( nM1
> nVirLeft
)
1390 ImplVDrawLine( nM1
-1, nVirTop
, nM1
-1, nVirBottom
);//right line of the left rectangle
1391 ImplVDrawLine( nP1
, nVirBottom
, nM1
-1, nVirBottom
);//bottom line of the left rectangle
1392 if ( nP1
>= nVirLeft
)
1394 ImplVDrawLine( nP1
, nVirTop
, nP1
, nVirBottom
);//left line of the left rectangle
1395 ImplVDrawLine( nP1
, nVirBottom
, nP1
+1, nVirBottom
);//?
1400 ImplVDrawLine( nM2
+1, nVirBottom
, nP2
-1, nVirBottom
);//bottom line of the right rectangle
1401 ImplVDrawLine( nM2
+1, nVirTop
, nM2
+1, nVirBottom
);//left line of the right rectangle
1402 if ( nP2
<= nVirRight
+1 )
1403 ImplVDrawLine( nP2
-1, nVirTop
, nP2
-1, nVirBottom
);//right line of the right rectangle
1408 maVirDev
.SetLineColor( rStyleSettings
.GetWindowTextColor() );
1409 if ( nP1
>= nVirLeft
)
1410 ImplVDrawLine( nP1
, nVirTop
, nP1
, nVirBottom
+1 );
1412 ImplVDrawLine( nM1
, nVirTop
, nM1
, nVirBottom
);
1414 ImplVDrawLine( nM2
, nVirTop
, nM2
, nVirBottom
);
1415 if ( nP2
<= nVirRight
+1 )
1416 ImplVDrawLine( nP2
, nVirTop
, nP2
, nVirBottom
+1 );
1419 // Lineal-Beschriftung (nur wenn keine Bemassungspfeile)
1420 if ( !mpData
->pArrows
)
1422 long nMin
= nVirLeft
;
1424 long nStart
= mpData
->bTextRTL
? mpData
->nMargin2
+ nNullVirOff
: nNullVirOff
;
1425 long nCenter
= nVirTop
+((nVirBottom
-nVirTop
)/2);
1427 // Nicht Schatten uebermalen
1428 if ( nP1
> nVirLeft
)
1430 if ( nP2
< nVirRight
)
1433 // Beschriftung ausgeben
1434 ImplDrawTicks( nMin
, nMax
, nStart
, nCenter
);
1438 if ( mpData
->pBorders
)
1439 ImplDrawBorders( nVirLeft
, nP2
, nVirTop
, nVirBottom
);
1441 // Einzuege ausgeben
1442 if ( mpData
->pIndents
)
1443 ImplDrawIndents( nVirLeft
, nP2
, nVirTop
-1, nVirBottom
+1 );
1446 if ( mpData
->pTabs
)
1448 ImplDrawTabs( nVirLeft
, nP2
, nVirTop
-1, nVirBottom
+1 );
1452 if ( mpData
->pArrows
)
1453 ImplDrawArrows( nVirTop
+((nVirBottom
-nVirTop
)/2) );
1455 // Wir haben formatiert
1459 // -----------------------------------------------------------------------
1461 void Ruler::ImplInitExtraField( BOOL bUpdate
)
1463 // Extra-Field beruecksichtigen
1464 if ( mnWinStyle
& WB_EXTRAFIELD
)
1466 maExtraRect
.Left() = RULER_OFF
;
1467 maExtraRect
.Top() = RULER_OFF
;
1468 maExtraRect
.Right() = RULER_OFF
+mnVirHeight
-1;
1469 maExtraRect
.Bottom() = RULER_OFF
+mnVirHeight
-1;
1470 if(mpData
->bTextRTL
)
1472 Size aWinSize
= GetOutputSizePixel();
1473 if(mnWinStyle
& WB_HORZ
)
1474 maExtraRect
.Move(aWinSize
.Width() - maExtraRect
.GetWidth() - maExtraRect
.Left(), 0);
1476 maExtraRect
.Move(0, aWinSize
.Height() - maExtraRect
.GetHeight() - maExtraRect
.Top());
1480 mnVirOff
= maExtraRect
.Right()+1;
1485 maExtraRect
.SetEmpty();
1497 // -----------------------------------------------------------------------
1499 void Ruler::ImplDraw()
1504 if ( IsReallyVisible() )
1506 // Lineal ueber das VirtualDevice ausgeben
1508 Size aVirDevSize
= maVirDev
.GetOutputSizePixel();
1509 // Size aVirDevSize2 = maVirDev.GetOutputSizePixel();
1510 if ( mnWinStyle
& WB_HORZ
)
1512 aOffPos
.X() = mnVirOff
;
1513 if(mpData
->bTextRTL
)
1514 aVirDevSize
.Width() -= maExtraRect
.GetWidth();
1517 // aVirDevSize.Width() -= mnVirOff;
1518 aOffPos
.Y() = RULER_OFF
;
1522 aOffPos
.X() = RULER_OFF
;
1523 aOffPos
.Y() = mnVirOff
;
1525 // aVirDevSize.Height() -= mnVirOff;
1527 DrawOutDev( aOffPos
, aVirDevSize
, Point(), aVirDevSize
, maVirDev
);
1529 // Positionslinien neu malen
1530 ImplInvertLines( TRUE
);
1534 // -----------------------------------------------------------------------
1536 void Ruler::ImplDrawExtra( BOOL bPaint
)
1538 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
1539 Rectangle aRect
= maExtraRect
;
1540 BOOL bEraseRect
= FALSE
;
1542 if ( !(rStyleSettings
.GetOptions() & STYLE_OPTION_MONO
) )
1547 aRect
.Bottom() -= 2;
1554 aRect
.Bottom() -= 1;
1557 if ( !bPaint
&& !(mnExtraStyle
& RULER_STYLE_HIGHLIGHT
) )
1559 if ( !(rStyleSettings
.GetOptions() & STYLE_OPTION_MONO
) )
1560 SetFillColor( rStyleSettings
.GetFaceColor() );
1562 SetFillColor( rStyleSettings
.GetWindowColor() );
1567 if ( !(rStyleSettings
.GetOptions() & STYLE_OPTION_MONO
) && (mnExtraStyle
& RULER_STYLE_HIGHLIGHT
) )
1569 SetFillColor( rStyleSettings
.GetCheckedColor() );
1581 if ( meExtraType
== RULER_EXTRA_NULLOFFSET
)
1583 if ( !(rStyleSettings
.GetOptions() & STYLE_OPTION_MONO
) )
1584 SetLineColor( rStyleSettings
.GetButtonTextColor() );
1586 SetLineColor( rStyleSettings
.GetWindowTextColor() );
1587 DrawLine( Point( aRect
.Left()+1, aRect
.Top()+4 ),
1588 Point( aRect
.Right()-1, aRect
.Top()+4 ) );
1589 DrawLine( Point( aRect
.Left()+4, aRect
.Top()+1 ),
1590 Point( aRect
.Left()+4, aRect
.Bottom()-1 ) );
1592 else if ( meExtraType
== RULER_EXTRA_TAB
)
1594 USHORT nTabStyle
= mnExtraStyle
& RULER_TAB_STYLE
;
1595 if(mpData
->bTextRTL
)
1596 nTabStyle
|= RULER_TAB_RTL
;
1597 Point aCenter
= aRect
.Center();
1598 Point
aDraw(aCenter
);
1599 ImplCenterTabPos( aDraw
, nTabStyle
);
1600 WinBits nWinBits
= GetStyle();
1601 if(0 == (nWinBits
&WB_HORZ
) )
1603 if(0 != (nWinBits
&WB_RIGHT_ALIGNED
))
1604 aDraw
.Y() = 2 * aCenter
.Y() - aDraw
.Y();
1605 if(mpData
->bTextRTL
)
1607 long nTemp
= aDraw
.X();
1608 aDraw
.X() = aDraw
.Y();
1612 ImplDrawTab( this, aDraw
, nTabStyle
);
1615 if ( (rStyleSettings
.GetOptions() & STYLE_OPTION_MONO
) && (mnExtraStyle
& RULER_STYLE_HIGHLIGHT
) )
1619 // -----------------------------------------------------------------------
1621 void Ruler::ImplUpdate( BOOL bMustCalc
)
1623 // Hier schon Linien loeschen, damit Sie vor dem Neuberechnen schon
1624 // geloscht sind, da danach die alten Positionen nicht mehr bestimmt
1634 // Wenn wir am Draggen sind, wird nach dem Drag-Handler automatisch
1635 // das Lineal neu upgedatet
1639 // Gegebenenfalls Update ausloesen
1640 if ( IsReallyVisible() && IsUpdateMode() )
1642 mnUpdateFlags
|= RULER_UPDATE_DRAW
;
1643 if ( !mnUpdateEvtId
)
1644 mnUpdateEvtId
= Application::PostUserEvent( LINK( this, Ruler
, ImplUpdateHdl
), NULL
);
1648 // -----------------------------------------------------------------------
1650 BOOL
Ruler::ImplHitTest( const Point
& rPos
, ImplRulerHitTest
* pHitTest
,
1651 BOOL bRequireStyle
, USHORT nRequiredStyle
) const
1664 // Position ermitteln
1665 BOOL bIsHori
= 0 != (mnWinStyle
& WB_HORZ
);
1676 nHitBottom
= mnVirHeight
+(RULER_OFF
*2);
1678 // --> FME 2004-08-05 #i32608#
1679 pHitTest
->nAryPos
= 0;
1680 pHitTest
->mnDragSize
= 0;
1681 pHitTest
->bSize
= FALSE
;
1682 pHitTest
->bSizeBar
= FALSE
;
1685 // Damit ueberstehende Tabs und Einzuege mit beruecksichtigt werden
1687 if ( mpData
->pTabs
|| mpData
->pIndents
)
1688 nXExtraOff
= (mnVirHeight
/2) - 4;
1692 // Test auf ausserhalb
1695 if ( (nX
< mpData
->nRulVirOff
-nXExtraOff
) || (nX
> mpData
->nRulVirOff
+mpData
->nRulWidth
+nXExtraOff
) ||
1696 (nY
< 0) || (nY
> nHitBottom
) )
1699 pHitTest
->eType
= RULER_TYPE_OUTSIDE
;
1703 nX
-= mpData
->nNullVirOff
;
1704 pHitTest
->nPos
= nX
;
1705 pHitTest
->eType
= RULER_TYPE_DONTKNOW
;
1707 // Zuerst die Tabs testen
1709 if ( mpData
->pTabs
)
1711 aRect
.Bottom() = nHitBottom
;
1712 aRect
.Top() = aRect
.Bottom()-RULER_TAB_HEIGHT
-RULER_OFF
;
1714 for ( i
= mpData
->nTabs
; i
; i
-- )
1716 nStyle
= mpData
->pTabs
[i
-1].nStyle
;
1717 if ( !(nStyle
& RULER_STYLE_INVISIBLE
) )
1719 nStyle
&= RULER_TAB_STYLE
;
1721 // Default-Tabs werden nur angezeigt
1722 if ( nStyle
!= RULER_TAB_DEFAULT
)
1724 n1
= mpData
->pTabs
[i
-1].nPos
;
1726 if ( nStyle
== RULER_TAB_LEFT
)
1729 aRect
.Right() = n1
+RULER_TAB_WIDTH
-1;
1731 else if ( nStyle
== RULER_TAB_RIGHT
)
1734 aRect
.Left() = n1
-RULER_TAB_WIDTH
-1;
1738 aRect
.Left() = n1
-RULER_TAB_CWIDTH2
+1;
1739 aRect
.Right() = n1
-RULER_TAB_CWIDTH2
+RULER_TAB_CWIDTH
;
1742 if ( aRect
.IsInside( Point( nX
, nY
) ) )
1744 pHitTest
->eType
= RULER_TYPE_TAB
;
1745 pHitTest
->nAryPos
= i
-1;
1753 // Dann die Einzuege
1754 if ( mpData
->pIndents
)
1756 long nIndentHeight
= (mnVirHeight
/2) - 1;
1757 long nIndentWidth2
= nIndentHeight
-3;
1759 for ( i
= mpData
->nIndents
; i
; i
-- )
1761 nStyle
= mpData
->pIndents
[i
-1].nStyle
;
1762 if ( (! bRequireStyle
|| nStyle
== nRequiredStyle
) &&
1763 !(nStyle
& RULER_STYLE_INVISIBLE
) )
1765 nStyle
&= RULER_INDENT_STYLE
;
1766 n1
= mpData
->pIndents
[i
-1].nPos
;
1768 if ( (nStyle
== RULER_INDENT_BOTTOM
) ^ (!bIsHori
) )
1770 aRect
.Left() = n1
-nIndentWidth2
;
1771 aRect
.Right() = n1
+nIndentWidth2
;
1772 aRect
.Top() = nHitBottom
-nIndentHeight
-RULER_OFF
+1;
1773 aRect
.Bottom() = nHitBottom
;
1777 aRect
.Left() = n1
-nIndentWidth2
;
1778 aRect
.Right() = n1
+nIndentWidth2
;
1780 aRect
.Bottom() = nIndentHeight
+RULER_OFF
-1;
1783 if ( aRect
.IsInside( Point( nX
, nY
) ) )
1785 pHitTest
->eType
= RULER_TYPE_INDENT
;
1786 pHitTest
->nAryPos
= i
-1;
1793 // Jetzt zaehlt nichts mehr, was links oder rechts uebersteht
1794 if ( (nXTemp
< mpData
->nRulVirOff
) || (nXTemp
> mpData
->nRulVirOff
+mpData
->nRulWidth
) )
1797 pHitTest
->eType
= RULER_TYPE_OUTSIDE
;
1801 // Danach die Spalten testen
1802 int nBorderTolerance
= 1;
1803 if(pHitTest
->bExpandTest
)
1808 for ( i
= mpData
->nBorders
; i
; i
-- )
1810 n1
= mpData
->pBorders
[i
-1].nPos
;
1811 n2
= n1
+ mpData
->pBorders
[i
-1].nWidth
;
1813 // Spalten werden mit mindestens 3 Pixel breite gezeichnet
1814 if ( !mpData
->pBorders
[i
-1].nWidth
)
1816 n1
-= nBorderTolerance
;
1817 n2
+= nBorderTolerance
;
1821 if ( (nX
>= n1
) && (nX
<= n2
) )
1823 nStyle
= mpData
->pBorders
[i
-1].nStyle
;
1824 if ( !(nStyle
& RULER_STYLE_INVISIBLE
) )
1826 pHitTest
->eType
= RULER_TYPE_BORDER
;
1827 pHitTest
->nAryPos
= i
-1;
1829 if ( !(nStyle
& RULER_BORDER_SIZEABLE
) )
1831 if ( nStyle
& RULER_BORDER_MOVEABLE
)
1833 pHitTest
->bSizeBar
= TRUE
;
1834 pHitTest
->mnDragSize
= RULER_DRAGSIZE_MOVE
;
1839 long nMOff
= RULER_MOUSE_BORDERWIDTH
;
1840 while ( nMOff
*2 >= (n2
-n1
-RULER_MOUSE_BORDERMOVE
) )
1851 if ( nX
<= n1
+nMOff
)
1853 pHitTest
->bSize
= TRUE
;
1854 pHitTest
->mnDragSize
= RULER_DRAGSIZE_1
;
1856 else if ( nX
>= n2
-nMOff
)
1858 pHitTest
->bSize
= TRUE
;
1859 pHitTest
->mnDragSize
= RULER_DRAGSIZE_2
;
1863 if ( nStyle
& RULER_BORDER_MOVEABLE
)
1865 pHitTest
->bSizeBar
= TRUE
;
1866 pHitTest
->mnDragSize
= RULER_DRAGSIZE_MOVE
;
1876 // Und zum Schluss die Raender
1877 int nMarginTolerance
= pHitTest
->bExpandTest
? nBorderTolerance
: RULER_MOUSE_MARGINWIDTH
;
1879 if ( (mpData
->nMargin1Style
& (RULER_MARGIN_SIZEABLE
| RULER_STYLE_INVISIBLE
)) == RULER_MARGIN_SIZEABLE
)
1881 n1
= mpData
->nMargin1
;
1882 if ( (nX
>= n1
- nMarginTolerance
) && (nX
<= n1
+ nMarginTolerance
) )
1884 pHitTest
->eType
= RULER_TYPE_MARGIN1
;
1885 pHitTest
->bSize
= TRUE
;
1889 if ( (mpData
->nMargin2Style
& (RULER_MARGIN_SIZEABLE
| RULER_STYLE_INVISIBLE
)) == RULER_MARGIN_SIZEABLE
)
1891 n1
= mpData
->nMargin2
;
1892 if ( (nX
>= n1
- nMarginTolerance
) && (nX
<= n1
+ nMarginTolerance
) )
1894 pHitTest
->eType
= RULER_TYPE_MARGIN2
;
1895 pHitTest
->bSize
= TRUE
;
1900 // Jetzt nocheinmal die Tabs testen, nur mit etwas mehr spielraum
1901 if ( mpData
->pTabs
)
1903 aRect
.Top() = RULER_OFF
;
1904 aRect
.Bottom() = nHitBottom
;
1906 for ( i
= mpData
->nTabs
; i
; i
-- )
1908 nStyle
= mpData
->pTabs
[i
-1].nStyle
;
1909 if ( !(nStyle
& RULER_STYLE_INVISIBLE
) )
1911 nStyle
&= RULER_TAB_STYLE
;
1913 // Default-Tabs werden nur angezeigt
1914 if ( nStyle
!= RULER_TAB_DEFAULT
)
1916 n1
= mpData
->pTabs
[i
-1].nPos
;
1918 if ( nStyle
== RULER_TAB_LEFT
)
1921 aRect
.Right() = n1
+RULER_TAB_WIDTH
-1;
1923 else if ( nStyle
== RULER_TAB_RIGHT
)
1926 aRect
.Left() = n1
-RULER_TAB_WIDTH
-1;
1930 aRect
.Left() = n1
-RULER_TAB_CWIDTH2
+1;
1931 aRect
.Right() = n1
-RULER_TAB_CWIDTH2
+RULER_TAB_CWIDTH
;
1937 if ( aRect
.IsInside( Point( nX
, nY
) ) )
1939 pHitTest
->eType
= RULER_TYPE_TAB
;
1940 pHitTest
->nAryPos
= i
-1;
1951 // -----------------------------------------------------------------------
1953 BOOL
Ruler::ImplDocHitTest( const Point
& rPos
, RulerType eDragType
,
1954 ImplRulerHitTest
* pHitTest
) const
1957 BOOL bRequiredStyle
= FALSE
;
1958 USHORT nRequiredStyle
= 0;
1960 if (eDragType
== RULER_TYPE_INDENT
)
1962 bRequiredStyle
= TRUE
;
1963 nRequiredStyle
= RULER_INDENT_BOTTOM
;
1966 if ( mnWinStyle
& WB_HORZ
)
1967 aPos
.X() += mnWinOff
;
1969 aPos
.Y() += mnWinOff
;
1971 if ( (eDragType
== RULER_TYPE_INDENT
) || (eDragType
== RULER_TYPE_DONTKNOW
) )
1973 if ( mnWinStyle
& WB_HORZ
)
1974 aPos
.Y() = RULER_OFF
+1;
1976 aPos
.X() = RULER_OFF
+1;
1978 // HitTest durchfuehren
1979 if ( ImplHitTest( aPos
, pHitTest
, bRequiredStyle
, nRequiredStyle
) )
1981 if ( (pHitTest
->eType
== eDragType
) || (eDragType
== RULER_TYPE_DONTKNOW
) )
1986 if ( (eDragType
== RULER_TYPE_INDENT
) || (eDragType
== RULER_TYPE_TAB
) ||
1987 (eDragType
== RULER_TYPE_DONTKNOW
) )
1989 if ( mnWinStyle
& WB_HORZ
)
1990 aPos
.Y() = mnHeight
-RULER_OFF
-1;
1992 aPos
.X() = mnWidth
-RULER_OFF
-1;
1994 // HitTest durchfuehren
1995 if ( ImplHitTest( aPos
, pHitTest
, bRequiredStyle
, nRequiredStyle
) )
1997 if ( (pHitTest
->eType
== eDragType
) || (eDragType
== RULER_TYPE_DONTKNOW
) )
2002 if ( (eDragType
== RULER_TYPE_MARGIN1
) || (eDragType
== RULER_TYPE_MARGIN2
) ||
2003 (eDragType
== RULER_TYPE_BORDER
) || (eDragType
== RULER_TYPE_DONTKNOW
) )
2005 if ( mnWinStyle
& WB_HORZ
)
2006 aPos
.Y() = RULER_OFF
+ (mnVirHeight
/2);
2008 aPos
.X() = RULER_OFF
+ (mnVirHeight
/2);
2010 // HitTest durchfuehren
2011 if ( ImplHitTest( aPos
, pHitTest
) )
2013 if ( (pHitTest
->eType
== eDragType
) || (eDragType
== RULER_TYPE_DONTKNOW
) )
2018 // Auf DontKnow setzen
2019 pHitTest
->eType
= RULER_TYPE_DONTKNOW
;
2024 // -----------------------------------------------------------------------
2026 BOOL
Ruler::ImplStartDrag( ImplRulerHitTest
* pHitTest
, USHORT nModifier
)
2028 // Wenn eine Spalte angeklick wurde, die weder verschiebar noch
2029 // in der Groesse aenderbar ist, brauchen wir auch kein Drag ausloesen
2030 if ( (pHitTest
->eType
== RULER_TYPE_BORDER
) &&
2031 !pHitTest
->bSize
&& !pHitTest
->bSizeBar
)
2035 meDragType
= pHitTest
->eType
;
2036 mnDragPos
= pHitTest
->nPos
;
2037 mnDragAryPos
= pHitTest
->nAryPos
;
2038 mnDragSize
= pHitTest
->mnDragSize
;
2039 mnDragModifier
= nModifier
;
2040 *mpDragData
= *mpSaveData
;
2041 mpData
= mpDragData
;
2046 // Wenn der Handler das Draggen erlaubt, dann das Draggen
2050 mnStartDragPos
= mnDragPos
;
2056 // Ansonsten muessen wir die Daten zuruecksetzen
2057 meDragType
= RULER_TYPE_DONTKNOW
;
2062 mpData
= mpSaveData
;
2068 // -----------------------------------------------------------------------
2070 void Ruler::ImplDrag( const Point
& rPos
)
2076 if ( mnWinStyle
& WB_HORZ
)
2080 nOutHeight
= mnHeight
;
2086 nOutHeight
= mnWidth
;
2089 // X berechnen und einpassen
2091 if ( nX
< mpData
->nRulVirOff
)
2093 nX
= mpData
->nRulVirOff
;
2094 mnDragScroll
= RULER_SCROLL_1
;
2096 else if ( nX
> mpData
->nRulVirOff
+mpData
->nRulWidth
)
2098 nX
= mpData
->nRulVirOff
+mpData
->nRulWidth
;
2099 mnDragScroll
= RULER_SCROLL_2
;
2101 nX
-= mpData
->nNullVirOff
;
2103 // Wenn oberhalb oder links vom Lineal, dann alte Werte
2104 mbDragDelete
= FALSE
;
2107 if ( !mbDragCanceled
)
2109 // Daten wiederherstellen
2110 mbDragCanceled
= TRUE
;
2111 ImplRulerData aTempData
;
2112 aTempData
= *mpDragData
;
2113 *mpDragData
= *mpSaveData
;
2118 mnDragPos
= mnStartDragPos
;
2121 // Und neu ausgeben (zeitverzoegert)
2123 mnUpdateFlags |= RULER_UPDATE_DRAW;
2124 if ( mnUpdateEvtId )
2125 Application::RemoveUserEvent( mnUpdateEvtId );
2126 mnUpdateEvtId = Application::PostUserEvent( LINK( this, Ruler, ImplUpdateHdl ), NULL );
2130 // Daten wieder wie vor dem Cancel herstellen
2131 *mpDragData
= aTempData
;
2136 mbDragCanceled
= FALSE
;
2138 // +2, damit nicht so schnell die Tabs geloescht werden
2139 if ( nY
> nOutHeight
+2 )
2140 mbDragDelete
= TRUE
;
2155 // -----------------------------------------------------------------------
2157 void Ruler::ImplEndDrag()
2159 // Werte uebernehmen
2160 if ( mbDragCanceled
)
2161 *mpDragData
= *mpSaveData
;
2163 *mpSaveData
= *mpDragData
;
2164 mpData
= mpSaveData
;
2170 // Drag-Werte zuruecksetzen
2171 meDragType
= RULER_TYPE_DONTKNOW
;
2175 mbDragCanceled
= FALSE
;
2176 mbDragDelete
= FALSE
;
2185 // -----------------------------------------------------------------------
2187 IMPL_LINK( Ruler
, ImplUpdateHdl
, void*, EMPTYARG
)
2191 // Feststellen, was upgedatet werden muss
2192 if ( mnUpdateFlags
& RULER_UPDATE_DRAW
)
2197 else if ( mnUpdateFlags
& RULER_UPDATE_LINES
)
2206 // -----------------------------------------------------------------------
2208 void Ruler::MouseButtonDown( const MouseEvent
& rMEvt
)
2210 if ( rMEvt
.IsLeft() && !IsTracking() )
2212 Point aMousePos
= rMEvt
.GetPosPixel();
2213 USHORT nMouseClicks
= rMEvt
.GetClicks();
2214 USHORT nMouseModifier
= rMEvt
.GetModifier();
2216 // Gegebenenfalls Lineal updaten (damit mit den richtigen Daten
2217 // gearbeitet wird und die Anzeige auch zur Bearbeitung passt)
2221 mnUpdateFlags
&= ~RULER_UPDATE_DRAW
;
2224 if ( maExtraRect
.IsInside( aMousePos
) )
2226 mnExtraClicks
= nMouseClicks
;
2227 mnExtraModifier
= nMouseModifier
;
2230 mnExtraModifier
= 0;
2234 ImplRulerHitTest aHitTest
;
2236 if ( nMouseClicks
== 1 )
2238 if ( ImplHitTest( aMousePos
, &aHitTest
) )
2239 ImplStartDrag( &aHitTest
, nMouseModifier
);
2242 // Position innerhalb des Lineal-Bereiches
2243 if ( aHitTest
.eType
== RULER_TYPE_DONTKNOW
)
2245 mnDragPos
= aHitTest
.nPos
;
2249 // Nocheinmal HitTest durchfuehren, da durch den Click
2250 // zum Beispiel ein neuer Tab gesetzt werden konnte
2251 if ( ImplHitTest( aMousePos
, &aHitTest
) )
2252 ImplStartDrag( &aHitTest
, nMouseModifier
);
2258 if ( ImplHitTest( aMousePos
, &aHitTest
) )
2260 mnDragPos
= aHitTest
.nPos
;
2261 mnDragAryPos
= aHitTest
.nAryPos
;
2263 meDragType
= aHitTest
.eType
;
2267 meDragType
= RULER_TYPE_DONTKNOW
;
2275 // -----------------------------------------------------------------------
2277 void Ruler::MouseMove( const MouseEvent
& rMEvt
)
2279 PointerStyle ePtrStyle
= POINTER_ARROW
;
2281 // Gegebenenfalls Lineal updaten (damit mit den richtigen Daten
2282 // gearbeitet wird und die Anzeige auch zur Bearbeitung passt)
2286 mnUpdateFlags
&= ~RULER_UPDATE_DRAW
;
2289 ImplRulerHitTest aHitTest
;
2290 if ( ImplHitTest( rMEvt
.GetPosPixel(), &aHitTest
) )
2292 if ( aHitTest
.bSize
)
2294 if ( mnWinStyle
& WB_HORZ
)
2295 ePtrStyle
= POINTER_ESIZE
;
2297 ePtrStyle
= POINTER_SSIZE
;
2299 else if ( aHitTest
.bSizeBar
)
2301 if ( mnWinStyle
& WB_HORZ
)
2302 ePtrStyle
= POINTER_HSIZEBAR
;
2304 ePtrStyle
= POINTER_VSIZEBAR
;
2308 SetPointer( Pointer( ePtrStyle
) );
2311 // -----------------------------------------------------------------------
2313 void Ruler::Tracking( const TrackingEvent
& rTEvt
)
2315 if ( rTEvt
.IsTrackingEnded() )
2317 // Bei Abbruch, den alten Status wieder herstellen
2318 if ( rTEvt
.IsTrackingCanceled() )
2320 mbDragCanceled
= TRUE
;
2327 ImplDrag( rTEvt
.GetMouseEvent().GetPosPixel() );
2330 // -----------------------------------------------------------------------
2332 void Ruler::Paint( const Rectangle
& )
2336 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
2338 // Extra-Field beruecksichtigen
2339 if ( mnWinStyle
& WB_EXTRAFIELD
)
2341 if ( !(rStyleSettings
.GetOptions() & STYLE_OPTION_MONO
) )
2343 SetLineColor( rStyleSettings
.GetShadowColor() );
2344 DrawLine( Point( maExtraRect
.Left(), maExtraRect
.Top() ),
2345 Point( maExtraRect
.Right()-1, maExtraRect
.Top() ) );
2346 DrawLine( Point( maExtraRect
.Left(), maExtraRect
.Top() ),
2347 Point( maExtraRect
.Left(), maExtraRect
.Bottom()-1 ) );
2348 DrawLine( Point( maExtraRect
.Left(), maExtraRect
.Bottom()-1 ),
2349 Point( maExtraRect
.Right()-1, maExtraRect
.Bottom()-1 ) );
2350 DrawLine( Point( maExtraRect
.Right()-1, maExtraRect
.Top() ),
2351 Point( maExtraRect
.Right()-1, maExtraRect
.Bottom()-1 ) );
2352 SetLineColor( rStyleSettings
.GetLightColor() );
2353 DrawLine( Point( maExtraRect
.Left()+1, maExtraRect
.Top()+1 ),
2354 Point( maExtraRect
.Right()-2, maExtraRect
.Top()+1 ) );
2355 DrawLine( Point( maExtraRect
.Left()+1, maExtraRect
.Top()+1 ),
2356 Point( maExtraRect
.Left()+1, maExtraRect
.Bottom()-2 ) );
2357 DrawLine( Point( maExtraRect
.Left(), maExtraRect
.Bottom() ),
2358 Point( maExtraRect
.Right(), maExtraRect
.Bottom() ) );
2359 DrawLine( Point( maExtraRect
.Right(), maExtraRect
.Top() ),
2360 Point( maExtraRect
.Right(), maExtraRect
.Bottom() ) );
2364 SetLineColor( rStyleSettings
.GetWindowTextColor() );
2365 SetFillColor( rStyleSettings
.GetWindowColor() );
2366 DrawRect( maExtraRect
);
2369 // Imhalt vom Extrafeld ausgeben
2370 ImplDrawExtra( TRUE
);
2373 if ( mnWinStyle
& WB_BORDER
)
2375 if ( mnWinStyle
& WB_HORZ
)
2377 if ( !(rStyleSettings
.GetOptions() & STYLE_OPTION_MONO
) )
2379 SetLineColor( rStyleSettings
.GetShadowColor() );
2380 DrawLine( Point( mnBorderOff
, mnHeight
-2 ),
2381 Point( mnWidth
, mnHeight
-2 ) );
2384 DrawLine( Point( mnBorderOff
-1, mnHeight
-2 ),
2385 Point( mnBorderOff
-1, mnHeight
-1 ) );
2388 SetLineColor( rStyleSettings
.GetWindowTextColor() );
2389 DrawLine( Point( mnBorderOff
, mnHeight
-1 ),
2390 Point( mnWidth
, mnHeight
-1 ) );
2394 if ( !(rStyleSettings
.GetOptions() & STYLE_OPTION_MONO
) )
2396 SetLineColor( rStyleSettings
.GetShadowColor() );
2397 DrawLine( Point( mnWidth
-2, mnBorderOff
),
2398 Point( mnWidth
-2, mnHeight
) );
2401 DrawLine( Point( mnWidth
-2, mnBorderOff
-1 ),
2402 Point( mnWidth
-1, mnBorderOff
-1 ) );
2405 SetLineColor( rStyleSettings
.GetWindowTextColor() );
2406 DrawLine( Point( mnWidth
-1, mnBorderOff
),
2407 Point( mnWidth
-1, mnHeight
) );
2412 // -----------------------------------------------------------------------
2414 void Ruler::Resize()
2416 Size aWinSize
= GetOutputSizePixel();
2419 if ( mnWinStyle
& WB_HORZ
)
2421 if ( aWinSize
.Height() != mnHeight
)
2422 nNewHeight
= aWinSize
.Height();
2428 if ( aWinSize
.Width() != mnWidth
)
2429 nNewHeight
= aWinSize
.Width();
2434 // Hier schon Linien loeschen
2435 BOOL bVisible
= IsReallyVisible();
2436 if ( bVisible
&& mpData
->nLines
)
2439 mnUpdateFlags
|= RULER_UPDATE_LINES
;
2440 if ( !mnUpdateEvtId
)
2441 mnUpdateEvtId
= Application::PostUserEvent( LINK( this, Ruler
, ImplUpdateHdl
), NULL
);
2445 // Wenn sich die Hoehe bzw. Breite aendert, dann muessen besimmte Werte
2446 // neu berechnet werden
2447 //extra field should always be updated
2448 ImplInitExtraField( mpData
->bTextRTL
);
2452 mnVirHeight
= nNewHeight
- mnBorderWidth
- (RULER_OFF
*2);
2456 if ( mpData
->bAutoPageWidth
)
2458 else if ( mbAutoWinWidth
)
2462 // Wenn Ruler eine Groesse hat, dann Groesse vom VirtualDevice setzen
2463 if ( (mnVirWidth
> RULER_MIN_SIZE
) ||
2464 ((aWinSize
.Width() > RULER_MIN_SIZE
) && (aWinSize
.Height() > RULER_MIN_SIZE
)) )
2466 if ( mnWinStyle
& WB_HORZ
)
2467 mnVirWidth
= aWinSize
.Width()-mnVirOff
;
2469 mnVirWidth
= aWinSize
.Height()-mnVirOff
;
2470 if ( mnVirWidth
< RULER_MIN_SIZE
)
2474 // Gegebenenfalls ein Teil vom Rand loeschen, da 3D-Effekt/Trennlinie am
2480 else if ( mpData
->bAutoPageWidth
)
2482 // Nur bei AutoPageWidth haben wir rechts einen 3D-Effekt,
2483 // der sich der Fensterbreite anpasst und deshalb neu gezeichnet
2487 if ( mnWinStyle
& WB_HORZ
)
2489 if ( mnWidth
< aWinSize
.Width() )
2490 aRect
.Left() = mnWidth
-RULER_RESIZE_OFF
;
2492 aRect
.Left() = aWinSize
.Width()-RULER_RESIZE_OFF
;
2493 aRect
.Right() = aRect
.Left()+RULER_RESIZE_OFF
;
2494 aRect
.Top() = RULER_OFF
;
2495 aRect
.Bottom() = RULER_OFF
+mnVirHeight
;
2499 if ( mnHeight
< aWinSize
.Height() )
2500 aRect
.Top() = mnHeight
-RULER_RESIZE_OFF
;
2502 aRect
.Top() = aWinSize
.Height()-RULER_RESIZE_OFF
;
2503 aRect
.Bottom() = aRect
.Top()+RULER_RESIZE_OFF
;
2504 aRect
.Left() = RULER_OFF
;
2505 aRect
.Right() = RULER_OFF
+mnVirHeight
;
2508 Invalidate( aRect
);
2512 // Neue Groesse merken
2513 mnWidth
= aWinSize
.Width();
2514 mnHeight
= aWinSize
.Height();
2517 // -----------------------------------------------------------------------
2519 void Ruler::StateChanged( StateChangedType nType
)
2521 Window::StateChanged( nType
);
2523 if ( nType
== STATE_CHANGE_INITSHOW
)
2525 else if ( nType
== STATE_CHANGE_UPDATEMODE
)
2527 if ( IsReallyVisible() && IsUpdateMode() )
2530 else if ( (nType
== STATE_CHANGE_ZOOM
) ||
2531 (nType
== STATE_CHANGE_CONTROLFONT
) )
2533 ImplInitSettings( TRUE
, FALSE
, FALSE
);
2536 else if ( nType
== STATE_CHANGE_CONTROLFOREGROUND
)
2538 ImplInitSettings( FALSE
, TRUE
, FALSE
);
2541 else if ( nType
== STATE_CHANGE_CONTROLBACKGROUND
)
2543 ImplInitSettings( FALSE
, FALSE
, TRUE
);
2548 // -----------------------------------------------------------------------
2550 void Ruler::DataChanged( const DataChangedEvent
& rDCEvt
)
2552 Window::DataChanged( rDCEvt
);
2554 if ( (rDCEvt
.GetType() == DATACHANGED_FONTS
) ||
2555 (rDCEvt
.GetType() == DATACHANGED_DISPLAY
) ||
2556 (rDCEvt
.GetType() == DATACHANGED_FONTSUBSTITUTION
) ||
2557 ((rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
2558 (rDCEvt
.GetFlags() & SETTINGS_STYLE
)) )
2561 ImplInitSettings( TRUE
, TRUE
, TRUE
);
2566 // -----------------------------------------------------------------------
2568 long Ruler::StartDrag()
2570 if ( maStartDragHdl
.IsSet() )
2571 return maStartDragHdl
.Call( this );
2576 // -----------------------------------------------------------------------
2580 maDragHdl
.Call( this );
2583 // -----------------------------------------------------------------------
2585 void Ruler::EndDrag()
2587 maEndDragHdl
.Call( this );
2590 // -----------------------------------------------------------------------
2594 maClickHdl
.Call( this );
2597 // -----------------------------------------------------------------------
2599 void Ruler::DoubleClick()
2601 maDoubleClickHdl
.Call( this );
2604 // -----------------------------------------------------------------------
2606 void Ruler::ExtraDown()
2608 maExtraDownHdl
.Call( this );
2611 // -----------------------------------------------------------------------
2613 void Ruler::Activate()
2617 // Positionslinien wieder anzeigen (erst hinter mbActive=TRUE rufen, da
2618 // von ImplInvertLines() ausgewertet wird). Das Zeichnen der Linien
2619 // wird verzoegert, damit im vermutlich noch nicht gepainteten Zustand
2620 // Linien gezeichnet werden.
2621 mnUpdateFlags
|= RULER_UPDATE_LINES
;
2622 if ( !mnUpdateEvtId
)
2623 mnUpdateEvtId
= Application::PostUserEvent( LINK( this, Ruler
, ImplUpdateHdl
), NULL
);
2626 // -----------------------------------------------------------------------
2628 void Ruler::Deactivate()
2630 // Positionslinien loeschen (schon vor mbActive=FALSE rufen, da
2631 // von ImplInvertLines() ausgewertet wird)
2637 // -----------------------------------------------------------------------
2639 BOOL
Ruler::StartDocDrag( const MouseEvent
& rMEvt
, RulerType eDragType
)
2643 Point aMousePos
= rMEvt
.GetPosPixel();
2644 USHORT nMouseClicks
= rMEvt
.GetClicks();
2645 USHORT nMouseModifier
= rMEvt
.GetModifier();
2646 ImplRulerHitTest aHitTest
;
2647 if(eDragType
!= RULER_TYPE_DONTKNOW
)
2648 aHitTest
.bExpandTest
= TRUE
;
2650 // Gegebenenfalls Lineal updaten (damit mit den richtigen Daten
2651 // gearbeitet wird und die Anzeige auch zur Bearbeitung passt)
2655 mnUpdateFlags
&= ~RULER_UPDATE_DRAW
;
2658 if ( nMouseClicks
== 1 )
2660 if ( ImplDocHitTest( aMousePos
, eDragType
, &aHitTest
) )
2664 if ( aHitTest
.bSize
)
2666 if ( mnWinStyle
& WB_HORZ
)
2667 aPtr
= Pointer( POINTER_ESIZE
);
2669 aPtr
= Pointer( POINTER_SSIZE
);
2671 else if ( aHitTest
.bSizeBar
)
2673 if ( mnWinStyle
& WB_HORZ
)
2674 aPtr
= Pointer( POINTER_HSIZEBAR
);
2676 aPtr
= Pointer( POINTER_VSIZEBAR
);
2679 return ImplStartDrag( &aHitTest
, nMouseModifier
);
2682 else if ( nMouseClicks
== 2 )
2684 if ( ImplDocHitTest( aMousePos
, eDragType
, &aHitTest
) )
2686 mnDragPos
= aHitTest
.nPos
;
2687 mnDragAryPos
= aHitTest
.nAryPos
;
2689 eDragType
= aHitTest
.eType
;
2693 eDragType
= RULER_TYPE_DONTKNOW
;
2704 // -----------------------------------------------------------------------
2706 RulerType
Ruler::GetDocType( const Point
& rPos
, RulerType eDragType
,
2707 USHORT
* pAryPos
) const
2709 ImplRulerHitTest aHitTest
;
2711 // Gegebenenfalls Lineal updaten (damit mit den richtigen Daten
2712 // gearbeitet wird und die Anzeige auch zur Bearbeitung passt)
2713 if ( IsReallyVisible() && mbFormat
)
2715 ((Ruler
*)this)->ImplDraw();
2716 ((Ruler
*)this)->mnUpdateFlags
&= ~RULER_UPDATE_DRAW
;
2719 // HitTest durchfuehren
2720 ImplDocHitTest( rPos
, eDragType
, &aHitTest
);
2722 // Werte zurueckgeben
2724 *pAryPos
= aHitTest
.nAryPos
;
2725 return aHitTest
.eType
;
2728 // -----------------------------------------------------------------------
2730 void Ruler::CancelDrag()
2734 ImplDrag( Point( -1, -1 ) );
2739 // -----------------------------------------------------------------------
2741 RulerType
Ruler::GetType( const Point
& rPos
, USHORT
* pAryPos
) const
2743 ImplRulerHitTest aHitTest
;
2745 // Gegebenenfalls Lineal updaten (damit mit den richtigen Daten
2746 // gearbeitet wird und die Anzeige auch zur Bearbeitung passt)
2747 if ( IsReallyVisible() && mbFormat
)
2749 ((Ruler
*)this)->ImplDraw();
2750 ((Ruler
*)this)->mnUpdateFlags
&= ~RULER_UPDATE_DRAW
;
2753 // HitTest durchfuehren
2754 ImplHitTest( rPos
, &aHitTest
);
2756 // Werte zurueckgeben
2758 *pAryPos
= aHitTest
.nAryPos
;
2759 return aHitTest
.eType
;
2762 // -----------------------------------------------------------------------
2764 void Ruler::SetWinPos( long nNewOff
, long nNewWidth
)
2766 // Gegebenenfalls werden die Breiten automatisch berechnet
2768 mbAutoWinWidth
= TRUE
;
2770 mbAutoWinWidth
= FALSE
;
2772 // Werte setzen (werden in ImplFormat gegebenenfalls mitberechnet)
2774 mnWinWidth
= nNewWidth
;
2778 // -----------------------------------------------------------------------
2780 void Ruler::SetPagePos( long nNewOff
, long nNewWidth
)
2782 // Muessen wir ueberhaupt was machen
2783 if ( (mpData
->nPageOff
== nNewOff
) && (mpData
->nPageWidth
== nNewWidth
) )
2786 // Gegebenenfalls werden die Breiten automatisch berechnet
2788 mpData
->bAutoPageWidth
= TRUE
;
2790 mpData
->bAutoPageWidth
= FALSE
;
2792 // Werte setzen (werden in ImplFormat gegebenenfalls mitberechnet)
2793 mpData
->nPageOff
= nNewOff
;
2794 mpData
->nPageWidth
= nNewWidth
;
2798 // -----------------------------------------------------------------------
2800 void Ruler::SetBorderPos( long nOff
)
2802 if ( mnWinStyle
& WB_BORDER
)
2804 if ( mnBorderOff
!= nOff
)
2808 if ( IsReallyVisible() && IsUpdateMode() )
2814 // -----------------------------------------------------------------------
2816 void Ruler::SetUnit( FieldUnit eNewUnit
)
2818 if ( meUnit
!= eNewUnit
)
2824 mnUnitIndex
= RULER_UNIT_MM
;
2827 mnUnitIndex
= RULER_UNIT_CM
;
2830 mnUnitIndex
= RULER_UNIT_M
;
2833 mnUnitIndex
= RULER_UNIT_KM
;
2836 mnUnitIndex
= RULER_UNIT_INCH
;
2839 mnUnitIndex
= RULER_UNIT_FOOT
;
2842 mnUnitIndex
= RULER_UNIT_MILE
;
2845 mnUnitIndex
= RULER_UNIT_POINT
;
2848 mnUnitIndex
= RULER_UNIT_PICA
;
2851 mnUnitIndex
= RULER_UNIT_CHAR
;
2854 mnUnitIndex
= RULER_UNIT_LINE
;
2858 DBG_ERRORFILE( "Ruler::SetUnit() - Wrong Unit" );
2863 maMapMode
.SetMapUnit( aImplRulerUnitTab
[mnUnitIndex
].eMapUnit
);
2868 // -----------------------------------------------------------------------
2870 void Ruler::SetZoom( const Fraction
& rNewZoom
)
2872 DBG_ASSERT( rNewZoom
.GetNumerator(), "Ruler::SetZoom() with scale 0 is not allowed" );
2874 if ( maZoom
!= rNewZoom
)
2877 maMapMode
.SetScaleX( maZoom
);
2878 maMapMode
.SetScaleY( maZoom
);
2883 // -----------------------------------------------------------------------
2885 void Ruler::SetExtraType( RulerExtra eNewExtraType
, USHORT nStyle
)
2887 if ( mnWinStyle
& WB_EXTRAFIELD
)
2889 meExtraType
= eNewExtraType
;
2890 mnExtraStyle
= nStyle
;
2891 if ( IsReallyVisible() && IsUpdateMode() )
2892 ImplDrawExtra( FALSE
);
2896 // -----------------------------------------------------------------------
2898 void Ruler::SetNullOffset( long nPos
)
2900 if ( mpData
->nNullOff
!= nPos
)
2902 mpData
->nNullOff
= nPos
;
2907 // -----------------------------------------------------------------------
2909 void Ruler::SetMargin1( long nPos
, USHORT nMarginStyle
)
2911 if ( (mpData
->nMargin1
!= nPos
) || (mpData
->nMargin1Style
!= nMarginStyle
) )
2913 mpData
->nMargin1
= nPos
;
2914 mpData
->nMargin1Style
= nMarginStyle
;
2919 // -----------------------------------------------------------------------
2921 void Ruler::SetMargin2( long nPos
, USHORT nMarginStyle
)
2923 DBG_ASSERT( (nPos
>= mpData
->nMargin1
) ||
2924 (mpData
->nMargin1Style
& RULER_STYLE_INVISIBLE
) ||
2925 (mpData
->nMargin2Style
& RULER_STYLE_INVISIBLE
),
2926 "Ruler::SetMargin2() - Margin2 < Margin1" );
2928 if ( (mpData
->nMargin2
!= nPos
) || (mpData
->nMargin2Style
!= nMarginStyle
) )
2930 mpData
->nMargin2
= nPos
;
2931 mpData
->nMargin2Style
= nMarginStyle
;
2936 // -----------------------------------------------------------------------
2938 void Ruler::SetLines( USHORT n
, const RulerLine
* pLineAry
)
2940 // Testen, ob sich was geaendert hat
2941 if ( mpData
->nLines
== n
)
2944 const RulerLine
* pAry1
= mpData
->pLines
;
2945 const RulerLine
* pAry2
= pLineAry
;
2948 if ( (pAry1
->nPos
!= pAry2
->nPos
) ||
2949 (pAry1
->nStyle
!= pAry2
->nStyle
) )
2959 // Neue Werte setzen und neu ausgeben
2961 if ( IsReallyVisible() && IsUpdateMode() )
2964 bMustUpdate
= FALSE
;
2966 // Alte Linien loeschen
2970 // Neue Daten setzen
2971 if ( !n
|| !pLineAry
)
2973 if ( !mpData
->pLines
)
2975 delete[] mpData
->pLines
;
2977 mpData
->pLines
= NULL
;
2981 if ( mpData
->nLines
!= n
)
2983 delete[] mpData
->pLines
;
2985 mpData
->pLines
= new RulerLine
[n
];
2988 memcpy( mpData
->pLines
, pLineAry
, n
*sizeof( RulerLine
) );
2990 // Linien neu ausgeben
2996 // -----------------------------------------------------------------------
2998 void Ruler::SetArrows( USHORT n
, const RulerArrow
* pArrowAry
)
3000 if ( !n
|| !pArrowAry
)
3002 if ( !mpData
->pArrows
)
3004 delete[] mpData
->pArrows
;
3005 mpData
->nArrows
= 0;
3006 mpData
->pArrows
= NULL
;
3010 if ( mpData
->nArrows
!= n
)
3012 delete[] mpData
->pArrows
;
3013 mpData
->nArrows
= n
;
3014 mpData
->pArrows
= new RulerArrow
[n
];
3019 const RulerArrow
* pAry1
= mpData
->pArrows
;
3020 const RulerArrow
* pAry2
= pArrowAry
;
3023 if ( (pAry1
->nPos
!= pAry2
->nPos
) ||
3024 (pAry1
->nWidth
!= pAry2
->nWidth
) ||
3025 (pAry1
->nLogWidth
!= pAry2
->nLogWidth
) ||
3026 (pAry1
->nStyle
!= pAry2
->nStyle
) )
3036 memcpy( mpData
->pArrows
, pArrowAry
, n
*sizeof( RulerArrow
) );
3042 // -----------------------------------------------------------------------
3044 void Ruler::SetBorders( USHORT n
, const RulerBorder
* pBrdAry
)
3046 if ( !n
|| !pBrdAry
)
3048 if ( !mpData
->pBorders
)
3050 delete[] mpData
->pBorders
;
3051 mpData
->nBorders
= 0;
3052 mpData
->pBorders
= NULL
;
3056 if ( mpData
->nBorders
!= n
)
3058 delete[] mpData
->pBorders
;
3059 mpData
->nBorders
= n
;
3060 mpData
->pBorders
= new RulerBorder
[n
];
3065 const RulerBorder
* pAry1
= mpData
->pBorders
;
3066 const RulerBorder
* pAry2
= pBrdAry
;
3069 if ( (pAry1
->nPos
!= pAry2
->nPos
) ||
3070 (pAry1
->nWidth
!= pAry2
->nWidth
) ||
3071 (pAry1
->nStyle
!= pAry2
->nStyle
) )
3081 memcpy( mpData
->pBorders
, pBrdAry
, n
*sizeof( RulerBorder
) );
3087 // -----------------------------------------------------------------------
3089 void Ruler::SetIndents( USHORT n
, const RulerIndent
* pIndentAry
)
3092 if ( !n
|| !pIndentAry
)
3094 if ( !mpData
->pIndents
)
3096 delete[] mpData
->pIndents
;
3097 mpData
->nIndents
= 0;
3098 mpData
->pIndents
= NULL
;
3102 if ( mpData
->nIndents
!= n
)
3104 delete[] mpData
->pIndents
;
3105 mpData
->nIndents
= n
;
3106 mpData
->pIndents
= new RulerIndent
[n
];
3111 const RulerIndent
* pAry1
= mpData
->pIndents
;
3112 const RulerIndent
* pAry2
= pIndentAry
;
3115 if ( (pAry1
->nPos
!= pAry2
->nPos
) ||
3116 (pAry1
->nStyle
!= pAry2
->nStyle
) )
3126 memcpy( mpData
->pIndents
, pIndentAry
, n
*sizeof( RulerIndent
) );
3132 // -----------------------------------------------------------------------
3134 void Ruler::SetTabs( USHORT n
, const RulerTab
* pTabAry
)
3136 if ( !n
|| !pTabAry
)
3138 if ( !mpData
->pTabs
)
3140 delete[] mpData
->pTabs
;
3142 mpData
->pTabs
= NULL
;
3146 if ( mpData
->nTabs
!= n
)
3148 delete[] mpData
->pTabs
;
3150 mpData
->pTabs
= new RulerTab
[n
];
3155 const RulerTab
* pAry1
= mpData
->pTabs
;
3156 const RulerTab
* pAry2
= pTabAry
;
3159 if ( (pAry1
->nPos
!= pAry2
->nPos
) ||
3160 (pAry1
->nStyle
!= pAry2
->nStyle
) )
3170 memcpy( mpData
->pTabs
, pTabAry
, n
*sizeof( RulerTab
) );
3176 // -----------------------------------------------------------------------
3178 void Ruler::SetStyle( WinBits nStyle
)
3180 if ( mnWinStyle
!= nStyle
)
3182 mnWinStyle
= nStyle
;
3183 ImplInitExtraField( TRUE
);
3187 // -----------------------------------------------------------------------
3189 void Ruler::DrawTab( OutputDevice
* pDevice
, const Point
& rPos
, USHORT nStyle
)
3191 /*const StyleSettings& rStyleSettings =*/ pDevice
->GetSettings().GetStyleSettings();
3193 USHORT nTabStyle
= nStyle
& (RULER_TAB_STYLE
| RULER_TAB_RTL
);
3195 pDevice
->Push( PUSH_LINECOLOR
| PUSH_FILLCOLOR
);
3196 pDevice
->SetLineColor();
3197 pDevice
->SetFillColor( pDevice
->GetSettings().GetStyleSettings().GetWindowTextColor() );
3198 ImplCenterTabPos( aPos
, nTabStyle
);
3199 ImplDrawRulerTab( pDevice
, aPos
, nTabStyle
, nStyle
);
3202 /* -----------------16.10.2002 15:17-----------------
3204 * --------------------------------------------------*/
3205 void Ruler::SetTextRTL(BOOL bRTL
)
3207 if(mpData
->bTextRTL
!= bRTL
)
3209 mpData
->bTextRTL
= bRTL
;
3210 if ( IsReallyVisible() && IsUpdateMode() )
3211 ImplInitExtraField( TRUE
);
3215 long Ruler::GetPageOffset() const { return mpData
->nPageOff
; }
3216 long Ruler::GetPageWidth() const { return mpData
->nPageWidth
; }
3217 long Ruler::GetNullOffset() const { return mpData
->nNullOff
; }
3218 long Ruler::GetMargin1() const { return mpData
->nMargin1
; }
3219 USHORT
Ruler::GetMargin1Style() const { return mpData
->nMargin1Style
; }
3220 long Ruler::GetMargin2() const { return mpData
->nMargin2
; }
3221 USHORT
Ruler::GetMargin2Style() const { return mpData
->nMargin2Style
; }
3222 USHORT
Ruler::GetLineCount() const { return mpData
->nLines
; }
3223 const RulerLine
* Ruler::GetLines() const { return mpData
->pLines
; }
3224 USHORT
Ruler::GetArrowCount() const { return mpData
->nArrows
; }
3225 const RulerArrow
* Ruler::GetArrows() const { return mpData
->pArrows
; }
3226 USHORT
Ruler::GetBorderCount() const { return mpData
->nBorders
; }
3227 const RulerBorder
* Ruler::GetBorders() const { return mpData
->pBorders
; }
3228 USHORT
Ruler::GetIndentCount() const { return mpData
->nIndents
; }
3229 const RulerIndent
* Ruler::GetIndents() const { return mpData
->pIndents
; }
3231 /* ---------------------------------------------------
3233 * ---------------------------------------------------*/
3234 void Ruler::DrawTicks()