New wxHtml stuff, including a TagHandler for placing wxPython widgets
on the html page. Some other tweaks and fixes git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3691 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
13
utils/wxPython/modules/html/_extras.py
Normal file
13
utils/wxPython/modules/html/_extras.py
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
# Stuff these names into the wx namespace so wxPyConstructObject can find them
|
||||
import wx
|
||||
wx.wxHtmlTagPtr = wxHtmlTag
|
||||
wx.wxHtmlParserPtr = wxHtmlParserPtr
|
||||
wx.wxHtmlWinParserPtr = wxHtmlWinParserPtr
|
||||
wx.wxHtmlTagHandlerPtr = wxHtmlTagHandlerPtr
|
||||
wx.wxHtmlWinTagHandlerPtr = wxHtmlWinTagHandlerPtr
|
||||
wx.wxHtmlCellPtr = wxHtmlCellPtr
|
||||
wx.wxHtmlContainerCellPtr = wxHtmlContainerCellPtr
|
||||
wx.wxHtmlWidgetCellPtr = wxHtmlWidgetCellPtr
|
||||
wx.HtmlHistoryItemPtr = HtmlHistoryItemPtr
|
||||
wx.wxHtmlWindowPtr = wxHtmlWindowPtr
|
@@ -12,3 +12,4 @@ OTHERCFLAGS = "-I%s/src/html" % (WXDIR,)
|
||||
|
||||
# There are no platform differences so we don't need separate code directories
|
||||
GENCODEDIR='.'
|
||||
SWIGTOOLKITFLAG=''
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -52,6 +52,7 @@ wxSize wxPyDefaultSize(wxDefaultSize);
|
||||
|
||||
%{
|
||||
|
||||
#if 0
|
||||
static PyObject* mod_dict = NULL; // will be set by init
|
||||
|
||||
#include <wx/html/mod_templ.h>
|
||||
@@ -129,15 +130,44 @@ TAGS_MODULE_BEGIN(PythonTag)
|
||||
TAGS_MODULE_END(PythonTag)
|
||||
|
||||
// Note: see also the init function where we add the module!
|
||||
|
||||
#endif
|
||||
%}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
enum {
|
||||
HTML_ALIGN_LEFT,
|
||||
HTML_ALIGN_CENTER,
|
||||
HTML_ALIGN_RIGHT,
|
||||
HTML_ALIGN_BOTTOM,
|
||||
HTML_ALIGN_TOP,
|
||||
|
||||
HTML_CLR_FOREGROUND,
|
||||
HTML_CLR_BACKGROUND,
|
||||
|
||||
HTML_UNITS_PIXELS,
|
||||
HTML_UNITS_PERCENT,
|
||||
|
||||
HTML_INDENT_LEFT,
|
||||
HTML_INDENT_RIGHT,
|
||||
HTML_INDENT_TOP,
|
||||
HTML_INDENT_BOTTOM,
|
||||
|
||||
HTML_INDENT_HORIZONTAL,
|
||||
HTML_INDENT_VERTICAL,
|
||||
HTML_INDENT_ALL,
|
||||
|
||||
HTML_COND_ISANCHOR,
|
||||
HTML_COND_ISIMAGEMAP,
|
||||
HTML_COND_USER,
|
||||
};
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class wxHtmlTag {
|
||||
public:
|
||||
// Never need to create a new tag...
|
||||
// Never need to create a new tag from Python...
|
||||
//wxHtmlTag(const wxString& source, int pos, int end_pos, wxHtmlTagsCache* cache);
|
||||
|
||||
wxString GetName();
|
||||
@@ -236,7 +266,6 @@ public:
|
||||
|
||||
IMP_PYCALLBACK_STRING__pure(wxPyHtmlTagHandler, wxHtmlTagHandler, GetSupportedTags);
|
||||
IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlTagHandler, wxHtmlTagHandler, HandleTag);
|
||||
|
||||
%}
|
||||
|
||||
|
||||
@@ -272,7 +301,6 @@ public:
|
||||
|
||||
IMP_PYCALLBACK_STRING__pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, GetSupportedTags);
|
||||
IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, HandleTag);
|
||||
|
||||
%}
|
||||
|
||||
|
||||
@@ -315,9 +343,11 @@ public:
|
||||
// Wave our magic wand... (if it works it's a miracle! ;-)
|
||||
|
||||
// First, make a new instance of the tag handler
|
||||
bool doSave = wxPyRestoreThread();
|
||||
PyObject* arg = Py_BuildValue("()");
|
||||
PyObject* obj = PyInstance_New(m_tagHandlerClass, arg, NULL);
|
||||
Py_DECREF(arg);
|
||||
wxPySaveThread(doSave);
|
||||
|
||||
// now figure out where it's C++ object is...
|
||||
wxPyHtmlWinTagHandler* thPtr;
|
||||
@@ -348,6 +378,63 @@ private:
|
||||
}
|
||||
%}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class wxHtmlCell {
|
||||
public:
|
||||
wxHtmlCell();
|
||||
|
||||
void SetParent(wxHtmlContainerCell *p);
|
||||
wxHtmlContainerCell* GetParent();
|
||||
int GetPosX();
|
||||
int GetPosY();
|
||||
int GetWidth();
|
||||
int GetHeight();
|
||||
int GetDescent();
|
||||
wxString GetLink(int x = 0, int y = 0);
|
||||
wxHtmlCell* GetNext();
|
||||
void SetPos(int x, int y);
|
||||
void SetLink(const wxString& link);
|
||||
void SetNext(wxHtmlCell *cell);
|
||||
void Layout(int w);
|
||||
void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2);
|
||||
void DrawInvisible(wxDC& dc, int x, int y);
|
||||
const wxHtmlCell* Find(int condition, const void* param);
|
||||
};
|
||||
|
||||
|
||||
class wxHtmlContainerCell : public wxHtmlCell {
|
||||
public:
|
||||
wxHtmlContainerCell(wxHtmlContainerCell *parent);
|
||||
|
||||
void InsertCell(wxHtmlCell *cell);
|
||||
void SetAlignHor(int al);
|
||||
int GetAlignHor();
|
||||
void SetAlignVer(int al);
|
||||
int GetAlignVer();
|
||||
void SetIndent(int i, int what, int units = HTML_UNITS_PIXELS);
|
||||
int GetIndent(int ind);
|
||||
int GetIndentUnits(int ind);
|
||||
void SetAlign(const wxHtmlTag& tag);
|
||||
void SetWidthFloat(int w, int units);
|
||||
%name(SetWidthFloatFromTag)void SetWidthFloat(const wxHtmlTag& tag);
|
||||
void SetMinHeight(int h, int align = HTML_ALIGN_TOP);
|
||||
int GetMaxLineWidth();
|
||||
void SetBackgroundColour(const wxColour& clr);
|
||||
void SetBorder(const wxColour& clr1, const wxColour& clr2);
|
||||
wxHtmlCell* GetFirstCell();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class wxHtmlWidgetCell : public wxHtmlCell {
|
||||
public:
|
||||
wxHtmlWidgetCell(wxWindow* wnd, int w = 0);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -461,6 +548,8 @@ public:
|
||||
// Returns pointer to conteiners/cells structure.
|
||||
// It should be used ONLY when printing
|
||||
|
||||
wxHtmlWinParser* GetParser();
|
||||
|
||||
|
||||
void base_OnLinkClicked(const char* link);
|
||||
// called when users clicked on hypertext link. Default behavior is to
|
||||
@@ -486,18 +575,22 @@ public:
|
||||
|
||||
%init %{
|
||||
|
||||
#if 0
|
||||
/* This is a bit cheesy. SWIG happens to call the dictionary d...
|
||||
* I save it here, 'cause I don't know how to get it back later! */
|
||||
mod_dict = d;
|
||||
#endif
|
||||
|
||||
//inithtmlhelpc();
|
||||
|
||||
wxClassInfo::CleanUpClasses();
|
||||
wxClassInfo::InitializeClasses();
|
||||
|
||||
#if 0
|
||||
/* specifically add our python tag handler; it doesn't seem to
|
||||
* happen by itself... */
|
||||
wxHtmlWinParser::AddModule(new HTML_ModulePythonTag());
|
||||
#endif
|
||||
|
||||
// Until wxFileSystem is wrapped...
|
||||
#if wxUSE_FS_ZIP
|
||||
@@ -505,4 +598,11 @@ public:
|
||||
#endif
|
||||
%}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// And this gets appended to the shadow class file.
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
%pragma(python) include="_extras.py";
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
@@ -135,12 +135,15 @@ class wxHtmlWinParserPtr(wxHtmlParserPtr):
|
||||
return val
|
||||
def GetContainer(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlWinParser_GetContainer,(self,) + _args, _kwargs)
|
||||
if val: val = wxHtmlContainerCellPtr(val)
|
||||
return val
|
||||
def OpenContainer(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlWinParser_OpenContainer,(self,) + _args, _kwargs)
|
||||
if val: val = wxHtmlContainerCellPtr(val)
|
||||
return val
|
||||
def CloseContainer(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlWinParser_CloseContainer,(self,) + _args, _kwargs)
|
||||
if val: val = wxHtmlContainerCellPtr(val)
|
||||
return val
|
||||
def GetFontSize(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlWinParser_GetFontSize,(self,) + _args, _kwargs)
|
||||
@@ -268,6 +271,148 @@ class wxHtmlWinTagHandler(wxHtmlWinTagHandlerPtr):
|
||||
|
||||
|
||||
|
||||
class wxHtmlCellPtr :
|
||||
def __init__(self,this):
|
||||
self.this = this
|
||||
self.thisown = 0
|
||||
def SetParent(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlCell_SetParent,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def GetParent(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlCell_GetParent,(self,) + _args, _kwargs)
|
||||
if val: val = wxHtmlContainerCellPtr(val)
|
||||
return val
|
||||
def GetPosX(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlCell_GetPosX,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def GetPosY(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlCell_GetPosY,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def GetWidth(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlCell_GetWidth,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def GetHeight(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlCell_GetHeight,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def GetDescent(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlCell_GetDescent,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def GetLink(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlCell_GetLink,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def GetNext(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlCell_GetNext,(self,) + _args, _kwargs)
|
||||
if val: val = wxHtmlCellPtr(val)
|
||||
return val
|
||||
def SetPos(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlCell_SetPos,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def SetLink(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlCell_SetLink,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def SetNext(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlCell_SetNext,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def Layout(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlCell_Layout,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def Draw(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlCell_Draw,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def DrawInvisible(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlCell_DrawInvisible,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def Find(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlCell_Find,(self,) + _args, _kwargs)
|
||||
if val: val = wxHtmlCellPtr(val)
|
||||
return val
|
||||
def __repr__(self):
|
||||
return "<C wxHtmlCell instance at %s>" % (self.this,)
|
||||
class wxHtmlCell(wxHtmlCellPtr):
|
||||
def __init__(self,*_args,**_kwargs):
|
||||
self.this = apply(htmlc.new_wxHtmlCell,_args,_kwargs)
|
||||
self.thisown = 1
|
||||
|
||||
|
||||
|
||||
|
||||
class wxHtmlContainerCellPtr(wxHtmlCellPtr):
|
||||
def __init__(self,this):
|
||||
self.this = this
|
||||
self.thisown = 0
|
||||
def InsertCell(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlContainerCell_InsertCell,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def SetAlignHor(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlContainerCell_SetAlignHor,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def GetAlignHor(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlContainerCell_GetAlignHor,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def SetAlignVer(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlContainerCell_SetAlignVer,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def GetAlignVer(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlContainerCell_GetAlignVer,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def SetIndent(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlContainerCell_SetIndent,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def GetIndent(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlContainerCell_GetIndent,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def GetIndentUnits(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlContainerCell_GetIndentUnits,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def SetAlign(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlContainerCell_SetAlign,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def SetWidthFloat(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlContainerCell_SetWidthFloat,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def SetWidthFloatFromTag(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlContainerCell_SetWidthFloatFromTag,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def SetMinHeight(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlContainerCell_SetMinHeight,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def GetMaxLineWidth(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlContainerCell_GetMaxLineWidth,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def SetBackgroundColour(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlContainerCell_SetBackgroundColour,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def SetBorder(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlContainerCell_SetBorder,(self,) + _args, _kwargs)
|
||||
return val
|
||||
def GetFirstCell(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlContainerCell_GetFirstCell,(self,) + _args, _kwargs)
|
||||
if val: val = wxHtmlCellPtr(val)
|
||||
return val
|
||||
def __repr__(self):
|
||||
return "<C wxHtmlContainerCell instance at %s>" % (self.this,)
|
||||
class wxHtmlContainerCell(wxHtmlContainerCellPtr):
|
||||
def __init__(self,*_args,**_kwargs):
|
||||
self.this = apply(htmlc.new_wxHtmlContainerCell,_args,_kwargs)
|
||||
self.thisown = 1
|
||||
|
||||
|
||||
|
||||
|
||||
class wxHtmlWidgetCellPtr(wxHtmlCellPtr):
|
||||
def __init__(self,this):
|
||||
self.this = this
|
||||
self.thisown = 0
|
||||
def __repr__(self):
|
||||
return "<C wxHtmlWidgetCell instance at %s>" % (self.this,)
|
||||
class wxHtmlWidgetCell(wxHtmlWidgetCellPtr):
|
||||
def __init__(self,*_args,**_kwargs):
|
||||
self.this = apply(htmlc.new_wxHtmlWidgetCell,_args,_kwargs)
|
||||
self.thisown = 1
|
||||
|
||||
|
||||
|
||||
|
||||
class HtmlHistoryItemPtr :
|
||||
def __init__(self,this):
|
||||
self.this = this
|
||||
@@ -346,6 +491,11 @@ class wxHtmlWindowPtr(wxScrolledWindowPtr):
|
||||
return val
|
||||
def GetInternalRepresentation(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlWindow_GetInternalRepresentation,(self,) + _args, _kwargs)
|
||||
if val: val = wxHtmlContainerCellPtr(val)
|
||||
return val
|
||||
def GetParser(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlWindow_GetParser,(self,) + _args, _kwargs)
|
||||
if val: val = wxHtmlWinParserPtr(val)
|
||||
return val
|
||||
def base_OnLinkClicked(self, *_args, **_kwargs):
|
||||
val = apply(htmlc.wxHtmlWindow_base_OnLinkClicked,(self,) + _args, _kwargs)
|
||||
@@ -375,3 +525,39 @@ wxHtmlWindow_AddFilter = htmlc.wxHtmlWindow_AddFilter
|
||||
|
||||
#-------------- VARIABLE WRAPPERS ------------------
|
||||
|
||||
HTML_ALIGN_LEFT = htmlc.HTML_ALIGN_LEFT
|
||||
HTML_ALIGN_CENTER = htmlc.HTML_ALIGN_CENTER
|
||||
HTML_ALIGN_RIGHT = htmlc.HTML_ALIGN_RIGHT
|
||||
HTML_ALIGN_BOTTOM = htmlc.HTML_ALIGN_BOTTOM
|
||||
HTML_ALIGN_TOP = htmlc.HTML_ALIGN_TOP
|
||||
HTML_CLR_FOREGROUND = htmlc.HTML_CLR_FOREGROUND
|
||||
HTML_CLR_BACKGROUND = htmlc.HTML_CLR_BACKGROUND
|
||||
HTML_UNITS_PIXELS = htmlc.HTML_UNITS_PIXELS
|
||||
HTML_UNITS_PERCENT = htmlc.HTML_UNITS_PERCENT
|
||||
HTML_INDENT_LEFT = htmlc.HTML_INDENT_LEFT
|
||||
HTML_INDENT_RIGHT = htmlc.HTML_INDENT_RIGHT
|
||||
HTML_INDENT_TOP = htmlc.HTML_INDENT_TOP
|
||||
HTML_INDENT_BOTTOM = htmlc.HTML_INDENT_BOTTOM
|
||||
HTML_INDENT_HORIZONTAL = htmlc.HTML_INDENT_HORIZONTAL
|
||||
HTML_INDENT_VERTICAL = htmlc.HTML_INDENT_VERTICAL
|
||||
HTML_INDENT_ALL = htmlc.HTML_INDENT_ALL
|
||||
HTML_COND_ISANCHOR = htmlc.HTML_COND_ISANCHOR
|
||||
HTML_COND_ISIMAGEMAP = htmlc.HTML_COND_ISIMAGEMAP
|
||||
HTML_COND_USER = htmlc.HTML_COND_USER
|
||||
|
||||
|
||||
#-------------- USER INCLUDE -----------------------
|
||||
|
||||
|
||||
# Stuff these names into the wx namespace so wxPyConstructObject can find them
|
||||
import wx
|
||||
wx.wxHtmlTagPtr = wxHtmlTag
|
||||
wx.wxHtmlParserPtr = wxHtmlParserPtr
|
||||
wx.wxHtmlWinParserPtr = wxHtmlWinParserPtr
|
||||
wx.wxHtmlTagHandlerPtr = wxHtmlTagHandlerPtr
|
||||
wx.wxHtmlWinTagHandlerPtr = wxHtmlWinTagHandlerPtr
|
||||
wx.wxHtmlCellPtr = wxHtmlCellPtr
|
||||
wx.wxHtmlContainerCellPtr = wxHtmlContainerCellPtr
|
||||
wx.wxHtmlWidgetCellPtr = wxHtmlWidgetCellPtr
|
||||
wx.HtmlHistoryItemPtr = HtmlHistoryItemPtr
|
||||
wx.wxHtmlWindowPtr = wxHtmlWindowPtr
|
||||
|
Reference in New Issue
Block a user