Added pixel size capability to wxTextAttr and wxRichTextCtrl.

Fixed composite object positioning in centred and right-aligned
paragraphs.
Added field example to sample, and enabled pixel font size selection.
Added custom text and dimension scaling.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71505 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2012-05-20 12:25:22 +00:00
parent c564ca3c97
commit 32423dd824
20 changed files with 1421 additions and 525 deletions

View File

@@ -548,6 +548,8 @@ All (GUI):
- Added wxAcceleratorEntry::ToRawString() (Armel Asselin). - Added wxAcceleratorEntry::ToRawString() (Armel Asselin).
- Added wxDataViewEvent::SetDragFlags() and GetDropEffect() (Friedrich). - Added wxDataViewEvent::SetDragFlags() and GetDropEffect() (Friedrich).
- Added support for fields and virtual attributes to wxRichTextCtrl. - Added support for fields and virtual attributes to wxRichTextCtrl.
- Added custom text and dimension scaling to wxRichTextCtrl.
- Added pixel font size capability to wxTextAttr and wxRichTextCtrl.
GTK: GTK:

View File

@@ -281,7 +281,7 @@ enum wxRichTextHitTestFlags
// A special flag telling the buffer to keep the first paragraph style // A special flag telling the buffer to keep the first paragraph style
// as-is, when deleting a paragraph marker. In future we might pass a // as-is, when deleting a paragraph marker. In future we might pass a
// flag to InsertFragment and DeleteRange to indicate the appropriate mode. // flag to InsertFragment and DeleteRange to indicate the appropriate mode.
#define wxTEXT_ATTR_KEEP_FIRST_PARA_STYLE 0x10000000 #define wxTEXT_ATTR_KEEP_FIRST_PARA_STYLE 0x20000000
/** /**
Default superscript/subscript font multiplication factor. Default superscript/subscript font multiplication factor.
@@ -370,9 +370,12 @@ public:
void Reset() { m_value = 0; m_flags = 0; } void Reset() { m_value = 0; m_flags = 0; }
/** /**
Partial equality test. Partial equality test. If @a weakTest is @true, attributes of this object do not
have to be present if those attributes of @a dim are present. If @a weakTest is
@false, the function will fail if an attribute is present in @a dim but not
in this object.
*/ */
bool EqPartial(const wxTextAttrDimension& dim) const; bool EqPartial(const wxTextAttrDimension& dim, bool weakTest = true) const;
/** Apply the dimension, but not those identical to @a compareWith if present. /** Apply the dimension, but not those identical to @a compareWith if present.
*/ */
@@ -497,10 +500,13 @@ public:
bool operator==(const wxTextAttrDimensions& dims) const { return m_left == dims.m_left && m_top == dims.m_top && m_right == dims.m_right && m_bottom == dims.m_bottom; } bool operator==(const wxTextAttrDimensions& 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. Partial equality test. If @a weakTest is @true, attributes of this object do not
have to be present if those attributes of @a dim sare present. If @a weakTest is
@false, the function will fail if an attribute is present in @a dims but not
in this object.
*/ */
bool EqPartial(const wxTextAttrDimensions& dims) const; bool EqPartial(const wxTextAttrDimensions& dims, bool weakTest = true) const;
/** /**
Apply to 'this', but not if the same as @a compareWith. Apply to 'this', but not if the same as @a compareWith.
@@ -588,9 +594,12 @@ public:
bool operator==(const wxTextAttrSize& size) const { return m_width == size.m_width && m_height == size.m_height ; } bool operator==(const wxTextAttrSize& size) const { return m_width == size.m_width && m_height == size.m_height ; }
/** /**
Partial equality test. Partial equality test. If @a weakTest is @true, attributes of this object do not
have to be present if those attributes of @a size are present. If @a weakTest is
@false, the function will fail if an attribute is present in @a size but not
in this object.
*/ */
bool EqPartial(const wxTextAttrSize& dims) const; bool EqPartial(const wxTextAttrSize& size, bool weakTest = true) const;
/** /**
Apply to this object, but not if the same as @a compareWith. Apply to this object, but not if the same as @a compareWith.
@@ -813,9 +822,12 @@ public:
void Reset() { m_borderStyle = 0; m_borderColour = 0; m_flags = 0; m_borderWidth.Reset(); } void Reset() { m_borderStyle = 0; m_borderColour = 0; m_flags = 0; m_borderWidth.Reset(); }
/** /**
Partial equality test. Partial equality test. If @a weakTest is @true, attributes of this object do not
have to be present if those attributes of @a border are present. If @a weakTest is
@false, the function will fail if an attribute is present in @a border but not
in this object.
*/ */
bool EqPartial(const wxTextAttrBorder& border) const; bool EqPartial(const wxTextAttrBorder& border, bool weakTest = true) const;
/** /**
Applies the border to this object, but not if the same as @a compareWith. Applies the border to this object, but not if the same as @a compareWith.
@@ -989,9 +1001,12 @@ public:
void Reset() { m_left.Reset(); m_right.Reset(); m_top.Reset(); m_bottom.Reset(); } void Reset() { m_left.Reset(); m_right.Reset(); m_top.Reset(); m_bottom.Reset(); }
/** /**
Partial equality test. Partial equality test. If @a weakTest is @true, attributes of this object do not
have to be present if those attributes of @a borders are present. If @a weakTest is
@false, the function will fail if an attribute is present in @a borders but not
in this object.
*/ */
bool EqPartial(const wxTextAttrBorders& borders) const; bool EqPartial(const wxTextAttrBorders& borders, bool weakTest = true) const;
/** /**
Applies border to this object, but not if the same as @a compareWith. Applies border to this object, but not if the same as @a compareWith.
@@ -1087,10 +1102,13 @@ public:
bool operator== (const wxTextBoxAttr& attr) const; bool operator== (const wxTextBoxAttr& attr) const;
/** /**
Partial equality test, ignoring unset attributes. Partial equality test, ignoring unset attributes. If @a weakTest is @true, attributes of this object do not
have to be present if those attributes of @a attr are present. If @a weakTest is
@false, the function will fail if an attribute is present in @a attr but not
in this object.
*/ */
bool EqPartial(const wxTextBoxAttr& attr) const; bool EqPartial(const wxTextBoxAttr& attr, bool weakTest = true) const;
/** /**
Merges the given attributes. If @a compareWith is non-NULL, then it will be used Merges the given attributes. If @a compareWith is non-NULL, then it will be used
@@ -1489,9 +1507,12 @@ public:
bool operator==(const wxRichTextAttr& attr) const; bool operator==(const wxRichTextAttr& attr) const;
/** /**
Partial equality test taking comparison object into account. Partial equality test. If @a weakTest is @true, attributes of this object do not
have to be present if those attributes of @a attr are present. If @a weakTest is
@false, the function will fail if an attribute is present in @a attr but not
in this object.
*/ */
bool EqPartial(const wxRichTextAttr& attr) const; bool EqPartial(const wxRichTextAttr& attr, bool weakTest = true) const;
/** /**
Merges the given attributes. If @a compareWith Merges the given attributes. If @a compareWith
@@ -1752,8 +1773,15 @@ public:
*/ */
bool operator != (const wxRichTextFontTable& table) const { return !(*this == table); } bool operator != (const wxRichTextFontTable& table) const { return !(*this == table); }
/**
Set the font scale factor.
*/
void SetFontScale(double fontScale);
protected: protected:
double m_fontScale;
DECLARE_DYNAMIC_CLASS(wxRichTextFontTable) DECLARE_DYNAMIC_CLASS(wxRichTextFontTable)
}; };
@@ -3545,7 +3573,7 @@ public:
Update the field; delegated to the associated field type. This would typically expand the field to its value, Update the field; delegated to the associated field type. This would typically expand the field to its value,
if this is a dynamically changing and/or composite field. if this is a dynamically changing and/or composite field.
*/ */
virtual bool UpdateField(); virtual bool UpdateField(wxRichTextBuffer* buffer);
virtual wxRichTextObject* Clone() const { return new wxRichTextField(*this); } virtual wxRichTextObject* Clone() const { return new wxRichTextField(*this); }
@@ -3628,7 +3656,7 @@ public:
Update the field. This would typically expand the field to its value, Update the field. This would typically expand the field to its value,
if this is a dynamically changing and/or composite field. if this is a dynamically changing and/or composite field.
*/ */
virtual bool UpdateField(wxRichTextField* WXUNUSED(obj)) { return false; } virtual bool UpdateField(wxRichTextBuffer* WXUNUSED(buffer), wxRichTextField* WXUNUSED(obj)) { return false; }
/** /**
Returns @true if this object is top-level, i.e. contains its own paragraphs, such as a text box. Returns @true if this object is top-level, i.e. contains its own paragraphs, such as a text box.
@@ -4704,6 +4732,31 @@ public:
*/ */
void SetFontTable(const wxRichTextFontTable& table) { m_fontTable = table; } void SetFontTable(const wxRichTextFontTable& table) { m_fontTable = table; }
/**
Sets the scale factor for displaying fonts, for example for more comfortable
editing.
*/
void SetFontScale(double fontScale);
/**
Returns the scale factor for displaying fonts, for example for more comfortable
editing.
*/
double GetFontScale() const { return m_fontScale; }
/**
Sets the scale factor for displaying certain dimensions such as indentation and
inter-paragraph spacing. This can be useful when editing in a small control
where you still want legible text, but a minimum of wasted white space.
*/
void SetDimensionScale(double dimScale);
/**
Returns the scale factor for displaying certain dimensions such as indentation
and inter-paragraph spacing.
*/
double GetDimensionScale() const { return m_dimensionScale; }
// Operations // Operations
/** /**
@@ -5374,6 +5427,12 @@ protected:
/// Scaling factor in use: needed to calculate correct dimensions when printing /// Scaling factor in use: needed to calculate correct dimensions when printing
double m_scale; double m_scale;
/// Font scale for adjusting the text size when editing
double m_fontScale;
/// Dimension scale for reducing redundant whitespace when editing
double m_dimensionScale;
}; };
/** /**
@@ -6332,10 +6391,6 @@ inline bool wxRichTextHasStyle(int flags, int style)
WXDLLIMPEXP_RICHTEXT bool wxTextAttrEq(const wxRichTextAttr& attr1, const wxRichTextAttr& attr2); WXDLLIMPEXP_RICHTEXT bool wxTextAttrEq(const wxRichTextAttr& attr1, const wxRichTextAttr& 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 wxRichTextAttr& attr1, const wxRichTextAttr& attr2);
/// Apply one style to another /// Apply one style to another
WXDLLIMPEXP_RICHTEXT bool wxRichTextApplyStyle(wxRichTextAttr& destStyle, const wxRichTextAttr& style, wxRichTextAttr* compareWith = NULL); WXDLLIMPEXP_RICHTEXT bool wxRichTextApplyStyle(wxRichTextAttr& destStyle, const wxRichTextAttr& style, wxRichTextAttr* compareWith = NULL);

View File

@@ -1701,6 +1701,31 @@ public:
*/ */
virtual bool GetVerticalScrollbarEnabled() const { return m_verticalScrollbarEnabled; } virtual bool GetVerticalScrollbarEnabled() const { return m_verticalScrollbarEnabled; }
/**
Sets the scale factor for displaying fonts, for example for more comfortable
editing.
*/
void SetFontScale(double fontScale, bool refresh = false);
/**
Returns the scale factor for displaying fonts, for example for more comfortable
editing.
*/
double GetFontScale() const { return GetBuffer().GetFontScale(); }
/**
Sets the scale factor for displaying certain dimensions such as indentation and
inter-paragraph spacing. This can be useful when editing in a small control
where you still want legible text, but a minimum of wasted white space.
*/
void SetDimensionScale(double dimScale, bool refresh = false);
/**
Returns the scale factor for displaying certain dimensions such as indentation
and inter-paragraph spacing.
*/
double GetDimensionScale() const { return GetBuffer().GetDimensionScale(); }
// Command handlers // Command handlers
/** /**

View File

@@ -19,6 +19,7 @@
#include "wx/richtext/richtextdialogpage.h" #include "wx/richtext/richtextdialogpage.h"
////@begin includes ////@begin includes
#include "wx/spinbutt.h"
////@end includes ////@end includes
/*! /*!
@@ -26,6 +27,8 @@
*/ */
////@begin forward declarations ////@begin forward declarations
class wxSpinButton;
class wxBoxSizer;
class wxRichTextFontListBox; class wxRichTextFontListBox;
class wxRichTextColourSwatchCtrl; class wxRichTextColourSwatchCtrl;
class wxRichTextFontPreviewCtrl; class wxRichTextFontPreviewCtrl;
@@ -82,12 +85,24 @@ public:
////@begin wxRichTextFontPage event handler declarations ////@begin wxRichTextFontPage event handler declarations
/// wxEVT_IDLE event handler for ID_RICHTEXTFONTPAGE
void OnIdle( wxIdleEvent& event );
/// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTFONTPAGE_FACETEXTCTRL /// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTFONTPAGE_FACETEXTCTRL
void OnFaceTextCtrlUpdated( wxCommandEvent& event ); void OnFaceTextCtrlUpdated( wxCommandEvent& event );
/// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTFONTPAGE_SIZETEXTCTRL /// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTFONTPAGE_SIZETEXTCTRL
void OnSizeTextCtrlUpdated( wxCommandEvent& event ); void OnSizeTextCtrlUpdated( wxCommandEvent& event );
/// wxEVT_SCROLL_LINEUP event handler for ID_RICHTEXTFONTPAGE_SPINBUTTONS
void OnRichtextfontpageSpinbuttonsUp( wxSpinEvent& event );
/// wxEVT_SCROLL_LINEDOWN event handler for ID_RICHTEXTFONTPAGE_SPINBUTTONS
void OnRichtextfontpageSpinbuttonsDown( wxSpinEvent& event );
/// wxEVT_COMMAND_CHOICE_SELECTED event handler for ID_RICHTEXTFONTPAGE_SIZE_UNITS
void OnRichtextfontpageSizeUnitsSelected( wxCommandEvent& event );
/// wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_SIZELISTBOX /// wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_SIZELISTBOX
void OnSizeListBoxSelected( wxCommandEvent& event ); void OnSizeListBoxSelected( wxCommandEvent& event );
@@ -128,8 +143,11 @@ public:
////@begin wxRichTextFontPage member variables ////@begin wxRichTextFontPage member variables
wxTextCtrl* m_faceTextCtrl; wxTextCtrl* m_faceTextCtrl;
wxRichTextFontListBox* m_faceListBox;
wxTextCtrl* m_sizeTextCtrl; wxTextCtrl* m_sizeTextCtrl;
wxSpinButton* m_fontSizeSpinButtons;
wxChoice* m_sizeUnitsCtrl;
wxBoxSizer* m_fontListBoxParent;
wxRichTextFontListBox* m_faceListBox;
wxListBox* m_sizeListBox; wxListBox* m_sizeListBox;
wxComboBox* m_styleCtrl; wxComboBox* m_styleCtrl;
wxComboBox* m_weightCtrl; wxComboBox* m_weightCtrl;
@@ -147,8 +165,10 @@ public:
enum { enum {
ID_RICHTEXTFONTPAGE = 10000, ID_RICHTEXTFONTPAGE = 10000,
ID_RICHTEXTFONTPAGE_FACETEXTCTRL = 10001, ID_RICHTEXTFONTPAGE_FACETEXTCTRL = 10001,
ID_RICHTEXTFONTPAGE_FACELISTBOX = 10002,
ID_RICHTEXTFONTPAGE_SIZETEXTCTRL = 10005, ID_RICHTEXTFONTPAGE_SIZETEXTCTRL = 10005,
ID_RICHTEXTFONTPAGE_SPINBUTTONS = 10018,
ID_RICHTEXTFONTPAGE_SIZE_UNITS = 10017,
ID_RICHTEXTFONTPAGE_FACELISTBOX = 10002,
ID_RICHTEXTFONTPAGE_SIZELISTBOX = 10006, ID_RICHTEXTFONTPAGE_SIZELISTBOX = 10006,
ID_RICHTEXTFONTPAGE_STYLECTRL = 10007, ID_RICHTEXTFONTPAGE_STYLECTRL = 10007,
ID_RICHTEXTFONTPAGE_WEIGHTCTRL = 10004, ID_RICHTEXTFONTPAGE_WEIGHTCTRL = 10004,

View File

@@ -126,6 +126,8 @@ DECLARE_CLASS(wxRichTextFormattingDialog)
DECLARE_HELP_PROVISION() DECLARE_HELP_PROVISION()
public: public:
enum { Option_AllowPixelFontSize = 0x0001 };
wxRichTextFormattingDialog() { Init(); } wxRichTextFormattingDialog() { Init(); }
wxRichTextFormattingDialog(long flags, wxWindow* parent, const wxString& title = wxGetTranslation(wxT("Formatting")), wxWindowID id = wxID_ANY, wxRichTextFormattingDialog(long flags, wxWindow* parent, const wxString& title = wxGetTranslation(wxT("Formatting")), wxWindowID id = wxID_ANY,
@@ -172,12 +174,18 @@ public:
const wxRichTextAttr& GetAttributes() const { return m_attributes; } const wxRichTextAttr& GetAttributes() const { return m_attributes; }
wxRichTextAttr& GetAttributes() { return m_attributes; } wxRichTextAttr& GetAttributes() { return m_attributes; }
void SetAttributes(const wxRichTextAttr& attr) { m_attributes = attr; } void SetAttributes(const wxRichTextAttr& attr) { m_attributes = attr; }
#if 0
/// Gets and sets the attributes that the user wants to reset /// Sets the dialog options, determining what the interface presents to the user.
const wxRichTextAttr& GetResetAttributes() const { return m_resetAttributes; } /// Currently the only option is Option_AllowPixelFontSize.
wxRichTextAttr& GetResetAttributes() { return m_resetAttributes; } void SetOptions(int options) { m_options = options; }
void SetResetAttributes(const wxRichTextAttr& attr) { m_resetAttributes = attr; }
#endif /// Gets the dialog options, determining what the interface presents to the user.
/// Currently the only option is Option_AllowPixelFontSize.
int GetOptions() const { return m_options; }
/// Returns @true if the given option is present.
bool HasOption(int option) const { return (m_options & option) != 0; }
/// If editing the attributes for a particular object, such as an image, /// If editing the attributes for a particular object, such as an image,
/// set the object so the code can initialize attributes such as size correctly. /// set the object so the code can initialize attributes such as size correctly.
wxRichTextObject* GetObject() const { return m_object; } wxRichTextObject* GetObject() const { return m_object; }
@@ -235,11 +243,11 @@ public:
protected: protected:
wxRichTextAttr m_attributes; wxRichTextAttr m_attributes;
//wxRichTextAttr m_resetAttributes;
wxRichTextStyleDefinition* m_styleDefinition; wxRichTextStyleDefinition* m_styleDefinition;
wxRichTextStyleSheet* m_styleSheet; wxRichTextStyleSheet* m_styleSheet;
wxRichTextObject* m_object; wxRichTextObject* m_object;
wxArrayInt m_pageIds; // mapping of book control indexes to page ids wxArrayInt m_pageIds; // mapping of book control indexes to page ids
int m_options; // UI options
static wxRichTextFormattingDialogFactory* ms_FormattingDialogFactory; static wxRichTextFormattingDialogFactory* ms_FormattingDialogFactory;
static bool sm_showToolTips; static bool sm_showToolTips;

View File

@@ -102,7 +102,7 @@ public:
virtual wxRichTextAttr GetStyleMergedWithBase(const wxRichTextStyleSheet* sheet) const; virtual wxRichTextAttr GetStyleMergedWithBase(const wxRichTextStyleSheet* sheet) const;
/** /**
Sets the definition's properties. Returns the definition's properties.
*/ */
wxRichTextProperties& GetProperties() { return m_properties; } wxRichTextProperties& GetProperties() { return m_properties; }
@@ -112,7 +112,7 @@ public:
const wxRichTextProperties& GetProperties() const { return m_properties; } const wxRichTextProperties& GetProperties() const { return m_properties; }
/** /**
Returns the definition's properties. Sets the definition's properties.
*/ */
void SetProperties(const wxRichTextProperties& props) { m_properties = props; } void SetProperties(const wxRichTextProperties& props) { m_properties = props; }
@@ -419,17 +419,17 @@ public:
const wxString& GetDescription() const { return m_description; } const wxString& GetDescription() const { return m_description; }
/** /**
Sets the definition's properties. Returns the sheet's properties.
*/ */
wxRichTextProperties& GetProperties() { return m_properties; } wxRichTextProperties& GetProperties() { return m_properties; }
/** /**
Returns the definition's properties. Returns the sheet's properties.
*/ */
const wxRichTextProperties& GetProperties() const { return m_properties; } const wxRichTextProperties& GetProperties() const { return m_properties; }
/** /**
Returns the definition's properties. Sets the sheet's properties.
*/ */
void SetProperties(const wxRichTextProperties& props) { m_properties = props; } void SetProperties(const wxRichTextProperties& props) { m_properties = props; }

View File

@@ -166,13 +166,16 @@ enum wxTextAttrFlags
wxTEXT_ATTR_BACKGROUND_COLOUR = 0x00000002, wxTEXT_ATTR_BACKGROUND_COLOUR = 0x00000002,
wxTEXT_ATTR_FONT_FACE = 0x00000004, wxTEXT_ATTR_FONT_FACE = 0x00000004,
wxTEXT_ATTR_FONT_SIZE = 0x00000008, wxTEXT_ATTR_FONT_POINT_SIZE = 0x00000008,
wxTEXT_ATTR_FONT_PIXEL_SIZE = 0x10000000,
wxTEXT_ATTR_FONT_WEIGHT = 0x00000010, wxTEXT_ATTR_FONT_WEIGHT = 0x00000010,
wxTEXT_ATTR_FONT_ITALIC = 0x00000020, wxTEXT_ATTR_FONT_ITALIC = 0x00000020,
wxTEXT_ATTR_FONT_UNDERLINE = 0x00000040, wxTEXT_ATTR_FONT_UNDERLINE = 0x00000040,
wxTEXT_ATTR_FONT_STRIKETHROUGH = 0x08000000, wxTEXT_ATTR_FONT_STRIKETHROUGH = 0x08000000,
wxTEXT_ATTR_FONT_ENCODING = 0x02000000, wxTEXT_ATTR_FONT_ENCODING = 0x02000000,
wxTEXT_ATTR_FONT_FAMILY = 0x04000000, wxTEXT_ATTR_FONT_FAMILY = 0x04000000,
wxTEXT_ATTR_FONT_SIZE = \
( wxTEXT_ATTR_FONT_POINT_SIZE | wxTEXT_ATTR_FONT_PIXEL_SIZE ),
wxTEXT_ATTR_FONT = \ wxTEXT_ATTR_FONT = \
( wxTEXT_ATTR_FONT_FACE | wxTEXT_ATTR_FONT_SIZE | wxTEXT_ATTR_FONT_WEIGHT | \ ( wxTEXT_ATTR_FONT_FACE | wxTEXT_ATTR_FONT_SIZE | wxTEXT_ATTR_FONT_WEIGHT | \
wxTEXT_ATTR_FONT_ITALIC | wxTEXT_ATTR_FONT_UNDERLINE | wxTEXT_ATTR_FONT_STRIKETHROUGH | wxTEXT_ATTR_FONT_ENCODING | wxTEXT_ATTR_FONT_FAMILY ), wxTEXT_ATTR_FONT_ITALIC | wxTEXT_ATTR_FONT_UNDERLINE | wxTEXT_ATTR_FONT_STRIKETHROUGH | wxTEXT_ATTR_FONT_ENCODING | wxTEXT_ATTR_FONT_FAMILY ),
@@ -298,8 +301,11 @@ public:
// Equality test // Equality test
bool operator== (const wxTextAttr& attr) const; bool operator== (const wxTextAttr& attr) const;
// Partial equality test // Partial equality test. If @a weakTest is @true, attributes of this object do not
bool EqPartial(const wxTextAttr& attr) const; // have to be present if those attributes of @a attr are present. If @a weakTest is
// @false, the function will fail if an attribute is present in @a attr but not
// in this object.
bool EqPartial(const wxTextAttr& attr, bool weakTest = true) const;
// Get attributes from font. // Get attributes from font.
bool GetFontAttributes(const wxFont& font, int flags = wxTEXT_ATTR_FONT); bool GetFontAttributes(const wxFont& font, int flags = wxTEXT_ATTR_FONT);
@@ -312,7 +318,9 @@ public:
void SetLeftIndent(int indent, int subIndent = 0) { m_leftIndent = indent; m_leftSubIndent = subIndent; m_flags |= wxTEXT_ATTR_LEFT_INDENT; } void SetLeftIndent(int indent, int subIndent = 0) { m_leftIndent = indent; m_leftSubIndent = subIndent; m_flags |= wxTEXT_ATTR_LEFT_INDENT; }
void SetRightIndent(int indent) { m_rightIndent = indent; m_flags |= wxTEXT_ATTR_RIGHT_INDENT; } void SetRightIndent(int indent) { m_rightIndent = indent; m_flags |= wxTEXT_ATTR_RIGHT_INDENT; }
void SetFontSize(int pointSize) { m_fontSize = pointSize; m_flags |= wxTEXT_ATTR_FONT_SIZE; } void SetFontSize(int pointSize) { m_fontSize = pointSize; m_flags &= ~wxTEXT_ATTR_FONT_SIZE; m_flags |= wxTEXT_ATTR_FONT_POINT_SIZE; }
void SetFontPointSize(int pointSize) { m_fontSize = pointSize; m_flags &= ~wxTEXT_ATTR_FONT_SIZE; m_flags |= wxTEXT_ATTR_FONT_POINT_SIZE; }
void SetFontPixelSize(int pixelSize) { m_fontSize = pixelSize; m_flags &= ~wxTEXT_ATTR_FONT_SIZE; m_flags |= wxTEXT_ATTR_FONT_PIXEL_SIZE; }
void SetFontStyle(wxFontStyle fontStyle) { m_fontStyle = fontStyle; m_flags |= wxTEXT_ATTR_FONT_ITALIC; } void SetFontStyle(wxFontStyle fontStyle) { m_fontStyle = fontStyle; m_flags |= wxTEXT_ATTR_FONT_ITALIC; }
void SetFontWeight(wxFontWeight fontWeight) { m_fontWeight = fontWeight; m_flags |= wxTEXT_ATTR_FONT_WEIGHT; } void SetFontWeight(wxFontWeight fontWeight) { m_fontWeight = fontWeight; m_flags |= wxTEXT_ATTR_FONT_WEIGHT; }
void SetFontFaceName(const wxString& faceName) { m_fontFaceName = faceName; m_flags |= wxTEXT_ATTR_FONT_FACE; } void SetFontFaceName(const wxString& faceName) { m_fontFaceName = faceName; m_flags |= wxTEXT_ATTR_FONT_FACE; }
@@ -322,7 +330,7 @@ public:
void SetFontFamily(wxFontFamily family) { m_fontFamily = family; m_flags |= wxTEXT_ATTR_FONT_FAMILY; } void SetFontFamily(wxFontFamily family) { m_fontFamily = family; m_flags |= wxTEXT_ATTR_FONT_FAMILY; }
// Set font // Set font
void SetFont(const wxFont& font, int flags = wxTEXT_ATTR_FONT) { GetFontAttributes(font, flags); } void SetFont(const wxFont& font, int flags = (wxTEXT_ATTR_FONT & ~wxTEXT_ATTR_FONT_PIXEL_SIZE)) { GetFontAttributes(font, flags); }
void SetFlags(long flags) { m_flags = flags; } void SetFlags(long flags) { m_flags = flags; }
@@ -389,6 +397,8 @@ public:
bool HasRightIndent() const { return HasFlag(wxTEXT_ATTR_RIGHT_INDENT); } bool HasRightIndent() const { return HasFlag(wxTEXT_ATTR_RIGHT_INDENT); }
bool HasFontWeight() const { return HasFlag(wxTEXT_ATTR_FONT_WEIGHT); } bool HasFontWeight() const { return HasFlag(wxTEXT_ATTR_FONT_WEIGHT); }
bool HasFontSize() const { return HasFlag(wxTEXT_ATTR_FONT_SIZE); } bool HasFontSize() const { return HasFlag(wxTEXT_ATTR_FONT_SIZE); }
bool HasFontPointSize() const { return HasFlag(wxTEXT_ATTR_FONT_POINT_SIZE); }
bool HasFontPixelSize() const { return HasFlag(wxTEXT_ATTR_FONT_PIXEL_SIZE); }
bool HasFontItalic() const { return HasFlag(wxTEXT_ATTR_FONT_ITALIC); } bool HasFontItalic() const { return HasFlag(wxTEXT_ATTR_FONT_ITALIC); }
bool HasFontUnderlined() const { return HasFlag(wxTEXT_ATTR_FONT_UNDERLINE); } bool HasFontUnderlined() const { return HasFlag(wxTEXT_ATTR_FONT_UNDERLINE); }
bool HasFontStrikethrough() const { return HasFlag(wxTEXT_ATTR_FONT_STRIKETHROUGH); } bool HasFontStrikethrough() const { return HasFlag(wxTEXT_ATTR_FONT_STRIKETHROUGH); }

View File

@@ -251,9 +251,12 @@ public:
void Reset() { m_value = 0; m_flags = 0; } void Reset() { m_value = 0; m_flags = 0; }
/** /**
Partial equality test. Partial equality test. If @a weakTest is @true, attributes of this object do not
have to be present if those attributes of @a dim are present. If @a weakTest is
@false, the function will fail if an attribute is present in @a dim but not
in this object.
*/ */
bool EqPartial(const wxTextAttrDimension& dim) const; bool EqPartial(const wxTextAttrDimension& dim, bool weakTest = true) const;
/** Apply the dimension, but not those identical to @a compareWith if present. /** Apply the dimension, but not those identical to @a compareWith if present.
*/ */
@@ -378,10 +381,13 @@ public:
bool operator==(const wxTextAttrDimensions& dims) const { return m_left == dims.m_left && m_top == dims.m_top && m_right == dims.m_right && m_bottom == dims.m_bottom; } bool operator==(const wxTextAttrDimensions& 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. Partial equality test. If @a weakTest is @true, attributes of this object do not
have to be present if those attributes of @a dim sare present. If @a weakTest is
@false, the function will fail if an attribute is present in @a dims but not
in this object.
*/ */
bool EqPartial(const wxTextAttrDimensions& dims) const; bool EqPartial(const wxTextAttrDimensions& dims, bool weakTest = true) const;
/** /**
Apply to 'this', but not if the same as @a compareWith. Apply to 'this', but not if the same as @a compareWith.
@@ -469,9 +475,12 @@ public:
bool operator==(const wxTextAttrSize& size) const { return m_width == size.m_width && m_height == size.m_height ; } bool operator==(const wxTextAttrSize& size) const { return m_width == size.m_width && m_height == size.m_height ; }
/** /**
Partial equality test. Partial equality test. If @a weakTest is @true, attributes of this object do not
have to be present if those attributes of @a size are present. If @a weakTest is
@false, the function will fail if an attribute is present in @a size but not
in this object.
*/ */
bool EqPartial(const wxTextAttrSize& dims) const; bool EqPartial(const wxTextAttrSize& size, bool weakTest = true) const;
/** /**
Apply to this object, but not if the same as @a compareWith. Apply to this object, but not if the same as @a compareWith.
@@ -694,9 +703,12 @@ public:
void Reset() { m_borderStyle = 0; m_borderColour = 0; m_flags = 0; m_borderWidth.Reset(); } void Reset() { m_borderStyle = 0; m_borderColour = 0; m_flags = 0; m_borderWidth.Reset(); }
/** /**
Partial equality test. Partial equality test. If @a weakTest is @true, attributes of this object do not
have to be present if those attributes of @a border are present. If @a weakTest is
@false, the function will fail if an attribute is present in @a border but not
in this object.
*/ */
bool EqPartial(const wxTextAttrBorder& border) const; bool EqPartial(const wxTextAttrBorder& border, bool weakTest = true) const;
/** /**
Applies the border to this object, but not if the same as @a compareWith. Applies the border to this object, but not if the same as @a compareWith.
@@ -870,9 +882,12 @@ public:
void Reset() { m_left.Reset(); m_right.Reset(); m_top.Reset(); m_bottom.Reset(); } void Reset() { m_left.Reset(); m_right.Reset(); m_top.Reset(); m_bottom.Reset(); }
/** /**
Partial equality test. Partial equality test. If @a weakTest is @true, attributes of this object do not
have to be present if those attributes of @a borders are present. If @a weakTest is
@false, the function will fail if an attribute is present in @a borders but not
in this object.
*/ */
bool EqPartial(const wxTextAttrBorders& borders) const; bool EqPartial(const wxTextAttrBorders& borders, bool weakTest = true) const;
/** /**
Applies border to this object, but not if the same as @a compareWith. Applies border to this object, but not if the same as @a compareWith.
@@ -968,10 +983,13 @@ public:
bool operator== (const wxTextBoxAttr& attr) const; bool operator== (const wxTextBoxAttr& attr) const;
/** /**
Partial equality test, ignoring unset attributes. Partial equality test, ignoring unset attributes. If @a weakTest is @true, attributes of this object do not
have to be present if those attributes of @a attr are present. If @a weakTest is
@false, the function will fail if an attribute is present in @a attr but not
in this object.
*/ */
bool EqPartial(const wxTextBoxAttr& attr) const; bool EqPartial(const wxTextBoxAttr& attr, bool weakTest = true) const;
/** /**
Merges the given attributes. If @a compareWith is non-NULL, then it will be used Merges the given attributes. If @a compareWith is non-NULL, then it will be used
@@ -1370,9 +1388,12 @@ public:
bool operator==(const wxRichTextAttr& attr) const; bool operator==(const wxRichTextAttr& attr) const;
/** /**
Partial equality test taking comparison object into account. Partial equality test. If @a weakTest is @true, attributes of this object do not
have to be present if those attributes of @a attr are present. If @a weakTest is
@false, the function will fail if an attribute is present in @a attr but not
in this object.
*/ */
bool EqPartial(const wxRichTextAttr& attr) const; bool EqPartial(const wxRichTextAttr& attr, bool weakTest = true) const;
/** /**
Merges the given attributes. If @a compareWith Merges the given attributes. If @a compareWith
@@ -1633,8 +1654,15 @@ public:
*/ */
bool operator != (const wxRichTextFontTable& table) const { return !(*this == table); } bool operator != (const wxRichTextFontTable& table) const { return !(*this == table); }
/**
Set the font scale factor.
*/
void SetFontScale(double fontScale);
protected: protected:
double m_fontScale;
DECLARE_DYNAMIC_CLASS(wxRichTextFontTable) DECLARE_DYNAMIC_CLASS(wxRichTextFontTable)
}; };
@@ -3423,7 +3451,7 @@ public:
Update the field; delegated to the associated field type. This would typically expand the field to its value, Update the field; delegated to the associated field type. This would typically expand the field to its value,
if this is a dynamically changing and/or composite field. if this is a dynamically changing and/or composite field.
*/ */
virtual bool UpdateField(); virtual bool UpdateField(wxRichTextBuffer* buffer);
virtual wxRichTextObject* Clone() const { return new wxRichTextField(*this); } virtual wxRichTextObject* Clone() const { return new wxRichTextField(*this); }
@@ -3506,7 +3534,7 @@ public:
Update the field. This would typically expand the field to its value, Update the field. This would typically expand the field to its value,
if this is a dynamically changing and/or composite field. if this is a dynamically changing and/or composite field.
*/ */
virtual bool UpdateField(wxRichTextField* WXUNUSED(obj)) { return false; } virtual bool UpdateField(wxRichTextBuffer* buffer, wxRichTextField* obj) { return false; }
/** /**
Returns @true if this object is top-level, i.e. contains its own paragraphs, such as a text box. Returns @true if this object is top-level, i.e. contains its own paragraphs, such as a text box.
@@ -4576,6 +4604,31 @@ public:
*/ */
void SetFontTable(const wxRichTextFontTable& table) { m_fontTable = table; } void SetFontTable(const wxRichTextFontTable& table) { m_fontTable = table; }
/**
Sets the scale factor for displaying fonts, for example for more comfortable
editing.
*/
void SetFontScale(double fontScale);
/**
Returns the scale factor for displaying fonts, for example for more comfortable
editing.
*/
double GetFontScale() const { return m_fontScale; }
/**
Sets the scale factor for displaying certain dimensions such as indentation and
inter-paragraph spacing. This can be useful when editing in a small control
where you still want legible text, but a minimum of wasted white space.
*/
void SetDimensionScale(double dimScale);
/**
Returns the scale factor for displaying certain dimensions such as indentation
and inter-paragraph spacing.
*/
double GetDimensionScale() const { return m_dimensionScale; }
// Operations // Operations
/** /**
@@ -6203,10 +6256,6 @@ inline bool wxRichTextHasStyle(int flags, int style)
WXDLLIMPEXP_RICHTEXT bool wxTextAttrEq(const wxRichTextAttr& attr1, const wxRichTextAttr& attr2); WXDLLIMPEXP_RICHTEXT bool wxTextAttrEq(const wxRichTextAttr& attr1, const wxRichTextAttr& 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 wxRichTextAttr& attr1, const wxRichTextAttr& attr2);
/// Apply one style to another /// Apply one style to another
WXDLLIMPEXP_RICHTEXT bool wxRichTextApplyStyle(wxRichTextAttr& destStyle, const wxRichTextAttr& style, wxRichTextAttr* compareWith = NULL); WXDLLIMPEXP_RICHTEXT bool wxRichTextApplyStyle(wxRichTextAttr& destStyle, const wxRichTextAttr& style, wxRichTextAttr* compareWith = NULL);

View File

@@ -1660,6 +1660,31 @@ public:
*/ */
virtual bool GetVerticalScrollbarEnabled() const; virtual bool GetVerticalScrollbarEnabled() const;
/**
Sets the scale factor for displaying fonts, for example for more comfortable
editing.
*/
void SetFontScale(double fontScale, bool refresh = false);
/**
Returns the scale factor for displaying fonts, for example for more comfortable
editing.
*/
double GetFontScale() const { return GetBuffer().GetFontScale(); }
/**
Sets the scale factor for displaying certain dimensions such as indentation and
inter-paragraph spacing. This can be useful when editing in a small control
where you still want legible text, but a minimum of wasted white space.
*/
void SetDimensionScale(double dimScale, bool refresh = false);
/**
Returns the scale factor for displaying certain dimensions such as indentation
and inter-paragraph spacing.
*/
double GetDimensionScale() const { return GetBuffer().GetDimensionScale(); }
// Command handlers // Command handlers
/** /**

View File

@@ -123,6 +123,8 @@ public:
class wxRichTextFormattingDialog : public wxPropertySheetDialog class wxRichTextFormattingDialog : public wxPropertySheetDialog
{ {
public: public:
enum { Option_AllowPixelFontSize = 0x0001 };
/** /**
Default ctor. Default ctor.
*/ */
@@ -227,6 +229,23 @@ public:
*/ */
void SetAttributes(const wxTextAttr& attr); void SetAttributes(const wxTextAttr& attr);
/**
Sets the dialog options, determining what the interface presents to the user.
Currently the only option is Option_AllowPixelFontSize.
*/
void SetOptions(int options) { m_options = options; }
/**
Gets the dialog options, determining what the interface presents to the user.
Currently the only option is Option_AllowPixelFontSize.
*/
int GetOptions() const { return m_options; }
/**
Returns @true if the given option is present.
*/
bool HasOption(int option) const { return (m_options & option) != 0; }
/** /**
Sets the formatting factory object to be used for customization and page Sets the formatting factory object to be used for customization and page
creation. creation.

View File

@@ -87,19 +87,23 @@ enum wxTextAttrFlags
wxTEXT_ATTR_BACKGROUND_COLOUR = 0x00000002, wxTEXT_ATTR_BACKGROUND_COLOUR = 0x00000002,
wxTEXT_ATTR_FONT_FACE = 0x00000004, wxTEXT_ATTR_FONT_FACE = 0x00000004,
wxTEXT_ATTR_FONT_SIZE = 0x00000008, wxTEXT_ATTR_FONT_POINT_SIZE = 0x00000008,
wxTEXT_ATTR_FONT_PIXEL_SIZE = 0x10000000,
wxTEXT_ATTR_FONT_WEIGHT = 0x00000010, wxTEXT_ATTR_FONT_WEIGHT = 0x00000010,
wxTEXT_ATTR_FONT_ITALIC = 0x00000020, wxTEXT_ATTR_FONT_ITALIC = 0x00000020,
wxTEXT_ATTR_FONT_UNDERLINE = 0x00000040, wxTEXT_ATTR_FONT_UNDERLINE = 0x00000040,
wxTEXT_ATTR_FONT_STRIKETHROUGH = 0x08000000,
wxTEXT_ATTR_FONT_ENCODING = 0x02000000, wxTEXT_ATTR_FONT_ENCODING = 0x02000000,
wxTEXT_ATTR_FONT_FAMILY = 0x04000000, wxTEXT_ATTR_FONT_FAMILY = 0x04000000,
wxTEXT_ATTR_FONT_SIZE = \
( wxTEXT_ATTR_FONT_POINT_SIZE | wxTEXT_ATTR_FONT_PIXEL_SIZE ),
/** /**
Defined as the combination of all @c wxTEXT_ATTR_FONT_* values above. Defined as the combination of all @c wxTEXT_ATTR_FONT_* values above.
*/ */
wxTEXT_ATTR_FONT = \ wxTEXT_ATTR_FONT = \
( wxTEXT_ATTR_FONT_FACE | wxTEXT_ATTR_FONT_SIZE | wxTEXT_ATTR_FONT_WEIGHT | \ ( wxTEXT_ATTR_FONT_FACE | wxTEXT_ATTR_FONT_SIZE | wxTEXT_ATTR_FONT_WEIGHT | \
wxTEXT_ATTR_FONT_ITALIC | wxTEXT_ATTR_FONT_UNDERLINE | wxTEXT_ATTR_FONT_ENCODING | wxTEXT_ATTR_FONT_FAMILY ), wxTEXT_ATTR_FONT_ITALIC | wxTEXT_ATTR_FONT_UNDERLINE | wxTEXT_ATTR_FONT_STRIKETHROUGH | wxTEXT_ATTR_FONT_ENCODING | wxTEXT_ATTR_FONT_FAMILY ),
wxTEXT_ATTR_ALIGNMENT = 0x00000080, wxTEXT_ATTR_ALIGNMENT = 0x00000080,
wxTEXT_ATTR_LEFT_INDENT = 0x00000100, wxTEXT_ATTR_LEFT_INDENT = 0x00000100,
@@ -290,6 +294,14 @@ public:
const wxTextAttr& overlay); const wxTextAttr& overlay);
/**
Partial equality test. If @a weakTest is @true, attributes of this object do not
have to be present if those attributes of @a attr are present. If @a weakTest is
@false, the function will fail if an attribute is present in @a attr but not
in this object.
*/
bool EqPartial(const wxTextAttrEx& attr, bool weakTest = true) const;
/** /**
@name GetXXX functions @name GetXXX functions
*/ */
@@ -567,10 +579,20 @@ public:
bool HasFontItalic() const; bool HasFontItalic() const;
/** /**
Returns @true if the attribute object specifies a font point size. Returns @true if the attribute object specifies a font point or pixel size.
*/ */
bool HasFontSize() const; bool HasFontSize() const;
/**
Returns @true if the attribute object specifies a font point size.
*/
bool HasFontPointSize() const;
/**
Returns @true if the attribute object specifies a font pixel size.
*/
bool HasFontPixelSize() const;
/** /**
Returns @true if the attribute object specifies either underlining or no Returns @true if the attribute object specifies either underlining or no
underlining. underlining.
@@ -738,7 +760,7 @@ public:
Sets the attributes for the given font. Sets the attributes for the given font.
Note that wxTextAttr does not store an actual wxFont object. Note that wxTextAttr does not store an actual wxFont object.
*/ */
void SetFont(const wxFont& font, int flags = wxTEXT_ATTR_FONT); void SetFont(const wxFont& font, int flags = (wxTEXT_ATTR_FONT & ~wxTEXT_ATTR_FONT_PIXEL_SIZE));
/** /**
Sets the font encoding. Sets the font encoding.
@@ -760,6 +782,16 @@ public:
*/ */
void SetFontSize(int pointSize); void SetFontSize(int pointSize);
/**
Sets the font size in points.
*/
void SetFontPointSize(int pointSize);
/**
Sets the font size in pixels.
*/
void SetFontPixelSize(int pixelSize);
/** /**
Sets the font style (normal, italic or slanted). Sets the font style (normal, italic or slanted).
*/ */

View File

@@ -82,6 +82,61 @@
#include "wx/richtext/richtextprint.h" #include "wx/richtext/richtextprint.h"
#include "wx/richtext/richtextimagedlg.h" #include "wx/richtext/richtextimagedlg.h"
// A custom field type
class wxRichTextFieldTypePropertiesTest: public wxRichTextFieldTypeStandard
{
public:
wxRichTextFieldTypePropertiesTest(const wxString& name, const wxString& label, int displayStyle = wxRICHTEXT_FIELD_STYLE_RECTANGLE):
wxRichTextFieldTypeStandard(name, label, displayStyle)
{
}
wxRichTextFieldTypePropertiesTest(const wxString& name, const wxBitmap& bitmap, int displayStyle = wxRICHTEXT_FIELD_STYLE_RECTANGLE):
wxRichTextFieldTypeStandard(name, bitmap, displayStyle)
{
}
virtual bool CanEditProperties(wxRichTextField* WXUNUSED(obj)) const { return true; }
virtual bool EditProperties(wxRichTextField* WXUNUSED(obj), wxWindow* WXUNUSED(parent), wxRichTextBuffer* WXUNUSED(buffer))
{
wxString label = GetLabel();
wxMessageBox(wxString::Format(wxT("Editing %s"), label.c_str()));
return true;
}
virtual wxString GetPropertiesMenuLabel(wxRichTextField* WXUNUSED(obj)) const
{
return GetLabel();
}
};
// A custom composite field type
class wxRichTextFieldTypeCompositeTest: public wxRichTextFieldTypePropertiesTest
{
public:
wxRichTextFieldTypeCompositeTest(const wxString& name, const wxString& label):
wxRichTextFieldTypePropertiesTest(name, label, wxRICHTEXT_FIELD_STYLE_COMPOSITE)
{
}
virtual bool UpdateField(wxRichTextBuffer* buffer, wxRichTextField* obj)
{
if (buffer)
{
wxRichTextAttr attr(buffer->GetAttributes());
attr.GetTextBoxAttr().Reset();
attr.SetParagraphSpacingAfter(0);
attr.SetLineSpacing(10);
obj->SetAttributes(attr);
}
obj->GetChildren().Clear();
wxRichTextParagraph* para = new wxRichTextParagraph;
wxRichTextPlainText* text = new wxRichTextPlainText(GetLabel());
para->AppendChild(text);
obj->AppendChild(para);
return true;
}
};
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// resources // resources
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -237,6 +292,9 @@ public:
void OnPageSetup(wxCommandEvent& event); void OnPageSetup(wxCommandEvent& event);
void OnInsertImage(wxCommandEvent& event); void OnInsertImage(wxCommandEvent& event);
void OnSetFontScale(wxCommandEvent& event);
void OnSetDimensionScale(wxCommandEvent& event);
protected: protected:
// Forward command events to the current rich text control, if any // Forward command events to the current rich text control, if any
@@ -302,6 +360,9 @@ enum
ID_FORMAT_DEMOTE_LIST, ID_FORMAT_DEMOTE_LIST,
ID_FORMAT_CLEAR_LIST, ID_FORMAT_CLEAR_LIST,
ID_SET_FONT_SCALE,
ID_SET_DIMENSION_SCALE,
ID_VIEW_HTML, ID_VIEW_HTML,
ID_SWITCH_STYLE_SHEETS, ID_SWITCH_STYLE_SHEETS,
ID_MANAGE_STYLES, ID_MANAGE_STYLES,
@@ -396,6 +457,9 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_TEXT_URL(wxID_ANY, MyFrame::OnURL) EVT_TEXT_URL(wxID_ANY, MyFrame::OnURL)
EVT_RICHTEXT_STYLESHEET_REPLACING(wxID_ANY, MyFrame::OnStyleSheetReplacing) EVT_RICHTEXT_STYLESHEET_REPLACING(wxID_ANY, MyFrame::OnStyleSheetReplacing)
EVT_MENU(ID_SET_FONT_SCALE, MyFrame::OnSetFontScale)
EVT_MENU(ID_SET_DIMENSION_SCALE, MyFrame::OnSetDimensionScale)
END_EVENT_TABLE() END_EVENT_TABLE()
// Create a new application object: this macro will allow wxWidgets to create // Create a new application object: this macro will allow wxWidgets to create
@@ -437,6 +501,25 @@ bool MyApp::OnInit()
wxRichTextBuffer::AddHandler(new wxRichTextXMLHandler); wxRichTextBuffer::AddHandler(new wxRichTextXMLHandler);
wxRichTextBuffer::AddHandler(new wxRichTextHTMLHandler); wxRichTextBuffer::AddHandler(new wxRichTextHTMLHandler);
// Add field types
wxRichTextBuffer::AddFieldType(new wxRichTextFieldTypePropertiesTest(wxT("rectangle"), wxT("RECTANGLE"), wxRichTextFieldTypeStandard::wxRICHTEXT_FIELD_STYLE_RECTANGLE));
wxRichTextFieldTypeStandard* s1 = new wxRichTextFieldTypeStandard(wxT("begin-section"), wxT("SECTION"), wxRichTextFieldTypeStandard::wxRICHTEXT_FIELD_STYLE_START_TAG);
s1->SetBackgroundColour(*wxBLUE);
wxRichTextFieldTypeStandard* s2 = new wxRichTextFieldTypeStandard(wxT("end-section"), wxT("SECTION"), wxRichTextFieldTypeStandard::wxRICHTEXT_FIELD_STYLE_END_TAG);
s2->SetBackgroundColour(*wxBLUE);
wxRichTextFieldTypeStandard* s3 = new wxRichTextFieldTypeStandard(wxT("bitmap"), wxBitmap(paste_xpm), wxRichTextFieldTypeStandard::wxRICHTEXT_FIELD_STYLE_NO_BORDER);
wxRichTextBuffer::AddFieldType(s1);
wxRichTextBuffer::AddFieldType(s2);
wxRichTextBuffer::AddFieldType(s3);
wxRichTextFieldTypeCompositeTest* s4 = new wxRichTextFieldTypeCompositeTest(wxT("composite"), wxT("This is a field value"));
wxRichTextBuffer::AddFieldType(s4);
// Add image handlers // Add image handlers
#if wxUSE_LIBPNG #if wxUSE_LIBPNG
wxImage::AddHandler( new wxPNGHandler ); wxImage::AddHandler( new wxPNGHandler );
@@ -673,11 +756,9 @@ MyFrame::MyFrame(const wxString& title, wxWindowID id, const wxPoint& pos,
editMenu->AppendSeparator(); editMenu->AppendSeparator();
editMenu->Append(wxID_SELECTALL, _("Select A&ll\tCtrl+A")); editMenu->Append(wxID_SELECTALL, _("Select A&ll\tCtrl+A"));
#if 0
editMenu->AppendSeparator(); editMenu->AppendSeparator();
editMenu->Append(wxID_FIND, _("&Find...\tCtrl+F")); editMenu->Append(ID_SET_FONT_SCALE, _("Set &Text Scale..."));
editMenu->Append(stID_FIND_REPLACE, _("&Replace...\tCtrl+R")); editMenu->Append(ID_SET_DIMENSION_SCALE, _("Set &Dimension Scale..."));
#endif
wxMenu* formatMenu = new wxMenu; wxMenu* formatMenu = new wxMenu;
formatMenu->AppendCheckItem(ID_FORMAT_BOLD, _("&Bold\tCtrl+B")); formatMenu->AppendCheckItem(ID_FORMAT_BOLD, _("&Bold\tCtrl+B"));
@@ -802,10 +883,14 @@ MyFrame::MyFrame(const wxString& title, wxWindowID id, const wxPoint& pos,
wxFont italicFont = wxFont(12, wxROMAN, wxITALIC, wxNORMAL); wxFont italicFont = wxFont(12, wxROMAN, wxITALIC, wxNORMAL);
m_richTextCtrl = new MyRichTextCtrl(splitter, ID_RICHTEXT_CTRL, wxEmptyString, wxDefaultPosition, wxSize(200, 200), wxVSCROLL|wxHSCROLL|wxWANTS_CHARS); m_richTextCtrl = new MyRichTextCtrl(splitter, ID_RICHTEXT_CTRL, wxEmptyString, wxDefaultPosition, wxSize(200, 200), wxVSCROLL|wxHSCROLL|wxWANTS_CHARS);
wxASSERT(!m_richTextCtrl->GetBuffer().GetAttributes().HasFontPixelSize());
wxFont font(12, wxROMAN, wxNORMAL, wxNORMAL); wxFont font(12, wxROMAN, wxNORMAL, wxNORMAL);
m_richTextCtrl->SetFont(font); m_richTextCtrl->SetFont(font);
wxASSERT(!m_richTextCtrl->GetBuffer().GetAttributes().HasFontPixelSize());
m_richTextCtrl->SetMargins(10, 10); m_richTextCtrl->SetMargins(10, 10);
m_richTextCtrl->SetStyleSheet(wxGetApp().GetStyleSheet()); m_richTextCtrl->SetStyleSheet(wxGetApp().GetStyleSheet());
@@ -874,6 +959,13 @@ void MyFrame::WriteInitialText()
r.EndAlignment(); r.EndAlignment();
#if 0
r.BeginAlignment(wxTEXT_ALIGNMENT_CENTRE);
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.Newline();
r.EndAlignment();
#endif
r.BeginAlignment(wxTEXT_ALIGNMENT_LEFT); r.BeginAlignment(wxTEXT_ALIGNMENT_LEFT);
wxRichTextAttr imageAttr; wxRichTextAttr imageAttr;
imageAttr.GetTextBoxAttr().SetFloatMode(wxTEXT_BOX_ATTR_FLOAT_LEFT); imageAttr.GetTextBoxAttr().SetFloatMode(wxTEXT_BOX_ATTR_FLOAT_LEFT);
@@ -1042,8 +1134,8 @@ void MyFrame::WriteInitialText()
r.WriteText(wxT("Note: this sample content was generated programmatically from within the MyFrame constructor in the demo. The images were loaded from inline XPMs. Enjoy wxRichTextCtrl!\n")); r.WriteText(wxT("Note: this sample content was generated programmatically from within the MyFrame constructor in the demo. The images were loaded from inline XPMs. Enjoy wxRichTextCtrl!\n"));
r.EndParagraphSpacing(); r.EndParagraphSpacing();
#if 1
#if 1
{ {
// Add a text box // Add a text box
@@ -1105,6 +1197,23 @@ void MyFrame::WriteInitialText()
} }
#endif #endif
r.Newline();
wxRichTextProperties properties;
r.WriteText(wxT("This is a rectangle field: "));
r.WriteField(wxT("rectangle"), properties);
r.WriteText(wxT(" and a begin section field: "));
r.WriteField(wxT("begin-section"), properties);
r.WriteText(wxT("This is text between the two tags."));
r.WriteField(wxT("end-section"), properties);
r.WriteText(wxT(" Now a bitmap. "));
r.WriteField(wxT("bitmap"), properties);
r.WriteText(wxT(" Before we go, here's a composite field: ***"));
wxRichTextField* field = r.WriteField(wxT("composite"), properties);
field->UpdateField(& r.GetBuffer()); // Creates the composite value (sort of a text box)
r.WriteText(wxT("*** End of composite field."));
r.Newline();
r.EndSuppressUndo(); r.EndSuppressUndo();
// Add some locked content first - needs Undo to be enabled // Add some locked content first - needs Undo to be enabled
@@ -1357,39 +1466,13 @@ void MyFrame::OnFont(wxCommandEvent& WXUNUSED(event))
int pages = wxRICHTEXT_FORMAT_FONT; int pages = wxRICHTEXT_FORMAT_FONT;
wxRichTextFormattingDialog formatDlg(pages, this); wxRichTextFormattingDialog formatDlg(pages, this);
formatDlg.SetOptions(wxRichTextFormattingDialog::Option_AllowPixelFontSize);
formatDlg.GetStyle(m_richTextCtrl, range); formatDlg.GetStyle(m_richTextCtrl, range);
if (formatDlg.ShowModal() == wxID_OK) if (formatDlg.ShowModal() == wxID_OK)
{ {
formatDlg.ApplyStyle(m_richTextCtrl, range, wxRICHTEXT_SETSTYLE_WITH_UNDO|wxRICHTEXT_SETSTYLE_OPTIMIZE|wxRICHTEXT_SETSTYLE_CHARACTERS_ONLY); formatDlg.ApplyStyle(m_richTextCtrl, range, wxRICHTEXT_SETSTYLE_WITH_UNDO|wxRICHTEXT_SETSTYLE_OPTIMIZE|wxRICHTEXT_SETSTYLE_CHARACTERS_ONLY);
} }
// Old method using wxFontDialog
#if 0
if (!m_richTextCtrl->HasSelection())
return;
wxRichTextRange range = m_richTextCtrl->GetSelectionRange();
wxFontData fontData;
wxRichTextAttr attr;
attr.SetFlags(wxTEXT_ATTR_FONT);
if (m_richTextCtrl->GetStyle(m_richTextCtrl->GetInsertionPoint(), attr))
fontData.SetInitialFont(attr.GetFont());
wxFontDialog dialog(this, fontData);
if (dialog.ShowModal() == wxID_OK)
{
fontData = dialog.GetFontData();
attr.SetFlags(wxTEXT_ATTR_FONT);
attr.SetFont(fontData.GetChosenFont());
if (attr.GetFont().IsOk())
{
m_richTextCtrl->SetStyle(range, attr);
}
}
#endif
} }
void MyFrame::OnImage(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnImage(wxCommandEvent& WXUNUSED(event))
@@ -1892,6 +1975,30 @@ void MyFrame::OnPageSetup(wxCommandEvent& WXUNUSED(event))
// wxGetApp().GetPrinting()->PageSetup(); // wxGetApp().GetPrinting()->PageSetup();
} }
void MyFrame::OnSetFontScale(wxCommandEvent& WXUNUSED(event))
{
wxString value = wxString::Format(wxT("%g"), m_richTextCtrl->GetFontScale());
wxString text = wxGetTextFromUser(wxT("Enter a text scale factor:"), wxT("Text Scale Factor"), value, wxGetTopLevelParent(this));
if (!text.IsEmpty() && value != text)
{
double scale = 1.0;
wxSscanf(text, wxT("%lf"), & scale);
m_richTextCtrl->SetFontScale(scale, true);
}
}
void MyFrame::OnSetDimensionScale(wxCommandEvent& WXUNUSED(event))
{
wxString value = wxString::Format(wxT("%g"), m_richTextCtrl->GetDimensionScale());
wxString text = wxGetTextFromUser(wxT("Enter a dimension scale factor:"), wxT("Dimension Scale Factor"), value, wxGetTopLevelParent(this));
if (!text.IsEmpty() && value != text)
{
double scale = 1.0;
wxSscanf(text, wxT("%lf"), & scale);
m_richTextCtrl->SetDimensionScale(scale, true);
}
}
void MyRichTextCtrl::PrepareContent(wxRichTextParagraphLayoutBox& container) void MyRichTextCtrl::PrepareContent(wxRichTextParagraphLayoutBox& container)
{ {
if (IsLocked()) if (IsLocked())

View File

@@ -267,117 +267,138 @@ bool wxTextAttr::operator== (const wxTextAttr& attr) const
} }
// Partial equality test. Only returns false if an attribute doesn't match. // Partial equality test. Only returns false if an attribute doesn't match.
bool wxTextAttr::EqPartial(const wxTextAttr& attr) const bool wxTextAttr::EqPartial(const wxTextAttr& attr, bool weakTest) const
{ {
int flags = attr.GetFlags(); int flags = attr.GetFlags();
if ((flags & wxTEXT_ATTR_TEXT_COLOUR) && GetTextColour() != attr.GetTextColour()) if (!weakTest &&
((!HasTextColour() && attr.HasTextColour()) ||
(!HasBackgroundColour() && attr.HasBackgroundColour()) ||
(!HasFontFaceName() && attr.HasFontFaceName()) ||
(!HasFontSize() && attr.HasFontSize()) ||
(!HasFontWeight() && attr.HasFontWeight()) ||
(!HasFontItalic() && attr.HasFontItalic()) ||
(!HasFontUnderlined() && attr.HasFontUnderlined()) ||
(!HasFontStrikethrough() && attr.HasFontStrikethrough()) ||
(!HasFontEncoding() && attr.HasFontEncoding()) ||
(!HasFontFamily() && attr.HasFontFamily()) ||
(!HasURL() && attr.HasURL()) ||
(!HasAlignment() && attr.HasAlignment()) ||
(!HasLeftIndent() && attr.HasLeftIndent()) ||
(!HasParagraphSpacingAfter() && attr.HasParagraphSpacingAfter()) ||
(!HasParagraphSpacingBefore() && attr.HasParagraphSpacingBefore()) ||
(!HasLineSpacing() && attr.HasLineSpacing()) ||
(!HasCharacterStyleName() && attr.HasCharacterStyleName()) ||
(!HasParagraphStyleName() && attr.HasParagraphStyleName()) ||
(!HasListStyleName() && attr.HasListStyleName()) ||
(!HasBulletStyle() && attr.HasBulletStyle()) ||
(!HasBulletNumber() && attr.HasBulletNumber()) ||
(!HasBulletText() && attr.HasBulletText()) ||
(!HasBulletName() && attr.HasBulletName()) ||
(!HasTabs() && attr.HasTabs()) ||
(!HasTextEffects() && attr.HasTextEffects()) ||
(!HasOutlineLevel() && attr.HasOutlineLevel())))
{
return false;
}
if (HasTextColour() && attr.HasTextColour() && GetTextColour() != attr.GetTextColour())
return false; return false;
if ((flags & wxTEXT_ATTR_BACKGROUND_COLOUR) && GetBackgroundColour() != attr.GetBackgroundColour()) if (HasBackgroundColour() && attr.HasBackgroundColour() && GetBackgroundColour() != attr.GetBackgroundColour())
return false; return false;
if ((flags & wxTEXT_ATTR_FONT_FACE) && if (HasFontFaceName() && attr.HasFontFaceName() && GetFontFaceName() != attr.GetFontFaceName())
GetFontFaceName() != attr.GetFontFaceName())
return false; return false;
if ((flags & wxTEXT_ATTR_FONT_SIZE) && // This checks whether the two objects have the same font size dimension (px versus pt)
GetFontSize() != attr.GetFontSize()) if (HasFontSize() && attr.HasFontSize() && (flags & wxTEXT_ATTR_FONT) != (GetFlags() & wxTEXT_ATTR_FONT))
return false; return false;
if ((flags & wxTEXT_ATTR_FONT_WEIGHT) && if (HasFontPointSize() && attr.HasFontPointSize() && GetFontSize() != attr.GetFontSize())
GetFontWeight() != attr.GetFontWeight())
return false; return false;
if ((flags & wxTEXT_ATTR_FONT_ITALIC) && if (HasFontPixelSize() && attr.HasFontPixelSize() && GetFontSize() != attr.GetFontSize())
GetFontStyle() != attr.GetFontStyle())
return false; return false;
if ((flags & wxTEXT_ATTR_FONT_UNDERLINE) && if (HasFontWeight() && attr.HasFontWeight() && GetFontWeight() != attr.GetFontWeight())
GetFontUnderlined() != attr.GetFontUnderlined())
return false; return false;
if ((flags & wxTEXT_ATTR_FONT_ENCODING) && if (HasFontItalic() && attr.HasFontItalic() && GetFontStyle() != attr.GetFontStyle())
GetFontEncoding() != attr.GetFontEncoding())
return false; return false;
if ((flags & wxTEXT_ATTR_FONT_FAMILY) && if (HasFontUnderlined() && attr.HasFontUnderlined() && GetFontUnderlined() != attr.GetFontUnderlined())
GetFontFamily() != attr.GetFontFamily())
return false; return false;
if ((flags & wxTEXT_ATTR_URL) && GetURL() != attr.GetURL()) if (HasFontStrikethrough() && attr.HasFontStrikethrough() && GetFontStrikethrough() != attr.GetFontStrikethrough())
return false; return false;
if ((flags & wxTEXT_ATTR_ALIGNMENT) && GetAlignment() != attr.GetAlignment()) if (HasFontEncoding() && attr.HasFontEncoding() && GetFontEncoding() != attr.GetFontEncoding())
return false; return false;
if ((flags & wxTEXT_ATTR_LEFT_INDENT) && if (HasFontFamily() && attr.HasFontFamily() && GetFontFamily() != attr.GetFontFamily())
return false;
if (HasURL() && attr.HasURL() && GetURL() != attr.GetURL())
return false;
if (HasAlignment() && attr.HasAlignment() && GetAlignment() != attr.GetAlignment())
return false;
if (HasLeftIndent() && attr.HasLeftIndent() &&
((GetLeftIndent() != attr.GetLeftIndent()) || (GetLeftSubIndent() != attr.GetLeftSubIndent()))) ((GetLeftIndent() != attr.GetLeftIndent()) || (GetLeftSubIndent() != attr.GetLeftSubIndent())))
return false; return false;
if ((flags & wxTEXT_ATTR_RIGHT_INDENT) && if (HasRightIndent() && attr.HasRightIndent() && (GetRightIndent() != attr.GetRightIndent()))
(GetRightIndent() != attr.GetRightIndent()))
return false; return false;
if ((flags & wxTEXT_ATTR_PARA_SPACING_AFTER) && if (HasParagraphSpacingAfter() && attr.HasParagraphSpacingAfter() &&
(GetParagraphSpacingAfter() != attr.GetParagraphSpacingAfter())) (GetParagraphSpacingAfter() != attr.GetParagraphSpacingAfter()))
return false; return false;
if ((flags & wxTEXT_ATTR_PARA_SPACING_BEFORE) && if (HasParagraphSpacingBefore() && attr.HasParagraphSpacingBefore() &&
(GetParagraphSpacingBefore() != attr.GetParagraphSpacingBefore())) (GetParagraphSpacingBefore() != attr.GetParagraphSpacingBefore()))
return false; return false;
if ((flags & wxTEXT_ATTR_LINE_SPACING) && if (HasLineSpacing() && attr.HasLineSpacing() && (GetLineSpacing() != attr.GetLineSpacing()))
(GetLineSpacing() != attr.GetLineSpacing()))
return false; return false;
if ((flags & wxTEXT_ATTR_CHARACTER_STYLE_NAME) && if (HasCharacterStyleName() && attr.HasCharacterStyleName() && (GetCharacterStyleName() != attr.GetCharacterStyleName()))
(GetCharacterStyleName() != attr.GetCharacterStyleName()))
return false; return false;
if ((flags & wxTEXT_ATTR_PARAGRAPH_STYLE_NAME) && if (HasParagraphStyleName() && attr.HasParagraphStyleName() && (GetParagraphStyleName() != attr.GetParagraphStyleName()))
(GetParagraphStyleName() != attr.GetParagraphStyleName()))
return false; return false;
if ((flags & wxTEXT_ATTR_LIST_STYLE_NAME) && if (HasListStyleName() && attr.HasListStyleName() && (GetListStyleName() != attr.GetListStyleName()))
(GetListStyleName() != attr.GetListStyleName()))
return false; return false;
if ((flags & wxTEXT_ATTR_BULLET_STYLE) && if (HasBulletStyle() && attr.HasBulletStyle() && (GetBulletStyle() != attr.GetBulletStyle()))
(GetBulletStyle() != attr.GetBulletStyle()))
return false; return false;
if ((flags & wxTEXT_ATTR_BULLET_NUMBER) && if (HasBulletNumber() && attr.HasBulletNumber() && (GetBulletNumber() != attr.GetBulletNumber()))
(GetBulletNumber() != attr.GetBulletNumber()))
return false; return false;
if ((flags & wxTEXT_ATTR_BULLET_TEXT) && if (HasBulletText() && attr.HasBulletText() &&
(GetBulletText() != attr.GetBulletText()) && (GetBulletText() != attr.GetBulletText()) &&
(GetBulletFont() != attr.GetBulletFont())) (GetBulletFont() != attr.GetBulletFont()))
return false; return false;
if ((flags & wxTEXT_ATTR_BULLET_NAME) && if (HasBulletName() && attr.HasBulletName() && (GetBulletName() != attr.GetBulletName()))
(GetBulletName() != attr.GetBulletName()))
return false; return false;
if ((flags & wxTEXT_ATTR_TABS) && if (HasTabs() && attr.HasTabs() && !TabsEq(GetTabs(), attr.GetTabs()))
!TabsEq(GetTabs(), attr.GetTabs()))
return false; return false;
if ((flags & wxTEXT_ATTR_PAGE_BREAK) && if ((HasPageBreak() != attr.HasPageBreak()))
(HasPageBreak() != attr.HasPageBreak()))
return false; return false;
if (flags & wxTEXT_ATTR_EFFECTS) if (HasTextEffects() && attr.HasTextEffects())
{ {
if (HasTextEffects() != attr.HasTextEffects())
return false;
if (!BitlistsEqPartial(GetTextEffects(), attr.GetTextEffects(), attr.GetTextEffectFlags())) if (!BitlistsEqPartial(GetTextEffects(), attr.GetTextEffects(), attr.GetTextEffectFlags()))
return false; return false;
} }
if ((flags & wxTEXT_ATTR_OUTLINE_LEVEL) && if (HasOutlineLevel() && attr.HasOutlineLevel() && (GetOutlineLevel() != attr.GetOutlineLevel()))
(GetOutlineLevel() != attr.GetOutlineLevel()))
return false; return false;
return true; return true;
@@ -393,11 +414,11 @@ wxFont wxTextAttr::GetFont() const
if (HasFontSize()) if (HasFontSize())
fontSize = GetFontSize(); fontSize = GetFontSize();
int fontStyle = wxNORMAL; wxFontStyle fontStyle = wxFONTSTYLE_NORMAL;
if (HasFontItalic()) if (HasFontItalic())
fontStyle = GetFontStyle(); fontStyle = GetFontStyle();
int fontWeight = wxNORMAL; wxFontWeight fontWeight = wxFONTWEIGHT_NORMAL;
if (HasFontWeight()) if (HasFontWeight())
fontWeight = GetFontWeight(); fontWeight = GetFontWeight();
@@ -406,7 +427,7 @@ wxFont wxTextAttr::GetFont() const
underlined = GetFontUnderlined(); underlined = GetFontUnderlined();
bool strikethrough = false; bool strikethrough = false;
if ( HasFontStrikethrough() ) if (HasFontStrikethrough())
strikethrough = GetFontStrikethrough(); strikethrough = GetFontStrikethrough();
wxString fontFaceName; wxString fontFaceName;
@@ -421,10 +442,20 @@ wxFont wxTextAttr::GetFont() const
if (HasFontFamily()) if (HasFontFamily())
fontFamily = GetFontFamily(); fontFamily = GetFontFamily();
wxFont font(fontSize, fontFamily, fontStyle, fontWeight, underlined, fontFaceName, encoding); if (HasFontPixelSize())
if ( strikethrough ) {
font.SetStrikethrough( true ); wxFont font(wxSize(0, fontSize), fontFamily, fontStyle, fontWeight, underlined, fontFaceName, encoding);
if (strikethrough)
font.SetStrikethrough(true);
return font; return font;
}
else
{
wxFont font(fontSize, fontFamily, fontStyle, fontWeight, underlined, fontFaceName, encoding);
if (strikethrough)
font.SetStrikethrough(true);
return font;
}
} }
// Get attributes from font. // Get attributes from font.
@@ -433,8 +464,30 @@ bool wxTextAttr::GetFontAttributes(const wxFont& font, int flags)
if (!font.IsOk()) if (!font.IsOk())
return false; return false;
if (flags & wxTEXT_ATTR_FONT_SIZE) // If we pass both pixel and point size attributes, this is an indication
// to choose the most appropriate units.
if ((flags & wxTEXT_ATTR_FONT) == wxTEXT_ATTR_FONT)
{
if (font.IsUsingSizeInPixels())
{
m_fontSize = font.GetPixelSize().y;
flags &= ~wxTEXT_ATTR_FONT_POINT_SIZE;
}
else
{
m_fontSize = font.GetPointSize(); m_fontSize = font.GetPointSize();
flags &= ~wxTEXT_ATTR_FONT_PIXEL_SIZE;
}
}
else if (flags & wxTEXT_ATTR_FONT_POINT_SIZE)
{
m_fontSize = font.GetPointSize();
flags &= ~wxTEXT_ATTR_FONT_PIXEL_SIZE;
}
else if (flags & wxTEXT_ATTR_FONT_PIXEL_SIZE)
{
m_fontSize = font.GetPixelSize().y;
}
if (flags & wxTEXT_ATTR_FONT_ITALIC) if (flags & wxTEXT_ATTR_FONT_ITALIC)
m_fontStyle = font.GetStyle(); m_fontStyle = font.GetStyle();
@@ -493,10 +546,15 @@ bool wxTextAttr::Apply(const wxTextAttr& style, const wxTextAttr* compareWith)
destStyle.SetFontWeight(style.GetFontWeight()); destStyle.SetFontWeight(style.GetFontWeight());
} }
if (style.HasFontSize()) if (style.HasFontPointSize())
{ {
if (!(compareWith && compareWith->HasFontSize() && compareWith->GetFontSize() == style.GetFontSize())) if (!(compareWith && compareWith->HasFontPointSize() && compareWith->GetFontSize() == style.GetFontSize()))
destStyle.SetFontSize(style.GetFontSize()); destStyle.SetFontPointSize(style.GetFontSize());
}
else if (style.HasFontPixelSize())
{
if (!(compareWith && compareWith->HasFontPixelSize() && compareWith->GetFontSize() == style.GetFontSize()))
destStyle.SetFontPixelSize(style.GetFontSize());
} }
if (style.HasFontItalic()) if (style.HasFontItalic())

