1998-08-09 08:31:08 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: misc.i
|
|
|
|
// Purpose: Definitions of miscelaneous functions and classes
|
|
|
|
//
|
|
|
|
// Author: Robin Dunn
|
|
|
|
//
|
|
|
|
// Created: 7/3/97
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) 1998 by Total Control Software
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-08-15 07:36:54 +00:00
|
|
|
%module misc
|
1998-08-09 08:31:08 +00:00
|
|
|
|
1998-08-15 07:36:54 +00:00
|
|
|
%{
|
1998-08-09 08:31:08 +00:00
|
|
|
#include "helpers.h"
|
|
|
|
#include <wx/resource.h>
|
1999-02-20 09:05:04 +00:00
|
|
|
#include <wx/tooltip.h>
|
1999-10-29 22:25:04 +00:00
|
|
|
#include <wx/busyinfo.h>
|
1998-08-09 08:31:08 +00:00
|
|
|
%}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
%include typemaps.i
|
|
|
|
%include my_typemaps.i
|
|
|
|
|
|
|
|
// Import some definitions of other classes, etc.
|
|
|
|
%import _defs.i
|
|
|
|
|
|
|
|
|
1999-06-22 07:03:29 +00:00
|
|
|
//---------------------------------------------------------------------------
|
1998-08-09 08:31:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
class wxSize {
|
|
|
|
public:
|
1999-02-20 09:05:04 +00:00
|
|
|
long x;
|
|
|
|
long y;
|
1998-08-09 08:31:08 +00:00
|
|
|
%name(width) long x;
|
|
|
|
%name(height)long y;
|
|
|
|
|
|
|
|
wxSize(long w=0, long h=0);
|
|
|
|
~wxSize();
|
|
|
|
void Set(long w, long h);
|
1999-02-20 09:05:04 +00:00
|
|
|
long GetX();
|
|
|
|
long GetY();
|
1999-06-22 07:03:29 +00:00
|
|
|
long GetWidth();
|
|
|
|
long GetHeight();
|
|
|
|
void SetWidth(long w);
|
|
|
|
void SetHeight(long h);
|
1998-08-09 08:31:08 +00:00
|
|
|
|
|
|
|
%addmethods {
|
1999-02-20 09:05:04 +00:00
|
|
|
PyObject* asTuple() {
|
1998-08-09 08:31:08 +00:00
|
|
|
PyObject* tup = PyTuple_New(2);
|
|
|
|
PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
|
|
|
|
PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
|
|
|
|
return tup;
|
|
|
|
}
|
|
|
|
}
|
1999-02-20 09:05:04 +00:00
|
|
|
%pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
|
|
|
|
%pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
|
|
|
|
|
1998-08-09 08:31:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class wxRealPoint {
|
|
|
|
public:
|
|
|
|
double x;
|
|
|
|
double y;
|
|
|
|
wxRealPoint(double x=0.0, double y=0.0);
|
|
|
|
~wxRealPoint();
|
1999-09-02 05:31:38 +00:00
|
|
|
|
|
|
|
%addmethods {
|
|
|
|
void Set(double x, double y) {
|
|
|
|
self->x = x;
|
|
|
|
self->y = y;
|
|
|
|
}
|
|
|
|
PyObject* asTuple() {
|
|
|
|
PyObject* tup = PyTuple_New(2);
|
|
|
|
PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->x));
|
|
|
|
PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->y));
|
|
|
|
return tup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
%pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
|
|
|
|
%pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
|
1998-08-09 08:31:08 +00:00
|
|
|
};
|
|
|
|
|
1999-09-02 05:31:38 +00:00
|
|
|
|
1998-08-09 08:31:08 +00:00
|
|
|
class wxPoint {
|
|
|
|
public:
|
|
|
|
long x;
|
|
|
|
long y;
|
|
|
|
wxPoint(long x=0, long y=0);
|
|
|
|
~wxPoint();
|
|
|
|
|
|
|
|
%addmethods {
|
|
|
|
void Set(long x, long y) {
|
|
|
|
self->x = x;
|
|
|
|
self->y = y;
|
|
|
|
}
|
1999-02-20 09:05:04 +00:00
|
|
|
PyObject* asTuple() {
|
1998-08-09 08:31:08 +00:00
|
|
|
PyObject* tup = PyTuple_New(2);
|
|
|
|
PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
|
|
|
|
PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
|
|
|
|
return tup;
|
|
|
|
}
|
|
|
|
}
|
1999-02-20 09:05:04 +00:00
|
|
|
%pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
|
|
|
|
%pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
|
1998-08-09 08:31:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class wxRect {
|
|
|
|
public:
|
1999-11-30 20:21:55 +00:00
|
|
|
wxRect(int x=0, int y=0, int w=0, int h=0);
|
|
|
|
// TODO: do this one too... wxRect(const wxPoint& pos, const wxSize& size);
|
|
|
|
~wxRect();
|
1998-08-09 08:31:08 +00:00
|
|
|
|
1999-11-30 20:21:55 +00:00
|
|
|
int GetX();
|
|
|
|
void SetX(int X);
|
|
|
|
int GetY();
|
|
|
|
void SetY(int Y);
|
|
|
|
int GetWidth();
|
|
|
|
void SetWidth(int w);
|
|
|
|
int GetHeight();
|
|
|
|
void SetHeight(int h);
|
1998-08-09 08:31:08 +00:00
|
|
|
|
|
|
|
|
1999-11-30 20:21:55 +00:00
|
|
|
wxPoint GetPosition();
|
|
|
|
wxSize GetSize();
|
1998-08-09 08:31:08 +00:00
|
|
|
|
1999-11-30 20:21:55 +00:00
|
|
|
int GetLeft();
|
|
|
|
int GetTop();
|
|
|
|
int GetBottom();
|
|
|
|
int GetRight();
|
1998-08-09 08:31:08 +00:00
|
|
|
|
1999-11-30 20:21:55 +00:00
|
|
|
void SetLeft(int left);
|
|
|
|
void SetRight(int right);
|
|
|
|
void SetTop(int top);
|
|
|
|
void SetBottom(int bottom);
|
|
|
|
|
|
|
|
|
|
|
|
int x, y, width, height;
|
1999-02-20 09:05:04 +00:00
|
|
|
|
|
|
|
%addmethods {
|
|
|
|
PyObject* asTuple() {
|
|
|
|
PyObject* tup = PyTuple_New(4);
|
|
|
|
PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
|
|
|
|
PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
|
1999-10-06 06:22:25 +00:00
|
|
|
PyTuple_SET_ITEM(tup, 2, PyInt_FromLong(self->width));
|
|
|
|
PyTuple_SET_ITEM(tup, 3, PyInt_FromLong(self->height));
|
1999-02-20 09:05:04 +00:00
|
|
|
return tup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
%pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
|
|
|
|
%pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
|
1998-08-09 08:31:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
1999-11-30 20:21:55 +00:00
|
|
|
// %inline %{
|
|
|
|
// bool wxIntersectRect(wxRect* dest, wxRect* r1, wxRect* r2) {
|
|
|
|
// wxRegion reg1(*r1);
|
|
|
|
// wxRegion reg2(*r2);
|
|
|
|
// bool success;
|
|
|
|
// *dest = wxRect(0,0,0,0);
|
|
|
|
// success = reg1.Intersect(reg2);
|
|
|
|
// if (success) {
|
|
|
|
// *dest = reg1.GetBox();
|
|
|
|
// return *dest != wxRect(0,0,0,0);
|
|
|
|
// }
|
|
|
|
// return FALSE;
|
|
|
|
// }
|
|
|
|
// %}
|
|
|
|
|
|
|
|
|
|
|
|
%inline %{
|
|
|
|
PyObject* wxIntersectRect(wxRect* r1, wxRect* r2) {
|
|
|
|
wxRegion reg1(*r1);
|
|
|
|
wxRegion reg2(*r2);
|
|
|
|
wxRect dest(0,0,0,0);
|
|
|
|
PyObject* obj;
|
|
|
|
|
|
|
|
reg1.Intersect(reg2);
|
|
|
|
dest = reg1.GetBox();
|
|
|
|
|
|
|
|
if (dest != wxRect(0,0,0,0)) {
|
|
|
|
bool doSave = wxPyRestoreThread();
|
|
|
|
wxRect* newRect = new wxRect(dest);
|
|
|
|
obj = wxPyConstructObject((void*)newRect, "wxRect");
|
|
|
|
PyObject_SetAttrString(obj, "thisown", PyInt_FromLong(1));
|
|
|
|
wxPySaveThread(doSave);
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
|
|
|
}
|
|
|
|
%}
|
1998-08-09 08:31:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// Miscellaneous functions
|
|
|
|
|
1999-04-30 03:29:54 +00:00
|
|
|
long wxNewId();
|
|
|
|
void wxRegisterId(long id);
|
|
|
|
%name(NewId) long wxNewId();
|
|
|
|
%name(RegisterId) void wxRegisterId(long id);
|
|
|
|
|
1998-08-09 08:31:08 +00:00
|
|
|
void wxBell();
|
|
|
|
void wxDisplaySize(int *OUTPUT, int *OUTPUT);
|
|
|
|
void wxEndBusyCursor();
|
1999-11-30 20:21:55 +00:00
|
|
|
long wxExecute(const wxString& command, int sync = FALSE);
|
1998-08-09 08:31:08 +00:00
|
|
|
long wxGetElapsedTime(bool resetTimer = TRUE);
|
1999-10-09 23:13:43 +00:00
|
|
|
#ifdef __WXMSW__
|
1998-08-09 08:31:08 +00:00
|
|
|
long wxGetFreeMemory();
|
1999-10-09 23:13:43 +00:00
|
|
|
#endif
|
1998-08-09 08:31:08 +00:00
|
|
|
void wxGetMousePosition(int* OUTPUT, int* OUTPUT);
|
|
|
|
bool wxIsBusy();
|
|
|
|
wxString wxNow();
|
1998-08-18 19:48:20 +00:00
|
|
|
bool wxShell(const wxString& command = wxPyEmptyStr);
|
1998-08-09 08:31:08 +00:00
|
|
|
void wxStartTimer();
|
1998-08-18 19:48:20 +00:00
|
|
|
int wxGetOsVersion(int *OUTPUT, int *OUTPUT);
|
|
|
|
|
1999-06-22 07:03:29 +00:00
|
|
|
void wxSleep(int secs);
|
1998-08-09 08:31:08 +00:00
|
|
|
bool wxYield();
|
1999-04-30 03:29:54 +00:00
|
|
|
bool wxSafeYield();
|
1999-06-22 07:03:29 +00:00
|
|
|
void wxEnableTopLevelWindows(bool enable);
|
1998-08-09 08:31:08 +00:00
|
|
|
|
|
|
|
%inline %{
|
|
|
|
char* wxGetResource(char *section, char *entry, char *file = NULL) {
|
|
|
|
char * retval;
|
|
|
|
wxGetResource(section, entry, &retval, file);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
%}
|
|
|
|
|
1999-11-25 07:08:14 +00:00
|
|
|
wxString wxStripMenuCodes(const wxString& in);
|
1998-08-09 08:31:08 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
class wxPyTimer {
|
|
|
|
public:
|
|
|
|
wxPyTimer(PyObject* notify);
|
|
|
|
~wxPyTimer();
|
1999-11-25 07:08:14 +00:00
|
|
|
int GetInterval();
|
|
|
|
bool IsOneShot();
|
1998-08-09 08:31:08 +00:00
|
|
|
void Start(int milliseconds=-1, int oneShot=FALSE);
|
|
|
|
void Stop();
|
|
|
|
};
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
enum wxEdge { wxLeft, wxTop, wxRight, wxBottom, wxWidth, wxHeight,
|
|
|
|
wxCentre, wxCenter = wxCentre, wxCentreX, wxCentreY };
|
|
|
|
enum wxRelationship { wxUnconstrained = 0,
|
|
|
|
wxAsIs,
|
|
|
|
wxPercentOf,
|
|
|
|
wxAbove,
|
|
|
|
wxBelow,
|
|
|
|
wxLeftOf,
|
|
|
|
wxRightOf,
|
|
|
|
wxSameAs,
|
|
|
|
wxAbsolute };
|
|
|
|
|
|
|
|
|
|
|
|
class wxIndividualLayoutConstraint {
|
|
|
|
public:
|
|
|
|
// wxIndividualLayoutConstraint();
|
|
|
|
// ~wxIndividualLayoutConstraint();
|
|
|
|
|
|
|
|
void Above(wxWindow *otherWin, int margin=0);
|
|
|
|
void Absolute(int value);
|
1999-01-30 07:31:33 +00:00
|
|
|
void AsIs();
|
1998-08-09 08:31:08 +00:00
|
|
|
void Below(wxWindow *otherWin, int margin=0);
|
1999-01-30 07:31:33 +00:00
|
|
|
void Unconstrained();
|
1998-08-09 08:31:08 +00:00
|
|
|
void LeftOf(wxWindow *otherWin, int margin=0);
|
|
|
|
void PercentOf(wxWindow *otherWin, wxEdge edge, int percent);
|
|
|
|
void RightOf(wxWindow *otherWin, int margin=0);
|
|
|
|
void SameAs(wxWindow *otherWin, wxEdge edge, int margin=0);
|
|
|
|
void Set(wxRelationship rel, wxWindow *otherWin, wxEdge otherEdge, int value=0, int margin=0);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class wxLayoutConstraints {
|
|
|
|
public:
|
|
|
|
wxLayoutConstraints();
|
|
|
|
|
|
|
|
%readonly
|
|
|
|
wxIndividualLayoutConstraint bottom;
|
|
|
|
wxIndividualLayoutConstraint centreX;
|
|
|
|
wxIndividualLayoutConstraint centreY;
|
|
|
|
wxIndividualLayoutConstraint height;
|
|
|
|
wxIndividualLayoutConstraint left;
|
|
|
|
wxIndividualLayoutConstraint right;
|
|
|
|
wxIndividualLayoutConstraint top;
|
|
|
|
wxIndividualLayoutConstraint width;
|
|
|
|
%readwrite
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-11-25 08:47:28 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// Regions, etc.
|
|
|
|
|
|
|
|
enum wxRegionContain {
|
|
|
|
wxOutRegion, wxPartRegion, wxInRegion
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class wxRegion {
|
|
|
|
public:
|
|
|
|
wxRegion();
|
|
|
|
~wxRegion();
|
|
|
|
|
|
|
|
void Clear();
|
|
|
|
wxRegionContain Contains(long x, long y);
|
|
|
|
%name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt);
|
|
|
|
%name(ContainsRect)wxRegionContain Contains(const wxRect& rect);
|
1999-11-30 20:21:55 +00:00
|
|
|
%name(ContainsRectDim)wxRegionContain Contains(long x, long y, long w, long h);
|
1998-11-25 08:47:28 +00:00
|
|
|
|
|
|
|
wxRect GetBox();
|
1999-11-30 20:21:55 +00:00
|
|
|
|
|
|
|
bool Intersect(long x, long y, long width, long height);
|
|
|
|
%name(IntersectRect)bool Intersect(const wxRect& rect);
|
|
|
|
%name(IntersectRegion)bool Intersect(const wxRegion& region);
|
|
|
|
|
1998-11-25 08:47:28 +00:00
|
|
|
bool IsEmpty();
|
1999-11-30 20:21:55 +00:00
|
|
|
|
|
|
|
bool Union(long x, long y, long width, long height);
|
|
|
|
%name(UnionRect)bool Union(const wxRect& rect);
|
|
|
|
%name(UnionRegion)bool Union(const wxRegion& region);
|
|
|
|
|
|
|
|
bool Subtract(long x, long y, long width, long height);
|
|
|
|
%name(SubtractRect)bool Subtract(const wxRect& rect);
|
|
|
|
%name(SubtractRegion)bool Subtract(const wxRegion& region);
|
|
|
|
|
|
|
|
bool Xor(long x, long y, long width, long height);
|
|
|
|
%name(XorRect)bool Xor(const wxRect& rect);
|
|
|
|
%name(XorRegion)bool Xor(const wxRegion& region);
|
1998-11-25 08:47:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class wxRegionIterator {
|
|
|
|
public:
|
|
|
|
wxRegionIterator(const wxRegion& region);
|
|
|
|
~wxRegionIterator();
|
|
|
|
|
|
|
|
long GetX();
|
|
|
|
long GetY();
|
|
|
|
long GetW();
|
|
|
|
long GetWidth();
|
|
|
|
long GetH();
|
|
|
|
long GetHeight();
|
|
|
|
wxRect GetRect();
|
|
|
|
bool HaveRects();
|
|
|
|
void Reset();
|
|
|
|
|
|
|
|
%addmethods {
|
|
|
|
void Next() {
|
|
|
|
(*self) ++;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
1998-08-09 08:31:08 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// Accelerator Entry and Table
|
|
|
|
|
|
|
|
class wxAcceleratorEntry {
|
|
|
|
public:
|
|
|
|
wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0);
|
1999-09-30 07:11:20 +00:00
|
|
|
~wxAcceleratorEntry();
|
1998-08-09 08:31:08 +00:00
|
|
|
|
|
|
|
void Set(int flags, int keyCode, int Cmd);
|
|
|
|
int GetFlags();
|
|
|
|
int GetKeyCode();
|
|
|
|
int GetCommand();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class wxAcceleratorTable {
|
|
|
|
public:
|
|
|
|
// Can also accept a list of 3-tuples
|
|
|
|
wxAcceleratorTable(int LCOUNT, wxAcceleratorEntry* LIST);
|
1999-09-30 07:11:20 +00:00
|
|
|
~wxAcceleratorTable();
|
1998-08-09 08:31:08 +00:00
|
|
|
|
|
|
|
};
|
1998-11-15 23:04:59 +00:00
|
|
|
|
1999-07-31 07:56:15 +00:00
|
|
|
//---------------------------------------------------------------------------
|
1999-10-29 22:25:04 +00:00
|
|
|
|
|
|
|
class wxBusyInfo {
|
|
|
|
public:
|
|
|
|
wxBusyInfo(const wxString& message);
|
|
|
|
~wxBusyInfo();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-07-31 07:56:15 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|