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