1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _SVT_SANEDLG_HXX
28 #define _SVT_SANEDLG_HXX
29 
30 #include <vcl/dialog.hxx>
31 #include <tools/config.hxx>
32 #include <vcl/lstbox.hxx>
33 #ifndef _SV_BUTTON_HXX
34 #include <vcl/button.hxx>
35 #endif
36 #include <vcl/fixed.hxx>
37 #include <vcl/group.hxx>
38 #include <vcl/field.hxx>
39 #include <vcl/edit.hxx>
40 #include <svtools/svtreebx.hxx>
41 
42 #include <sane.hxx>
43 
44 class SaneDlg : public ModalDialog
45 {
46 private:
47 	enum DragDirection { TopLeft, Top, TopRight, Right, BottomRight, Bottom,
48 						 BottomLeft, Left };
49 
50 	Sane&			mrSane;
51 	Bitmap			maPreviewBitmap;
52 	Rectangle		maPreviewRect;
53 	Point			maTopLeft, maBottomRight;
54 	Point			maMinTopLeft, maMaxBottomRight;
55     sal_Bool			mbDragEnable;
56 	sal_Bool			mbIsDragging;
57 	int				mnDragMode;
58 	sal_Bool			mbDragDrawn;
59 	DragDirection	meDragDirection;
60 
61 	MapMode			maMapMode;
62 
63 	Link			maOldLink;
64 
65 	OKButton		maOKButton;
66 	CancelButton	maCancelButton;
67 	PushButton		maDeviceInfoButton;
68 	PushButton		maPreviewButton;
69 	PushButton		maButtonOption;
70 
71 	FixedText		maOptionsTxt;
72 	FixedText		maOptionTitle;
73 	FixedText		maOptionDescTxt;
74 	FixedText		maVectorTxt;
75 
76 	FixedText		maScanLeftTxt;
77 	MetricField		maLeftField;
78 	FixedText		maScanTopTxt;
79 	MetricField		maTopField;
80 	FixedText		maRightTxt;
81 	MetricField		maRightField;
82 	FixedText		maBottomTxt;
83 	MetricField		maBottomField;
84 
85 	FixedText		maDeviceBoxTxt;
86 	ListBox			maDeviceBox;
87 	FixedText		maReslTxt;
88 	NumericBox		maReslBox;
89 	FixedText		maAdvancedTxt;
90 	CheckBox		maAdvancedBox;
91 
92 	NumericField	maVectorBox;
93 	ListBox			maQuantumRangeBox;
94 	ListBox			maStringRangeBox;
95 
96 	FixedLine		maPreviewBox;
97 	FixedLine		maAreaBox;
98 
99 	CheckBox		maBoolCheckBox;
100 
101 	Edit			maStringEdit;
102 	Edit			maNumericEdit;
103 
104 	SvTreeListBox	maOptionBox;
105 
106 	int				mnCurrentOption;
107 	int				mnCurrentElement;
108 	double*			mpRange;
109 	double			mfMin, mfMax;
110 
111 	DECL_LINK( ClickBtnHdl, Button* );
112 	DECL_LINK( SelectHdl, ListBox* );
113 	DECL_LINK( ModifyHdl, Edit* );
114 	DECL_LINK( ReloadSaneOptionsHdl, Sane* );
115 	DECL_LINK( OptionsBoxSelectHdl, SvTreeListBox* );
116 
117 	void SaveState();
118 	sal_Bool LoadState();
119 
120 	void InitDevices();
121 	void InitFields();
122 	void AcquirePreview();
123 	void DisableOption();
124 	void EstablishBoolOption();
125 	void EstablishStringOption();
126 	void EstablishStringRange();
127 	void EstablishQuantumRange();
128 	void EstablishNumericOption();
129 	void EstablishButtonOption();
130 
131 	void DrawRectangles( Point&, Point& );
132 	void DrawDrag();
133 	Point GetPixelPos( const Point& );
134 	Point GetLogicPos( const Point& );
135 	void UpdateScanArea( sal_Bool );
136 
137 	// helper
138 	sal_Bool SetAdjustedNumericalValue( const char* pOption, double fValue, int nElement = 0 );
139 
140 	virtual void Paint( const Rectangle& );
141 	virtual void MouseMove( const MouseEvent& rMEvt );
142 	virtual void MouseButtonDown( const MouseEvent& rMEvt );
143 	virtual void MouseButtonUp( const MouseEvent& rMEvt );
144 public:
145 	SaneDlg( Window*, Sane& );
146 	~SaneDlg();
147 
148 	virtual short Execute();
149 };
150 
151 
152 #endif
153