2004-03-23 12:35:05 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2006-01-17 22:40:58 -05:00
|
|
|
// Name: wx/mac/carbon/textctrl.h
|
2004-03-23 12:35:05 -05:00
|
|
|
// Purpose: wxTextCtrl class
|
|
|
|
// Author: Stefan Csomor
|
|
|
|
// Modified by:
|
|
|
|
// Created: 1998-01-01
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Stefan Csomor
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
2004-03-23 12:35:05 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_TEXTCTRL_H_
|
|
|
|
#define _WX_TEXTCTRL_H_
|
|
|
|
|
2005-04-03 12:38:14 -04:00
|
|
|
#if wxUSE_SYSTEM_OPTIONS
|
2006-01-17 22:40:58 -05:00
|
|
|
// set this to 'true' if you want to use the 'classic' MLTE-based implementation
|
|
|
|
// instead of the HIView-based implementation in 10.3 and upwards, the former
|
|
|
|
// has more features (backgrounds etc.), but may show redraw artefacts and other
|
|
|
|
// problems depending on your usage; hence, the default is 'false'.
|
2006-01-09 23:10:57 -05:00
|
|
|
#define wxMAC_TEXTCONTROL_USE_MLTE wxT("mac.textcontrol-use-mlte")
|
2005-04-03 12:38:14 -04:00
|
|
|
#endif
|
|
|
|
|
2004-03-23 12:35:05 -05:00
|
|
|
#include "wx/control.h"
|
2006-01-17 22:40:58 -05:00
|
|
|
#include "wx/textctrl.h"
|
2004-03-23 12:35:05 -05:00
|
|
|
|
2006-01-17 22:40:58 -05:00
|
|
|
class wxMacTextControl;
|
2004-03-23 12:35:05 -05:00
|
|
|
|
2004-07-11 12:19:18 -04:00
|
|
|
|
2004-03-23 12:35:05 -05:00
|
|
|
class WXDLLEXPORT wxTextCtrl: public wxTextCtrlBase
|
|
|
|
{
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxTextCtrl)
|
2005-01-19 11:25:34 -05:00
|
|
|
|
2004-03-23 12:35:05 -05:00
|
|
|
public:
|
2006-01-17 22:40:58 -05:00
|
|
|
wxTextCtrl()
|
|
|
|
{ Init(); }
|
|
|
|
|
|
|
|
wxTextCtrl(wxWindow *parent,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxString& value = wxEmptyString,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = wxTextCtrlNameStr)
|
2006-01-09 23:10:57 -05:00
|
|
|
{
|
|
|
|
Init();
|
|
|
|
Create(parent, id, value, pos, size, style, validator, name);
|
|
|
|
}
|
2004-03-23 12:35:05 -05:00
|
|
|
|
2006-09-05 16:47:48 -04:00
|
|
|
virtual ~wxTextCtrl();
|
2005-01-19 11:25:34 -05:00
|
|
|
|
2006-01-17 22:40:58 -05:00
|
|
|
bool Create(wxWindow *parent,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxString& value = wxEmptyString,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = wxTextCtrlNameStr);
|
2005-01-19 11:25:34 -05:00
|
|
|
|
2006-01-09 23:10:57 -05:00
|
|
|
// accessors
|
|
|
|
// ---------
|
2006-01-17 22:40:58 -05:00
|
|
|
virtual wxString GetValue() const;
|
2006-01-09 23:10:57 -05:00
|
|
|
virtual void SetValue(const wxString& value);
|
2004-03-23 12:35:05 -05:00
|
|
|
|
2006-01-09 23:10:57 -05:00
|
|
|
virtual int GetLineLength(long lineNo) const;
|
|
|
|
virtual wxString GetLineText(long lineNo) const;
|
|
|
|
virtual int GetNumberOfLines() const;
|
2004-03-23 12:35:05 -05:00
|
|
|
|
2006-01-09 23:10:57 -05:00
|
|
|
virtual bool IsModified() const;
|
|
|
|
virtual bool IsEditable() const;
|
2004-03-23 12:35:05 -05:00
|
|
|
|
2006-01-09 23:10:57 -05:00
|
|
|
// If the return values from and to are the same, there is no selection.
|
|
|
|
virtual void GetSelection(long* from, long* to) const;
|
2004-03-23 12:35:05 -05:00
|
|
|
|
2006-01-09 23:10:57 -05:00
|
|
|
// operations
|
|
|
|
// ----------
|
2004-03-23 12:35:05 -05:00
|
|
|
|
2006-01-09 23:10:57 -05:00
|
|
|
// editing
|
|
|
|
virtual void Clear();
|
|
|
|
virtual void Replace(long from, long to, const wxString& value);
|
|
|
|
virtual void Remove(long from, long to);
|
2004-03-23 12:35:05 -05:00
|
|
|
|
2006-01-09 23:10:57 -05:00
|
|
|
// load the controls contents from the file
|
|
|
|
virtual bool LoadFile(const wxString& file);
|
2004-03-23 12:35:05 -05:00
|
|
|
|
2006-01-09 23:10:57 -05:00
|
|
|
// sets/clears the dirty flag
|
|
|
|
virtual void MarkDirty();
|
|
|
|
virtual void DiscardEdits();
|
2004-03-23 12:35:05 -05:00
|
|
|
|
2006-01-09 23:10:57 -05:00
|
|
|
// set the max number of characters which may be entered
|
|
|
|
// in a single line text control
|
2006-01-17 22:40:58 -05:00
|
|
|
virtual void SetMaxLength(unsigned long len);
|
2004-03-23 12:35:05 -05:00
|
|
|
|
2006-01-09 23:10:57 -05:00
|
|
|
// text control under some platforms supports the text styles: these
|
2006-01-17 22:40:58 -05:00
|
|
|
// methods apply the given text style to the given selection or to
|
2006-01-09 23:10:57 -05:00
|
|
|
// set/get the style which will be used for all appended text
|
2006-01-17 22:40:58 -05:00
|
|
|
virtual bool SetFont( const wxFont &font );
|
2006-01-09 23:10:57 -05:00
|
|
|
virtual bool SetStyle(long start, long end, const wxTextAttr& style);
|
|
|
|
virtual bool SetDefaultStyle(const wxTextAttr& style);
|
2004-03-23 12:35:05 -05:00
|
|
|
|
2006-01-09 23:10:57 -05:00
|
|
|
// writing text inserts it at the current position;
|
|
|
|
// appending always inserts it at the end
|
|
|
|
virtual void WriteText(const wxString& text);
|
|
|
|
virtual void AppendText(const wxString& text);
|
2004-03-23 12:35:05 -05:00
|
|
|
|
2006-01-17 22:40:58 -05:00
|
|
|
// translate between the position (which is just an index into the textctrl
|
2006-01-09 23:10:57 -05:00
|
|
|
// considering all its contents as a single strings) and (x, y) coordinates
|
|
|
|
// which represent column and line.
|
|
|
|
virtual long XYToPosition(long x, long y) const;
|
|
|
|
virtual bool PositionToXY(long pos, long *x, long *y) const;
|
2004-03-23 12:35:05 -05:00
|
|
|
|
2006-01-09 23:10:57 -05:00
|
|
|
virtual void ShowPosition(long pos);
|
2004-03-23 12:35:05 -05:00
|
|
|
|
2006-01-09 23:10:57 -05:00
|
|
|
// Clipboard operations
|
|
|
|
virtual void Copy();
|
|
|
|
virtual void Cut();
|
|
|
|
virtual void Paste();
|
2005-01-19 11:25:34 -05:00
|
|
|
|
2006-01-09 23:10:57 -05:00
|
|
|
virtual bool CanCopy() const;
|
|
|
|
virtual bool CanCut() const;
|
|
|
|
virtual bool CanPaste() const;
|
2004-03-23 12:35:05 -05:00
|
|
|
|
2006-01-09 23:10:57 -05:00
|
|
|
// Undo/redo
|
|
|
|
virtual void Undo();
|
|
|
|
virtual void Redo();
|
2004-03-23 12:35:05 -05:00
|
|
|
|
2006-01-09 23:10:57 -05:00
|
|
|
virtual bool CanUndo() const;
|
|
|
|
virtual bool CanRedo() const;
|
2004-03-23 12:35:05 -05:00
|
|
|
|
2006-01-09 23:10:57 -05:00
|
|
|
// Insertion point
|
|
|
|
virtual void SetInsertionPoint(long pos);
|
|
|
|
virtual void SetInsertionPointEnd();
|
|
|
|
virtual long GetInsertionPoint() const;
|
|
|
|
virtual wxTextPos GetLastPosition() const;
|
2004-03-23 12:35:05 -05:00
|
|
|
|
2006-01-09 23:10:57 -05:00
|
|
|
virtual void SetSelection(long from, long to);
|
|
|
|
virtual void SetEditable(bool editable);
|
2004-03-23 12:35:05 -05:00
|
|
|
|
|
|
|
// Implementation
|
|
|
|
// --------------
|
|
|
|
virtual void Command(wxCommandEvent& event);
|
|
|
|
|
|
|
|
virtual bool AcceptsFocus() const;
|
|
|
|
|
|
|
|
// callbacks
|
|
|
|
void OnDropFiles(wxDropFilesEvent& event);
|
|
|
|
void OnChar(wxKeyEvent& event); // Process 'enter' if required
|
|
|
|
|
|
|
|
void OnCut(wxCommandEvent& event);
|
|
|
|
void OnCopy(wxCommandEvent& event);
|
|
|
|
void OnPaste(wxCommandEvent& event);
|
|
|
|
void OnUndo(wxCommandEvent& event);
|
|
|
|
void OnRedo(wxCommandEvent& event);
|
2005-07-25 02:09:18 -04:00
|
|
|
void OnDelete(wxCommandEvent& event);
|
|
|
|
void OnSelectAll(wxCommandEvent& event);
|
2006-01-17 22:40:58 -05:00
|
|
|
|
2004-03-23 12:35:05 -05:00
|
|
|
void OnUpdateCut(wxUpdateUIEvent& event);
|
|
|
|
void OnUpdateCopy(wxUpdateUIEvent& event);
|
|
|
|
void OnUpdatePaste(wxUpdateUIEvent& event);
|
|
|
|
void OnUpdateUndo(wxUpdateUIEvent& event);
|
|
|
|
void OnUpdateRedo(wxUpdateUIEvent& event);
|
2005-07-25 02:09:18 -04:00
|
|
|
void OnUpdateDelete(wxUpdateUIEvent& event);
|
|
|
|
void OnUpdateSelectAll(wxUpdateUIEvent& event);
|
2005-01-19 11:25:34 -05:00
|
|
|
|
2006-01-17 22:40:58 -05:00
|
|
|
void OnEraseBackground(wxEraseEvent& event);
|
2005-07-25 02:09:18 -04:00
|
|
|
void OnContextMenu(wxContextMenuEvent& event);
|
2004-03-23 12:35:05 -05:00
|
|
|
|
2006-01-17 22:40:58 -05:00
|
|
|
virtual bool MacCanFocus() const
|
|
|
|
{ return true; }
|
2006-01-09 23:10:57 -05:00
|
|
|
|
2006-01-17 22:40:58 -05:00
|
|
|
virtual bool MacSetupCursor( const wxPoint& pt );
|
2004-03-23 12:35:05 -05:00
|
|
|
|
2006-01-17 22:40:58 -05:00
|
|
|
virtual void MacVisibilityChanged();
|
|
|
|
virtual void MacEnabledStateChanged();
|
|
|
|
virtual void MacSuperChangedPosition();
|
2006-01-09 23:10:57 -05:00
|
|
|
|
2005-02-12 06:34:05 -05:00
|
|
|
#ifndef __WXMAC_OSX__
|
2006-01-17 22:40:58 -05:00
|
|
|
virtual void MacControlUserPaneDrawProc(wxInt16 part);
|
|
|
|
virtual wxInt16 MacControlUserPaneHitTestProc(wxInt16 x, wxInt16 y);
|
|
|
|
virtual wxInt16 MacControlUserPaneTrackingProc(wxInt16 x, wxInt16 y, void* actionProc);
|
|
|
|
virtual void MacControlUserPaneIdleProc();
|
|
|
|
virtual wxInt16 MacControlUserPaneKeyDownProc(wxInt16 keyCode, wxInt16 charCode, wxInt16 modifiers);
|
|
|
|
virtual void MacControlUserPaneActivateProc(bool activating);
|
|
|
|
virtual wxInt16 MacControlUserPaneFocusProc(wxInt16 action);
|
|
|
|
virtual void MacControlUserPaneBackgroundProc(void* info);
|
2005-02-12 06:34:05 -05:00
|
|
|
#endif
|
2004-03-23 12:35:05 -05:00
|
|
|
|
2006-01-17 22:40:58 -05:00
|
|
|
wxMacTextControl * GetPeer() const
|
|
|
|
{ return (wxMacTextControl*) m_peer; }
|
2006-04-08 09:00:13 -04:00
|
|
|
|
2004-03-23 12:35:05 -05:00
|
|
|
protected:
|
|
|
|
// common part of all ctors
|
|
|
|
void Init();
|
|
|
|
|
2006-01-09 23:10:57 -05:00
|
|
|
virtual wxSize DoGetBestSize() const;
|
2004-03-23 12:35:05 -05:00
|
|
|
|
2006-01-17 22:40:58 -05:00
|
|
|
bool m_editable;
|
2004-03-23 12:35:05 -05:00
|
|
|
|
2006-01-09 23:10:57 -05:00
|
|
|
// flag is set to true when the user edits the controls contents
|
|
|
|
bool m_dirty;
|
2004-03-23 12:35:05 -05:00
|
|
|
|
2004-03-27 02:15:02 -05:00
|
|
|
// need to make this public because of the current implementation via callbacks
|
2006-01-17 22:40:58 -05:00
|
|
|
unsigned long m_maxLength;
|
2006-04-08 09:00:13 -04:00
|
|
|
|
|
|
|
bool GetTriggerOnSetValue() const
|
|
|
|
{
|
|
|
|
return m_triggerOnSetValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetTriggerOnSetValue(bool trigger)
|
|
|
|
{
|
|
|
|
m_triggerOnSetValue = trigger;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool m_triggerOnSetValue ;
|
2006-01-09 23:10:57 -05:00
|
|
|
|
2004-03-27 02:15:02 -05:00
|
|
|
private :
|
2005-07-25 02:09:18 -04:00
|
|
|
wxMenu *m_privateContextMenu;
|
|
|
|
|
2004-03-23 12:35:05 -05:00
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
};
|
|
|
|
|
2006-01-17 22:40:58 -05:00
|
|
|
#endif // _WX_TEXTCTRL_H_
|