Added wxHyperlinkCtrl, wxPowerEvent, and lots of little things to

match changes made in wx.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39452 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2006-05-29 19:52:17 +00:00
parent 9e89f049b8
commit d0e2ede057
15 changed files with 630 additions and 378 deletions

View File

@@ -153,6 +153,16 @@ to OpenEditor to send the BEGIN_LABEL_EDIT event and to not allow the
opening of the editor to continue if the event handler doesn't allow opening of the editor to continue if the event handler doesn't allow
it. it.
wx.StaticBoxSizer now keeps better track of the wx.StaticBox, and it
will destroy it if the sizer is destroyed before the parent window is.
Added wx.HyperlinkCtrl.
Added battery and power related functions and events (wxMSW only so
far.) See wx.PowerEvent, wx.GetPowerType and wx.GetBatteryState.
Added wx.ListCtrl.HitTestSubItem which returns the sub-item that was
hit (if any) in addition to the item and flags.

View File

@@ -105,6 +105,11 @@ wxColour wxGetColourFromUser(wxWindow *parent = (wxWindow *)NULL,
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
enum {
wxDD_NEW_DIR_BUTTON,
wxDD_DEFAULT_STYLE,
wxDD_CHANGE_DIR,
};
DocStr(wxDirDialog, DocStr(wxDirDialog,
"wx.DirDialog allows the user to select a directory by browising the "wx.DirDialog allows the user to select a directory by browising the
@@ -113,10 +118,17 @@ file system.", "
Window Styles Window Styles
-------------- --------------
==================== ========================================== ==================== ==========================================
wx.DD_DEFAULT_STYLE Equivalent to a combination of
wx.DEFAULT_DIALOG_STYLE, wx.DD_NEW_DIR_BUTTON
and wx.RESIZE_BORDER.
wx.DD_NEW_DIR_BUTTON Add 'Create new directory' button and allow wx.DD_NEW_DIR_BUTTON Add 'Create new directory' button and allow
directory names to be editable. On Windows directory names to be editable. On Windows
the new directory button is only available the new directory button is only available
with recent versions of the common dialogs. with recent versions of the common dialogs.
wx.DD_CHANGE_DIR Change the current working directory to the
directory chosen by the user.
==================== ========================================== ==================== ==========================================
"); ");
@@ -131,7 +143,7 @@ public:
wxDirDialog(wxWindow* parent, wxDirDialog(wxWindow* parent,
const wxString& message = wxPyDirSelectorPromptStr, const wxString& message = wxPyDirSelectorPromptStr,
const wxString& defaultPath = wxPyEmptyString, const wxString& defaultPath = wxPyEmptyString,
long style = 0, long style = wxDD_DEFAULT_STYLE,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
const wxString& name = wxPyDirDialogNameStr), const wxString& name = wxPyDirDialogNameStr),
@@ -168,6 +180,25 @@ public:
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
enum {
// These will dissappear in 2.8
wxOPEN,
wxSAVE,
wxHIDE_READONLY,
wxOVERWRITE_PROMPT,
wxFILE_MUST_EXIST,
wxMULTIPLE,
wxCHANGE_DIR,
wxFD_OPEN,
wxFD_SAVE,
wxFD_OVERWRITE_PROMPT,
wxFD_FILE_MUST_EXIST,
wxFD_MULTIPLE,
wxFD_CHANGE_DIR,
wxFD_DEFAULT_STYLE,
};
DocStr(wxFileDialog, DocStr(wxFileDialog,
"wx.FileDialog allows the user to select one or more files from the "wx.FileDialog allows the user to select one or more files from the
filesystem.", " filesystem.", "
@@ -191,24 +222,21 @@ types of file with a description for each, such as::
Window Styles Window Styles
-------------- --------------
=================== ========================================== ====================== ==========================================
wx.OPEN This is an open dialog. wx.FD_OPEN This is an open dialog.
wx.SAVE This is a save dialog. wx.FD_SAVE This is a save dialog.
wx.HIDE_READONLY For open dialog only: hide the checkbox wx.FD_OVERWRITE_PROMPT For save dialog only: prompt for a confirmation
allowing to open the file in read-only mode. if a file will be overwritten.
wx.OVERWRITE_PROMPT For save dialog only: prompt for a confirmation wx.FD_MULTIPLE For open dialog only: allows selecting multiple
if a file will be overwritten. files.
wx.MULTIPLE For open dialog only: allows selecting multiple wx.FD_CHANGE_DIR Change the current working directory to the
files. directory where the file(s) chosen by the user
are.
wx.CHANGE_DIR Change the current working directory to the ====================== ==========================================
directory where the file(s) chosen by the user
are.
=================== ==========================================
"); ");
@@ -225,7 +253,7 @@ public:
const wxString& defaultDir = wxPyEmptyString, const wxString& defaultDir = wxPyEmptyString,
const wxString& defaultFile = wxPyEmptyString, const wxString& defaultFile = wxPyEmptyString,
const wxString& wildcard = wxPyFileSelectorDefaultWildcardStr, const wxString& wildcard = wxPyFileSelectorDefaultWildcardStr,
long style = 0, long style = wxFD_DEFAULT_STYLE,
const wxPoint& pos = wxDefaultPosition), const wxPoint& pos = wxDefaultPosition),
"Constructor. Use ShowModal method to show the dialog.", ""); "Constructor. Use ShowModal method to show the dialog.", "");

