1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
|
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/cocoa/private/textimpl.h
// Purpose: textcontrol implementation classes that have to be exposed
// Author: Stefan Csomor
// Modified by:
// Created: 03/02/99
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_OSX_COCOA_PRIVATE_TEXTIMPL_H_
#define _WX_OSX_COCOA_PRIVATE_TEXTIMPL_H_
#include "wx/combobox.h"
#include "wx/osx/private.h"
@class wxTextEntryFormatter;
class wxNSTextBase : public wxWidgetCocoaImpl, public wxTextWidgetImpl
{
public :
wxNSTextBase( wxTextCtrl *text, WXWidget w )
: wxWidgetCocoaImpl(text, w),
wxTextWidgetImpl(text)
{
}
wxNSTextBase( wxWindow *wxPeer, wxTextEntry *entry, WXWidget w )
: wxWidgetCocoaImpl(wxPeer, w),
wxTextWidgetImpl(entry)
{
}
virtual ~wxNSTextBase() { }
virtual bool ShouldHandleKeyNavigation(const wxKeyEvent &event) const wxOVERRIDE;
virtual void SetInitialLabel(const wxString& WXUNUSED(title), wxFontEncoding WXUNUSED(encoding)) wxOVERRIDE
{
// Don't do anything here, text controls don't have any label and
// setting it would overwrite the string value set when creating it.
}
};
// implementation exposed, so that search control can pull it
class wxNSTextFieldControl : public wxNSTextBase
{
public :
// wxNSTextFieldControl must always be associated with a wxTextEntry. If
// it's associated with a wxTextCtrl then we can get the associated entry
// from it but otherwise the second ctor should be used to explicitly pass
// us the entry.
wxNSTextFieldControl( wxTextCtrl *text, WXWidget w );
wxNSTextFieldControl( wxWindow *wxPeer, wxTextEntry *entry, WXWidget w );
virtual ~wxNSTextFieldControl();
virtual bool CanClipMaxLength() const wxOVERRIDE { return true; }
virtual void SetMaxLength(unsigned long len) wxOVERRIDE;
virtual bool CanForceUpper() wxOVERRIDE { return true; }
virtual void ForceUpper() wxOVERRIDE;
virtual wxString GetStringValue() const wxOVERRIDE ;
virtual void SetStringValue( const wxString &str) wxOVERRIDE ;
virtual void Copy() wxOVERRIDE ;
virtual void Cut() wxOVERRIDE ;
virtual void Paste() wxOVERRIDE ;
virtual bool CanPaste() const wxOVERRIDE ;
virtual void SetEditable(bool editable) wxOVERRIDE ;
virtual long GetLastPosition() const wxOVERRIDE;
virtual void GetSelection( long* from, long* to) const wxOVERRIDE ;
virtual void SetSelection( long from , long to ) wxOVERRIDE;
virtual bool PositionToXY(long pos, long *x, long *y) const wxOVERRIDE;
virtual long XYToPosition(long x, long y) const wxOVERRIDE;
virtual void ShowPosition(long pos) wxOVERRIDE;
virtual void WriteText(const wxString& str) wxOVERRIDE ;
virtual bool HasOwnContextMenu() const wxOVERRIDE { return true; }
virtual bool SetHint(const wxString& hint) wxOVERRIDE;
virtual void SetJustification() wxOVERRIDE;
virtual void controlAction(WXWidget slf, void* _cmd, void *sender) wxOVERRIDE;
virtual bool becomeFirstResponder(WXWidget slf, void *_cmd) wxOVERRIDE;
virtual bool resignFirstResponder(WXWidget slf, void *_cmd) wxOVERRIDE;
virtual void EnableNewLineReplacement(bool enable) wxOVERRIDE;
virtual bool GetNewLineReplacement() wxOVERRIDE;
virtual void SetInternalSelection( long from , long to );
virtual void UpdateInternalSelectionFromEditor( wxNSTextFieldEditor* editor);
virtual wxSize GetBestSize() const wxOVERRIDE;
protected :
NSTextField* m_textField;
long m_selStart;
long m_selEnd;
private:
// Common part of both ctors.
void Init(WXWidget w);
// Get our formatter, creating it if necessary.
wxTextEntryFormatter* GetFormatter();
};
class wxNSTextViewControl : public wxNSTextBase
{
public:
wxNSTextViewControl( wxTextCtrl *wxPeer, WXWidget w, long style );
virtual ~wxNSTextViewControl();
virtual void insertText(NSString* text, WXWidget slf, void *_cmd) wxOVERRIDE;
virtual wxString GetStringValue() const wxOVERRIDE ;
virtual void SetStringValue( const wxString &str) wxOVERRIDE ;
virtual void Copy() wxOVERRIDE ;
virtual void Cut() wxOVERRIDE ;
virtual void Paste() wxOVERRIDE ;
virtual bool CanPaste() const wxOVERRIDE ;
virtual void SetEditable(bool editable) wxOVERRIDE ;
virtual long GetLastPosition() const wxOVERRIDE;
virtual void GetSelection( long* from, long* to) const wxOVERRIDE ;
virtual void SetSelection( long from , long to ) wxOVERRIDE;
virtual bool PositionToXY(long pos, long *x, long *y) const wxOVERRIDE;
virtual long XYToPosition(long x, long y) const wxOVERRIDE;
virtual void ShowPosition(long pos) wxOVERRIDE;
virtual void WriteText(const wxString& str) wxOVERRIDE ;
virtual void SetFont(const wxFont & font) wxOVERRIDE;
virtual bool GetStyle(long position, wxTextAttr& style) wxOVERRIDE;
virtual void SetStyle(long start, long end, const wxTextAttr& style) wxOVERRIDE;
virtual bool CanFocus() const wxOVERRIDE;
virtual bool HasOwnContextMenu() const wxOVERRIDE { return true; }
#if wxUSE_SPELLCHECK
virtual void CheckSpelling(const wxTextProofOptions& options) wxOVERRIDE;
virtual wxTextProofOptions GetCheckingOptions() const wxOVERRIDE;
#endif // wxUSE_SPELLCHECK
virtual void EnableAutomaticQuoteSubstitution(bool enable) wxOVERRIDE;
virtual void EnableAutomaticDashSubstitution(bool enable) wxOVERRIDE;
virtual void EnableNewLineReplacement(bool enable) wxOVERRIDE;
virtual bool GetNewLineReplacement() wxOVERRIDE;
virtual wxSize GetBestSize() const wxOVERRIDE;
virtual void SetJustification() wxOVERRIDE;
virtual void controlTextDidChange() wxOVERRIDE;
virtual bool CanUndo() const wxOVERRIDE;
virtual void Undo() wxOVERRIDE;
virtual bool CanRedo() const wxOVERRIDE;
virtual void Redo() wxOVERRIDE;
virtual void EmptyUndoBuffer() wxOVERRIDE;
protected:
void DoUpdateTextStyle();
NSScrollView* m_scrollView;
NSTextView* m_textView;
bool m_useCharWrapping;
NSUndoManager* m_undoManager;
};
class wxNSComboBoxControl : public wxNSTextFieldControl, public wxComboWidgetImpl
{
public :
wxNSComboBoxControl( wxComboBox *wxPeer, WXWidget w );
virtual ~wxNSComboBoxControl();
virtual int GetSelectedItem() const;
virtual void SetSelectedItem(int item);
virtual int GetNumberOfItems() const;
virtual void InsertItem(int pos, const wxString& item);
virtual void RemoveItem(int pos);
virtual void Clear();
virtual wxString GetStringAtIndex(int pos) const;
virtual int FindString(const wxString& text) const;
virtual void Popup();
virtual void Dismiss();
virtual void SetEditable(bool editable);
virtual void mouseEvent(WX_NSEvent event, WXWidget slf, void *_cmd);
private:
NSComboBox* m_comboBox;
};
#endif // _WX_OSX_COCOA_PRIVATE_TEXTIMPL_H_
|