]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/paper.cpp
Correct the drawing of check tools with a drop down button in wxAuiToolBar.
[wxWidgets.git] / src / common / paper.cpp
index fb2c1ca6d3ffa74011638a04728fc82e8ed4a0be..db2f7e0a5dc84df1c42c692a39438956d73cf971 100644 (file)
 
 #if wxUSE_PRINTING_ARCHITECTURE
 
 
 #if wxUSE_PRINTING_ARCHITECTURE
 
-
 #ifndef WX_PRECOMP
 #ifndef WX_PRECOMP
+    #if defined(__WXMSW__)
+        #include "wx/msw/wrapcdlg.h"
+    #endif // MSW
     #include "wx/utils.h"
     #include "wx/settings.h"
     #include "wx/intl.h"
     #include "wx/utils.h"
     #include "wx/settings.h"
     #include "wx/intl.h"
@@ -32,7 +34,6 @@
 #include <string.h>
 
 #ifdef __WXMSW__
 #include <string.h>
 
 #ifdef __WXMSW__
-    #include "wx/msw/wrapcdlg.h"
     #ifndef __WIN32__
         #include <print.h>
     #endif
     #ifndef __WIN32__
         #include <print.h>
     #endif
@@ -78,7 +79,7 @@ WX_DECLARE_LIST(wxPrintPaperType, wxPrintPaperTypeList);
 #include "wx/listimpl.cpp"
 WX_DEFINE_LIST(wxPrintPaperTypeList)
 
 #include "wx/listimpl.cpp"
 WX_DEFINE_LIST(wxPrintPaperTypeList)
 
-wxPrintPaperDatabase* wxThePrintPaperDatabase = (wxPrintPaperDatabase*) NULL;
+wxPrintPaperDatabase* wxThePrintPaperDatabase = NULL;
 
 wxPrintPaperDatabase::wxPrintPaperDatabase()
 {
 
 wxPrintPaperDatabase::wxPrintPaperDatabase()
 {
@@ -211,6 +212,12 @@ void wxPrintPaperDatabase::CreateDatabase()
     WXADDPAPER(wxPAPER_PENV_8_ROTATED,      116,                        wxTRANSLATE("PRC Envelope #8 Rotated 309 x 120 mm"), 3090, 1200);
     WXADDPAPER(wxPAPER_PENV_9_ROTATED,      117,                        wxTRANSLATE("PRC Envelope #9 Rotated 324 x 229 mm"), 3240, 2290);
     WXADDPAPER(wxPAPER_PENV_10_ROTATED,     118,                        wxTRANSLATE("PRC Envelope #10 Rotated 458 x 324 mm"), 4580, 3240);
     WXADDPAPER(wxPAPER_PENV_8_ROTATED,      116,                        wxTRANSLATE("PRC Envelope #8 Rotated 309 x 120 mm"), 3090, 1200);
     WXADDPAPER(wxPAPER_PENV_9_ROTATED,      117,                        wxTRANSLATE("PRC Envelope #9 Rotated 324 x 229 mm"), 3240, 2290);
     WXADDPAPER(wxPAPER_PENV_10_ROTATED,     118,                        wxTRANSLATE("PRC Envelope #10 Rotated 458 x 324 mm"), 4580, 3240);
+
+    // notice that the values 135 and 136 for Windows paper size ids of A0 and
+    // A1 formats are not documented anywhere but seem to work for at least
+    // some printers so we use them until we find a better way (see #11083)
+    WXADDPAPER(wxPAPER_A0,                  136,                        wxTRANSLATE("A0 sheet, 841 x 1189 mm"), 8410, 11888);
+    WXADDPAPER(wxPAPER_A1,                  135,                        wxTRANSLATE("A1 sheet, 594 x 841 mm"), 5940, 8410);
 }
 
 void wxPrintPaperDatabase::ClearDatabase()
 }
 
 void wxPrintPaperDatabase::ClearDatabase()
@@ -273,13 +280,15 @@ wxPrintPaperType *wxPrintPaperDatabase::FindPaperTypeByPlatformId(int id)
 
 wxPrintPaperType *wxPrintPaperDatabase::FindPaperType(const wxSize& sz)
 {
 
 wxPrintPaperType *wxPrintPaperDatabase::FindPaperType(const wxSize& sz)
 {
-    typedef wxStringToPrintPaperTypeHashMap::iterator iterator;
-
-    for (iterator it = m_map->begin(), en = m_map->end(); it != en; ++it)
+    // Take the item ordering into account so that the more common types
+    // are likely to be taken into account first. This fixes problems with,
+    // for example, Letter reverting to A4 in the page setup dialog because
+    // it was wrongly translated to Note.
+    for ( size_t i = 0; i < GetCount(); i++ )
     {
     {
-        wxPrintPaperType* paperType = it->second;
-        wxSize paperSize = paperType->GetSize() ;
-        if ( abs( paperSize.x - sz.x ) < 10 && abs( paperSize.y - sz.y ) < 10 )
+        wxPrintPaperType* const paperType = Item(i);
+        const wxSize paperSize = paperType->GetSize() ;
+        if ( abs(paperSize.x - sz.x) < 10 && abs(paperSize.y - sz.y) < 10 )
             return paperType;
     }
 
             return paperType;
     }
 
@@ -365,8 +374,7 @@ bool wxPrintPaperModule::OnInit()
 
 void wxPrintPaperModule::OnExit()
 {
 
 void wxPrintPaperModule::OnExit()
 {
-    delete wxThePrintPaperDatabase;
-    wxThePrintPaperDatabase = NULL;
+    wxDELETE(wxThePrintPaperDatabase);
 }
 
 #endif // wxUSE_PRINTING_ARCHITECTURE
 }
 
 #endif // wxUSE_PRINTING_ARCHITECTURE