1780d8a62SMichael Pfeiffer /*****************************************************************************/ 2780d8a62SMichael Pfeiffer // PrintOptionsWindow 381b9c776SMichael Pfeiffer // Written by Michael Pfeiffer 4780d8a62SMichael Pfeiffer // 5780d8a62SMichael Pfeiffer // PrintOptionsWindow.h 6780d8a62SMichael Pfeiffer // 7780d8a62SMichael Pfeiffer // 8780d8a62SMichael Pfeiffer // Copyright (c) 2003 OpenBeOS Project 9780d8a62SMichael Pfeiffer // 10780d8a62SMichael Pfeiffer // Permission is hereby granted, free of charge, to any person obtaining a 11780d8a62SMichael Pfeiffer // copy of this software and associated documentation files (the "Software"), 12780d8a62SMichael Pfeiffer // to deal in the Software without restriction, including without limitation 13780d8a62SMichael Pfeiffer // the rights to use, copy, modify, merge, publish, distribute, sublicense, 14780d8a62SMichael Pfeiffer // and/or sell copies of the Software, and to permit persons to whom the 15780d8a62SMichael Pfeiffer // Software is furnished to do so, subject to the following conditions: 16780d8a62SMichael Pfeiffer // 17780d8a62SMichael Pfeiffer // The above copyright notice and this permission notice shall be included 18780d8a62SMichael Pfeiffer // in all copies or substantial portions of the Software. 19780d8a62SMichael Pfeiffer // 20780d8a62SMichael Pfeiffer // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 21780d8a62SMichael Pfeiffer // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22780d8a62SMichael Pfeiffer // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 23780d8a62SMichael Pfeiffer // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24780d8a62SMichael Pfeiffer // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 25780d8a62SMichael Pfeiffer // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 26780d8a62SMichael Pfeiffer // DEALINGS IN THE SOFTWARE. 27780d8a62SMichael Pfeiffer /*****************************************************************************/ 28780d8a62SMichael Pfeiffer 29780d8a62SMichael Pfeiffer #ifndef _PrintOptionsWindow_h 30780d8a62SMichael Pfeiffer #define _PrintOptionsWindow_h 31780d8a62SMichael Pfeiffer 32780d8a62SMichael Pfeiffer #include <Window.h> 33780d8a62SMichael Pfeiffer #include <RadioButton.h> 34780d8a62SMichael Pfeiffer #include <TextControl.h> 35780d8a62SMichael Pfeiffer #include <Messenger.h> 36780d8a62SMichael Pfeiffer #include <Rect.h> 37780d8a62SMichael Pfeiffer 38780d8a62SMichael Pfeiffer class PrintOptions { 39780d8a62SMichael Pfeiffer public: 40780d8a62SMichael Pfeiffer enum Option { 41780d8a62SMichael Pfeiffer kFitToPage, 42780d8a62SMichael Pfeiffer kZoomFactor, 43780d8a62SMichael Pfeiffer kDPI, 44780d8a62SMichael Pfeiffer kWidth, 45*d3046f7dSMichael Pfeiffer kHeight, 46*d3046f7dSMichael Pfeiffer kNumberOfOptions 47780d8a62SMichael Pfeiffer }; 48780d8a62SMichael Pfeiffer 49780d8a62SMichael Pfeiffer PrintOptions(); 50780d8a62SMichael Pfeiffer 51780d8a62SMichael Pfeiffer // bounds of the image 52780d8a62SMichael Pfeiffer BRect Bounds() const { return fBounds; } 53780d8a62SMichael Pfeiffer void SetBounds(BRect bounds); 54780d8a62SMichael Pfeiffer 55780d8a62SMichael Pfeiffer Option Option() const { return fOption; } 56780d8a62SMichael Pfeiffer void SetOption(Option op) { fOption = op; } 57780d8a62SMichael Pfeiffer // zoomFactor = 72.0 / dpi 58780d8a62SMichael Pfeiffer float ZoomFactor() const { return fZoomFactor; } 59780d8a62SMichael Pfeiffer void SetZoomFactor(float z); 60780d8a62SMichael Pfeiffer float DPI() const { return fDPI; } 61780d8a62SMichael Pfeiffer void SetDPI(float dpi); 62780d8a62SMichael Pfeiffer // setting width/height updates height/width to keep aspect ratio 63780d8a62SMichael Pfeiffer float Width() const { return fWidth; } 64780d8a62SMichael Pfeiffer float Height() const { return fHeight; } 65780d8a62SMichael Pfeiffer void SetWidth(float width); 66780d8a62SMichael Pfeiffer void SetHeight(float height); 67780d8a62SMichael Pfeiffer 68780d8a62SMichael Pfeiffer private: 69780d8a62SMichael Pfeiffer BRect fBounds; 70780d8a62SMichael Pfeiffer Option fOption; 71780d8a62SMichael Pfeiffer float fZoomFactor; 72780d8a62SMichael Pfeiffer float fDPI; 73780d8a62SMichael Pfeiffer float fWidth, fHeight; // 1/72 Inches 74780d8a62SMichael Pfeiffer }; 75780d8a62SMichael Pfeiffer 76780d8a62SMichael Pfeiffer class PrintOptionsWindow : public BWindow 77780d8a62SMichael Pfeiffer { 78780d8a62SMichael Pfeiffer public: 79780d8a62SMichael Pfeiffer PrintOptionsWindow(BPoint at, PrintOptions* options, BWindow* listener); 80780d8a62SMichael Pfeiffer ~PrintOptionsWindow(); 81780d8a62SMichael Pfeiffer 82780d8a62SMichael Pfeiffer void MessageReceived(BMessage* msg); 83780d8a62SMichael Pfeiffer 84780d8a62SMichael Pfeiffer private: 85780d8a62SMichael Pfeiffer BRadioButton* AddRadioButton(BView* view, BPoint& at, const char* name, const char* label, uint32 what, bool selected); 86780d8a62SMichael Pfeiffer BTextControl* AddTextControl(BView* view, BPoint& at, const char* name, const char* label, float value, float divider, uint32 what); 87780d8a62SMichael Pfeiffer void Setup(); 88780d8a62SMichael Pfeiffer enum PrintOptions::Option MsgToOption(uint32 what); 89780d8a62SMichael Pfeiffer bool GetValue(BTextControl* text, float* value); 90780d8a62SMichael Pfeiffer void SetValue(BTextControl* text, float value); 91780d8a62SMichael Pfeiffer 92780d8a62SMichael Pfeiffer enum { 93780d8a62SMichael Pfeiffer kMsgOK = 'mPOW', 94780d8a62SMichael Pfeiffer kMsgFitToPageSelected, 95780d8a62SMichael Pfeiffer kMsgZoomFactorSelected, 96780d8a62SMichael Pfeiffer kMsgDPISelected, 97780d8a62SMichael Pfeiffer kMsgWidthAndHeightSelected, 98780d8a62SMichael Pfeiffer 99780d8a62SMichael Pfeiffer kMsgZoomFactorChanged, 100780d8a62SMichael Pfeiffer kMsgDPIChanged, 101780d8a62SMichael Pfeiffer kMsgWidthChanged, 102780d8a62SMichael Pfeiffer kMsgHeightChanged, 103780d8a62SMichael Pfeiffer 104780d8a62SMichael Pfeiffer kMsgJobSetup, 105780d8a62SMichael Pfeiffer 106780d8a62SMichael Pfeiffer kIndent = 5, 107780d8a62SMichael Pfeiffer kLineSkip = 5, 108780d8a62SMichael Pfeiffer }; 109780d8a62SMichael Pfeiffer 110780d8a62SMichael Pfeiffer PrintOptions* fPrintOptions; 111780d8a62SMichael Pfeiffer PrintOptions fCurrentOptions; 112780d8a62SMichael Pfeiffer BMessenger fListener; 113780d8a62SMichael Pfeiffer status_t fStatus; 114780d8a62SMichael Pfeiffer BTextControl* fZoomFactor; 115780d8a62SMichael Pfeiffer BTextControl* fDPI; 116780d8a62SMichael Pfeiffer BTextControl* fWidth; 117780d8a62SMichael Pfeiffer BTextControl* fHeight; 118780d8a62SMichael Pfeiffer }; 119780d8a62SMichael Pfeiffer 120780d8a62SMichael Pfeiffer #endif 121