]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/textctrl.h
Update for bitmap, image on scaling, transparancy,
[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
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_TEXTCTRL_H_
13 #define _WX_TEXTCTRL_H_
14
15 #ifdef __GNUG__
16 #pragma interface "textctrl.h"
17 #endif
18
19 #include "wx/control.h"
20
21 #if wxUSE_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 public:
49 // creation
50 // --------
51 wxTextCtrl();
52 inline wxTextCtrl(wxWindow *parent, wxWindowID id,
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)
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, wxWindowID id,
66 const wxString& value = wxEmptyString,
67 const wxPoint& pos = wxDefaultPosition,
68 const wxSize& size = wxDefaultSize, long style = 0,
69 const wxValidator& validator = wxDefaultValidator,
70 const wxString& name = wxTextCtrlNameStr);
71
72 // accessors
73 // ---------
74 virtual wxString GetValue() const ;
75 virtual void SetValue(const wxString& value);
76
77 virtual int GetLineLength(long lineNo) const;
78 virtual wxString GetLineText(long lineNo) const;
79 virtual int GetNumberOfLines() const;
80
81 // operations
82 // ----------
83 virtual void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
84 void SetSize(const wxRect& rect, int sizeFlags = wxSIZE_AUTO)
85 { wxWindow::SetSize(rect, sizeFlags); }
86 void SetSize(const wxSize& size) { wxWindow::SetSize(size); }
87
88 // Clipboard operations
89 virtual void Copy();
90 virtual void Cut();
91 virtual void Paste();
92
93 virtual void SetInsertionPoint(long pos);
94 virtual void SetInsertionPointEnd();
95 virtual long GetInsertionPoint() const ;
96 virtual long GetLastPosition() const ;
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);
100 virtual void SetEditable(bool editable);
101
102 // streambuf implementation
103 #ifndef NO_TEXT_WINDOW_STREAM
104 int overflow(int i);
105 int sync();
106 int underflow();
107 #endif
108
109 wxTextCtrl& operator<<(const wxString& s);
110 wxTextCtrl& operator<<(int i);
111 wxTextCtrl& operator<<(long i);
112 wxTextCtrl& operator<<(float f);
113 wxTextCtrl& operator<<(double d);
114 wxTextCtrl& operator<<(const char c);
115
116 virtual bool LoadFile(const wxString& file);
117 virtual bool SaveFile(const wxString& file);
118 virtual void WriteText(const wxString& text);
119 virtual void DiscardEdits();
120 virtual bool IsModified() const;
121
122 #if WXWIN_COMPATIBILITY
123 inline bool Modified() const { return IsModified(); }
124 #endif
125
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);
129 virtual void Clear();
130
131 // callbacks
132 // ---------
133 void OnDropFiles(wxDropFilesEvent& event);
134 void OnChar(wxKeyEvent& event); // Process 'enter' if required
135 void OnEraseBackground(wxEraseEvent& event);
136
137 // Implementation
138 // --------------
139 virtual void Command(wxCommandEvent& event);
140 virtual bool MSWCommand(WXUINT param, WXWORD id);
141 inline bool IsRich() const { return m_isRich; }
142 inline void SetRichEdit(bool isRich) { m_isRich = isRich; }
143 virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
144 WXUINT message, WXWPARAM wParam,
145 WXLPARAM lParam);
146
147 virtual void AdoptAttributesFromHWND();
148 virtual void SetupColours();
149 virtual long MSWGetDlgCode();
150
151 protected:
152 bool m_isRich; // Are we using rich text edit to implement this?
153 wxString m_fileName;
154
155 DECLARE_EVENT_TABLE()
156 };
157
158 #endif
159 // _WX_TEXTCTRL_H_