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