View File

@@ -679,14 +679,6 @@ enum {
wxID_HIGHEST, wxID_HIGHEST,
wxOPEN,
wxSAVE,
wxHIDE_READONLY,
wxOVERWRITE_PROMPT,
wxFILE_MUST_EXIST,
wxMULTIPLE,
wxCHANGE_DIR,
wxACCEL_ALT, wxACCEL_ALT,
wxACCEL_CTRL, wxACCEL_CTRL,
wxACCEL_SHIFT, wxACCEL_SHIFT,
@@ -701,10 +693,6 @@ enum {
wxPD_SMOOTH, wxPD_SMOOTH,
wxPD_CAN_SKIP, wxPD_CAN_SKIP,
wxDD_NEW_DIR_BUTTON,
wxDD_DEFAULT_STYLE,
wxDD_CHANGE_DIR,
wxMENU_TEAROFF, wxMENU_TEAROFF,
wxMB_DOCKABLE, wxMB_DOCKABLE,
wxNO_FULL_REPAINT_ON_RESIZE, wxNO_FULL_REPAINT_ON_RESIZE,

View File

@@ -86,7 +86,8 @@ public:
// Try to expand as much of the given path as possible. // Try to expand as much of the given path as possible.
virtual bool ExpandPath(const wxString& path); virtual bool ExpandPath(const wxString& path);
// collapse the path
virtual bool CollapsePath(const wxString& path);
virtual inline wxString GetDefaultPath() const; virtual inline wxString GetDefaultPath() const;
virtual void SetDefaultPath(const wxString& path); virtual void SetDefaultPath(const wxString& path);

View File

@@ -142,7 +142,6 @@ wxEventType wxNewEventType();
%constant wxEventType wxEVT_END_SESSION; %constant wxEventType wxEVT_END_SESSION;
%constant wxEventType wxEVT_QUERY_END_SESSION; %constant wxEventType wxEVT_QUERY_END_SESSION;
%constant wxEventType wxEVT_ACTIVATE_APP; %constant wxEventType wxEVT_ACTIVATE_APP;
%constant wxEventType wxEVT_POWER;
%constant wxEventType wxEVT_ACTIVATE; %constant wxEventType wxEVT_ACTIVATE;
%constant wxEventType wxEVT_CREATE; %constant wxEventType wxEVT_CREATE;
%constant wxEventType wxEVT_DESTROY; %constant wxEventType wxEVT_DESTROY;
@@ -2552,3 +2551,4 @@ internally.", "");
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
//---------------------------------------------------------------------------

View File

@@ -250,10 +250,18 @@ public:
void SetStyle(wxFontStyle style); void SetStyle(wxFontStyle style);
void SetWeight(wxFontWeight weight); void SetWeight(wxFontWeight weight);
void SetUnderlined(bool underlined); void SetUnderlined(bool underlined);
void SetFaceName(wxString facename); bool SetFaceName(wxString facename);
void SetFamily(wxFontFamily family); void SetFamily(wxFontFamily family);
void SetEncoding(wxFontEncoding encoding); void SetEncoding(wxFontEncoding encoding);
// TODO:
// // sets the first facename in the given array which is found
// // to be valid. If no valid facename is given, sets the
// // first valid facename returned by wxFontEnumerator::GetFacenames().
// // Does not return a bool since it cannot fail.
// void SetFaceName(const wxArrayString &facenames);
// it is important to be able to serialize wxNativeFontInfo objects to be // it is important to be able to serialize wxNativeFontInfo objects to be
// able to store them (in config file, for example) // able to store them (in config file, for example)
bool FromString(const wxString& s); bool FromString(const wxString& s);
@@ -734,7 +742,7 @@ size is found using a binary search.", "");
"Sets the font weight.", ""); "Sets the font weight.", "");
DocDeclStr( DocDeclStr(
virtual void , SetFaceName( const wxString& faceName ), virtual bool , SetFaceName( const wxString& faceName ),
"Sets the facename for the font. The facename, which should be a valid "Sets the facename for the font. The facename, which should be a valid
font installed on the end-user's system. font installed on the end-user's system.
@@ -758,13 +766,13 @@ then for a font belonging to the same family.", "");
DocDeclStrName( DocDeclStrName(
void , SetNativeFontInfo(const wxString& info), bool , SetNativeFontInfo(const wxString& info),
"Set the font's attributes from string representation of a "Set the font's attributes from string representation of a
`wx.NativeFontInfo` object.", "", `wx.NativeFontInfo` object.", "",
SetNativeFontInfoFromString); SetNativeFontInfoFromString);
DocDeclStr( DocDeclStr(
void , SetNativeFontInfoUserDesc(const wxString& info), bool , SetNativeFontInfoUserDesc(const wxString& info),
"Set the font's attributes from a string formerly returned from "Set the font's attributes from a string formerly returned from
`GetNativeFontInfoDesc`.", ""); `GetNativeFontInfoDesc`.", "");
@@ -838,33 +846,31 @@ public:
bool EnumerateEncodings(const wxString& facename = wxPyEmptyString); bool EnumerateEncodings(const wxString& facename = wxPyEmptyString);
//wxArrayString* GetEncodings();
//wxArrayString* GetFacenames();
%extend { %extend {
PyObject* GetEncodings() { static PyObject* GetEncodings() {
PyObject* ret; PyObject* ret;
wxArrayString* arr = self->GetEncodings(); wxArrayString arr = wxFontEnumerator::GetEncodings();
wxPyBlock_t blocked = wxPyBeginBlockThreads(); wxPyBlock_t blocked = wxPyBeginBlockThreads();
if (arr) ret = wxArrayString2PyList_helper(arr);
ret = wxArrayString2PyList_helper(*arr);
else
ret = PyList_New(0);
wxPyEndBlockThreads(blocked); wxPyEndBlockThreads(blocked);
return ret; return ret;
} }
PyObject* GetFacenames() { static PyObject* GetFacenames() {
PyObject* ret; PyObject* ret;
wxArrayString* arr = self->GetFacenames(); wxArrayString arr = wxFontEnumerator::GetFacenames();
wxPyBlock_t blocked = wxPyBeginBlockThreads(); wxPyBlock_t blocked = wxPyBeginBlockThreads();
if (arr) ret = wxArrayString2PyList_helper(arr);
ret = wxArrayString2PyList_helper(*arr);
else
ret = PyList_New(0);
wxPyEndBlockThreads(blocked); wxPyEndBlockThreads(blocked);
return ret; return ret;
} }
} }
DocDeclStr(
static bool , IsValidFacename(const wxString &str),
"Convenience function that returns true if the given face name exist in
the user's system", "");
}; };

View File

@@ -427,40 +427,5 @@ MustHaveApp(wxThread);
} }
%} %}
//---------------------------------------------------------------------------
// enum wxPowerType
// {
// wxPOWER_SOCKET,
// wxPOWER_BATTERY,
// wxPOWER_UNKNOWN
// };
// DocDeclStr(
// wxPowerType , wxGetPowerType(),
// "Returns the type of power source as one of wx.POWER_SOCKET,
// wx.POWER_BATTERY or wx.POWER_UNKNOWN. wx.POWER_UNKNOWN is also the
// default on platforms where this feature is not implemented.", "");
// enum wxBatteryState
// {
// wxBATTERY_NORMAL_STATE, // system is fully usable
// wxBATTERY_LOW_STATE, // start to worry
// wxBATTERY_CRITICAL_STATE, // save quickly
// wxBATTERY_SHUTDOWN_STATE, // too late
// wxBATTERY_UNKNOWN_STATE
// };
// DocDeclStr(
// wxBatteryState , wxGetBatteryState(),
// "Returns battery state as one of wx.BATTERY_NORMAL_STATE,
// wx.BATTERY_LOW_STATE}, wx.BATTERY_CRITICAL_STATE,
// wx.BATTERY_SHUTDOWN_STATE or wx.BATTERY_UNKNOWN_STATE.
// wx.BATTERY_UNKNOWN_STATE is also the default on platforms where this
// feature is not implemented.", "");
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

