1/*
2 * Copyright 2003-2009 Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		Michael Pfeiffer, laplace@haiku-os.org
7 */
8#ifndef PRINT_OPTIONS_WINDOW_H
9#define PRINT_OPTIONS_WINDOW_H
10
11
12#include <Messenger.h>
13#include <RadioButton.h>
14#include <Rect.h>
15#include <TextControl.h>
16#include <Window.h>
17
18
19class PrintOptions {
20public:
21					PrintOptions();
22
23	// bounds of the image
24	BRect 			Bounds() const { return fBounds; }
25	void 			SetBounds(BRect bounds);
26
27	enum Option {
28		kFitToPage,
29		kZoomFactor,
30		kDPI,
31		kWidth,
32		kHeight,
33		kNumberOfOptions
34	};
35	enum Option		Option() const { return fOption; }
36	void 			SetOption(enum Option op) { fOption = op; }
37
38	// ZoomFactor = 72.0 / dpi
39	float 			ZoomFactor() const { return fZoomFactor; }
40	void 			SetZoomFactor(float z);
41	float 			DPI() const { return fDPI; }
42	void 			SetDPI(float dpi);
43
44	// Setting width/height updates height/width to keep aspect ratio
45	float 			Width() const { return fWidth; }
46	float 			Height() const { return fHeight; }
47	void 			SetWidth(float width);
48	void 			SetHeight(float height);
49
50private:
51	BRect 			fBounds;
52	enum Option		fOption;
53	float 			fZoomFactor;
54	float 			fDPI;
55	float 			fWidth, fHeight; // 1/72 Inches
56};
57
58class PrintOptionsWindow : public BWindow {
59public:
60								PrintOptionsWindow(BPoint at,
61									PrintOptions* options, BWindow* listener);
62								~PrintOptionsWindow();
63
64	void 			MessageReceived(BMessage* msg);
65
66private:
67	BRadioButton* 				AddRadioButton(const char* name, const char* label,
68									uint32 what, bool selected);
69
70	BTextControl* 				AddTextControl(const char* name, const char* label,
71									float value, uint32 what);
72
73	void						Setup();
74	enum PrintOptions::Option	MsgToOption(uint32 what);
75	bool						GetValue(BTextControl* text, float* value);
76	void						SetValue(BTextControl* text, float value);
77
78	PrintOptions* 				fPrintOptions;
79	PrintOptions 				fCurrentOptions;
80	BMessenger 					fListener;
81	status_t 					fStatus;
82	BTextControl* 				fZoomFactor;
83	BTextControl* 				fDPI;
84	BTextControl* 				fWidth;
85	BTextControl* 				fHeight;
86
87	enum {
88		kMsgOK = 'mPOW',
89		kMsgFitToPageSelected,
90		kMsgZoomFactorSelected,
91		kMsgDPISelected,
92		kMsgWidthAndHeightSelected,
93
94		kMsgZoomFactorChanged,
95		kMsgDPIChanged,
96		kMsgWidthChanged,
97		kMsgHeightChanged,
98
99		kMsgJobSetup,
100
101		kIndent = 5,
102		kLineSkip = 5,
103	};
104};
105
106
107#endif
108
109