00001 00012 #include "CanvasSettings.h" 00013 00014 #include <qspinbox.h> 00015 #include <qcheckbox.h> 00016 #include <qradiobutton.h> 00017 00018 using namespace hippodraw; 00019 00020 // #if QT_VERSION < 0x040000 00021 CanvasSettings:: 00022 CanvasSettings ( QWidget * parent, 00023 const char * name, 00024 bool modal, 00025 Qt::WFlags flags ) 00026 : CanvasSettingsBase ( parent, name, modal, flags ) 00027 { 00028 // #else 00029 // CanvasSettings:: 00030 // CanvasSettings ( QWidget * parent ) 00031 // : QDialog ( parent ) 00032 // { 00033 // setupUi ( this ); 00034 // #endif 00035 } 00036 00037 void 00038 CanvasSettings:: 00039 cancel () 00040 { 00041 done ( CanvasSettings::Rejected ); 00042 } 00043 00044 void 00045 CanvasSettings:: 00046 saveRetile () 00047 { 00048 done ( CanvasSettings::AcceptedAndRetile ); 00049 } 00050 00051 void 00052 CanvasSettings:: 00053 retile_clicked () 00054 { 00055 done ( CanvasSettings::Retile ); 00056 } 00057 00058 int 00059 CanvasSettings:: 00060 getWidthNumber () const 00061 { 00062 return m_h_spin -> value(); 00063 } 00064 00065 void 00066 CanvasSettings:: 00067 setWidthNumber ( int number ) 00068 { 00069 m_h_spin -> setValue ( number ); 00070 } 00071 00072 int 00073 CanvasSettings:: 00074 getHeightNumber () const 00075 { 00076 return m_v_spin -> value(); 00077 } 00078 00079 void 00080 CanvasSettings:: 00081 setHeightNumber ( int number ) 00082 { 00083 m_v_spin -> setValue ( number ); 00084 } 00085 00086 void 00087 CanvasSettings:: 00088 portraitRadioButton_toggled ( bool ) 00089 { 00090 orientationChanged(); 00091 } 00092 00093 void 00094 CanvasSettings:: 00095 orientationChanged () 00096 { 00097 int vSpinNumber = getHeightNumber (); 00098 int hSpinNumber = getWidthNumber (); 00099 00100 setHeightNumber( hSpinNumber ); 00101 setWidthNumber( vSpinNumber ); 00102 00103 } 00104 00105 QPrinter::Orientation 00106 CanvasSettings::orientation() 00107 { 00108 if ( portraitRadioButton -> isChecked() ) { 00109 return QPrinter::Portrait; 00110 } 00111 else { 00112 return QPrinter::Landscape; 00113 } 00114 00115 return QPrinter::Portrait; 00116 } 00117 00118 void CanvasSettings::setOrientation( QPrinter::Orientation orientation ) 00119 { 00120 if ( orientation == QPrinter::Portrait ) { 00121 portraitRadioButton -> setChecked( true ); 00122 } 00123 else { 00124 landscapeRadioButton -> setChecked( true ); 00125 } 00126 } 00127 00128 bool CanvasSettings::printerBounds() 00129 { 00130 return m_visibleMarginRadioButton -> isChecked(); 00131 } 00132 00133 void CanvasSettings::setPrinterBounds( bool flag ) 00134 { 00135 if( flag == true ) 00136 m_visibleMarginRadioButton -> setChecked( true ); 00137 else 00138 m_invisibleMarginRadioButton -> setChecked( true ); 00139 } 00140 00141 bool 00142 CanvasSettings:: 00143 getAddSelected () const 00144 { 00145 return m_add_selected -> isChecked (); 00146 } 00147 00148 void 00149 CanvasSettings:: 00150 setAddSelected ( bool yes ) 00151 { 00152 m_add_selected -> setChecked ( yes ); 00153 } 00154 00155 bool 00156 CanvasSettings:: 00157 ignorePrinterMargin () const 00158 { 00159 return ignore_margin -> isChecked (); 00160 } 00161 00162 void 00163 CanvasSettings:: 00164 setIgnorePrinterMargin ( bool yes ) 00165 { 00166 ignore_margin -> setChecked ( yes ); 00167 }