View File

@@ -465,21 +465,6 @@ int wxRichTextFloatCollector::HitTest(wxDC& dc, wxRichTextDrawingContext& contex
// Helpers for efficiency // Helpers for efficiency
inline void wxCheckSetFont(wxDC& dc, const wxFont& font) inline void wxCheckSetFont(wxDC& dc, const wxFont& font)
{ {
// JACS: did I do this some time ago when testing? Should we re-enable it?
#if 0
const wxFont& font1 = dc.GetFont();
if (font1.IsOk() && font.IsOk())
{
if (font1.GetPointSize() == font.GetPointSize() &&
font1.GetFamily() == font.GetFamily() &&
font1.GetStyle() == font.GetStyle() &&
font1.GetWeight() == font.GetWeight() &&
font1.GetUnderlined() == font.GetUnderlined() &&
font1.GetFamily() == font.GetFamily() &&
font1.GetFaceName() == font.GetFaceName())
return;
}
#endif
dc.SetFont(font); dc.SetFont(font);
} }
@@ -630,7 +615,7 @@ int wxRichTextObject::ConvertTenthsMMToPixels(wxDC& dc, int units) const
// Unscale // Unscale
double scale = 1.0; double scale = 1.0;
if (GetBuffer()) if (GetBuffer())
scale = GetBuffer()->GetScale(); scale = GetBuffer()->GetScale() / GetBuffer()->GetDimensionScale();
int p = ConvertTenthsMMToPixels(dc.GetPPI().x, units, scale); int p = ConvertTenthsMMToPixels(dc.GetPPI().x, units, scale);
return p; return p;
@@ -2052,6 +2037,12 @@ bool wxRichTextParagraphLayoutBox::Layout(wxDC& dc, wxRichTextDrawingContext& co
maxWidth = wxMax(maxWidth, w); maxWidth = wxMax(maxWidth, w);
maxMaxWidth = wxMax(maxMaxWidth, w); maxMaxWidth = wxMax(maxMaxWidth, w);
} }
else
{
// TODO: Make sure the layout box's position reflects
// the position of the children, but without
// breaking layout of a box within a paragraph.
}
// TODO: (also in para layout) should set the // TODO: (also in para layout) should set the
// object's size to an absolute one if specified, // object's size to an absolute one if specified,
@@ -2372,6 +2363,7 @@ wxRichTextRange wxRichTextParagraphLayoutBox::AddParagraph(const wxString& text,
wxRichTextAttr* cStyle = & defaultCharStyle; wxRichTextAttr* cStyle = & defaultCharStyle;
wxRichTextParagraph* para = new wxRichTextParagraph(text, this, pStyle, cStyle); wxRichTextParagraph* para = new wxRichTextParagraph(text, this, pStyle, cStyle);
para->GetAttributes().GetTextBoxAttr().Reset();
AppendChild(para); AppendChild(para);
@@ -2413,6 +2405,7 @@ wxRichTextRange wxRichTextParagraphLayoutBox::AddParagraphs(const wxString& text
size_t len = text.length(); size_t len = text.length();
wxString line; wxString line;
wxRichTextParagraph* para = new wxRichTextParagraph(wxEmptyString, this, pStyle, cStyle); wxRichTextParagraph* para = new wxRichTextParagraph(wxEmptyString, this, pStyle, cStyle);
para->GetAttributes().GetTextBoxAttr().Reset();
AppendChild(para); AppendChild(para);
@@ -2430,6 +2423,7 @@ wxRichTextRange wxRichTextParagraphLayoutBox::AddParagraphs(const wxString& text
plainText->SetText(line); plainText->SetText(line);
para = new wxRichTextParagraph(wxEmptyString, this, pStyle, cStyle); para = new wxRichTextParagraph(wxEmptyString, this, pStyle, cStyle);
para->GetAttributes().GetTextBoxAttr().Reset();
AppendChild(para); AppendChild(para);
@@ -2479,6 +2473,7 @@ wxRichTextRange wxRichTextParagraphLayoutBox::AddImage(const wxImage& image, wxR
wxRichTextAttr* cStyle = & defaultCharStyle; wxRichTextAttr* cStyle = & defaultCharStyle;
wxRichTextParagraph* para = new wxRichTextParagraph(this, pStyle); wxRichTextParagraph* para = new wxRichTextParagraph(this, pStyle);
para->GetAttributes().GetTextBoxAttr().Reset();
AppendChild(para); AppendChild(para);
para->AppendChild(new wxRichTextImage(image, this, cStyle)); para->AppendChild(new wxRichTextImage(image, this, cStyle));
@@ -3342,6 +3337,7 @@ bool wxRichTextParagraphLayoutBox::DoGetStyle(long position, wxRichTextAttr& sty
{ {
// Start with the base style // Start with the base style
style = GetAttributes(); style = GetAttributes();
style.GetTextBoxAttr().Reset();
// Apply the paragraph style // Apply the paragraph style
wxRichTextApplyStyle(style, obj->GetAttributes()); wxRichTextApplyStyle(style, obj->GetAttributes());
@@ -3487,7 +3483,7 @@ bool wxRichTextParagraphLayoutBox::HasCharacterAttributes(const wxRichTextRange&
foundCount ++; foundCount ++;
wxRichTextAttr textAttr = para->GetCombinedAttributes(child->GetAttributes()); wxRichTextAttr textAttr = para->GetCombinedAttributes(child->GetAttributes());
if (wxTextAttrEqPartial(textAttr, style)) if (textAttr.EqPartial(style, false /* strong test - attributes must be valid in both objects */))
matchingCount ++; matchingCount ++;
} }
@@ -3530,7 +3526,7 @@ bool wxRichTextParagraphLayoutBox::HasParagraphAttributes(const wxRichTextRange&
wxRichTextApplyStyle(textAttr, para->GetAttributes()); wxRichTextApplyStyle(textAttr, para->GetAttributes());
foundCount ++; foundCount ++;
if (wxTextAttrEqPartial(textAttr, style)) if (textAttr.EqPartial(style, false /* strong test */))
matchingCount ++; matchingCount ++;
} }
} }
@@ -4795,7 +4791,8 @@ bool wxRichTextParagraph::Layout(wxDC& dc, wxRichTextDrawingContext& context, co
if (child->IsTopLevel()) if (child->IsTopLevel())
{ {
// We can move it to the correct position at this point // We can move it to the correct position at this point
child->Move(GetPosition() + wxPoint(currentWidth, currentPosition.y)); // TODO: probably need to add margin
child->Move(GetPosition() + wxPoint(currentWidth + (wxMax(leftIndent, leftIndent + leftSubIndent)), currentPosition.y));
} }
// Cases: // Cases:
@@ -5052,6 +5049,7 @@ void wxRichTextParagraph::ApplyParagraphStyle(wxRichTextLine* line, const wxRich
return; return;
wxPoint pos = line->GetPosition(); wxPoint pos = line->GetPosition();
wxPoint originalPos = pos;
wxSize size = line->GetSize(); wxSize size = line->GetSize();
// centering, right-justification // centering, right-justification
@@ -5067,6 +5065,22 @@ void wxRichTextParagraph::ApplyParagraphStyle(wxRichTextLine* line, const wxRich
pos.x = pos.x + rect.GetWidth() - size.x - rightIndent; pos.x = pos.x + rect.GetWidth() - size.x - rightIndent;
line->SetPosition(pos); line->SetPosition(pos);
} }
if (pos != originalPos)
{
wxPoint inc = pos - originalPos;
wxRichTextObjectList::compatibility_iterator node = m_children.GetFirst();
while (node)
{
wxRichTextObject* child = node->GetData();
if (child->IsTopLevel() && !child->GetRange().IsOutside(line->GetAbsoluteRange()))
child->Move(child->GetPosition() + inc);
node = node->GetNext();
}
}
} }
/// Insert text at the given position /// Insert text at the given position
@@ -6255,20 +6269,41 @@ bool wxRichTextPlainText::Draw(wxDC& dc, wxRichTextDrawingContext& context, cons
if ( textFont.IsOk() ) if ( textFont.IsOk() )
{ {
if ( textAttr.HasTextEffects() && (textAttr.GetTextEffects() & wxTEXT_ATTR_EFFECT_SUPERSCRIPT) ) if ( textAttr.HasTextEffects() && (textAttr.GetTextEffects() & wxTEXT_ATTR_EFFECT_SUPERSCRIPT) )
{
if (textFont.IsUsingSizeInPixels())
{
double size = static_cast<double>(textFont.GetPixelSize().y) / wxSCRIPT_MUL_FACTOR;
textFont.SetPixelSize(wxSize(0, static_cast<int>(size)) );
x = rect.x;
y = rect.y;
}
else
{ {
double size = static_cast<double>(textFont.GetPointSize()) / wxSCRIPT_MUL_FACTOR; double size = static_cast<double>(textFont.GetPointSize()) / wxSCRIPT_MUL_FACTOR;
textFont.SetPointSize( static_cast<int>(size) ); textFont.SetPointSize( static_cast<int>(size) );
x = rect.x; x = rect.x;
y = rect.y; y = rect.y;
}
wxCheckSetFont(dc, textFont); wxCheckSetFont(dc, textFont);
} }
else if ( textAttr.HasTextEffects() && (textAttr.GetTextEffects() & wxTEXT_ATTR_EFFECT_SUBSCRIPT) ) else if ( textAttr.HasTextEffects() && (textAttr.GetTextEffects() & wxTEXT_ATTR_EFFECT_SUBSCRIPT) )
{
if (textFont.IsUsingSizeInPixels())
{
double size = static_cast<double>(textFont.GetPixelSize().y) / wxSCRIPT_MUL_FACTOR;
textFont.SetPixelSize(wxSize(0, static_cast<int>(size)));
x = rect.x;
int sub_height = static_cast<int>( static_cast<double>(charHeight) / wxSCRIPT_MUL_FACTOR);
y = rect.y + (rect.height - sub_height + (descent - m_descent));
}
else
{ {
double size = static_cast<double>(textFont.GetPointSize()) / wxSCRIPT_MUL_FACTOR; double size = static_cast<double>(textFont.GetPointSize()) / wxSCRIPT_MUL_FACTOR;
textFont.SetPointSize( static_cast<int>(size) ); textFont.SetPointSize( static_cast<int>(size) );
x = rect.x; x = rect.x;
int sub_height = static_cast<int>( static_cast<double>(charHeight) / wxSCRIPT_MUL_FACTOR); int sub_height = static_cast<int>( static_cast<double>(charHeight) / wxSCRIPT_MUL_FACTOR);
y = rect.y + (rect.height - sub_height + (descent - m_descent)); y = rect.y + (rect.height - sub_height + (descent - m_descent));
}
wxCheckSetFont(dc, textFont); wxCheckSetFont(dc, textFont);
} }
else else
@@ -6558,8 +6593,16 @@ bool wxRichTextPlainText::GetRangeSize(const wxRichTextRange& range, wxSize& siz
|| (textAttr.GetTextEffects() & wxTEXT_ATTR_EFFECT_SUBSCRIPT) ) ) || (textAttr.GetTextEffects() & wxTEXT_ATTR_EFFECT_SUBSCRIPT) ) )
{ {
wxFont textFont = font; wxFont textFont = font;
if (textFont.IsUsingSizeInPixels())
{
double size = static_cast<double>(textFont.GetPixelSize().y) / wxSCRIPT_MUL_FACTOR;
textFont.SetPixelSize(wxSize(0, static_cast<int>(size)));
}
else
{
double size = static_cast<double>(textFont.GetPointSize()) / wxSCRIPT_MUL_FACTOR; double size = static_cast<double>(textFont.GetPointSize()) / wxSCRIPT_MUL_FACTOR;
textFont.SetPointSize( static_cast<int>(size) ); textFont.SetPointSize(static_cast<int>(size));
}
wxCheckSetFont(dc, textFont); wxCheckSetFont(dc, textFont);
bScript = true; bScript = true;
} }
@@ -6852,6 +6895,8 @@ void wxRichTextBuffer::Init()
m_suppressUndo = 0; m_suppressUndo = 0;
m_handlerFlags = 0; m_handlerFlags = 0;
m_scale = 1.0; m_scale = 1.0;
m_dimensionScale = 1.0;
m_fontScale = 1.0;
SetMargins(4); SetMargins(4);
} }
@@ -6887,6 +6932,8 @@ void wxRichTextBuffer::Copy(const wxRichTextBuffer& obj)
m_batchedCommand = NULL; m_batchedCommand = NULL;
m_suppressUndo = obj.m_suppressUndo; m_suppressUndo = obj.m_suppressUndo;
m_invalidRange = obj.m_invalidRange; m_invalidRange = obj.m_invalidRange;
m_dimensionScale = obj.m_dimensionScale;
m_fontScale = obj.m_fontScale;
} }
/// Push style sheet to top of stack /// Push style sheet to top of stack
@@ -7007,6 +7054,8 @@ bool wxRichTextParagraphLayoutBox::InsertNewlineWithUndo(wxRichTextBuffer* buffe
} }
wxRichTextAttr attr(buffer->GetDefaultStyle()); wxRichTextAttr attr(buffer->GetDefaultStyle());
// Don't include box attributes such as margins
attr.GetTextBoxAttr().Reset();
wxRichTextParagraph* newPara = new wxRichTextParagraph(wxEmptyString, this, & attr); wxRichTextParagraph* newPara = new wxRichTextParagraph(wxEmptyString, this, & attr);
action->GetNewParagraphs().AppendChild(newPara); action->GetNewParagraphs().AppendChild(newPara);
@@ -7034,13 +7083,13 @@ bool wxRichTextParagraphLayoutBox::InsertNewlineWithUndo(wxRichTextBuffer* buffe
action->SetPosition(pos); action->SetPosition(pos);
// Use the default character style
// Use the default character style // Use the default character style
if (!buffer->GetDefaultStyle().IsDefault() && newPara->GetChildren().GetFirst()) if (!buffer->GetDefaultStyle().IsDefault() && newPara->GetChildren().GetFirst())
{ {
// Check whether the default style merely reflects the paragraph/basic style, // Check whether the default style merely reflects the paragraph/basic style,
// in which case don't apply it. // in which case don't apply it.
wxRichTextAttr defaultStyle(buffer->GetDefaultStyle()); wxRichTextAttr defaultStyle(buffer->GetDefaultStyle());
defaultStyle.GetTextBoxAttr().Reset();
wxRichTextAttr toApply; wxRichTextAttr toApply;
if (para) if (para)
{ {
@@ -7090,6 +7139,9 @@ bool wxRichTextParagraphLayoutBox::InsertImageWithUndo(wxRichTextBuffer* buffer,
wxRichTextAttr attr(buffer->GetDefaultStyle()); wxRichTextAttr attr(buffer->GetDefaultStyle());
// Don't include box attributes such as margins
attr.GetTextBoxAttr().Reset();
wxRichTextParagraph* newPara = new wxRichTextParagraph(this, & attr); wxRichTextParagraph* newPara = new wxRichTextParagraph(this, & attr);
if (p) if (p)
newPara->SetAttributes(*p); newPara->SetAttributes(*p);
@@ -7134,6 +7186,9 @@ wxRichTextObject* wxRichTextParagraphLayoutBox::InsertObjectWithUndo(wxRichTextB
wxRichTextAttr attr(buffer->GetDefaultStyle()); wxRichTextAttr attr(buffer->GetDefaultStyle());
// Don't include box attributes such as margins
attr.GetTextBoxAttr().Reset();
wxRichTextParagraph* newPara = new wxRichTextParagraph(this, & attr); wxRichTextParagraph* newPara = new wxRichTextParagraph(this, & attr);
if (p) if (p)
newPara->SetAttributes(*p); newPara->SetAttributes(*p);
@@ -7173,6 +7228,9 @@ wxRichTextField* wxRichTextParagraphLayoutBox::InsertFieldWithUndo(wxRichTextBuf
wxRichTextAttr attr(buffer->GetDefaultStyle()); wxRichTextAttr attr(buffer->GetDefaultStyle());
// Don't include box attributes such as margins
attr.GetTextBoxAttr().Reset();
wxRichTextParagraph* newPara = new wxRichTextParagraph(this, & attr); wxRichTextParagraph* newPara = new wxRichTextParagraph(this, & attr);
if (p) if (p)
newPara->SetAttributes(*p); newPara->SetAttributes(*p);
@@ -7392,9 +7450,10 @@ bool wxRichTextBuffer::EndSuppressUndo()
bool wxRichTextBuffer::BeginStyle(const wxRichTextAttr& style) bool wxRichTextBuffer::BeginStyle(const wxRichTextAttr& style)
{ {
wxRichTextAttr newStyle(GetDefaultStyle()); wxRichTextAttr newStyle(GetDefaultStyle());
newStyle.GetTextBoxAttr().Reset();
// Save the old default style // Save the old default style
m_attributeStack.Append((wxObject*) new wxRichTextAttr(GetDefaultStyle())); m_attributeStack.Append((wxObject*) new wxRichTextAttr(newStyle));
wxRichTextApplyStyle(newStyle, style); wxRichTextApplyStyle(newStyle, style);
newStyle.SetFlags(style.GetFlags()|newStyle.GetFlags()); newStyle.SetFlags(style.GetFlags()|newStyle.GetFlags());
@@ -8142,6 +8201,17 @@ int wxRichTextBuffer::HitTest(wxDC& dc, wxRichTextDrawingContext& context, const
} }
} }
void wxRichTextBuffer::SetFontScale(double fontScale)
{
m_fontScale = fontScale;
m_fontTable.SetFontScale(fontScale);
}
void wxRichTextBuffer::SetDimensionScale(double dimScale)
{
m_dimensionScale = dimScale;
}
bool wxRichTextStdRenderer::DrawStandardBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxRichTextAttr& bulletAttr, const wxRect& rect) bool wxRichTextStdRenderer::DrawStandardBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxRichTextAttr& bulletAttr, const wxRect& rect)
{ {
if (bulletAttr.GetTextColour().IsOk()) if (bulletAttr.GetTextColour().IsOk())
@@ -8230,7 +8300,10 @@ bool wxRichTextStdRenderer::DrawTextBullet(wxRichTextParagraph* paragraph, wxDC&
if ((attr.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_SYMBOL) && !attr.GetBulletFont().IsEmpty() && attr.HasFont()) if ((attr.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_SYMBOL) && !attr.GetBulletFont().IsEmpty() && attr.HasFont())
{ {
wxRichTextAttr fontAttr; wxRichTextAttr fontAttr;
fontAttr.SetFontSize(attr.GetFontSize()); if (attr.HasFontPixelSize())
fontAttr.SetFontPixelSize(attr.GetFontSize());
else
fontAttr.SetFontPointSize(attr.GetFontSize());
fontAttr.SetFontStyle(attr.GetFontStyle()); fontAttr.SetFontStyle(attr.GetFontStyle());
fontAttr.SetFontWeight(attr.GetFontWeight()); fontAttr.SetFontWeight(attr.GetFontWeight());
fontAttr.SetFontUnderlined(attr.GetFontUnderlined()); fontAttr.SetFontUnderlined(attr.GetFontUnderlined());
@@ -8401,7 +8474,7 @@ void wxRichTextField::Copy(const wxRichTextField& obj)
{ {
wxRichTextParagraphLayoutBox::Copy(obj); wxRichTextParagraphLayoutBox::Copy(obj);
UpdateField(); UpdateField(GetBuffer());
} }
// Edit properties via a GUI // Edit properties via a GUI
@@ -8432,11 +8505,11 @@ wxString wxRichTextField::GetPropertiesMenuLabel() const
return wxEmptyString; return wxEmptyString;
} }
bool wxRichTextField::UpdateField() bool wxRichTextField::UpdateField(wxRichTextBuffer* buffer)
{ {
wxRichTextFieldType* fieldType = wxRichTextBuffer::FindFieldType(GetFieldType()); wxRichTextFieldType* fieldType = wxRichTextBuffer::FindFieldType(GetFieldType());
if (fieldType) if (fieldType)
return fieldType->UpdateField((wxRichTextField*) this); return fieldType->UpdateField(buffer, (wxRichTextField*) this);
return false; return false;
} }
@@ -10874,12 +10947,6 @@ bool wxTextAttrEq(const wxRichTextAttr& attr1, const wxRichTextAttr& attr2)
return (attr1 == attr2); return (attr1 == attr2);
} }
// Partial equality test taking flags into account
bool wxTextAttrEqPartial(const wxRichTextAttr& attr1, const wxRichTextAttr& attr2)
{
return attr1.EqPartial(attr2);
}
/// Compare tabs /// Compare tabs
bool wxRichTextTabsEq(const wxArrayInt& tabs1, const wxArrayInt& tabs2) bool wxRichTextTabsEq(const wxArrayInt& tabs1, const wxArrayInt& tabs2)
{ {
@@ -11494,24 +11561,50 @@ class wxRichTextFontTableData: public wxObjectRefData
public: public:
wxRichTextFontTableData() {} wxRichTextFontTableData() {}
wxFont FindFont(const wxRichTextAttr& fontSpec); wxFont FindFont(const wxRichTextAttr& fontSpec, double fontScale);
wxRichTextFontTableHashMap m_hashMap; wxRichTextFontTableHashMap m_hashMap;
}; };
wxFont wxRichTextFontTableData::FindFont(const wxRichTextAttr& fontSpec) wxFont wxRichTextFontTableData::FindFont(const wxRichTextAttr& fontSpec, double fontScale)
{ {
wxString facename(fontSpec.GetFontFaceName()); wxString facename(fontSpec.GetFontFaceName());
wxString spec(wxString::Format(wxT("%d-%d-%d-%d-%s-%d"), fontSpec.GetFontSize(), fontSpec.GetFontStyle(), fontSpec.GetFontWeight(), (int) fontSpec.GetFontUnderlined(), facename.c_str(), (int) fontSpec.GetFontEncoding()));
wxRichTextFontTableHashMap::iterator entry = m_hashMap.find(spec);
int fontSize = fontSpec.GetFontSize();
if (fontScale != 1.0)
fontSize = (int) ((double(fontSize) * fontScale) + 0.5);
wxString units;
if (fontSpec.HasFontPixelSize() && !fontSpec.HasFontPointSize())
units = wxT("px");
else
units = wxT("pt");
wxString spec = wxString::Format(wxT("%d-%s-%d-%d-%d-%d-%s-%d"),
fontSize, units.c_str(), fontSpec.GetFontStyle(), fontSpec.GetFontWeight(), (int) fontSpec.GetFontUnderlined(), (int) fontSpec.GetFontStrikethrough(),
facename.c_str(), (int) fontSpec.GetFontEncoding());
wxRichTextFontTableHashMap::iterator entry = m_hashMap.find(spec);
if ( entry == m_hashMap.end() ) if ( entry == m_hashMap.end() )
{ {
wxFont font(fontSpec.GetFontSize(), wxDEFAULT, fontSpec.GetFontStyle(), fontSpec.GetFontWeight(), fontSpec.GetFontUnderlined(), facename.c_str()); if (fontSpec.HasFontPixelSize() && !fontSpec.HasFontPointSize())
{
wxFont font(wxSize(0, fontSize), wxDEFAULT, fontSpec.GetFontStyle(), fontSpec.GetFontWeight(), fontSpec.GetFontUnderlined(), facename.c_str());
if (fontSpec.HasFontStrikethrough() && fontSpec.GetFontStrikethrough())
font.SetStrikethrough(true);
m_hashMap[spec] = font; m_hashMap[spec] = font;
return font; return font;
} }
else else
{
wxFont font(fontSize, wxDEFAULT, fontSpec.GetFontStyle(), fontSpec.GetFontWeight(), fontSpec.GetFontUnderlined(), facename.c_str());
if (fontSpec.HasFontStrikethrough() && fontSpec.GetFontStrikethrough())
font.SetStrikethrough(true);
m_hashMap[spec] = font;
return font;
}
}
else
{ {
return entry->second; return entry->second;
} }
@@ -11522,6 +11615,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxRichTextFontTable, wxObject)
wxRichTextFontTable::wxRichTextFontTable() wxRichTextFontTable::wxRichTextFontTable()
{ {
m_refData = new wxRichTextFontTableData; m_refData = new wxRichTextFontTableData;
m_fontScale = 1.0;
} }
wxRichTextFontTable::wxRichTextFontTable(const wxRichTextFontTable& table) wxRichTextFontTable::wxRichTextFontTable(const wxRichTextFontTable& table)
@@ -11543,13 +11637,14 @@ bool wxRichTextFontTable::operator == (const wxRichTextFontTable& table) const
void wxRichTextFontTable::operator= (const wxRichTextFontTable& table) void wxRichTextFontTable::operator= (const wxRichTextFontTable& table)
{ {
Ref(table); Ref(table);
m_fontScale = table.m_fontScale;
} }
wxFont wxRichTextFontTable::FindFont(const wxRichTextAttr& fontSpec) wxFont wxRichTextFontTable::FindFont(const wxRichTextAttr& fontSpec)
{ {
wxRichTextFontTableData* data = (wxRichTextFontTableData*) m_refData; wxRichTextFontTableData* data = (wxRichTextFontTableData*) m_refData;
if (data) if (data)
return data->FindFont(fontSpec); return data->FindFont(fontSpec, m_fontScale);
else else
return wxFont(); return wxFont();
} }
@@ -11561,6 +11656,13 @@ void wxRichTextFontTable::Clear()
data->m_hashMap.clear(); data->m_hashMap.clear();
} }
void wxRichTextFontTable::SetFontScale(double fontScale)
{
if (fontScale != m_fontScale)
Clear();
m_fontScale = fontScale;
}
// wxTextBoxAttr // wxTextBoxAttr
void wxTextBoxAttr::Reset() void wxTextBoxAttr::Reset()
@@ -11610,8 +11712,17 @@ bool wxTextBoxAttr::operator== (const wxTextBoxAttr& attr) const
} }
// Partial equality test // Partial equality test
bool wxTextBoxAttr::EqPartial(const wxTextBoxAttr& attr) const bool wxTextBoxAttr::EqPartial(const wxTextBoxAttr& attr, bool weakTest) const
{ {
if (!weakTest &&
((!HasFloatMode() && attr.HasFloatMode()) ||
(!HasClearMode() && attr.HasClearMode()) ||
(!HasCollapseBorders() && attr.HasCollapseBorders()) ||
(!HasVerticalAlignment() && attr.HasVerticalAlignment()) ||
(!HasBoxStyleName() && attr.HasBoxStyleName())))
{
return false;
}
if (attr.HasFloatMode() && HasFloatMode() && (GetFloatMode() != attr.GetFloatMode())) if (attr.HasFloatMode() && HasFloatMode() && (GetFloatMode() != attr.GetFloatMode()))
return false; return false;
@@ -11629,36 +11740,36 @@ bool wxTextBoxAttr::EqPartial(const wxTextBoxAttr& attr) const
// Position // Position
if (!m_position.EqPartial(attr.m_position)) if (!m_position.EqPartial(attr.m_position, weakTest))
return false; return false;
// Size // Size
if (!m_size.EqPartial(attr.m_size)) if (!m_size.EqPartial(attr.m_size, weakTest))
return false; return false;
if (!m_minSize.EqPartial(attr.m_minSize)) if (!m_minSize.EqPartial(attr.m_minSize, weakTest))
return false; return false;
if (!m_maxSize.EqPartial(attr.m_maxSize)) if (!m_maxSize.EqPartial(attr.m_maxSize, weakTest))
return false; return false;
// Margins // Margins
if (!m_margins.EqPartial(attr.m_margins)) if (!m_margins.EqPartial(attr.m_margins, weakTest))
return false; return false;
// Padding // Padding
if (!m_padding.EqPartial(attr.m_padding)) if (!m_padding.EqPartial(attr.m_padding, weakTest))
return false; return false;
// Border // Border
if (!GetBorder().EqPartial(attr.GetBorder())) if (!GetBorder().EqPartial(attr.GetBorder(), weakTest))
return false; return false;
// Outline // Outline
if (!GetOutline().EqPartial(attr.GetOutline())) if (!GetOutline().EqPartial(attr.GetOutline(), weakTest))
return false; return false;
return true; return true;
@@ -11883,13 +11994,13 @@ bool wxRichTextAttr::operator==(const wxRichTextAttr& attr) const
return (m_textBoxAttr == attr.m_textBoxAttr); return (m_textBoxAttr == attr.m_textBoxAttr);
} }
// Partial equality test taking comparison object into account // Partial equality test
bool wxRichTextAttr::EqPartial(const wxRichTextAttr& attr) const bool wxRichTextAttr::EqPartial(const wxRichTextAttr& attr, bool weakTest) const
{ {
if (!(wxTextAttr::EqPartial(attr))) if (!(wxTextAttr::EqPartial(attr, weakTest)))
return false; return false;
return m_textBoxAttr.EqPartial(attr.m_textBoxAttr); return m_textBoxAttr.EqPartial(attr.m_textBoxAttr, weakTest);
} }
// Merges the given attributes. If compareWith // Merges the given attributes. If compareWith
@@ -11920,15 +12031,23 @@ void wxRichTextAttr::CollectCommonAttributes(const wxRichTextAttr& attr, wxRichT
} }
// Partial equality test // Partial equality test
bool wxTextAttrBorder::EqPartial(const wxTextAttrBorder& border) const bool wxTextAttrBorder::EqPartial(const wxTextAttrBorder& border, bool weakTest) const
{ {
if (border.HasStyle() && !HasStyle() && (border.GetStyle() != GetStyle())) if (!weakTest &&
((!HasStyle() && border.HasStyle()) ||
(!HasColour() && border.HasColour()) ||
(!HasWidth() && border.HasWidth())))
{
return false;
}
if (border.HasStyle() && HasStyle() && (border.GetStyle() != GetStyle()))
return false; return false;
if (border.HasColour() && !HasColour() && (border.GetColourLong() != GetColourLong())) if (border.HasColour() && HasColour() && (border.GetColourLong() != GetColourLong()))
return false; return false;
if (border.HasWidth() && !HasWidth() && !(border.GetWidth() == GetWidth())) if (border.HasWidth() && HasWidth() && !(border.GetWidth() == GetWidth()))
return false; return false;
return true; return true;
@@ -12015,10 +12134,10 @@ void wxTextAttrBorder::CollectCommonAttributes(const wxTextAttrBorder& attr, wxT
} }
// Partial equality test // Partial equality test
bool wxTextAttrBorders::EqPartial(const wxTextAttrBorders& borders) const bool wxTextAttrBorders::EqPartial(const wxTextAttrBorders& borders, bool weakTest) const
{ {
return m_left.EqPartial(borders.m_left) && m_right.EqPartial(borders.m_right) && return m_left.EqPartial(borders.m_left, weakTest) && m_right.EqPartial(borders.m_right, weakTest) &&
m_top.EqPartial(borders.m_top) && m_bottom.EqPartial(borders.m_bottom); m_top.EqPartial(borders.m_top, weakTest) && m_bottom.EqPartial(borders.m_bottom, weakTest);
} }
// Apply border to 'this', but not if the same as compareWith // Apply border to 'this', but not if the same as compareWith
@@ -12087,8 +12206,11 @@ void wxTextAttrBorders::SetWidth(const wxTextAttrDimension& width)
} }
// Partial equality test // Partial equality test
bool wxTextAttrDimension::EqPartial(const wxTextAttrDimension& dim) const bool wxTextAttrDimension::EqPartial(const wxTextAttrDimension& dim, bool weakTest) const
{ {
if (!weakTest && !IsValid() && dim.IsValid())
return false;
if (dim.IsValid() && IsValid() && !((*this) == dim)) if (dim.IsValid() && IsValid() && !((*this) == dim))
return false; return false;
else else
@@ -12185,18 +12307,18 @@ int wxTextAttrDimensionConverter::GetTenthsMM(const wxTextAttrDimension& dim) co
} }
// Partial equality test // Partial equality test
bool wxTextAttrDimensions::EqPartial(const wxTextAttrDimensions& dims) const bool wxTextAttrDimensions::EqPartial(const wxTextAttrDimensions& dims, bool weakTest) const
{ {
if (!m_left.EqPartial(dims.m_left)) if (!m_left.EqPartial(dims.m_left, weakTest))
return false; return false;
if (!m_right.EqPartial(dims.m_right)) if (!m_right.EqPartial(dims.m_right, weakTest))
return false; return false;
if (!m_top.EqPartial(dims.m_top)) if (!m_top.EqPartial(dims.m_top, weakTest))
return false; return false;
if (!m_bottom.EqPartial(dims.m_bottom)) if (!m_bottom.EqPartial(dims.m_bottom, weakTest))
return false; return false;
return true; return true;
@@ -12239,12 +12361,12 @@ void wxTextAttrDimensions::CollectCommonAttributes(const wxTextAttrDimensions& a
} }
// Partial equality test // Partial equality test
bool wxTextAttrSize::EqPartial(const wxTextAttrSize& size) const bool wxTextAttrSize::EqPartial(const wxTextAttrSize& size, bool weakTest) const
{ {
if (!m_width.EqPartial(size.m_width)) if (!m_width.EqPartial(size.m_width, weakTest))
return false; return false;
if (!m_height.EqPartial(size.m_height)) if (!m_height.EqPartial(size.m_height, weakTest))
return false; return false;
return true; return true;
@@ -12289,21 +12411,36 @@ void wxTextAttrCollectCommonAttributes(wxTextAttr& currentStyle, const wxTextAtt
if (attr.HasFont()) if (attr.HasFont())
{ {
if (attr.HasFontSize() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_FONT_SIZE)) if (attr.HasFontPointSize() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_FONT_POINT_SIZE))
{ {
if (currentStyle.HasFontSize()) if (currentStyle.HasFontPointSize())
{ {
if (currentStyle.GetFontSize() != attr.GetFontSize()) if (currentStyle.GetFontSize() != attr.GetFontSize())
{ {
// Clash of attr - mark as such // Clash of attr - mark as such
clashingAttr.AddFlag(wxTEXT_ATTR_FONT_SIZE); clashingAttr.AddFlag(wxTEXT_ATTR_FONT_POINT_SIZE);
currentStyle.RemoveFlag(wxTEXT_ATTR_FONT_SIZE); currentStyle.RemoveFlag(wxTEXT_ATTR_FONT_POINT_SIZE);
} }
} }
else else
currentStyle.SetFontSize(attr.GetFontSize()); currentStyle.SetFontSize(attr.GetFontSize());
} }
if (attr.HasFontPixelSize() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_FONT_PIXEL_SIZE))
{
if (currentStyle.HasFontPixelSize())
{
if (currentStyle.GetFontSize() != attr.GetFontSize())
{
// Clash of attr - mark as such
clashingAttr.AddFlag(wxTEXT_ATTR_FONT_PIXEL_SIZE);
currentStyle.RemoveFlag(wxTEXT_ATTR_FONT_PIXEL_SIZE);
}
}
else
currentStyle.SetFontPixelSize(attr.GetFontSize());
}
if (attr.HasFontItalic() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_FONT_ITALIC)) if (attr.HasFontItalic() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_FONT_ITALIC))
{ {
if (currentStyle.HasFontItalic()) if (currentStyle.HasFontItalic())
@@ -12381,6 +12518,21 @@ void wxTextAttrCollectCommonAttributes(wxTextAttr& currentStyle, const wxTextAtt
else else
currentStyle.SetFontUnderlined(attr.GetFontUnderlined()); currentStyle.SetFontUnderlined(attr.GetFontUnderlined());
} }
if (attr.HasFontStrikethrough() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_FONT_STRIKETHROUGH))
{
if (currentStyle.HasFontStrikethrough())
{
if (currentStyle.GetFontStrikethrough() != attr.GetFontStrikethrough())
{
// Clash of attr - mark as such
clashingAttr.AddFlag(wxTEXT_ATTR_FONT_STRIKETHROUGH);
currentStyle.RemoveFlag(wxTEXT_ATTR_FONT_STRIKETHROUGH);
}
}
else
currentStyle.SetFontStrikethrough(attr.GetFontStrikethrough());
}
} }
if (attr.HasTextColour() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_TEXT_COLOUR)) if (attr.HasTextColour() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_TEXT_COLOUR))