118
wxPython/src/_hyperlink.i Normal file
View File

@@ -0,0 +1,118 @@
/////////////////////////////////////////////////////////////////////////////
// Name: _hyperlink.i
// Purpose: SWIG interface defs for wxHyperlinkCtrl
//
// Author: Robin Dunn
//
// Created: 28-May-2006
// RCS-ID: $Id$
// Copyright: (c) 2006 by Total Control Software
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
// Not a %module
//---------------------------------------------------------------------------
%{
#include <wx/hyperlink.h>
%}
MAKE_CONST_WXSTRING(HyperlinkCtrlNameStr);
enum {
wxHL_CONTEXTMENU,
wxHL_DEFAULT_STYLE
};
//---------------------------------------------------------------------------
%newgroup
MustHaveApp(wxHyperlinkCtrl);
DocStr( wxHyperlinkCtrl,
"A static text control that emulates a hyperlink. The link is displayed
in an appropriate text style, derived from the control's normal font.
When the mouse rolls over the link, the cursor changes to a hand and
the link's color changes to the active color.
Clicking on the link does not launch a web browser; instead, a
wx.HyperlinkEvent is fired. Use the wx.EVT_HYPERLINK to catch link
events.
", "");
class wxHyperlinkCtrl : public wxControl
{
public:
%pythonAppend wxHyperlinkCtrl "self._setOORInfo(self)"
%pythonAppend wxHyperlinkCtrl() ""
// Constructor.
wxHyperlinkCtrl(wxWindow *parent,
wxWindowID id,
const wxString& label, const wxString& url,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxHL_DEFAULT_STYLE,
const wxString& name = wxPyHyperlinkCtrlNameStr);
%RenameCtor(PreHyperlinkCtrl, wxHyperlinkCtrl());
// Creation function (for two-step construction).
bool Create(wxWindow *parent,
wxWindowID id,
const wxString& label, const wxString& url,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxHL_DEFAULT_STYLE,
const wxString& name = wxPyHyperlinkCtrlNameStr);
// get/set
wxColour GetHoverColour() const;
void SetHoverColour(const wxColour &colour);
wxColour GetNormalColour() const;
void SetNormalColour(const wxColour &colour);
wxColour GetVisitedColour() const;
void SetVisitedColour(const wxColour &colour);
wxString GetURL() const;
void SetURL (const wxString &url);
void SetVisited(bool visited = true);
bool GetVisited() const;
};
%constant wxEventType wxEVT_COMMAND_HYPERLINK;
//
// An event fired when the user clicks on the label in a hyperlink control.
// See HyperlinkControl for details.
//
class wxHyperlinkEvent : public wxCommandEvent
{
public:
wxHyperlinkEvent(wxObject *generator, wxWindowID id, const wxString& url);
// Returns the URL associated with the hyperlink control
// that the user clicked on.
wxString GetURL() const;
void SetURL(const wxString &url);
};
%pythoncode {
EVT_HYPERLINK = wx.PyEventBinder( wxEVT_COMMAND_HYPERLINK, 1 )
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------

View File

@@ -84,6 +84,9 @@ enum {
wxLIST_HITTEST_TOLEFT, wxLIST_HITTEST_TOLEFT,
wxLIST_HITTEST_TORIGHT, wxLIST_HITTEST_TORIGHT,
wxLIST_HITTEST_ONITEM, wxLIST_HITTEST_ONITEM,
// GetSubItemRect constants
wxLIST_GETSUBITEMRECT_WHOLEITEM,
}; };
@@ -544,6 +547,13 @@ public:
self->GetItemRect(item, rect, code); self->GetItemRect(item, rect, code);
return rect; return rect;
} }
// MSW only so far...
// wxRect GetSubItemRect(long item, long subItem, int code = wxLIST_RECT_BOUNDS) {
// wxRect rect;
// self->GetSubItemRect(item, subItem, rect, code);
// return rect;
// }
} }
@@ -660,6 +670,15 @@ public:
"Determines which item (if any) is at the specified point, giving "Determines which item (if any) is at the specified point, giving
details in the second return value (see wx.LIST_HITTEST flags.)", ""); details in the second return value (see wx.LIST_HITTEST flags.)", "");
DocDeclAStrName(
long, HitTest(const wxPoint& point, int& OUTPUT, long* OUTPUT),
"HitTestSubItem(Point point) -> (item, where, subItem)",
"Determines which item (if any) is at the specified point, giving details in
the second return value (see wx.LIST_HITTEST flags) and also the subItem, if
any.", "",
HitTestSubItem);
// Inserts an item, returning the index of the new item if successful, // Inserts an item, returning the index of the new item if successful,
// -1 otherwise. // -1 otherwise.
long InsertItem(wxListItem& info); long InsertItem(wxListItem& info);

