wxRTC no longer derives from wxTextCtrlBase; added wxRichTextAttr deriving from wxTextAttr

with CSS-like attributes for future developments; removed image-specific attributes object


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65756 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart 2010-10-04 08:37:31 +00:00
parent 1d12c6e2be
commit 2477747881
31 changed files with 2007 additions and 1231 deletions

View File

@ -71,7 +71,7 @@
#endif
// Compatibility
#define wxRichTextAttr wxTextAttr
//#define wxRichTextAttr wxTextAttr
#define wxTextAttrEx wxTextAttr
// Setting wxRICHTEXT_USE_OWN_CARET to 1 implements a
@ -235,67 +235,471 @@ enum wxRichTextHitTestFlags
#define wxSCRIPT_MUL_FACTOR 1.5
// Image align/floating
#define wxRICHTEXT_LEFT 0x00
#define wxRICHTEXT_CENTRE 0x01
#define wxRICHTEXT_RIGHT 0x02
typedef unsigned short wxTextAttrDimensionFlags;
#define wxRICHTEXT_FLOAT_NONE 0x00
#define wxRICHTEXT_FLOAT_LEFT 0x01
#define wxRICHTEXT_FLOAT_RIGHT 0x02
// Miscelaneous text box flags
enum wxTextBoxAttrFlags
{
wxTEXT_BOX_ATTR_FLOAT = 0x00000001,
wxTEXT_BOX_ATTR_CLEAR = 0x00000002,
wxTEXT_BOX_ATTR_COLLAPSE_BORDERS = 0x00000004
};
// Image width/height scale
#define wxRICHTEXT_PX 0x00
#define wxRICHTEXT_MM 0x01
// Whether a value is present, used in dimension flags
enum wxTextAttrValueFlags
{
wxTEXT_ATTR_VALUE_PRESENT = 0x1000,
wxTEXT_ATTR_VALUE_PRESENT_MASK = 0x1000
};
/*!
* wxRichTextAnchoredObjectAttr class declaration
*/
class WXDLLIMPEXP_RICHTEXT wxRichTextAnchoredObjectAttr
// Units - included in the dimension value
enum wxTextAttrUnits
{
wxTEXT_ATTR_UNITS_TENTHS_MM = 0x0001,
wxTEXT_ATTR_UNITS_PIXELS = 0x0002,
wxTEXT_ATTR_UNITS_PERCENTAGE = 0x0004,
wxTEXT_ATTR_UNITS_POINTS = 0x0008,
wxTEXT_ATTR_UNITS_MASK = 0x000F
};
// Position - included in the dimension flags
enum wxTextBoxAttrPosition
{
wxTEXT_BOX_ATTR_POSITION_STATIC = 0x0000, // Default is static, i.e. as per normal layout
wxTEXT_BOX_ATTR_POSITION_RELATIVE = 0x0010,
wxTEXT_BOX_ATTR_POSITION_ABSOLUTE = 0x0020,
wxTEXT_BOX_ATTR_POSITION_MASK = 0x00F0
};
// Dimension, including units and position
class WXDLLIMPEXP_CORE wxTextAttrDimension
{
public:
wxRichTextAnchoredObjectAttr() { Init(); }
wxRichTextAnchoredObjectAttr(const wxRichTextAnchoredObjectAttr& attr) { Copy(attr); }
wxTextAttrDimension() { Reset(); }
wxTextAttrDimension(int value, wxTextAttrDimensionFlags flags = wxTEXT_ATTR_VALUE_PRESENT|wxTEXT_ATTR_UNITS_TENTHS_MM) { m_value = value; m_flags = flags; }
void Reset() { m_value = 0; m_flags = 0; }
void Init();
// Partial equality test
bool EqPartial(const wxTextAttrDimension& dim) const;
void operator= (const wxRichTextAnchoredObjectAttr& attr) { Copy(attr); }
void Copy(const wxRichTextAnchoredObjectAttr& attr);
// Apply
bool Apply(const wxTextAttrDimension& dim, const wxTextAttrDimension* compareWith = NULL);
/// Is this anchored? TODO: difference between anchored and floating?
bool IsAnchored() const { return m_floating != wxRICHTEXT_FLOAT_NONE; }
// Collects the attributes that are common to a range of content, building up a note of
// which attributes are absent in some objects and which clash in some objects.
void CollectCommonAttributes(const wxTextAttrDimension& attr, wxTextAttrDimension& clashingAttr, wxTextAttrDimension& absentAttr);
/// Is this floating?
bool IsFloating() const { return m_floating != wxRICHTEXT_FLOAT_NONE; }
void SetFloatingMode(int floating) { m_floating = floating; }
bool operator==(const wxTextAttrDimension& dim) const { return m_value == dim.m_value && m_flags == dim.m_flags; }
int GetValue() const { return m_value; }
float GetValueMM() const { return float(m_value) / 10.0; }
void SetValueMM(float value) { m_value = (int) ((value * 10.0) + 0.5); m_flags |= wxTEXT_ATTR_VALUE_PRESENT; }
void SetValue(int value) { m_value = value; m_flags |= wxTEXT_ATTR_VALUE_PRESENT; }
void SetValue(int value, wxTextAttrDimensionFlags flags) { m_value = value; m_flags = flags; }
wxTextAttrUnits GetUnits() const { return (wxTextAttrUnits) (m_flags & wxTEXT_ATTR_UNITS_MASK); }
void SetUnits(wxTextAttrUnits units) { m_flags &= ~wxTEXT_ATTR_UNITS_MASK; m_flags |= units; }
wxTextBoxAttrPosition GetPosition() const { return (wxTextBoxAttrPosition) (m_flags & wxTEXT_BOX_ATTR_POSITION_MASK); }
void SetPosition(wxTextBoxAttrPosition pos) { m_flags &= ~wxTEXT_BOX_ATTR_POSITION_MASK; m_flags |= pos; }
bool IsPresent() const { return (m_flags & wxTEXT_ATTR_VALUE_PRESENT) != 0; }
void SetPresent(bool b) { m_flags &= ~wxTEXT_ATTR_VALUE_PRESENT_MASK; m_flags |= (b ? wxTEXT_ATTR_VALUE_PRESENT : 0); }
int m_value;
wxTextAttrDimensionFlags m_flags;
};
int GetAlignment() const { return m_align; }
void SetAlignment(int align) { m_align = align; }
class WXDLLIMPEXP_CORE wxTextBoxAttrDimensions
{
public:
void Reset() { m_left.Reset(); m_top.Reset(); m_right.Reset(); m_bottom.Reset(); }
bool operator==(const wxTextBoxAttrDimensions& dims) const { return m_left == dims.m_left && m_top == dims.m_top && m_right == dims.m_right && m_bottom == dims.m_bottom; }
// Partial equality test
bool EqPartial(const wxTextBoxAttrDimensions& dims) const;
int GetOffset() const { return m_offset; }
void SetOffset(int offset) { m_offset = offset; }
// Apply border to 'this', but not if the same as compareWith
bool Apply(const wxTextBoxAttrDimensions& dims, const wxTextBoxAttrDimensions* compareWith = NULL);
int GetUnitsOffset() const { return m_unitsOffset; }
void SetUnitsOffset(int offset) { m_unitsOffset = offset; }
// Collects the attributes that are common to a range of content, building up a note of
// which attributes are absent in some objects and which clash in some objects.
void CollectCommonAttributes(const wxTextBoxAttrDimensions& attr, wxTextBoxAttrDimensions& clashingAttr, wxTextBoxAttrDimensions& absentAttr);
int GetUnitsW() const { return m_unitsW; }
void SetUnitsW(int u) { m_unitsW = u; }
// Remove specified attributes from this object
bool RemoveStyle(const wxTextBoxAttrDimensions& attr);
int GetUnitsH() const { return m_unitsH; }
void SetUnitsH(int u) { m_unitsH = u; }
wxTextAttrDimension m_left;
wxTextAttrDimension m_top;
wxTextAttrDimension m_right;
wxTextAttrDimension m_bottom;
};
int GetWidth() const { return m_width; }
void SetWidth(int w) { m_width = w; }
// Border styles
enum wxTextBoxAttrBorderStyle
{
wxTEXT_BOX_ATTR_BORDER_NONE = 0,
wxTEXT_BOX_ATTR_BORDER_SOLID = 1,
wxTEXT_BOX_ATTR_BORDER_DOTTED = 2,
wxTEXT_BOX_ATTR_BORDER_DASHED = 3,
wxTEXT_BOX_ATTR_BORDER_DOUBLE = 4,
wxTEXT_BOX_ATTR_BORDER_GROOVE = 5,
wxTEXT_BOX_ATTR_BORDER_RIDGE = 6,
wxTEXT_BOX_ATTR_BORDER_INSET = 7,
wxTEXT_BOX_ATTR_BORDER_OUTSET = 8
};
int GetHeight() const { return m_height; }
void SetHeight(int h) { m_height = h; }
// Border style presence flags
enum wxTextBoxAttrBorderFlags
{
wxTEXT_BOX_ATTR_BORDER_STYLE = 0x0001,
wxTEXT_BOX_ATTR_BORDER_COLOUR = 0x0002
};
int m_align;
int m_floating;
int m_offset;
int m_unitsOffset;
int m_unitsW, m_unitsH;
int m_width, m_height;
// Float styles
enum wxTextBoxAttrFloatStyle
{
wxTEXT_BOX_ATTR_FLOAT_NONE = 0,
wxTEXT_BOX_ATTR_FLOAT_LEFT = 1,
wxTEXT_BOX_ATTR_FLOAT_RIGHT = 2
};
// Clear styles
enum wxTextBoxAttrClearStyle
{
wxTEXT_BOX_ATTR_CLEAR_NONE = 0,
wxTEXT_BOX_ATTR_CLEAR_LEFT = 1,
wxTEXT_BOX_ATTR_CLEAR_RIGHT = 2,
wxTEXT_BOX_ATTR_CLEAR_BOTH = 3
};
// Collapse mode styles. TODO: can they be switched on per side?
enum wxTextBoxAttrCollapseMode
{
wxTEXT_BOX_ATTR_COLLAPSE_NONE = 0,
wxTEXT_BOX_ATTR_COLLAPSE_FULL = 1
};
// Border
class WXDLLIMPEXP_CORE wxTextBoxAttrBorder
{
public:
wxTextBoxAttrBorder() { Reset(); }
bool operator==(const wxTextBoxAttrBorder& border) const
{
return m_flags == border.m_flags && m_borderStyle == border.m_borderStyle &&
m_borderColour == border.m_borderColour && m_borderWidth == border.m_borderWidth;
}
void Reset() { m_borderStyle = 0; m_borderColour = 0; m_flags = 0; m_borderWidth.Reset(); }
// Partial equality test
bool EqPartial(const wxTextBoxAttrBorder& border) const;
// Apply border to 'this', but not if the same as compareWith
bool Apply(const wxTextBoxAttrBorder& border, const wxTextBoxAttrBorder* compareWith = NULL);
// Remove specified attributes from this object
bool RemoveStyle(const wxTextBoxAttrBorder& attr);
// Collects the attributes that are common to a range of content, building up a note of
// which attributes are absent in some objects and which clash in some objects.
void CollectCommonAttributes(const wxTextBoxAttrBorder& attr, wxTextBoxAttrBorder& clashingAttr, wxTextBoxAttrBorder& absentAttr);
void SetStyle(int style) { m_borderStyle = style; m_flags |= wxTEXT_BOX_ATTR_BORDER_STYLE; }
int GetStyle() const { return m_borderStyle; }
void SetColour(unsigned long colour) { m_borderColour = colour; m_flags |= wxTEXT_BOX_ATTR_BORDER_COLOUR; }
void SetColour(const wxColour& colour) { m_borderColour = colour.GetRGB(); m_flags |= wxTEXT_BOX_ATTR_BORDER_COLOUR; }
unsigned long GetColourLong() const { return m_borderColour; }
wxColour GetColour() const { return wxColour(m_borderColour); }
wxTextAttrDimension& GetWidth() { return m_borderWidth; }
const wxTextAttrDimension& GetWidth() const { return m_borderWidth; }
void SetWidth(const wxTextAttrDimension& width) { m_borderWidth = width; }
bool HasStyle() const { return (m_flags & wxTEXT_BOX_ATTR_BORDER_STYLE) == 0; }
bool HasColour() const { return (m_flags & wxTEXT_BOX_ATTR_BORDER_COLOUR) == 0; }
bool HasWidth() const { return m_borderWidth.IsPresent(); }
int GetFlags() const { return m_flags; }
void SetFlags(int flags) { m_flags = flags; }
void AddFlag(int flag) { m_flags |= flag; }
void RemoveFlag(int flag) { m_flags &= ~flag; }
int m_borderStyle;
unsigned long m_borderColour;
wxTextAttrDimension m_borderWidth;
int m_flags;
};
// Borders
class WXDLLIMPEXP_CORE wxTextBoxAttrBorders
{
public:
wxTextBoxAttrBorders() { }
bool operator==(const wxTextBoxAttrBorders& borders) const
{
return m_left == borders.m_left && m_right == borders.m_right &&
m_top == borders.m_top && m_bottom == borders.m_bottom;
}
// Set style of all borders
void SetStyle(int style);
// Set colour of all borders
void SetColour(unsigned long colour);
void SetColour(const wxColour& colour);
// Set width of all borders
void SetWidth(const wxTextAttrDimension& width);
// Reset
void Reset() { m_left.Reset(); m_right.Reset(); m_top.Reset(); m_bottom.Reset(); }
// Partial equality test
bool EqPartial(const wxTextBoxAttrBorders& borders) const;
// Apply border to 'this', but not if the same as compareWith
bool Apply(const wxTextBoxAttrBorders& borders, const wxTextBoxAttrBorders* compareWith = NULL);
// Remove specified attributes from this object
bool RemoveStyle(const wxTextBoxAttrBorders& attr);
// Collects the attributes that are common to a range of content, building up a note of
// which attributes are absent in some objects and which clash in some objects.
void CollectCommonAttributes(const wxTextBoxAttrBorders& attr, wxTextBoxAttrBorders& clashingAttr, wxTextBoxAttrBorders& absentAttr);
wxTextBoxAttrBorder m_left, m_right, m_top, m_bottom;
};
// ----------------------------------------------------------------------------
// wxTextBoxAttr: a structure containing box attributes
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxTextBoxAttr
{
public:
// ctors
wxTextBoxAttr() { Init(); }
wxTextBoxAttr(const wxTextBoxAttr& attr) { Init(); (*this) = attr; }
// Initialise this object.
void Init() { Reset(); }
// Reset this object.
void Reset();
// Copy. Unecessary since we let it do a binary copy
//void Copy(const wxTextBoxAttr& attr);
// Assignment
//void operator= (const wxTextBoxAttr& attr);
// Equality test
bool operator== (const wxTextBoxAttr& attr) const;
// Partial equality test
bool EqPartial(const wxTextBoxAttr& attr) const;
// Merges the given attributes. If compareWith
// is non-NULL, then it will be used to mask out those attributes that are the same in style
// and compareWith, for situations where we don't want to explicitly set inherited attributes.
bool Apply(const wxTextBoxAttr& style, const wxTextBoxAttr* compareWith = NULL);
// Collects the attributes that are common to a range of content, building up a note of
// which attributes are absent in some objects and which clash in some objects.
void CollectCommonAttributes(const wxTextBoxAttr& attr, wxTextBoxAttr& clashingAttr, wxTextBoxAttr& absentAttr);
// Remove specified attributes from this object
bool RemoveStyle(const wxTextBoxAttr& attr);
// Set flags
void SetFlags(int flags) { m_flags = flags; }
// Get flags
int GetFlags() const { return m_flags; }
// Is this flag present?
bool HasFlag(wxTextBoxAttrFlags flag) const { return (m_flags & flag) != 0; }
// Remove this flag
void RemoveFlag(wxTextBoxAttrFlags flag) { m_flags &= ~flag; }
// Add this flag
void AddFlag(wxTextBoxAttrFlags flag) { m_flags |= flag; }
// Is this default? I.e. no flags set
bool IsDefault() const;
// Float mode
short int GetFloatMode() const { return m_floatMode; }
void SetFloatMode(short int mode) { m_floatMode = mode; m_flags |= wxTEXT_BOX_ATTR_FLOAT; }
bool HasFloatMode() const { return HasFlag(wxTEXT_BOX_ATTR_FLOAT); }
bool IsFloating() const { return HasFloatMode() && GetFloatMode() != wxTEXT_BOX_ATTR_FLOAT_NONE; }
// Whether to wrap text after object
short int GetClearMode() const { return m_clearMode; }
void SetClearMode(short int mode) { m_clearMode = mode; m_flags |= wxTEXT_BOX_ATTR_CLEAR; }
bool HasClearMode() const { return HasFlag(wxTEXT_BOX_ATTR_CLEAR); }
// Whether to collapse borders
int GetCollapseBorders() const { return m_collapseMode ; }
void SetCollapseBorders(int collapse) { m_collapseMode = collapse; m_flags |= wxTEXT_BOX_ATTR_COLLAPSE_BORDERS; }
bool HasCollapseBorders() const { return HasFlag(wxTEXT_BOX_ATTR_COLLAPSE_BORDERS); }
// Margins
wxTextAttrDimension& GetLeftMargin() { return m_margins.m_left; }
const wxTextAttrDimension& GetLeftMargin() const { return m_margins.m_left; }
wxTextAttrDimension& GetRightMargin() { return m_margins.m_right; }
const wxTextAttrDimension& GetRightMargin() const { return m_margins.m_right; }
wxTextAttrDimension& GetTopMargin() { return m_margins.m_top; }
const wxTextAttrDimension& GetTopMargin() const { return m_margins.m_top; }
wxTextAttrDimension& GetBottomMargin() { return m_margins.m_bottom; }
const wxTextAttrDimension& GetBottomMargin() const { return m_margins.m_bottom; }
// Position
wxTextAttrDimension& GetLeft() { return m_position.m_left; }
const wxTextAttrDimension& GetLeft() const { return m_position.m_left; }
wxTextAttrDimension& GetRight() { return m_position.m_right; }
const wxTextAttrDimension& GetRight() const { return m_position.m_right; }
wxTextAttrDimension& GetTop() { return m_position.m_top; }
const wxTextAttrDimension& GetTop() const { return m_position.m_top; }
wxTextAttrDimension& GetBottom() { return m_position.m_bottom; }
const wxTextAttrDimension& GetBottom() const { return m_position.m_bottom; }
// Padding
wxTextAttrDimension& GetLeftPadding() { return m_padding.m_left; }
const wxTextAttrDimension& GetLeftPadding() const { return m_padding.m_left; }
wxTextAttrDimension& GetRightPadding() { return m_padding.m_right; }
const wxTextAttrDimension& GetRightPadding() const { return m_padding.m_right; }
wxTextAttrDimension& GetTopPadding() { return m_padding.m_top; }
const wxTextAttrDimension& GetTopPadding() const { return m_padding.m_top; }
wxTextAttrDimension& GetBottomPadding() { return m_padding.m_bottom; }
const wxTextAttrDimension& GetBottomPadding() const { return m_padding.m_bottom; }
// Border
wxTextBoxAttrBorders& GetBorder() { return m_border; }
const wxTextBoxAttrBorders& GetBorder() const { return m_border; }
wxTextBoxAttrBorder& GetLeftBorder() { return m_border.m_left; }
const wxTextBoxAttrBorder& GetLeftBorder() const { return m_border.m_left; }
wxTextBoxAttrBorder& GetTopBorder() { return m_border.m_top; }
const wxTextBoxAttrBorder& GetTopBorder() const { return m_border.m_top; }
wxTextBoxAttrBorder& GetRightBorder() { return m_border.m_right; }
const wxTextBoxAttrBorder& GetRightBorder() const { return m_border.m_right; }
wxTextBoxAttrBorder& GetBottomBorder() { return m_border.m_bottom; }
const wxTextBoxAttrBorder& GetBottomBorder() const { return m_border.m_bottom; }
// Outline
wxTextBoxAttrBorders& GetOutline() { return m_outline; }
const wxTextBoxAttrBorders& GetOutline() const { return m_outline; }
wxTextBoxAttrBorder& GetLeftOutline() { return m_outline.m_left; }
const wxTextBoxAttrBorder& GetLeftOutline() const { return m_outline.m_left; }
wxTextBoxAttrBorder& GetTopOutline() { return m_outline.m_top; }
const wxTextBoxAttrBorder& GetTopOutline() const { return m_outline.m_top; }
wxTextBoxAttrBorder& GetRightOutline() { return m_outline.m_right; }
const wxTextBoxAttrBorder& GetRightOutline() const { return m_outline.m_right; }
wxTextBoxAttrBorder& GetBottomOutline() { return m_outline.m_bottom; }
const wxTextBoxAttrBorder& GetBottomOutline() const { return m_outline.m_bottom; }
// Width and height
wxTextAttrDimension& GetWidth() { return m_width; }
const wxTextAttrDimension& GetWidth() const { return m_width; }
wxTextAttrDimension& GetHeight() { return m_height; }
const wxTextAttrDimension& GetHeight() const { return m_height; }
public:
int m_flags;
wxTextBoxAttrDimensions m_margins;
wxTextBoxAttrDimensions m_padding;
wxTextBoxAttrDimensions m_position;
wxTextAttrDimension m_width;
wxTextAttrDimension m_height;
wxTextBoxAttrBorders m_border;
wxTextBoxAttrBorders m_outline;
short int m_floatMode;
short int m_clearMode;
short int m_collapseMode;
};
// ----------------------------------------------------------------------------
// wxRichTextAttr: an enhanced attribute
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_RICHTEXT wxRichTextAttr: public wxTextAttr
{
public:
wxRichTextAttr(const wxTextAttr& attr) { wxTextAttr::Copy(attr); }
wxRichTextAttr(const wxRichTextAttr& attr) { Copy(attr); }
wxRichTextAttr() {}
// Copy
void Copy(const wxRichTextAttr& attr);
// Assignment
void operator=(const wxRichTextAttr& attr) { Copy(attr); }
void operator=(const wxTextAttr& attr) { wxTextAttr::Copy(attr); }
// Equality test
bool operator==(const wxRichTextAttr& attr) const;
// Partial equality test taking comparison object into account
bool EqPartial(const wxRichTextAttr& attr) const;
// Merges the given attributes. If compareWith
// is non-NULL, then it will be used to mask out those attributes that are the same in style
// and compareWith, for situations where we don't want to explicitly set inherited attributes.
bool Apply(const wxRichTextAttr& style, const wxRichTextAttr* compareWith = NULL);
// Collects the attributes that are common to a range of content, building up a note of
// which attributes are absent in some objects and which clash in some objects.
void CollectCommonAttributes(const wxRichTextAttr& attr, wxRichTextAttr& clashingAttr, wxRichTextAttr& absentAttr);
// Remove specified attributes from this object
bool RemoveStyle(const wxRichTextAttr& attr);
wxTextBoxAttr& GetTextBoxAttr() { return m_textBoxAttr; }
const wxTextBoxAttr& GetTextBoxAttr() const { return m_textBoxAttr; }
void SetTextBoxAttr(const wxTextBoxAttr& attr) { m_textBoxAttr = attr; }
wxTextBoxAttr m_textBoxAttr;
};
/*!
@ -313,7 +717,7 @@ public:
bool IsOk() const { return m_refData != NULL; }
wxFont FindFont(const wxTextAttr& fontSpec);
wxFont FindFont(const wxRichTextAttr& fontSpec);
void Clear();
void operator= (const wxRichTextFontTable& table);
@ -453,7 +857,7 @@ public:
// virtual bool IsPlaceHolding() const { return false; }
/// Floating direction
virtual int GetFloatDirection() const { return wxRICHTEXT_FLOAT_NONE; }
virtual int GetFloatDirection() const { return wxTEXT_BOX_ATTR_FLOAT_NONE; }
/// Get any text in this object for the given range
virtual wxString GetTextForRange(const wxRichTextRange& WXUNUSED(range)) const { return wxEmptyString; }
@ -514,9 +918,9 @@ public:
virtual int GetBottomMargin() const { return m_bottomMargin; }
/// Set attributes object
void SetAttributes(const wxTextAttr& attr) { m_attributes = attr; }
const wxTextAttr& GetAttributes() const { return m_attributes; }
wxTextAttr& GetAttributes() { return m_attributes; }
void SetAttributes(const wxRichTextAttr& attr) { m_attributes = attr; }
const wxRichTextAttr& GetAttributes() const { return m_attributes; }
wxRichTextAttr& GetAttributes() { return m_attributes; }
/// Set/get stored descent
void SetDescent(int descent) { m_descent = descent; }
@ -542,6 +946,10 @@ public:
int ConvertTenthsMMToPixels(wxDC& dc, int units) const;
static int ConvertTenthsMMToPixels(int ppi, int units);
/// Convert units in pixels to tenths of a millimetre
int ConvertPixelsToTenthsMM(wxDC& dc, int pixels) const;
static int ConvertPixelsToTenthsMM(int ppi, int pixels);
protected:
wxSize m_size;
wxPoint m_pos;
@ -560,7 +968,7 @@ protected:
int m_bottomMargin;
/// Attributes
wxTextAttr m_attributes;
wxRichTextAttr m_attributes;
};
WX_DECLARE_LIST_WITH_DECL( wxRichTextObject, wxRichTextObjectList, class WXDLLIMPEXP_RICHTEXT );
@ -758,13 +1166,13 @@ public:
virtual void Reset();
/// Convenience function to add a paragraph of text
virtual wxRichTextRange AddParagraph(const wxString& text, wxTextAttr* paraStyle = NULL);
virtual wxRichTextRange AddParagraph(const wxString& text, wxRichTextAttr* paraStyle = NULL);
/// Convenience function to add an image
virtual wxRichTextRange AddImage(const wxImage& image, wxTextAttr* paraStyle = NULL);
virtual wxRichTextRange AddImage(const wxImage& image, wxRichTextAttr* paraStyle = NULL);
/// Adds multiple paragraphs, based on newlines.
virtual wxRichTextRange AddParagraphs(const wxString& text, wxTextAttr* paraStyle = NULL);
virtual wxRichTextRange AddParagraphs(const wxString& text, wxRichTextAttr* paraStyle = NULL);
/// Get the line at the given position. If caretPosition is true, the position is
/// a caret position, which is normally a smaller number.
@ -818,28 +1226,28 @@ public:
virtual bool PositionToXY(long pos, long* x, long* y) const;
/// Set text attributes: character and/or paragraph styles.
virtual bool SetStyle(const wxRichTextRange& range, const wxTextAttr& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO);
virtual bool SetStyle(const wxRichTextRange& range, const wxRichTextAttr& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO);
/// Set image attribute
void SetImageStyle(wxRichTextImage *image, const wxRichTextAnchoredObjectAttr& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO);
void SetImageStyle(wxRichTextImage *image, const wxRichTextAttr& textAttr, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO);
/// Get the conbined text attributes for this position.
virtual bool GetStyle(long position, wxTextAttr& style);
virtual bool GetStyle(long position, wxRichTextAttr& style);
/// Get the content (uncombined) attributes for this position.
virtual bool GetUncombinedStyle(long position, wxTextAttr& style);
virtual bool GetUncombinedStyle(long position, wxRichTextAttr& style);
/// Implementation helper for GetStyle. If combineStyles is true, combine base, paragraph and
/// context attributes.
virtual bool DoGetStyle(long position, wxTextAttr& style, bool combineStyles = true);
virtual bool DoGetStyle(long position, wxRichTextAttr& style, bool combineStyles = true);
/// Get the combined style for a range - if any attribute is different within the range,
/// that attribute is not present within the flags
virtual bool GetStyleForRange(const wxRichTextRange& range, wxTextAttr& style);
virtual bool GetStyleForRange(const wxRichTextRange& range, wxRichTextAttr& style);
/// Combines 'style' with 'currentStyle' for the purpose of summarising the attributes of a range of
/// content.
bool CollectStyle(wxTextAttr& currentStyle, const wxTextAttr& style, long& multipleStyleAttributes, int& multipleTextEffectAttributes, int& absentStyleAttributes, int& absentTextEffectAttributes);
bool CollectStyle(wxRichTextAttr& currentStyle, const wxRichTextAttr& style, wxRichTextAttr& clashingAttr, wxRichTextAttr& absentAttr);
/// Set list style
virtual bool SetListStyle(const wxRichTextRange& range, wxRichTextListStyleDefinition* def, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1);
@ -863,19 +1271,19 @@ public:
virtual bool DoNumberList(const wxRichTextRange& range, const wxRichTextRange& promotionRange, int promoteBy, wxRichTextListStyleDefinition* def, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1);
/// Fills in the attributes for numbering a paragraph after previousParagraph.
virtual bool FindNextParagraphNumber(wxRichTextParagraph* previousParagraph, wxTextAttr& attr) const;
virtual bool FindNextParagraphNumber(wxRichTextParagraph* previousParagraph, wxRichTextAttr& attr) const;
/// Test if this whole range has character attributes of the specified kind. If any
/// of the attributes are different within the range, the test fails. You
/// can use this to implement, for example, bold button updating. style must have
/// flags indicating which attributes are of interest.
virtual bool HasCharacterAttributes(const wxRichTextRange& range, const wxTextAttr& style) const;
virtual bool HasCharacterAttributes(const wxRichTextRange& range, const wxRichTextAttr& style) const;
/// Test if this whole range has paragraph attributes of the specified kind. If any
/// of the attributes are different within the range, the test fails. You
/// can use this to implement, for example, centering button updating. style must have
/// flags indicating which attributes are of interest.
virtual bool HasParagraphAttributes(const wxRichTextRange& range, const wxTextAttr& style) const;
virtual bool HasParagraphAttributes(const wxRichTextRange& range, const wxRichTextAttr& style) const;
/// Clone
virtual wxRichTextObject* Clone() const { return new wxRichTextParagraphLayoutBox(*this); }
@ -905,16 +1313,16 @@ public:
/// Set default style for new content. Setting it to a default attribute
/// makes new content take on the 'basic' style.
virtual bool SetDefaultStyle(const wxTextAttr& style);
virtual bool SetDefaultStyle(const wxRichTextAttr& style);
/// Get default style
virtual const wxTextAttr& GetDefaultStyle() const { return m_defaultAttributes; }
virtual const wxRichTextAttr& GetDefaultStyle() const { return m_defaultAttributes; }
/// Set basic (overall) style
virtual void SetBasicStyle(const wxTextAttr& style) { m_attributes = style; }
virtual void SetBasicStyle(const wxRichTextAttr& style) { m_attributes = style; }
/// Get basic (overall) style
virtual const wxTextAttr& GetBasicStyle() const { return m_attributes; }
virtual const wxRichTextAttr& GetBasicStyle() const { return m_attributes; }
/// Invalidate the buffer. With no argument, invalidates whole buffer.
void Invalidate(const wxRichTextRange& invalidRange = wxRICHTEXT_ALL);
@ -932,7 +1340,7 @@ public:
protected:
wxRichTextCtrl* m_ctrl;
wxTextAttr m_defaultAttributes;
wxRichTextAttr m_defaultAttributes;
/// The invalidated range that will need full layout
wxRichTextRange m_invalidRange;
@ -1046,8 +1454,8 @@ class WXDLLIMPEXP_RICHTEXT wxRichTextParagraph: public wxRichTextBox
public:
// Constructors
wxRichTextParagraph(wxRichTextObject* parent = NULL, wxTextAttr* style = NULL);
wxRichTextParagraph(const wxString& text, wxRichTextObject* parent = NULL, wxTextAttr* paraStyle = NULL, wxTextAttr* charStyle = NULL);
wxRichTextParagraph(wxRichTextObject* parent = NULL, wxRichTextAttr* style = NULL);
wxRichTextParagraph(const wxString& text, wxRichTextObject* parent = NULL, wxRichTextAttr* paraStyle = NULL, wxRichTextAttr* charStyle = NULL);
virtual ~wxRichTextParagraph();
wxRichTextParagraph(const wxRichTextParagraph& obj): wxRichTextBox() { Copy(obj); }
@ -1092,7 +1500,7 @@ public:
// Implementation
/// Apply paragraph styles such as centering to the wrapped lines
virtual void ApplyParagraphStyle(const wxTextAttr& attr, const wxRect& rect, wxDC& dc);
virtual void ApplyParagraphStyle(const wxRichTextAttr& attr, const wxRect& rect, wxDC& dc);
/// Insert text at the given position
virtual bool InsertText(long pos, const wxString& text);
@ -1129,10 +1537,10 @@ public:
/// Get combined attributes of the base style, paragraph style and character style. We use this to dynamically
/// retrieve the actual style.
wxTextAttr GetCombinedAttributes(const wxTextAttr& contentStyle) const;
wxRichTextAttr GetCombinedAttributes(const wxRichTextAttr& contentStyle) const;
/// Get combined attributes of the base style and paragraph style.
wxTextAttr GetCombinedAttributes() const;
wxRichTextAttr GetCombinedAttributes() const;
/// Get the first position from pos that has a line break character.
long GetFirstLineBreakPosition(long pos);
@ -1170,7 +1578,7 @@ class WXDLLIMPEXP_RICHTEXT wxRichTextPlainText: public wxRichTextObject
public:
// Constructors
wxRichTextPlainText(const wxString& text = wxEmptyString, wxRichTextObject* parent = NULL, wxTextAttr* style = NULL);
wxRichTextPlainText(const wxString& text = wxEmptyString, wxRichTextObject* parent = NULL, wxRichTextAttr* style = NULL);
wxRichTextPlainText(const wxRichTextPlainText& obj): wxRichTextObject() { Copy(obj); }
// Overrideables
@ -1230,7 +1638,7 @@ public:
/// Clone
virtual wxRichTextObject* Clone() const { return new wxRichTextPlainText(*this); }
private:
bool DrawTabbedString(wxDC& dc, const wxTextAttr& attr, const wxRect& rect, wxString& str, wxCoord& x, wxCoord& y, bool selected);
bool DrawTabbedString(wxDC& dc, const wxRichTextAttr& attr, const wxRect& rect, wxString& str, wxCoord& x, wxCoord& y, bool selected);
protected:
wxString m_text;
@ -1334,7 +1742,7 @@ class WXDLLIMPEXP_RICHTEXT wxRichTextAnchoredObject: public wxRichTextObject
DECLARE_CLASS(wxRichTextAnchoredObject)
public:
// Constructors
wxRichTextAnchoredObject(wxRichTextObject* parent = NULL, const wxRichTextAnchoredObjectAttr& attr = wxRichTextAnchoredObjectAttr());
wxRichTextAnchoredObject(wxRichTextObject* parent = NULL, const wxRichTextAttr& attr = wxRichTextAttr());
wxRichTextAnchoredObject(const wxRichTextAnchoredObject& obj) : wxRichTextObject(obj) /* , m_ph(NULL) */ { Copy(obj); }
~wxRichTextAnchoredObject();
@ -1342,16 +1750,14 @@ public:
virtual bool IsFloatable() const { return true; }
/// Whether this object is currently floating
virtual bool IsFloating() const { return m_anchoredAttr.m_floating != wxRICHTEXT_FLOAT_NONE; }
virtual bool IsFloating() const { return GetAttributes().GetTextBoxAttr().IsFloating(); }
virtual void SetParent(wxRichTextObject* parent);
// Accessors
const wxRichTextAnchoredObjectAttr& GetAnchoredAttr() const { return m_anchoredAttr; }
void SetAnchoredAttr(const wxRichTextAnchoredObjectAttr& attr);
/// The floating direction
virtual int GetFloatDirection() const { return m_anchoredAttr.m_floating; }
virtual int GetFloatDirection() const { return GetAttributes().GetTextBoxAttr().GetFloatMode(); }
void operator=(const wxRichTextAnchoredObject&) { wxASSERT("Nobody can reset this object using ="); }
@ -1359,7 +1765,7 @@ public:
void Copy(const wxRichTextAnchoredObject& obj);
protected:
wxRichTextAnchoredObjectAttr m_anchoredAttr;
};
/*!
@ -1374,8 +1780,8 @@ public:
// Constructors
wxRichTextImage(wxRichTextObject* parent = NULL): wxRichTextAnchoredObject(parent) { }
wxRichTextImage(const wxImage& image, wxRichTextObject* parent = NULL, wxTextAttr* charStyle = NULL);
wxRichTextImage(const wxRichTextImageBlock& imageBlock, wxRichTextObject* parent = NULL, wxTextAttr* charStyle = NULL);
wxRichTextImage(const wxImage& image, wxRichTextObject* parent = NULL, wxRichTextAttr* charStyle = NULL);
wxRichTextImage(const wxRichTextImageBlock& imageBlock, wxRichTextObject* parent = NULL, wxRichTextAttr* charStyle = NULL);
wxRichTextImage(const wxRichTextImage& obj): wxRichTextAnchoredObject(obj) { Copy(obj); }
// Overrideables
@ -1498,7 +1904,7 @@ public:
int GetHandlerFlags() const { return m_handlerFlags; }
/// Convenience function to add a paragraph of text
virtual wxRichTextRange AddParagraph(const wxString& text, wxTextAttr* paraStyle = NULL) { Modify(); return wxRichTextParagraphLayoutBox::AddParagraph(text, paraStyle); }
virtual wxRichTextRange AddParagraph(const wxString& text, wxRichTextAttr* paraStyle = NULL) { Modify(); return wxRichTextParagraphLayoutBox::AddParagraph(text, paraStyle); }
/// Begin collapsing undo/redo commands. Note that this may not work properly
/// if combining commands that delete or insert content, changing ranges for
@ -1539,7 +1945,7 @@ public:
virtual bool CanPasteFromClipboard() const;
/// Begin using a style
virtual bool BeginStyle(const wxTextAttr& style);
virtual bool BeginStyle(const wxRichTextAttr& style);
/// End the style
virtual bool EndStyle();
@ -1694,7 +2100,8 @@ public:
bool InsertNewlineWithUndo(long pos, wxRichTextCtrl* ctrl, int flags = 0);
/// Submit command to insert the given image
bool InsertImageWithUndo(long pos, const wxRichTextImageBlock& imageBlock, wxRichTextCtrl* ctrl, int flags = 0, const wxRichTextAnchoredObjectAttr& floatAttr = wxRichTextAnchoredObjectAttr());
bool InsertImageWithUndo(long pos, const wxRichTextImageBlock& imageBlock, wxRichTextCtrl* ctrl, int flags = 0,
const wxRichTextAttr& textAttr = wxRichTextAttr());
/// Submit command to insert an object
bool InsertObjectWithUndo(long pos, wxRichTextObject *object, wxRichTextCtrl* ctrl, int flags);
@ -1709,7 +2116,7 @@ public:
/// Get the style that is appropriate for a new paragraph at this position.
/// If the previous paragraph has a paragraph style name, look up the next-paragraph
/// style.
wxTextAttr GetStyleForNewParagraph(long pos, bool caretPosition = false, bool lookUpNewParaStyle=false) const;
wxRichTextAttr GetStyleForNewParagraph(long pos, bool caretPosition = false, bool lookUpNewParaStyle=false) const;
/// Dumps contents of buffer for debugging purposes
virtual void Dump();
@ -2113,13 +2520,13 @@ public:
virtual ~wxRichTextRenderer() {}
/// Draw a standard bullet, as specified by the value of GetBulletName
virtual bool DrawStandardBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttr& attr, const wxRect& rect) = 0;
virtual bool DrawStandardBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxRichTextAttr& attr, const wxRect& rect) = 0;
/// Draw a bullet that can be described by text, such as numbered or symbol bullets
virtual bool DrawTextBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttr& attr, const wxRect& rect, const wxString& text) = 0;
virtual bool DrawTextBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxRichTextAttr& attr, const wxRect& rect, const wxString& text) = 0;
/// Draw a bitmap bullet, where the bullet bitmap is specified by the value of GetBulletName
virtual bool DrawBitmapBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttr& attr, const wxRect& rect) = 0;
virtual bool DrawBitmapBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxRichTextAttr& attr, const wxRect& rect) = 0;
/// Enumerate the standard bullet names currently supported
virtual bool EnumerateStandardBulletNames(wxArrayString& bulletNames) = 0;
@ -2135,13 +2542,13 @@ public:
wxRichTextStdRenderer() {}
/// Draw a standard bullet, as specified by the value of GetBulletName
virtual bool DrawStandardBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttr& attr, const wxRect& rect);
virtual bool DrawStandardBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxRichTextAttr& attr, const wxRect& rect);
/// Draw a bullet that can be described by text, such as numbered or symbol bullets
virtual bool DrawTextBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttr& attr, const wxRect& rect, const wxString& text);
virtual bool DrawTextBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxRichTextAttr& attr, const wxRect& rect, const wxString& text);
/// Draw a bitmap bullet, where the bullet bitmap is specified by the value of GetBulletName
virtual bool DrawBitmapBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttr& attr, const wxRect& rect);
virtual bool DrawBitmapBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxRichTextAttr& attr, const wxRect& rect);
/// Enumerate the standard bullet names currently supported
virtual bool EnumerateStandardBulletNames(wxArrayString& bulletNames);
@ -2158,18 +2565,18 @@ inline bool wxRichTextHasStyle(int flags, int style)
}
/// Compare two attribute objects
WXDLLIMPEXP_RICHTEXT bool wxTextAttrEq(const wxTextAttr& attr1, const wxTextAttr& attr2);
WXDLLIMPEXP_RICHTEXT bool wxTextAttrEq(const wxTextAttr& attr1, const wxTextAttr& attr2);
WXDLLIMPEXP_RICHTEXT bool wxTextAttrEq(const wxRichTextAttr& attr1, const wxRichTextAttr& attr2);
WXDLLIMPEXP_RICHTEXT bool wxTextAttrEq(const wxRichTextAttr& attr1, const wxRichTextAttr& attr2);
/// Compare two attribute objects, but take into account the flags
/// specifying attributes of interest.
WXDLLIMPEXP_RICHTEXT bool wxTextAttrEqPartial(const wxTextAttr& attr1, const wxTextAttr& attr2, int flags);
WXDLLIMPEXP_RICHTEXT bool wxTextAttrEqPartial(const wxRichTextAttr& attr1, const wxRichTextAttr& attr2);
/// Apply one style to another
WXDLLIMPEXP_RICHTEXT bool wxRichTextApplyStyle(wxTextAttr& destStyle, const wxTextAttr& style, wxTextAttr* compareWith = NULL);
WXDLLIMPEXP_RICHTEXT bool wxRichTextApplyStyle(wxRichTextAttr& destStyle, const wxRichTextAttr& style, wxRichTextAttr* compareWith = NULL);
// Remove attributes
WXDLLIMPEXP_RICHTEXT bool wxRichTextRemoveStyle(wxTextAttr& destStyle, const wxTextAttr& style);
WXDLLIMPEXP_RICHTEXT bool wxRichTextRemoveStyle(wxRichTextAttr& destStyle, const wxRichTextAttr& style);
/// Combine two bitlists
WXDLLIMPEXP_RICHTEXT bool wxRichTextCombineBitlists(int& valueA, int valueB, int& flagsA, int flagsB);
@ -2178,7 +2585,7 @@ WXDLLIMPEXP_RICHTEXT bool wxRichTextCombineBitlists(int& valueA, int valueB, int
WXDLLIMPEXP_RICHTEXT bool wxRichTextBitlistsEqPartial(int valueA, int valueB, int flags);
/// Split into paragraph and character styles
WXDLLIMPEXP_RICHTEXT bool wxRichTextSplitParaCharStyles(const wxTextAttr& style, wxTextAttr& parStyle, wxTextAttr& charStyle);
WXDLLIMPEXP_RICHTEXT bool wxRichTextSplitParaCharStyles(const wxRichTextAttr& style, wxRichTextAttr& parStyle, wxRichTextAttr& charStyle);
/// Compare tabs
WXDLLIMPEXP_RICHTEXT bool wxRichTextTabsEq(const wxArrayInt& tabs1, const wxArrayInt& tabs2);
@ -2186,6 +2593,10 @@ WXDLLIMPEXP_RICHTEXT bool wxRichTextTabsEq(const wxArrayInt& tabs1, const wxArra
/// Convert a decimal to Roman numerals
WXDLLIMPEXP_RICHTEXT wxString wxRichTextDecimalToRoman(long n);
// Collects the attributes that are common to a range of content, building up a note of
// which attributes are absent in some objects and which clash in some objects.
WXDLLIMPEXP_RICHTEXT void wxTextAttrCollectCommonAttributes(wxTextAttr& currentStyle, const wxTextAttr& attr, wxTextAttr& clashingAttr, wxTextAttr& absentAttr);
WXDLLIMPEXP_RICHTEXT void wxRichTextModuleInit();
#endif

View File

@ -69,7 +69,7 @@ public:
virtual bool TransferDataToWindow();
/// Gets the attributes associated with the main formatting dialog
wxTextAttr* GetAttributes();
wxRichTextAttr* GetAttributes();
/// Update for symbol-related controls
void OnSymbolUpdate( wxUpdateUIEvent& event );

View File

@ -86,7 +86,8 @@ class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextStyleDefinition;
* wxRichTextCtrl class declaration
*/
class WXDLLIMPEXP_RICHTEXT wxRichTextCtrl : public wxTextCtrlBase,
class WXDLLIMPEXP_RICHTEXT wxRichTextCtrl : public wxControl,
public wxTextCtrlIface,
public wxScrollHelper
{
DECLARE_CLASS( wxRichTextCtrl )
@ -200,6 +201,9 @@ public:
virtual bool DoSaveFile(const wxString& file = wxEmptyString,
int fileType = wxRICHTEXT_TYPE_ANY);
// implement the wxTextEntry pure virtual method
virtual wxWindow *GetEditableWindow() { return this; }
/// Set the handler flags, controlling loading and saving
void SetHandlerFlags(int flags) { GetBuffer().SetHandlerFlags(flags); }
@ -223,27 +227,32 @@ public:
// methods allow to apply the given text style to the given selection or to
// set/get the style which will be used for all appended text
virtual bool SetStyle(long start, long end, const wxTextAttr& style);
virtual bool SetStyle(long start, long end, const wxRichTextAttr& style);
virtual bool SetStyle(const wxRichTextRange& range, const wxTextAttr& style);
virtual bool SetStyle(const wxRichTextRange& range, const wxRichTextAttr& style);
virtual bool GetStyle(long position, wxTextAttr& style);
virtual bool GetStyle(long position, wxRichTextAttr& style);
// Set an image style
void SetImageStyle(wxRichTextImage *image, const wxRichTextAnchoredObjectAttr& style);
void SetImageStyle(wxRichTextImage *image, const wxRichTextAttr& textAttr);
// get the common set of styles for the range
virtual bool GetStyleForRange(const wxRichTextRange& range, wxTextAttr& style);
virtual bool GetStyleForRange(const wxRichTextRange& range, wxRichTextAttr& style);
// extended style setting operation with flags including:
// wxRICHTEXT_SETSTYLE_WITH_UNDO, wxRICHTEXT_SETSTYLE_OPTIMIZE, wxRICHTEXT_SETSTYLE_PARAGRAPHS_ONLY, wxRICHTEXT_SETSTYLE_CHARACTERS_ONLY
// see richtextbuffer.h for more details.
virtual bool SetStyleEx(const wxRichTextRange& range, const wxTextAttr& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO);
virtual bool SetStyleEx(const wxRichTextRange& range, const wxRichTextAttr& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO);
/// Get the content (uncombined) attributes for this position.
virtual bool GetUncombinedStyle(long position, wxTextAttr& style);
virtual bool GetUncombinedStyle(long position, wxRichTextAttr& style);
virtual bool SetDefaultStyle(const wxTextAttr& style);
virtual bool SetDefaultStyle(const wxRichTextAttr& style);
virtual const wxTextAttr& GetDefaultStyleEx() const { return GetDefaultStyle(); }
virtual const wxRichTextAttr& GetDefaultStyleEx() const;
virtual const wxTextAttr& GetDefaultStyle() const;
//virtual const wxTextAttr& GetDefaultStyle() const;
/// Set list style
virtual bool SetListStyle(const wxRichTextRange& range, wxRichTextListStyleDefinition* def, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1);
@ -316,17 +325,21 @@ public:
/// Write an image at the current insertion point. Supply optional type to use
/// for internal and file storage of the raw data.
virtual bool WriteImage(const wxImage& image, wxBitmapType bitmapType = wxBITMAP_TYPE_PNG, const wxRichTextAnchoredObjectAttr& attr = wxRichTextAnchoredObjectAttr());
virtual bool WriteImage(const wxImage& image, wxBitmapType bitmapType = wxBITMAP_TYPE_PNG,
const wxRichTextAttr& textAttr = wxRichTextAttr());
/// Write a bitmap at the current insertion point. Supply optional type to use
/// for internal and file storage of the raw data.
virtual bool WriteImage(const wxBitmap& bitmap, wxBitmapType bitmapType = wxBITMAP_TYPE_PNG, const wxRichTextAnchoredObjectAttr& attr = wxRichTextAnchoredObjectAttr());
virtual bool WriteImage(const wxBitmap& bitmap, wxBitmapType bitmapType = wxBITMAP_TYPE_PNG,
const wxRichTextAttr& textAttr = wxRichTextAttr());
/// Load an image from file and write at the current insertion point.
virtual bool WriteImage(const wxString& filename, wxBitmapType bitmapType, const wxRichTextAnchoredObjectAttr& attr = wxRichTextAnchoredObjectAttr());
virtual bool WriteImage(const wxString& filename, wxBitmapType bitmapType,
const wxRichTextAttr& textAttr = wxRichTextAttr());
/// Write an image block at the current insertion point.
virtual bool WriteImage(const wxRichTextImageBlock& imageBlock, const wxRichTextAnchoredObjectAttr& attr = wxRichTextAnchoredObjectAttr());
virtual bool WriteImage(const wxRichTextImageBlock& imageBlock,
const wxRichTextAttr& textAttr = wxRichTextAttr());
/// Insert a newline (actually paragraph) at the current insertion point.
virtual bool Newline();
@ -335,12 +348,12 @@ public:
virtual bool LineBreak();
/// Set basic (overall) style
virtual void SetBasicStyle(const wxTextAttr& style) { GetBuffer().SetBasicStyle(style); }
virtual void SetBasicStyle(const wxRichTextAttr& style) { GetBuffer().SetBasicStyle(style); }
/// Get basic (overall) style
virtual const wxTextAttr& GetBasicStyle() const { return GetBuffer().GetBasicStyle(); }
virtual const wxRichTextAttr& GetBasicStyle() const { return GetBuffer().GetBasicStyle(); }
virtual bool BeginStyle(const wxTextAttr& style) { return GetBuffer().BeginStyle(style); }
virtual bool BeginStyle(const wxRichTextAttr& style) { return GetBuffer().BeginStyle(style); }
/// End the style
virtual bool EndStyle() { return GetBuffer().EndStyle(); }
@ -561,7 +574,7 @@ public:
/// of the attributes are different within the range, the test fails. You
/// can use this to implement, for example, bold button updating. style must have
/// flags indicating which attributes are of interest.
virtual bool HasCharacterAttributes(const wxRichTextRange& range, const wxTextAttr& style) const
virtual bool HasCharacterAttributes(const wxRichTextRange& range, const wxRichTextAttr& style) const
{
return GetBuffer().HasCharacterAttributes(range.ToInternal(), style);
}
@ -570,7 +583,7 @@ public:
/// of the attributes are different within the range, the test fails. You
/// can use this to implement, for example, centering button updating. style must have
/// flags indicating which attributes are of interest.
virtual bool HasParagraphAttributes(const wxRichTextRange& range, const wxTextAttr& style) const
virtual bool HasParagraphAttributes(const wxRichTextRange& range, const wxRichTextAttr& style) const
{
return GetBuffer().HasParagraphAttributes(range.ToInternal(), style);
}
@ -791,7 +804,7 @@ public:
/// Convenience function that tells the control to start reflecting the default
/// style, since the user is changing it.
void SetAndShowDefaultStyle(const wxTextAttr& attr)
void SetAndShowDefaultStyle(const wxRichTextAttr& attr)
{
SetDefaultStyle(attr);
SetCaretPositionForDefaultStyle(GetCaretPosition());

View File

@ -75,7 +75,7 @@ public:
void OnColourClicked( wxCommandEvent& event );
/// Gets the attributes associated with the main formatting dialog
wxTextAttr* GetAttributes();
wxRichTextAttr* GetAttributes();
////@begin wxRichTextFontPage event handler declarations

View File

@ -138,7 +138,7 @@ public:
virtual bool GetStyle(wxRichTextCtrl* ctrl, const wxRichTextRange& range);
/// Set the attributes and optionally update the display
virtual bool SetStyle(const wxTextAttr& style, bool update = true);
virtual bool SetStyle(const wxRichTextAttr& style, bool update = true);
/// Set the style definition and optionally update the display
virtual bool SetStyleDefinition(const wxRichTextStyleDefinition& styleDef, wxRichTextStyleSheet* sheet, bool update = true);
@ -156,9 +156,9 @@ public:
virtual bool ApplyStyle(wxRichTextCtrl* ctrl, const wxRichTextRange& range, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO|wxRICHTEXT_SETSTYLE_OPTIMIZE);
/// Gets and sets the attributes
const wxTextAttr& GetAttributes() const { return m_attributes; }
wxTextAttr& GetAttributes() { return m_attributes; }
void SetAttributes(const wxTextAttr& attr) { m_attributes = attr; }
const wxRichTextAttr& GetAttributes() const { return m_attributes; }
wxRichTextAttr& GetAttributes() { return m_attributes; }
void SetAttributes(const wxRichTextAttr& attr) { m_attributes = attr; }
/// Transfers the data and from to the window
virtual bool TransferDataToWindow();
@ -183,7 +183,7 @@ public:
static wxRichTextFormattingDialog* GetDialog(wxWindow* win);
/// Helper for pages to get the attributes
static wxTextAttr* GetDialogAttributes(wxWindow* win);
static wxRichTextAttr* GetDialogAttributes(wxWindow* win);
/// Helper for pages to get the style
static wxRichTextStyleDefinition* GetDialogStyleDefinition(wxWindow* win);
@ -200,7 +200,7 @@ public:
protected:
wxImageList* m_imageList;
wxTextAttr m_attributes;
wxRichTextAttr m_attributes;
wxRichTextStyleDefinition* m_styleDefinition;
wxRichTextStyleSheet* m_styleSheet;
wxArrayInt m_pageIds; // mapping of book control indexes to page ids

View File

@ -80,15 +80,15 @@ protected:
virtual bool DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream);
/// Output character formatting
void BeginCharacterFormatting(const wxTextAttr& currentStyle, const wxTextAttr& thisStyle, const wxTextAttr& paraStyle, wxTextOutputStream& stream );
void EndCharacterFormatting(const wxTextAttr& currentStyle, const wxTextAttr& thisStyle, const wxTextAttr& paraStyle, wxTextOutputStream& stream );
void BeginCharacterFormatting(const wxRichTextAttr& currentStyle, const wxRichTextAttr& thisStyle, const wxRichTextAttr& paraStyle, wxTextOutputStream& stream );
void EndCharacterFormatting(const wxRichTextAttr& currentStyle, const wxRichTextAttr& thisStyle, const wxRichTextAttr& paraStyle, wxTextOutputStream& stream );
/// Output paragraph formatting
void BeginParagraphFormatting(const wxTextAttr& currentStyle, const wxTextAttr& thisStyle, wxTextOutputStream& stream);
void EndParagraphFormatting(const wxTextAttr& currentStyle, const wxTextAttr& thisStyle, wxTextOutputStream& stream);
void BeginParagraphFormatting(const wxRichTextAttr& currentStyle, const wxRichTextAttr& thisStyle, wxTextOutputStream& stream);
void EndParagraphFormatting(const wxRichTextAttr& currentStyle, const wxRichTextAttr& thisStyle, wxTextOutputStream& stream);
/// Output font tag
void OutputFont(const wxTextAttr& style, wxTextOutputStream& stream);
void OutputFont(const wxRichTextAttr& style, wxTextOutputStream& stream);
/// Closes lists to level (-1 means close all)
void CloseLists(int level, wxTextOutputStream& str);
@ -106,13 +106,13 @@ protected:
const wxChar* GetMimeType(int imageType);
/// Gets the html equivalent of the specified value
wxString GetAlignment(const wxTextAttr& thisStyle);
wxString GetAlignment(const wxRichTextAttr& thisStyle);
/// Generates   array for indentations
wxString SymbolicIndent(long indent);
/// Finds the html equivalent of the specified bullet
int TypeOfList(const wxTextAttr& thisStyle, wxString& tag);
int TypeOfList(const wxRichTextAttr& thisStyle, wxString& tag);
#endif
// Data members

View File

@ -66,6 +66,12 @@ public:
/// Creates the controls and sizers
void CreateControls();
/// Set the dimension into the value and units controls
void SetDimensionValue(wxTextAttrDimension& dim, wxTextCtrl* valueCtrl, wxComboBox* unitsCtrl);
/// Get the dimension from the value and units controls
void GetDimensionValue(wxTextAttrDimension& dim, wxTextCtrl* valueCtrl, wxComboBox* unitsCtrl);
////@begin wxRichTextImageDialog event handler declarations
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXTIMAGEDIALOG_PARA_UP
@ -89,7 +95,7 @@ public:
static bool ShowToolTips();
/// Set the image attribute
void SetImageAttr(const wxRichTextAnchoredObjectAttr& attr);
void SetImageAttr(const wxRichTextAttr& textAttr);
wxRichTextImage* ApplyImageAttr();
/// Set the anchored object
@ -101,9 +107,9 @@ private:
/// Convert CM to MM
bool ConvertFromString(const wxString& string, int& ret, int scale);
private:
wxRichTextAnchoredObjectAttr m_attr;
wxRichTextAttr m_textAttr;
////@begin wxRichTextImageDialog member variables
wxComboBox* m_alignment;
wxComboBox* m_float;
wxTextCtrl* m_width;
wxComboBox* m_unitsW;
@ -116,7 +122,6 @@ private:
/// Control identifiers
enum {
ID_WXRICHTEXTIMAGEPAGE = 10015,
ID_COMBOBOX_ALIGN = 10016,
ID_RICHTEXTIMAGEDIALOG_FLOATING_MODE = 10017,
ID_RICHTEXTIMAGEDIALOG_WIDTH = 10018,
ID_RICHTEXTIMAGEDIALOG_UNITS_W = 10019,

View File

@ -71,7 +71,7 @@ public:
void UpdatePreview();
/// Gets the attributes associated with the main formatting dialog
wxTextAttr* GetAttributes();
wxRichTextAttr* GetAttributes();
////@begin wxRichTextIndentsSpacingPage event handler declarations

View File

@ -65,7 +65,7 @@ public:
virtual bool TransferDataToWindow();
/// Get attributes for selected level
wxTextAttr* GetAttributesForSelection();
wxRichTextAttr* GetAttributesForSelection();
/// Update for symbol-related controls
void OnSymbolUpdate( wxUpdateUIEvent& event );

View File

@ -52,7 +52,7 @@ public:
virtual bool TransferDataToWindow();
/// Gets the attributes associated with the main formatting dialog
wxTextAttr* GetAttributes();
wxRichTextAttr* GetAttributes();
////@begin wxRichTextStylePage event handler declarations

View File

@ -94,18 +94,18 @@ public:
const wxString& GetBaseStyle() const { return m_baseStyle; }
/// Sets and gets the style
void SetStyle(const wxTextAttr& style) { m_style = style; }
const wxTextAttr& GetStyle() const { return m_style; }
wxTextAttr& GetStyle() { return m_style; }
void SetStyle(const wxRichTextAttr& style) { m_style = style; }
const wxRichTextAttr& GetStyle() const { return m_style; }
wxRichTextAttr& GetStyle() { return m_style; }
/// Gets the style combined with the base style
virtual wxTextAttr GetStyleMergedWithBase(const wxRichTextStyleSheet* sheet) const;
virtual wxRichTextAttr GetStyleMergedWithBase(const wxRichTextStyleSheet* sheet) const;
protected:
wxString m_name;
wxString m_baseStyle;
wxString m_description;
wxTextAttr m_style;
wxRichTextAttr m_style;
};
/*!
@ -206,9 +206,9 @@ public:
virtual wxRichTextStyleDefinition* Clone() const { return new wxRichTextListStyleDefinition(*this); }
/// Sets/gets the attributes for the given level
void SetLevelAttributes(int i, const wxTextAttr& attr);
wxTextAttr* GetLevelAttributes(int i);
const wxTextAttr* GetLevelAttributes(int i) const;
void SetLevelAttributes(int i, const wxRichTextAttr& attr);
wxRichTextAttr* GetLevelAttributes(int i);
const wxRichTextAttr* GetLevelAttributes(int i) const;
/// Convenience function for setting the major attributes for a list level specification
void SetAttributes(int i, int leftIndent, int leftSubIndent, int bulletStyle, const wxString& bulletSymbol = wxEmptyString);
@ -218,15 +218,15 @@ public:
/// Combine the base and list style with a paragraph style, using the given indent (from which
/// an appropriate level is found)
wxTextAttr CombineWithParagraphStyle(int indent, const wxTextAttr& paraStyle, wxRichTextStyleSheet* styleSheet = NULL);
wxRichTextAttr CombineWithParagraphStyle(int indent, const wxRichTextAttr& paraStyle, wxRichTextStyleSheet* styleSheet = NULL);
/// Combine the base and list style, using the given indent (from which
/// an appropriate level is found)
wxTextAttr GetCombinedStyle(int indent, wxRichTextStyleSheet* styleSheet = NULL);
wxRichTextAttr GetCombinedStyle(int indent, wxRichTextStyleSheet* styleSheet = NULL);
/// Combine the base and list style, using the given level from which
/// an appropriate level is found)
wxTextAttr GetCombinedStyleForLevel(int level, wxRichTextStyleSheet* styleSheet = NULL);
wxRichTextAttr GetCombinedStyleForLevel(int level, wxRichTextStyleSheet* styleSheet = NULL);
/// Gets the number of available levels
int GetLevelCount() const { return 10; }
@ -237,7 +237,7 @@ public:
protected:
/// The styles for each level (up to 10)
wxTextAttr m_levelStyles[10];
wxRichTextAttr m_levelStyles[10];
};
/*!

View File

@ -69,7 +69,7 @@ public:
virtual void SortTabs();
/// Gets the attributes associated with the main formatting dialog
wxTextAttr* GetAttributes();
wxRichTextAttr* GetAttributes();
////@begin wxRichTextTabsPage event handler declarations

View File

@ -45,10 +45,10 @@ public:
bool ImportStyleDefinition(wxRichTextStyleSheet* sheet, wxXmlNode* node);
/// Create style parameters
wxString CreateStyle(const wxTextAttr& attr, bool isPara = false);
wxString CreateStyle(const wxRichTextAttr& attr, bool isPara = false);
/// Get style parameters
bool GetStyle(wxTextAttr& attr, wxXmlNode* node, bool isPara = false);
bool GetStyle(wxRichTextAttr& attr, wxXmlNode* node, bool isPara = false);
#endif
/// Can we save using this handler?

View File

@ -298,8 +298,8 @@ public:
// Equality test
bool operator== (const wxTextAttr& attr) const;
// Partial equality test taking flags into account
bool EqPartial(const wxTextAttr& attr, int flags) const;
// Partial equality test
bool EqPartial(const wxTextAttr& attr) const;
// Get attributes from font.
bool GetFontAttributes(const wxFont& font, int flags = wxTEXT_ATTR_FONT);
@ -411,6 +411,8 @@ public:
bool HasOutlineLevel() const { return HasFlag(wxTEXT_ATTR_OUTLINE_LEVEL); }
bool HasFlag(long flag) const { return (m_flags & flag) != 0; }
void RemoveFlag(long flag) { m_flags &= ~flag; }
void AddFlag(long flag) { m_flags |= flag; }
// Is this a character style?
bool IsCharacterStyle() const { return HasFlag(wxTEXT_ATTR_CHARACTER); }
@ -422,11 +424,11 @@ public:
return GetFlags() == 0;
}
// Merges the given attributes. Does not affect 'this'. If compareWith
// Merges the given attributes. If compareWith
// is non-NULL, then it will be used to mask out those attributes that are the same in style
// and compareWith, for situations where we don't want to explicitly set inherited attributes.
bool Apply(const wxTextAttr& style, const wxTextAttr* compareWith = NULL);
// merges the attributes of the base and the overlay objects and returns
// the result; the parameter attributes take precedence
//

View File

@ -783,13 +783,14 @@ void MyFrame::WriteInitialText()
r.EndAlignment();
r.BeginAlignment(wxTEXT_ALIGNMENT_LEFT);
wxRichTextAnchoredObjectAttr anchoredAttr;
anchoredAttr.m_floating = wxRICHTEXT_FLOAT_LEFT;
wxRichTextAttr imageAttr;
imageAttr.GetTextBoxAttr().SetFloatMode(wxTEXT_BOX_ATTR_FLOAT_LEFT);
r.WriteText(wxString(wxT("This is a simple test for a floating left image test. The zebra image should be placed at the left side of the current buffer and all the text should flow around it at the right side. This is a simple test for a floating left image test. The zebra image should be placed at the left side of the current buffer and all the text should flow around it at the right side. This is a simple test for a floating left image test. The zebra image should be placed at the left side of the current buffer and all the text should flow around it at the right side.")));
r.WriteImage(wxBitmap(zebra_xpm), wxBITMAP_TYPE_PNG, anchoredAttr);
anchoredAttr.m_floating = wxRICHTEXT_FLOAT_RIGHT;
anchoredAttr.m_offset = 200;
r.WriteImage(wxBitmap(zebra_xpm), wxBITMAP_TYPE_PNG, anchoredAttr);
r.WriteImage(wxBitmap(zebra_xpm), wxBITMAP_TYPE_PNG, imageAttr);
imageAttr.GetTextBoxAttr().GetTop().SetValue(200);
imageAttr.GetTextBoxAttr().GetTop().SetUnits(wxTEXT_ATTR_UNITS_PIXELS);
imageAttr.GetTextBoxAttr().SetFloatMode(wxTEXT_BOX_ATTR_FLOAT_RIGHT);
r.WriteImage(wxBitmap(zebra_xpm), wxBITMAP_TYPE_PNG, imageAttr);
r.WriteText(wxString(wxT("This is a simple test for a floating left image test. The zebra image should be placed at the left side of the current buffer and all the text should flow around it at the right side. This is a simple test for a floating left image test. The zebra image should be placed at the left side of the current buffer and all the text should flow around it at the right side. This is a simple test for a floating left image test. The zebra image should be placed at the left side of the current buffer and all the text should flow around it at the right side.")));
r.EndAlignment();
r.Newline();
@ -884,7 +885,7 @@ void MyFrame::WriteInitialText()
tabs.Add(600);
tabs.Add(800);
tabs.Add(1000);
wxTextAttrEx attr;
wxRichTextAttr attr;
attr.SetFlags(wxTEXT_ATTR_TABS);
attr.SetTabs(tabs);
r.SetDefaultStyle(attr);
@ -1162,7 +1163,7 @@ void MyFrame::OnFont(wxCommandEvent& WXUNUSED(event))
wxRichTextRange range = m_richTextCtrl->GetSelectionRange();
wxFontData fontData;
wxTextAttrEx attr;
wxRichTextAttr attr;
attr.SetFlags(wxTEXT_ATTR_FONT);
if (m_richTextCtrl->GetStyle(m_richTextCtrl->GetInsertionPoint(), attr))
@ -1664,5 +1665,21 @@ void MyFrame::OnPreview(wxCommandEvent& WXUNUSED(event))
void MyFrame::OnPageSetup(wxCommandEvent& WXUNUSED(event))
{
wxGetApp().GetPrinting()->PageSetup();
wxDialog dialog(this, wxID_ANY, wxT("Testing"), wxPoint(10, 10), wxSize(400, 300), wxDEFAULT_DIALOG_STYLE);
wxNotebook* nb = new wxNotebook(& dialog, wxID_ANY, wxPoint(5, 5), wxSize(300, 250));
wxPanel* panel = new wxPanel(nb, wxID_ANY, wxDefaultPosition, wxDefaultSize);
wxPanel* panel2 = new wxPanel(nb, wxID_ANY, wxDefaultPosition, wxDefaultSize);
wxRichTextCtrl* richTextCtrl = new wxRichTextCtrl(panel, wxID_ANY, wxEmptyString, wxPoint(5, 5), wxSize(200, 150), wxVSCROLL|wxTE_READONLY);
nb->AddPage(panel, wxT("Page 1"));
wxRichTextCtrl* richTextCtrl2 = new wxRichTextCtrl(panel2, wxID_ANY, wxEmptyString, wxPoint(5, 5), wxSize(200, 150), wxVSCROLL|wxTE_READONLY);
nb->AddPage(panel2, wxT("Page 2"));
wxButton* button = new wxButton(& dialog, wxID_OK, wxT("OK"), wxPoint(5, 180));
dialog.ShowModal();
// wxGetApp().GetPrinting()->PageSetup();
}

View File

@ -188,9 +188,11 @@ bool wxTextAttr::operator== (const wxTextAttr& attr) const
GetURL() == attr.GetURL();
}
// Partial equality test taking flags into account
bool wxTextAttr::EqPartial(const wxTextAttr& attr, int flags) const
// Partial equality test. Only returns false if an attribute doesn't match.
bool wxTextAttr::EqPartial(const wxTextAttr& attr) const
{
int flags = attr.GetFlags();
if ((flags & wxTEXT_ATTR_TEXT_COLOUR) && GetTextColour() != attr.GetTextColour())
return false;

File diff suppressed because it is too large Load Diff

View File

@ -316,7 +316,7 @@ bool wxRichTextBulletsPage::TransferDataFromWindow()
{
wxPanel::TransferDataFromWindow();
wxTextAttr* attr = GetAttributes();
wxRichTextAttr* attr = GetAttributes();
if (m_hasBulletStyle)
{
@ -404,7 +404,7 @@ bool wxRichTextBulletsPage::TransferDataToWindow()
wxPanel::TransferDataToWindow();
wxTextAttr* attr = GetAttributes();
wxRichTextAttr* attr = GetAttributes();
if (attr->HasBulletStyle())
{
@ -522,7 +522,7 @@ et magnis dis parturient montes, nascetur ridiculus mus. Nullam vitae justo id m
iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
TransferDataFromWindow();
wxTextAttr attr(*GetAttributes());
wxRichTextAttr attr(*GetAttributes());
attr.SetFlags(attr.GetFlags() &
(wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_BULLET_NUMBER|wxTEXT_ATTR_BULLET_TEXT|wxTEXT_ATTR_BULLET_NAME|
wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER|
@ -532,7 +532,7 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
font.SetPointSize(9);
m_previewCtrl->SetFont(font);
wxTextAttr normalParaAttr;
wxRichTextAttr normalParaAttr;
normalParaAttr.SetFont(font);
normalParaAttr.SetTextColour(wxColour(wxT("LIGHT GREY")));
@ -556,7 +556,7 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
m_previewCtrl->Thaw();
}
wxTextAttr* wxRichTextBulletsPage::GetAttributes()
wxRichTextAttr* wxRichTextBulletsPage::GetAttributes()
{
return wxRichTextFormattingDialog::GetDialogAttributes(this);
}

View File

@ -136,11 +136,11 @@ private:
};
#endif
IMPLEMENT_DYNAMIC_CLASS( wxRichTextCtrl, wxTextCtrlBase )
IMPLEMENT_DYNAMIC_CLASS( wxRichTextCtrl, wxControl )
IMPLEMENT_DYNAMIC_CLASS( wxRichTextEvent, wxNotifyEvent )
BEGIN_EVENT_TABLE( wxRichTextCtrl, wxTextCtrlBase )
BEGIN_EVENT_TABLE( wxRichTextCtrl, wxControl )
EVT_PAINT(wxRichTextCtrl::OnPaint)
EVT_ERASE_BACKGROUND(wxRichTextCtrl::OnEraseBackground)
EVT_IDLE(wxRichTextCtrl::OnIdle)
@ -214,7 +214,7 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& va
{
style |= wxVSCROLL;
if (!wxTextCtrlBase::Create(parent, id, pos, size,
if (!wxControl::Create(parent, id, pos, size,
style|wxFULL_REPAINT_ON_RESIZE,
validator, name))
return false;
@ -231,7 +231,7 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& va
SetEditable(false);
// The base attributes must all have default values
wxTextAttr attributes;
wxRichTextAttr attributes;
attributes.SetFont(GetFont());
attributes.SetTextColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
attributes.SetAlignment(wxTEXT_ALIGNMENT_LEFT);
@ -243,7 +243,7 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& va
// The default attributes will be merged with base attributes, so
// can be empty to begin with
wxTextAttr defaultAttributes;
wxRichTextAttr defaultAttributes;
SetDefaultStyle(defaultAttributes);
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
@ -560,7 +560,7 @@ void wxRichTextCtrl::OnLeftUp(wxMouseEvent& event)
if (!GetEventHandler()->ProcessEvent(cmdEvent))
{
wxTextAttr attr;
wxRichTextAttr attr;
if (GetStyle(position, attr))
{
if (attr.HasFlag(wxTEXT_ATTR_URL))
@ -608,7 +608,7 @@ void wxRichTextCtrl::OnMoveMouse(wxMouseEvent& event)
{
if (hit != wxRICHTEXT_HITTEST_NONE && !(hit & wxRICHTEXT_HITTEST_OUTSIDE))
{
wxTextAttr attr;
wxRichTextAttr attr;
if (GetStyle(position, attr))
{
if (attr.HasFlag(wxTEXT_ATTR_URL))
@ -2397,34 +2397,34 @@ void wxRichTextCtrl::AppendText(const wxString& text)
}
/// Write an image at the current insertion point
bool wxRichTextCtrl::WriteImage(const wxImage& image, wxBitmapType bitmapType, const wxRichTextAnchoredObjectAttr& attr)
bool wxRichTextCtrl::WriteImage(const wxImage& image, wxBitmapType bitmapType, const wxRichTextAttr& textAttr)
{
wxRichTextImageBlock imageBlock;
wxImage image2 = image;
if (imageBlock.MakeImageBlock(image2, bitmapType))
return WriteImage(imageBlock, attr);
return WriteImage(imageBlock, textAttr);
return false;
}
bool wxRichTextCtrl::WriteImage(const wxString& filename, wxBitmapType bitmapType, const wxRichTextAnchoredObjectAttr& attr)
bool wxRichTextCtrl::WriteImage(const wxString& filename, wxBitmapType bitmapType, const wxRichTextAttr& textAttr)
{
wxRichTextImageBlock imageBlock;
wxImage image;
if (imageBlock.MakeImageBlock(filename, bitmapType, image, false))
return WriteImage(imageBlock, attr);
return WriteImage(imageBlock, textAttr);
return false;
}
bool wxRichTextCtrl::WriteImage(const wxRichTextImageBlock& imageBlock, const wxRichTextAnchoredObjectAttr& attr)
bool wxRichTextCtrl::WriteImage(const wxRichTextImageBlock& imageBlock, const wxRichTextAttr& textAttr)
{
return GetBuffer().InsertImageWithUndo(m_caretPosition+1, imageBlock, this, NULL, attr);
return GetBuffer().InsertImageWithUndo(m_caretPosition+1, imageBlock, this, NULL, textAttr);
}
bool wxRichTextCtrl::WriteImage(const wxBitmap& bitmap, wxBitmapType bitmapType, const wxRichTextAnchoredObjectAttr& attr)
bool wxRichTextCtrl::WriteImage(const wxBitmap& bitmap, wxBitmapType bitmapType, const wxRichTextAttr& textAttr)
{
if (bitmap.Ok())
{
@ -2432,7 +2432,7 @@ bool wxRichTextCtrl::WriteImage(const wxBitmap& bitmap, wxBitmapType bitmapType,
wxImage image = bitmap.ConvertToImage();
if (image.Ok() && imageBlock.MakeImageBlock(image, bitmapType))
return WriteImage(imageBlock, attr);
return WriteImage(imageBlock, textAttr);
}
return false;
@ -2878,51 +2878,90 @@ void wxRichTextCtrl::OnContextMenu(wxContextMenuEvent& event)
bool wxRichTextCtrl::SetStyle(long start, long end, const wxTextAttr& style)
{
return GetBuffer().SetStyle(wxRichTextRange(start, end-1), wxTextAttr(style));
return GetBuffer().SetStyle(wxRichTextRange(start, end-1), wxRichTextAttr(style));
}
bool wxRichTextCtrl::SetStyle(long start, long end, const wxRichTextAttr& style)
{
return GetBuffer().SetStyle(wxRichTextRange(start, end-1), style);
}
bool wxRichTextCtrl::SetStyle(const wxRichTextRange& range, const wxTextAttr& style)
{
return GetBuffer().SetStyle(range.ToInternal(), wxRichTextAttr(style));
}
bool wxRichTextCtrl::SetStyle(const wxRichTextRange& range, const wxRichTextAttr& style)
{
return GetBuffer().SetStyle(range.ToInternal(), style);
}
void wxRichTextCtrl::SetImageStyle(wxRichTextImage *image, const wxRichTextAnchoredObjectAttr& attr)
void wxRichTextCtrl::SetImageStyle(wxRichTextImage *image, const wxRichTextAttr& textAttr)
{
GetBuffer().SetImageStyle(image, attr);
GetBuffer().SetImageStyle(image, textAttr);
}
// extended style setting operation with flags including:
// wxRICHTEXT_SETSTYLE_WITH_UNDO, wxRICHTEXT_SETSTYLE_OPTIMIZE, wxRICHTEXT_SETSTYLE_PARAGRAPHS_ONLY.
// see richtextbuffer.h for more details.
bool wxRichTextCtrl::SetStyleEx(const wxRichTextRange& range, const wxTextAttr& style, int flags)
bool wxRichTextCtrl::SetStyleEx(const wxRichTextRange& range, const wxRichTextAttr& style, int flags)
{
return GetBuffer().SetStyle(range.ToInternal(), style, flags);
}
bool wxRichTextCtrl::SetDefaultStyle(const wxTextAttr& style)
{
return GetBuffer().SetDefaultStyle(wxTextAttr(style));
return GetBuffer().SetDefaultStyle(style);
}
const wxTextAttr& wxRichTextCtrl::GetDefaultStyle() const
bool wxRichTextCtrl::SetDefaultStyle(const wxRichTextAttr& style)
{
return GetBuffer().SetDefaultStyle(style);
}
const wxRichTextAttr& wxRichTextCtrl::GetDefaultStyleEx() const
{
return GetBuffer().GetDefaultStyle();
}
bool wxRichTextCtrl::GetStyle(long position, wxTextAttr& style)
{
wxRichTextAttr attr;
if (GetBuffer().GetStyle(position, attr))
{
style = attr;
return true;
}
else
return false;
}
bool wxRichTextCtrl::GetStyle(long position, wxRichTextAttr& style)
{
return GetBuffer().GetStyle(position, style);
}
// get the common set of styles for the range
bool wxRichTextCtrl::GetStyleForRange(const wxRichTextRange& range, wxTextAttr& style)
{
wxRichTextAttr attr;
if (GetBuffer().GetStyleForRange(range.ToInternal(), attr))
{
style = attr;
return true;
}
else
return false;
}
bool wxRichTextCtrl::GetStyleForRange(const wxRichTextRange& range, wxRichTextAttr& style)
{
return GetBuffer().GetStyleForRange(range.ToInternal(), style);
}
/// Get the content (uncombined) attributes for this position.
bool wxRichTextCtrl::GetUncombinedStyle(long position, wxTextAttr& style)
bool wxRichTextCtrl::GetUncombinedStyle(long position, wxRichTextAttr& style)
{
return GetBuffer().GetUncombinedStyle(position, style);
}
@ -2930,9 +2969,9 @@ bool wxRichTextCtrl::GetUncombinedStyle(long position, wxTextAttr& style)
/// Set font, and also the buffer attributes
bool wxRichTextCtrl::SetFont(const wxFont& font)
{
wxTextCtrlBase::SetFont(font);
wxControl::SetFont(font);
wxTextAttr attr = GetBuffer().GetAttributes();
wxRichTextAttr attr = GetBuffer().GetAttributes();
attr.SetFont(font);
GetBuffer().SetBasicStyle(attr);
@ -3096,7 +3135,7 @@ bool wxRichTextCtrl::IsSelectionBold()
{
if (HasSelection())
{
wxTextAttr attr;
wxRichTextAttr attr;
wxRichTextRange range = GetSelectionRange();
attr.SetFlags(wxTEXT_ATTR_FONT_WEIGHT);
attr.SetFontWeight(wxFONTWEIGHT_BOLD);
@ -3107,7 +3146,7 @@ bool wxRichTextCtrl::IsSelectionBold()
{
// If no selection, then we need to combine current style with default style
// to see what the effect would be if we started typing.
wxTextAttr attr;
wxRichTextAttr attr;
attr.SetFlags(wxTEXT_ATTR_FONT_WEIGHT);
long pos = GetAdjustedCaretPosition(GetCaretPosition());
@ -3127,7 +3166,7 @@ bool wxRichTextCtrl::IsSelectionItalics()
if (HasSelection())
{
wxRichTextRange range = GetSelectionRange();
wxTextAttr attr;
wxRichTextAttr attr;
attr.SetFlags(wxTEXT_ATTR_FONT_ITALIC);
attr.SetFontStyle(wxFONTSTYLE_ITALIC);
@ -3137,7 +3176,7 @@ bool wxRichTextCtrl::IsSelectionItalics()
{
// If no selection, then we need to combine current style with default style
// to see what the effect would be if we started typing.
wxTextAttr attr;
wxRichTextAttr attr;
attr.SetFlags(wxTEXT_ATTR_FONT_ITALIC);
long pos = GetAdjustedCaretPosition(GetCaretPosition());
@ -3157,7 +3196,7 @@ bool wxRichTextCtrl::IsSelectionUnderlined()
if (HasSelection())
{
wxRichTextRange range = GetSelectionRange();
wxTextAttr attr;
wxRichTextAttr attr;
attr.SetFlags(wxTEXT_ATTR_FONT_UNDERLINE);
attr.SetFontUnderlined(true);
@ -3167,7 +3206,7 @@ bool wxRichTextCtrl::IsSelectionUnderlined()
{
// If no selection, then we need to combine current style with default style
// to see what the effect would be if we started typing.
wxTextAttr attr;
wxRichTextAttr attr;
attr.SetFlags(wxTEXT_ATTR_FONT_UNDERLINE);
long pos = GetAdjustedCaretPosition(GetCaretPosition());
@ -3184,7 +3223,7 @@ bool wxRichTextCtrl::IsSelectionUnderlined()
/// Apply bold to the selection
bool wxRichTextCtrl::ApplyBoldToSelection()
{
wxTextAttr attr;
wxRichTextAttr attr;
attr.SetFlags(wxTEXT_ATTR_FONT_WEIGHT);
attr.SetFontWeight(IsSelectionBold() ? wxFONTWEIGHT_NORMAL : wxFONTWEIGHT_BOLD);
@ -3202,7 +3241,7 @@ bool wxRichTextCtrl::ApplyBoldToSelection()
/// Apply italic to the selection
bool wxRichTextCtrl::ApplyItalicToSelection()
{
wxTextAttr attr;
wxRichTextAttr attr;
attr.SetFlags(wxTEXT_ATTR_FONT_ITALIC);
attr.SetFontStyle(IsSelectionItalics() ? wxFONTSTYLE_NORMAL : wxFONTSTYLE_ITALIC);
@ -3220,7 +3259,7 @@ bool wxRichTextCtrl::ApplyItalicToSelection()
/// Apply underline to the selection
bool wxRichTextCtrl::ApplyUnderlineToSelection()
{
wxTextAttr attr;
wxRichTextAttr attr;
attr.SetFlags(wxTEXT_ATTR_FONT_UNDERLINE);
attr.SetFontUnderlined(!IsSelectionUnderlined());
@ -3244,7 +3283,7 @@ bool wxRichTextCtrl::IsSelectionAligned(wxTextAttrAlignment alignment)
else
range = wxRichTextRange(GetCaretPosition()+1, GetCaretPosition()+2);
wxTextAttr attr;
wxRichTextAttr attr;
attr.SetAlignment(alignment);
return HasParagraphAttributes(range, attr);
@ -3253,7 +3292,7 @@ bool wxRichTextCtrl::IsSelectionAligned(wxTextAttrAlignment alignment)
/// Apply alignment to the selection
bool wxRichTextCtrl::ApplyAlignmentToSelection(wxTextAttrAlignment alignment)
{
wxTextAttr attr;
wxRichTextAttr attr;
attr.SetAlignment(alignment);
if (HasSelection())
return SetStyle(GetSelectionRange(), attr);
@ -3271,7 +3310,7 @@ bool wxRichTextCtrl::ApplyStyle(wxRichTextStyleDefinition* def)
{
// Flags are defined within each definition, so only certain
// attributes are applied.
wxTextAttr attr(GetStyleSheet() ? def->GetStyleMergedWithBase(GetStyleSheet()) : def->GetStyle());
wxRichTextAttr attr(GetStyleSheet() ? def->GetStyleMergedWithBase(GetStyleSheet()) : def->GetStyle());
int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO|wxRICHTEXT_SETSTYLE_OPTIMIZE|wxRICHTEXT_SETSTYLE_RESET;
@ -3312,8 +3351,8 @@ bool wxRichTextCtrl::ApplyStyle(wxRichTextStyleDefinition* def)
return SetStyleEx(GetSelectionRange(), attr, flags);
else
{
wxTextAttr current = GetDefaultStyleEx();
wxTextAttr defaultStyle(attr);
wxRichTextAttr current = GetDefaultStyleEx();
wxRichTextAttr defaultStyle(attr);
if (isPara)
{
// Don't apply extra character styles since they are already implied
@ -3359,7 +3398,7 @@ bool wxRichTextCtrl::ApplyStyleSheet(wxRichTextStyleSheet* styleSheet)
/// Sets the default style to the style under the cursor
bool wxRichTextCtrl::SetDefaultStyleToCursorStyle()
{
wxTextAttr attr;
wxRichTextAttr attr;
attr.SetFlags(wxTEXT_ATTR_CHARACTER);
// If at the start of a paragraph, use the next position.

View File

@ -14747,140 +14747,6 @@
<bool name="proxy-wxSHAPED">0</bool>
<bool name="proxy-wxADJUST_MINSIZE">0</bool>
<bool name="proxy-wxFIXED_MINSIZE">0</bool>
<document>
<string name="title">"wxStaticText: wxID_STATIC"</string>
<string name="type">"dialog-control-document"</string>
<string name="filename">""</string>
<string name="icon-name">"statictext"</string>
<long name="is-transient">0</long>
<long name="owns-file">1</long>
<long name="title-mode">0</long>
<long name="locked">0</long>
<string name="proxy-type">"wbStaticTextProxy"</string>
<string name="proxy-Id name">"wxID_STATIC"</string>
<long name="proxy-Id value">5105</long>
<string name="proxy-Name">""</string>
<string name="proxy-Class">"wxStaticText"</string>
<string name="proxy-Base class">"wxStaticText"</string>
<bool name="proxy-External implementation">1</bool>
<bool name="proxy-Separate files">0</bool>
<string name="proxy-Implementation filename">""</string>
<string name="proxy-Header filename">""</string>
<string name="proxy-Member variable name">""</string>
<string name="proxy-Label">"Alignment:"</string>
<long name="proxy-Wrapping width">-1</long>
<string name="proxy-Help text">""</string>
<string name="proxy-Tooltip text">""</string>
<string name="proxy-Background colour">""</string>
<string name="proxy-Foreground colour">""</string>
<string name="proxy-Font">""</string>
<bool name="proxy-Hidden">1</bool>
<bool name="proxy-Enabled">1</bool>
<string name="proxy-Platform">"&lt;Any platform&gt;"</string>
<string name="proxy-Data variable">""</string>
<string name="proxy-Data validator">""</string>
<string name="proxy-Data source">""</string>
<string name="proxy-Data class name">""</string>
<string name="proxy-Data class implementation filename">""</string>
<string name="proxy-Data class header filename">""</string>
<string name="proxy-Data class manager window">""</string>
<bool name="proxy-wxALIGN_LEFT">0</bool>
<bool name="proxy-wxALIGN_RIGHT">0</bool>
<bool name="proxy-wxALIGN_CENTRE">0</bool>
<bool name="proxy-wxST_NO_AUTORESIZE">0</bool>
<bool name="proxy-wxNO_BORDER">0</bool>
<bool name="proxy-wxSIMPLE_BORDER">0</bool>
<bool name="proxy-wxDOUBLE_BORDER">0</bool>
<bool name="proxy-wxBORDER_THEME">0</bool>
<bool name="proxy-wxSUNKEN_BORDER">0</bool>
<bool name="proxy-wxRAISED_BORDER">0</bool>
<bool name="proxy-wxSTATIC_BORDER">0</bool>
<bool name="proxy-wxWANTS_CHARS">0</bool>
<bool name="proxy-wxNO_FULL_REPAINT_ON_RESIZE">0</bool>
<bool name="proxy-wxFULL_REPAINT_ON_RESIZE">0</bool>
<string name="proxy-Custom styles">""</string>
<long name="proxy-X">-1</long>
<long name="proxy-Y">-1</long>
<long name="proxy-Width">-1</long>
<long name="proxy-Height">-1</long>
<string name="proxy-AlignH">"Centre"</string>
<string name="proxy-AlignV">"Centre"</string>
<long name="proxy-Stretch factor">0</long>
<long name="proxy-Border">5</long>
<bool name="proxy-wxLEFT">1</bool>
<bool name="proxy-wxRIGHT">1</bool>
<bool name="proxy-wxTOP">1</bool>
<bool name="proxy-wxBOTTOM">1</bool>
<bool name="proxy-wxSHAPED">0</bool>
<bool name="proxy-wxADJUST_MINSIZE">0</bool>
<bool name="proxy-wxFIXED_MINSIZE">0</bool>
<string name="proxy-Custom arguments">""</string>
<string name="proxy-Custom ctor arguments">""</string>
</document>
<document>
<string name="title">"wxComboBox: ID_COMBOBOX_ALIGN"</string>
<string name="type">"dialog-control-document"</string>
<string name="filename">""</string>
<string name="icon-name">"combobox"</string>
<long name="is-transient">0</long>
<long name="owns-file">1</long>
<long name="title-mode">0</long>
<long name="locked">0</long>
<string name="proxy-type">"wbComboBoxProxy"</string>
<string name="proxy-Id name">"ID_COMBOBOX_ALIGN"</string>
<long name="proxy-Id value">10016</long>
<string name="proxy-Name">""</string>
<string name="proxy-Class">"wxComboBox"</string>
<string name="proxy-Base class">"wxComboBox"</string>
<bool name="proxy-External implementation">1</bool>
<bool name="proxy-Separate files">0</bool>
<string name="proxy-Implementation filename">""</string>
<string name="proxy-Header filename">""</string>
<string name="proxy-Member variable name">"m_alignment"</string>
<string name="proxy-Strings">"Left|Centre|Right"</string>
<string name="proxy-Initial value">"Left"</string>
<string name="proxy-Help text">""</string>
<string name="proxy-Tooltip text">""</string>
<string name="proxy-Background colour">""</string>
<string name="proxy-Foreground colour">""</string>
<string name="proxy-Font">""</string>
<bool name="proxy-Hidden">1</bool>
<bool name="proxy-Enabled">1</bool>
<string name="proxy-Platform">"&lt;Any platform&gt;"</string>
<string name="proxy-Data variable">""</string>
<string name="proxy-Data validator">""</string>
<string name="proxy-Data source">""</string>
<string name="proxy-Data class name">""</string>
<string name="proxy-Data class implementation filename">""</string>
<string name="proxy-Data class header filename">""</string>
<string name="proxy-Data class manager window">""</string>
<bool name="proxy-wxCB_SIMPLE">0</bool>
<bool name="proxy-wxCB_DROPDOWN">0</bool>
<bool name="proxy-wxCB_READONLY">1</bool>
<bool name="proxy-wxCB_SORT">0</bool>
<bool name="proxy-wxTE_PROCESS_ENTER">0</bool>
<bool name="proxy-wxWANTS_CHARS">0</bool>
<bool name="proxy-wxNO_FULL_REPAINT_ON_RESIZE">0</bool>
<bool name="proxy-wxFULL_REPAINT_ON_RESIZE">0</bool>
<string name="proxy-Custom styles">""</string>
<long name="proxy-X">-1</long>
<long name="proxy-Y">-1</long>
<long name="proxy-Width">80</long>
<long name="proxy-Height">-1</long>
<string name="proxy-AlignH">"Centre"</string>
<string name="proxy-AlignV">"Centre"</string>
<long name="proxy-Stretch factor">0</long>
<long name="proxy-Border">5</long>
<bool name="proxy-wxLEFT">1</bool>
<bool name="proxy-wxRIGHT">1</bool>
<bool name="proxy-wxTOP">1</bool>
<bool name="proxy-wxBOTTOM">1</bool>
<bool name="proxy-wxSHAPED">0</bool>
<bool name="proxy-wxADJUST_MINSIZE">0</bool>
<bool name="proxy-wxFIXED_MINSIZE">0</bool>
<string name="proxy-Custom arguments">""</string>
<string name="proxy-Custom ctor arguments">""</string>
</document>
<document>
<string name="title">"wxStaticText: wxID_STATIC"</string>
<string name="type">"dialog-control-document"</string>

View File

@ -304,7 +304,7 @@ bool wxRichTextFontPage::TransferDataFromWindow()
{
wxPanel::TransferDataFromWindow();
wxTextAttr* attr = GetAttributes();
wxRichTextAttr* attr = GetAttributes();
if (m_faceListBox->GetSelection() != wxNOT_FOUND)
{
@ -429,7 +429,7 @@ bool wxRichTextFontPage::TransferDataToWindow()
wxPanel::TransferDataToWindow();
m_dontUpdate = true;
wxTextAttr* attr = GetAttributes();
wxRichTextAttr* attr = GetAttributes();
if (attr->HasFontFaceName())
{
@ -564,7 +564,7 @@ bool wxRichTextFontPage::TransferDataToWindow()
return true;
}
wxTextAttr* wxRichTextFontPage::GetAttributes()
wxRichTextAttr* wxRichTextFontPage::GetAttributes()
{
return wxRichTextFormattingDialog::GetDialogAttributes(this);
}
@ -572,7 +572,7 @@ wxTextAttr* wxRichTextFontPage::GetAttributes()
/// Updates the font preview
void wxRichTextFontPage::UpdatePreview()
{
wxTextAttr attr;
wxRichTextAttr attr;
if (m_colourPresent)
m_previewCtrl->SetForegroundColour(m_colourCtrl->GetBackgroundColour());

View File

@ -130,7 +130,7 @@ bool wxRichTextFormattingDialog::ApplyStyle(wxRichTextCtrl* ctrl, const wxRichTe
}
/// Set the attributes and optionally update the display
bool wxRichTextFormattingDialog::SetStyle(const wxTextAttr& style, bool update)
bool wxRichTextFormattingDialog::SetStyle(const wxRichTextAttr& style, bool update)
{
m_attributes = style;
if (update)
@ -462,7 +462,7 @@ wxRichTextFormattingDialog* wxRichTextFormattingDialog::GetDialog(wxWindow* win)
// Helper for pages to get the attributes
wxTextAttr* wxRichTextFormattingDialog::GetDialogAttributes(wxWindow* win)
wxRichTextAttr* wxRichTextFormattingDialog::GetDialogAttributes(wxWindow* win)
{
wxRichTextFormattingDialog* dialog = GetDialog(win);
if (dialog)

View File

@ -101,8 +101,8 @@ bool wxRichTextHTMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream&
wxTextOutputStream str(stream, wxEOL_NATIVE);
#endif
wxTextAttr currentParaStyle = buffer->GetAttributes();
wxTextAttr currentCharStyle = buffer->GetAttributes();
wxRichTextAttr currentParaStyle = buffer->GetAttributes();
wxRichTextAttr currentCharStyle = buffer->GetAttributes();
if ((GetFlags() & wxRICHTEXT_HANDLER_NO_HEADER_FOOTER) == 0)
str << wxT("<html><head></head><body>\n");
@ -123,7 +123,7 @@ bool wxRichTextHTMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream&
if (para)
{
wxTextAttr paraStyle(para->GetCombinedAttributes());
wxRichTextAttr paraStyle(para->GetCombinedAttributes());
BeginParagraphFormatting(currentParaStyle, paraStyle, str);
@ -134,7 +134,7 @@ bool wxRichTextHTMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream&
wxRichTextPlainText* textObj = wxDynamicCast(obj, wxRichTextPlainText);
if (textObj && !textObj->IsEmpty())
{
wxTextAttr charStyle(para->GetCombinedAttributes(obj->GetAttributes()));
wxRichTextAttr charStyle(para->GetCombinedAttributes(obj->GetAttributes()));
BeginCharacterFormatting(currentCharStyle, charStyle, paraStyle, str);
wxString text = textObj->GetText();
@ -184,7 +184,7 @@ bool wxRichTextHTMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream&
return true;
}
void wxRichTextHTMLHandler::BeginCharacterFormatting(const wxTextAttr& currentStyle, const wxTextAttr& thisStyle, const wxTextAttr& WXUNUSED(paraStyle), wxTextOutputStream& str)
void wxRichTextHTMLHandler::BeginCharacterFormatting(const wxRichTextAttr& currentStyle, const wxRichTextAttr& thisStyle, const wxRichTextAttr& WXUNUSED(paraStyle), wxTextOutputStream& str)
{
wxString style;
@ -219,7 +219,7 @@ void wxRichTextHTMLHandler::BeginCharacterFormatting(const wxTextAttr& currentSt
str << wxT("<a href=\"") << thisStyle.GetURL() << wxT("\">");
}
void wxRichTextHTMLHandler::EndCharacterFormatting(const wxTextAttr& WXUNUSED(currentStyle), const wxTextAttr& thisStyle, const wxTextAttr& WXUNUSED(paraStyle), wxTextOutputStream& stream)
void wxRichTextHTMLHandler::EndCharacterFormatting(const wxRichTextAttr& WXUNUSED(currentStyle), const wxRichTextAttr& thisStyle, const wxRichTextAttr& WXUNUSED(paraStyle), wxTextOutputStream& stream)
{
if (thisStyle.HasURL())
stream << wxT("</a>");
@ -239,7 +239,7 @@ void wxRichTextHTMLHandler::EndCharacterFormatting(const wxTextAttr& WXUNUSED(cu
}
/// Begin paragraph formatting
void wxRichTextHTMLHandler::BeginParagraphFormatting(const wxTextAttr& WXUNUSED(currentStyle), const wxTextAttr& thisStyle, wxTextOutputStream& str)
void wxRichTextHTMLHandler::BeginParagraphFormatting(const wxRichTextAttr& WXUNUSED(currentStyle), const wxRichTextAttr& thisStyle, wxTextOutputStream& str)
{
if (thisStyle.HasPageBreak())
{
@ -367,7 +367,7 @@ void wxRichTextHTMLHandler::BeginParagraphFormatting(const wxTextAttr& WXUNUSED(
}
/// End paragraph formatting
void wxRichTextHTMLHandler::EndParagraphFormatting(const wxTextAttr& WXUNUSED(currentStyle), const wxTextAttr& thisStyle, wxTextOutputStream& stream)
void wxRichTextHTMLHandler::EndParagraphFormatting(const wxRichTextAttr& WXUNUSED(currentStyle), const wxRichTextAttr& thisStyle, wxTextOutputStream& stream)
{
if (thisStyle.HasFont())
stream << wxT("</font>");
@ -405,7 +405,7 @@ void wxRichTextHTMLHandler::CloseLists(int level, wxTextOutputStream& str)
}
/// Output font tag
void wxRichTextHTMLHandler::OutputFont(const wxTextAttr& style, wxTextOutputStream& stream)
void wxRichTextHTMLHandler::OutputFont(const wxRichTextAttr& style, wxTextOutputStream& stream)
{
if (style.HasFont())
{
@ -416,7 +416,7 @@ void wxRichTextHTMLHandler::OutputFont(const wxTextAttr& style, wxTextOutputStre
}
}
int wxRichTextHTMLHandler::TypeOfList( const wxTextAttr& thisStyle, wxString& tag )
int wxRichTextHTMLHandler::TypeOfList( const wxRichTextAttr& thisStyle, wxString& tag )
{
// We can use number attribute of li tag but not all the browsers support it.
// also wxHtmlWindow doesn't support type attribute.
@ -444,7 +444,7 @@ int wxRichTextHTMLHandler::TypeOfList( const wxTextAttr& thisStyle, wxString& ta
return 0;
}
wxString wxRichTextHTMLHandler::GetAlignment( const wxTextAttr& thisStyle )
wxString wxRichTextHTMLHandler::GetAlignment( const wxRichTextAttr& thisStyle )
{
switch( thisStyle.GetAlignment() )
{

View File

@ -111,7 +111,6 @@ wxRichTextImageDialog::~wxRichTextImageDialog()
void wxRichTextImageDialog::Init()
{
////@begin wxRichTextImageDialog member initialisation
m_alignment = NULL;
m_float = NULL;
m_width = NULL;
m_unitsW = NULL;
@ -147,21 +146,8 @@ void wxRichTextImageDialog::CreateControls()
wxFlexGridSizer* itemFlexGridSizer4 = new wxFlexGridSizer(0, 2, 0, 0);
itemBoxSizer3->Add(itemFlexGridSizer4, 0, wxALIGN_TOP|wxRIGHT, 5);
wxStaticText* itemStaticText5 = new wxStaticText( itemDialog1, wxID_STATIC, _("Alignment:"), wxDefaultPosition, wxDefaultSize, 0 );
itemStaticText5->Show(false);
itemFlexGridSizer4->Add(itemStaticText5, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxArrayString m_alignmentStrings;
m_alignmentStrings.Add(_("Left"));
m_alignmentStrings.Add(_("Centre"));
m_alignmentStrings.Add(_("Right"));
m_alignment = new wxComboBox( itemDialog1, ID_COMBOBOX_ALIGN, _("Left"), wxDefaultPosition, wxSize(80, -1), m_alignmentStrings, wxCB_READONLY );
m_alignment->SetStringSelection(_("Left"));
m_alignment->Show(false);
itemFlexGridSizer4->Add(m_alignment, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxStaticText* itemStaticText7 = new wxStaticText( itemDialog1, wxID_STATIC, _("&Floating mode:"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer4->Add(itemStaticText7, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxStaticText* itemStaticText5 = new wxStaticText( itemDialog1, wxID_STATIC, _("&Floating mode:"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer4->Add(itemStaticText5, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxArrayString m_floatStrings;
m_floatStrings.Add(_("None"));
@ -174,17 +160,17 @@ void wxRichTextImageDialog::CreateControls()
m_float->SetToolTip(_("How the image will float relative to the text."));
itemFlexGridSizer4->Add(m_float, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxStaticText* itemStaticText9 = new wxStaticText( itemDialog1, wxID_STATIC, _("&Width:"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer4->Add(itemStaticText9, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxStaticText* itemStaticText7 = new wxStaticText( itemDialog1, wxID_STATIC, _("&Width:"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer4->Add(itemStaticText7, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxHORIZONTAL);
itemFlexGridSizer4->Add(itemBoxSizer10, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxHORIZONTAL);
itemFlexGridSizer4->Add(itemBoxSizer8, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
m_width = new wxTextCtrl( itemDialog1, ID_RICHTEXTIMAGEDIALOG_WIDTH, wxEmptyString, wxDefaultPosition, wxSize(65, -1), 0 );
m_width->SetHelpText(_("The image width to be shown - does not change the source image width."));
if (wxRichTextImageDialog::ShowToolTips())
m_width->SetToolTip(_("The image width to be shown - does not change the source image width."));
itemBoxSizer10->Add(m_width, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
itemBoxSizer8->Add(m_width, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxArrayString m_unitsWStrings;
m_unitsWStrings.Add(_("px"));
@ -194,19 +180,19 @@ void wxRichTextImageDialog::CreateControls()
m_unitsW->SetHelpText(_("Units for the image width."));
if (wxRichTextImageDialog::ShowToolTips())
m_unitsW->SetToolTip(_("Units for the image width."));
itemBoxSizer10->Add(m_unitsW, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
itemBoxSizer8->Add(m_unitsW, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxStaticText* itemStaticText13 = new wxStaticText( itemDialog1, wxID_STATIC, _("&Height:"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer4->Add(itemStaticText13, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxStaticText* itemStaticText11 = new wxStaticText( itemDialog1, wxID_STATIC, _("&Height:"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer4->Add(itemStaticText11, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxBoxSizer* itemBoxSizer14 = new wxBoxSizer(wxHORIZONTAL);
itemFlexGridSizer4->Add(itemBoxSizer14, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
wxBoxSizer* itemBoxSizer12 = new wxBoxSizer(wxHORIZONTAL);
itemFlexGridSizer4->Add(itemBoxSizer12, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
m_height = new wxTextCtrl( itemDialog1, ID_RICHTEXTIMAGEDIALOG_HEIGHT, wxEmptyString, wxDefaultPosition, wxSize(65, -1), 0 );
m_height->SetHelpText(_("The image height to be shown - does not change the source image height."));
if (wxRichTextImageDialog::ShowToolTips())
m_height->SetToolTip(_("The image height to be shown - does not change the source image height."));
itemBoxSizer14->Add(m_height, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
itemBoxSizer12->Add(m_height, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxArrayString m_unitsHStrings;
m_unitsHStrings.Add(_("px"));
@ -216,20 +202,20 @@ void wxRichTextImageDialog::CreateControls()
m_unitsH->SetHelpText(_("Units for the image height."));
if (wxRichTextImageDialog::ShowToolTips())
m_unitsH->SetToolTip(_("Units for the image height."));
itemBoxSizer14->Add(m_unitsH, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
itemBoxSizer12->Add(m_unitsH, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxStaticText* itemStaticText17 = new wxStaticText( itemDialog1, wxID_STATIC, _("Image Vertical &Offset:"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer4->Add(itemStaticText17, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxStaticText* itemStaticText15 = new wxStaticText( itemDialog1, wxID_STATIC, _("Image Vertical &Offset:"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer4->Add(itemStaticText15, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxBoxSizer* itemBoxSizer18 = new wxBoxSizer(wxHORIZONTAL);
itemFlexGridSizer4->Add(itemBoxSizer18, 1, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
wxBoxSizer* itemBoxSizer16 = new wxBoxSizer(wxHORIZONTAL);
itemFlexGridSizer4->Add(itemBoxSizer16, 1, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
m_offset = new wxTextCtrl( itemDialog1, ID_RICHTEXTIMAGEDIALOG_OFFSET, wxEmptyString, wxDefaultPosition, wxSize(65, -1), 0 );
m_offset->SetMaxLength(10);
m_offset->SetHelpText(_("The vertical offset relative to the paragraph."));
if (wxRichTextImageDialog::ShowToolTips())
m_offset->SetToolTip(_("The vertical offset relative to the paragraph."));
itemBoxSizer18->Add(m_offset, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
itemBoxSizer16->Add(m_offset, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxArrayString m_unitsOffsetStrings;
m_unitsOffsetStrings.Add(_("px"));
@ -239,45 +225,45 @@ void wxRichTextImageDialog::CreateControls()
m_unitsOffset->SetHelpText(_("Units for the image offset."));
if (wxRichTextImageDialog::ShowToolTips())
m_unitsOffset->SetToolTip(_("Units for the image offset."));
itemBoxSizer18->Add(m_unitsOffset, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
itemBoxSizer16->Add(m_unitsOffset, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxStaticText* itemStaticText21 = new wxStaticText( itemDialog1, wxID_STATIC, _("&Move the image to:"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer4->Add(itemStaticText21, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxStaticText* itemStaticText19 = new wxStaticText( itemDialog1, wxID_STATIC, _("&Move the image to:"), wxDefaultPosition, wxDefaultSize, 0 );
itemFlexGridSizer4->Add(itemStaticText19, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxBoxSizer* itemBoxSizer22 = new wxBoxSizer(wxHORIZONTAL);
itemFlexGridSizer4->Add(itemBoxSizer22, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxHORIZONTAL);
itemFlexGridSizer4->Add(itemBoxSizer20, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
wxButton* itemButton23 = new wxButton( itemDialog1, ID_RICHTEXTIMAGEDIALOG_PARA_UP, _("&Previous Paragraph"), wxDefaultPosition, wxDefaultSize, 0 );
itemButton23->SetHelpText(_("Moves the image to the previous paragraph."));
wxButton* itemButton21 = new wxButton( itemDialog1, ID_RICHTEXTIMAGEDIALOG_PARA_UP, _("&Previous Paragraph"), wxDefaultPosition, wxDefaultSize, 0 );
itemButton21->SetHelpText(_("Moves the image to the previous paragraph."));
if (wxRichTextImageDialog::ShowToolTips())
itemButton23->SetToolTip(_("Moves the image to the previous paragraph."));
itemBoxSizer22->Add(itemButton23, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
itemButton21->SetToolTip(_("Moves the image to the previous paragraph."));
itemBoxSizer20->Add(itemButton21, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxButton* itemButton24 = new wxButton( itemDialog1, ID_RICHTEXTIMAGEDIALOG_DOWN, _("&Next Paragraph"), wxDefaultPosition, wxDefaultSize, 0 );
itemButton24->SetHelpText(_("Moves the image to the next paragraph."));
wxButton* itemButton22 = new wxButton( itemDialog1, ID_RICHTEXTIMAGEDIALOG_DOWN, _("&Next Paragraph"), wxDefaultPosition, wxDefaultSize, 0 );
itemButton22->SetHelpText(_("Moves the image to the next paragraph."));
if (wxRichTextImageDialog::ShowToolTips())
itemButton24->SetToolTip(_("Moves the image to the next paragraph."));
itemBoxSizer22->Add(itemButton24, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP|wxBOTTOM, 5);
itemButton22->SetToolTip(_("Moves the image to the next paragraph."));
itemBoxSizer20->Add(itemButton22, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP|wxBOTTOM, 5);
wxStaticLine* itemStaticLine25 = new wxStaticLine( itemDialog1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
itemBoxSizer2->Add(itemStaticLine25, 0, wxGROW|wxALL, 5);
wxStaticLine* itemStaticLine23 = new wxStaticLine( itemDialog1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
itemBoxSizer2->Add(itemStaticLine23, 0, wxGROW|wxALL, 5);
wxStdDialogButtonSizer* itemStdDialogButtonSizer26 = new wxStdDialogButtonSizer;
wxStdDialogButtonSizer* itemStdDialogButtonSizer24 = new wxStdDialogButtonSizer;
itemBoxSizer2->Add(itemStdDialogButtonSizer26, 0, wxGROW|wxALL, 5);
itemBoxSizer2->Add(itemStdDialogButtonSizer24, 0, wxGROW|wxALL, 5);
m_saveButton = new wxButton( itemDialog1, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 );
m_saveButton->SetHelpText(_("Click to confirm your changes."));
if (wxRichTextImageDialog::ShowToolTips())
m_saveButton->SetToolTip(_("Click to confirm your changes."));
itemStdDialogButtonSizer26->AddButton(m_saveButton);
itemStdDialogButtonSizer24->AddButton(m_saveButton);
m_cancelButton = new wxButton( itemDialog1, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
m_cancelButton->SetHelpText(_("Click to discard your changes."));
if (wxRichTextImageDialog::ShowToolTips())
m_cancelButton->SetToolTip(_("Click to discard your changes."));
itemStdDialogButtonSizer26->AddButton(m_cancelButton);
itemStdDialogButtonSizer24->AddButton(m_cancelButton);
itemStdDialogButtonSizer26->Realize();
itemStdDialogButtonSizer24->Realize();
////@end wxRichTextImageDialog content construction
}
@ -321,9 +307,10 @@ wxIcon wxRichTextImageDialog::GetIconResource( const wxString& name )
/*!
* Set the image attribute
*/
void wxRichTextImageDialog::SetImageAttr(const wxRichTextAnchoredObjectAttr& attr)
void wxRichTextImageDialog::SetImageAttr(const wxRichTextAttr& textAttr)
{
m_attr = attr;
m_textAttr = textAttr;
TransferDataToWindow();
}
@ -337,7 +324,7 @@ wxRichTextImage* wxRichTextImageDialog::ApplyImageAttr()
TransferDataFromWindow();
if (m_buffer->GetRichTextCtrl())
{
m_buffer->GetRichTextCtrl()->SetImageStyle(image, m_attr);
m_buffer->GetRichTextCtrl()->SetImageStyle(image, m_textAttr);
}
return image;
}
@ -349,107 +336,77 @@ void wxRichTextImageDialog::SetImageObject(wxRichTextImage* image, wxRichTextBuf
m_buffer = buffer;
m_image = image;
m_parent = parent;
SetImageAttr(image->GetAnchoredAttr());
SetImageAttr(image->GetAttributes());
if (image->GetImageCache().IsOk())
{
if (m_attr.m_width == -1)
if (!m_textAttr.GetTextBoxAttr().GetWidth().IsPresent() || m_textAttr.GetTextBoxAttr().GetWidth().GetValue() <= 0)
{
m_attr.m_width = image->GetImageCache().GetWidth();
wxASSERT(m_attr.m_unitsW == wxRICHTEXT_PX);
m_attr.m_unitsW = wxRICHTEXT_PX;
m_textAttr.GetTextBoxAttr().GetWidth().SetValue(image->GetImageCache().GetWidth());
m_textAttr.GetTextBoxAttr().GetWidth().SetUnits(wxTEXT_ATTR_UNITS_PIXELS);
}
if (m_attr.m_height == -1)
if (!m_textAttr.GetTextBoxAttr().GetHeight().IsPresent() || m_textAttr.GetTextBoxAttr().GetHeight().GetValue() <= 0)
{
m_attr.m_height = image->GetImageCache().GetHeight();
wxASSERT(m_attr.m_unitsH == wxRICHTEXT_PX);
m_attr.m_unitsH = wxRICHTEXT_PX;
m_textAttr.GetTextBoxAttr().GetHeight().SetValue(image->GetImageCache().GetHeight());
m_textAttr.GetTextBoxAttr().GetHeight().SetUnits(wxTEXT_ATTR_UNITS_PIXELS);
}
}
}
void wxRichTextImageDialog::SetDimensionValue(wxTextAttrDimension& dim, wxTextCtrl* valueCtrl, wxComboBox* unitsCtrl)
{
int unitsIdx = 0;
if (!dim.IsPresent())
{
dim.SetValue(0);
dim.SetUnits(wxTEXT_ATTR_UNITS_PIXELS);
}
if (dim.GetUnits() == wxTEXT_ATTR_UNITS_TENTHS_MM)
{
unitsIdx = 1;
float value = float(dim.GetValue()) / 10.0;
valueCtrl->SetValue(wxString::Format(wxT("%.2f"), value));
}
else
{
unitsIdx = 0;
valueCtrl->SetValue(wxString::Format(wxT("%d"), (int) dim.GetValue()));
}
unitsCtrl->SetSelection(unitsIdx);
}
void wxRichTextImageDialog::GetDimensionValue(wxTextAttrDimension& dim, wxTextCtrl* valueCtrl, wxComboBox* unitsCtrl)
{
if (unitsCtrl->GetSelection() == 1)
dim.SetUnits(wxTEXT_ATTR_UNITS_TENTHS_MM);
else
dim.SetUnits(wxTEXT_ATTR_UNITS_PIXELS);
int value = 0;
if (ConvertFromString(valueCtrl->GetValue(), value, dim.GetUnits()))
dim.SetValue(value);
}
bool wxRichTextImageDialog::TransferDataToWindow()
{
int remain = 100;
m_float->SetSelection(m_textAttr.GetTextBoxAttr().GetFloatMode());
m_alignment->SetSelection(m_attr.m_align);
m_float->SetSelection(m_attr.m_floating);
// Update scale
m_unitsW->SetSelection(m_attr.m_unitsW);
m_unitsH->SetSelection(m_attr.m_unitsH);
m_unitsOffset->SetSelection(m_attr.m_unitsOffset);
// Update metric
m_width->Clear();
if (m_attr.m_unitsW == wxRICHTEXT_MM)
{
int remainder = m_attr.m_width % remain;
*m_width << m_attr.m_width / remain;
if (remainder)
{
*m_width << '.' << remainder;
}
}
else
{
*m_width << m_attr.m_width;
}
m_height->Clear();
if (m_attr.m_unitsH == wxRICHTEXT_MM)
{
int remainder = m_attr.m_height % remain;
*m_height << m_attr.m_height / remain;
if (remainder)
{
*m_height << '.' << remainder;
}
}
else
{
*m_height << m_attr.m_height;
}
m_offset->Clear();
if (m_attr.m_unitsOffset == wxRICHTEXT_MM)
{
int remainder = m_attr.m_offset % remain;
*m_offset << m_attr.m_offset / remain;
if (remainder)
{
*m_offset << '.' << remainder;
}
}
else
{
*m_offset << m_attr.m_offset;
}
SetDimensionValue(m_textAttr.GetTextBoxAttr().GetWidth(), m_width, m_unitsW);
SetDimensionValue(m_textAttr.GetTextBoxAttr().GetHeight(), m_height, m_unitsH);
SetDimensionValue(m_textAttr.GetTextBoxAttr().GetTop(), m_offset, m_unitsOffset);
return true;
}
bool wxRichTextImageDialog::TransferDataFromWindow()
{
wxString width = m_width->GetValue();
wxString height = m_height->GetValue();
wxString offset = m_offset->GetValue();
int w, h, o;
m_textAttr.GetTextBoxAttr().SetFloatMode(m_float->GetSelection());
m_attr.m_align = m_alignment->GetSelection();
m_attr.m_floating = m_float->GetSelection();
m_attr.m_unitsW = m_unitsW->GetSelection();
m_attr.m_unitsH = m_unitsH->GetSelection();
m_attr.m_unitsOffset = m_unitsOffset->GetSelection();
if (ConvertFromString(width, w, m_attr.m_unitsW))
m_attr.m_width = w;
if (ConvertFromString(height, h, m_attr.m_unitsH))
m_attr.m_height = h;
if (ConvertFromString(offset, o, m_attr.m_unitsOffset))
m_attr.m_offset = o;
GetDimensionValue(m_textAttr.GetTextBoxAttr().GetWidth(), m_width, m_unitsW);
GetDimensionValue(m_textAttr.GetTextBoxAttr().GetHeight(), m_height, m_unitsH);
GetDimensionValue(m_textAttr.GetTextBoxAttr().GetTop(), m_offset, m_unitsOffset);
return true;
}
@ -463,7 +420,7 @@ bool wxRichTextImageDialog::ConvertFromString(const wxString& string, int& ret,
for (unsigned int i = 0; i < string.Len() && remain; i++)
{
if (!(chars[i] >= '0' && chars[i] <= '9') && !(scale == wxRICHTEXT_MM && chars[i] == '.'))
if (!(chars[i] >= '0' && chars[i] <= '9') && !(scale == wxTEXT_ATTR_UNITS_TENTHS_MM && chars[i] == '.'))
return false;
if (chars[i] == '.')
@ -478,7 +435,7 @@ bool wxRichTextImageDialog::ConvertFromString(const wxString& string, int& ret,
ret = ret * 10 + chars[i] - '0';
}
while (remain-- > 0 && scale == wxRICHTEXT_MM)
while (remain-- > 0 && scale == wxTEXT_ATTR_UNITS_TENTHS_MM)
ret *= 10;
return true;

View File

@ -340,7 +340,7 @@ void wxRichTextIndentsSpacingPage::CreateControls()
////@end wxRichTextIndentsSpacingPage content construction
}
wxTextAttr* wxRichTextIndentsSpacingPage::GetAttributes()
wxRichTextAttr* wxRichTextIndentsSpacingPage::GetAttributes()
{
return wxRichTextFormattingDialog::GetDialogAttributes(this);
}
@ -358,7 +358,7 @@ et magnis dis parturient montes, nascetur ridiculus mus. Nullam vitae justo id m
iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
TransferDataFromWindow();
wxTextAttr attr(*GetAttributes());
wxRichTextAttr attr(*GetAttributes());
attr.SetFlags(attr.GetFlags() &
(wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER|
wxTEXT_ATTR_LINE_SPACING|
@ -368,7 +368,7 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
font.SetPointSize(9);
m_previewCtrl->SetFont(font);
wxTextAttr normalParaAttr;
wxRichTextAttr normalParaAttr;
normalParaAttr.SetFont(font);
normalParaAttr.SetTextColour(wxColour(wxT("LIGHT GREY")));
@ -395,7 +395,7 @@ bool wxRichTextIndentsSpacingPage::TransferDataFromWindow()
{
wxPanel::TransferDataFromWindow();
wxTextAttr* attr = GetAttributes();
wxRichTextAttr* attr = GetAttributes();
if (m_alignmentLeft->GetValue())
attr->SetAlignment(wxTEXT_ALIGNMENT_LEFT);
@ -466,7 +466,7 @@ bool wxRichTextIndentsSpacingPage::TransferDataToWindow()
wxPanel::TransferDataToWindow();
wxTextAttr* attr = GetAttributes();
wxRichTextAttr* attr = GetAttributes();
if (attr->HasAlignment())
{

View File

@ -528,7 +528,7 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
wxRichTextStyleSheet* styleSheet = wxRichTextFormattingDialog::GetDialog(this)->GetStyleSheet();
wxTextAttr attr((const wxTextAttr &)(styleSheet ? def->GetStyle() : def->GetStyleMergedWithBase(styleSheet)));
wxRichTextAttr attr((const wxRichTextAttr &)(styleSheet ? def->GetStyle() : def->GetStyleMergedWithBase(styleSheet)));
attr.SetFlags(attr.GetFlags() &
(wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER|
@ -539,7 +539,7 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
font.SetPointSize(9);
m_previewCtrl->SetFont(font);
wxTextAttr normalParaAttr;
wxRichTextAttr normalParaAttr;
normalParaAttr.SetFont(font);
normalParaAttr.SetTextColour(wxColour(wxT("LIGHT GREY")));
@ -556,7 +556,7 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
int i;
for (i = 0; i < 10; i++)
{
wxTextAttr levelAttr = * def->GetLevelAttributes(i);
wxRichTextAttr levelAttr = * def->GetLevelAttributes(i);
levelAttr.SetBulletNumber(1);
m_previewCtrl->BeginStyle(levelAttr);
m_previewCtrl->WriteText(wxString::Format(wxT("List level %d. "), i+1) + s_para2);
@ -581,7 +581,7 @@ bool wxRichTextListStylePage::TransferDataFromWindow()
m_currentLevel = m_levelCtrl->GetValue();
wxTextAttr* attr = GetAttributesForSelection();
wxRichTextAttr* attr = GetAttributesForSelection();
if (m_alignmentLeft->GetValue())
attr->SetAlignment(wxTEXT_ALIGNMENT_LEFT);
@ -719,7 +719,7 @@ void wxRichTextListStylePage::DoTransferDataToWindow()
wxPanel::TransferDataToWindow();
wxTextAttr* attr = GetAttributesForSelection();
wxRichTextAttr* attr = GetAttributesForSelection();
if (attr->HasAlignment())
{
@ -875,7 +875,7 @@ void wxRichTextListStylePage::DoTransferDataToWindow()
}
/// Get attributes for selected level
wxTextAttr* wxRichTextListStylePage::GetAttributesForSelection()
wxRichTextAttr* wxRichTextListStylePage::GetAttributesForSelection()
{
wxRichTextListStyleDefinition* def = wxDynamicCast(wxRichTextFormattingDialog::GetDialogStyleDefinition(this),
wxRichTextListStyleDefinition);
@ -1280,7 +1280,7 @@ void wxRichTextListStylePage::OnStandardBulletUpdate( wxUpdateUIEvent& event )
void wxRichTextListStylePage::OnChooseFontClick( wxCommandEvent& WXUNUSED(event) )
{
wxTextAttr* attr = GetAttributesForSelection();
wxRichTextAttr* attr = GetAttributesForSelection();
int pages = wxRICHTEXT_FORMAT_FONT;
wxRichTextFormattingDialog formatDlg;

View File

@ -430,13 +430,13 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
if (labelCtrl)
labelCtrl->SetLabel(def->GetName() + wxT(":"));
wxTextAttr attr(def->GetStyleMergedWithBase(GetStyleSheet()));
wxRichTextAttr attr(def->GetStyleMergedWithBase(GetStyleSheet()));
wxFont font(m_previewCtrl->GetFont());
font.SetPointSize(9);
m_previewCtrl->SetFont(font);
wxTextAttr normalParaAttr;
wxRichTextAttr normalParaAttr;
normalParaAttr.SetFont(font);
normalParaAttr.SetTextColour(wxColour(wxT("LIGHT GREY")));
@ -455,7 +455,7 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
int i;
for (i = 0; i < 10; i++)
{
wxTextAttr levelAttr = * listDef->GetLevelAttributes(i);
wxRichTextAttr levelAttr = * listDef->GetLevelAttributes(i);
levelAttr.SetBulletNumber(1);
m_previewCtrl->BeginStyle(levelAttr);
m_previewCtrl->WriteText(wxString::Format(wxT("List level %d. "), i+1) + s_para2List);

View File

@ -245,7 +245,7 @@ bool wxRichTextStylePage::TransferDataToWindow()
return true;
}
wxTextAttr* wxRichTextStylePage::GetAttributes()
wxRichTextAttr* wxRichTextStylePage::GetAttributes()
{
return wxRichTextFormattingDialog::GetDialogAttributes(this);
}

View File

@ -54,7 +54,7 @@ bool wxRichTextStyleDefinition::Eq(const wxRichTextStyleDefinition& def) const
}
/// Gets the style combined with the base style
wxTextAttr wxRichTextStyleDefinition::GetStyleMergedWithBase(const wxRichTextStyleSheet* sheet) const
wxRichTextAttr wxRichTextStyleDefinition::GetStyleMergedWithBase(const wxRichTextStyleSheet* sheet) const
{
if (m_baseStyle.IsEmpty())
return m_style;
@ -129,14 +129,14 @@ bool wxRichTextListStyleDefinition::operator ==(const wxRichTextListStyleDefinit
}
/// Sets/gets the attributes for the given level
void wxRichTextListStyleDefinition::SetLevelAttributes(int i, const wxTextAttr& attr)
void wxRichTextListStyleDefinition::SetLevelAttributes(int i, const wxRichTextAttr& attr)
{
wxASSERT( (i >= 0 && i < 10) );
if (i >= 0 && i < 10)
m_levelStyles[i] = attr;
}
const wxTextAttr* wxRichTextListStyleDefinition::GetLevelAttributes(int i) const
const wxRichTextAttr* wxRichTextListStyleDefinition::GetLevelAttributes(int i) const
{
wxASSERT( (i >= 0 && i < 10) );
if (i >= 0 && i < 10)
@ -145,7 +145,7 @@ const wxTextAttr* wxRichTextListStyleDefinition::GetLevelAttributes(int i) const
return NULL;
}
wxTextAttr* wxRichTextListStyleDefinition::GetLevelAttributes(int i)
wxRichTextAttr* wxRichTextListStyleDefinition::GetLevelAttributes(int i)
{
wxASSERT( (i >= 0 && i < 10) );
if (i >= 0 && i < 10)
@ -160,7 +160,7 @@ void wxRichTextListStyleDefinition::SetAttributes(int i, int leftIndent, int lef
wxASSERT( (i >= 0 && i < 10) );
if (i >= 0 && i < 10)
{
wxTextAttr attr;
wxRichTextAttr attr;
attr.SetBulletStyle(bulletStyle);
attr.SetLeftIndent(leftIndent, leftSubIndent);
@ -196,11 +196,11 @@ int wxRichTextListStyleDefinition::FindLevelForIndent(int indent) const
/// Combine the list style with a paragraph style, using the given indent (from which
/// an appropriate level is found)
wxTextAttr wxRichTextListStyleDefinition::CombineWithParagraphStyle(int indent, const wxTextAttr& paraStyle, wxRichTextStyleSheet* styleSheet)
wxRichTextAttr wxRichTextListStyleDefinition::CombineWithParagraphStyle(int indent, const wxRichTextAttr& paraStyle, wxRichTextStyleSheet* styleSheet)
{
int listLevel = FindLevelForIndent(indent);
wxTextAttr attr(*GetLevelAttributes(listLevel));
wxRichTextAttr attr(*GetLevelAttributes(listLevel));
int oldLeftIndent = attr.GetLeftIndent();
int oldLeftSubIndent = attr.GetLeftSubIndent();
@ -221,7 +221,7 @@ wxTextAttr wxRichTextListStyleDefinition::CombineWithParagraphStyle(int indent,
/// Combine the base and list style, using the given indent (from which
/// an appropriate level is found)
wxTextAttr wxRichTextListStyleDefinition::GetCombinedStyle(int indent, wxRichTextStyleSheet* styleSheet)
wxRichTextAttr wxRichTextListStyleDefinition::GetCombinedStyle(int indent, wxRichTextStyleSheet* styleSheet)
{
int listLevel = FindLevelForIndent(indent);
return GetCombinedStyleForLevel(listLevel, styleSheet);
@ -229,9 +229,9 @@ wxTextAttr wxRichTextListStyleDefinition::GetCombinedStyle(int indent, wxRichTex
/// Combine the base and list style, using the given indent (from which
/// an appropriate level is found)
wxTextAttr wxRichTextListStyleDefinition::GetCombinedStyleForLevel(int listLevel, wxRichTextStyleSheet* styleSheet)
wxRichTextAttr wxRichTextListStyleDefinition::GetCombinedStyleForLevel(int listLevel, wxRichTextStyleSheet* styleSheet)
{
wxTextAttr attr(*GetLevelAttributes(listLevel));
wxRichTextAttr attr(*GetLevelAttributes(listLevel));
int oldLeftIndent = attr.GetLeftIndent();
int oldLeftSubIndent = attr.GetLeftSubIndent();
@ -616,7 +616,7 @@ wxString wxRichTextStyleListBox::CreateHTML(wxRichTextStyleDefinition* def) cons
bool isCentred = false;
wxTextAttr attr(def->GetStyleMergedWithBase(GetStyleSheet()));
wxRichTextAttr attr(def->GetStyleMergedWithBase(GetStyleSheet()));
if (attr.HasAlignment() && attr.GetAlignment() == wxTEXT_ALIGNMENT_CENTRE)
isCentred = true;
@ -800,7 +800,7 @@ wxString wxRichTextStyleListBox::GetStyleToShowInIdleTime(wxRichTextCtrl* ctrl,
wxString styleName;
wxTextAttr attr;
wxRichTextAttr attr;
ctrl->GetStyle(adjustedCaretPos, attr);
// Take into account current default style just chosen by user

View File

@ -158,7 +158,7 @@ bool wxRichTextTabsPage::TransferDataFromWindow()
{
wxPanel::TransferDataFromWindow();
wxTextAttr* attr = GetAttributes();
wxRichTextAttr* attr = GetAttributes();
if (m_tabsPresent)
{
@ -177,7 +177,7 @@ bool wxRichTextTabsPage::TransferDataToWindow()
{
wxPanel::TransferDataToWindow();
wxTextAttr* attr = GetAttributes();
wxRichTextAttr* attr = GetAttributes();
m_tabListCtrl->Clear();
m_tabEditCtrl->SetValue(wxEmptyString);
@ -225,7 +225,7 @@ void wxRichTextTabsPage::SortTabs()
}
}
wxTextAttr* wxRichTextTabsPage::GetAttributes()
wxRichTextAttr* wxRichTextTabsPage::GetAttributes()
{
return wxRichTextFormattingDialog::GetDialogAttributes(this);
}

View File

@ -284,7 +284,7 @@ bool wxRichTextXMLHandler::ImportStyleDefinition(wxRichTextStyleSheet* sheet, wx
{
if (child->GetName() == wxT("style"))
{
wxTextAttr attr;
wxRichTextAttr attr;
GetStyle(attr, child, false);
def->SetStyle(attr);
}
@ -306,7 +306,7 @@ bool wxRichTextXMLHandler::ImportStyleDefinition(wxRichTextStyleSheet* sheet, wx
{
if (child->GetName() == wxT("style"))
{
wxTextAttr attr;
wxRichTextAttr attr;
GetStyle(attr, child, false);
def->SetStyle(attr);
}
@ -328,7 +328,7 @@ bool wxRichTextXMLHandler::ImportStyleDefinition(wxRichTextStyleSheet* sheet, wx
{
if (child->GetName() == wxT("style"))
{
wxTextAttr attr;
wxRichTextAttr attr;
GetStyle(attr, child, false);
wxString styleLevel = child->GetAttribute(wxT("level"), wxEmptyString);
@ -927,7 +927,7 @@ bool wxRichTextXMLHandler::ExportStyleDefinition(wxOutputStream& stream, wxMBCon
int i;
for (i = 0; i < 10; i ++)
{
wxTextAttr* levelAttr = listDef->GetLevelAttributes(i);
wxRichTextAttr* levelAttr = listDef->GetLevelAttributes(i);
if (levelAttr)
{
wxString style = CreateStyle(def->GetStyle(), false);
@ -975,7 +975,7 @@ bool wxRichTextXMLHandler::ExportStyleDefinition(wxOutputStream& stream, wxMBCon
}
/// Create style parameters
wxString wxRichTextXMLHandler::CreateStyle(const wxTextAttr& attr, bool isPara)
wxString wxRichTextXMLHandler::CreateStyle(const wxRichTextAttr& attr, bool isPara)
{
wxString str;
if (attr.HasTextColour() && attr.GetTextColour().Ok())
@ -1146,7 +1146,7 @@ bool wxRichTextFixFaceName(wxString& facename)
}
/// Get style parameters
bool wxRichTextXMLHandler::GetStyle(wxTextAttr& attr, wxXmlNode* node, bool isPara)
bool wxRichTextXMLHandler::GetStyle(wxRichTextAttr& attr, wxXmlNode* node, bool isPara)
{
wxString fontFacename;
int fontSize = 12;