Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
a97fc29f
Kaydet (Commit)
a97fc29f
authored
May 18, 2015
tarafından
Tomaž Vajngerl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
refactor scanner ext. to use RenderContext
Change-Id: I31e4ea09b3a7bd65e589481c4c128275a8a7c1b7
üst
b4bbb5e5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
132 additions
and
117 deletions
+132
-117
grid.cxx
extensions/source/scanner/grid.cxx
+56
-54
sanedlg.cxx
extensions/source/scanner/sanedlg.cxx
+76
-63
No files found.
extensions/source/scanner/grid.cxx
Dosyayı görüntüle @
a97fc29f
...
@@ -50,10 +50,10 @@ class GridWindow : public vcl::Window
...
@@ -50,10 +50,10 @@ class GridWindow : public vcl::Window
return
(
maPos
.
X
()
<
rComp
.
maPos
.
X
());
return
(
maPos
.
X
()
<
rComp
.
maPos
.
X
());
}
}
void
draw
(
vcl
::
Window
&
rWin
,
const
BitmapEx
&
rBitmapEx
)
void
draw
(
vcl
::
RenderContext
&
rRenderContext
,
const
BitmapEx
&
rBitmapEx
)
{
{
const
Point
aOffset
(
r
Win
.
PixelToLogic
(
Point
(
mnOffX
,
mnOffY
)));
const
Point
aOffset
(
r
RenderContext
.
PixelToLogic
(
Point
(
mnOffX
,
mnOffY
)));
r
Win
.
DrawBitmapEx
(
maPos
-
aOffset
,
rBitmapEx
);
r
RenderContext
.
DrawBitmapEx
(
maPos
-
aOffset
,
rBitmapEx
);
}
}
bool
isHit
(
vcl
::
Window
&
rWin
,
const
Point
&
rPos
)
bool
isHit
(
vcl
::
Window
&
rWin
,
const
Point
&
rPos
)
...
@@ -100,10 +100,10 @@ class GridWindow : public vcl::Window
...
@@ -100,10 +100,10 @@ class GridWindow : public vcl::Window
double
findMaxX
();
double
findMaxX
();
double
findMaxY
();
double
findMaxY
();
void
drawGrid
();
void
drawGrid
(
vcl
::
RenderContext
&
rRenderContext
);
void
drawOriginal
();
void
drawOriginal
(
vcl
::
RenderContext
&
rRenderContext
);
void
drawNew
();
void
drawNew
(
vcl
::
RenderContext
&
rRenderContext
);
void
drawHandles
();
void
drawHandles
(
vcl
::
RenderContext
&
rRenderContext
);
void
computeExtremes
();
void
computeExtremes
();
static
void
computeChunk
(
double
fMin
,
double
fMax
,
double
&
fChunkOut
,
double
&
fMinChunkOut
);
static
void
computeChunk
(
double
fMin
,
double
fMax
,
double
&
fChunkOut
,
double
&
fMinChunkOut
);
...
@@ -116,7 +116,7 @@ class GridWindow : public vcl::Window
...
@@ -116,7 +116,7 @@ class GridWindow : public vcl::Window
void
onResize
();
void
onResize
();
virtual
void
Resize
()
SAL_OVERRIDE
;
virtual
void
Resize
()
SAL_OVERRIDE
;
virtual
Size
GetOptimalSize
()
const
SAL_OVERRIDE
;
virtual
Size
GetOptimalSize
()
const
SAL_OVERRIDE
;
void
drawLine
(
double
x1
,
double
y1
,
double
x2
,
double
y2
);
void
drawLine
(
vcl
::
RenderContext
&
rRenderContext
,
double
x1
,
double
y1
,
double
x2
,
double
y2
);
public
:
public
:
GridWindow
(
vcl
::
Window
*
pParent
);
GridWindow
(
vcl
::
Window
*
pParent
);
void
Init
(
double
*
pXValues
,
double
*
pYValues
,
int
nValues
,
bool
bCutValues
,
const
BitmapEx
&
rMarkerBitmap
);
void
Init
(
double
*
pXValues
,
double
*
pYValues
,
int
nValues
,
bool
bCutValues
,
const
BitmapEx
&
rMarkerBitmap
);
...
@@ -336,9 +336,9 @@ void GridWindow::transform( const Point& rOriginal, double& x, double& y )
...
@@ -336,9 +336,9 @@ void GridWindow::transform( const Point& rOriginal, double& x, double& y )
y
=
(
m_aGridArea
.
Bottom
()
-
rOriginal
.
Y
()
)
*
(
m_fMaxY
-
m_fMinY
)
/
(
double
)
nHeight
+
m_fMinY
;
y
=
(
m_aGridArea
.
Bottom
()
-
rOriginal
.
Y
()
)
*
(
m_fMaxY
-
m_fMinY
)
/
(
double
)
nHeight
+
m_fMinY
;
}
}
void
GridWindow
::
drawLine
(
double
x1
,
double
y1
,
double
x2
,
double
y2
)
void
GridWindow
::
drawLine
(
vcl
::
RenderContext
&
rRenderContext
,
double
x1
,
double
y1
,
double
x2
,
double
y2
)
{
{
DrawLine
(
transform
(
x1
,
y1
),
transform
(
x2
,
y2
)
);
rRenderContext
.
DrawLine
(
transform
(
x1
,
y1
),
transform
(
x2
,
y2
)
);
}
}
void
GridWindow
::
computeChunk
(
double
fMin
,
double
fMax
,
double
&
fChunkOut
,
double
&
fMinChunkOut
)
void
GridWindow
::
computeChunk
(
double
fMin
,
double
fMax
,
double
&
fChunkOut
,
double
&
fMinChunkOut
)
...
@@ -455,87 +455,89 @@ void GridWindow::setBoundings(double fMinX, double fMinY, double fMaxX, double f
...
@@ -455,87 +455,89 @@ void GridWindow::setBoundings(double fMinX, double fMinY, double fMaxX, double f
computeChunk
(
m_fMinY
,
m_fMaxY
,
m_fChunkY
,
m_fMinChunkY
);
computeChunk
(
m_fMinY
,
m_fMaxY
,
m_fChunkY
,
m_fMinChunkY
);
}
}
void
GridWindow
::
drawGrid
()
void
GridWindow
::
drawGrid
(
vcl
::
RenderContext
&
rRenderContext
)
{
{
char
pBuf
[
256
];
char
pBuf
[
256
];
SetLineColor
(
Color
(
COL_BLACK
)
);
rRenderContext
.
SetLineColor
(
Color
(
COL_BLACK
)
);
// draw vertical lines
// draw vertical lines
for
(
double
fX
=
m_fMinChunkX
;
fX
<
m_fMaxX
;
fX
+=
m_fChunkX
)
for
(
double
fX
=
m_fMinChunkX
;
fX
<
m_fMaxX
;
fX
+=
m_fChunkX
)
{
{
drawLine
(
fX
,
m_fMinY
,
fX
,
m_fMaxY
);
drawLine
(
rRenderContext
,
fX
,
m_fMinY
,
fX
,
m_fMaxY
);
// draw tickmarks
// draw tickmarks
Point
aPt
=
transform
(
fX
,
m_fMinY
);
Point
aPt
=
transform
(
fX
,
m_fMinY
);
std
::
sprintf
(
pBuf
,
"%g"
,
fX
);
std
::
sprintf
(
pBuf
,
"%g"
,
fX
);
OUString
aMark
(
pBuf
,
strlen
(
pBuf
),
osl_getThreadTextEncoding
()
);
OUString
aMark
(
pBuf
,
strlen
(
pBuf
),
osl_getThreadTextEncoding
()
);
Size
aTextSize
(
GetTextWidth
(
aMark
),
GetTextHeight
()
);
Size
aTextSize
(
rRenderContext
.
GetTextWidth
(
aMark
),
rRenderContext
.
GetTextHeight
()
);
aPt
.
X
()
-=
aTextSize
.
Width
()
/
2
;
aPt
.
X
()
-=
aTextSize
.
Width
()
/
2
;
aPt
.
Y
()
+=
aTextSize
.
Height
()
/
2
;
aPt
.
Y
()
+=
aTextSize
.
Height
()
/
2
;
DrawText
(
aPt
,
aMark
);
rRenderContext
.
DrawText
(
aPt
,
aMark
);
}
}
// draw horizontal lines
// draw horizontal lines
for
(
double
fY
=
m_fMinChunkY
;
fY
<
m_fMaxY
;
fY
+=
m_fChunkY
)
for
(
double
fY
=
m_fMinChunkY
;
fY
<
m_fMaxY
;
fY
+=
m_fChunkY
)
{
{
drawLine
(
m_fMinX
,
fY
,
m_fMaxX
,
fY
);
drawLine
(
rRenderContext
,
m_fMinX
,
fY
,
m_fMaxX
,
fY
);
// draw tickmarks
// draw tickmarks
Point
aPt
=
transform
(
m_fMinX
,
fY
);
Point
aPt
=
transform
(
m_fMinX
,
fY
);
std
::
sprintf
(
pBuf
,
"%g"
,
fY
);
std
::
sprintf
(
pBuf
,
"%g"
,
fY
);
OUString
aMark
(
pBuf
,
strlen
(
pBuf
),
osl_getThreadTextEncoding
()
);
OUString
aMark
(
pBuf
,
strlen
(
pBuf
),
osl_getThreadTextEncoding
()
);
Size
aTextSize
(
GetTextWidth
(
aMark
),
GetTextHeight
()
);
Size
aTextSize
(
rRenderContext
.
GetTextWidth
(
aMark
),
rRenderContext
.
GetTextHeight
()
);
aPt
.
X
()
-=
aTextSize
.
Width
()
+
2
;
aPt
.
X
()
-=
aTextSize
.
Width
()
+
2
;
aPt
.
Y
()
-=
aTextSize
.
Height
()
/
2
;
aPt
.
Y
()
-=
aTextSize
.
Height
()
/
2
;
DrawText
(
aPt
,
aMark
);
rRenderContext
.
DrawText
(
aPt
,
aMark
);
}
}
// draw boundings
// draw boundings
drawLine
(
m_fMinX
,
m_fMinY
,
m_fMaxX
,
m_fMinY
);
drawLine
(
rRenderContext
,
m_fMinX
,
m_fMinY
,
m_fMaxX
,
m_fMinY
);
drawLine
(
m_fMinX
,
m_fMaxY
,
m_fMaxX
,
m_fMaxY
);
drawLine
(
rRenderContext
,
m_fMinX
,
m_fMaxY
,
m_fMaxX
,
m_fMaxY
);
drawLine
(
m_fMinX
,
m_fMinY
,
m_fMinX
,
m_fMaxY
);
drawLine
(
rRenderContext
,
m_fMinX
,
m_fMinY
,
m_fMinX
,
m_fMaxY
);
drawLine
(
m_fMaxX
,
m_fMinY
,
m_fMaxX
,
m_fMaxY
);
drawLine
(
rRenderContext
,
m_fMaxX
,
m_fMinY
,
m_fMaxX
,
m_fMaxY
);
}
}
void
GridWindow
::
drawOriginal
()
void
GridWindow
::
drawOriginal
(
vcl
::
RenderContext
&
rRenderContext
)
{
{
if
(
m_nValues
&&
m_pXValues
&&
m_pOrigYValues
)
if
(
m_nValues
&&
m_pXValues
&&
m_pOrigYValues
)
{
{
SetLineColor
(
Color
(
COL_RED
)
);
rRenderContext
.
SetLineColor
(
Color
(
COL_RED
)
);
for
(
int
i
=
0
;
i
<
m_nValues
-
1
;
i
++
)
for
(
int
i
=
0
;
i
<
m_nValues
-
1
;
i
++
)
{
{
drawLine
(
m_pXValues
[
i
],
m_pOrigYValues
[
i
],
drawLine
(
rRenderContext
,
m_pXValues
[
i
+
1
],
m_pOrigYValues
[
i
+
1
]
);
m_pXValues
[
i
],
m_pOrigYValues
[
i
],
m_pXValues
[
i
+
1
],
m_pOrigYValues
[
i
+
1
]);
}
}
}
}
}
}
void
GridWindow
::
drawNew
()
void
GridWindow
::
drawNew
(
vcl
::
RenderContext
&
rRenderContext
)
{
{
if
(
m_nValues
&&
m_pXValues
&&
m_pNewYValues
)
if
(
m_nValues
&&
m_pXValues
&&
m_pNewYValues
)
{
{
SetClipRegion
(
vcl
::
Region
(
m_aGridArea
));
rRenderContext
.
SetClipRegion
(
vcl
::
Region
(
m_aGridArea
));
SetLineColor
(
Color
(
COL_YELLOW
)
);
rRenderContext
.
SetLineColor
(
Color
(
COL_YELLOW
)
);
for
(
int
i
=
0
;
i
<
m_nValues
-
1
;
i
++
)
for
(
int
i
=
0
;
i
<
m_nValues
-
1
;
i
++
)
{
{
drawLine
(
m_pXValues
[
i
],
m_pNewYValues
[
i
],
drawLine
(
rRenderContext
,
m_pXValues
[
i
+
1
],
m_pNewYValues
[
i
+
1
]
);
m_pXValues
[
i
],
m_pNewYValues
[
i
],
m_pXValues
[
i
+
1
],
m_pNewYValues
[
i
+
1
]);
}
}
SetClipRegion
();
rRenderContext
.
SetClipRegion
();
}
}
}
}
void
GridWindow
::
drawHandles
()
void
GridWindow
::
drawHandles
(
vcl
::
RenderContext
&
rRenderContext
)
{
{
for
(
sal_uInt32
i
(
0L
);
i
<
m_aHandles
.
size
();
i
++
)
for
(
sal_uInt32
i
(
0L
);
i
<
m_aHandles
.
size
();
i
++
)
{
{
m_aHandles
[
i
].
draw
(
*
this
,
m_aMarkerBitmap
);
m_aHandles
[
i
].
draw
(
rRenderContext
,
m_aMarkerBitmap
);
}
}
}
}
void
GridWindow
::
Paint
(
vcl
::
RenderContext
&
rRenderContext
,
const
Rectangle
&
rRect
)
void
GridWindow
::
Paint
(
vcl
::
RenderContext
&
rRenderContext
,
const
Rectangle
&
rRect
)
{
{
Window
::
Paint
(
rRenderContext
,
rRect
);
Window
::
Paint
(
rRenderContext
,
rRect
);
drawGrid
();
drawGrid
(
rRenderContext
);
drawOriginal
();
drawOriginal
(
rRenderContext
);
drawNew
();
drawNew
(
rRenderContext
);
drawHandles
();
drawHandles
(
rRenderContext
);
}
}
void
GridWindow
::
MouseMove
(
const
MouseEvent
&
rEvt
)
void
GridWindow
::
MouseMove
(
const
MouseEvent
&
rEvt
)
...
...
extensions/source/scanner/sanedlg.cxx
Dosyayı görüntüle @
a97fc29f
...
@@ -50,7 +50,7 @@ private:
...
@@ -50,7 +50,7 @@ private:
bool
mbDragDrawn
;
bool
mbDragDrawn
;
bool
mbIsDragging
;
bool
mbIsDragging
;
void
DrawRectangles
(
Point
&
rUL
,
Point
&
rBR
);
void
DrawRectangles
(
vcl
::
RenderContext
&
rRenderContext
,
Point
&
rUL
,
Point
&
rBR
);
public
:
public
:
ScanPreview
(
vcl
::
Window
*
pParent
,
WinBits
nStyle
)
ScanPreview
(
vcl
::
Window
*
pParent
,
WinBits
nStyle
)
:
Window
(
pParent
,
nStyle
)
:
Window
(
pParent
,
nStyle
)
...
@@ -62,16 +62,23 @@ public:
...
@@ -62,16 +62,23 @@ public:
,
mbIsDragging
(
false
)
,
mbIsDragging
(
false
)
{
{
}
}
virtual
~
ScanPreview
()
{
disposeOnce
();
}
virtual
~
ScanPreview
()
{
disposeOnce
();
}
virtual
void
dispose
()
SAL_OVERRIDE
virtual
void
dispose
()
SAL_OVERRIDE
{
{
mpParentDialog
.
clear
();
mpParentDialog
.
clear
();
vcl
::
Window
::
dispose
();
vcl
::
Window
::
dispose
();
}
}
void
Init
(
SaneDlg
*
pParent
)
void
Init
(
SaneDlg
*
pParent
)
{
{
mpParentDialog
=
pParent
;
mpParentDialog
=
pParent
;
}
}
void
ResetForNewScanner
()
void
ResetForNewScanner
()
{
{
maTopLeft
=
Point
();
maTopLeft
=
Point
();
...
@@ -79,15 +86,27 @@ public:
...
@@ -79,15 +86,27 @@ public:
maMinTopLeft
=
Point
();
maMinTopLeft
=
Point
();
maMaxBottomRight
=
Point
(
PREVIEW_WIDTH
,
PREVIEW_HEIGHT
);
maMaxBottomRight
=
Point
(
PREVIEW_WIDTH
,
PREVIEW_HEIGHT
);
}
}
void
EnableDrag
()
{
mbDragEnable
=
true
;
}
void
DisableDrag
()
{
mbDragEnable
=
false
;
}
void
EnableDrag
()
bool
IsDragEnabled
()
{
return
mbDragEnable
;
}
{
virtual
void
Paint
(
vcl
::
RenderContext
&
/*rRenderContext*/
,
const
Rectangle
&
rRect
)
SAL_OVERRIDE
;
mbDragEnable
=
true
;
}
void
DisableDrag
()
{
mbDragEnable
=
false
;
}
bool
IsDragEnabled
()
{
return
mbDragEnable
;
}
virtual
void
Paint
(
vcl
::
RenderContext
&
rRenderContext
,
const
Rectangle
&
rRect
)
SAL_OVERRIDE
;
virtual
void
MouseButtonDown
(
const
MouseEvent
&
rMEvt
)
SAL_OVERRIDE
;
virtual
void
MouseButtonDown
(
const
MouseEvent
&
rMEvt
)
SAL_OVERRIDE
;
virtual
void
MouseMove
(
const
MouseEvent
&
rMEvt
)
SAL_OVERRIDE
;
virtual
void
MouseMove
(
const
MouseEvent
&
rMEvt
)
SAL_OVERRIDE
;
virtual
void
MouseButtonUp
(
const
MouseEvent
&
rMEvt
)
SAL_OVERRIDE
;
virtual
void
MouseButtonUp
(
const
MouseEvent
&
rMEvt
)
SAL_OVERRIDE
;
Point
GetPixelPos
(
const
Point
&
rIn
)
const
;
Point
GetPixelPos
(
const
Point
&
rIn
)
const
;
Point
GetLogicPos
(
const
Point
&
rIn
)
const
;
Point
GetLogicPos
(
const
Point
&
rIn
)
const
;
void
GetPreviewLogicRect
(
Point
&
rTopLeft
,
Point
&
rBottomRight
)
const
void
GetPreviewLogicRect
(
Point
&
rTopLeft
,
Point
&
rBottomRight
)
const
{
{
rTopLeft
=
GetLogicPos
(
maTopLeft
);
rTopLeft
=
GetLogicPos
(
maTopLeft
);
...
@@ -127,17 +146,16 @@ public:
...
@@ -127,17 +146,16 @@ public:
{
{
maTopLeft
=
GetPixelPos
(
rTopLeft
);
maTopLeft
=
GetPixelPos
(
rTopLeft
);
maBottomRight
=
GetPixelPos
(
rBottomRight
);
maBottomRight
=
GetPixelPos
(
rBottomRight
);
maPreviewRect
=
Rectangle
(
maTopLeft
,
maPreviewRect
=
Rectangle
(
maTopLeft
,
Size
(
maBottomRight
.
X
()
-
maTopLeft
.
X
(),
Size
(
maBottomRight
.
X
()
-
maTopLeft
.
X
(),
maBottomRight
.
Y
()
-
maTopLeft
.
Y
()
)
maBottomRight
.
Y
()
-
maTopLeft
.
Y
()));
);
}
}
void
SetPreviewMaxRect
(
const
Point
&
rTopLeft
,
const
Point
&
rBottomRight
)
void
SetPreviewMaxRect
(
const
Point
&
rTopLeft
,
const
Point
&
rBottomRight
)
{
{
maMinTopLeft
=
rTopLeft
;
maMinTopLeft
=
rTopLeft
;
maMaxBottomRight
=
rBottomRight
;
maMaxBottomRight
=
rBottomRight
;
}
}
void
DrawDrag
();
void
DrawDrag
(
vcl
::
RenderContext
&
rRenderContext
);
void
UpdatePreviewBounds
();
void
UpdatePreviewBounds
();
void
SetBitmap
(
SvStream
&
rStream
)
void
SetBitmap
(
SvStream
&
rStream
)
{
{
...
@@ -233,14 +251,10 @@ SaneDlg::SaneDlg( vcl::Window* pParent, Sane& rSane, bool bScanEnabled ) :
...
@@ -233,14 +251,10 @@ SaneDlg::SaneDlg( vcl::Window* pParent, Sane& rSane, bool bScanEnabled ) :
maOldLink
=
mrSane
.
SetReloadOptionsHdl
(
LINK
(
this
,
SaneDlg
,
ReloadSaneOptionsHdl
)
);
maOldLink
=
mrSane
.
SetReloadOptionsHdl
(
LINK
(
this
,
SaneDlg
,
ReloadSaneOptionsHdl
)
);
mpOptionBox
->
SetNodeBitmaps
(
get
<
FixedImage
>
(
"plus"
)
->
GetImage
(),
mpOptionBox
->
SetNodeBitmaps
(
get
<
FixedImage
>
(
"plus"
)
->
GetImage
(),
get
<
FixedImage
>
(
"minus"
)
->
GetImage
());
get
<
FixedImage
>
(
"minus"
)
->
GetImage
());
mpOptionBox
->
SetStyle
(
mpOptionBox
->
GetStyle
()
|
mpOptionBox
->
SetStyle
(
mpOptionBox
->
GetStyle
()
|
WB_HASLINES
|
WB_HASLINES
|
WB_HASBUTTONS
|
WB_NOINITIALSELECTION
|
WB_HASBUTTONS
|
WB_HASBUTTONSATROOT
|
WB_HASLINESATROOT
);
WB_NOINITIALSELECTION
|
WB_HASBUTTONSATROOT
|
WB_HASLINESATROOT
);
}
}
SaneDlg
::~
SaneDlg
()
SaneDlg
::~
SaneDlg
()
...
@@ -250,7 +264,7 @@ SaneDlg::~SaneDlg()
...
@@ -250,7 +264,7 @@ SaneDlg::~SaneDlg()
void
SaneDlg
::
dispose
()
void
SaneDlg
::
dispose
()
{
{
mrSane
.
SetReloadOptionsHdl
(
maOldLink
);
mrSane
.
SetReloadOptionsHdl
(
maOldLink
);
mpOKButton
.
clear
();
mpOKButton
.
clear
();
mpCancelButton
.
clear
();
mpCancelButton
.
clear
();
mpDeviceInfoButton
.
clear
();
mpDeviceInfoButton
.
clear
();
...
@@ -811,22 +825,22 @@ IMPL_LINK( SaneDlg, ModifyHdl, Edit*, pEdit )
...
@@ -811,22 +825,22 @@ IMPL_LINK( SaneDlg, ModifyHdl, Edit*, pEdit )
else
if
(
pEdit
==
mpTopField
)
else
if
(
pEdit
==
mpTopField
)
{
{
mpPreview
->
ChangePreviewLogicTopLeftY
(
mpTopField
->
GetValue
());
mpPreview
->
ChangePreviewLogicTopLeftY
(
mpTopField
->
GetValue
());
mpPreview
->
DrawDrag
();
mpPreview
->
Invalidate
();
}
}
else
if
(
pEdit
==
mpLeftField
)
else
if
(
pEdit
==
mpLeftField
)
{
{
mpPreview
->
ChangePreviewLogicTopLeftX
(
mpLeftField
->
GetValue
());
mpPreview
->
ChangePreviewLogicTopLeftX
(
mpLeftField
->
GetValue
());
mpPreview
->
DrawDrag
();
mpPreview
->
Invalidate
();
}
}
else
if
(
pEdit
==
mpBottomField
)
else
if
(
pEdit
==
mpBottomField
)
{
{
mpPreview
->
ChangePreviewLogicBottomRightY
(
mpBottomField
->
GetValue
());
mpPreview
->
ChangePreviewLogicBottomRightY
(
mpBottomField
->
GetValue
());
mpPreview
->
DrawDrag
();
mpPreview
->
Invalidate
();
}
}
else
if
(
pEdit
==
mpRightField
)
else
if
(
pEdit
==
mpRightField
)
{
{
mpPreview
->
ChangePreviewLogicBottomRightX
(
mpRightField
->
GetValue
());
mpPreview
->
ChangePreviewLogicBottomRightX
(
mpRightField
->
GetValue
());
mpPreview
->
DrawDrag
();
mpPreview
->
Invalidate
();
}
}
}
}
return
0
;
return
0
;
...
@@ -918,18 +932,17 @@ void ScanPreview::UpdatePreviewBounds()
...
@@ -918,18 +932,17 @@ void ScanPreview::UpdatePreviewBounds()
void
ScanPreview
::
Paint
(
vcl
::
RenderContext
&
rRenderContext
,
const
Rectangle
&
rRect
)
void
ScanPreview
::
Paint
(
vcl
::
RenderContext
&
rRenderContext
,
const
Rectangle
&
rRect
)
{
{
Window
::
Paint
(
rRenderContext
,
rRect
);
Window
::
Paint
(
rRenderContext
,
rRect
);
SetMapMode
(
MAP_APPFONT
);
rRenderContext
.
SetMapMode
(
MAP_APPFONT
);
SetFillColor
(
Color
(
COL_WHITE
)
);
rRenderContext
.
SetFillColor
(
Color
(
COL_WHITE
)
);
SetLineColor
(
Color
(
COL_WHITE
)
);
rRenderContext
.
SetLineColor
(
Color
(
COL_WHITE
)
);
DrawRect
(
Rectangle
(
Point
(
0
,
0
),
rRenderContext
.
DrawRect
(
Rectangle
(
Point
(
0
,
0
),
Size
(
PREVIEW_WIDTH
,
PREVIEW_HEIGHT
)
)
);
Size
(
PREVIEW_WIDTH
,
PREVIEW_HEIGHT
))
);
SetMapMode
(
MapMode
(
MAP_PIXEL
)
);
rRenderContext
.
SetMapMode
(
MapMode
(
MAP_PIXEL
)
);
// check for sane values
// check for sane values
DrawBitmap
(
maPreviewRect
.
TopLeft
(),
maPreviewRect
.
GetSize
(),
rRenderContext
.
DrawBitmap
(
maPreviewRect
.
TopLeft
(),
maPreviewRect
.
GetSize
(),
maPreviewBitmap
);
maPreviewBitmap
);
mbDragDrawn
=
false
;
mbDragDrawn
=
false
;
DrawDrag
();
DrawDrag
(
rRenderContext
);
}
}
void
SaneDlg
::
DisableOption
()
void
SaneDlg
::
DisableOption
()
...
@@ -1102,7 +1115,7 @@ void ScanPreview::MouseMove(const MouseEvent& rMEvt)
...
@@ -1102,7 +1115,7 @@ void ScanPreview::MouseMove(const MouseEvent& rMEvt)
maTopLeft
.
Y
()
=
maBottomRight
.
Y
();
maTopLeft
.
Y
()
=
maBottomRight
.
Y
();
maBottomRight
.
Y
()
=
nSwap
;
maBottomRight
.
Y
()
=
nSwap
;
}
}
DrawDrag
();
Invalidate
();
mpParentDialog
->
UpdateScanArea
(
false
);
mpParentDialog
->
UpdateScanArea
(
false
);
}
}
Window
::
MouseMove
(
rMEvt
);
Window
::
MouseMove
(
rMEvt
);
...
@@ -1188,7 +1201,7 @@ void ScanPreview::MouseButtonDown( const MouseEvent& rMEvt )
...
@@ -1188,7 +1201,7 @@ void ScanPreview::MouseButtonDown( const MouseEvent& rMEvt )
if
(
mbIsDragging
)
if
(
mbIsDragging
)
{
{
SetPointerPosPixel
(
aMousePixel
);
SetPointerPosPixel
(
aMousePixel
);
DrawDrag
();
Invalidate
();
}
}
Window
::
MouseButtonDown
(
rMEvt
);
Window
::
MouseButtonDown
(
rMEvt
);
}
}
...
@@ -1204,51 +1217,51 @@ void ScanPreview::MouseButtonUp( const MouseEvent& rMEvt )
...
@@ -1204,51 +1217,51 @@ void ScanPreview::MouseButtonUp( const MouseEvent& rMEvt )
Window
::
MouseButtonUp
(
rMEvt
);
Window
::
MouseButtonUp
(
rMEvt
);
}
}
void
ScanPreview
::
DrawRectangles
(
Point
&
rUL
,
Point
&
rBR
)
void
ScanPreview
::
DrawRectangles
(
vcl
::
RenderContext
&
rRenderContext
,
Point
&
rUL
,
Point
&
rBR
)
{
{
int
nMiddleX
,
nMiddleY
;
int
nMiddleX
,
nMiddleY
;
Point
aBL
,
aUR
;
Point
aBL
,
aUR
;
aUR
=
Point
(
rBR
.
X
(),
rUL
.
Y
()
);
aUR
=
Point
(
rBR
.
X
(),
rUL
.
Y
()
);
aBL
=
Point
(
rUL
.
X
(),
rBR
.
Y
()
);
aBL
=
Point
(
rUL
.
X
(),
rBR
.
Y
()
);
nMiddleX
=
(
rBR
.
X
()
-
rUL
.
X
()
)
/
2
+
rUL
.
X
();
nMiddleX
=
(
rBR
.
X
()
-
rUL
.
X
()
)
/
2
+
rUL
.
X
();
nMiddleY
=
(
rBR
.
Y
()
-
rUL
.
Y
()
)
/
2
+
rUL
.
Y
();
nMiddleY
=
(
rBR
.
Y
()
-
rUL
.
Y
()
)
/
2
+
rUL
.
Y
();
DrawLine
(
rUL
,
aBL
);
rRenderContext
.
DrawLine
(
rUL
,
aBL
);
DrawLine
(
aBL
,
rBR
);
rRenderContext
.
DrawLine
(
aBL
,
rBR
);
DrawLine
(
rBR
,
aUR
);
rRenderContext
.
DrawLine
(
rBR
,
aUR
);
DrawLine
(
aUR
,
rUL
);
rRenderContext
.
DrawLine
(
aUR
,
rUL
);
DrawRect
(
Rectangle
(
rUL
,
Size
(
RECT_SIZE_PIX
,
RECT_SIZE_PIX
)
)
);
rRenderContext
.
DrawRect
(
Rectangle
(
rUL
,
Size
(
RECT_SIZE_PIX
,
RECT_SIZE_PIX
))
);
DrawRect
(
Rectangle
(
aBL
,
Size
(
RECT_SIZE_PIX
,
-
RECT_SIZE_PIX
)
)
);
rRenderContext
.
DrawRect
(
Rectangle
(
aBL
,
Size
(
RECT_SIZE_PIX
,
-
RECT_SIZE_PIX
))
);
DrawRect
(
Rectangle
(
rBR
,
Size
(
-
RECT_SIZE_PIX
,
-
RECT_SIZE_PIX
)
)
);
rRenderContext
.
DrawRect
(
Rectangle
(
rBR
,
Size
(
-
RECT_SIZE_PIX
,
-
RECT_SIZE_PIX
))
);
DrawRect
(
Rectangle
(
aUR
,
Size
(
-
RECT_SIZE_PIX
,
RECT_SIZE_PIX
)
)
);
rRenderContext
.
DrawRect
(
Rectangle
(
aUR
,
Size
(
-
RECT_SIZE_PIX
,
RECT_SIZE_PIX
))
);
DrawRect
(
Rectangle
(
Point
(
nMiddleX
-
RECT_SIZE_PIX
/
2
,
rUL
.
Y
()
),
Size
(
RECT_SIZE_PIX
,
RECT_SIZE_PIX
)
)
);
rRenderContext
.
DrawRect
(
Rectangle
(
Point
(
nMiddleX
-
RECT_SIZE_PIX
/
2
,
rUL
.
Y
()),
Size
(
RECT_SIZE_PIX
,
RECT_SIZE_PIX
))
);
DrawRect
(
Rectangle
(
Point
(
nMiddleX
-
RECT_SIZE_PIX
/
2
,
rBR
.
Y
()
),
Size
(
RECT_SIZE_PIX
,
-
RECT_SIZE_PIX
)
)
);
rRenderContext
.
DrawRect
(
Rectangle
(
Point
(
nMiddleX
-
RECT_SIZE_PIX
/
2
,
rBR
.
Y
()),
Size
(
RECT_SIZE_PIX
,
-
RECT_SIZE_PIX
))
);
DrawRect
(
Rectangle
(
Point
(
rUL
.
X
(),
nMiddleY
-
RECT_SIZE_PIX
/
2
),
Size
(
RECT_SIZE_PIX
,
RECT_SIZE_PIX
)
)
);
rRenderContext
.
DrawRect
(
Rectangle
(
Point
(
rUL
.
X
(),
nMiddleY
-
RECT_SIZE_PIX
/
2
),
Size
(
RECT_SIZE_PIX
,
RECT_SIZE_PIX
))
);
DrawRect
(
Rectangle
(
Point
(
rBR
.
X
(),
nMiddleY
-
RECT_SIZE_PIX
/
2
),
Size
(
-
RECT_SIZE_PIX
,
RECT_SIZE_PIX
)
)
);
rRenderContext
.
DrawRect
(
Rectangle
(
Point
(
rBR
.
X
(),
nMiddleY
-
RECT_SIZE_PIX
/
2
),
Size
(
-
RECT_SIZE_PIX
,
RECT_SIZE_PIX
))
);
}
}
void
ScanPreview
::
DrawDrag
()
void
ScanPreview
::
DrawDrag
(
vcl
::
RenderContext
&
rRenderContext
)
{
{
static
Point
aLastUL
,
aLastBR
;
static
Point
aLastUL
,
aLastBR
;
if
(
!
mbDragEnable
)
if
(
!
mbDragEnable
)
return
;
return
;
RasterOp
eROP
=
GetRasterOp
();
RasterOp
eROP
=
rRenderContext
.
GetRasterOp
();
SetRasterOp
(
ROP_INVERT
);
rRenderContext
.
SetRasterOp
(
ROP_INVERT
);
SetMapMode
(
MapMode
(
MAP_PIXEL
)
);
rRenderContext
.
SetMapMode
(
MapMode
(
MAP_PIXEL
)
);
if
(
mbDragDrawn
)
if
(
mbDragDrawn
)
DrawRectangles
(
aLastUL
,
aLastBR
);
DrawRectangles
(
rRenderContext
,
aLastUL
,
aLastBR
);
aLastUL
=
maTopLeft
;
aLastUL
=
maTopLeft
;
aLastBR
=
maBottomRight
;
aLastBR
=
maBottomRight
;
DrawRectangles
(
maTopLeft
,
maBottomRight
);
DrawRectangles
(
rRenderContext
,
maTopLeft
,
maBottomRight
);
mbDragDrawn
=
true
;
mbDragDrawn
=
true
;
SetRasterOp
(
eROP
);
rRenderContext
.
SetRasterOp
(
eROP
);
SetMapMode
(
MAP_APPFONT
);
rRenderContext
.
SetMapMode
(
MAP_APPFONT
);
}
}
Point
ScanPreview
::
GetPixelPos
(
const
Point
&
rIn
)
const
Point
ScanPreview
::
GetPixelPos
(
const
Point
&
rIn
)
const
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment