X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f2aa588ba5c2e316d87105da86e0ebe8bbeac5df..564c92d95b0c73256fd2be165986204bb213359d:/src/common/cmndata.cpp?ds=inline diff --git a/src/common/cmndata.cpp b/src/common/cmndata.cpp index 5f75393a5e..07040ea1e8 100644 --- a/src/common/cmndata.cpp +++ b/src/common/cmndata.cpp @@ -51,7 +51,7 @@ #include #include "wx/msw/private.h" - #ifndef __SMARTPHONE__ + #ifndef __SMARTPHONE__ /* of WinCE */ #include #endif @@ -88,12 +88,9 @@ wxColourData::wxColourData() { - int i; - for (i = 0; i < 16; i++) - m_custColours[i].Set(255, 255, 255); - - m_chooseFull = FALSE; + m_chooseFull = false; m_dataColour.Set(0,0,0); + // m_custColours are wxNullColours initially } wxColourData::wxColourData(const wxColourData& data) @@ -108,16 +105,15 @@ wxColourData::~wxColourData() void wxColourData::SetCustomColour(int i, const wxColour& colour) { - if (i > 15 || i < 0) - return; + wxCHECK_RET( (i >= 0 && i < 16), _T("custom colour index out of range") ); m_custColours[i] = colour; } wxColour wxColourData::GetCustomColour(int i) { - if (i > 15 || i < 0) - return wxColour(0,0,0); + wxCHECK_MSG( (i >= 0 && i < 16), wxColour(0,0,0), + _T("custom colour index out of range") ); return m_custColours[i]; } @@ -141,9 +137,9 @@ wxFontData::wxFontData() // Intialize colour to black. m_fontColour = wxNullColour; - m_showHelp = FALSE; - m_allowSymbols = TRUE; - m_enableEffects = TRUE; + m_showHelp = false; + m_allowSymbols = true; + m_enableEffects = true; m_minSize = 0; m_maxSize = 0; @@ -175,13 +171,14 @@ wxPrintData::wxPrintData() #elif defined( __WXMAC__ ) m_nativePrintData = wxNativePrintData::Create() ; #endif + m_bin = wxPRINTBIN_DEFAULT; m_printOrientation = wxPORTRAIT; m_printNoCopies = 1; - m_printCollate = FALSE; + m_printCollate = false; // New, 24/3/99 m_printerName = wxT(""); - m_colour = TRUE; + m_colour = true; m_duplexMode = wxDUPLEX_SIMPLEX; m_printQuality = wxPRINT_QUALITY_HIGH; m_paperId = wxPAPER_A4; @@ -296,16 +293,16 @@ static HGLOBAL wxCreateDevNames(const wxString& driverName, const wxString& prin printerName.Length() + 1 + portName.Length()+1 ) * sizeof(wxChar) ); LPDEVNAMES lpDev = (LPDEVNAMES)GlobalLock(hDev); - lpDev->wDriverOffset = sizeof(WORD)*4; - wxStrcpy((wxChar*)((char*)lpDev + lpDev->wDriverOffset ), driverName); + lpDev->wDriverOffset = sizeof(WORD) * 4 / sizeof(wxChar); + wxStrcpy((wxChar*)lpDev + lpDev->wDriverOffset, driverName); lpDev->wDeviceOffset = (WORD)( lpDev->wDriverOffset + - sizeof(wxChar) * ( driverName.Length() + 1 ) ); - wxStrcpy((wxChar*)((char*)lpDev + lpDev->wDeviceOffset ), printerName); + driverName.Length() + 1 ); + wxStrcpy((wxChar*)lpDev + lpDev->wDeviceOffset, printerName); lpDev->wOutputOffset = (WORD)( lpDev->wDeviceOffset + - sizeof(wxChar) * ( printerName.Length() + 1 ) ); - wxStrcpy((wxChar*)((char*) lpDev + lpDev->wOutputOffset ), portName); + printerName.Length() + 1 ); + wxStrcpy((wxChar*)lpDev + lpDev->wOutputOffset, portName); lpDev->wDefault = 0; @@ -386,7 +383,7 @@ void wxPrintData::ConvertToNative() //// Orientation - devMode->dmOrientation = m_printOrientation; + devMode->dmOrientation = (short)m_printOrientation; //// Collation @@ -395,7 +392,7 @@ void wxPrintData::ConvertToNative() //// Number of copies - devMode->dmCopies = m_printNoCopies; + devMode->dmCopies = (short)m_printNoCopies; devMode->dmFields |= DM_COPIES; //// Printer name @@ -421,8 +418,8 @@ void wxPrintData::ConvertToNative() if (m_paperId == wxPAPER_NONE) { // DEVMODE is in tenths of a milimeter - devMode->dmPaperWidth = m_paperSize.x * 10; - devMode->dmPaperLength = m_paperSize.y * 10; + devMode->dmPaperWidth = (short)(m_paperSize.x * 10); + devMode->dmPaperLength = (short)(m_paperSize.y * 10); devMode->dmPaperSize = DMPAPER_USER; devMode->dmFields |= DM_PAPERWIDTH; devMode->dmFields |= DM_PAPERLENGTH; @@ -434,7 +431,7 @@ void wxPrintData::ConvertToNative() wxPrintPaperType* paper = wxThePrintPaperDatabase->FindPaperType(m_paperId); if (paper) { - devMode->dmPaperSize = paper->GetPlatformId(); + devMode->dmPaperSize = (short)paper->GetPlatformId(); devMode->dmFields |= DM_PAPERSIZE; } } @@ -442,47 +439,73 @@ void wxPrintData::ConvertToNative() //// Duplex - int duplex; + short duplex; switch (m_duplexMode) { - case wxDUPLEX_HORIZONTAL: { - duplex = DMDUP_HORIZONTAL; break; - } - case wxDUPLEX_VERTICAL: { - duplex = DMDUP_VERTICAL; break; - } - default: - case wxDUPLEX_SIMPLEX: { - duplex = DMDUP_SIMPLEX; break; - } + case wxDUPLEX_HORIZONTAL: + duplex = DMDUP_HORIZONTAL; + break; + case wxDUPLEX_VERTICAL: + duplex = DMDUP_VERTICAL; + break; + default: + // in fact case wxDUPLEX_SIMPLEX: + duplex = DMDUP_SIMPLEX; + break; } devMode->dmDuplex = duplex; devMode->dmFields |= DM_DUPLEX; //// Quality - int quality; + short quality; switch (m_printQuality) { - case wxPRINT_QUALITY_MEDIUM: { - quality = DMRES_MEDIUM; break; - } - case wxPRINT_QUALITY_LOW: { - quality = DMRES_LOW; break; - } - case wxPRINT_QUALITY_DRAFT: { - quality = DMRES_DRAFT; break; - } - case wxPRINT_QUALITY_HIGH: { - quality = DMRES_HIGH; break; - } - default: { - quality = m_printQuality; break; - } + case wxPRINT_QUALITY_MEDIUM: + quality = DMRES_MEDIUM; + break; + case wxPRINT_QUALITY_LOW: + quality = DMRES_LOW; + break; + case wxPRINT_QUALITY_DRAFT: + quality = DMRES_DRAFT; + break; + case wxPRINT_QUALITY_HIGH: + quality = DMRES_HIGH; + break; + default: + quality = (short)m_printQuality; + break; } devMode->dmPrintQuality = quality; devMode->dmFields |= DM_PRINTQUALITY; + if ( m_bin != wxPRINTBIN_DEFAULT ) + { + switch ( m_bin ) + { + case wxPRINTBIN_ONLYONE: devMode->dmDefaultSource = DMBIN_ONLYONE; break; + case wxPRINTBIN_LOWER: devMode->dmDefaultSource = DMBIN_LOWER; break; + case wxPRINTBIN_MIDDLE: devMode->dmDefaultSource = DMBIN_MIDDLE; break; + case wxPRINTBIN_MANUAL: devMode->dmDefaultSource = DMBIN_MANUAL; break; + case wxPRINTBIN_ENVELOPE: devMode->dmDefaultSource = DMBIN_ENVELOPE; break; + case wxPRINTBIN_ENVMANUAL: devMode->dmDefaultSource = DMBIN_ENVMANUAL; break; + case wxPRINTBIN_AUTO: devMode->dmDefaultSource = DMBIN_AUTO; break; + case wxPRINTBIN_TRACTOR: devMode->dmDefaultSource = DMBIN_TRACTOR; break; + case wxPRINTBIN_SMALLFMT: devMode->dmDefaultSource = DMBIN_SMALLFMT; break; + case wxPRINTBIN_LARGEFMT: devMode->dmDefaultSource = DMBIN_LARGEFMT; break; + case wxPRINTBIN_LARGECAPACITY: devMode->dmDefaultSource = DMBIN_LARGECAPACITY; break; + case wxPRINTBIN_CASSETTE: devMode->dmDefaultSource = DMBIN_CASSETTE; break; + case wxPRINTBIN_FORMSOURCE: devMode->dmDefaultSource = DMBIN_FORMSOURCE; break; + + default: + devMode->dmDefaultSource = (short)(DMBIN_USER + m_bin - wxPRINTBIN_USER); + break; + } + + devMode->dmFields |= DM_DEFAULTSOURCE; + } + GlobalUnlock(hDevMode); } @@ -517,9 +540,9 @@ void wxPrintData::ConvertFromNative() if (devMode->dmFields & DM_COLLATE) { if (devMode->dmCollate == DMCOLLATE_TRUE) - m_printCollate = TRUE; + m_printCollate = true; else - m_printCollate = FALSE; + m_printCollate = false; } //// Number of copies @@ -529,6 +552,11 @@ void wxPrintData::ConvertFromNative() m_printNoCopies = devMode->dmCopies; } + if (devMode->dmFields & DM_DEFAULTSOURCE) + { + m_bin = (wxPrintBin)devMode->dmDefaultSource; + } + //// Printer name if (devMode->dmDeviceName[0] != 0) @@ -541,12 +569,12 @@ void wxPrintData::ConvertFromNative() if (devMode->dmFields & DM_COLOR) { if (devMode->dmColor == DMCOLOR_COLOR) - m_colour = TRUE; + m_colour = true; else - m_colour = FALSE; + m_colour = false; } else - m_colour = TRUE; + m_colour = true; //// Paper size @@ -712,6 +740,7 @@ void wxPrintData::operator=(const wxPrintData& data) m_printQuality = data.m_printQuality; m_paperId = data.m_paperId; m_paperSize = data.m_paperSize; + m_bin = data.m_bin; #ifdef wxUSE_STREAMS m_outputstream = data.m_outputstream; #endif @@ -736,7 +765,7 @@ bool wxPrintData::Ok() const ((wxPrintData*)this)->ConvertToNative(); return (m_devMode != NULL) ; #else - return TRUE; + return true; #endif } @@ -754,15 +783,15 @@ wxPrintDialogData::wxPrintDialogData() m_printMinPage = 0; m_printMaxPage = 0; m_printNoCopies = 1; - m_printAllPages = FALSE; - m_printCollate = FALSE; - m_printToFile = FALSE; - m_printSelection = FALSE; - m_printEnableSelection = FALSE; - m_printEnablePageNumbers = TRUE; - m_printEnablePrintToFile = TRUE; - m_printEnableHelp = FALSE; - m_printSetupDialog = FALSE; + m_printAllPages = false; + m_printCollate = false; + m_printToFile = false; + m_printSelection = false; + m_printEnableSelection = false; + m_printEnablePageNumbers = true; + m_printEnablePrintToFile = true; + m_printEnableHelp = false; + m_printSetupDialog = false; } wxPrintDialogData::wxPrintDialogData(const wxPrintDialogData& dialogData) @@ -784,15 +813,15 @@ wxPrintDialogData::wxPrintDialogData(const wxPrintData& printData) m_printMinPage = 1; m_printMaxPage = 9999; m_printNoCopies = 1; - m_printAllPages = FALSE; - m_printCollate = FALSE; - m_printToFile = FALSE; - m_printSelection = FALSE; - m_printEnableSelection = FALSE; - m_printEnablePageNumbers = TRUE; - m_printEnablePrintToFile = TRUE; - m_printEnableHelp = FALSE; - m_printSetupDialog = FALSE; + m_printAllPages = false; + m_printCollate = false; + m_printToFile = false; + m_printSelection = false; + m_printEnableSelection = false; + m_printEnablePageNumbers = true; + m_printEnablePrintToFile = true; + m_printEnableHelp = false; + m_printSetupDialog = false; m_printData = printData; } @@ -939,7 +968,7 @@ void wxPrintDialogData::ConvertFromNative() } // Now convert the DEVMODE object, passed down from the PRINTDLG object, - // into wxWindows form. + // into wxWidgets form. m_printData.ConvertFromNative(); m_printFromPage = pd->nFromPage; @@ -1048,13 +1077,13 @@ wxPageSetupDialogData::wxPageSetupDialogData() m_marginBottomRight = wxPoint(0, 0); // Flags - m_defaultMinMargins = FALSE; - m_enableMargins = TRUE; - m_enableOrientation = TRUE; - m_enablePaper = TRUE; - m_enablePrinter = TRUE; - m_enableHelp = FALSE; - m_getDefaultInfo = FALSE; + m_defaultMinMargins = false; + m_enableMargins = true; + m_enableOrientation = true; + m_enablePaper = true; + m_enablePrinter = true; + m_enableHelp = false; + m_getDefaultInfo = false; } wxPageSetupDialogData::wxPageSetupDialogData(const wxPageSetupDialogData& dialogData) @@ -1078,13 +1107,13 @@ wxPageSetupDialogData::wxPageSetupDialogData(const wxPrintData& printData) m_marginBottomRight = wxPoint(0, 0); // Flags - m_defaultMinMargins = FALSE; - m_enableMargins = TRUE; - m_enableOrientation = TRUE; - m_enablePaper = TRUE; - m_enablePrinter = TRUE; - m_enableHelp = FALSE; - m_getDefaultInfo = FALSE; + m_defaultMinMargins = false; + m_enableMargins = true; + m_enableOrientation = true; + m_enablePaper = true; + m_enablePrinter = true; + m_enableHelp = false; + m_getDefaultInfo = false; m_printData = printData;