View File

@@ -264,7 +264,6 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& va
attributes.SetLineSpacing(10); attributes.SetLineSpacing(10);
attributes.SetParagraphSpacingAfter(10); attributes.SetParagraphSpacingAfter(10);
attributes.SetParagraphSpacingBefore(0); attributes.SetParagraphSpacingBefore(0);
SetBasicStyle(attributes); SetBasicStyle(attributes);
int margin = 5; int margin = 5;
@@ -2931,6 +2930,7 @@ void wxRichTextCtrl::DoWriteText(const wxString& value, int flags)
wxString valueUnix = wxTextFile::Translate(value, wxTextFileType_Unix); wxString valueUnix = wxTextFile::Translate(value, wxTextFileType_Unix);
GetFocusObject()->InsertTextWithUndo(& GetBuffer(), m_caretPosition+1, valueUnix, this, wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE); GetFocusObject()->InsertTextWithUndo(& GetBuffer(), m_caretPosition+1, valueUnix, this, wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE);
GetBuffer().Defragment();
if ( flags & SetValue_SendEvent ) if ( flags & SetValue_SendEvent )
wxTextCtrl::SendTextUpdatedEvent(this); wxTextCtrl::SendTextUpdatedEvent(this);
@@ -4580,6 +4580,26 @@ void wxRichTextCtrl::EnableVerticalScrollbar(bool enable)
SetupScrollbars(); SetupScrollbars();
} }
void wxRichTextCtrl::SetFontScale(double fontScale, bool refresh)
{
GetBuffer().SetFontScale(fontScale);
if (refresh)
{
GetBuffer().Invalidate(wxRICHTEXT_ALL);
Refresh();
}
}
void wxRichTextCtrl::SetDimensionScale(double dimScale, bool refresh)
{
GetBuffer().SetDimensionScale(dimScale);
if (refresh)
{
GetBuffer().Invalidate(wxRICHTEXT_ALL);
Refresh();
}
}
#if wxRICHTEXT_USE_OWN_CARET #if wxRICHTEXT_USE_OWN_CARET
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -234,6 +234,7 @@
<string name="app-kind">"Standard"</string> <string name="app-kind">"Standard"</string>
<long name="use-xrc">0</long> <long name="use-xrc">0</long>
<long name="working-mode">0</long> <long name="working-mode">0</long>
<string name="event-handler-0">"wxEVT_IDLE|OnIdle|NONE||wxRichTextFontPage"</string>
<string name="proxy-Id name">"ID_RICHTEXTFONTPAGE"</string> <string name="proxy-Id name">"ID_RICHTEXTFONTPAGE"</string>
<long name="proxy-Id value">10000</long> <long name="proxy-Id value">10000</long>
<string name="proxy-Class">"wxRichTextFontPage"</string> <string name="proxy-Class">"wxRichTextFontPage"</string>
@@ -307,14 +308,6 @@
<string name="proxy-type">"wbBoxSizerProxy"</string> <string name="proxy-type">"wbBoxSizerProxy"</string>
<string name="proxy-Orientation">"Vertical"</string> <string name="proxy-Orientation">"Vertical"</string>
<string name="proxy-Member variable name">""</string> <string name="proxy-Member variable name">""</string>
<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-wxSHAPED">0</bool>
<bool name="proxy-wxADJUST_MINSIZE">0</bool> <bool name="proxy-wxADJUST_MINSIZE">0</bool>
<bool name="proxy-wxFIXED_MINSIZE">0</bool> <bool name="proxy-wxFIXED_MINSIZE">0</bool>
@@ -549,77 +542,6 @@
<string name="proxy-Custom arguments">""</string> <string name="proxy-Custom arguments">""</string>
<string name="proxy-Custom ctor arguments">""</string> <string name="proxy-Custom ctor arguments">""</string>
</document> </document>
<document>
<string name="title">"wxRichTextFontListBox: ID_RICHTEXTFONTPAGE_FACELISTBOX"</string>
<string name="type">"dialog-control-document"</string>
<string name="filename">""</string>
<string name="icon-name">"foreign"</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="created">"2/10/2006"</string>
<string name="proxy-type">"wbForeignCtrlProxy"</string>
<string name="proxy-Id name">"ID_RICHTEXTFONTPAGE_FACELISTBOX"</string>
<long name="proxy-Id value">10002</long>
<string name="proxy-Name">""</string>
<string name="proxy-Class">"wxRichTextFontListBox"</string>
<string name="proxy-Base class">"wxWindow"</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_faceListBox"</string>
<bool name="proxy-Create in situ">1</bool>
<string name="proxy-Help text">"Lists the available fonts."</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">0</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-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>
<bool name="proxy-wxCLIP_CHILDREN">0</bool>
<bool name="proxy-wxHSCROLL">0</bool>
<bool name="proxy-wxVSCROLL">0</bool>
<bool name="proxy-wxWS_EX_VALIDATE_RECURSIVELY">0</bool>
<string name="proxy-Custom styles">""</string>
<long name="proxy-X">-1</long>
<long name="proxy-Y">-1</long>
<long name="proxy-Width">200</long>
<long name="proxy-Height">100</long>
<string name="proxy-AlignH">"Expand"</string>
<string name="proxy-AlignV">"Centre"</string>
<long name="proxy-Stretch factor">1</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">1</bool>
<string name="proxy-Custom arguments">""</string>
<string name="proxy-Custom ctor arguments">""</string>
<string name="proxy-Event sources">""</string>
</document>
</document> </document>
<document> <document>
<string name="title">"wxBoxSizer V"</string> <string name="title">"wxBoxSizer V"</string>
@@ -717,6 +639,30 @@
<string name="proxy-Custom arguments">""</string> <string name="proxy-Custom arguments">""</string>
<string name="proxy-Custom ctor arguments">""</string> <string name="proxy-Custom ctor arguments">""</string>
</document> </document>
<document>
<string name="title">"wxBoxSizer H"</string>
<string name="type">"dialog-control-document"</string>
<string name="filename">""</string>
<string name="icon-name">"sizer"</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">"wbBoxSizerProxy"</string>
<string name="proxy-Orientation">"Horizontal"</string>
<string name="proxy-Member variable name">""</string>
<string name="proxy-AlignH">"Expand"</string>
<string name="proxy-AlignV">"Centre"</string>
<long name="proxy-Stretch factor">0</long>
<long name="proxy-Border">5</long>
<bool name="proxy-wxLEFT">0</bool>
<bool name="proxy-wxRIGHT">0</bool>
<bool name="proxy-wxTOP">0</bool>
<bool name="proxy-wxBOTTOM">0</bool>
<bool name="proxy-wxSHAPED">0</bool>
<bool name="proxy-wxADJUST_MINSIZE">0</bool>
<bool name="proxy-wxFIXED_MINSIZE">0</bool>
<string name="proxy-Platform">"&lt;Any platform&gt;"</string>
<document> <document>
<string name="title">"wxTextCtrl: ID_RICHTEXTFONTPAGE_SIZETEXTCTRL"</string> <string name="title">"wxTextCtrl: ID_RICHTEXTFONTPAGE_SIZETEXTCTRL"</string>
<string name="type">"dialog-control-document"</string> <string name="type">"dialog-control-document"</string>
@@ -726,7 +672,6 @@
<long name="owns-file">1</long> <long name="owns-file">1</long>
<long name="title-mode">0</long> <long name="title-mode">0</long>
<long name="locked">0</long> <long name="locked">0</long>
<string name="created">"2/10/2006"</string>
<string name="proxy-type">"wbTextCtrlProxy"</string> <string name="proxy-type">"wbTextCtrlProxy"</string>
<string name="event-handler-0">"wxEVT_COMMAND_TEXT_UPDATED|OnSizeTextCtrlUpdated"</string> <string name="event-handler-0">"wxEVT_COMMAND_TEXT_UPDATED|OnSizeTextCtrlUpdated"</string>
<string name="proxy-Id name">"ID_RICHTEXTFONTPAGE_SIZETEXTCTRL"</string> <string name="proxy-Id name">"ID_RICHTEXTFONTPAGE_SIZETEXTCTRL"</string>
@@ -792,6 +737,79 @@
<long name="proxy-Stretch factor">0</long> <long name="proxy-Stretch factor">0</long>
<long name="proxy-Border">5</long> <long name="proxy-Border">5</long>
<bool name="proxy-wxLEFT">1</bool> <bool name="proxy-wxLEFT">1</bool>
<bool name="proxy-wxRIGHT">0</bool>
<bool name="proxy-wxTOP">1</bool>
<bool name="proxy-wxBOTTOM">0</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">"wxSpinButton: ID_RICHTEXTFONTPAGE_SPINBUTTONS"</string>
<string name="type">"dialog-control-document"</string>
<string name="filename">""</string>
<string name="icon-name">"spinctrl"</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">"wbSpinButtonProxy"</string>
<string name="event-handler-0">"wxEVT_SCROLL_LINEUP|OnRichtextfontpageSpinbuttonsUp|NONE||wxRichTextFontPage"</string>
<string name="event-handler-1">"wxEVT_SCROLL_LINEDOWN|OnRichtextfontpageSpinbuttonsDown|NONE||wxRichTextFontPage"</string>
<string name="proxy-Id name">"ID_RICHTEXTFONTPAGE_SPINBUTTONS"</string>
<long name="proxy-Id value">10018</long>
<string name="proxy-Name">""</string>
<string name="proxy-Class">"wxSpinButton"</string>
<string name="proxy-Base class">"wxSpinButton"</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_fontSizeSpinButtons"</string>
<long name="proxy-Minimum value">0</long>
<long name="proxy-Maximum value">100</long>
<long name="proxy-Initial value">0</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">0</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-wxSP_HORIZONTAL">0</bool>
<bool name="proxy-wxSP_VERTICAL">1</bool>
<bool name="proxy-wxSP_ARROW_KEYS">0</bool>
<bool name="proxy-wxSP_WRAP">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">20</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">0</bool>
<bool name="proxy-wxRIGHT">1</bool> <bool name="proxy-wxRIGHT">1</bool>
<bool name="proxy-wxTOP">1</bool> <bool name="proxy-wxTOP">1</bool>
<bool name="proxy-wxBOTTOM">0</bool> <bool name="proxy-wxBOTTOM">0</bool>
@@ -801,6 +819,163 @@
<string name="proxy-Custom arguments">""</string> <string name="proxy-Custom arguments">""</string>
<string name="proxy-Custom ctor arguments">""</string> <string name="proxy-Custom ctor arguments">""</string>
</document> </document>
<document>
<string name="title">"wxChoice: ID_RICHTEXTFONTPAGE_SIZE_UNITS"</string>
<string name="type">"dialog-control-document"</string>
<string name="filename">""</string>
<string name="icon-name">"choice"</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">"wbChoiceProxy"</string>
<string name="event-handler-0">"wxEVT_COMMAND_CHOICE_SELECTED|OnRichtextfontpageSizeUnitsSelected|NONE||wxRichTextFontPage"</string>
<string name="proxy-Id name">"ID_RICHTEXTFONTPAGE_SIZE_UNITS"</string>
<long name="proxy-Id value">10017</long>
<string name="proxy-Name">""</string>
<string name="proxy-Class">"wxChoice"</string>
<string name="proxy-Base class">"wxChoice"</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_sizeUnitsCtrl"</string>
<string name="proxy-Strings">"pt|px"</string>
<string name="proxy-Initial value">"pt"</string>
<string name="proxy-Help text">"The font size units, points or pixels."</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">0</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-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">"Expand"</string>
<string name="proxy-AlignV">"Centre"</string>
<long name="proxy-Stretch factor">0</long>
<long name="proxy-Border">5</long>
<bool name="proxy-wxLEFT">0</bool>
<bool name="proxy-wxRIGHT">1</bool>
<bool name="proxy-wxTOP">1</bool>
<bool name="proxy-wxBOTTOM">0</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>
</document>
</document>
<document>
<string name="title">"wxBoxSizer H"</string>
<string name="type">"dialog-control-document"</string>
<string name="filename">""</string>
<string name="icon-name">"sizer"</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">"wbBoxSizerProxy"</string>
<string name="proxy-Orientation">"Horizontal"</string>
<string name="proxy-Member variable name">"m_fontListBoxParent"</string>
<string name="proxy-AlignH">"Expand"</string>
<string name="proxy-AlignV">"Centre"</string>
<long name="proxy-Stretch factor">0</long>
<long name="proxy-Border">5</long>
<bool name="proxy-wxLEFT">0</bool>
<bool name="proxy-wxRIGHT">0</bool>
<bool name="proxy-wxTOP">0</bool>
<bool name="proxy-wxBOTTOM">0</bool>
<bool name="proxy-wxSHAPED">0</bool>
<bool name="proxy-wxADJUST_MINSIZE">0</bool>
<bool name="proxy-wxFIXED_MINSIZE">0</bool>
<string name="proxy-Platform">"&lt;Any platform&gt;"</string>
<document>
<string name="title">"wxRichTextFontListBox: ID_RICHTEXTFONTPAGE_FACELISTBOX"</string>
<string name="type">"dialog-control-document"</string>
<string name="filename">""</string>
<string name="icon-name">"foreign"</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">"wbForeignCtrlProxy"</string>
<string name="proxy-Id name">"ID_RICHTEXTFONTPAGE_FACELISTBOX"</string>
<long name="proxy-Id value">10002</long>
<string name="proxy-Name">""</string>
<string name="proxy-Class">"wxRichTextFontListBox"</string>
<string name="proxy-Base class">"wxWindow"</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_faceListBox"</string>
<bool name="proxy-Create in situ">1</bool>
<string name="proxy-Help text">"Lists the available fonts."</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">0</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-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>
<bool name="proxy-wxCLIP_CHILDREN">0</bool>
<bool name="proxy-wxHSCROLL">0</bool>
<bool name="proxy-wxVSCROLL">0</bool>
<bool name="proxy-wxWS_EX_VALIDATE_RECURSIVELY">0</bool>
<string name="proxy-Custom styles">""</string>
<long name="proxy-X">-1</long>
<long name="proxy-Y">-1</long>
<long name="proxy-Width">200</long>
<long name="proxy-Height">100</long>
<string name="proxy-AlignH">"Expand"</string>
<string name="proxy-AlignV">"Centre"</string>
<long name="proxy-Stretch factor">1</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">1</bool>
<string name="proxy-Custom arguments">""</string>
<string name="proxy-Custom ctor arguments">""</string>
<string name="proxy-Event sources">""</string>
</document>
<document> <document>
<string name="title">"wxListBox: ID_RICHTEXTFONTPAGE_SIZELISTBOX"</string> <string name="title">"wxListBox: ID_RICHTEXTFONTPAGE_SIZELISTBOX"</string>
<string name="type">"dialog-control-document"</string> <string name="type">"dialog-control-document"</string>
@@ -810,7 +985,6 @@
<long name="owns-file">1</long> <long name="owns-file">1</long>
<long name="title-mode">0</long> <long name="title-mode">0</long>
<long name="locked">0</long> <long name="locked">0</long>
<string name="created">"2/10/2006"</string>
<string name="proxy-type">"wbListBoxProxy"</string> <string name="proxy-type">"wbListBoxProxy"</string>
<string name="event-handler-0">"wxEVT_COMMAND_LISTBOX_SELECTED|OnSizeListBoxSelected"</string> <string name="event-handler-0">"wxEVT_COMMAND_LISTBOX_SELECTED|OnSizeListBoxSelected"</string>
<string name="proxy-Id name">"ID_RICHTEXTFONTPAGE_SIZELISTBOX"</string> <string name="proxy-Id name">"ID_RICHTEXTFONTPAGE_SIZELISTBOX"</string>
@@ -863,8 +1037,8 @@
<long name="proxy-Width">50</long> <long name="proxy-Width">50</long>
<long name="proxy-Height">-1</long> <long name="proxy-Height">-1</long>
<string name="proxy-AlignH">"Centre"</string> <string name="proxy-AlignH">"Centre"</string>
<string name="proxy-AlignV">"Centre"</string> <string name="proxy-AlignV">"Expand"</string>
<long name="proxy-Stretch factor">1</long> <long name="proxy-Stretch factor">0</long>
<long name="proxy-Border">5</long> <long name="proxy-Border">5</long>
<bool name="proxy-wxLEFT">1</bool> <bool name="proxy-wxLEFT">1</bool>
<bool name="proxy-wxRIGHT">1</bool> <bool name="proxy-wxRIGHT">1</bool>
@@ -877,7 +1051,6 @@
<string name="proxy-Custom ctor arguments">""</string> <string name="proxy-Custom ctor arguments">""</string>
</document> </document>
</document> </document>
</document>
<document> <document>
<string name="title">"wxBoxSizer H"</string> <string name="title">"wxBoxSizer H"</string>
<string name="type">"dialog-control-document"</string> <string name="type">"dialog-control-document"</string>
@@ -14643,6 +14816,14 @@
<string name="proxy-type">"wbBoxSizerProxy"</string> <string name="proxy-type">"wbBoxSizerProxy"</string>
<string name="proxy-Orientation">"Vertical"</string> <string name="proxy-Orientation">"Vertical"</string>
<string name="proxy-Member variable name">""</string> <string name="proxy-Member variable name">""</string>
<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-wxSHAPED">0</bool>
<bool name="proxy-wxADJUST_MINSIZE">0</bool> <bool name="proxy-wxADJUST_MINSIZE">0</bool>
<bool name="proxy-wxFIXED_MINSIZE">0</bool> <bool name="proxy-wxFIXED_MINSIZE">0</bool>

