[Libreoffice-commits] core.git: svtools/source

2015-01-19 Thread dbeurle
 svtools/source/control/ruler.cxx |   29 -
 1 file changed, 16 insertions(+), 13 deletions(-)

New commits:
commit 0a612a5c5c2982bccfe0cd6c5a3bba8d9107e043
Author: dbeurle dbeu...@student.unimelb.edu.au
Date:   Mon Jan 19 09:47:29 2015 +1100

Ruler ticks spacing consistent with lowDPI monitors.  Draw ticks with width

Change-Id: Id636fa87ac7fd4a8c33d65bd72822768bc94b592
Reviewed-on: https://gerrit.libreoffice.org/13987
Reviewed-by: Tomaž Vajngerl qui...@gmail.com
Tested-by: Tomaž Vajngerl qui...@gmail.com

diff --git a/svtools/source/control/ruler.cxx b/svtools/source/control/ruler.cxx
index 96b6aa0..e97386c 100644
--- a/svtools/source/control/ruler.cxx
+++ b/svtools/source/control/ruler.cxx
@@ -463,13 +463,16 @@ void Ruler::ImplDrawTicks( long nMin, long nMax, long 
nStart, long nTop, long nB
 {
 double nCenter = nTop + ((nBottom - nTop) / 2);
 
-long nTickLength3 = (nBottom - nTop) * 0.5 * ruler_tab.DPIScaleFactor;
+long nTickLength3 = (nBottom - nTop) * 0.5;
 long nTickLength2 = nTickLength3 * 0.66;
 long nTickLength1 = nTickLength2 * 0.66;
 
+long nScale = ruler_tab.DPIScaleFactor;
+long DPIOffset = nScale - 1;
+
 double nTick4 = aImplRulerUnitTab[mnUnitIndex].nTick4;
 double nTick2 = 0;
-double nTickCount = aImplRulerUnitTab[mnUnitIndex].nTick1;
+double nTickCount = aImplRulerUnitTab[mnUnitIndex].nTick1 / nScale;
 double nTickUnit = 0;
 long nTickWidth;
 bool bNoTicks = false;
@@ -548,7 +551,7 @@ void Ruler::ImplDrawTicks( long nMin, long nMax, long 
nStart, long nTop, long nB
 else
 nMulti += 1000;
 
-// Overeflow - in this case don't draw ticks and exit
+// Overflow - in this case don't draw ticks and exit
 if ( nMulti  nOldMulti )
 {
 bNoTicks = true;
@@ -630,10 +633,10 @@ void Ruler::ImplDrawTicks( long nMin, long nMax, long 
nStart, long nTop, long nB
 
 if(nMin  nHorizontalLocation  nHorizontalLocation  
nMax)
 {
-ImplVDrawLine(nHorizontalLocation, nBottom, 
nHorizontalLocation,
-nBottom - 1 * ruler_tab.DPIScaleFactor);
-ImplVDrawLine(nHorizontalLocation, nTop,
nHorizontalLocation,
-nTop+ 1 * ruler_tab.DPIScaleFactor);
+ImplVDrawRect(nHorizontalLocation, nBottom, 
nHorizontalLocation + DPIOffset,
+nBottom - 1 * nScale);
+ImplVDrawRect(nHorizontalLocation, nTop,
nHorizontalLocation + DPIOffset,
+nTop+ 1 * nScale);
 }
 
 nHorizontalLocation = nStart - n;
@@ -641,10 +644,10 @@ void Ruler::ImplDrawTicks( long nMin, long nMax, long 
nStart, long nTop, long nB
 
 if(nMin  nHorizontalLocation  nHorizontalLocation  
nMax)
 {
-ImplVDrawLine( nHorizontalLocation, nBottom, 
nHorizontalLocation,
-nBottom - 1 * ruler_tab.DPIScaleFactor );
-ImplVDrawLine( nHorizontalLocation, nTop,
nHorizontalLocation,
-nTop+ 1 * ruler_tab.DPIScaleFactor );
+ImplVDrawRect( nHorizontalLocation, nBottom, 
nHorizontalLocation + DPIOffset,
+nBottom - 1 * nScale );
+ImplVDrawRect( nHorizontalLocation, nTop,
nHorizontalLocation + DPIOffset,
+nTop+ 1 * nScale );
 }
 }
 // Tick/Tick2 - Output (Strokes)
@@ -673,10 +676,10 @@ void Ruler::ImplDrawTicks( long nMin, long nMax, long 
nStart, long nTop, long nB
 nT = nStart + n;
 
 if ( nT  nMax )
-ImplVDrawLine( nT, nT1, nT, nT2 );
+ImplVDrawRect( nT, nT1, nT + DPIOffset, nT2 );
 nT = nStart - n;
 if ( nT  nMin )
-ImplVDrawLine( nT, nT1, nT, nT2 );
+ImplVDrawRect( nT, nT1, nT + DPIOffset, nT2 );
 }
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/svtools svtools/source svx/source

2015-01-14 Thread dbeurle
 include/svtools/ruler.hxx|   24 +
 svtools/source/control/ruler.cxx |  168 ---
 svx/source/dialog/svxruler.cxx   |   27 ++
 3 files changed, 152 insertions(+), 67 deletions(-)

New commits:
commit 8748ae646bd5347ce9b964efbb941a873a7b5e0d
Author: dbeurle dbeu...@student.unimelb.edu.au
Date:   Mon Jan 12 17:36:02 2015 +1100

HiDPI changes to ruler to respect screen DPI

Change-Id: I4cbb303b395ad60d4935bff55fbaea08f13334a0
Reviewed-on: https://gerrit.libreoffice.org/13867
Tested-by: Jenkins c...@libreoffice.org
Reviewed-by: Tomaž Vajngerl qui...@gmail.com
Tested-by: Tomaž Vajngerl qui...@gmail.com
Reviewed-by: Caolán McNamara caol...@redhat.com
Tested-by: Caolán McNamara caol...@redhat.com

diff --git a/include/svtools/ruler.hxx b/include/svtools/ruler.hxx
index 06463cf..8667f69 100644
--- a/include/svtools/ruler.hxx
+++ b/include/svtools/ruler.hxx
@@ -555,8 +555,7 @@ struct RulerTab
 sal_uInt16  nStyle;
 };
 
-#define RULER_TAB_WIDTH 7
-#define RULER_TAB_HEIGHT6
+
 
 // - RulerLine -
 
@@ -600,6 +599,27 @@ struct RulerUnitData
 sal_CharaUnitStr[8];// Unit string
 };
 
+// Data for drawing ruler tabstops
+struct RulerTabData
+{
+sal_uInt16  DPIScaleFactor;
+sal_uInt16  width;
+sal_uInt16  height;
+sal_uInt16  height2;
+sal_uInt16  width2;
+sal_uInt16  cwidth;
+sal_uInt16  cwidth2;
+sal_uInt16  cwidth3;
+sal_uInt16  cwidth4;
+sal_uInt16  dheight;
+sal_uInt16  dheight2;
+sal_uInt16  dwidth;
+sal_uInt16  dwidth2;
+sal_uInt16  dwidth3;
+sal_uInt16  dwidth4;
+sal_uInt16  textoff;
+};
+
 // - Ruler -
 
 class ImplRulerData;
diff --git a/svtools/source/control/ruler.cxx b/svtools/source/control/ruler.cxx
index fa16f47..96b6aa0 100644
--- a/svtools/source/control/ruler.cxx
+++ b/svtools/source/control/ruler.cxx
@@ -39,25 +39,11 @@ using namespace ::com::sun::star::lang;
 using namespace ::com::sun::star::accessibility;
 
 #define RULER_OFF   3
-#define RULER_TEXTOFF   5
 #define RULER_RESIZE_OFF4
 #define RULER_MIN_SIZE  3
 
 #define RULER_VAR_SIZE  8
 
-#define RULER_TAB_HEIGHT2   2
-#define RULER_TAB_WIDTH22
-#define RULER_TAB_CWIDTH8
-#define RULER_TAB_CWIDTH2   4
-#define RULER_TAB_CWIDTH3   4
-#define RULER_TAB_CWIDTH4   2
-#define RULER_TAB_DHEIGHT   4
-#define RULER_TAB_DHEIGHT2  1
-#define RULER_TAB_DWIDTH5
-#define RULER_TAB_DWIDTH2   3
-#define RULER_TAB_DWIDTH3   3
-#define RULER_TAB_DWIDTH4   1
-
 #define RULER_UPDATE_LINES  0x01
 #define RULER_UPDATE_DRAW   0x02
 
@@ -207,6 +193,26 @@ static const RulerUnitData 
aImplRulerUnitTab[RULER_UNIT_COUNT] =
 { MAP_100TH_MM,551,   551.0,   551.0,551.0,   1102.0, 551, 3, 
 li}  // LINE
 };
 
+static RulerTabData ruler_tab =
+{
+0, // DPIScaleFactor to be set
+7, // ruler_tab_width
+6, // ruler_tab_height
+2, // ruler_tab_height2
+2, // ruler_tab_width2
+8, // ruler_tab_cwidth
+4, // ruler_tab_cwidth2
+4, // ruler_tab_cwidth3
+2, // ruler_tab_cwidth4
+4, // ruler_tab_dheight
+1, // ruler_tab_dheight2
+5, // ruler_tab_dwidth
+3, // ruler_tab_dwidth2
+3, // ruler_tab_dwidth3
+1, // ruler_tab_dwidth4
+5  // ruler_tab_textoff
+};
+
 void Ruler::ImplInit( WinBits nWinBits )
 {
 // Default WinBits setzen
@@ -219,7 +225,7 @@ void Ruler::ImplInit( WinBits nWinBits )
 EnableRTL( false );
 }
 
-// Variablen initialisieren
+// Initialize variables
 mnWinStyle  = nWinBits; // Window-Style
 mnBorderOff = 0;// Border-Offset
 mnWinOff= 0;// EditWinOffset
@@ -270,7 +276,7 @@ void Ruler::ImplInit( WinBits nWinBits )
 // Setup the default size
 Rectangle aRect;
 GetTextBoundRect( aRect, OUString( 0123456789 ) );
-long nDefHeight = aRect.GetHeight() + RULER_OFF * 2 + RULER_TEXTOFF * 2 + 
mnBorderWidth;
+long nDefHeight = aRect.GetHeight() + RULER_OFF * 2 + ruler_tab.textoff * 
2 + mnBorderWidth;
 
 Size aDefSize;
 if ( nWinBits  WB_HORZ )
@@ -290,7 +296,32 @@ Ruler::Ruler( vcl::Window* pParent, WinBits nWinStyle ) :
 mpData(NULL),
 mpDragData(new ImplRulerData)
 {
+
+// Check to see if the ruler constructor has
+// already been called before otherwise
+// we end up with over-scaled elements
+if( ruler_tab.DPIScaleFactor == 0 )
+{
+ruler_tab.DPIScaleFactor = pParent-GetDPIScaleFactor();
+ruler_tab.width*= ruler_tab.DPIScaleFactor;
+ruler_tab.height   *= ruler_tab.DPIScaleFactor;
+ruler_tab.height2  *= ruler_tab.DPIScaleFactor;
+ruler_tab.width2   *= ruler_tab.DPIScaleFactor;
+ruler_tab.cwidth   *= ruler_tab.DPIScaleFactor;
+ruler_tab.cwidth2  *= ruler_tab.DPIScaleFactor;
+ruler_tab.cwidth3  *= ruler_tab.DPIScaleFactor;
+ruler_tab.cwidth4