]> git.saurik.com Git - wxWidgets.git/blob - src/palmos/textctrl.cpp
adding explicit log.h include
[wxWidgets.git] / src / palmos / textctrl.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/textctrl.cpp
3 // Purpose: wxTextCtrl
4 // Author: William Osborne - minimal working wxPalmOS port
5 // Modified by:
6 // Created: 10/13/04
7 // RCS-ID: $Id$
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
22
23 #ifdef __BORLANDC__
24 #pragma hdrstop
25 #endif
26
27 #if wxUSE_TEXTCTRL
28
29 #include "wx/textctrl.h"
30
31 #ifndef WX_PRECOMP
32 #include "wx/settings.h"
33 #include "wx/brush.h"
34 #include "wx/utils.h"
35 #include "wx/intl.h"
36 #include "wx/log.h"
37 #include "wx/app.h"
38 #include "wx/menu.h"
39 #include "wx/module.h"
40 #endif
41
42 #if wxUSE_CLIPBOARD
43 #include "wx/clipbrd.h"
44 #endif
45
46 #include "wx/textfile.h"
47
48 #include <string.h>
49
50 #if wxUSE_RICHEDIT
51
52 #include "wx/palmos/missing.h"
53
54 #endif // wxUSE_RICHEDIT
55
56 // ----------------------------------------------------------------------------
57 // private classes
58 // ----------------------------------------------------------------------------
59
60 #if wxUSE_RICHEDIT
61
62 // this module initializes RichEdit DLL(s) if needed
63 class wxRichEditModule : public wxModule
64 {
65 public:
66 virtual bool OnInit();
67 virtual void OnExit();
68
69 // load the richedit DLL of at least of required version
70 static bool Load(int version = 1);
71
72 private:
73 // the handles to richedit 1.0 and 2.0 (or 3.0) DLLs
74 static HINSTANCE ms_hRichEdit[2];
75
76 DECLARE_DYNAMIC_CLASS(wxRichEditModule)
77 };
78
79 HINSTANCE wxRichEditModule::ms_hRichEdit[2] = { NULL, NULL };
80
81 IMPLEMENT_DYNAMIC_CLASS(wxRichEditModule, wxModule)
82
83 #endif // wxUSE_RICHEDIT
84
85 // ----------------------------------------------------------------------------
86 // event tables and other macros
87 // ----------------------------------------------------------------------------
88
89 #if wxUSE_EXTENDED_RTTI
90 WX_DEFINE_FLAGS( wxTextCtrlStyle )
91
92 wxBEGIN_FLAGS( wxTextCtrlStyle )
93 // new style border flags, we put them first to
94 // use them for streaming out
95 wxFLAGS_MEMBER(wxBORDER_SIMPLE)
96 wxFLAGS_MEMBER(wxBORDER_SUNKEN)
97 wxFLAGS_MEMBER(wxBORDER_DOUBLE)
98 wxFLAGS_MEMBER(wxBORDER_RAISED)
99 wxFLAGS_MEMBER(wxBORDER_STATIC)
100 wxFLAGS_MEMBER(wxBORDER_NONE)
101
102 // old style border flags
103 wxFLAGS_MEMBER(wxSIMPLE_BORDER)
104 wxFLAGS_MEMBER(wxSUNKEN_BORDER)
105 wxFLAGS_MEMBER(wxDOUBLE_BORDER)
106 wxFLAGS_MEMBER(wxRAISED_BORDER)
107 wxFLAGS_MEMBER(wxSTATIC_BORDER)
108 wxFLAGS_MEMBER(wxBORDER)
109
110 // standard window styles
111 wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
112 wxFLAGS_MEMBER(wxCLIP_CHILDREN)
113 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
114 wxFLAGS_MEMBER(wxWANTS_CHARS)
115 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
116 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
117 wxFLAGS_MEMBER(wxVSCROLL)
118 wxFLAGS_MEMBER(wxHSCROLL)
119
120 wxFLAGS_MEMBER(wxTE_PROCESS_ENTER)
121 wxFLAGS_MEMBER(wxTE_PROCESS_TAB)
122 wxFLAGS_MEMBER(wxTE_MULTILINE)
123 wxFLAGS_MEMBER(wxTE_PASSWORD)
124 wxFLAGS_MEMBER(wxTE_READONLY)
125 wxFLAGS_MEMBER(wxHSCROLL)
126 wxFLAGS_MEMBER(wxTE_RICH)
127 wxFLAGS_MEMBER(wxTE_RICH2)
128 wxFLAGS_MEMBER(wxTE_AUTO_URL)
129 wxFLAGS_MEMBER(wxTE_NOHIDESEL)
130 wxFLAGS_MEMBER(wxTE_LEFT)
131 wxFLAGS_MEMBER(wxTE_CENTRE)
132 wxFLAGS_MEMBER(wxTE_RIGHT)
133 wxFLAGS_MEMBER(wxTE_DONTWRAP)
134 wxFLAGS_MEMBER(wxTE_CHARWRAP)
135 wxFLAGS_MEMBER(wxTE_WORDWRAP)
136
137 wxEND_FLAGS( wxTextCtrlStyle )
138
139 IMPLEMENT_DYNAMIC_CLASS_XTI(wxTextCtrl, wxControl,"wx/textctrl.h")
140
141 wxBEGIN_PROPERTIES_TABLE(wxTextCtrl)
142 wxEVENT_PROPERTY( TextUpdated , wxEVT_COMMAND_TEXT_UPDATED , wxCommandEvent )
143 wxEVENT_PROPERTY( TextEnter , wxEVT_COMMAND_TEXT_ENTER , wxCommandEvent )
144
145 wxPROPERTY( Font , wxFont , SetFont , GetFont , EMPTY_MACROVALUE, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
146 wxPROPERTY( Value , wxString , SetValue, GetValue, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
147 wxPROPERTY_FLAGS( WindowStyle , wxTextCtrlStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
148 wxEND_PROPERTIES_TABLE()
149
150 wxBEGIN_HANDLERS_TABLE(wxTextCtrl)
151 wxEND_HANDLERS_TABLE()
152
153 wxCONSTRUCTOR_6( wxTextCtrl , wxWindow* , Parent , wxWindowID , Id , wxString , Value , wxPoint , Position , wxSize , Size , long , WindowStyle)
154 #else
155 IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxTextCtrlBase)
156 #endif
157
158
159 BEGIN_EVENT_TABLE(wxTextCtrl, wxTextCtrlBase)
160 EVT_CHAR(wxTextCtrl::OnChar)
161 EVT_DROP_FILES(wxTextCtrl::OnDropFiles)
162
163 #if wxUSE_RICHEDIT
164 EVT_RIGHT_UP(wxTextCtrl::OnRightClick)
165 #endif
166
167 EVT_MENU(wxID_CUT, wxTextCtrl::OnCut)
168 EVT_MENU(wxID_COPY, wxTextCtrl::OnCopy)
169 EVT_MENU(wxID_PASTE, wxTextCtrl::OnPaste)
170 EVT_MENU(wxID_UNDO, wxTextCtrl::OnUndo)
171 EVT_MENU(wxID_REDO, wxTextCtrl::OnRedo)
172 EVT_MENU(wxID_CLEAR, wxTextCtrl::OnDelete)
173 EVT_MENU(wxID_SELECTALL, wxTextCtrl::OnSelectAll)
174
175 EVT_UPDATE_UI(wxID_CUT, wxTextCtrl::OnUpdateCut)
176 EVT_UPDATE_UI(wxID_COPY, wxTextCtrl::OnUpdateCopy)
177 EVT_UPDATE_UI(wxID_PASTE, wxTextCtrl::OnUpdatePaste)
178 EVT_UPDATE_UI(wxID_UNDO, wxTextCtrl::OnUpdateUndo)
179 EVT_UPDATE_UI(wxID_REDO, wxTextCtrl::OnUpdateRedo)
180 EVT_UPDATE_UI(wxID_CLEAR, wxTextCtrl::OnUpdateDelete)
181 EVT_UPDATE_UI(wxID_SELECTALL, wxTextCtrl::OnUpdateSelectAll)
182
183 EVT_SET_FOCUS(wxTextCtrl::OnSetFocus)
184 END_EVENT_TABLE()
185
186 // ============================================================================
187 // implementation
188 // ============================================================================
189
190 // ----------------------------------------------------------------------------
191 // creation
192 // ----------------------------------------------------------------------------
193
194 void wxTextCtrl::Init()
195 {
196 }
197
198 wxTextCtrl::~wxTextCtrl()
199 {
200 }
201
202 bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
203 const wxString& value,
204 const wxPoint& pos,
205 const wxSize& size,
206 long style,
207 const wxValidator& validator,
208 const wxString& name)
209 {
210 return false;
211 }
212
213 // ----------------------------------------------------------------------------
214 // set/get the controls text
215 // ----------------------------------------------------------------------------
216
217 wxString wxTextCtrl::GetValue() const
218 {
219 wxString res;
220 return res;
221 }
222
223 wxString wxTextCtrl::GetRange(long from, long to) const
224 {
225 wxString res;
226 return res;
227 }
228
229 void wxTextCtrl::DoSetValue(const wxString& value, int flags)
230 {
231 }
232
233 void wxTextCtrl::WriteText(const wxString& value)
234 {
235 }
236
237 void wxTextCtrl::DoWriteText(const wxString& text, int flags)
238 {
239 }
240
241 void wxTextCtrl::AppendText(const wxString& text)
242 {
243 }
244
245 void wxTextCtrl::Clear()
246 {
247 }
248
249 // ----------------------------------------------------------------------------
250 // Clipboard operations
251 // ----------------------------------------------------------------------------
252
253 void wxTextCtrl::Copy()
254 {
255 }
256
257 void wxTextCtrl::Cut()
258 {
259 }
260
261 void wxTextCtrl::Paste()
262 {
263 }
264
265 bool wxTextCtrl::CanCopy() const
266 {
267 return false;
268 }
269
270 bool wxTextCtrl::CanCut() const
271 {
272 return false;
273 }
274
275 bool wxTextCtrl::CanPaste() const
276 {
277 return false;
278 }
279
280 // ----------------------------------------------------------------------------
281 // Accessors
282 // ----------------------------------------------------------------------------
283
284 void wxTextCtrl::SetEditable(bool editable)
285 {
286 }
287
288 void wxTextCtrl::SetInsertionPoint(long pos)
289 {
290 }
291
292 void wxTextCtrl::SetInsertionPointEnd()
293 {
294 }
295
296 long wxTextCtrl::GetInsertionPoint() const
297 {
298 return 0;
299 }
300
301 wxTextPos wxTextCtrl::GetLastPosition() const
302 {
303 return 0;
304 }
305
306 // If the return values from and to are the same, there is no
307 // selection.
308 void wxTextCtrl::GetSelection(long* from, long* to) const
309 {
310 }
311
312 bool wxTextCtrl::IsEditable() const
313 {
314 return false;
315 }
316
317 // ----------------------------------------------------------------------------
318 // selection
319 // ----------------------------------------------------------------------------
320
321 void wxTextCtrl::SetSelection(long from, long to)
322 {
323 }
324
325 void wxTextCtrl::DoSetSelection(long from, long to, int flags)
326 {
327 }
328
329 // ----------------------------------------------------------------------------
330 // Working with files
331 // ----------------------------------------------------------------------------
332
333 bool wxTextCtrl::DoLoadFile(const wxString& file, int fileType)
334 {
335 return false;
336 }
337
338 // ----------------------------------------------------------------------------
339 // Editing
340 // ----------------------------------------------------------------------------
341
342 void wxTextCtrl::Replace(long from, long to, const wxString& value)
343 {
344 }
345
346 void wxTextCtrl::Remove(long from, long to)
347 {
348 }
349
350 bool wxTextCtrl::IsModified() const
351 {
352 return false;
353 }
354
355 void wxTextCtrl::MarkDirty()
356 {
357 }
358
359 void wxTextCtrl::DiscardEdits()
360 {
361 }
362
363 int wxTextCtrl::GetNumberOfLines() const
364 {
365 return 0;
366 }
367
368 // ----------------------------------------------------------------------------
369 // Positions <-> coords
370 // ----------------------------------------------------------------------------
371
372 long wxTextCtrl::XYToPosition(long x, long y) const
373 {
374 return 0;
375 }
376
377 bool wxTextCtrl::PositionToXY(long pos, long *x, long *y) const
378 {
379 return false;
380 }
381
382 wxTextCtrlHitTestResult
383 wxTextCtrl::HitTest(const wxPoint& pt, long *pos) const
384 {
385 return wxTE_HT_UNKNOWN;
386 }
387
388 // ----------------------------------------------------------------------------
389 //
390 // ----------------------------------------------------------------------------
391
392 void wxTextCtrl::ShowPosition(long pos)
393 {
394 }
395
396 long wxTextCtrl::GetLengthOfLineContainingPos(long pos) const
397 {
398 return 0;
399 }
400
401 int wxTextCtrl::GetLineLength(long lineNo) const
402 {
403 return 0;
404 }
405
406 wxString wxTextCtrl::GetLineText(long lineNo) const
407 {
408 wxString str;
409
410 return str;
411 }
412
413 void wxTextCtrl::SetMaxLength(unsigned long len)
414 {
415 }
416
417 // ----------------------------------------------------------------------------
418 // Undo/redo
419 // ----------------------------------------------------------------------------
420
421 void wxTextCtrl::Undo()
422 {
423 }
424
425 void wxTextCtrl::Redo()
426 {
427 }
428
429 bool wxTextCtrl::CanUndo() const
430 {
431 return false;
432 }
433
434 bool wxTextCtrl::CanRedo() const
435 {
436 return false;
437 }
438
439 // ----------------------------------------------------------------------------
440 // caret handling (Windows only)
441 // ----------------------------------------------------------------------------
442
443 bool wxTextCtrl::ShowNativeCaret(bool show)
444 {
445 return false;
446 }
447
448 // ----------------------------------------------------------------------------
449 // implemenation details
450 // ----------------------------------------------------------------------------
451
452 void wxTextCtrl::Command(wxCommandEvent & event)
453 {
454 }
455
456 void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event)
457 {
458 }
459
460 // ----------------------------------------------------------------------------
461 // kbd input processing
462 // ----------------------------------------------------------------------------
463
464 void wxTextCtrl::OnChar(wxKeyEvent& event)
465 {
466 }
467
468 // ----------------------------------------------------------------------------
469 // text control event processing
470 // ----------------------------------------------------------------------------
471
472 bool wxTextCtrl::SendUpdateEvent()
473 {
474 return false;
475 }
476
477 bool wxTextCtrl::AdjustSpaceLimit()
478 {
479 return false;
480 }
481
482 wxSize wxTextCtrl::DoGetBestSize() const
483 {
484 return wxSize(0,0);
485 }
486
487 // ----------------------------------------------------------------------------
488 // standard handlers for standard edit menu events
489 // ----------------------------------------------------------------------------
490
491 void wxTextCtrl::OnCut(wxCommandEvent& WXUNUSED(event))
492 {
493 }
494
495 void wxTextCtrl::OnCopy(wxCommandEvent& WXUNUSED(event))
496 {
497 }
498
499 void wxTextCtrl::OnPaste(wxCommandEvent& WXUNUSED(event))
500 {
501 }
502
503 void wxTextCtrl::OnUndo(wxCommandEvent& WXUNUSED(event))
504 {
505 }
506
507 void wxTextCtrl::OnRedo(wxCommandEvent& WXUNUSED(event))
508 {
509 }
510
511 void wxTextCtrl::OnDelete(wxCommandEvent& WXUNUSED(event))
512 {
513 }
514
515 void wxTextCtrl::OnSelectAll(wxCommandEvent& WXUNUSED(event))
516 {
517 }
518
519 void wxTextCtrl::OnUpdateCut(wxUpdateUIEvent& event)
520 {
521 }
522
523 void wxTextCtrl::OnUpdateCopy(wxUpdateUIEvent& event)
524 {
525 }
526
527 void wxTextCtrl::OnUpdatePaste(wxUpdateUIEvent& event)
528 {
529 }
530
531 void wxTextCtrl::OnUpdateUndo(wxUpdateUIEvent& event)
532 {
533 }
534
535 void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent& event)
536 {
537 }
538
539 void wxTextCtrl::OnUpdateDelete(wxUpdateUIEvent& event)
540 {
541 }
542
543 void wxTextCtrl::OnUpdateSelectAll(wxUpdateUIEvent& event)
544 {
545 }
546
547 void wxTextCtrl::OnSetFocus(wxFocusEvent& WXUNUSED(event))
548 {
549 }
550
551 wxVisualAttributes wxTextCtrl::GetDefaultAttributes() const
552 {
553 wxVisualAttributes attrs;
554 attrs.font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
555 attrs.colFg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
556 attrs.colBg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); //white
557 return attrs;
558 }
559
560 bool wxTextCtrl::EmulateKeyPress(const wxKeyEvent& rEvent)
561 {
562 return false;
563 }
564 bool wxTextCtrl::CanApplyThemeBorder() const
565 {
566 return false;
567 }
568 bool wxTextCtrl::IsEmpty() const
569 {
570 return false;
571 }
572 bool wxTextCtrl::AcceptsFocusFromKeyboard() const
573 {
574 return false;
575 }
576 void wxTextCtrl::AdoptAttributesFromHWND()
577 {
578 }
579 void wxTextCtrl::SetWindowStyleFlag(long lStyle)
580 {
581 }
582
583 // the rest of the file only deals with the rich edit controls
584 #if wxUSE_RICHEDIT
585
586 // ----------------------------------------------------------------------------
587 // EN_LINK processing
588 // ----------------------------------------------------------------------------
589
590 bool wxTextCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
591 {
592 return false;
593 }
594
595 // ----------------------------------------------------------------------------
596 // colour setting for the rich edit controls
597 // ----------------------------------------------------------------------------
598
599 bool wxTextCtrl::SetBackgroundColour(const wxColour& colour)
600 {
601 return false;
602 }
603
604 bool wxTextCtrl::SetForegroundColour(const wxColour& colour)
605 {
606 return false;
607 }
608
609 // ----------------------------------------------------------------------------
610 // wxRichEditModule
611 // ----------------------------------------------------------------------------
612
613 bool wxRichEditModule::OnInit()
614 {
615 return false;
616 }
617
618 void wxRichEditModule::OnExit()
619 {
620 }
621
622 /* static */
623 bool wxRichEditModule::Load(int version)
624 {
625 return false;
626 }
627
628 #endif // wxUSE_RICHEDIT
629
630 // ----------------------------------------------------------------------------
631 // styling support for rich edit controls
632 // ----------------------------------------------------------------------------
633
634 #if wxUSE_RICHEDIT
635
636 bool wxTextCtrl::SetStyle(long start, long end, const wxTextAttr& style)
637 {
638 return false;
639 }
640
641 bool wxTextCtrl::SetDefaultStyle(const wxTextAttr& style)
642 {
643 return false;
644 }
645
646 bool wxTextCtrl::GetStyle(long position, wxTextAttr& style)
647 {
648 return false;
649 }
650
651 #endif // wxUSE_RICHEDIT
652
653 #endif // wxUSE_TEXTCTRL