%{
#include "helpers.h"
#include <wx/html/htmlwin.h>
+#include <wx/html/htmprint.h>
#include <wx/image.h>
#include <wx/fs_zip.h>
#include <wx/fs_inet.h>
#include <wx/wfstream.h>
+
+#include "printfw.h"
%}
//---------------------------------------------------------------------------
%extern events.i
%extern controls.i
%extern controls2.i
+%extern printfw.i
%extern utils.i
%}
%pragma(python) code = "import wx"
-%pragma(python) code = "widget = htmlc"
-
-%{
-
-#if 0
-static PyObject* mod_dict = NULL; // will be set by init
-
-#include <wx/html/mod_templ.h>
-
-TAG_HANDLER_BEGIN(PYTHONTAG, "PYTHON")
- TAG_HANDLER_PROC(tag)
- {
- wxWindow *wnd;
- wxString errmsg;
- char pbuf[256];
-
- int fl = 0;
-
- bool doSave = wxPyRestoreThread();
- while (1) {
- if (tag.HasParam("FLOAT"))
- tag.ScanParam("FLOAT", "%i", &fl);
- PyObject* pyfunc = PyDict_GetItemString(mod_dict, "WidgetStarter");
- if (pyfunc == NULL) {
- errmsg = "Could not find object WidgetStarter";
- break;
- }
- if (! PyCallable_Check(pyfunc)) {
- errmsg = "WidgetStarter does not appear to be callable";
- break;
- }
- SWIG_MakePtr(pbuf, m_WParser->GetWindow(), "_wxPyHtmlWindow_p");
- PyObject* arglist = Py_BuildValue("(s,s)", pbuf,
- (const char*)tag.GetAllParams());
- if (! arglist) {
- errmsg = "Failed making argument list";
- break;
- }
- PyObject* ret = PyEval_CallObject(pyfunc, arglist);
- Py_DECREF(arglist);
- if (ret == NULL) {
- errmsg = "An error occured while calling WidgetStarter";
- if (PyErr_Occurred())
- PyErr_Print();
- break;
- }
- wnd = NULL;
- if (PyString_Check(ret)) {
- char* thisc = PyString_AsString(ret);
- SWIG_GetPtr(thisc, (void**)&wnd, "_wxWindow_p");
- }
- Py_DECREF(ret);
- if (! wnd) {
- errmsg = "Could not make a wxWindow pointer from return ptr";
- break;
- }
- wxPySaveThread(doSave);
- wnd -> Show(TRUE);
- m_WParser->OpenContainer()->InsertCell(new wxHtmlWidgetCell(wnd, fl));
- return FALSE;
- }
-
- wxPySaveThread(doSave);
-
- /* we got out of the loop. Must be an error. Show a box stating it. */
- wnd = new wxTextCtrl( m_WParser -> GetWindow(), -1,
- errmsg, wxPoint(0,0),
- wxSize(300, 100), wxTE_MULTILINE );
- wnd -> Show(TRUE);
- m_WParser->OpenContainer()->InsertCell(new wxHtmlWidgetCell(wnd, 100));
- return FALSE;
- }
-TAG_HANDLER_END(PYTHONTAG)
-
-TAGS_MODULE_BEGIN(PythonTag)
-
- TAGS_MODULE_ADD(PYTHONTAG)
-
-TAGS_MODULE_END(PythonTag)
-
-// Note: see also the init function where we add the module!
-#endif
-%}
//---------------------------------------------------------------------------
};
+//---------------------------------------------------------------------------
+
+class wxHtmlLinkInfo {
+public:
+ wxHtmlLinkInfo(const wxString& href, const wxString& target = wxEmptyString);
+ wxString GetHref();
+ wxString GetTarget();
+};
+
//---------------------------------------------------------------------------
class wxHtmlTag {
// wxObject* GetProduct();
void AddTagHandler(wxHtmlTagHandler *handler);
wxString* GetSource();
+ void PushTagHandler(wxHtmlTagHandler* handler, wxString tags);
+ void PopTagHandler();
// void AddText(const char* txt) = 0;
int GetCharHeight();
int GetCharWidth();
wxWindow* GetWindow();
- void SetFonts(wxString normal_face, int normal_italic_mode,
- wxString fixed_face, int fixed_italic_mode, int *LIST);
+ void SetFonts(wxString normal_face, wxString fixed_face, int *LIST);
wxHtmlContainerCell* GetContainer();
wxHtmlContainerCell* OpenContainer();
+ wxHtmlContainerCell *SetContainer(wxHtmlContainerCell *c);
wxHtmlContainerCell* CloseContainer();
+
int GetFontSize();
void SetFontSize(int s);
int GetFontBold();
void SetLinkColor(const wxColour& clr);
const wxColour& GetActualColor();
void SetActualColor(const wxColour& clr);
- const wxString& GetLink();
void SetLink(const wxString& link);
wxFont* CreateCurrentFont();
+ wxHtmlLinkInfo GetLink();
+
};
void OnExit() {
Py_DECREF(m_tagHandlerClass);
m_tagHandlerClass = NULL;
- for (int x=0; x < m_objArray.GetCount(); x++) {
+ for (size_t x=0; x < m_objArray.GetCount(); x++) {
PyObject* obj = (PyObject*)m_objArray.Item(x);
Py_DECREF(obj);
}
}
%}
+
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
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);
+ wxHtmlLinkInfo* GetLink(int x = 0, int y = 0);
wxHtmlCell* GetNext();
- void SetPos(int x, int y);
- void SetLink(const wxString& link);
+ wxHtmlContainerCell* GetParent();
+ void SetLink(const wxHtmlLinkInfo& link);
void SetNext(wxHtmlCell *cell);
+ void SetParent(wxHtmlContainerCell *p);
+ void SetPos(int x, int y);
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);
+
+ bool AdjustPagebreak(int * pagebreak);
+ void SetCanLiveOnPagebreak(bool can);
+
};
+class wxHtmlColourCell : public wxHtmlCell {
+public:
+ wxHtmlColourCell(wxColour clr, int flags = wxHTML_CLR_FOREGROUND);
+
+};
+
+
class wxHtmlWidgetCell : public wxHtmlCell {
public:
const wxString& name = "htmlWindow")
: wxHtmlWindow(parent, id, pos, size, style, name) {};
- DEC_PYCALLBACK__STRING(OnLinkClicked);
+ void OnLinkClicked(wxHtmlLinkInfo* link);
+ void base_OnLinkClicked(wxHtmlLinkInfo* link);
+
+ DEC_PYCALLBACK__STRING(OnSetTitle);
PYPRIVATE;
};
-IMP_PYCALLBACK__STRING(wxPyHtmlWindow, wxHtmlWindow, OnLinkClicked);
+IMP_PYCALLBACK__STRING(wxPyHtmlWindow, wxHtmlWindow, OnSetTitle);
+void wxPyHtmlWindow::OnLinkClicked(wxHtmlLinkInfo* link) {
+ bool doSave = wxPyRestoreThread();
+ if (m_myInst.findCallback("OnLinkClicked")) {
+ PyObject* obj = wxPyConstructObject(link, "wxHtmlLinkInfo");
+ m_myInst.callCallback(Py_BuildValue("(O)", obj));
+ }
+ else
+ wxHtmlWindow::OnLinkClicked(link);
+ wxPySaveThread(doSave);
+}
+void wxPyHtmlWindow::base_OnLinkClicked(wxHtmlLinkInfo* link) {
+ wxHtmlWindow::OnLinkClicked(link);
+}
%}
void SetRelatedFrame(wxFrame* frame, const char* format);
wxFrame* GetRelatedFrame();
void SetRelatedStatusBar(int bar);
- void SetFonts(wxString normal_face, int normal_italic_mode,
- wxString fixed_face, int fixed_italic_mode, int *LIST);
+ void SetFonts(wxString normal_face, wxString fixed_face, int *LIST);
void SetTitle(const char* title);
void SetBorders(int b);
void ReadCustomization(wxConfigBase *cfg, char* path = "");
wxHtmlWinParser* GetParser();
- void base_OnLinkClicked(const char* link);
+ void base_OnSetTitle(const char* title);
};
// Static methods are mapped to stand-alone functions
%}
+//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
+
+
+class wxHtmlDCRenderer {
+public:
+ wxHtmlDCRenderer();
+ ~wxHtmlDCRenderer();
+
+ void SetDC(wxDC *dc, int maxwidth);
+ void SetSize(int width, int height);
+ void SetHtmlText(const wxString& html,
+ const wxString& basepath = wxEmptyString,
+ bool isdir = TRUE);
+ int Render(int x, int y, int from = 0, int dont_render = FALSE);
+ int GetTotalHeight();
+ // returns total height of the html document
+ // (compare Render's return value with this)
+};
+
+enum {
+ wxPAGE_ODD,
+ wxPAGE_EVEN,
+ wxPAGE_ALL
+};
+
+
+class wxHtmlPrintout : public wxPyPrintout {
+public:
+ wxHtmlPrintout(const char* title = "Printout");
+ ~wxHtmlPrintout();
+
+ void SetHtmlText(const wxString& html,
+ const wxString &basepath = wxEmptyString,
+ bool isdir = TRUE);
+ void SetHtmlFile(const wxString &htmlfile);
+ void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
+ void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
+ void SetMargins(float top = 25.2, float bottom = 25.2,
+ float left = 25.2, float right = 25.2,
+ float spaces = 5);
+};
+
+
+
+class wxHtmlEasyPrinting {
+public:
+ wxHtmlEasyPrinting(const char* name = "Printing",
+ wxFrame *parent_frame = NULL);
+ ~wxHtmlEasyPrinting();
+
+ void PreviewFile(const wxString &htmlfile);
+ void PreviewText(const wxString &htmltext, const wxString& basepath = wxEmptyString);
+ void PrintFile(const wxString &htmlfile);
+ void PrintText(const wxString &htmltext, const wxString& basepath = wxEmptyString);
+ void PrinterSetup();
+ void PageSetup();
+ void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
+ void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
+
+ wxPrintData *GetPrintData() {return m_PrintData;}
+ wxPageSetupDialogData *GetPageSetupData() {return m_PageSetupData;}
+
+};
+
+
+
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
%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
wxFileSystem::AddHandler(new wxZipFSHandler);