wxTEXT_ATTR_PARAGRAPH = \
(wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_TABS|\
wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER|wxTEXT_ATTR_LINE_SPACING|\
- wxTEXT_ATTR_BULLET|wxTEXT_ATTR_PARAGRAPH_STYLE_NAME|wxTEXT_ATTR_LIST_STYLE_NAME|wxTEXT_ATTR_OUTLINE_LEVEL),
+ wxTEXT_ATTR_BULLET|wxTEXT_ATTR_PARAGRAPH_STYLE_NAME|wxTEXT_ATTR_LIST_STYLE_NAME|wxTEXT_ATTR_OUTLINE_LEVEL|wxTEXT_ATTR_PAGE_BREAK),
wxTEXT_ATTR_ALL = (wxTEXT_ATTR_CHARACTER|wxTEXT_ATTR_PARAGRAPH)
};
// Equality test
bool operator== (const wxTextAttr& attr) const;
- // Partial equality test taking flags into account
- bool EqPartial(const wxTextAttr& attr, int flags) const;
+ // Partial equality test
+ bool EqPartial(const wxTextAttr& attr) const;
// Get attributes from font.
bool GetFontAttributes(const wxFont& font, int flags = wxTEXT_ATTR_FONT);
int GetOutlineLevel() const { return m_outlineLevel; }
// accessors
- bool HasTextColour() const { return m_colText.Ok() && HasFlag(wxTEXT_ATTR_TEXT_COLOUR) ; }
- bool HasBackgroundColour() const { return m_colBack.Ok() && HasFlag(wxTEXT_ATTR_BACKGROUND_COLOUR) ; }
+ bool HasTextColour() const { return m_colText.IsOk() && HasFlag(wxTEXT_ATTR_TEXT_COLOUR) ; }
+ bool HasBackgroundColour() const { return m_colBack.IsOk() && HasFlag(wxTEXT_ATTR_BACKGROUND_COLOUR) ; }
bool HasAlignment() const { return (m_textAlignment != wxTEXT_ALIGNMENT_DEFAULT) && HasFlag(wxTEXT_ATTR_ALIGNMENT) ; }
bool HasTabs() const { return HasFlag(wxTEXT_ATTR_TABS) ; }
bool HasLeftIndent() const { return HasFlag(wxTEXT_ATTR_LEFT_INDENT); }
bool HasOutlineLevel() const { return HasFlag(wxTEXT_ATTR_OUTLINE_LEVEL); }
bool HasFlag(long flag) const { return (m_flags & flag) != 0; }
+ void RemoveFlag(long flag) { m_flags &= ~flag; }
+ void AddFlag(long flag) { m_flags |= flag; }
// Is this a character style?
bool IsCharacterStyle() const { return HasFlag(wxTEXT_ATTR_CHARACTER); }
return GetFlags() == 0;
}
- // Merges the given attributes. Does not affect 'this'. If compareWith
+ // Merges the given attributes. If compareWith
// is non-NULL, then it will be used to mask out those attributes that are the same in style
// and compareWith, for situations where we don't want to explicitly set inherited attributes.
bool Apply(const wxTextAttr& style, const wxTextAttr* compareWith = NULL);
-
+
// merges the attributes of the base and the overlay objects and returns
// the result; the parameter attributes take precedence
//
virtual long XYToPosition(long x, long y) const = 0;
virtual bool PositionToXY(long pos, long *x, long *y) const = 0;
+ // translate the given position (which is just an index in the text control)
+ // to client coordinates
+ wxPoint PositionToCoords(long pos) const;
+
+
virtual void ShowPosition(long pos) = 0;
// find the character at position given in pixels
virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt,
wxTextCoord *col,
wxTextCoord *row) const;
+ virtual wxString GetValue() const = 0;
+ virtual void SetValue(const wxString& value) = 0;
protected:
// implementation of loading/saving
- virtual bool DoLoadFile(const wxString& file, int fileType) = 0;
- virtual bool DoSaveFile(const wxString& file, int fileType) = 0;
+ virtual bool DoLoadFile(const wxString& file, int fileType);
+ virtual bool DoSaveFile(const wxString& file, int fileType);
+
+ // Return true if the given position is valid, i.e. positive and less than
+ // the last position.
+ virtual bool IsValidPosition(long pos) const = 0;
+ // Default stub implementation of PositionToCoords() always returns
+ // wxDefaultPosition.
+ virtual wxPoint DoPositionToCoords(long pos) const;
// the name of the last file loaded with LoadFile() which will be used by
// SaveFile() by default
public:
wxTextCtrlIface() { }
+ // wxTextAreaBase overrides
+ virtual wxString GetValue() const
+ {
+ return wxTextEntryBase::GetValue();
+ }
+ virtual void SetValue(const wxString& value)
+ {
+ wxTextEntryBase::SetValue(value);
+ }
+
+protected:
+ virtual bool IsValidPosition(long pos) const
+ {
+ return pos >= 0 && pos <= GetLastPosition();
+ }
+
private:
wxDECLARE_NO_COPY_CLASS(wxTextCtrlIface);
};
virtual bool EmulateKeyPress(const wxKeyEvent& event);
- // generate the wxEVT_COMMAND_TEXT_UPDATED event, like SetValue() does and
- // return true if the event was processed
- static bool SendTextUpdatedEvent(wxWindow *win);
- bool SendTextUpdatedEvent() { return SendTextUpdatedEvent(this); }
-
// do the window-specific processing after processing the update event
virtual void DoUpdateWindowUI(wxUpdateUIEvent& event);
virtual bool GetStyle(long position, wxTextAttr& style);
virtual bool SetDefaultStyle(const wxTextAttr& style);
+ // wxTextAreaBase overrides
+ virtual wxString GetValue() const
+ {
+ return wxTextEntry::GetValue();
+ }
+ virtual void SetValue(const wxString& value)
+ {
+ wxTextEntry::SetValue(value);
+ }
+
+ // wxWindow overrides
+ virtual wxVisualAttributes GetDefaultAttributes() const
+ {
+ return GetClassDefaultAttributes(GetWindowVariant());
+ }
+
+ static wxVisualAttributes
+ GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL)
+ {
+ return GetCompositeControlsDefaultAttributes(variant);
+ }
+
protected:
// override streambuf method
#if wxHAS_TEXT_WINDOW_STREAM
virtual bool DoLoadFile(const wxString& file, int fileType);
virtual bool DoSaveFile(const wxString& file, int fileType);
-private:
+ // Another wxTextAreaBase override.
+ virtual bool IsValidPosition(long pos) const
+ {
+ return pos >= 0 && pos <= GetLastPosition();
+ }
+
// implement the wxTextEntry pure virtual method
virtual wxWindow *GetEditableWindow() { return this; }