]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/textctrl.h
no message
[wxWidgets.git] / include / wx / msw / textctrl.h
CommitLineData
2bda0e17
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: textctrl.h
3// Purpose: wxTextCtrl class
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
bbcdf8bc
JS
8// Copyright: (c) Julian Smart
9// Licence: wxWindows licence
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
bbcdf8bc
JS
12#ifndef _WX_TEXTCTRL_H_
13#define _WX_TEXTCTRL_H_
2bda0e17
KB
14
15#ifdef __GNUG__
16#pragma interface "textctrl.h"
17#endif
18
19#include "wx/control.h"
20
47d67540 21#if wxUSE_IOSTREAMH
2bda0e17
KB
22#include <iostream.h>
23#else
24#include <iostream>
25#endif
26
27WXDLLEXPORT_DATA(extern const char*) wxTextCtrlNameStr;
28WXDLLEXPORT_DATA(extern const char*) wxEmptyString;
29
30// Single-line text item
31class WXDLLEXPORT wxTextCtrl: public wxControl
32
33// 16-bit Borland 4.0 doesn't seem to allow multiple inheritance with wxWindow and streambuf:
34// it complains about deriving a huge class from the huge class streambuf. !!
35// Also, can't use streambuf if making or using a DLL :-(
36
3f1af920 37#if (defined(__BORLANDC__)) || defined(__MWERKS__) || defined(_WINDLL) || defined(WXUSINGDLL) || defined(WXMAKINGDLL)
2bda0e17
KB
38#define NO_TEXT_WINDOW_STREAM
39#endif
40
41#ifndef NO_TEXT_WINDOW_STREAM
42, public streambuf
43#endif
44
45{
46 DECLARE_DYNAMIC_CLASS(wxTextCtrl)
ae29de83
VZ
47
48public:
49 // creation
50 // --------
51 wxTextCtrl();
debe6624 52 inline wxTextCtrl(wxWindow *parent, wxWindowID id,
ae29de83
VZ
53 const wxString& value = wxEmptyString,
54 const wxPoint& pos = wxDefaultPosition,
55 const wxSize& size = wxDefaultSize, long style = 0,
56 const wxValidator& validator = wxDefaultValidator,
57 const wxString& name = wxTextCtrlNameStr)
2bda0e17 58#ifndef NO_TEXT_WINDOW_STREAM
ae29de83 59 :streambuf()
2bda0e17
KB
60#endif
61 {
ae29de83 62 Create(parent, id, value, pos, size, style, validator, name);
2bda0e17 63 }
ae29de83 64
debe6624 65 bool Create(wxWindow *parent, wxWindowID id,
ae29de83
VZ
66 const wxString& value = wxEmptyString,
67 const wxPoint& pos = wxDefaultPosition,
2004484f 68 const wxSize& size = wxDefaultSize, long style = wxTE_PROCESS_TAB,
ae29de83
VZ
69 const wxValidator& validator = wxDefaultValidator,
70 const wxString& name = wxTextCtrlNameStr);
71
72 // accessors
73 // ---------
74 virtual wxString GetValue() const ;
2bda0e17 75 virtual void SetValue(const wxString& value);
2bda0e17 76
ae29de83
VZ
77 virtual int GetLineLength(long lineNo) const;
78 virtual wxString GetLineText(long lineNo) const;
79 virtual int GetNumberOfLines() const;
2bda0e17 80
ae29de83
VZ
81 // operations
82 // ----------
83 virtual void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
4fabb575
JS
84 void SetSize(const wxRect& rect, int sizeFlags = wxSIZE_AUTO)
85 { wxWindow::SetSize(rect, sizeFlags); }
86 void SetSize(const wxSize& size) { wxWindow::SetSize(size); }
ae29de83
VZ
87
88 // Clipboard operations
89 virtual void Copy();
90 virtual void Cut();
91 virtual void Paste();
92
debe6624 93 virtual void SetInsertionPoint(long pos);
ae29de83
VZ
94 virtual void SetInsertionPointEnd();
95 virtual long GetInsertionPoint() const ;
96 virtual long GetLastPosition() const ;
debe6624
JS
97 virtual void Replace(long from, long to, const wxString& value);
98 virtual void Remove(long from, long to);
99 virtual void SetSelection(long from, long to);
debe6624 100 virtual void SetEditable(bool editable);
ae29de83
VZ
101
102 // streambuf implementation
2bda0e17
KB
103#ifndef NO_TEXT_WINDOW_STREAM
104 int overflow(int i);
ae29de83
VZ
105 int sync();
106 int underflow();
2bda0e17 107#endif
ae29de83 108
2bda0e17 109 wxTextCtrl& operator<<(const wxString& s);
debe6624
JS
110 wxTextCtrl& operator<<(int i);
111 wxTextCtrl& operator<<(long i);
112 wxTextCtrl& operator<<(float f);
113 wxTextCtrl& operator<<(double d);
2bda0e17 114 wxTextCtrl& operator<<(const char c);
ae29de83 115
2bda0e17
KB
116 virtual bool LoadFile(const wxString& file);
117 virtual bool SaveFile(const wxString& file);
118 virtual void WriteText(const wxString& text);
ae29de83
VZ
119 virtual void DiscardEdits();
120 virtual bool IsModified() const;
121
2bda0e17 122#if WXWIN_COMPATIBILITY
ae29de83 123 inline bool Modified() const { return IsModified(); }
2bda0e17 124#endif
ae29de83 125
debe6624
JS
126 virtual long XYToPosition(long x, long y) const ;
127 virtual void PositionToXY(long pos, long *x, long *y) const ;
128 virtual void ShowPosition(long pos);
ae29de83
VZ
129 virtual void Clear();
130
131 // callbacks
132 // ---------
133 void OnDropFiles(wxDropFilesEvent& event);
134 void OnChar(wxKeyEvent& event); // Process 'enter' if required
2bda0e17 135 void OnEraseBackground(wxEraseEvent& event);
ae29de83 136
2bda0e17 137 // Implementation
ae29de83
VZ
138 // --------------
139 virtual void Command(wxCommandEvent& event);
debe6624 140 virtual bool MSWCommand(WXUINT param, WXWORD id);
ae29de83 141 inline bool IsRich() const { return m_isRich; }
debe6624
JS
142 inline void SetRichEdit(bool isRich) { m_isRich = isRich; }
143 virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
ae29de83
VZ
144 WXUINT message, WXWPARAM wParam,
145 WXLPARAM lParam);
146
147 virtual void AdoptAttributesFromHWND();
148 virtual void SetupColours();
149 virtual long MSWGetDlgCode();
150
2bda0e17 151protected:
ae29de83 152 bool m_isRich; // Are we using rich text edit to implement this?
b823f5a1 153 wxString m_fileName;
ae29de83
VZ
154
155 DECLARE_EVENT_TABLE()
2bda0e17
KB
156};
157
158#endif
bbcdf8bc 159 // _WX_TEXTCTRL_H_