%{
#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 "helpsys.h"
+
+#include "printfw.h"
%}
//---------------------------------------------------------------------------
%extern events.i
%extern controls.i
%extern controls2.i
+%extern printfw.i
%extern utils.i
#endif
%}
-%pragma(python) code = "import wx,htmlhelper"
-%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];
+%pragma(python) code = "import wx"
- 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)
+enum {
+ wxHTML_ALIGN_LEFT,
+ wxHTML_ALIGN_CENTER,
+ wxHTML_ALIGN_RIGHT,
+ wxHTML_ALIGN_BOTTOM,
+ wxHTML_ALIGN_TOP,
+
+ wxHTML_CLR_FOREGROUND,
+ wxHTML_CLR_BACKGROUND,
+
+ wxHTML_UNITS_PIXELS,
+ wxHTML_UNITS_PERCENT,
+
+ wxHTML_INDENT_LEFT,
+ wxHTML_INDENT_RIGHT,
+ wxHTML_INDENT_TOP,
+ wxHTML_INDENT_BOTTOM,
+
+ wxHTML_INDENT_HORIZONTAL,
+ wxHTML_INDENT_VERTICAL,
+ wxHTML_INDENT_ALL,
+
+ wxHTML_COND_ISANCHOR,
+ wxHTML_COND_ISIMAGEMAP,
+ wxHTML_COND_USER,
+};
-// 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 wxHtmlLinkInfo {
+public:
+ wxHtmlLinkInfo(const wxString& href, const wxString& target = wxEmptyString);
+ wxString GetHref();
+ wxString GetTarget();
+ wxMouseEvent* GetEvent();
+ wxHtmlCell* GetHtmlCell();
};
-
//---------------------------------------------------------------------------
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);
+
};
int GetAlignHor();
void SetAlignVer(int al);
int GetAlignVer();
- void SetIndent(int i, int what, int units = HTML_UNITS_PIXELS);
+ void SetIndent(int i, int what, int units = wxHTML_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 SetMinHeight(int h, int align = wxHTML_ALIGN_TOP);
void SetBackgroundColour(const wxColour& clr);
void SetBorder(const wxColour& clr1, const wxColour& clr2);
wxHtmlCell* GetFirstCell();
+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(const wxHtmlLinkInfo& link);
+ void base_OnLinkClicked(const wxHtmlLinkInfo& link);
+
+ DEC_PYCALLBACK__STRING(OnSetTitle);
PYPRIVATE;
};
-IMP_PYCALLBACK__STRING(wxPyHtmlWindow, wxHtmlWindow, OnLinkClicked);
+IMP_PYCALLBACK__STRING(wxPyHtmlWindow, wxHtmlWindow, OnSetTitle);
+
+void wxPyHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link) {
+ bool doSave = wxPyRestoreThread();
+ if (m_myInst.findCallback("OnLinkClicked")) {
+ PyObject* obj = wxPyConstructObject((void*)&link, "wxHtmlLinkInfo");
+ m_myInst.callCallback(Py_BuildValue("(O)", obj));
+ }
+ else
+ wxHtmlWindow::OnLinkClicked(link);
+ wxPySaveThread(doSave);
+}
+void wxPyHtmlWindow::base_OnLinkClicked(const wxHtmlLinkInfo& link) {
+ wxHtmlWindow::OnLinkClicked(link);
+}
%}
+
%name(wxHtmlWindow) class wxPyHtmlWindow : public wxScrolledWindow {
public:
wxPyHtmlWindow(wxWindow *parent, int id = -1,
bool SetPage(const char* source);
- // Set HTML page and display it. !! source is HTML document itself,
- // it is NOT address/filename of HTML document. If you want to
- // specify document location, use LoadPage() istead
- // Return value : FALSE if an error occured, TRUE otherwise
-
bool LoadPage(const char* location);
- // Load HTML page from given location. Location can be either
- // a) /usr/wxGTK2/docs/html/wx.htm
- // b) http://www.somewhere.uk/document.htm
- // c) ftp://ftp.somesite.cz/pub/something.htm
- // In case there is no prefix (http:,ftp:), the method
- // will try to find it itself (1. local file, then http or ftp)
- // After the page is loaded, the method calls SetPage() to display it.
- // Note : you can also use path relative to previously loaded page
- // Return value : same as SetPage
-
wxString GetOpenedPage();
- // Returns full location of opened page
-
void SetRelatedFrame(wxFrame* frame, const char* format);
- // sets frame in which page title will be displayed. Format is format of
- // frame title, e.g. "HtmlHelp : %s". It must contain exactly one %s
wxFrame* GetRelatedFrame();
-
void SetRelatedStatusBar(int bar);
- // after(!) calling SetRelatedFrame, this sets statusbar slot where messages
- // will be displayed. Default is -1 = no messages.
-
- void SetFonts(wxString normal_face, int normal_italic_mode,
- wxString fixed_face, int fixed_italic_mode, int *LIST);
- // sets fonts to be used when displaying HTML page.
- // *_italic_mode can be either wxSLANT or wxITALIC
-
+ void SetFonts(wxString normal_face, wxString fixed_face, int *LIST);
void SetTitle(const char* title);
- // Sets the title of the window
- // (depending on the information passed to SetRelatedFrame() method)
-
void SetBorders(int b);
- // Sets space between text and window borders.
-
void ReadCustomization(wxConfigBase *cfg, char* path = "");
- // saves custom settings into cfg config. it will use the path 'path'
- // if given, otherwise it will save info into currently selected path.
- // saved values : things set by SetFonts, SetBorders.
-
void WriteCustomization(wxConfigBase *cfg, char* path = "");
- // ...
-
bool HistoryBack();
bool HistoryForward();
- // Goes to previous/next page (in browsing history)
- // Returns TRUE if successful, FALSE otherwise
void HistoryClear();
- // Resets history
-
wxHtmlContainerCell* GetInternalRepresentation();
- // 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
- // call LoadPage(loc)
-
+ void base_OnLinkClicked(const wxHtmlLinkInfo& 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();
+ 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);