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