Added __nonzero__ method to more classes that have a Ok or IsOk

method.  This allows code like "if obj: ..." to be the same as
"if obj.Ok: ..."


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@20123 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2003-04-10 19:38:11 +00:00
parent d2d844fa99
commit 88cd49f777
6 changed files with 33 additions and 6 deletions

View File

@@ -374,6 +374,7 @@ public:
static wxFontEncoding GetDefaultEncoding(); static wxFontEncoding GetDefaultEncoding();
static void SetDefaultEncoding(wxFontEncoding encoding); static void SetDefaultEncoding(wxFontEncoding encoding);
%pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
}; };
@@ -962,6 +963,7 @@ public:
// equivalent encodings, regardless the platform, including itself. // equivalent encodings, regardless the platform, including itself.
static wxFontEncodingArray GetAllEquivalents(wxFontEncoding enc); static wxFontEncodingArray GetAllEquivalents(wxFontEncoding enc);
%pragma(python) addtoclass = "def __nonzero__(self): return self.IsOk()"
}; };

View File

@@ -101,6 +101,7 @@ public:
void SetQuality(int q); void SetQuality(int q);
#endif #endif
%pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
}; };
@@ -229,6 +230,7 @@ public:
#endif #endif
void CopyFromBitmap(const wxBitmap& bmp); void CopyFromBitmap(const wxBitmap& bmp);
%pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
}; };
@@ -318,6 +320,7 @@ public:
void SetDepth(int d); void SetDepth(int d);
void SetSize(const wxSize& size); void SetSize(const wxSize& size);
#endif #endif
%pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
}; };
%name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id); %name(wxStockCursor) %new wxCursor* wxPyStockCursor(int id);
@@ -473,6 +476,8 @@ public:
wxBitmap* GetStipple(); wxBitmap* GetStipple();
void SetStipple(wxBitmap& stipple); void SetStipple(wxBitmap& stipple);
#endif #endif
%pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
}; };
@@ -546,6 +551,8 @@ public:
void SetColour(wxColour &colour); void SetColour(wxColour &colour);
void SetStipple(wxBitmap& bitmap); void SetStipple(wxBitmap& bitmap);
void SetStyle(int style); void SetStyle(int style);
%pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
}; };
@@ -705,6 +712,8 @@ public:
// See below for implementation // See below for implementation
} }
%pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
#ifdef __WXMSW__ #ifdef __WXMSW__
long GetHDC(); long GetHDC();
#endif #endif
@@ -959,6 +968,7 @@ public:
const wxString& GetFileName() const { return m_filename; } const wxString& GetFileName() const { return m_filename; }
%pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
}; };
// bool wxMakeMetaFilePlaceable(const wxString& filename, // bool wxMakeMetaFilePlaceable(const wxString& filename,
@@ -985,6 +995,8 @@ public:
int GetPixel(byte red, byte green, byte blue); int GetPixel(byte red, byte green, byte blue);
bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT); bool GetRGB(int pixel, byte* OUTPUT, byte* OUTPUT, byte* OUTPUT);
bool Ok(); bool Ok();
%pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
}; };
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View File

@@ -256,6 +256,8 @@ public:
return bitmap; return bitmap;
} }
} }
%pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
}; };

View File

@@ -379,6 +379,8 @@ public:
void SetSize(const wxSize& size); void SetSize(const wxSize& size);
void Show(int show = TRUE); void Show(int show = TRUE);
void Hide(); void Hide();
%pragma(python) addtoclass = "def __nonzero__(self): return self.IsOk()"
}; };
%inline %{ %inline %{
@@ -1050,6 +1052,8 @@ public:
bool SetCapture(wxWindow* win, int pollingFreq = 0); bool SetCapture(wxWindow* win, int pollingFreq = 0);
bool ReleaseCapture(); bool ReleaseCapture();
%pragma(python) addtoclass = "def __nonzero__(self): return self.IsOk()"
}; };
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@@ -1083,11 +1087,13 @@ public:
class wxWave : public wxObject class wxWave : public wxObject
{ {
public: public:
wxWave(const wxString& fileName, bool isResource = FALSE); wxWave(const wxString& fileName, bool isResource = FALSE);
~wxWave(); ~wxWave();
bool IsOk() const; bool IsOk() const;
bool Play(bool async = TRUE, bool looped = FALSE) const; bool Play(bool async = TRUE, bool looped = FALSE) const;
%pragma(python) addtoclass = "def __nonzero__(self): return self.IsOk()"
}; };
%new wxWave* wxWaveData(const wxString& data); %new wxWave* wxWaveData(const wxString& data);

View File

@@ -107,6 +107,7 @@ public:
void SetPrinterTranslation(long x, long y); void SetPrinterTranslation(long x, long y);
void SetPrintMode(wxPrintMode printMode); void SetPrintMode(wxPrintMode printMode);
%pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
}; };
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@@ -181,6 +182,8 @@ public:
void SetPaperId(wxPaperSize id); void SetPaperId(wxPaperSize id);
void SetPaperSize(const wxSize& size); void SetPaperSize(const wxSize& size);
void SetPrintData(const wxPrintData& printData); void SetPrintData(const wxPrintData& printData);
%pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
}; };
@@ -231,6 +234,8 @@ public:
void SetPrintToFile(bool flag); void SetPrintToFile(bool flag);
void SetSetupDialog(bool flag); void SetSetupDialog(bool flag);
void SetToPage(int page); void SetToPage(int page);
%pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
}; };
@@ -386,6 +391,8 @@ public:
void SetFrame(wxFrame *frame); void SetFrame(wxFrame *frame);
void SetPrintout(wxPyPrintout *printout); void SetPrintout(wxPyPrintout *printout);
void SetZoom(int percent); void SetZoom(int percent);
%pragma(python) addtoclass = "def __nonzero__(self): return self.Ok()"
}; };
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@@ -730,8 +730,6 @@ public:
%name(RemoveItem) wxMenuItem *Remove(wxMenuItem *item); %name(RemoveItem) wxMenuItem *Remove(wxMenuItem *item);
%addmethods { %addmethods {
void Destroy() { delete self; } void Destroy() { delete self; }
} }