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