1 /*****************************************************************************/ 2 // PrintOptionsWindow 3 // Written by Michael Pfeiffer 4 // 5 // PrintOptionsWindow.h 6 // 7 // 8 // Copyright (c) 2003 OpenBeOS Project 9 // 10 // Permission is hereby granted, free of charge, to any person obtaining a 11 // copy of this software and associated documentation files (the "Software"), 12 // to deal in the Software without restriction, including without limitation 13 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 14 // and/or sell copies of the Software, and to permit persons to whom the 15 // Software is furnished to do so, subject to the following conditions: 16 // 17 // The above copyright notice and this permission notice shall be included 18 // in all copies or substantial portions of the Software. 19 // 20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 21 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 23 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 25 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 26 // DEALINGS IN THE SOFTWARE. 27 /*****************************************************************************/ 28 29 #ifndef _PrintOptionsWindow_h 30 #define _PrintOptionsWindow_h 31 32 #include <Window.h> 33 #include <RadioButton.h> 34 #include <TextControl.h> 35 #include <Messenger.h> 36 #include <Rect.h> 37 38 class PrintOptions { 39 public: 40 enum Option { 41 kFitToPage, 42 kZoomFactor, 43 kDPI, 44 kWidth, 45 kHeight, 46 kNumberOfOptions 47 }; 48 49 PrintOptions(); 50 51 // bounds of the image 52 BRect Bounds() const { return fBounds; } 53 void SetBounds(BRect bounds); 54 55 enum Option Option() const { return fOption; } 56 void SetOption(enum Option op) { fOption = op; } 57 // zoomFactor = 72.0 / dpi 58 float ZoomFactor() const { return fZoomFactor; } 59 void SetZoomFactor(float z); 60 float DPI() const { return fDPI; } 61 void SetDPI(float dpi); 62 // setting width/height updates height/width to keep aspect ratio 63 float Width() const { return fWidth; } 64 float Height() const { return fHeight; } 65 void SetWidth(float width); 66 void SetHeight(float height); 67 68 private: 69 BRect fBounds; 70 enum Option fOption; 71 float fZoomFactor; 72 float fDPI; 73 float fWidth, fHeight; // 1/72 Inches 74 }; 75 76 class PrintOptionsWindow : public BWindow 77 { 78 public: 79 PrintOptionsWindow(BPoint at, PrintOptions* options, BWindow* listener); 80 ~PrintOptionsWindow(); 81 82 void MessageReceived(BMessage* msg); 83 84 private: 85 BRadioButton* AddRadioButton(BView* view, BPoint& at, const char* name, const char* label, uint32 what, bool selected); 86 BTextControl* AddTextControl(BView* view, BPoint& at, const char* name, const char* label, float value, float divider, uint32 what); 87 void Setup(); 88 enum PrintOptions::Option MsgToOption(uint32 what); 89 bool GetValue(BTextControl* text, float* value); 90 void SetValue(BTextControl* text, float value); 91 92 enum { 93 kMsgOK = 'mPOW', 94 kMsgFitToPageSelected, 95 kMsgZoomFactorSelected, 96 kMsgDPISelected, 97 kMsgWidthAndHeightSelected, 98 99 kMsgZoomFactorChanged, 100 kMsgDPIChanged, 101 kMsgWidthChanged, 102 kMsgHeightChanged, 103 104 kMsgJobSetup, 105 106 kIndent = 5, 107 kLineSkip = 5, 108 }; 109 110 PrintOptions* fPrintOptions; 111 PrintOptions fCurrentOptions; 112 BMessenger fListener; 113 status_t fStatus; 114 BTextControl* fZoomFactor; 115 BTextControl* fDPI; 116 BTextControl* fWidth; 117 BTextControl* fHeight; 118 }; 119 120 #endif 121