108
wxPython/src/_power.i Normal file
View File

@@ -0,0 +1,108 @@
/////////////////////////////////////////////////////////////////////////////
// Name: _power.i
// Purpose: SWIG interface for wx poser events and functions
//
// Author: Robin Dunn
//
// Created: 28-May-2006
// RCS-ID: $Id$
// Copyright: (c) 2006 by Total Control Software
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
// Not a %module
//---------------------------------------------------------------------------
%newgroup
%{
#include <wx/power.h>
%}
%{
#ifndef wxHAS_POWER_EVENTS
// Dummy class and other definitions for platforms that don't have them
class wxPowerEvent : public wxEvent
{
public:
wxPowerEvent(wxEventType evtType) : wxEvent(wxID_NONE, evtType) {}
void Veto() {}
bool IsVetoed() const { return false; }
virtual wxEvent *Clone() const { return new wxPowerEvent(*this); }
};
enum {
wxEVT_POWER_SUSPENDING,
wxEVT_POWER_SUSPENDED,
wxEVT_POWER_SUSPEND_CANCEL,
wxEVT_POWER_RESUME,
};
wxPowerType wxGetPowerType() { return wxPOWER_UNKNOWN; }
wxBatteryState wxGetBatteryState() { return wxBATTERY_UNKNOWN_STATE; }
#endif
%}
enum wxPowerType
{
wxPOWER_SOCKET,
wxPOWER_BATTERY,
wxPOWER_UNKNOWN
};
enum wxBatteryState
{
wxBATTERY_NORMAL_STATE, // system is fully usable
wxBATTERY_LOW_STATE, // start to worry
wxBATTERY_CRITICAL_STATE, // save quickly
wxBATTERY_SHUTDOWN_STATE, // too late
wxBATTERY_UNKNOWN_STATE
};
DocStr(wxPowerEvent,
"wx.PowerEvent is generated when the system online status changes.
Currently this is only implemented for Windows.",
"");
class wxPowerEvent : public wxEvent
{
public:
wxPowerEvent(wxEventType evtType);
// Veto the operation (only makes sense with EVT_POWER_SUSPENDING)
void Veto();
bool IsVetoed() const;
};
%constant wxEventType wxEVT_POWER_SUSPENDING;
%constant wxEventType wxEVT_POWER_SUSPENDED;
%constant wxEventType wxEVT_POWER_SUSPEND_CANCEL;
%constant wxEventType wxEVT_POWER_RESUME;
%pythoncode {
EVT_POWER_SUSPENDING = wx.PyEventBinder( wxEVT_POWER_SUSPENDING , 1 )
EVT_POWER_SUSPENDED = wx.PyEventBinder( wxEVT_POWER_SUSPENDED , 1 )
EVT_POWER_SUSPEND_CANCEL = wx.PyEventBinder( wxEVT_POWER_SUSPEND_CANCEL , 1 )
EVT_POWER_RESUME = wx.PyEventBinder( wxEVT_POWER_RESUME , 1 )
}
DocDeclStr(
wxPowerType , wxGetPowerType(),
"return the current system power state: online or offline", "");
DocDeclStr(
wxBatteryState , wxGetBatteryState(),
"return approximate battery state", "");
//---------------------------------------------------------------------------

