]> git.saurik.com Git - wxWidgets.git/blame - src/palmos/textctrl.cpp
Test for x, y in GetPosition
[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
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
70class wxRichEditModule : public wxModule
71{
72public:
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
79private:
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
86HINSTANCE wxRichEditModule::ms_hRichEdit[2] = { NULL, NULL };
87
88IMPLEMENT_DYNAMIC_CLASS(wxRichEditModule, wxModule)
89
90#endif // wxUSE_RICHEDIT
91
92// ----------------------------------------------------------------------------
93// event tables and other macros
94// ----------------------------------------------------------------------------
95
96#if wxUSE_EXTENDED_RTTI
97WX_DEFINE_FLAGS( wxTextCtrlStyle )
98
99wxBEGIN_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)
4055ed82 108
ffecfa5a
JS
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
144wxEND_FLAGS( wxTextCtrlStyle )
145
146IMPLEMENT_DYNAMIC_CLASS_XTI(wxTextCtrl, wxControl,"wx/textctrl.h")
147
148wxBEGIN_PROPERTIES_TABLE(wxTextCtrl)
4055ed82 149 wxEVENT_PROPERTY( TextUpdated , wxEVT_COMMAND_TEXT_UPDATED , wxCommandEvent )
ffecfa5a
JS
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
155wxEND_PROPERTIES_TABLE()
156
157wxBEGIN_HANDLERS_TABLE(wxTextCtrl)
158wxEND_HANDLERS_TABLE()
159
160wxCONSTRUCTOR_6( wxTextCtrl , wxWindow* , Parent , wxWindowID , Id , wxString , Value , wxPoint , Position , wxSize , Size , long , WindowStyle)
161#else
162IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
163#endif
164
165
166BEGIN_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)
191END_EVENT_TABLE()
192
193// ============================================================================
194// implementation
195// ============================================================================
196
197// ----------------------------------------------------------------------------
198// creation
199// ----------------------------------------------------------------------------
200
201void wxTextCtrl::Init()
202{
203}
204
205wxTextCtrl::~wxTextCtrl()
206{
207}
208
209bool 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
ffecfa5a
JS
220WXDWORD wxTextCtrl::MSWGetStyle(long style, WXDWORD *exstyle) const
221{
222 return 0;
223}
224
ffecfa5a
JS
225// ----------------------------------------------------------------------------
226// set/get the controls text
227// ----------------------------------------------------------------------------
228
229wxString wxTextCtrl::GetValue() const
230{
231 wxString res;
232
233 return res;
234}
235
236wxString wxTextCtrl::GetRange(long from, long to) const
237{
238 wxString str;
239
240 return str;
241}
242
243void wxTextCtrl::SetValue(const wxString& value)
244{
245}
246
247#if wxUSE_RICHEDIT && (!wxUSE_UNICODE || wxUSE_UNICODE_MSLU)
248
249// TODO: using memcpy() would improve performance a lot for big amounts of text
250
251DWORD CALLBACK
252wxRichEditStreamIn(DWORD dwCookie, BYTE *buf, LONG cb, LONG *pcb)
253{
254 return 0;
255}
256
257// helper struct used to pass parameters from wxTextCtrl to wxRichEditStreamOut
258struct wxStreamOutData
259{
260 wchar_t *wpc;
261 size_t len;
262};
263
264DWORD CALLBACK
265wxRichEditStreamOut(DWORD_PTR dwCookie, BYTE *buf, LONG cb, LONG *pcb)
266{
267 return 0;
268}
269
270
271#if wxUSE_UNICODE_MSLU
272 #define UNUSED_IF_MSLU(param)
273#else
274 #define UNUSED_IF_MSLU(param) param
275#endif
276
277bool
278wxTextCtrl::StreamIn(const wxString& value,
279 wxFontEncoding UNUSED_IF_MSLU(encoding),
280 bool selectionOnly)
281{
282 return false;
283}
284
285#if !wxUSE_UNICODE_MSLU
286
287wxString
288wxTextCtrl::StreamOut(wxFontEncoding encoding, bool selectionOnly) const
289{
290 wxString out;
291
292 return out;
293}
294
295#endif // !wxUSE_UNICODE_MSLU
296
297#endif // wxUSE_RICHEDIT
298
299void wxTextCtrl::WriteText(const wxString& value)
300{
301}
302
303void wxTextCtrl::DoWriteText(const wxString& value, bool selectionOnly)
304{
305}
306
307void wxTextCtrl::AppendText(const wxString& text)
308{
309}
310
311void wxTextCtrl::Clear()
312{
313}
314
ffecfa5a
JS
315// ----------------------------------------------------------------------------
316// Clipboard operations
317// ----------------------------------------------------------------------------
318
319void wxTextCtrl::Copy()
320{
321}
322
323void wxTextCtrl::Cut()
324{
325}
326
327void wxTextCtrl::Paste()
328{
329}
330
331bool wxTextCtrl::HasSelection() const
332{
333 return false;
334}
335
336bool wxTextCtrl::CanCopy() const
337{
338 return false;
339}
340
341bool wxTextCtrl::CanCut() const
342{
343 return false;
344}
345
346bool wxTextCtrl::CanPaste() const
347{
348 return false;
349}
350
351// ----------------------------------------------------------------------------
352// Accessors
353// ----------------------------------------------------------------------------
354
355void wxTextCtrl::SetEditable(bool editable)
356{
357}
358
359void wxTextCtrl::SetInsertionPoint(long pos)
360{
361}
362
363void wxTextCtrl::SetInsertionPointEnd()
364{
365}
366
367long wxTextCtrl::GetInsertionPoint() const
368{
369 return 0;
370}
371
7d8268a1 372wxTextPos wxTextCtrl::GetLastPosition() const
ffecfa5a
JS
373{
374 return 0;
375}
376
377// If the return values from and to are the same, there is no
378// selection.
379void wxTextCtrl::GetSelection(long* from, long* to) const
380{
381}
382
383bool wxTextCtrl::IsEditable() const
384{
385 return false;
386}
387
388// ----------------------------------------------------------------------------
389// selection
390// ----------------------------------------------------------------------------
391
392void wxTextCtrl::SetSelection(long from, long to)
393{
394}
395
396void wxTextCtrl::DoSetSelection(long from, long to, bool scrollCaret)
397{
398}
399
400// ----------------------------------------------------------------------------
401// Working with files
402// ----------------------------------------------------------------------------
403
404bool wxTextCtrl::LoadFile(const wxString& file)
405{
406 return false;
407}
408
409// ----------------------------------------------------------------------------
410// Editing
411// ----------------------------------------------------------------------------
412
413void wxTextCtrl::Replace(long from, long to, const wxString& value)
414{
415}
416
417void wxTextCtrl::Remove(long from, long to)
418{
419}
420
421bool wxTextCtrl::IsModified() const
422{
423 return false;
424}
425
426void wxTextCtrl::MarkDirty()
427{
428}
429
430void wxTextCtrl::DiscardEdits()
431{
432}
433
434int wxTextCtrl::GetNumberOfLines() const
435{
436 return 0;
437}
438
439// ----------------------------------------------------------------------------
440// Positions <-> coords
441// ----------------------------------------------------------------------------
442
443long wxTextCtrl::XYToPosition(long x, long y) const
444{
445 return 0;
446}
447
448bool wxTextCtrl::PositionToXY(long pos, long *x, long *y) const
449{
450 return false;
451}
452
453wxTextCtrlHitTestResult
454wxTextCtrl::HitTest(const wxPoint& pt, wxTextCoord *col, wxTextCoord *row) const
455{
456 return wxTE_HT_UNKNOWN;
457}
458
459// ----------------------------------------------------------------------------
4055ed82 460//
ffecfa5a
JS
461// ----------------------------------------------------------------------------
462
463void wxTextCtrl::ShowPosition(long pos)
464{
465}
466
467long wxTextCtrl::GetLengthOfLineContainingPos(long pos) const
468{
469 return 0;
470}
471
472int wxTextCtrl::GetLineLength(long lineNo) const
473{
474 return 0;
475}
476
477wxString wxTextCtrl::GetLineText(long lineNo) const
478{
479 wxString str;
480
481 return str;
482}
483
484void wxTextCtrl::SetMaxLength(unsigned long len)
485{
486}
487
488// ----------------------------------------------------------------------------
489// Undo/redo
490// ----------------------------------------------------------------------------
491
492void wxTextCtrl::Undo()
493{
494}
495
496void wxTextCtrl::Redo()
497{
498}
499
500bool wxTextCtrl::CanUndo() const
501{
502}
503
504bool wxTextCtrl::CanRedo() const
505{
506}
507
508// ----------------------------------------------------------------------------
509// caret handling (Windows only)
510// ----------------------------------------------------------------------------
511
512bool wxTextCtrl::ShowNativeCaret(bool show)
513{
514 return false;
515}
516
517// ----------------------------------------------------------------------------
518// implemenation details
519// ----------------------------------------------------------------------------
520
521void wxTextCtrl::Command(wxCommandEvent & event)
522{
523}
524
525void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event)
526{
527}
528
529// ----------------------------------------------------------------------------
530// kbd input processing
531// ----------------------------------------------------------------------------
532
533bool wxTextCtrl::MSWShouldPreProcessMessage(WXMSG* pMsg)
534{
535 return false;
536}
537
538void wxTextCtrl::OnChar(wxKeyEvent& event)
539{
540}
541
542WXLRESULT wxTextCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
543{
544 return 0;
545}
546
547// ----------------------------------------------------------------------------
548// text control event processing
549// ----------------------------------------------------------------------------
550
551bool wxTextCtrl::SendUpdateEvent()
552{
553 return false;
554}
555
556bool wxTextCtrl::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
557{
558 return false;
559}
560
ffecfa5a
JS
561bool wxTextCtrl::AdjustSpaceLimit()
562{
563 return false;
564}
565
566bool wxTextCtrl::AcceptsFocus() const
567{
568 return false;
569}
570
571wxSize wxTextCtrl::DoGetBestSize() const
572{
573 return wxSize(0,0);
574}
575
576// ----------------------------------------------------------------------------
577// standard handlers for standard edit menu events
578// ----------------------------------------------------------------------------
579
580void wxTextCtrl::OnCut(wxCommandEvent& WXUNUSED(event))
581{
582}
583
584void wxTextCtrl::OnCopy(wxCommandEvent& WXUNUSED(event))
585{
586}
587
588void wxTextCtrl::OnPaste(wxCommandEvent& WXUNUSED(event))
589{
590}
591
592void wxTextCtrl::OnUndo(wxCommandEvent& WXUNUSED(event))
593{
594}
595
596void wxTextCtrl::OnRedo(wxCommandEvent& WXUNUSED(event))
597{
598}
599
600void wxTextCtrl::OnDelete(wxCommandEvent& WXUNUSED(event))
601{
602}
603
604void wxTextCtrl::OnSelectAll(wxCommandEvent& WXUNUSED(event))
605{
606}
607
608void wxTextCtrl::OnUpdateCut(wxUpdateUIEvent& event)
609{
610}
611
612void wxTextCtrl::OnUpdateCopy(wxUpdateUIEvent& event)
613{
614}
615
616void wxTextCtrl::OnUpdatePaste(wxUpdateUIEvent& event)
617{
618}
619
620void wxTextCtrl::OnUpdateUndo(wxUpdateUIEvent& event)
621{
622}
623
624void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent& event)
625{
626}
627
628void wxTextCtrl::OnUpdateDelete(wxUpdateUIEvent& event)
629{
630}
631
632void wxTextCtrl::OnUpdateSelectAll(wxUpdateUIEvent& event)
633{
634}
635
636void wxTextCtrl::OnRightClick(wxMouseEvent& event)
637{
638}
639
640void wxTextCtrl::OnSetFocus(wxFocusEvent& WXUNUSED(event))
641{
642}
643
644// the rest of the file only deals with the rich edit controls
645#if wxUSE_RICHEDIT
646
647// ----------------------------------------------------------------------------
648// EN_LINK processing
649// ----------------------------------------------------------------------------
650
651bool wxTextCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
652{
653 return false;
654}
655
656// ----------------------------------------------------------------------------
657// colour setting for the rich edit controls
658// ----------------------------------------------------------------------------
659
660bool wxTextCtrl::SetBackgroundColour(const wxColour& colour)
661{
662 return false;
663}
664
665bool wxTextCtrl::SetForegroundColour(const wxColour& colour)
666{
667 return false;
668}
669
670// ----------------------------------------------------------------------------
671// styling support for rich edit controls
672// ----------------------------------------------------------------------------
673
674#if wxUSE_RICHEDIT
675
676bool wxTextCtrl::SetStyle(long start, long end, const wxTextAttr& style)
677{
678 return false;
679}
680
681bool wxTextCtrl::SetDefaultStyle(const wxTextAttr& style)
682{
683 return false;
684}
685
686bool wxTextCtrl::GetStyle(long position, wxTextAttr& style)
687{
688 return false;
689}
690
691#endif
692
693// ----------------------------------------------------------------------------
694// wxRichEditModule
695// ----------------------------------------------------------------------------
696
697bool wxRichEditModule::OnInit()
698{
699 return false;
700}
701
702void wxRichEditModule::OnExit()
703{
704}
705
706/* static */
707bool wxRichEditModule::Load(int version)
708{
709 return false;
710}
711
712#endif // wxUSE_RICHEDIT
713
714#endif // wxUSE_TEXTCTRL