]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/textctrl.h
wxApp::CreateConfig() only defined #if USE_WXCONFIG
[wxWidgets.git] / include / wx / msw / textctrl.h
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$
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef __TEXTCTRLH__
13 #define __TEXTCTRLH__
14
15 #ifdef __GNUG__
16 #pragma interface "textctrl.h"
17 #endif
18
19 #include "wx/control.h"
20
21 #if USE_IOSTREAMH
22 #include <iostream.h>
23 #else
24 #include <iostream>
25 #endif
26
27 WXDLLEXPORT_DATA(extern const char*) wxTextCtrlNameStr;
28 WXDLLEXPORT_DATA(extern const char*) wxEmptyString;
29
30 // Single-line text item
31 class 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
37 #if (defined(__BORLANDC__) && !defined(__WIN32__)) || defined(__MWERKS__) || defined(_WINDLL) || defined(WXUSINGDLL) || defined(WXMAKINGDLL)
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)
47
48 protected:
49 wxString fileName;
50 public:
51 wxTextCtrl(void);
52 inline wxTextCtrl(wxWindow *parent, const wxWindowID id,
53 const wxString& value = wxEmptyString,
54 const wxPoint& pos = wxDefaultPosition,
55 const wxSize& size = wxDefaultSize, const long style = 0,
56 const wxValidator& validator = wxDefaultValidator,
57 const wxString& name = wxTextCtrlNameStr)
58 #ifndef NO_TEXT_WINDOW_STREAM
59 :streambuf()
60 #endif
61 {
62 Create(parent, id, value, pos, size, style, validator, name);
63 }
64
65 bool Create(wxWindow *parent, const wxWindowID id,
66 const wxString& value = wxEmptyString,
67 const wxPoint& pos = wxDefaultPosition,
68 const wxSize& size = wxDefaultSize, const long style = 0,
69 const wxValidator& validator = wxDefaultValidator,
70 const wxString& name = wxTextCtrlNameStr);
71
72 virtual wxString GetValue(void) const ;
73 virtual void SetValue(const wxString& value);
74 virtual void SetSize(const int x, const int y, const int width, const int height, const int sizeFlags = wxSIZE_AUTO);
75
76 // Clipboard operations
77 virtual void Copy(void);
78 virtual void Cut(void);
79 virtual void Paste(void);
80
81 virtual void SetInsertionPoint(const long pos);
82 virtual void SetInsertionPointEnd(void);
83 virtual long GetInsertionPoint(void) const ;
84 virtual long GetLastPosition(void) const ;
85 virtual void Replace(const long from, const long to, const wxString& value);
86 virtual void Remove(const long from, const long to);
87 virtual void SetSelection(const long from, const long to);
88
89 virtual void Command(wxCommandEvent& event);
90
91 virtual void SetEditable(const bool editable);
92
93 #ifndef NO_TEXT_WINDOW_STREAM
94 int overflow(int i);
95 int sync(void);
96 int underflow(void);
97 #endif
98
99 void OnDropFiles(wxDropFilesEvent& event);
100
101 wxTextCtrl& operator<<(const wxString& s);
102 wxTextCtrl& operator<<(const int i);
103 wxTextCtrl& operator<<(const long i);
104 wxTextCtrl& operator<<(const float f);
105 wxTextCtrl& operator<<(const double d);
106 wxTextCtrl& operator<<(const char c);
107
108 virtual bool LoadFile(const wxString& file);
109 virtual bool SaveFile(const wxString& file);
110 virtual void WriteText(const wxString& text);
111 virtual void DiscardEdits(void);
112 virtual bool IsModified(void) const;
113
114 #if WXWIN_COMPATIBILITY
115 inline bool Modified(void) const { return IsModified(); }
116 #endif
117
118 virtual long XYToPosition(const long x, const long y) const ;
119 virtual void PositionToXY(const long pos, long *x, long *y) const ;
120 virtual void ShowPosition(const long pos);
121 virtual int GetLineLength(const long lineNo) const ;
122 virtual wxString GetLineText(const long lineNo) const ;
123 virtual int GetNumberOfLines(void) const ;
124 virtual void Clear(void);
125
126 // Process special keys e.g. 'enter' and process as if it were a command, if required
127 void OnChar(wxKeyEvent& event);
128
129 void OnEraseBackground(wxEraseEvent& event);
130
131 // Implementation
132 virtual bool MSWCommand(const WXUINT param, const WXWORD id);
133 inline bool IsRich(void) { return m_isRich; }
134 inline void SetRichEdit(const bool isRich) { m_isRich = isRich; }
135 virtual WXHBRUSH OnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor,
136 WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
137
138 virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
139 virtual void AdoptAttributesFromHWND(void);
140 virtual void SetupColours(void);
141
142 protected:
143 bool m_isRich; // Are we using rich text edit to implement this?
144
145 DECLARE_EVENT_TABLE()
146 };
147
148 #endif
149 // __TEXTCTRLH__