]> git.saurik.com Git - wxWidgets.git/blame - src/palmos/textctrl.cpp
Committing in .
[wxWidgets.git] / src / palmos / textctrl.cpp
CommitLineData
ffecfa5a 1/////////////////////////////////////////////////////////////////////////////
e2731512 2// Name: src/palmos/textctrl.cpp
ffecfa5a 3// Purpose: wxTextCtrl
e2731512 4// Author: William Osborne - minimal working wxPalmOS port
ffecfa5a
JS
5// Modified by:
6// Created: 10/13/04
e2731512 7// RCS-ID: $Id$
ffecfa5a
JS
8// Copyright: (c) William Osborne
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
ffecfa5a
JS
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
fec9cc08
WS
29#include "wx/textctrl.h"
30
ffecfa5a 31#ifndef WX_PRECOMP
ffecfa5a
JS
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
67class wxRichEditModule : public wxModule
68{
69public:
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
76private:
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
83HINSTANCE wxRichEditModule::ms_hRichEdit[2] = { NULL, NULL };
84
85IMPLEMENT_DYNAMIC_CLASS(wxRichEditModule, wxModule)
86
87#endif // wxUSE_RICHEDIT
88
89// ----------------------------------------------------------------------------
90// event tables and other macros
91// ----------------------------------------------------------------------------
92
93#if wxUSE_EXTENDED_RTTI
94WX_DEFINE_FLAGS( wxTextCtrlStyle )
95
96wxBEGIN_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)
4055ed82 105
ffecfa5a
JS
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)
40ff126a 138 wxFLAGS_MEMBER(wxTE_CHARWRAP)
ffecfa5a
JS
139 wxFLAGS_MEMBER(wxTE_WORDWRAP)
140
141wxEND_FLAGS( wxTextCtrlStyle )
142
143IMPLEMENT_DYNAMIC_CLASS_XTI(wxTextCtrl, wxControl,"wx/textctrl.h")
144
145wxBEGIN_PROPERTIES_TABLE(wxTextCtrl)
4055ed82 146 wxEVENT_PROPERTY( TextUpdated , wxEVT_COMMAND_TEXT_UPDATED , wxCommandEvent )
ffecfa5a
JS
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
152wxEND_PROPERTIES_TABLE()
153
154wxBEGIN_HANDLERS_TABLE(wxTextCtrl)
155wxEND_HANDLERS_TABLE()
156
157wxCONSTRUCTOR_6( wxTextCtrl , wxWindow* , Parent , wxWindowID , Id , wxString , Value , wxPoint , Position , wxSize , Size , long , WindowStyle)
158#else
159IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
160#endif
161
162
163BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
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)
188END_EVENT_TABLE()
189
190// ============================================================================
191// implementation
192// ============================================================================
193
194// ----------------------------------------------------------------------------
195// creation
196// ----------------------------------------------------------------------------
197
198void wxTextCtrl::Init()
199{
200}
201
202wxTextCtrl::~wxTextCtrl()
203{
204}
205
206bool 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
ffecfa5a
JS
217WXDWORD wxTextCtrl::MSWGetStyle(long style, WXDWORD *exstyle) const
218{
219 return 0;
220}
221
ffecfa5a
JS
222// ----------------------------------------------------------------------------
223// set/get the controls text
224// ----------------------------------------------------------------------------
225
226wxString wxTextCtrl::GetValue() const
227{
228 wxString res;
229
230 return res;
231}
232
ffecfa5a
JS
233void 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
241DWORD CALLBACK
242wxRichEditStreamIn(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
248struct wxStreamOutData
249{
250 wchar_t *wpc;
251 size_t len;
252};
253
254DWORD CALLBACK
255wxRichEditStreamOut(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
267bool
268wxTextCtrl::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
277wxString
278wxTextCtrl::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
289void wxTextCtrl::WriteText(const wxString& value)
290{
291}
292
293void wxTextCtrl::DoWriteText(const wxString& value, bool selectionOnly)
294{
295}
296
297void wxTextCtrl::AppendText(const wxString& text)
298{
299}
300
301void wxTextCtrl::Clear()
302{
303}
304
ffecfa5a
JS
305// ----------------------------------------------------------------------------
306// Clipboard operations
307// ----------------------------------------------------------------------------
308
309void wxTextCtrl::Copy()
310{
311}
312
313void wxTextCtrl::Cut()
314{
315}
316
317void wxTextCtrl::Paste()
318{
319}
320
321bool wxTextCtrl::HasSelection() const
322{
323 return false;
324}
325
326bool wxTextCtrl::CanCopy() const
327{
328 return false;
329}
330
331bool wxTextCtrl::CanCut() const
332{
333 return false;
334}
335
336bool wxTextCtrl::CanPaste() const
337{
338 return false;
339}
340
341// ----------------------------------------------------------------------------
342// Accessors
343// ----------------------------------------------------------------------------
344
345void wxTextCtrl::SetEditable(bool editable)
346{
347}
348
349void wxTextCtrl::SetInsertionPoint(long pos)
350{
351}
352
353void wxTextCtrl::SetInsertionPointEnd()
354{
355}
356
357long wxTextCtrl::GetInsertionPoint() const
358{
359 return 0;
360}
361
7d8268a1 362wxTextPos wxTextCtrl::GetLastPosition() const
ffecfa5a
JS
363{
364 return 0;
365}
366
367// If the return values from and to are the same, there is no
368// selection.
369void wxTextCtrl::GetSelection(long* from, long* to) const
370{
371}
372
373bool wxTextCtrl::IsEditable() const
374{
375 return false;
376}
377
378// ----------------------------------------------------------------------------
379// selection
380// ----------------------------------------------------------------------------
381
382void wxTextCtrl::SetSelection(long from, long to)
383{
384}
385
386void wxTextCtrl::DoSetSelection(long from, long to, bool scrollCaret)
387{
388}
389
390// ----------------------------------------------------------------------------
391// Working with files
392// ----------------------------------------------------------------------------
393
394bool wxTextCtrl::LoadFile(const wxString& file)
395{
396 return false;
397}
398
399// ----------------------------------------------------------------------------
400// Editing
401// ----------------------------------------------------------------------------
402
403void wxTextCtrl::Replace(long from, long to, const wxString& value)
404{
405}
406
407void wxTextCtrl::Remove(long from, long to)
408{
409}
410
411bool wxTextCtrl::IsModified() const
412{
413 return false;
414}
415
416void wxTextCtrl::MarkDirty()
417{
418}
419
420void wxTextCtrl::DiscardEdits()
421{
422}
423
424int wxTextCtrl::GetNumberOfLines() const
425{
426 return 0;
427}
428
429// ----------------------------------------------------------------------------
430// Positions <-> coords
431// ----------------------------------------------------------------------------
432
433long wxTextCtrl::XYToPosition(long x, long y) const
434{
435 return 0;
436}
437
438bool wxTextCtrl::PositionToXY(long pos, long *x, long *y) const
439{
440 return false;
441}
442
443wxTextCtrlHitTestResult
444wxTextCtrl::HitTest(const wxPoint& pt, wxTextCoord *col, wxTextCoord *row) const
445{
446 return wxTE_HT_UNKNOWN;
447}
448
449// ----------------------------------------------------------------------------
4055ed82 450//
ffecfa5a
JS
451// ----------------------------------------------------------------------------
452
453void wxTextCtrl::ShowPosition(long pos)
454{
455}
456
457long wxTextCtrl::GetLengthOfLineContainingPos(long pos) const
458{
459 return 0;
460}
461
462int wxTextCtrl::GetLineLength(long lineNo) const
463{
464 return 0;
465}
466
467wxString wxTextCtrl::GetLineText(long lineNo) const
468{
469 wxString str;
470
471 return str;
472}
473
474void wxTextCtrl::SetMaxLength(unsigned long len)
475{
476}
477
478// ----------------------------------------------------------------------------
479// Undo/redo
480// ----------------------------------------------------------------------------
481
482void wxTextCtrl::Undo()
483{
484}
485
486void wxTextCtrl::Redo()
487{
488}
489
490bool wxTextCtrl::CanUndo() const
491{
492}
493
494bool wxTextCtrl::CanRedo() const
495{
496}
497
498// ----------------------------------------------------------------------------
499// caret handling (Windows only)
500// ----------------------------------------------------------------------------
501
502bool wxTextCtrl::ShowNativeCaret(bool show)
503{
504 return false;
505}
506
507// ----------------------------------------------------------------------------
508// implemenation details
509// ----------------------------------------------------------------------------
510
511void wxTextCtrl::Command(wxCommandEvent & event)
512{
513}
514
515void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event)
516{
517}
518
519// ----------------------------------------------------------------------------
520// kbd input processing
521// ----------------------------------------------------------------------------
522
523bool wxTextCtrl::MSWShouldPreProcessMessage(WXMSG* pMsg)
524{
525 return false;
526}
527
528void wxTextCtrl::OnChar(wxKeyEvent& event)
529{
530}
531
532WXLRESULT wxTextCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
533{
534 return 0;
535}
536
537// ----------------------------------------------------------------------------
538// text control event processing
539// ----------------------------------------------------------------------------
540
541bool wxTextCtrl::SendUpdateEvent()
542{
543 return false;
544}
545
546bool wxTextCtrl::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
547{
548 return false;
549}
550
ffecfa5a
JS
551bool wxTextCtrl::AdjustSpaceLimit()
552{
553 return false;
554}
555
556bool wxTextCtrl::AcceptsFocus() const
557{
558 return false;
559}
560
561wxSize wxTextCtrl::DoGetBestSize() const
562{
563 return wxSize(0,0);
564}
565
566// ----------------------------------------------------------------------------
567// standard handlers for standard edit menu events
568// ----------------------------------------------------------------------------
569
570void wxTextCtrl::OnCut(wxCommandEvent& WXUNUSED(event))
571{
572}
573
574void wxTextCtrl::OnCopy(wxCommandEvent& WXUNUSED(event))
575{
576}
577
578void wxTextCtrl::OnPaste(wxCommandEvent& WXUNUSED(event))
579{
580}
581
582void wxTextCtrl::OnUndo(wxCommandEvent& WXUNUSED(event))
583{
584}
585
586void wxTextCtrl::OnRedo(wxCommandEvent& WXUNUSED(event))
587{
588}
589
590void wxTextCtrl::OnDelete(wxCommandEvent& WXUNUSED(event))
591{
592}
593
594void wxTextCtrl::OnSelectAll(wxCommandEvent& WXUNUSED(event))
595{
596}
597
598void wxTextCtrl::OnUpdateCut(wxUpdateUIEvent& event)
599{
600}
601
602void wxTextCtrl::OnUpdateCopy(wxUpdateUIEvent& event)
603{
604}
605
606void wxTextCtrl::OnUpdatePaste(wxUpdateUIEvent& event)
607{
608}
609
610void wxTextCtrl::OnUpdateUndo(wxUpdateUIEvent& event)
611{
612}
613
614void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent& event)
615{
616}
617
618void wxTextCtrl::OnUpdateDelete(wxUpdateUIEvent& event)
619{
620}
621
622void wxTextCtrl::OnUpdateSelectAll(wxUpdateUIEvent& event)
623{
624}
625
626void wxTextCtrl::OnRightClick(wxMouseEvent& event)
627{
628}
629
630void 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
641bool 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
650bool wxTextCtrl::SetBackgroundColour(const wxColour& colour)
651{
652 return false;
653}
654
655bool 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
666bool wxTextCtrl::SetStyle(long start, long end, const wxTextAttr& style)
667{
668 return false;
669}
670
671bool wxTextCtrl::SetDefaultStyle(const wxTextAttr& style)
672{
673 return false;
674}
675
676bool wxTextCtrl::GetStyle(long position, wxTextAttr& style)
677{
678 return false;
679}
680
681#endif
682
683// ----------------------------------------------------------------------------
684// wxRichEditModule
685// ----------------------------------------------------------------------------
686
687bool wxRichEditModule::OnInit()
688{
689 return false;
690}
691
692void wxRichEditModule::OnExit()
693{
694}
695
696/* static */
697bool wxRichEditModule::Load(int version)
698{
699 return false;
700}
701
702#endif // wxUSE_RICHEDIT
703
704#endif // wxUSE_TEXTCTRL