From 9cbf6f6ea3ce56a15841a4f773bffef71c92c398 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 26 Mar 2003 01:41:21 +0000 Subject: [PATCH] Tweaks for various diffs from 2.4.0 to current HEAD git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19806 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/src/_defs.i | 9 +++- wxPython/src/fonts.i | 19 +++++--- wxPython/src/gdi.i | 4 ++ wxPython/src/html.i | 53 +++++++++++++++++----- wxPython/src/image.i | 99 ++++++++++++++++++++++++++++++++++++----- wxPython/src/misc2.i | 18 +------- wxPython/src/stattool.i | 3 ++ wxPython/src/windows2.i | 3 -- 8 files changed, 159 insertions(+), 49 deletions(-) diff --git a/wxPython/src/_defs.i b/wxPython/src/_defs.i index 7e07e02954..8790c0705d 100644 --- a/wxPython/src/_defs.i +++ b/wxPython/src/_defs.i @@ -188,7 +188,7 @@ enum { wxNO_BORDER, wxUSER_COLOURS, wxNO_3D, -//wxOVERRIDE_KEY_TRANSLATIONS, + wxTAB_TRAVERSAL, wxWANTS_CHARS, wxPOPUP_WINDOW, @@ -203,6 +203,7 @@ enum { wxICONIZE, wxMINIMIZE, wxMAXIMIZE, + wxCLOSE_BOX, wxTHICK_FRAME, wxSYSTEM_MENU, wxMINIMIZE_BOX, @@ -733,7 +734,11 @@ enum wxKeyCode { WXK_NUMPAD_SEPARATOR, WXK_NUMPAD_SUBTRACT, WXK_NUMPAD_DECIMAL, - WXK_NUMPAD_DIVIDE + WXK_NUMPAD_DIVIDE, + + WXK_WINDOWS_LEFT, + WXK_WINDOWS_RIGHT, + WXK_WINDOWS_MENU }; diff --git a/wxPython/src/fonts.i b/wxPython/src/fonts.i index dffe3ed4d2..a98abd1ff2 100644 --- a/wxPython/src/fonts.i +++ b/wxPython/src/fonts.i @@ -74,6 +74,7 @@ enum wxFontWeight }; + // font encodings enum wxFontEncoding { @@ -115,7 +116,7 @@ enum wxFontEncoding // and for Windows wxFONTENCODING_CP874, // WinThai wxFONTENCODING_CP932, // Japanese (shift-JIS) - wxFONTENCODING_CP936, // Chiniese simplified (GB) + wxFONTENCODING_CP936, // Chinese simplified (GB) wxFONTENCODING_CP949, // Korean (Hangul charset) wxFONTENCODING_CP950, // Chinese (traditional - Big5) wxFONTENCODING_CP1250, // WinLatin2 @@ -138,16 +139,15 @@ enum wxFontEncoding // Japanese (see http://zsigri.tripod.com/fontboard/cjk/jis.html) wxFONTENCODING_SHIFT_JIS = wxFONTENCODING_CP932, // Shift JIS - wxFONTENCODING_EUC_JP, // Extended Unix Codepage for Japanese + wxFONTENCODING_EUC_JP = wxFONTENCODING_UTF8 + 1, // Extended Unix Codepage + // for Japanese - wxFONTENCODING_UNICODE, // Unicode - currently used only by - // wxEncodingConverter class + wxFONTENCODING_UNICODE, // Unicode (for wxEncodingConverter only) wxFONTENCODING_MAX }; - //--------------------------------------------------------------------------- // wxNativeFontInfo is platform-specific font representation: this struct // should be considered as opaque font description only used by the native @@ -805,7 +805,14 @@ public: // Returns NULL if no info found, pointer must *not* be deleted by caller static const wxLanguageInfo *GetLanguageInfo(int lang); - // Add custom language to the list of known languages. + // Find the language for the given locale string which may be either a + // canonical ISO 2 letter language code ("xx"), a language code followed by + // the country code ("xx_XX") or a Windows full language name ("Xxxxx...") + // + // Returns NULL if no info found, pointer must *not* be deleted by caller + static const wxLanguageInfo *FindLanguageInfo(const wxString& locale); + + // Add custom language to the list of known languages. // Notes: 1) wxLanguageInfo contains platform-specific data // 2) must be called before Init to have effect static void AddLanguage(const wxLanguageInfo& info); diff --git a/wxPython/src/gdi.i b/wxPython/src/gdi.i index 7d521625ed..91810b0290 100644 --- a/wxPython/src/gdi.i +++ b/wxPython/src/gdi.i @@ -57,6 +57,10 @@ public: //--------------------------------------------------------------------------- + +// TODO: When the API stabalizes and is available on other platforms, add +// wrappers for the new wxBitmap, wxRawBitmap, wxDIB stuff... + class wxBitmap : public wxGDIObject { public: diff --git a/wxPython/src/html.i b/wxPython/src/html.i index 7673a3637e..cafe91ec3b 100644 --- a/wxPython/src/html.i +++ b/wxPython/src/html.i @@ -187,14 +187,13 @@ public: int GetCharHeight(); int GetCharWidth(); wxHtmlWindow* GetWindow(); - //void SetFonts(wxString normal_face, wxString fixed_face, int *LIST); %addmethods { - void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes) { - int* temp = int_LIST_helper(sizes); - if (temp) { - self->SetFonts(normal_face, fixed_face, temp); + void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) { + int* temp = NULL; + if (sizes) temp = int_LIST_helper(sizes); + self->SetFonts(normal_face, fixed_face, temp); + if (temp) delete [] temp; - } } } @@ -651,6 +650,10 @@ public: // Return value : same as SetPage bool LoadPage(const wxString& location); + // TODO: (accept a string, convert to filename) + // Loads HTML page from file + // bool LoadFile(const wxFileName& filename); + // Append to current page bool AppendToPage(const wxString& source); @@ -674,12 +677,12 @@ public: // Sets fonts to be used when displaying HTML page. %addmethods { - void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes) { - int* temp = int_LIST_helper(sizes); - if (temp) { - self->SetFonts(normal_face, fixed_face, temp); + void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) { + int* temp = NULL; + if (sizes) temp = int_LIST_helper(sizes); + self->SetFonts(normal_face, fixed_face, temp); + if (temp) delete [] temp; - } } } @@ -741,6 +744,15 @@ public: void SetHtmlText(const wxString& html, const wxString& basepath = wxPyEmptyString, bool isdir = TRUE); + %addmethods { + void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) { + int* temp = NULL; + if (sizes) temp = int_LIST_helper(sizes); + self->SetFonts(normal_face, fixed_face, temp); + if (temp) + delete [] temp; + } + } int Render(int x, int y, int from = 0, int dont_render = FALSE); int GetTotalHeight(); // returns total height of the html document @@ -765,6 +777,15 @@ public: void SetHtmlFile(const wxString &htmlfile); void SetHeader(const wxString& header, int pg = wxPAGE_ALL); void SetFooter(const wxString& footer, int pg = wxPAGE_ALL); + %addmethods { + void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) { + int* temp = NULL; + if (sizes) temp = int_LIST_helper(sizes); + self->SetFonts(normal_face, fixed_face, temp); + if (temp) + delete [] temp; + } + } void SetMargins(float top = 25.2, float bottom = 25.2, float left = 25.2, float right = 25.2, float spaces = 5); @@ -787,6 +808,16 @@ public: void SetHeader(const wxString& header, int pg = wxPAGE_ALL); void SetFooter(const wxString& footer, int pg = wxPAGE_ALL); + %addmethods { + void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) { + int* temp = NULL; + if (sizes) temp = int_LIST_helper(sizes); + self->SetFonts(normal_face, fixed_face, temp); + if (temp) + delete [] temp; + } + } + wxPrintData *GetPrintData() {return m_PrintData;} wxPageSetupDialogData *GetPageSetupData() {return m_PageSetupData;} diff --git a/wxPython/src/image.i b/wxPython/src/image.i index 7f125f11bc..8e001f0d11 100644 --- a/wxPython/src/image.i +++ b/wxPython/src/image.i @@ -30,6 +30,32 @@ %import gdi.i %import streams.i +//--------------------------------------------------------------------------- + +class wxImageHistogram /* : public wxImageHistogramBase */ +{ +public: + wxImageHistogram(); + + // get the key in the histogram for the given RGB values + static unsigned long MakeKey(unsigned char r, + unsigned char g, + unsigned char b); + + // find first colour that is not used in the image and has higher + // RGB values than RGB(startR, startG, startB) + // + // returns true and puts this colour in r, g, b (each of which may be NULL) + // on success or returns false if there are no more free colours + bool FindFirstUnusedColour(unsigned char *OUTPUT, + unsigned char *OUTPUT, + unsigned char *OUTPUT, + unsigned char startR = 1, + unsigned char startG = 0, + unsigned char startB = 0 ) const; +}; + + //--------------------------------------------------------------------------- class wxImageHandler : public wxObject { @@ -120,6 +146,7 @@ public: void Destroy(); wxImage Scale( int width, int height ); + wxImage ShrinkBy( int xFactor , int yFactor ) const ; wxImage& Rescale(int width, int height); void SetRGB( int x, int y, unsigned char r, unsigned char g, unsigned char b ); @@ -127,7 +154,11 @@ public: unsigned char GetGreen( int x, int y ); unsigned char GetBlue( int x, int y ); - // find first colour that is not used in the image and has higher + void SetAlpha(int x, int y, unsigned char alpha); + unsigned char GetAlpha(int x, int y); + bool HasAlpha(); + + // find first colour that is not used in the image and has higher // RGB values than bool FindFirstUnusedColour( byte *OUTPUT, byte *OUTPUT, byte *OUTPUT, byte startR = 0, byte startG = 0, byte startB = 0 ) const; @@ -167,18 +198,33 @@ public: //void SetData( unsigned char *data ); %addmethods { - PyObject* GetDataBuffer() { + PyObject* GetData() { unsigned char* data = self->GetData(); int len = self->GetWidth() * self->GetHeight() * 3; - return PyBuffer_FromReadWriteMemory(data, len); + return PyString_FromStringAndSize((char*)data, len); } + void SetData(PyObject* data) { + unsigned char* dataPtr; - PyObject* GetData() { + if (! PyString_Check(data)) { + PyErr_SetString(PyExc_TypeError, "Expected string object"); + return /* NULL */ ; + } + + size_t len = self->GetWidth() * self->GetHeight() * 3; + dataPtr = (unsigned char*) malloc(len); + memcpy(dataPtr, PyString_AsString(data), len); + self->SetData(dataPtr); + // wxImage takes ownership of dataPtr... + } + + + + PyObject* GetDataBuffer() { unsigned char* data = self->GetData(); int len = self->GetWidth() * self->GetHeight() * 3; - return PyString_FromStringAndSize((char*)data, len); + return PyBuffer_FromReadWriteMemory(data, len); } - void SetDataBuffer(PyObject* data) { unsigned char* buffer; int size; @@ -190,11 +236,21 @@ public: PyErr_SetString(PyExc_TypeError, "Incorrect buffer size"); return; } - self->SetData(buffer); } - void SetData(PyObject* data) { + + + PyObject* GetAlphaData() { + unsigned char* data = self->GetAlpha(); + if (! data) { + RETURN_NONE(); + } else { + int len = self->GetWidth() * self->GetHeight(); + return PyString_FromStringAndSize((char*)data, len); + } + } + void SetAlphaData(PyObject* data) { unsigned char* dataPtr; if (! PyString_Check(data)) { @@ -202,12 +258,33 @@ public: return /* NULL */ ; } - size_t len = self->GetWidth() * self->GetHeight() * 3; + size_t len = self->GetWidth() * self->GetHeight(); dataPtr = (unsigned char*) malloc(len); memcpy(dataPtr, PyString_AsString(data), len); - self->SetData(dataPtr); + self->SetAlpha(dataPtr); // wxImage takes ownership of dataPtr... } + + + + PyObject* GetAlphaBuffer() { + unsigned char* data = self->GetAlpha(); + int len = self->GetWidth() * self->GetHeight(); + return PyBuffer_FromReadWriteMemory(data, len); + } + void SetAlphaBuffer(PyObject* data) { + unsigned char* buffer; + int size; + + if (!PyArg_Parse(data, "w#", &buffer, &size)) + return; + + if (size != self->GetWidth() * self->GetHeight()) { + PyErr_SetString(PyExc_TypeError, "Incorrect buffer size"); + return; + } + self->SetAlpha(buffer); + } } void SetMaskColour( unsigned char r, unsigned char g, unsigned char b ); @@ -235,7 +312,7 @@ public: bool HasOption(const wxString& name) const; unsigned long CountColours( unsigned long stopafter = (unsigned long) -1 ); - // TODO: unsigned long ComputeHistogram( wxHashTable &h ); + unsigned long ComputeHistogram( wxImageHistogram& h ); static void AddHandler( wxImageHandler *handler ); static void InsertHandler( wxImageHandler *handler ); diff --git a/wxPython/src/misc2.i b/wxPython/src/misc2.i index 15edd72de2..c719f1e09d 100644 --- a/wxPython/src/misc2.i +++ b/wxPython/src/misc2.i @@ -607,8 +607,6 @@ public: static void OnLog(unsigned long level, const wxString& szString, int t=0); virtual void Flush(); - bool HasPendingMessages() const; - static void FlushActive(); static wxLog *GetActiveTarget(); static wxLog *SetActiveTarget(wxLog *pLogger); @@ -1398,7 +1396,7 @@ public: // // use the extraDir parameter if you want to look for files in another // directory - void Initialize(int mailcapStyle = wxMAILCAP_STANDARD, + void Initialize(int mailcapStyle = wxMAILCAP_ALL, const wxString& extraDir = wxPyEmptyString); // and this function clears all the data from the manager @@ -1522,6 +1520,7 @@ wxART_ERROR = 'wxART_ERROR' wxART_QUESTION = 'wxART_QUESTION' wxART_WARNING = 'wxART_WARNING' wxART_INFORMATION = 'wxART_INFORMATION' +wxART_MISSING_IMAGE = 'wxART_MISSING_IMAGE' " %{ // Python aware wxArtProvider @@ -1693,19 +1692,6 @@ public: //---------------------------------------------------------------------- -// %{ -// #if wxUSE_UNICODE -// #define ADD_STRING(dict, str) \ -// wxString tmp##str(str); \ -// PyDict_SetItemString(dict, #str, \ -// PyUnicode_FromWideChar(tmp##str.c_str(), tmp##str.Len())) -// #else -// #define ADD_STRING(dict, str) \ -// PyDict_SetItemString(d, #str, PyString_FromString(str)) -// #endif -// %} - - %init %{ wxPyPtrTypeMap_Add("wxDragImage", "wxGenericDragImage"); wxPyPtrTypeMap_Add("wxProcess", "wxPyProcess"); diff --git a/wxPython/src/stattool.i b/wxPython/src/stattool.i index 26c4e1537d..e2b4183a11 100644 --- a/wxPython/src/stattool.i +++ b/wxPython/src/stattool.i @@ -341,6 +341,9 @@ public: shortHelp, longHelp, clientData) " + // TODO? + //wxToolBarToolBase *AddTool (wxToolBarToolBase *tool); + //wxToolBarToolBase *InsertTool (size_t pos, wxToolBarToolBase *tool); wxToolBarToolBase *AddControl(wxControl *control); wxToolBarToolBase *InsertControl(size_t pos, wxControl *control); diff --git a/wxPython/src/windows2.i b/wxPython/src/windows2.i index 77fedbb253..167ecb379f 100644 --- a/wxPython/src/windows2.i +++ b/wxPython/src/windows2.i @@ -14,9 +14,6 @@ %{ #include "helpers.h" -#ifdef OLD_GRID -#include -#endif #include #include #include -- 2.47.2