| 1 | ///////////////////////////////////////////////////////////////////////////// |
| 2 | // Name: wx/osx/cocoa/private/textimpl.h |
| 3 | // Purpose: textcontrol implementation classes that have to be exposed |
| 4 | // Author: Stefan Csomor |
| 5 | // Modified by: |
| 6 | // Created: 03/02/99 |
| 7 | // Copyright: (c) Stefan Csomor |
| 8 | // Licence: wxWindows licence |
| 9 | ///////////////////////////////////////////////////////////////////////////// |
| 10 | |
| 11 | #ifndef _WX_OSX_COCOA_PRIVATE_TEXTIMPL_H_ |
| 12 | #define _WX_OSX_COCOA_PRIVATE_TEXTIMPL_H_ |
| 13 | |
| 14 | #include "wx/combobox.h" |
| 15 | #include "wx/osx/private.h" |
| 16 | |
| 17 | // implementation exposed, so that search control can pull it |
| 18 | |
| 19 | class wxNSTextFieldControl : public wxWidgetCocoaImpl, public wxTextWidgetImpl |
| 20 | { |
| 21 | public : |
| 22 | // wxNSTextFieldControl must always be associated with a wxTextEntry. If |
| 23 | // it's associated with a wxTextCtrl then we can get the associated entry |
| 24 | // from it but otherwise the second ctor should be used to explicitly pass |
| 25 | // us the entry. |
| 26 | wxNSTextFieldControl( wxTextCtrl *text, WXWidget w ); |
| 27 | wxNSTextFieldControl( wxWindow *wxPeer, wxTextEntry *entry, WXWidget w ); |
| 28 | virtual ~wxNSTextFieldControl(); |
| 29 | |
| 30 | virtual bool CanClipMaxLength() const { return true; } |
| 31 | virtual void SetMaxLength(unsigned long len); |
| 32 | |
| 33 | virtual wxString GetStringValue() const ; |
| 34 | virtual void SetStringValue( const wxString &str) ; |
| 35 | virtual void Copy() ; |
| 36 | virtual void Cut() ; |
| 37 | virtual void Paste() ; |
| 38 | virtual bool CanPaste() const ; |
| 39 | virtual void SetEditable(bool editable) ; |
| 40 | virtual void GetSelection( long* from, long* to) const ; |
| 41 | virtual void SetSelection( long from , long to ); |
| 42 | virtual void WriteText(const wxString& str) ; |
| 43 | virtual bool HasOwnContextMenu() const { return true; } |
| 44 | virtual bool SetHint(const wxString& hint); |
| 45 | |
| 46 | virtual void controlAction(WXWidget slf, void* _cmd, void *sender); |
| 47 | virtual bool becomeFirstResponder(WXWidget slf, void *_cmd); |
| 48 | virtual bool resignFirstResponder(WXWidget slf, void *_cmd); |
| 49 | |
| 50 | virtual void SetInternalSelection( long from , long to ); |
| 51 | |
| 52 | protected : |
| 53 | NSTextField* m_textField; |
| 54 | long m_selStart; |
| 55 | long m_selEnd; |
| 56 | |
| 57 | private: |
| 58 | // Common part of both ctors. |
| 59 | void Init(WXWidget w); |
| 60 | }; |
| 61 | |
| 62 | class wxNSTextViewControl : public wxWidgetCocoaImpl, public wxTextWidgetImpl |
| 63 | { |
| 64 | public: |
| 65 | wxNSTextViewControl( wxTextCtrl *wxPeer, WXWidget w ); |
| 66 | virtual ~wxNSTextViewControl(); |
| 67 | |
| 68 | virtual wxString GetStringValue() const ; |
| 69 | virtual void SetStringValue( const wxString &str) ; |
| 70 | virtual void Copy() ; |
| 71 | virtual void Cut() ; |
| 72 | virtual void Paste() ; |
| 73 | virtual bool CanPaste() const ; |
| 74 | virtual void SetEditable(bool editable) ; |
| 75 | virtual void GetSelection( long* from, long* to) const ; |
| 76 | virtual void SetSelection( long from , long to ); |
| 77 | virtual void WriteText(const wxString& str) ; |
| 78 | virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true ); |
| 79 | |
| 80 | virtual bool GetStyle(long position, wxTextAttr& style); |
| 81 | virtual void SetStyle(long start, long end, const wxTextAttr& style); |
| 82 | |
| 83 | virtual bool CanFocus() const; |
| 84 | |
| 85 | virtual bool HasOwnContextMenu() const { return true; } |
| 86 | |
| 87 | virtual void CheckSpelling(bool check); |
| 88 | virtual wxSize GetBestSize() const; |
| 89 | |
| 90 | protected: |
| 91 | NSScrollView* m_scrollView; |
| 92 | NSTextView* m_textView; |
| 93 | }; |
| 94 | |
| 95 | class wxNSComboBoxControl : public wxNSTextFieldControl, public wxComboWidgetImpl |
| 96 | { |
| 97 | public : |
| 98 | wxNSComboBoxControl( wxComboBox *wxPeer, WXWidget w ); |
| 99 | virtual ~wxNSComboBoxControl(); |
| 100 | |
| 101 | virtual int GetSelectedItem() const; |
| 102 | virtual void SetSelectedItem(int item); |
| 103 | |
| 104 | virtual int GetNumberOfItems() const; |
| 105 | |
| 106 | virtual void InsertItem(int pos, const wxString& item); |
| 107 | virtual void RemoveItem(int pos); |
| 108 | |
| 109 | virtual void Clear(); |
| 110 | |
| 111 | virtual wxString GetStringAtIndex(int pos) const; |
| 112 | |
| 113 | virtual int FindString(const wxString& text) const; |
| 114 | virtual void Popup(); |
| 115 | virtual void Dismiss(); |
| 116 | |
| 117 | virtual void SetEditable(bool editable); |
| 118 | |
| 119 | virtual void mouseEvent(WX_NSEvent event, WXWidget slf, void *_cmd); |
| 120 | |
| 121 | private: |
| 122 | NSComboBox* m_comboBox; |
| 123 | }; |
| 124 | |
| 125 | #endif // _WX_OSX_COCOA_PRIVATE_TEXTIMPL_H_ |