View File

@@ -27,10 +27,17 @@ BEGIN_EVENT_TABLE( wxRichTextFontPage, wxRichTextDialogPage )
EVT_BUTTON( ID_RICHTEXTFONTPAGE_BGCOLOURCTRL, wxRichTextFontPage::OnColourClicked ) EVT_BUTTON( ID_RICHTEXTFONTPAGE_BGCOLOURCTRL, wxRichTextFontPage::OnColourClicked )
////@begin wxRichTextFontPage event table entries ////@begin wxRichTextFontPage event table entries
EVT_IDLE( wxRichTextFontPage::OnIdle )
EVT_TEXT( ID_RICHTEXTFONTPAGE_FACETEXTCTRL, wxRichTextFontPage::OnFaceTextCtrlUpdated ) EVT_TEXT( ID_RICHTEXTFONTPAGE_FACETEXTCTRL, wxRichTextFontPage::OnFaceTextCtrlUpdated )
EVT_TEXT( ID_RICHTEXTFONTPAGE_SIZETEXTCTRL, wxRichTextFontPage::OnSizeTextCtrlUpdated ) EVT_TEXT( ID_RICHTEXTFONTPAGE_SIZETEXTCTRL, wxRichTextFontPage::OnSizeTextCtrlUpdated )
EVT_SPIN_UP( ID_RICHTEXTFONTPAGE_SPINBUTTONS, wxRichTextFontPage::OnRichtextfontpageSpinbuttonsUp )
EVT_SPIN_DOWN( ID_RICHTEXTFONTPAGE_SPINBUTTONS, wxRichTextFontPage::OnRichtextfontpageSpinbuttonsDown )
EVT_CHOICE( ID_RICHTEXTFONTPAGE_SIZE_UNITS, wxRichTextFontPage::OnRichtextfontpageSizeUnitsSelected )
EVT_LISTBOX( ID_RICHTEXTFONTPAGE_SIZELISTBOX, wxRichTextFontPage::OnSizeListBoxSelected ) EVT_LISTBOX( ID_RICHTEXTFONTPAGE_SIZELISTBOX, wxRichTextFontPage::OnSizeListBoxSelected )
EVT_COMBOBOX( ID_RICHTEXTFONTPAGE_STYLECTRL, wxRichTextFontPage::OnStyleCtrlSelected ) EVT_COMBOBOX( ID_RICHTEXTFONTPAGE_STYLECTRL, wxRichTextFontPage::OnStyleCtrlSelected )
@@ -83,8 +90,11 @@ void wxRichTextFontPage::Init()
////@begin wxRichTextFontPage member initialisation ////@begin wxRichTextFontPage member initialisation
m_faceTextCtrl = NULL; m_faceTextCtrl = NULL;
m_faceListBox = NULL;
m_sizeTextCtrl = NULL; m_sizeTextCtrl = NULL;
m_fontSizeSpinButtons = NULL;
m_sizeUnitsCtrl = NULL;
m_fontListBoxParent = NULL;
m_faceListBox = NULL;
m_sizeListBox = NULL; m_sizeListBox = NULL;
m_styleCtrl = NULL; m_styleCtrl = NULL;
m_weightCtrl = NULL; m_weightCtrl = NULL;
@@ -150,131 +160,152 @@ void wxRichTextFontPage::CreateControls()
m_faceTextCtrl->SetToolTip(_("Type a font name.")); m_faceTextCtrl->SetToolTip(_("Type a font name."));
itemBoxSizer5->Add(m_faceTextCtrl, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5); itemBoxSizer5->Add(m_faceTextCtrl, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5);
m_faceListBox = new wxRichTextFontListBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_FACELISTBOX, wxDefaultPosition, wxSize(200, 100), 0 ); wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxVERTICAL);
m_faceListBox->SetHelpText(_("Lists the available fonts.")); itemBoxSizer4->Add(itemBoxSizer8, 0, wxGROW, 5);
if (wxRichTextFontPage::ShowToolTips())
m_faceListBox->SetToolTip(_("Lists the available fonts."));
itemBoxSizer5->Add(m_faceListBox, 1, wxGROW|wxALL|wxFIXED_MINSIZE, 5);
wxBoxSizer* itemBoxSizer9 = new wxBoxSizer(wxVERTICAL); wxStaticText* itemStaticText9 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Size:"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer4->Add(itemBoxSizer9, 0, wxGROW, 5); itemBoxSizer8->Add(itemStaticText9, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5);
wxStaticText* itemStaticText10 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Size:"), wxDefaultPosition, wxDefaultSize, 0 ); wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxHORIZONTAL);
itemBoxSizer9->Add(itemStaticText10, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); itemBoxSizer8->Add(itemBoxSizer10, 0, wxGROW, 5);
m_sizeTextCtrl = new wxTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SIZETEXTCTRL, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 ); m_sizeTextCtrl = new wxTextCtrl( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SIZETEXTCTRL, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 );
m_sizeTextCtrl->SetHelpText(_("Type a size in points.")); m_sizeTextCtrl->SetHelpText(_("Type a size in points."));
if (wxRichTextFontPage::ShowToolTips()) if (wxRichTextFontPage::ShowToolTips())
m_sizeTextCtrl->SetToolTip(_("Type a size in points.")); m_sizeTextCtrl->SetToolTip(_("Type a size in points."));
itemBoxSizer9->Add(m_sizeTextCtrl, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5); itemBoxSizer10->Add(m_sizeTextCtrl, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5);
m_fontSizeSpinButtons = new wxSpinButton( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SPINBUTTONS, wxDefaultPosition, wxSize(-1, 20), wxSP_VERTICAL );
m_fontSizeSpinButtons->SetRange(0, 100);
m_fontSizeSpinButtons->SetValue(0);
itemBoxSizer10->Add(m_fontSizeSpinButtons, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP, 5);
wxArrayString m_sizeUnitsCtrlStrings;
m_sizeUnitsCtrlStrings.Add(_("pt"));
m_sizeUnitsCtrlStrings.Add(_("px"));
m_sizeUnitsCtrl = new wxChoice( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SIZE_UNITS, wxDefaultPosition, wxDefaultSize, m_sizeUnitsCtrlStrings, 0 );
m_sizeUnitsCtrl->SetStringSelection(_("pt"));
m_sizeUnitsCtrl->SetHelpText(_("The font size units, points or pixels."));
if (wxRichTextFontPage::ShowToolTips())
m_sizeUnitsCtrl->SetToolTip(_("The font size units, points or pixels."));
itemBoxSizer10->Add(m_sizeUnitsCtrl, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP, 5);
m_fontListBoxParent = new wxBoxSizer(wxHORIZONTAL);
itemBoxSizer3->Add(m_fontListBoxParent, 0, wxGROW, 5);
m_faceListBox = new wxRichTextFontListBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_FACELISTBOX, wxDefaultPosition, wxSize(200, 100), 0 );
m_faceListBox->SetHelpText(_("Lists the available fonts."));
if (wxRichTextFontPage::ShowToolTips())
m_faceListBox->SetToolTip(_("Lists the available fonts."));
m_fontListBoxParent->Add(m_faceListBox, 1, wxALIGN_CENTER_VERTICAL|wxALL|wxFIXED_MINSIZE, 5);
wxArrayString m_sizeListBoxStrings; wxArrayString m_sizeListBoxStrings;
m_sizeListBox = new wxListBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SIZELISTBOX, wxDefaultPosition, wxSize(50, -1), m_sizeListBoxStrings, wxLB_SINGLE ); m_sizeListBox = new wxListBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SIZELISTBOX, wxDefaultPosition, wxSize(50, -1), m_sizeListBoxStrings, wxLB_SINGLE );
m_sizeListBox->SetHelpText(_("Lists font sizes in points.")); m_sizeListBox->SetHelpText(_("Lists font sizes in points."));
if (wxRichTextFontPage::ShowToolTips()) if (wxRichTextFontPage::ShowToolTips())
m_sizeListBox->SetToolTip(_("Lists font sizes in points.")); m_sizeListBox->SetToolTip(_("Lists font sizes in points."));
itemBoxSizer9->Add(m_sizeListBox, 1, wxALIGN_CENTER_HORIZONTAL|wxALL|wxFIXED_MINSIZE, 5); m_fontListBoxParent->Add(m_sizeListBox, 0, wxGROW|wxALL|wxFIXED_MINSIZE, 5);
wxBoxSizer* itemBoxSizer13 = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* itemBoxSizer17 = new wxBoxSizer(wxHORIZONTAL);
itemBoxSizer3->Add(itemBoxSizer13, 0, wxGROW, 5); itemBoxSizer3->Add(itemBoxSizer17, 0, wxGROW, 5);
wxBoxSizer* itemBoxSizer14 = new wxBoxSizer(wxVERTICAL); wxBoxSizer* itemBoxSizer18 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer13->Add(itemBoxSizer14, 0, wxGROW, 5); itemBoxSizer17->Add(itemBoxSizer18, 0, wxGROW, 5);
wxStaticText* itemStaticText15 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("Font st&yle:"), wxDefaultPosition, wxDefaultSize, 0 ); wxStaticText* itemStaticText19 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("Font st&yle:"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer14->Add(itemStaticText15, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); itemBoxSizer18->Add(itemStaticText19, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5);
wxArrayString m_styleCtrlStrings; wxArrayString m_styleCtrlStrings;
m_styleCtrl = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_STYLECTRL, wxEmptyString, wxDefaultPosition, wxSize(110, -1), m_styleCtrlStrings, wxCB_READONLY ); m_styleCtrl = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_STYLECTRL, wxEmptyString, wxDefaultPosition, wxSize(110, -1), m_styleCtrlStrings, wxCB_READONLY );
m_styleCtrl->SetHelpText(_("Select regular or italic style.")); m_styleCtrl->SetHelpText(_("Select regular or italic style."));
if (wxRichTextFontPage::ShowToolTips()) if (wxRichTextFontPage::ShowToolTips())
m_styleCtrl->SetToolTip(_("Select regular or italic style.")); m_styleCtrl->SetToolTip(_("Select regular or italic style."));
itemBoxSizer14->Add(m_styleCtrl, 0, wxGROW|wxALL, 5); itemBoxSizer18->Add(m_styleCtrl, 0, wxGROW|wxALL, 5);
wxBoxSizer* itemBoxSizer17 = new wxBoxSizer(wxVERTICAL); wxBoxSizer* itemBoxSizer21 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer13->Add(itemBoxSizer17, 0, wxGROW, 5); itemBoxSizer17->Add(itemBoxSizer21, 0, wxGROW, 5);
wxStaticText* itemStaticText18 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("Font &weight:"), wxDefaultPosition, wxDefaultSize, 0 ); wxStaticText* itemStaticText22 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("Font &weight:"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer17->Add(itemStaticText18, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); itemBoxSizer21->Add(itemStaticText22, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5);
wxArrayString m_weightCtrlStrings; wxArrayString m_weightCtrlStrings;
m_weightCtrl = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_WEIGHTCTRL, wxEmptyString, wxDefaultPosition, wxSize(110, -1), m_weightCtrlStrings, wxCB_READONLY ); m_weightCtrl = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_WEIGHTCTRL, wxEmptyString, wxDefaultPosition, wxSize(110, -1), m_weightCtrlStrings, wxCB_READONLY );
m_weightCtrl->SetHelpText(_("Select regular or bold.")); m_weightCtrl->SetHelpText(_("Select regular or bold."));
if (wxRichTextFontPage::ShowToolTips()) if (wxRichTextFontPage::ShowToolTips())
m_weightCtrl->SetToolTip(_("Select regular or bold.")); m_weightCtrl->SetToolTip(_("Select regular or bold."));
itemBoxSizer17->Add(m_weightCtrl, 0, wxGROW|wxALL, 5); itemBoxSizer21->Add(m_weightCtrl, 0, wxGROW|wxALL, 5);
wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxVERTICAL); wxBoxSizer* itemBoxSizer24 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer13->Add(itemBoxSizer20, 0, wxGROW, 5); itemBoxSizer17->Add(itemBoxSizer24, 0, wxGROW, 5);
wxStaticText* itemStaticText21 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Underlining:"), wxDefaultPosition, wxDefaultSize, 0 ); wxStaticText* itemStaticText25 = new wxStaticText( itemRichTextDialogPage1, wxID_STATIC, _("&Underlining:"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer20->Add(itemStaticText21, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); itemBoxSizer24->Add(itemStaticText25, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5);
wxArrayString m_underliningCtrlStrings; wxArrayString m_underliningCtrlStrings;
m_underliningCtrl = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL, wxEmptyString, wxDefaultPosition, wxSize(110, -1), m_underliningCtrlStrings, wxCB_READONLY ); m_underliningCtrl = new wxComboBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL, wxEmptyString, wxDefaultPosition, wxSize(110, -1), m_underliningCtrlStrings, wxCB_READONLY );
m_underliningCtrl->SetHelpText(_("Select underlining or no underlining.")); m_underliningCtrl->SetHelpText(_("Select underlining or no underlining."));
if (wxRichTextFontPage::ShowToolTips()) if (wxRichTextFontPage::ShowToolTips())
m_underliningCtrl->SetToolTip(_("Select underlining or no underlining.")); m_underliningCtrl->SetToolTip(_("Select underlining or no underlining."));
itemBoxSizer20->Add(m_underliningCtrl, 0, wxGROW|wxALL, 5); itemBoxSizer24->Add(m_underliningCtrl, 0, wxGROW|wxALL, 5);
itemBoxSizer13->Add(0, 0, 1, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5); itemBoxSizer17->Add(0, 0, 1, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5);
wxBoxSizer* itemBoxSizer24 = new wxBoxSizer(wxVERTICAL); wxBoxSizer* itemBoxSizer28 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer13->Add(itemBoxSizer24, 0, wxGROW, 5); itemBoxSizer17->Add(itemBoxSizer28, 0, wxGROW, 5);
m_textColourLabel = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_COLOURCTRL_LABEL, _("&Colour:"), wxDefaultPosition, wxDefaultSize, 0 ); m_textColourLabel = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_COLOURCTRL_LABEL, _("&Colour:"), wxDefaultPosition, wxDefaultSize, 0 );
m_textColourLabel->SetValue(false); m_textColourLabel->SetValue(false);
itemBoxSizer24->Add(m_textColourLabel, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxTOP, 5); itemBoxSizer28->Add(m_textColourLabel, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxTOP, 5);
m_colourCtrl = new wxRichTextColourSwatchCtrl( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_COLOURCTRL, wxDefaultPosition, wxSize(40, 20), 0 ); m_colourCtrl = new wxRichTextColourSwatchCtrl( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_COLOURCTRL, wxDefaultPosition, wxSize(40, 20), 0 );
m_colourCtrl->SetHelpText(_("Click to change the text colour.")); m_colourCtrl->SetHelpText(_("Click to change the text colour."));
if (wxRichTextFontPage::ShowToolTips()) if (wxRichTextFontPage::ShowToolTips())
m_colourCtrl->SetToolTip(_("Click to change the text colour.")); m_colourCtrl->SetToolTip(_("Click to change the text colour."));
itemBoxSizer24->Add(m_colourCtrl, 0, wxGROW|wxALL, 5); itemBoxSizer28->Add(m_colourCtrl, 0, wxGROW|wxALL, 5);
wxBoxSizer* itemBoxSizer27 = new wxBoxSizer(wxVERTICAL); wxBoxSizer* itemBoxSizer31 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer13->Add(itemBoxSizer27, 0, wxGROW, 5); itemBoxSizer17->Add(itemBoxSizer31, 0, wxGROW, 5);
m_bgColourLabel = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_BGCOLOURCTRL_LABEL, _("&Bg colour:"), wxDefaultPosition, wxDefaultSize, 0 ); m_bgColourLabel = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_BGCOLOURCTRL_LABEL, _("&Bg colour:"), wxDefaultPosition, wxDefaultSize, 0 );
m_bgColourLabel->SetValue(false); m_bgColourLabel->SetValue(false);
itemBoxSizer27->Add(m_bgColourLabel, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxTOP, 5); itemBoxSizer31->Add(m_bgColourLabel, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxTOP, 5);
m_bgColourCtrl = new wxRichTextColourSwatchCtrl( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_BGCOLOURCTRL, wxDefaultPosition, wxSize(40, 20), 0 ); m_bgColourCtrl = new wxRichTextColourSwatchCtrl( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_BGCOLOURCTRL, wxDefaultPosition, wxSize(40, 20), 0 );
m_bgColourCtrl->SetHelpText(_("Click to change the text background colour.")); m_bgColourCtrl->SetHelpText(_("Click to change the text background colour."));
if (wxRichTextFontPage::ShowToolTips()) if (wxRichTextFontPage::ShowToolTips())
m_bgColourCtrl->SetToolTip(_("Click to change the text background colour.")); m_bgColourCtrl->SetToolTip(_("Click to change the text background colour."));
itemBoxSizer27->Add(m_bgColourCtrl, 0, wxGROW|wxALL, 5); itemBoxSizer31->Add(m_bgColourCtrl, 0, wxGROW|wxALL, 5);
wxBoxSizer* itemBoxSizer30 = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* itemBoxSizer34 = new wxBoxSizer(wxHORIZONTAL);
itemBoxSizer3->Add(itemBoxSizer30, 0, wxGROW, 5); itemBoxSizer3->Add(itemBoxSizer34, 0, wxGROW, 5);
m_strikethroughCtrl = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_STRIKETHROUGHCTRL, _("&Strikethrough"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER ); m_strikethroughCtrl = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_STRIKETHROUGHCTRL, _("&Strikethrough"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER );
m_strikethroughCtrl->SetValue(false); m_strikethroughCtrl->SetValue(false);
m_strikethroughCtrl->SetHelpText(_("Check to show a line through the text.")); m_strikethroughCtrl->SetHelpText(_("Check to show a line through the text."));
if (wxRichTextFontPage::ShowToolTips()) if (wxRichTextFontPage::ShowToolTips())
m_strikethroughCtrl->SetToolTip(_("Check to show a line through the text.")); m_strikethroughCtrl->SetToolTip(_("Check to show a line through the text."));
itemBoxSizer30->Add(m_strikethroughCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); itemBoxSizer34->Add(m_strikethroughCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
m_capitalsCtrl = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_CAPSCTRL, _("Ca&pitals"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER ); m_capitalsCtrl = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_CAPSCTRL, _("Ca&pitals"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER );
m_capitalsCtrl->SetValue(false); m_capitalsCtrl->SetValue(false);
m_capitalsCtrl->SetHelpText(_("Check to show the text in capitals.")); m_capitalsCtrl->SetHelpText(_("Check to show the text in capitals."));
if (wxRichTextFontPage::ShowToolTips()) if (wxRichTextFontPage::ShowToolTips())
m_capitalsCtrl->SetToolTip(_("Check to show the text in capitals.")); m_capitalsCtrl->SetToolTip(_("Check to show the text in capitals."));
itemBoxSizer30->Add(m_capitalsCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); itemBoxSizer34->Add(m_capitalsCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
m_superscriptCtrl = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SUPERSCRIPT, _("Supe&rscript"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER ); m_superscriptCtrl = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SUPERSCRIPT, _("Supe&rscript"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER );
m_superscriptCtrl->SetValue(false); m_superscriptCtrl->SetValue(false);
m_superscriptCtrl->SetHelpText(_("Check to show the text in superscript.")); m_superscriptCtrl->SetHelpText(_("Check to show the text in superscript."));
if (wxRichTextFontPage::ShowToolTips()) if (wxRichTextFontPage::ShowToolTips())
m_superscriptCtrl->SetToolTip(_("Check to show the text in superscript.")); m_superscriptCtrl->SetToolTip(_("Check to show the text in superscript."));
itemBoxSizer30->Add(m_superscriptCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); itemBoxSizer34->Add(m_superscriptCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
m_subscriptCtrl = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SUBSCRIPT, _("Subscrip&t"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER ); m_subscriptCtrl = new wxCheckBox( itemRichTextDialogPage1, ID_RICHTEXTFONTPAGE_SUBSCRIPT, _("Subscrip&t"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER );
m_subscriptCtrl->SetValue(false); m_subscriptCtrl->SetValue(false);
m_subscriptCtrl->SetHelpText(_("Check to show the text in subscript.")); m_subscriptCtrl->SetHelpText(_("Check to show the text in subscript."));
if (wxRichTextFontPage::ShowToolTips()) if (wxRichTextFontPage::ShowToolTips())
m_subscriptCtrl->SetToolTip(_("Check to show the text in subscript.")); m_subscriptCtrl->SetToolTip(_("Check to show the text in subscript."));
itemBoxSizer30->Add(m_subscriptCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); itemBoxSizer34->Add(m_subscriptCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL, 5); itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL, 5);
@@ -332,7 +363,10 @@ bool wxRichTextFontPage::TransferDataFromWindow()
int sz = wxAtoi(strSize); int sz = wxAtoi(strSize);
if (sz > 0) if (sz > 0)
{ {
attr->SetFontSize(sz); if (m_sizeUnitsCtrl->GetSelection() == 0)
attr->SetFontPointSize(sz);
else
attr->SetFontPixelSize(sz);
} }
} }
else else
@@ -462,13 +496,21 @@ bool wxRichTextFontPage::TransferDataToWindow()
m_faceListBox->SetFaceNameSelection(wxEmptyString); m_faceListBox->SetFaceNameSelection(wxEmptyString);
} }
if (attr->HasFontSize()) if (attr->HasFontPointSize())
{ {
wxString strSize = wxString::Format(wxT("%d"), attr->GetFontSize()); wxString strSize = wxString::Format(wxT("%d"), attr->GetFontSize());
m_sizeTextCtrl->SetValue(strSize); m_sizeTextCtrl->SetValue(strSize);
m_sizeUnitsCtrl->SetSelection(0);
if (m_sizeListBox->FindString(strSize) != wxNOT_FOUND) if (m_sizeListBox->FindString(strSize) != wxNOT_FOUND)
m_sizeListBox->SetStringSelection(strSize); m_sizeListBox->SetStringSelection(strSize);
} }
else if (attr->HasFontPixelSize())
{
wxString strSize = wxString::Format(wxT("%d"), attr->GetFontSize());
m_sizeTextCtrl->SetValue(strSize);
m_sizeUnitsCtrl->SetSelection(1);
m_sizeListBox->SetSelection(wxNOT_FOUND);
}
else else
{ {
m_sizeTextCtrl->SetValue(wxEmptyString); m_sizeTextCtrl->SetValue(wxEmptyString);
@@ -642,7 +684,12 @@ void wxRichTextFontPage::UpdatePreview()
{ {
int sz = wxAtoi(strSize); int sz = wxAtoi(strSize);
if (sz > 0) if (sz > 0)
attr.SetFontSize(sz); {
if (m_sizeUnitsCtrl->GetSelection() == 1)
attr.SetFontPixelSize(sz);
else
attr.SetFontPointSize(sz);
}
} }
if (m_styleCtrl->GetSelection() != wxNOT_FOUND && m_styleCtrl->GetSelection() != 0) if (m_styleCtrl->GetSelection() != wxNOT_FOUND && m_styleCtrl->GetSelection() != 0)
@@ -938,3 +985,79 @@ void wxRichTextFontPage::OnRichtextfontpageSubscriptClick( wxCommandEvent& WXUNU
UpdatePreview(); UpdatePreview();
} }
/*!
* wxEVT_COMMAND_CHOICE_SELECTED event handler for ID_RICHTEXTFONTPAGE_SIZE_UNITS
*/
void wxRichTextFontPage::OnRichtextfontpageSizeUnitsSelected( wxCommandEvent& WXUNUSED(event) )
{
if (m_dontUpdate)
return;
UpdatePreview();
}
/*!
* wxEVT_COMMAND_SPINCTRL_UPDATED event handler for ID_RICHTEXTFONTPAGE_SPINBUTTONS
*/
void wxRichTextFontPage::OnRichtextfontpageSpinbuttonsUp( wxSpinEvent& WXUNUSED(event) )
{
wxString text = m_sizeTextCtrl->GetValue();
if (!text.IsEmpty())
{
int size = wxAtoi(text);
if (size > 0)
{
size ++;
m_sizeTextCtrl->SetValue(wxString::Format(wxT("%d"), size));
UpdatePreview();
}
}
}
/*!
* wxEVT_SCROLL_LINEDOWN event handler for ID_RICHTEXTFONTPAGE_SPINBUTTONS
*/
void wxRichTextFontPage::OnRichtextfontpageSpinbuttonsDown( wxSpinEvent& WXUNUSED(event) )
{
wxString text = m_sizeTextCtrl->GetValue();
if (!text.IsEmpty())
{
int size = wxAtoi(text);
if (size > 0)
{
size --;
m_sizeTextCtrl->SetValue(wxString::Format(wxT("%d"), size));
UpdatePreview();
}
}
}
/*!
* wxEVT_IDLE event handler for ID_RICHTEXTFONTPAGE
*/
void wxRichTextFontPage::OnIdle( wxIdleEvent& WXUNUSED(event) )
{
if (!m_sizeUnitsCtrl)
return;
if (m_sizeUnitsCtrl->GetSelection() == 1 && m_sizeListBox->IsShown())
{
m_fontListBoxParent->Show(m_sizeListBox, false);
Layout();
}
else if (m_sizeUnitsCtrl->GetSelection() == 0 && !m_sizeListBox->IsShown())
{
m_fontListBoxParent->Show(m_sizeListBox, true);
Layout();
}
if (!wxRichTextFormattingDialog::GetDialog(this)->HasOption(wxRichTextFormattingDialog::Option_AllowPixelFontSize) &&
m_sizeUnitsCtrl->IsEnabled())
{
m_sizeUnitsCtrl->Disable();
}
}

View File

@@ -97,6 +97,7 @@ void wxRichTextFormattingDialog::Init()
m_styleDefinition = NULL; m_styleDefinition = NULL;
m_styleSheet = NULL; m_styleSheet = NULL;
m_object = NULL; m_object = NULL;
m_options = 0;
} }
wxRichTextFormattingDialog::~wxRichTextFormattingDialog() wxRichTextFormattingDialog::~wxRichTextFormattingDialog()

