projects
/
wxWidgets.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Warning fixes.
[wxWidgets.git]
/
src
/
common
/
paper.cpp
diff --git
a/src/common/paper.cpp
b/src/common/paper.cpp
index 58156a1bb496d1e44c7ab4344d62c4a1ee4921ac..dafaeb189af193865214e5afccc6999da2820378 100644
(file)
--- a/
src/common/paper.cpp
+++ b/
src/common/paper.cpp
@@
-1,15
+1,15
@@
/////////////////////////////////////////////////////////////////////////////
// Name: paper.cpp
// Purpose: Paper size classes
/////////////////////////////////////////////////////////////////////////////
// Name: paper.cpp
// Purpose: Paper size classes
-// Author: Julian Smart
+// Author: Julian Smart
// Modified by:
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Modified by:
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
-// Licence: wxWindows licence
+// Licence:
wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
-#if
def __GNUG__
+#if
defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "paper.h"
#endif
#pragma implementation "paper.h"
#endif
@@
-38,7
+38,7
@@
#include <string.h>
#ifdef __WXMSW__
#include <string.h>
#ifdef __WXMSW__
-#include
<windows.h>
+#include
"wx/msw/wrapwin.h"
#include <commdlg.h>
#ifndef __WIN32__
#include <commdlg.h>
#ifndef __WIN32__
@@
-49,7
+49,7
@@
// End __WXMSW__
IMPLEMENT_DYNAMIC_CLASS(wxPrintPaperType, wxObject)
// End __WXMSW__
IMPLEMENT_DYNAMIC_CLASS(wxPrintPaperType, wxObject)
-IMPLEMENT_DYNAMIC_CLASS(wxPrintPaperDatabase, wxList)
+
//
IMPLEMENT_DYNAMIC_CLASS(wxPrintPaperDatabase, wxList)
/*
* Paper size database for all platforms
/*
* Paper size database for all platforms
@@
-83,11
+83,21
@@
wxSize wxPrintPaperType::GetSizeDeviceUnits() const
* Print paper database for PostScript
*/
* Print paper database for PostScript
*/
+WX_DECLARE_LIST(wxPrintPaperType, wxPrintPaperTypeList);
+#include "wx/listimpl.cpp"
+WX_DEFINE_LIST(wxPrintPaperTypeList);
+
wxPrintPaperDatabase* wxThePrintPaperDatabase = (wxPrintPaperDatabase*) NULL;
wxPrintPaperDatabase* wxThePrintPaperDatabase = (wxPrintPaperDatabase*) NULL;
-wxPrintPaperDatabase::wxPrintPaperDatabase():wxList(wxKEY_STRING)
+wxPrintPaperDatabase::wxPrintPaperDatabase()
+{
+ m_map = new wxStringToPrintPaperTypeHashMap;
+ m_list = new wxPrintPaperTypeList;
+}
+
+wxPrintPaperDatabase::~wxPrintPaperDatabase()
{
{
-
DeleteContents(TRUE
);
+
ClearDatabase(
);
}
void wxPrintPaperDatabase::CreateDatabase()
}
void wxPrintPaperDatabase::CreateDatabase()
@@
-175,65
+185,75
@@
void wxPrintPaperDatabase::CreateDatabase()
void wxPrintPaperDatabase::ClearDatabase()
{
void wxPrintPaperDatabase::ClearDatabase()
{
- Clear();
+ delete m_list;
+ WX_CLEAR_HASH_MAP(wxStringToPrintPaperTypeHashMap, *m_map);
+ delete m_map;
}
void wxPrintPaperDatabase::AddPaperType(wxPaperSize paperId, const wxString& name, int w, int h)
{
}
void wxPrintPaperDatabase::AddPaperType(wxPaperSize paperId, const wxString& name, int w, int h)
{
- Append(name, new wxPrintPaperType(paperId, 0, name, w, h));
+ wxPrintPaperType* tmp = new wxPrintPaperType(paperId, 0, name, w, h);
+ (*m_map)[name] = tmp;
+ m_list->push_back(tmp);
}
void wxPrintPaperDatabase::AddPaperType(wxPaperSize paperId, int platformId, const wxString& name, int w, int h)
{
}
void wxPrintPaperDatabase::AddPaperType(wxPaperSize paperId, int platformId, const wxString& name, int w, int h)
{
- Append(name, new wxPrintPaperType(paperId, platformId, name, w, h));
+ wxPrintPaperType* tmp = new wxPrintPaperType(paperId, platformId, name, w, h);
+ (*m_map)[name] = tmp;
+ m_list->push_back(tmp);
}
wxPrintPaperType *wxPrintPaperDatabase::FindPaperType(const wxString& name)
{
}
wxPrintPaperType *wxPrintPaperDatabase::FindPaperType(const wxString& name)
{
- wx
Node *node = F
ind(name);
- if (
node
)
- return
(wxPrintPaperType *)node->Data()
;
+ wx
StringToPrintPaperTypeHashMap::iterator it = m_map->f
ind(name);
+ if (
it != m_map->end()
)
+ return
it->second
;
else
else
- return
(wxPrintPaperType *)
NULL;
+ return NULL;
}
wxPrintPaperType *wxPrintPaperDatabase::FindPaperType(wxPaperSize id)
{
}
wxPrintPaperType *wxPrintPaperDatabase::FindPaperType(wxPaperSize id)
{
- wxNode *node = First();
- while (node)
+ typedef wxStringToPrintPaperTypeHashMap::iterator iterator;
+
+ for (iterator it = m_map->begin(), en = m_map->end(); it != en; ++it)
{
{
- wxPrintPaperType* paperType =
(wxPrintPaperType*) node->Data()
;
+ wxPrintPaperType* paperType =
it->second
;
if (paperType->GetId() == id)
return paperType;
if (paperType->GetId() == id)
return paperType;
- node = node->Next();
}
}
- return (wxPrintPaperType *) NULL;
+
+ return NULL;
}
wxPrintPaperType *wxPrintPaperDatabase::FindPaperTypeByPlatformId(int id)
{
}
wxPrintPaperType *wxPrintPaperDatabase::FindPaperTypeByPlatformId(int id)
{
- wxNode *node = First();
- while (node)
+ typedef wxStringToPrintPaperTypeHashMap::iterator iterator;
+
+ for (iterator it = m_map->begin(), en = m_map->end(); it != en; ++it)
{
{
- wxPrintPaperType* paperType =
(wxPrintPaperType*) node->Data()
;
+ wxPrintPaperType* paperType =
it->second
;
if (paperType->GetPlatformId() == id)
return paperType;
if (paperType->GetPlatformId() == id)
return paperType;
- node = node->Next();
}
}
- return (wxPrintPaperType *) NULL;
+
+ return NULL;
}
wxPrintPaperType *wxPrintPaperDatabase::FindPaperType(const wxSize& sz)
{
}
wxPrintPaperType *wxPrintPaperDatabase::FindPaperType(const wxSize& sz)
{
- wxNode *node = First();
- while (node)
+ typedef wxStringToPrintPaperTypeHashMap::iterator iterator;
+
+ for (iterator it = m_map->begin(), en = m_map->end(); it != en; ++it)
{
{
- wxPrintPaperType* paperType = (wxPrintPaperType*) node->Data();
- if (paperType->GetSize() == sz)
+ wxPrintPaperType* paperType = it->second;
+ wxSize paperSize = paperType->GetSize() ;
+ if ( abs( paperSize.x - sz.x ) < 10 && abs( paperSize.y - sz.y ) < 10 )
return paperType;
return paperType;
- node = node->Next();
}
}
- return (wxPrintPaperType *) NULL;
+
+ return NULL;
}
// Convert name to size id
}
// Convert name to size id
@@
-276,6
+296,17
@@
wxPaperSize wxPrintPaperDatabase::GetSize(const wxSize& size)
return wxPAPER_NONE;
}
return wxPAPER_NONE;
}
+// QUICK and DIRTY
+size_t wxPrintPaperDatabase::GetCount() const
+{
+ return m_list->GetCount();
+}
+
+wxPrintPaperType* wxPrintPaperDatabase::Item(size_t index) const
+{
+ return m_list->Item(index)->GetData();
+}
+
// A module to allow initialization/cleanup of print paper
// things without calling these functions from app.cpp.
// A module to allow initialization/cleanup of print paper
// things without calling these functions from app.cpp.
@@
-299,7
+330,7
@@
bool wxPrintPaperModule::OnInit()
wxThePrintPaperDatabase = new wxPrintPaperDatabase;
wxThePrintPaperDatabase->CreateDatabase();
wxThePrintPaperDatabase = new wxPrintPaperDatabase;
wxThePrintPaperDatabase->CreateDatabase();
- return
TRUE
;
+ return
true
;
}
void wxPrintPaperModule::OnExit()
}
void wxPrintPaperModule::OnExit()