// Name: html/htmlcell.h
// Purpose: interface of wxHtml*Cell
// Author: wxWidgets team
-// RCS-ID: $Id$
-// Licence: wxWindows license
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
+
/**
- @class wxHtmlColourCell
+ @class wxHtmlRenderingStyle
+
+ 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.
+
+ @library{wxhtml}
+ @category{html}
+*/
+class wxHtmlSelection
+{
+public:
+ wxHtmlSelection();
- This cell changes the colour of either the background or the foreground.
+ // 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;
+ const wxHtmlCell *GetToCell() const;
+
+ // these values are in absolute coordinates:
+ const wxPoint& GetFromPos() const;
+ const wxPoint& GetToPos() const;
+
+ // these are From/ToCell's private data
+ void ClearFromToCharacterPos();
+ bool AreFromToCharacterPosSet() const;
+
+ void SetFromCharacterPos (wxCoord pos);
+ void SetToCharacterPos (wxCoord pos);
+ wxCoord GetFromCharacterPos () const;
+ wxCoord GetToCharacterPos () const;
+
+ bool IsEmpty() const;
+};
+
+
+
+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
+};
+
+
+/**
+ @class wxHtmlRenderingState
+
+ Selection state is passed to wxHtmlCell::Draw so that it can render itself
+ differently e.g. when inside text selection or outside it.
+
+ @library{wxhtml}
+ @category{html}
+*/
+class wxHtmlRenderingState
+{
+public:
+ wxHtmlRenderingState();
+
+ void SetSelectionState(wxHtmlSelectionState s);
+ wxHtmlSelectionState GetSelectionState() const;
+
+ void SetFgColour(const wxColour& c);
+ const wxColour& GetFgColour() const;
+ void SetBgColour(const wxColour& c);
+ const wxColour& GetBgColour() const;
+ void SetBgMode(int m);
+ int GetBgMode() const;
+};
+
+
+
+/**
+ @class wxHtmlRenderingStyle
+
+ Allows HTML rendering customizations.
+ This class is used when rendering wxHtmlCells as a callback.
@library{wxhtml}
@category{html}
+
+ @see wxHtmlRenderingInfo
*/
-class wxHtmlColourCell : public wxHtmlCell
+class wxHtmlRenderingStyle
{
public:
/**
- Constructor.
+ Returns the colour to use for the selected text.
+ */
+ virtual wxColour GetSelectedTextColour(const wxColour& clr) = 0;
- @param clr
- The color
- @param flags
- Can be one of following:
- - wxHTML_CLR_FOREGROUND: change color of text
- - wxHTML_CLR_BACKGROUND: change background color
+ /**
+ Returns the colour to use for the selected text's background.
*/
- wxHtmlColourCell(const wxColour& clr, int flags = wxHTML_CLR_FOREGROUND);
+ virtual wxColour GetSelectedTextBgColour(const wxColour& clr) = 0;
};
-
/**
- @class wxHtmlWidgetCell
-
- wxHtmlWidgetCell is a class that provides a connection between HTML cells and
- widgets (an object derived from wxWindow).
- You can use it to display things like forms, input boxes etc. in an HTML window.
+ @class wxHtmlRenderingInfo
- wxHtmlWidgetCell takes care of resizing and moving window.
+ This class contains information given to cells when drawing them.
+ Contains rendering state, selection information and rendering style object
+ that can be used to customize the output.
@library{wxhtml}
@category{html}
+
+ @see @ref overview_html_cells, wxHtmlCell
*/
-class wxHtmlWidgetCell : public wxHtmlCell
+class wxHtmlRenderingInfo
{
public:
/**
- Constructor.
+ Default ctor.
+ */
+ wxHtmlRenderingInfo();
- @param wnd
- Connected window. It is parent window @b must be the wxHtmlWindow object
- within which it is displayed!
- @param w
- Floating width. If non-zero width of wnd window is adjusted so that it is
- always w percents of parent container's width. (For example w = 100 means
- that the window will always have same width as parent container).
+ //@{
+ /**
+ Accessors.
*/
- wxHtmlWidgetCell(wxWindow* wnd, int w = 0);
+ void SetSelection(wxHtmlSelection *s);
+ wxHtmlSelection *GetSelection() const;
+
+ void SetStyle(wxHtmlRenderingStyle *style);
+ wxHtmlRenderingStyle& GetStyle();
+
+ wxHtmlRenderingState& GetState();
+ //@}
};
+// 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
+};
+
+
/**
@class wxHtmlCell
/**
This method is used to adjust pagebreak position.
- The parameter is variable that contains y-coordinate of page break
+ The first parameter is a variable that contains the y-coordinate of the page break
(= horizontal line that should not be crossed by words, images etc.).
If this cell cannot be divided into two pieces (each one on another page)
- then it moves the pagebreak few pixels up.
+ then it either moves the pagebreak a few pixels up, if possible, or, if
+ the cell cannot fit on the page at all, then the cell is forced to
+ split unconditionally.
+
Returns @true if pagebreak was modified, @false otherwise.
+ @param pagebreak
+ position in pixel of the pagebreak.
+
+ @param known_pagebreaks
+ the list of the previous pagebreaks
+
+ @param pageHeight
+ the height in pixel of the page drawable area
+
Usage:
@code
- while (container->AdjustPagebreak(&p)) {}
+ while (container->AdjustPagebreak(&p, kp, ph)) {}
@endcode
+
*/
virtual bool AdjustPagebreak(int* pagebreak,
- wxArrayInt& known_pagebreaks) const;
+ const wxArrayInt& known_pagebreaks,
+ int pageHeight) const;
/**
Renders the cell.
@param dc
- Device context to which the cell is to be drawn
+ Device context to which the cell is to be drawn.
@param x,y
Coordinates of parent's upper left corner (origin). You must
add this to m_PosX,m_PosY when passing coordinates to dc's methods
@endcode
@param view_y1
y-coord of the first line visible in window.
- This is used to optimize rendering speed
+ This is used to optimize rendering speed.
@param view_y2
y-coord of the last line visible in window.
- This is used to optimize rendering speed
+ This is used to optimize rendering speed.
+ @param info
+ Additional information for the rendering of the cell.
*/
virtual void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2, wxHtmlRenderingInfo& info);
@code
dc->DrawText("hello", x + m_PosX, y + m_PosY)
@endcode
+ @param info
+ Additional information for the rendering of the cell.
*/
- virtual void DrawInvisible(wxDC& cd, int x , int y, wxHtmlRenderingInfo& info);
+ virtual void DrawInvisible(wxDC& dc, int x , int y, wxHtmlRenderingInfo& info);
/**
Returns pointer to itself if this cell matches condition (or if any of the
/**
Returns descent value of the cell (m_Descent member).
See explanation:
- @image html descent.png
+ @image html htmlcell_descent.png
*/
int GetDescent() const;
@param window
interface to the parent HTML window
+
+ @see GetMouseCursorAt()
*/
virtual wxCursor GetMouseCursor(wxHtmlWindowInterface* window) const;
+ /**
+ Returns cursor to show when mouse pointer is over the specified point.
+
+ This function should be overridden instead of GetMouseCursorAt() if
+ the cursor should depend on the exact position of the mouse in the
+ window.
+
+ @param window
+ interface to the parent HTML window
+
+ @since 3.0
+ */
+ virtual wxCursor GetMouseCursorAt(wxHtmlWindowInterface* window,
+ const wxPoint& rePos) const;
+
/**
Returns pointer to the next cell in list (see htmlcell.h if you're
interested in details).
int GetWidth() const;
/**
+ Layouts the cell.
+
This method performs two actions:
-# adjusts the cell's width according to the fact that maximal possible
- width is @e w. (this has sense when working with horizontal lines, tables etc.)
+ width is @e w (this has sense when working with horizontal lines, tables etc.)
-# prepares layout (=fill-in m_PosX, m_PosY (and sometimes m_Height) members)
based on actual width @e w
This function is simple event handler.
Each time the user clicks mouse button over a cell within wxHtmlWindow
this method of that cell is called.
- Default behavior is to call wxHtmlWindow::LoadPage.
+ Default behaviour is to call wxHtmlWindow::LoadPage.
@param window
interface to the parent HTML window
- wxHTML_ALIGN_CENTER: cells are centered on line
- wxHTML_ALIGN_TOP: cells are under the line
- @image html alignv.png
+ @image html htmlcontcell_alignv.png
*/
void SetAlignVer(int al);
Colour of top and left lines
@param clr2
Colour of bottom and right lines
+ @param border
+ Size of the border in pixels
*/
- void SetBorder(const wxColour& clr1, const wxColour& clr2);
+ void SetBorder(const wxColour& clr1, const wxColour& clr2, int border = 1);
/**
Sets the indentation (free space between borders of container and subcells).
- @image html indent.png
+ @image html htmlcontcell_indent.png
@param i
Indentation value.
wxString GetTarget() const;
};
+/**
+ @class wxHtmlColourCell
+
+ This cell changes the colour of either the background or the foreground.
+
+ @library{wxhtml}
+ @category{html}
+*/
+class wxHtmlColourCell : public wxHtmlCell
+{
+public:
+ /**
+ Constructor.
+
+ @param clr
+ The color
+ @param flags
+ Can be one of following:
+ - wxHTML_CLR_FOREGROUND: change color of text
+ - wxHTML_CLR_BACKGROUND: change background color
+ */
+ wxHtmlColourCell(const wxColour& clr, int flags = wxHTML_CLR_FOREGROUND);
+};
+
+
+
+/**
+ @class wxHtmlWidgetCell
+
+ wxHtmlWidgetCell is a class that provides a connection between HTML cells and
+ widgets (an object derived from wxWindow).
+ You can use it to display things like forms, input boxes etc. in an HTML window.
+
+ wxHtmlWidgetCell takes care of resizing and moving window.
+
+ @library{wxhtml}
+ @category{html}
+*/
+class wxHtmlWidgetCell : public wxHtmlCell
+{
+public:
+ /**
+ Constructor.
+
+ @param wnd
+ Connected window. It is parent window @b must be the wxHtmlWindow object
+ within which it is displayed!
+ @param w
+ Floating width. If non-zero width of wnd window is adjusted so that it is
+ always w percents of parent container's width. (For example w = 100 means
+ that the window will always have same width as parent container).
+ */
+ wxHtmlWidgetCell(wxWindow* wnd, int w = 0);
+};
+
+
+
+/**
+ @class wxHtmlWordCell
+
+ This html cell represents a single word or text fragment in the document stream.
+
+ @library{wxhtml}
+ @category{html}
+*/
+class wxHtmlWordCell : public wxHtmlCell
+{
+public:
+ wxHtmlWordCell(const wxString& word, const wxDC& dc);
+};
+
+
+/**
+ @class wxHtmlWordWithTabsCell
+
+ wxHtmlWordCell is a specialization for storing text fragments with
+ embedded tab characters.
+
+ @library{wxhtml}
+ @category{html}
+*/
+class wxHtmlWordWithTabsCell : public wxHtmlWordCell
+{
+public:
+ wxHtmlWordWithTabsCell(const wxString& word,
+ const wxString& wordOrig,
+ size_t linepos,
+ const wxDC& dc);
+};
+
+
+/**
+ @class wxHtmlFontCell
+
+ This cell represents a font change in the document stream.
+
+ @library{wxhtml}
+ @category{html}
+*/
+class wxHtmlFontCell : public wxHtmlCell
+{
+public:
+ wxHtmlFontCell(wxFont *font);
+};