+
+// wxHtmlSelection is data holder with information about text selection.
+// Selection is defined by two positions (beginning and end of the selection)
+// and two leaf(!) cells at these positions.
+class WXDLLIMPEXP_HTML wxHtmlSelection
+{
+public:
+ wxHtmlSelection()
+ : m_fromPos(wxDefaultPosition), m_toPos(wxDefaultPosition),
+ m_fromCharacterPos(-1), m_toCharacterPos(-1),
+ m_fromCell(NULL), m_toCell(NULL) {}
+
+ // this version is used for the user selection defined with the mouse
+ void Set(const wxPoint& fromPos, const wxHtmlCell *fromCell,
+ const wxPoint& toPos, const wxHtmlCell *toCell);
+ void Set(const wxHtmlCell *fromCell, const wxHtmlCell *toCell);
+
+ const wxHtmlCell *GetFromCell() const { return m_fromCell; }
+ const wxHtmlCell *GetToCell() const { return m_toCell; }
+
+ // these values are in absolute coordinates:
+ const wxPoint& GetFromPos() const { return m_fromPos; }
+ const wxPoint& GetToPos() const { return m_toPos; }
+
+ // these are From/ToCell's private data
+ void ClearFromToCharacterPos() { m_toCharacterPos = m_fromCharacterPos = -1; }
+ bool AreFromToCharacterPosSet() const { return m_toCharacterPos != -1 && m_fromCharacterPos != -1; }
+
+ void SetFromCharacterPos (wxCoord pos) { m_fromCharacterPos = pos; }
+ void SetToCharacterPos (wxCoord pos) { m_toCharacterPos = pos; }
+ wxCoord GetFromCharacterPos () const { return m_fromCharacterPos; }
+ wxCoord GetToCharacterPos () const { return m_toCharacterPos; }
+
+ bool IsEmpty() const
+ { return m_fromPos == wxDefaultPosition &&
+ m_toPos == wxDefaultPosition; }
+
+private:
+ wxPoint m_fromPos, m_toPos;
+ wxCoord m_fromCharacterPos, m_toCharacterPos;
+ const wxHtmlCell *m_fromCell, *m_toCell;
+};
+
+
+
+enum wxHtmlSelectionState
+{
+ wxHTML_SEL_OUT, // currently rendered cell is outside the selection
+ wxHTML_SEL_IN, // ... is inside selection
+ wxHTML_SEL_CHANGING // ... is the cell on which selection state changes
+};
+
+// Selection state is passed to wxHtmlCell::Draw so that it can render itself
+// differently e.g. when inside text selection or outside it.
+class WXDLLIMPEXP_HTML wxHtmlRenderingState
+{
+public:
+ wxHtmlRenderingState() : m_selState(wxHTML_SEL_OUT) {}
+
+ void SetSelectionState(wxHtmlSelectionState s) { m_selState = s; }
+ wxHtmlSelectionState GetSelectionState() const { return m_selState; }
+
+ void SetFgColour(const wxColour& c) { m_fgColour = c; }
+ const wxColour& GetFgColour() const { return m_fgColour; }
+ void SetBgColour(const wxColour& c) { m_bgColour = c; }
+ const wxColour& GetBgColour() const { return m_bgColour; }
+ void SetBgMode(int m) { m_bgMode = m; }
+ int GetBgMode() const { return m_bgMode; }
+
+private:
+ wxHtmlSelectionState m_selState;
+ wxColour m_fgColour, m_bgColour;
+ int m_bgMode;
+};
+
+
+// HTML rendering customization. This class is used when rendering wxHtmlCells
+// as a callback:
+class WXDLLIMPEXP_HTML wxHtmlRenderingStyle
+{
+public:
+ virtual ~wxHtmlRenderingStyle() {}
+ virtual wxColour GetSelectedTextColour(const wxColour& clr) = 0;
+ virtual wxColour GetSelectedTextBgColour(const wxColour& clr) = 0;
+};
+
+// Standard style:
+class WXDLLIMPEXP_HTML wxDefaultHtmlRenderingStyle : public wxHtmlRenderingStyle
+{
+public:
+ virtual wxColour GetSelectedTextColour(const wxColour& clr);
+ virtual wxColour GetSelectedTextBgColour(const wxColour& clr);
+};
+
+
+// Information given to cells when drawing them. Contains rendering state,
+// selection information and rendering style object that can be used to
+// customize the output.
+class WXDLLIMPEXP_HTML wxHtmlRenderingInfo
+{
+public:
+ wxHtmlRenderingInfo() : m_selection(NULL), m_style(NULL) {}
+
+ void SetSelection(wxHtmlSelection *s) { m_selection = s; }
+ wxHtmlSelection *GetSelection() const { return m_selection; }
+
+ void SetStyle(wxHtmlRenderingStyle *style) { m_style = style; }
+ wxHtmlRenderingStyle& GetStyle() { return *m_style; }
+
+ wxHtmlRenderingState& GetState() { return m_state; }
+
+protected:
+ wxHtmlSelection *m_selection;
+ wxHtmlRenderingStyle *m_style;
+ wxHtmlRenderingState m_state;
+};
+
+
+// Flags for wxHtmlCell::FindCellByPos
+enum
+{
+ wxHTML_FIND_EXACT = 1,
+ wxHTML_FIND_NEAREST_BEFORE = 2,
+ wxHTML_FIND_NEAREST_AFTER = 4
+};
+
+
+// Superscript/subscript/normal script mode of a cell
+enum wxHtmlScriptMode
+{
+ wxHTML_SCRIPT_NORMAL,
+ wxHTML_SCRIPT_SUB,
+ wxHTML_SCRIPT_SUP
+};
+
+
+// ---------------------------------------------------------------------------