View File

@@ -43,6 +43,7 @@ enum {
wxTB_NOALIGN, wxTB_NOALIGN,
wxTB_HORZ_LAYOUT, wxTB_HORZ_LAYOUT,
wxTB_HORZ_TEXT, wxTB_HORZ_TEXT,
wxTB_NO_TOOLTIPS,
}; };

View File

@@ -982,6 +982,15 @@ deletion functions so should not be required by the application
programmer.", ""); programmer.", "");
DocStr(SetDoubleBuffered,
"Currently wxGTK2 only.", "");
#ifdef __WXGTK__
void SetDoubleBuffered(bool on);
#else
%extend {
void SetDoubleBuffered(bool on) {}
}
#endif
// looking for windows // looking for windows

View File

@@ -59,7 +59,7 @@ MAKE_CONST_WXSTRING_NOSWIG(ControlNameStr);
%include _cshelp.i %include _cshelp.i
%include _dragimg.i %include _dragimg.i
%include _datectrl.i %include _datectrl.i
%include _hyperlink.i
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View File

@@ -1146,10 +1146,8 @@ public:
const wxString& normal_face = wxPyEmptyString, const wxString& normal_face = wxPyEmptyString,
const wxString& fixed_face = wxPyEmptyString); const wxString& fixed_face = wxPyEmptyString);
int Render(int x, int y, int from = 0, int dont_render = false, int maxHeight = INT_MAX, int Render(int x, int y, wxArrayInt& known_pagebreaks, int from = 0,
//int *known_pagebreaks = NULL, int number_of_pages = 0 int dont_render = FALSE, int to = INT_MAX);
int* choices=NULL, int LCOUNT = 0
);
int GetTotalHeight(); int GetTotalHeight();
// returns total height of the html document // returns total height of the html document
// (compare Render's return value with this) // (compare Render's return value with this)

View File

@@ -48,5 +48,6 @@ MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
%include _clipbrd.i %include _clipbrd.i
%include _display.i %include _display.i
%include _stdpaths.i %include _stdpaths.i
%include _power.i
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------