1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _SVT_SANEDLG_HXX
24 #define _SVT_SANEDLG_HXX
25 
26 #include <vcl/dialog.hxx>
27 #include <tools/config.hxx>
28 #include <vcl/lstbox.hxx>
29 #ifndef _SV_BUTTON_HXX
30 #include <vcl/button.hxx>
31 #endif
32 #include <vcl/fixed.hxx>
33 #include <vcl/group.hxx>
34 #include <vcl/field.hxx>
35 #include <vcl/edit.hxx>
36 #include <svtools/svtreebx.hxx>
37 
38 #include <sane.hxx>
39 
40 class SaneDlg : public ModalDialog
41 {
42 private:
43 	enum DragDirection { TopLeft, Top, TopRight, Right, BottomRight, Bottom,
44 						 BottomLeft, Left };
45 
46 	Sane&			mrSane;
47 	Bitmap			maPreviewBitmap;
48 	Rectangle		maPreviewRect;
49 	Point			maTopLeft, maBottomRight;
50 	Point			maMinTopLeft, maMaxBottomRight;
51     sal_Bool			mbDragEnable;
52 	sal_Bool			mbIsDragging;
53 	int				mnDragMode;
54 	sal_Bool			mbDragDrawn;
55 	DragDirection	meDragDirection;
56 
57 	MapMode			maMapMode;
58 
59 	Link			maOldLink;
60 
61 	OKButton		maOKButton;
62 	CancelButton	maCancelButton;
63 	PushButton		maDeviceInfoButton;
64 	PushButton		maPreviewButton;
65 	PushButton		maButtonOption;
66 
67 	FixedText		maOptionsTxt;
68 	FixedText		maOptionTitle;
69 	FixedText		maOptionDescTxt;
70 	FixedText		maVectorTxt;
71 
72 	FixedText		maScanLeftTxt;
73 	MetricField		maLeftField;
74 	FixedText		maScanTopTxt;
75 	MetricField		maTopField;
76 	FixedText		maRightTxt;
77 	MetricField		maRightField;
78 	FixedText		maBottomTxt;
79 	MetricField		maBottomField;
80 
81 	FixedText		maDeviceBoxTxt;
82 	ListBox			maDeviceBox;
83 	FixedText		maReslTxt;
84 	NumericBox		maReslBox;
85 	FixedText		maAdvancedTxt;
86 	CheckBox		maAdvancedBox;
87 
88 	NumericField	maVectorBox;
89 	ListBox			maQuantumRangeBox;
90 	ListBox			maStringRangeBox;
91 
92 	FixedLine		maPreviewBox;
93 	FixedLine		maAreaBox;
94 
95 	CheckBox		maBoolCheckBox;
96 
97 	Edit			maStringEdit;
98 	Edit			maNumericEdit;
99 
100 	SvTreeListBox	maOptionBox;
101 
102 	int				mnCurrentOption;
103 	int				mnCurrentElement;
104 	double*			mpRange;
105 	double			mfMin, mfMax;
106 
107 	DECL_LINK( ClickBtnHdl, Button* );
108 	DECL_LINK( SelectHdl, ListBox* );
109 	DECL_LINK( ModifyHdl, Edit* );
110 	DECL_LINK( ReloadSaneOptionsHdl, Sane* );
111 	DECL_LINK( OptionsBoxSelectHdl, SvTreeListBox* );
112 
113 	void SaveState();
114 	sal_Bool LoadState();
115 
116 	void InitDevices();
117 	void InitFields();
118 	void AcquirePreview();
119 	void DisableOption();
120 	void EstablishBoolOption();
121 	void EstablishStringOption();
122 	void EstablishStringRange();
123 	void EstablishQuantumRange();
124 	void EstablishNumericOption();
125 	void EstablishButtonOption();
126 
127 	void DrawRectangles( Point&, Point& );
128 	void DrawDrag();
129 	Point GetPixelPos( const Point& );
130 	Point GetLogicPos( const Point& );
131 	void UpdateScanArea( sal_Bool );
132 
133 	// helper
134 	sal_Bool SetAdjustedNumericalValue( const char* pOption, double fValue, int nElement = 0 );
135 
136 	virtual void Paint( const Rectangle& );
137 	virtual void MouseMove( const MouseEvent& rMEvt );
138 	virtual void MouseButtonDown( const MouseEvent& rMEvt );
139 	virtual void MouseButtonUp( const MouseEvent& rMEvt );
140 public:
141 	SaneDlg( Window*, Sane& );
142 	~SaneDlg();
143 
144 	virtual short Execute();
145 };
146 
147 
148 #endif
149