View File

@@ -775,7 +775,7 @@ wxString wxRichTextStyleListBox::CreateHTML(wxRichTextStyleDefinition* def) cons
name.Find(wxT("default")) != wxNOT_FOUND || name.Find(defaultTranslated) != wxNOT_FOUND) name.Find(wxT("default")) != wxNOT_FOUND || name.Find(defaultTranslated) != wxNOT_FOUND)
{ {
wxRichTextAttr attr2(d->GetStyleMergedWithBase(GetStyleSheet())); wxRichTextAttr attr2(d->GetStyleMergedWithBase(GetStyleSheet()));
if (attr2.HasFontSize()) if (attr2.HasFontPointSize())
{ {
stdFontSize = attr2.GetFontSize(); stdFontSize = attr2.GetFontSize();
break; break;
@@ -796,7 +796,7 @@ wxString wxRichTextStyleListBox::CreateHTML(wxRichTextStyleDefinition* def) cons
if (d) if (d)
{ {
wxRichTextAttr attr2(d->GetStyleMergedWithBase(GetStyleSheet())); wxRichTextAttr attr2(d->GetStyleMergedWithBase(GetStyleSheet()));
if (attr2.HasFontSize()) if (attr2.HasFontPointSize())
{ {
if (attr2.GetFontSize() <= (int) maxSize) if (attr2.GetFontSize() <= (int) maxSize)
sizes[attr2.GetFontSize()] ++; sizes[attr2.GetFontSize()] ++;
@@ -816,7 +816,7 @@ wxString wxRichTextStyleListBox::CreateHTML(wxRichTextStyleDefinition* def) cons
if (stdFontSize == 0) if (stdFontSize == 0)
stdFontSize = 12; stdFontSize = 12;
int thisFontSize = ((attr.GetFlags() & wxTEXT_ATTR_FONT_SIZE) != 0) ? attr.GetFontSize() : stdFontSize; int thisFontSize = attr.HasFontPointSize() ? attr.GetFontSize() : stdFontSize;
if (thisFontSize < stdFontSize) if (thisFontSize < stdFontSize)
size --; size --;

View File

@@ -1092,8 +1092,10 @@ wxString wxRichTextXMLHandler::AddAttributes(const wxRichTextAttr& attr, bool is
if (attr.HasBackgroundColour() && attr.GetBackgroundColour().IsOk()) if (attr.HasBackgroundColour() && attr.GetBackgroundColour().IsOk())
AddAttribute(str, wxT("bgcolor"), attr.GetBackgroundColour()); AddAttribute(str, wxT("bgcolor"), attr.GetBackgroundColour());
if (attr.HasFontSize()) if (attr.HasFontPointSize())
AddAttribute(str, wxT("fontsize"), attr.GetFontSize()); AddAttribute(str, wxT("fontpointsize"), attr.GetFontSize());
else if (attr.HasFontPixelSize())
AddAttribute(str, wxT("fontpixelsize"), attr.GetFontSize());
if (attr.HasFontFamily()) if (attr.HasFontFamily())
AddAttribute(str, wxT("fontfamily"), attr.GetFontFamily()); AddAttribute(str, wxT("fontfamily"), attr.GetFontFamily());
@@ -1395,8 +1397,10 @@ bool wxRichTextXMLHandler::AddAttributes(wxXmlNode* node, wxRichTextAttr& attr,
if (attr.HasBackgroundColour() && attr.GetBackgroundColour().IsOk()) if (attr.HasBackgroundColour() && attr.GetBackgroundColour().IsOk())
node->AddAttribute(wxT("bgcolor"), MakeString(attr.GetBackgroundColour())); node->AddAttribute(wxT("bgcolor"), MakeString(attr.GetBackgroundColour()));
if (attr.HasFontSize()) if (attr.HasFontPointSize())
node->AddAttribute(wxT("fontsize"), MakeString(attr.GetFontSize())); node->AddAttribute(wxT("fontpointsize"), MakeString(attr.GetFontSize()));
else if (attr.HasFontPixelSize())
node->AddAttribute(wxT("fontpixelsize"), MakeString(attr.GetFontSize()));
if (attr.HasFontFamily()) if (attr.HasFontFamily())
node->AddAttribute(wxT("fontfamily"), MakeString(attr.GetFontFamily())); node->AddAttribute(wxT("fontfamily"), MakeString(attr.GetFontFamily()));
if (attr.HasFontItalic()) if (attr.HasFontItalic())
@@ -1683,10 +1687,15 @@ bool wxRichTextXMLHandler::ImportStyle(wxRichTextAttr& attr, wxXmlNode* node, bo
if (!value.empty()) if (!value.empty())
attr.SetFontStyle((wxFontStyle)wxAtoi(value)); attr.SetFontStyle((wxFontStyle)wxAtoi(value));
} }
else if (name == wxT("fontsize")) else if (name == wxT("fontsize") || name == wxT("fontpointsize"))
{ {
if (!value.empty()) if (!value.empty())
attr.SetFontSize(wxAtoi(value)); attr.SetFontPointSize(wxAtoi(value));
}
else if (name == wxT("fontpixelsize"))
{
if (!value.empty())
attr.SetFontPixelSize(wxAtoi(value));
} }
else if (name == wxT("fontweight")) else if (name == wxT("fontweight"))
{ {