+
+#if wxUSE_COMBOCTRL
+
+/*!
+ * Style drop-down for a wxComboCtrl
+ */
+
+class wxRichTextStyleComboPopup : public wxRichTextStyleListBox, public wxComboPopup
+{
+public:
+ virtual void Init()
+ {
+ m_itemHere = -1; // hot item in list
+ m_value = -1;
+ }
+
+ virtual bool Create( wxWindow* parent );
+
+ virtual wxWindow *GetControl() { return this; }
+
+ virtual void SetStringValue( const wxString& s );
+
+ virtual wxString GetStringValue() const;
+
+ /// Can we set the selection based on the editor caret position?
+ // virtual bool CanAutoSetSelection() { return ((m_combo == NULL) || !m_combo->IsPopupShown()); }
+ virtual bool CanAutoSetSelection() { return false; }
+
+ //
+ // Popup event handlers
+ //
+
+ // Mouse hot-tracking
+ void OnMouseMove(wxMouseEvent& event);
+
+ // On mouse left, set the value and close the popup
+ void OnMouseClick(wxMouseEvent& WXUNUSED(event));
+
+protected:
+
+ int m_itemHere; // hot item in popup
+ int m_value;
+
+private:
+ DECLARE_EVENT_TABLE()
+};
+
+/*!
+ * wxRichTextStyleComboCtrl
+ * A combo for applying styles.
+ */
+
+class WXDLLIMPEXP_RICHTEXT wxRichTextStyleComboCtrl: public wxComboCtrl
+{
+ DECLARE_CLASS(wxRichTextStyleComboCtrl)
+ DECLARE_EVENT_TABLE()
+
+public:
+ wxRichTextStyleComboCtrl()
+ {
+ Init();
+ }
+
+ wxRichTextStyleComboCtrl(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize, long style = wxCB_READONLY)
+ {
+ Init();
+ Create(parent, id, pos, size, style);
+ }
+
+ virtual ~wxRichTextStyleComboCtrl() {}
+
+ void Init()
+ {
+ m_stylePopup = NULL;
+ }
+
+ bool Create(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize, long style = 0);
+
+ /// Updates the list
+ void UpdateStyles() { m_stylePopup->UpdateStyles(); }
+
+ /// Associates the control with a style sheet
+ void SetStyleSheet(wxRichTextStyleSheet* styleSheet) { m_stylePopup->SetStyleSheet(styleSheet); }
+ wxRichTextStyleSheet* GetStyleSheet() const { return m_stylePopup->GetStyleSheet(); }
+
+ /// Associates the control with a wxRichTextCtrl
+ void SetRichTextCtrl(wxRichTextCtrl* ctrl) { m_stylePopup->SetRichTextCtrl(ctrl); }
+ wxRichTextCtrl* GetRichTextCtrl() const { return m_stylePopup->GetRichTextCtrl(); }
+
+ /// Gets the style popup
+ wxRichTextStyleComboPopup* GetStylePopup() const { return m_stylePopup; }
+
+ /// Auto-select from style under caret in idle time
+ void OnIdle(wxIdleEvent& event);
+
+protected:
+ wxRichTextStyleComboPopup* m_stylePopup;
+};
+
+#endif
+ // wxUSE_COMBOCTRL
+