~registry/codeblocks/trunk

« back to all changes in this revision

Viewing changes to src/sdk/propgrid/include/wx/propgrid/custctrl.h

  • Committer: mandrav
  • Date: 2007-02-12 14:55:28 UTC
  • Revision ID: svn-v4:98b59c6a-2706-0410-b7d6-d2fa1a1880c9:trunk:3594
* First part of directories layout re-organization: moved all sdk header files to a new dir named "include".

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/////////////////////////////////////////////////////////////////////////////
2
 
// Name:        custctrl.h
3
 
// Purpose:     wxCustomControls (v1.0.8)
4
 
// Author:      Jaakko Salli
5
 
// Modified by:
6
 
// Created:     Oct-24-2004
7
 
// RCS-ID:      $Id:
8
 
// Copyright:   (c) Jaakko Salli
9
 
// Licence:     wxWindows license
10
 
/////////////////////////////////////////////////////////////////////////////
11
 
 
12
 
#ifndef __WX_CUSTCTRL_H__
13
 
#define __WX_CUSTCTRL_H__
14
 
 
15
 
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16
 
    #pragma interface "custctrl.cpp"
17
 
#endif
18
 
 
19
 
// Doxygen special
20
 
#ifndef _WX_WINDOW_H_BASE_
21
 
# include "cc_dox_mainpage.h"
22
 
#endif
23
 
 
24
 
// -----------------------------------------------------------------------
25
 
 
26
 
#include "wx/caret.h"
27
 
 
28
 
#include "wx/renderer.h"
29
 
 
30
 
// -----------------------------------------------------------------------
31
 
 
32
 
#if defined(WXMAKINGDLL_CUSTCTRL) || defined(WXMAKINGDLL_PROPGRID)
33
 
    #define WXDLLIMPEXP_CC WXEXPORT
34
 
//#elif defined(WXUSINGDLL)
35
 
//    #define WXDLLIMPEXP_CC WXIMPORT
36
 
#else // not making nor using DLL
37
 
    #define WXDLLIMPEXP_CC
38
 
#endif
39
 
 
40
 
// If given in button renderer flags, then popup arrow
41
 
// is drawn on it as well.
42
 
#define wxCONTROL_POPUP_ARROW       wxCONTROL_CHECKED
43
 
 
44
 
// -----------------------------------------------------------------------
45
 
 
46
 
//
47
 
// Here are some platform dependent defines
48
 
// (more in custctrl.cpp)
49
 
//
50
 
 
51
 
#if defined(__WXMSW__)
52
 
    // tested
53
 
 
54
 
#if wxUSE_UXTHEME
55
 
# include "wx/msw/uxtheme.h"
56
 
#endif
57
 
 
58
 
    #define wxCC_CUSTOM_IMAGE_MARGIN1       2  // before image
59
 
    #define wxCC_CUSTOM_IMAGE_MARGIN2       7  // after image
60
 
 
61
 
    #define wxCC_TEXTCTRL_YSPACING          2
62
 
    #define wxCC_TEXTCTRL_XSPACING          3
63
 
 
64
 
    #define wxCC_USE_POPUPWIN               1  // 1 if wxPopupWindow can be used.
65
 
 
66
 
#elif defined(__WXGTK__)
67
 
    // tested
68
 
 
69
 
    #define wxCC_CUSTOM_IMAGE_MARGIN1       2  // before image
70
 
    #define wxCC_CUSTOM_IMAGE_MARGIN2       7  // after image
71
 
 
72
 
    #define wxCC_TEXTCTRL_YSPACING          2
73
 
    #define wxCC_TEXTCTRL_XSPACING          3
74
 
 
75
 
    // Disabled because no proper border support.
76
 
    #define wxCC_USE_POPUPWIN               0  // 1 if wxPopupWindow can be used.
77
 
 
78
 
#elif defined(__WXMAC__)
79
 
    // *not* tested
80
 
 
81
 
    #define wxCC_CUSTOM_IMAGE_MARGIN1       2  // before image
82
 
    #define wxCC_CUSTOM_IMAGE_MARGIN2       7  // after image
83
 
 
84
 
    #define wxCC_TEXTCTRL_YSPACING          2
85
 
    #define wxCC_TEXTCTRL_XSPACING          3
86
 
 
87
 
    #define wxCC_USE_POPUPWIN               1  // 1 if wxPopupWindow can be used.
88
 
 
89
 
#else
90
 
    // defaults
91
 
 
92
 
    #define wxCC_CUSTOM_IMAGE_MARGIN1       2  // before image
93
 
    #define wxCC_CUSTOM_IMAGE_MARGIN2       7  // after image
94
 
 
95
 
    #define wxCC_TEXTCTRL_YSPACING          2
96
 
    #define wxCC_TEXTCTRL_XSPACING          3
97
 
 
98
 
    #define wxCC_USE_POPUPWIN               0  // 1 if wxPopupWindow can be used.
99
 
 
100
 
#endif
101
 
 
102
 
// Conform to wxUSE_POPUPWIN
103
 
#if !wxUSE_POPUPWIN
104
 
# undef wxCC_USE_POPUPWIN
105
 
# define wxCC_USE_POPUPWIN                  0
106
 
#endif
107
 
 
108
 
/** If 1, then controls will be moved according to scrolling
109
 
    (does not work exactly, so 0 is recommended value).
110
 
*/
111
 
#define wxCC_CORRECT_CONTROL_POSITION     0
112
 
 
113
 
#if !wxPG_USE_CUSTOM_CONTROLS
114
 
# undef wxCC_CUSTOM_IMAGE_MARGIN1
115
 
# undef wxCC_CUSTOM_IMAGE_MARGIN2
116
 
#endif
117
 
 
118
 
#if wxPG_USE_CUSTOM_CONTROLS
119
 
 
120
 
// -----------------------------------------------------------------------
121
 
 
122
 
#ifndef SWIG
123
 
class WXDLLIMPEXP_CC wxCustomControl;
124
 
class WXDLLIMPEXP_CC wxCCustomTextCtrl;
125
 
class WXDLLIMPEXP_CC wxCCustomButton;
126
 
class WXDLLIMPEXP_CC wxCCustomComboBox;
127
 
class WXDLLIMPEXP_CC wxCCustomComboBoxHandler;
128
 
class WXDLLIMPEXP_CC wxCustomControlManager;
129
 
#endif
130
 
 
131
 
// -----------------------------------------------------------------------
132
 
 
133
 
/** Each wxCustomControl uses 1+ wxCustomControlHandler.
134
 
*/
135
 
class WXDLLIMPEXP_CC wxCustomControlHandler
136
 
{
137
 
public:
138
 
 
139
 
    inline void SetControl ( wxCustomControl* pctrl )
140
 
    {
141
 
        m_control = pctrl;
142
 
        m_flags = 0;
143
 
    }
144
 
    inline wxCustomControl* GetControl() const { return m_control; }
145
 
    inline bool IsMouseFocused() const;
146
 
    inline void Move ( int x, int y ) { m_rect.x = x; m_rect.y = y; }
147
 
    inline void SetSize ( int width, int height ) { m_rect.width = width; m_rect.height = height; }
148
 
 
149
 
    inline void SetSize ( const wxPoint& pos, const wxSize& sz )
150
 
    {
151
 
        m_rect.x = pos.x; m_rect.y = pos.y;
152
 
        m_rect.width = sz.x; m_rect.height = sz.y;
153
 
    }
154
 
 
155
 
    inline const wxRect& GetRect() const { return m_rect; }
156
 
 
157
 
    inline void ClearFlag( long flag ) { m_flags &= ~(flag); }
158
 
    inline void SetFlag( long flag ) { m_flags |= flag; }
159
 
 
160
 
    void Create ( wxCustomControl* pctrl, const wxPoint& pos, const wxSize& sz );
161
 
 
162
 
protected:
163
 
    wxCustomControl*        m_control;
164
 
    wxRect                  m_rect;
165
 
    long                    m_flags; // barely needed
166
 
};
167
 
 
168
 
// -----------------------------------------------------------------------
169
 
 
170
 
class WXDLLIMPEXP_CC wxCustomTextCtrlHandler : public wxCustomControlHandler
171
 
{
172
 
public:
173
 
    
174
 
    void Create ( wxCustomControl* pctrl, const wxPoint& pos, const wxSize& sz,
175
 
        const wxString& value );
176
 
 
177
 
    void Draw ( wxDC& dc, const wxRect& rect );
178
 
 
179
 
    bool OnKeyEvent ( wxKeyEvent& event );
180
 
    
181
 
    bool OnMouseEvent ( wxMouseEvent& event );
182
 
 
183
 
    int HitTest ( wxCoord x, int* pCol );
184
 
 
185
 
    bool SetInsertionPoint ( long pos, long first_visible );
186
 
 
187
 
    bool SetSelection ( long from, long to );
188
 
 
189
 
    void SetValue ( const wxString& value );
190
 
 
191
 
    inline int GetPosition () const
192
 
    {
193
 
        return m_position;
194
 
    }
195
 
 
196
 
    inline const wxString& GetValue() const { return m_text; }
197
 
 
198
 
    // like DEL key was pressed
199
 
    void DeleteSelection ();
200
 
 
201
 
    // wxCC_FL_MODIFIED
202
 
 
203
 
protected:
204
 
 
205
 
    wxString        m_text;
206
 
    //wxString        m_textAtPos; // text that begins at position
207
 
    unsigned int    m_position;
208
 
    unsigned int    m_scrollPosition;
209
 
    int             m_selStart;
210
 
    int             m_selEnd;
211
 
    int             m_itemButDown; // dragging centers around this
212
 
 
213
 
    wxArrayInt      m_arrExtents; // cached array of text extents
214
 
 
215
 
    int UpdateExtentCache ( wxString& tempstr, size_t index );
216
 
 
217
 
};
218
 
 
219
 
// -----------------------------------------------------------------------
220
 
 
221
 
class WXDLLIMPEXP_CC wxCCustomButtonHandler : public wxCustomControlHandler
222
 
{
223
 
    friend class wxCCustomButton;
224
 
public:
225
 
    
226
 
    void Draw ( wxDC& dc, const wxRect& rect );
227
 
 
228
 
    bool OnMouseEvent ( wxMouseEvent& event );
229
 
 
230
 
    inline void SetButtonState ( int state ) { m_down = (unsigned char)state; }
231
 
 
232
 
protected:
233
 
    wxString        m_label;
234
 
    unsigned char   m_down; // 0 means button is up
235
 
 
236
 
};
237
 
 
238
 
// -----------------------------------------------------------------------
239
 
 
240
 
#if wxCC_USE_POPUPWIN
241
 
# include "wx/popupwin.h"
242
 
# define wxCustomComboPopupBase      wxPopupWindow
243
 
#else
244
 
# define wxCustomComboPopupBase      wxWindow
245
 
#endif
246
 
 
247
 
class WXDLLIMPEXP_CC wxCustomComboItem
248
 
{
249
 
public:
250
 
    wxCustomComboItem();
251
 
    virtual ~wxCustomComboItem();
252
 
protected:
253
 
};
254
 
 
255
 
// -----------------------------------------------------------------------
256
 
 
257
 
class WXDLLIMPEXP_CC wxCustomComboPopup : public wxCustomComboPopupBase
258
 
{
259
 
    friend class wxCustomControlManager;
260
 
public:
261
 
    wxCustomComboPopup ();
262
 
    virtual ~wxCustomComboPopup();
263
 
 
264
 
    bool Create ( wxWindow* frame, wxCCustomComboBoxHandler* data,
265
 
        const wxRect& ctrl_rect, wxCustomControl* ctrl,
266
 
        const wxSize& size, int sizealign );
267
 
 
268
 
/*#if wxCC_USE_POPUPWIN
269
 
    inline wxScrolledWindow* GetWindow() const { return m_subWindow; };
270
 
#else
271
 
    inline wxScrolledWindow* GetWindow() { return this; };
272
 
#endif*/
273
 
 
274
 
    // kbscroll allows forcing to scroll one item at a time.
275
 
    virtual void ShowItem ( const wxCustomComboItem& item, bool kbscroll = FALSE ) = 0;
276
 
    virtual void OnKeyEvent ( wxKeyEvent& event ) = 0;
277
 
    //virtual void SetSelection ( const wxCustomComboItem& item ) = 0;
278
 
 
279
 
    void ForcedClose ();
280
 
 
281
 
    inline wxCustomControl* GetControl () const { return m_control; }
282
 
 
283
 
    // Event handlers.
284
 
    void OnMouseEntry( wxMouseEvent& event );
285
 
 
286
 
protected:
287
 
    wxCustomControl*            m_control;
288
 
    wxCustomControlManager*     m_manager;
289
 
    wxCCustomComboBoxHandler*   m_chData;
290
 
 
291
 
    wxArrayPtrVoid              m_labels; // holds pointers to labels
292
 
 
293
 
    int                         m_wheelSum;
294
 
 
295
 
    unsigned char               m_orientation;
296
 
 
297
 
    //unsigned char               m_entryStatus;
298
 
private:
299
 
    DECLARE_EVENT_TABLE()
300
 
};
301
 
 
302
 
// -----------------------------------------------------------------------
303
 
 
304
 
class WXDLLIMPEXP_CC wxCustomComboListItem : public wxCustomComboItem
305
 
{
306
 
public:
307
 
    wxCustomComboListItem();
308
 
    wxCustomComboListItem( int index ) { m_index = index; }
309
 
    virtual ~wxCustomComboListItem();
310
 
 
311
 
    int m_index;
312
 
 
313
 
protected:
314
 
};
315
 
 
316
 
// -----------------------------------------------------------------------
317
 
 
318
 
#include "wx/scrolbar.h"
319
 
 
320
 
class WXDLLIMPEXP_CC wxComboPopupDefaultList : public wxCustomComboPopup
321
 
{
322
 
public:
323
 
    wxComboPopupDefaultList ( wxWindow* frame, wxCCustomComboBoxHandler* data,
324
 
        const wxRect& rect, wxCustomControl* ctrl );
325
 
    virtual ~wxComboPopupDefaultList();
326
 
 
327
 
    virtual void ShowItem ( const wxCustomComboItem& item, bool kbscroll = FALSE );
328
 
 
329
 
    inline void ShowItem ( int index, bool kbscroll = FALSE )
330
 
    {
331
 
        wxCustomComboListItem item(index);
332
 
        ShowItem (item,kbscroll);
333
 
    }
334
 
 
335
 
    //virtual void SetSelection ( const wxCustomComboItem& item );
336
 
 
337
 
    virtual void OnKeyEvent ( wxKeyEvent& event );
338
 
 
339
 
    int HitTest ( int y );
340
 
 
341
 
    inline void DrawItem ( int index )
342
 
    {
343
 
        wxCustomComboListItem item(index);
344
 
        DrawItem(item);
345
 
    }
346
 
    void DrawItem ( const wxCustomComboItem& item );
347
 
    void DrawItem ( wxDC& dc, wxRect& r, unsigned int index );
348
 
 
349
 
    void OnMouseWheelEvent ( wxMouseEvent& event );
350
 
 
351
 
    void OnPaint ( wxPaintEvent& event );
352
 
 
353
 
    void OnMouseDown ( wxMouseEvent& event );
354
 
    void OnMouseMove ( wxMouseEvent& event );
355
 
    void OnScrollEvent ( wxScrollEvent& event );
356
 
 
357
 
    void SetViewStart ( int index, bool adjust_sb );
358
 
    void RecheckHilighted ( int y );
359
 
 
360
 
    //void OnMouseUp ( wxMouseEvent& event );
361
 
 
362
 
    //void SetImagePaintFunction ( wxCustomPaintFunc paintfunc ) { m_paintFunc = paintfunc; }
363
 
 
364
 
protected:
365
 
 
366
 
    int             m_hilighted;
367
 
    int             m_itemHeight;
368
 
 
369
 
    // Scrolling related.
370
 
    wxScrollBar*    m_pScrollBar;
371
 
    int             m_clientWidth;
372
 
    int             m_viewStartY;
373
 
    int             m_viewStartIndex;
374
 
    int             m_sbWidth;
375
 
 
376
 
private:
377
 
    DECLARE_EVENT_TABLE()
378
 
};
379
 
 
380
 
// -----------------------------------------------------------------------
381
 
 
382
 
typedef wxSize (*wxCustomPaintFunc) ( wxDC&, const wxRect&, int, void* );
383
 
 
384
 
class WXDLLIMPEXP_CC wxCustomComboPopup;
385
 
class WXDLLIMPEXP_CC wxCustomComboItem;
386
 
class WXDLLIMPEXP_CC wxComboPopupDefaultList;
387
 
 
388
 
class WXDLLIMPEXP_CC wxCCustomComboBoxHandler : public wxCustomControlHandler
389
 
{
390
 
    friend class wxCCustomComboBox;
391
 
    friend class wxCustomComboPopup;
392
 
public:
393
 
    void Create ( wxCustomControl* pctrl, const wxString& value,
394
 
        const wxPoint& pos, const wxSize& sz );
395
 
 
396
 
    inline void SetControl ( wxCustomControl* pctrl )
397
 
    {
398
 
        wxCustomControlHandler::SetControl ( pctrl );
399
 
        m_btData.SetControl ( pctrl );
400
 
    }
401
 
 
402
 
    virtual void SetSelection ( const wxCustomComboItem& item ) = 0;
403
 
 
404
 
    void Draw ( wxDC& dc, const wxRect& rect, bool item_too );
405
 
 
406
 
    inline wxCustomComboPopup* GetPopupInstance () const
407
 
    {
408
 
        return m_listInstance;
409
 
    }
410
 
 
411
 
    virtual void OnSelect ( const wxCustomComboItem& item ) = 0;
412
 
 
413
 
    inline void IntOnSelect ( int index )
414
 
    {
415
 
        wxCustomComboListItem item(index);
416
 
        OnSelect (item);
417
 
    }
418
 
 
419
 
    virtual bool OnKeyEvent ( wxKeyEvent& event ) = 0;
420
 
 
421
 
    virtual wxCustomComboPopup* CreatePopup ( wxWindow* frame,
422
 
        const wxRect& ctrl_rect, wxCustomControl* ctrl ) = 0;
423
 
 
424
 
    virtual bool OnMouseEvent ( wxMouseEvent& event, wxCustomControlHandler* pdata );
425
 
 
426
 
    inline void Move ( int x, int y )
427
 
    {
428
 
        m_rect.x = x; m_rect.y = y;
429
 
        m_btData.Move ( x + m_rect.width - m_buttonWidth, y );
430
 
    }
431
 
    inline void SetSize ( int width, int height )
432
 
    {
433
 
        m_rect.width = width - m_buttonWidth;
434
 
        m_rect.height = height;
435
 
        m_btData.Move ( m_rect.x + width - m_buttonWidth, m_rect.y );
436
 
        m_btData.SetSize ( m_buttonWidth, height );
437
 
    }
438
 
 
439
 
    //inline const wxArrayPtrVoid& GetLabels() const { return m_labels; }
440
 
    inline wxCustomPaintFunc GetPaintFunc() const { return m_paintfunc; }
441
 
    inline void* GetPaintFuncCustomData() const { return m_paintfunc_customdata; }
442
 
    inline const wxSize& GetImageSize() const { return m_imageSize; }
443
 
    //inline int GetSelection() const { return m_selection; }
444
 
 
445
 
    inline void SetValue( const wxString& text ) { m_text = text; }
446
 
    inline const wxString& GetValue() const { return m_text; }
447
 
 
448
 
    inline wxCCustomButtonHandler* GetButtonData() { return &m_btData; }
449
 
 
450
 
    virtual ~wxCCustomComboBoxHandler();
451
 
 
452
 
protected:
453
 
 
454
 
    //int                     m_selection;
455
 
 
456
 
    int                     m_buttonWidth;
457
 
 
458
 
    wxSize                  m_imageSize; // size of custom image in the list
459
 
 
460
 
    wxString                m_text; // text currently shown
461
 
 
462
 
    //wxArrayPtrVoid          m_labels; // holds pointers to labels
463
 
 
464
 
    wxCCustomButtonHandler      m_btData;
465
 
 
466
 
    //wxCustomComboItem*      m_pItem;
467
 
 
468
 
    wxCustomComboPopup*     m_listInstance;
469
 
 
470
 
    wxCustomPaintFunc       m_paintfunc;
471
 
    void*                   m_paintfunc_customdata;
472
 
 
473
 
    unsigned char           m_prevMouseFocus; // used detect in which portion of control mouse is
474
 
 
475
 
};
476
 
 
477
 
// -----------------------------------------------------------------------
478
 
 
479
 
class WXDLLIMPEXP_CC wxCCustomComboBoxDefaultHandler : public wxCCustomComboBoxHandler
480
 
{
481
 
public:
482
 
    void Create ( wxCustomControl* pctrl, const wxString& value,
483
 
        const wxPoint& pos, const wxSize& sz,
484
 
        int n, const wxChar* choices[] );
485
 
 
486
 
    int Append( const wxString& str );
487
 
 
488
 
    virtual void SetSelection ( const wxCustomComboItem& item );
489
 
    virtual void OnSelect ( const wxCustomComboItem& item );
490
 
    virtual bool OnMouseEvent ( wxMouseEvent& event, wxCustomControlHandler* pdata );
491
 
    virtual bool OnKeyEvent ( wxKeyEvent& event );
492
 
    virtual wxCustomComboPopup* CreatePopup ( wxWindow* frame,
493
 
        const wxRect& ctrl_rect, wxCustomControl* ctrl );
494
 
 
495
 
    inline const wxArrayPtrVoid& GetLabels() const { return m_labels; }
496
 
    inline wxArrayPtrVoid& GetWritableLabels() { return m_labels; }
497
 
    inline int GetSelection() const { return m_selection; }
498
 
 
499
 
    virtual ~wxCCustomComboBoxDefaultHandler();
500
 
 
501
 
protected:
502
 
 
503
 
    int                     m_selection;
504
 
 
505
 
    wxArrayPtrVoid          m_labels; // Holds pointers to labels.
506
 
 
507
 
    wxArrayString           m_extraStrings; // Place extra appended strings here.
508
 
 
509
 
};
510
 
 
511
 
/** wxCustomControlManager's flags
512
 
*/
513
 
 
514
 
/** m_parent is wxScrolledWindow or derivative. */
515
 
#define wxCCM_FL_SCROLLEDWIN        0x0001
516
 
 
517
 
/** Notify for the event poller. */
518
 
#define wxCCM_FL_EVENTREADY         0x0002
519
 
 
520
 
/** If there is internal-to-control dragging going on. */
521
 
#define wxCCM_FL_DRAGGING           0x0004
522
 
 
523
 
/** When mouse cursor is actually inside mouse-focused control. */
524
 
#define wxCCM_FL_MOUSE_INSIDE       0x0008
525
 
 
526
 
/** Set by OnParentScrollEvent handler. */
527
 
#define wxCCM_FL_VIEWSTARTCHANGED   0x0010
528
 
 
529
 
/** Helper caret info. */
530
 
#define wxCCM_FL_CARETVISIBLE       0x0020
531
 
 
532
 
// -----------------------------------------------------------------------
533
 
 
534
 
/** \class wxCustomControls
535
 
    \ingroup classes
536
 
    \brief Static functions for drawing custom controls.
537
 
*/
538
 
class WXDLLIMPEXP_CC wxCustomControlManager
539
 
{
540
 
    friend class wxCustomControl;
541
 
    friend class wxCustomTextCtrlHandler;
542
 
    friend class wxCCustomTextCtrl;
543
 
    friend class wxCCustomButtonHandler;
544
 
    friend class wxCCustomButton;
545
 
    friend class wxCCustomComboBoxHandler;
546
 
    friend class wxCCustomComboBox;
547
 
public:
548
 
    
549
 
    wxCustomControlManager();
550
 
    wxCustomControlManager( wxWindow* parent );
551
 
    ~wxCustomControlManager();
552
 
 
553
 
    void AddChild ( wxCustomControl* child );
554
 
 
555
 
    void AddChildData ( wxCustomControlHandler* pdata );
556
 
 
557
 
    void AddEvent ( wxCustomControl* child, int eventtype );
558
 
 
559
 
    void ClosePopup ();
560
 
 
561
 
    void Create ( wxWindow* parent );
562
 
 
563
 
    /** When xxData needs to redraw the control in question, use this
564
 
        to create the necessary device context. Then DestroyDC must be
565
 
        used to delete it.
566
 
    */
567
 
    wxDC& CreateDC ( wxPoint* palignpt );
568
 
 
569
 
    /** Creates frame etc. for a popup.
570
 
    */
571
 
    wxWindow* CreatePopupParent() { return m_parent; }
572
 
 
573
 
    /** Black text on white background, centered vertically in the rect etc.
574
 
        state 0 = no background clearing, 1 = clear bg, 3 = selected, clearbg.
575
 
    */
576
 
    void CtrlWriteText ( wxDC& dc, const wxChar* text,
577
 
        const wxRect& rect, wxCustomControl* ctrl, int state );
578
 
 
579
 
    /** See CreateDC.*/
580
 
    void DestroyDC ( wxDC& dc );
581
 
 
582
 
    wxCustomControlHandler* FindDataByPosition ( int x, int y );
583
 
    wxCustomControl* FindWindowByPosition ( int x, int y );
584
 
 
585
 
    inline void ForceMouseLeave ( wxMouseEvent& event )
586
 
    {
587
 
        DoMouseLeave ( event, NULL, TRUE );
588
 
    }
589
 
 
590
 
    inline wxEvent& GetEvent ()
591
 
    {
592
 
        m_flags &= ~(wxCCM_FL_EVENTREADY);
593
 
        return *(&m_event);
594
 
    }
595
 
 
596
 
    inline wxPoint GetCaretPosition () const
597
 
    {
598
 
        wxPoint p = m_pCaret->GetPosition();
599
 
        //TranslatePositionToLogical ( &p.x, &p.y );
600
 
        return p;
601
 
    }
602
 
 
603
 
    inline long GetFlags () const { return m_flags; }
604
 
 
605
 
    inline wxWindow* GetPopup () const { return m_openPopup; }
606
 
 
607
 
    inline wxCustomControl* GetFocused () const { return m_ctrlKbFocus; }
608
 
    inline wxCustomControlHandler* GetMouseFocusedData () const { return m_dataMouseFocus; }
609
 
 
610
 
    inline wxWindow* GetWindow () const { return m_parent; }
611
 
 
612
 
    inline const wxColour& GetWindowColour () const { return *(&m_colBackground); }
613
 
    inline const wxColour& GetWindowTextColour () const { return *(&m_colText); }
614
 
    inline const wxColour& GetSelectionColour () const { return *(&m_colSelection); }
615
 
    inline const wxColour& GetSelectionTextColour () const { return *(&m_colSelectionText); }
616
 
    inline const wxColour& GetButtonColour () const { return *(&m_colButton); }
617
 
    inline const wxColour& GetButtonTextColour () const { return *(&m_colButtonText); }
618
 
 
619
 
    inline wxString& GetTempString() { return *(&m_tempStr1); }
620
 
 
621
 
    inline bool HasEvent () const { return (m_flags & wxCCM_FL_EVENTREADY)?TRUE:FALSE; }
622
 
 
623
 
    inline bool HasKbFocus () const { return (m_ctrlKbFocus!=NULL)?TRUE:FALSE; }
624
 
 
625
 
    inline bool HasMouseFocus () const { return (m_ctrlMouseFocus!=NULL)?TRUE:FALSE; }
626
 
 
627
 
    inline bool IsDragging () const { return (m_flags & wxCCM_FL_DRAGGING)?TRUE:FALSE; }
628
 
 
629
 
    void MoveCaret ( const wxRect& ctrl_rect, int x, int y );
630
 
    //void MoveCaretRelative ( int x, int y );
631
 
    void RepositionCaret ();
632
 
 
633
 
    /** Must be called when parent's focus changes. state = TRUE if focused.
634
 
    */
635
 
    void OnParentFocusChange ( bool state );
636
 
 
637
 
    /** Must be called when parent wxScrolledWindow gets scrolling event.
638
 
    */
639
 
    void OnParentScrollWinEvent ( wxScrollWinEvent &event );
640
 
 
641
 
    void OnParentScrollChange ();
642
 
 
643
 
    bool ProcessKeyboardEvent ( wxKeyEvent& event );
644
 
 
645
 
    /** Relays mouse event to appropriate managed custom control. If processes
646
 
        (i.e. returns TRUE),  event's coordinates have been converted to control's
647
 
        local space.
648
 
        \returns
649
 
        Returns TRUE if event was inside some ctrl (some events may actually be processed even in this case).
650
 
    */
651
 
    bool ProcessMouseEvent ( wxMouseEvent& event );
652
 
 
653
 
    void RemoveChild ( wxCustomControl* child );
654
 
 
655
 
    void RemoveFocus ( wxCustomControl* child );
656
 
 
657
 
    inline void ShowCaret ()
658
 
    {
659
 
        if ( m_pCaret && !(m_flags & wxCCM_FL_CARETVISIBLE) )
660
 
        {
661
 
            m_pCaret->Show ( TRUE );
662
 
            m_flags |= wxCCM_FL_CARETVISIBLE;
663
 
            //wxLogDebug ( wxT("ShowCaret( visible_after=%i )"), (int)m_pCaret->IsVisible() );
664
 
        }
665
 
    }
666
 
 
667
 
    inline void ShowCaretBalanced ()
668
 
    {
669
 
        m_pCaret->Show ( TRUE );
670
 
    }
671
 
 
672
 
    inline void HideCaretBalanced ()
673
 
    {
674
 
        m_pCaret->Show ( FALSE );
675
 
    }
676
 
 
677
 
    inline void HideCaret ()
678
 
    {
679
 
        if ( m_pCaret && ( m_flags & wxCCM_FL_CARETVISIBLE ) )
680
 
        {
681
 
            m_pCaret->Show ( FALSE );
682
 
            m_flags &= ~(wxCCM_FL_CARETVISIBLE);
683
 
            //wxLogDebug ( wxT("HideCaret( visible_after=%i )"), (int)m_pCaret->IsVisible() );
684
 
        }
685
 
    }
686
 
 
687
 
    inline bool IsCaretVisible () const
688
 
    {
689
 
        //if ( m_pCaret )
690
 
            return m_pCaret->IsVisible();
691
 
        //return FALSE;
692
 
    }
693
 
 
694
 
    void SetDoubleBuffer ( wxBitmap* buffer ) { m_bmpDoubleBuffer = buffer; }
695
 
 
696
 
    void SetFocus ( wxCustomControl* child );
697
 
 
698
 
    void SetFont ( const wxFont& font ) { m_font = font; }
699
 
 
700
 
    void SetPopup ( wxCustomComboPopup* popup );
701
 
 
702
 
    inline void StartDragging () { m_flags |= wxCCM_FL_DRAGGING; }
703
 
    
704
 
    inline void StopDragging () { m_flags &= ~(wxCCM_FL_DRAGGING); }
705
 
 
706
 
    /** Translates coordinate translation necessary for scrolled window.
707
 
    */
708
 
    void TranslatePositionToPhysical ( int* x, int* y ) const;
709
 
    void TranslatePositionToLogical ( int* x, int* y ) const;
710
 
 
711
 
protected:
712
 
 
713
 
    // returns index to first data of a control
714
 
    int GetControlsFirstData ( wxCustomControl* ctrl );
715
 
 
716
 
protected:
717
 
 
718
 
 
719
 
    wxWindow*               m_parent;
720
 
 
721
 
    wxBitmap*               m_bmpDoubleBuffer; // never owns; just borrows parent's, if available;
722
 
 
723
 
    //wxArrayPtrVoid          m_controls;
724
 
 
725
 
    wxArrayPtrVoid          m_handlers; // one control may comprise of more than one controldata
726
 
 
727
 
    wxCustomControl*    m_ctrlMouseFocus; // which control has mouse focus
728
 
    wxCustomControlHandler*    m_dataMouseFocus; // which controldata has mouse focus
729
 
    wxCustomControl*    m_ctrlKbFocus; // which control has keyboard focus
730
 
 
731
 
    wxCaret*                m_pCaret;
732
 
 
733
 
    wxPoint                 m_caretRelativePos; // caret x inside m_ctrlKbFocus
734
 
 
735
 
    wxColour                m_colBackground;
736
 
    wxColour                m_colText;
737
 
    wxColour                m_colSelection;
738
 
    wxColour                m_colSelectionText;
739
 
    wxColour                m_colButton;
740
 
    wxColour                m_colButtonText;
741
 
 
742
 
    wxFont                  m_font;
743
 
 
744
 
    wxCursor                m_cursorIBeam;
745
 
 
746
 
    wxString                m_tempStr1;
747
 
 
748
 
    long                    m_flags;
749
 
 
750
 
    wxCommandEvent          m_event;
751
 
 
752
 
#if wxCC_CORRECT_CONTROL_POSITION
753
 
    wxSize                  m_prevViewStart; // for wxScrolledWindow scroll management
754
 
#endif
755
 
 
756
 
    wxWindow*               m_openPopup;
757
 
 
758
 
    void DoMouseLeave ( wxMouseEvent& event, wxCustomControlHandler* newdata, bool force );
759
 
 
760
 
};
761
 
 
762
 
// -----------------------------------------------------------------------
763
 
 
764
 
#define wxCC_FL_KBFOCUS         0x0001
765
 
 
766
 
#define wxCC_FL_MOUSEFOCUS      0x0002 // When mouse is over the control and it is not dragging for another control
767
 
 
768
 
#define wxCC_FL_NEEDSCARET      0x0004
769
 
 
770
 
#define wxCC_FL_DRAWN           0x0008 // Set by drawing function
771
 
 
772
 
#define wxCC_FL_MODIFIED        0x0010 // May be needed internally by various controls/datas
773
 
 
774
 
#define wxCC_FL_REMOVED         0x0020 // Manager's RemoveChild already called on this.
775
 
 
776
 
#define wxCC_EXTRA_FLAG(N)      (1<<(16+N))
777
 
 
778
 
// -----------------------------------------------------------------------
779
 
 
780
 
void wxRendererNative_DrawButton (wxWindow* win, wxDC& dc, const wxRect& rect, int flags = wxUP );
781
 
 
782
 
// -----------------------------------------------------------------------
783
 
 
784
 
class WXDLLIMPEXP_CC wxCustomControl : public wxObject
785
 
{
786
 
        DECLARE_DYNAMIC_CLASS(wxCustomControl)
787
 
 
788
 
    friend class wxCustomControlManager;
789
 
    friend class wxCustomTextCtrlHandler;
790
 
    friend class wxCCustomButtonHandler;
791
 
    friend class wxCCustomComboBoxHandler;
792
 
public:
793
 
 
794
 
    wxCustomControl();
795
 
    wxCustomControl ( wxCustomControlManager* manager, wxWindowID id,
796
 
        const wxPoint& pos, const wxSize& size, long style = 0 );
797
 
    virtual ~wxCustomControl();
798
 
 
799
 
    virtual void DoMove ( int x, int y );
800
 
 
801
 
    inline const wxColour& GetBackgroundColour() const { return *(&m_manager->m_colBackground);}
802
 
 
803
 
    inline wxFont& GetFont () const { return *m_pFont; }
804
 
    inline int GetFontHeight () const { return m_fontHeight; }
805
 
 
806
 
    inline wxWindowID GetId () const { return m_id; }
807
 
 
808
 
    inline wxCustomControlManager* GetManager () const { return m_manager; }
809
 
 
810
 
    inline wxWindow* GetParent () const { return m_manager->m_parent; }
811
 
    
812
 
    inline wxPoint GetPosition () const { return wxPoint(m_rect.x,m_rect.y); }
813
 
    
814
 
    inline wxRect GetRect () const { return m_rect; }
815
 
    
816
 
    inline wxSize GetSize () const { return wxSize(m_rect.width,m_rect.height); }
817
 
 
818
 
    inline int GetX () const { return m_rect.x; }
819
 
    
820
 
    inline long GetWindowStyle () const { return m_windowStyle; }
821
 
 
822
 
    inline void Move ( const wxPoint& pos ) { DoMove (pos.x,pos.y); }
823
 
 
824
 
    inline void Move ( wxCoord x, wxCoord y ) { DoMove (x,y); }
825
 
 
826
 
    /** Called on keyboard focus.
827
 
    */
828
 
    virtual void OnFocus ( bool focused );
829
 
 
830
 
    /** Returns TRUE if processed.
831
 
    */
832
 
    virtual bool OnKeyEvent ( wxKeyEvent& event );
833
 
 
834
 
    /** entry is TRUE if mouse enters, FALSE if leaves.
835
 
    */
836
 
    virtual bool OnMouseFocus ( bool entry );
837
 
 
838
 
    virtual bool OnMouseEvent ( wxMouseEvent& event, wxCustomControlHandler* pdata );
839
 
 
840
 
    /** Draw control on parent. If dc is NULL, creates one. */
841
 
    void DrawPDC ( wxDC* dc = NULL );
842
 
 
843
 
    inline void Draw () { DrawPDC ( NULL ); }
844
 
 
845
 
    void Draw ( wxDC& dc );
846
 
 
847
 
    /** Draw control on dc. align is control position adjustment on dc (incase
848
 
        of a double-buffer, for example).
849
 
    */
850
 
    void Draw ( wxDC& dc, const wxPoint* align );
851
 
 
852
 
    /**
853
 
    Draws control in to the dc.
854
 
    \remarks
855
 
    - On both entry and exit, nothing can be assumed of current Pen or Brush.
856
 
    - May set clipping region to the control rectangle. If so, calls
857
 
      DestroyClippingRegion before exiting.
858
 
    */
859
 
    virtual void DoDraw ( wxDC& dc, const wxRect& rect );
860
 
 
861
 
    virtual void DoSetSize ( int width, int height );
862
 
 
863
 
    wxCommandEvent& GetEvent () const { return *(&m_manager->m_event); }
864
 
 
865
 
    inline bool HasFocus () const { return (m_manager->m_ctrlKbFocus == this )?TRUE:FALSE; }
866
 
 
867
 
    inline void Refresh ( bool = FALSE, const wxRect* = (const wxRect*) NULL ) { Draw(); }
868
 
 
869
 
    inline void RemoveFocus ()
870
 
    {
871
 
        m_manager->RemoveFocus ( this );
872
 
    }
873
 
 
874
 
    inline void ResetFont () { m_pFont = &m_manager->m_font; }
875
 
 
876
 
    inline void SetFocus ()
877
 
    {
878
 
        m_manager->SetFocus ( this );
879
 
    }
880
 
 
881
 
    inline void SetFocusFromKbd ()
882
 
    {
883
 
        m_manager->SetFocus ( this );
884
 
    }
885
 
 
886
 
    /** Sets font for the control.
887
 
        \remarks
888
 
        Does not copy the font for itself, just pointer to it.
889
 
    */
890
 
    virtual void SetFont ( wxFont& font, wxDC* pdc = NULL );
891
 
 
892
 
    inline void SetSize ( int x, int y, int width, int height )
893
 
    {
894
 
        DoMove ( x, y );
895
 
        DoSetSize ( width, height );
896
 
    }
897
 
 
898
 
    inline void SetSize ( const wxRect& rect )
899
 
    {
900
 
        DoMove ( rect.x, rect.y );
901
 
        DoSetSize ( rect.width, rect.height );
902
 
    }
903
 
 
904
 
    inline void SetSize ( int width, int height )
905
 
    { 
906
 
        DoSetSize ( width, height );
907
 
    }
908
 
 
909
 
    inline void SetSize ( const wxSize& size )
910
 
    {
911
 
        DoSetSize ( size.x, size.y );
912
 
    }
913
 
 
914
 
    inline void Show() { }
915
 
 
916
 
protected:
917
 
    wxCustomControlManager  *m_manager;
918
 
    wxFont                  *m_pFont;
919
 
    wxRect                  m_rect;
920
 
    //wxSize                  m_imageSize; // Size of image in front of the control
921
 
    wxWindowID              m_id;
922
 
    long                    m_windowStyle;
923
 
    wxUint32                m_flags;
924
 
    int                     m_fontHeight;
925
 
    int                     m_xSplit; // splitting the control into two parts (wxCCustomComboBox needs)
926
 
    unsigned char           m_curPart; // which part of the control is focused? (only if m_xSplit)
927
 
};
928
 
 
929
 
// -----------------------------------------------------------------------
930
 
 
931
 
inline bool wxCustomControlHandler::IsMouseFocused() const
932
 
{
933
 
    return m_control->GetManager()->GetMouseFocusedData() == this;
934
 
}
935
 
 
936
 
// -----------------------------------------------------------------------
937
 
 
938
 
class WXDLLIMPEXP_CC wxCCustomTextCtrl : public wxCustomControl
939
 
{
940
 
        DECLARE_DYNAMIC_CLASS(wxCCustomTextCtrl)
941
 
 
942
 
public:
943
 
 
944
 
    wxCCustomTextCtrl () : wxCustomControl() { }
945
 
 
946
 
    wxCCustomTextCtrl ( wxCustomControlManager* manager, wxWindowID id, const wxString& value = wxEmptyString,
947
 
        const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
948
 
        long style = 0 );
949
 
 
950
 
    virtual ~wxCCustomTextCtrl();
951
 
 
952
 
    inline wxString GetValue() const { return m_data.GetValue(); }
953
 
 
954
 
    inline void SetSelection(long from, long to)
955
 
    {
956
 
        if ( m_data.SetSelection(from,to) )
957
 
            Draw ();
958
 
    }
959
 
 
960
 
    void SetValue ( const wxString& value );
961
 
 
962
 
    inline void SetInsertionPoint ( long pos, long first_visible = -1 )
963
 
    {
964
 
        if ( m_data.SetInsertionPoint (pos,first_visible) )
965
 
            Draw ();
966
 
    }
967
 
 
968
 
    virtual void DoDraw ( wxDC& dc, const wxRect& rect );
969
 
    virtual void DoMove ( int x, int y );
970
 
    virtual void DoSetSize ( int width, int height );
971
 
    virtual void OnFocus ( bool focused );
972
 
    virtual bool OnKeyEvent ( wxKeyEvent& event );
973
 
    virtual bool OnMouseFocus ( bool entry );
974
 
    virtual bool OnMouseEvent ( wxMouseEvent& event, wxCustomControlHandler* pdata );
975
 
    virtual void SetFont ( wxFont& font, wxDC* pdc );
976
 
 
977
 
protected:
978
 
    wxCustomTextCtrlHandler    m_data;
979
 
};
980
 
 
981
 
// -----------------------------------------------------------------------
982
 
 
983
 
//#define wxCC_BT_DOWN    wxCC_EXTRA_FLAG(0)
984
 
 
985
 
class WXDLLIMPEXP_CC wxCCustomButton : public wxCustomControl
986
 
{
987
 
        DECLARE_DYNAMIC_CLASS(wxCCustomButton)
988
 
 
989
 
public:
990
 
 
991
 
    wxCCustomButton () : wxCustomControl() { }
992
 
 
993
 
    wxCCustomButton ( wxCustomControlManager* manager, wxWindowID id, const wxChar* label,
994
 
        const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize );
995
 
    virtual ~wxCCustomButton();
996
 
 
997
 
    inline void SetLabel ( const wxChar* label ) { m_data.m_label = label; }
998
 
 
999
 
    virtual void DoDraw ( wxDC& dc, const wxRect& rect );
1000
 
    virtual void DoMove ( int x, int y );
1001
 
    virtual void DoSetSize ( int width, int height );
1002
 
    virtual bool OnKeyEvent ( wxKeyEvent& event );
1003
 
    virtual bool OnMouseFocus ( bool entry );
1004
 
    virtual bool OnMouseEvent ( wxMouseEvent& event, wxCustomControlHandler* pdata );
1005
 
    //virtual void SetFont ( wxFont& font );
1006
 
 
1007
 
protected:
1008
 
    wxCCustomButtonHandler      m_data;
1009
 
};
1010
 
 
1011
 
// -----------------------------------------------------------------------
1012
 
 
1013
 
#define wxCH_CC_DOUBLE_CLICK_CYCLES     0x0010 // double-clicking cycles the selection
1014
 
#define wxCH_CC_IMAGE_EXTENDS           0x0020 // image is drawn outside in non-popup portion
1015
 
#define wxCH_CC_DROPDOWN_ANCHOR_RIGHT   0x0040 // anchor drop-down to right edge of parent window.
1016
 
 
1017
 
class WXDLLIMPEXP_CC wxCCustomComboBox : public wxCustomControl
1018
 
{
1019
 
        DECLARE_DYNAMIC_CLASS(wxCCustomComboBox)
1020
 
 
1021
 
public:
1022
 
 
1023
 
    wxCCustomComboBox () : wxCustomControl() { }
1024
 
 
1025
 
    wxCCustomComboBox ( wxCustomControlManager* manager, wxWindowID id,
1026
 
        const wxString& value = wxEmptyString,
1027
 
        const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
1028
 
        int n = 0, const wxChar* choices[] = NULL, long style = 0,
1029
 
        const wxSize& imagesize = wxDefaultSize );
1030
 
    virtual ~wxCCustomComboBox();
1031
 
 
1032
 
    inline int Append( const wxString& str )
1033
 
    {
1034
 
        return ((wxCCustomComboBoxDefaultHandler*)m_chData)->Append( str );
1035
 
    }
1036
 
 
1037
 
    inline wxWindow* GetPopupInstance() const { return m_chData->GetPopupInstance(); }
1038
 
 
1039
 
    inline int GetSelection () const { return ((wxCCustomComboBoxDefaultHandler*)m_chData)->GetSelection(); }
1040
 
 
1041
 
    inline const wxString& GetValue () const
1042
 
    {
1043
 
        return m_chData->m_text;
1044
 
    }
1045
 
 
1046
 
    void SetSelection ( int n );
1047
 
 
1048
 
    inline void SetImagePaintFunction ( wxCustomPaintFunc paintfunc, void* userdata )
1049
 
    {
1050
 
        m_chData->m_paintfunc = paintfunc;
1051
 
        m_chData->m_paintfunc_customdata = userdata;
1052
 
    }
1053
 
 
1054
 
    virtual void DoDraw ( wxDC& dc, const wxRect& rect );
1055
 
    virtual bool OnKeyEvent ( wxKeyEvent& event );
1056
 
    virtual bool OnMouseFocus ( bool entry );
1057
 
    virtual bool OnMouseEvent ( wxMouseEvent& event, wxCustomControlHandler* pdata );
1058
 
    virtual void DoMove ( int x, int y );
1059
 
    virtual void DoSetSize ( int width, int height );
1060
 
 
1061
 
    inline void SetValue ( const wxString& text )
1062
 
    {
1063
 
        m_chData->SetValue(text);
1064
 
        Draw();
1065
 
    }
1066
 
 
1067
 
    inline const wxString& SetValue () const
1068
 
    {
1069
 
        return m_chData->GetValue();
1070
 
    }
1071
 
 
1072
 
protected:
1073
 
    wxCCustomComboBoxHandler*    m_chData;
1074
 
};
1075
 
 
1076
 
class WXDLLIMPEXP_CC wxCCustomChoice : public wxCCustomComboBox
1077
 
{
1078
 
        DECLARE_DYNAMIC_CLASS(wxCCustomChoice)
1079
 
 
1080
 
public:
1081
 
 
1082
 
    wxCCustomChoice () : wxCCustomComboBox() { }
1083
 
 
1084
 
    wxCCustomChoice ( wxCustomControlManager* manager, wxWindowID id,
1085
 
        const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
1086
 
        int n = 0, const wxChar* choices[] = NULL, long style = 0,
1087
 
        const wxSize& imagesize = wxDefaultSize );
1088
 
    virtual ~wxCCustomChoice();
1089
 
};
1090
 
 
1091
 
// -----------------------------------------------------------------------
1092
 
 
1093
 
#endif // wxPG_USE_CUSTOM_CONTROLS
1094
 
 
1095
 
#if wxPG_USE_GENERIC_TEXTCTRL
1096
 
 
1097
 
#define wxGTextCtrlBase wxControl
1098
 
 
1099
 
class WXDLLIMPEXP_CC wxGenericTextCtrl : public wxGTextCtrlBase
1100
 
{
1101
 
public:
1102
 
    // creation
1103
 
    // --------
1104
 
 
1105
 
    wxGenericTextCtrl() { Init(); }
1106
 
    wxGenericTextCtrl(wxWindow *parent, wxWindowID id,
1107
 
                      const wxString& value = wxEmptyString,
1108
 
                      const wxPoint& pos = wxDefaultPosition,
1109
 
                      const wxSize& size = wxDefaultSize,
1110
 
                      long style = 0,
1111
 
                      const wxValidator& validator = wxDefaultValidator,
1112
 
                      const wxString& name = wxTextCtrlNameStr)
1113
 
    {
1114
 
        Init();
1115
 
 
1116
 
        Create(parent, id, value, pos, size, style, validator, name);
1117
 
    }
1118
 
    ~wxGenericTextCtrl();
1119
 
 
1120
 
    bool Create(wxWindow *parent, wxWindowID id,
1121
 
                const wxString& value = wxEmptyString,
1122
 
                const wxPoint& pos = wxDefaultPosition,
1123
 
                const wxSize& size = wxDefaultSize,
1124
 
                long style = 0,
1125
 
                const wxValidator& validator = wxDefaultValidator,
1126
 
                const wxString& name = wxTextCtrlNameStr);
1127
 
 
1128
 
    // implement base class pure virtuals
1129
 
    // ----------------------------------
1130
 
    virtual wxString GetValue() const;
1131
 
    virtual void SetValue(const wxString& value);
1132
 
 
1133
 
    virtual wxString GetRange(long from, long to) const;
1134
 
 
1135
 
    virtual int GetLineLength(long lineNo) const;
1136
 
    virtual wxString GetLineText(long lineNo) const;
1137
 
    virtual int GetNumberOfLines() const;
1138
 
 
1139
 
    virtual bool IsModified() const;
1140
 
    virtual bool IsEditable() const;
1141
 
 
1142
 
    virtual void GetSelection(long* from, long* to) const;
1143
 
 
1144
 
    // operations
1145
 
    // ----------
1146
 
    virtual void Remove(long from, long to);
1147
 
 
1148
 
    // special
1149
 
    void DispatchEvent( int evtId );
1150
 
    bool SetInsertionPoint (long pos,
1151
 
                            long first_visible = -1);
1152
 
    void DeleteSelection ();
1153
 
    bool SetSelection ( long from, long to );
1154
 
 
1155
 
    inline wxTextPos GetLastPosition() const
1156
 
    {
1157
 
        return m_text.length();
1158
 
    }
1159
 
 
1160
 
    // Standard wxWindow virtual overrides
1161
 
    virtual void SetFocus();
1162
 
 
1163
 
protected:
1164
 
 
1165
 
    int HitTest ( wxCoord x, int* pCol );
1166
 
    void RecalculateMetrics();
1167
 
 
1168
 
    // common part of all ctors
1169
 
    void Init();
1170
 
 
1171
 
    wxString        m_text;
1172
 
    wxCaret*        m_pCaret;
1173
 
    unsigned int    m_position;
1174
 
    unsigned int    m_scrollPosition;
1175
 
    int             m_selStart;
1176
 
    int             m_selEnd;
1177
 
    int             m_itemButDown; // dragging centers around this
1178
 
    int             m_fontHeight;
1179
 
 
1180
 
    bool            m_isModified;
1181
 
    bool            m_isEditable;
1182
 
 
1183
 
    wxArrayInt      m_arrExtents; // cached array of text extents
1184
 
 
1185
 
    //int UpdateExtentCache ( wxString& tempstr, size_t index );
1186
 
 
1187
 
    // event handlers
1188
 
    void OnKeyEvent ( wxKeyEvent& event );
1189
 
    void OnMouseEvent ( wxMouseEvent& event );
1190
 
    void OnPaint ( wxPaintEvent& event );
1191
 
 
1192
 
/*    inline void ShowCaret ()
1193
 
    {
1194
 
        if ( m_pCaret && !(m_flags & wxCCM_FL_CARETVISIBLE) )
1195
 
        {
1196
 
            m_pCaret->Show ( TRUE );
1197
 
            m_flags |= wxCCM_FL_CARETVISIBLE;
1198
 
            //wxLogDebug ( wxT("ShowCaret( visible_after=%i )"), (int)m_pCaret->IsVisible() );
1199
 
        }
1200
 
    }*/
1201
 
 
1202
 
    inline void ShowCaretBalanced ()
1203
 
    {
1204
 
        m_pCaret->Show ( TRUE );
1205
 
    }
1206
 
 
1207
 
    inline void HideCaretBalanced ()
1208
 
    {
1209
 
        m_pCaret->Show ( FALSE );
1210
 
    }
1211
 
 
1212
 
    //void MoveCaret ( int x, int y );
1213
 
 
1214
 
/*    inline void HideCaret ()
1215
 
    {
1216
 
        if ( m_pCaret && ( m_flags & wxCCM_FL_CARETVISIBLE ) )
1217
 
        {
1218
 
            m_pCaret->Show ( FALSE );
1219
 
            m_flags &= ~(wxCCM_FL_CARETVISIBLE);
1220
 
            //wxLogDebug ( wxT("HideCaret( visible_after=%i )"), (int)m_pCaret->IsVisible() );
1221
 
        }
1222
 
    }*/
1223
 
 
1224
 
    inline bool IsCaretVisible () const
1225
 
    {
1226
 
        //if ( m_pCaret )
1227
 
            return m_pCaret->IsVisible();
1228
 
        //return FALSE;
1229
 
    }
1230
 
 
1231
 
    /*
1232
 
    // editing
1233
 
    virtual void Clear();
1234
 
    virtual void Replace(long from, long to, const wxString& value);
1235
 
    virtual void Remove(long from, long to);
1236
 
 
1237
 
    // load the controls contents from the file
1238
 
    virtual bool LoadFile(const wxString& file);
1239
 
 
1240
 
    // clears the dirty flag
1241
 
    virtual void MarkDirty();
1242
 
    virtual void DiscardEdits();
1243
 
 
1244
 
    virtual void SetMaxLength(unsigned long len);
1245
 
 
1246
 
    // writing text inserts it at the current position, appending always
1247
 
    // inserts it at the end
1248
 
    virtual void WriteText(const wxString& text);
1249
 
    virtual void AppendText(const wxString& text);
1250
 
 
1251
 
#ifdef __WIN32__
1252
 
    virtual bool EmulateKeyPress(const wxKeyEvent& event);
1253
 
#endif // __WIN32__
1254
 
 
1255
 
#if wxUSE_RICHEDIT
1256
 
    // apply text attribute to the range of text (only works with richedit
1257
 
    // controls)
1258
 
    virtual bool SetStyle(long start, long end, const wxTextAttr& style);
1259
 
    virtual bool SetDefaultStyle(const wxTextAttr& style);
1260
 
    virtual bool GetStyle(long position, wxTextAttr& style);
1261
 
#endif // wxUSE_RICHEDIT
1262
 
 
1263
 
    // translate between the position (which is just an index in the text ctrl
1264
 
    // considering all its contents as a single strings) and (x, y) coordinates
1265
 
    // which represent column and line.
1266
 
    virtual long XYToPosition(long x, long y) const;
1267
 
    virtual bool PositionToXY(long pos, long *x, long *y) const;
1268
 
 
1269
 
    virtual void ShowPosition(long pos);
1270
 
    virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long *pos) const;
1271
 
    virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt,
1272
 
                                            wxTextCoord *col,
1273
 
                                            wxTextCoord *row) const
1274
 
    {
1275
 
        return wxTextCtrlBase::HitTest(pt, col, row);
1276
 
    }
1277
 
 
1278
 
    // Clipboard operations
1279
 
    virtual void Copy();
1280
 
    virtual void Cut();
1281
 
    virtual void Paste();
1282
 
 
1283
 
    virtual bool CanCopy() const;
1284
 
    virtual bool CanCut() const;
1285
 
    virtual bool CanPaste() const;
1286
 
 
1287
 
    // Undo/redo
1288
 
    virtual void Undo();
1289
 
    virtual void Redo();
1290
 
 
1291
 
    virtual bool CanUndo() const;
1292
 
    virtual bool CanRedo() const;
1293
 
 
1294
 
    // Insertion point
1295
 
    virtual void SetInsertionPoint(long pos);
1296
 
    virtual void SetInsertionPointEnd();
1297
 
    virtual long GetInsertionPoint() const;
1298
 
    virtual wxTextPos GetLastPosition() const;
1299
 
 
1300
 
    virtual void SetSelection(long from, long to);
1301
 
    virtual void SetEditable(bool editable);
1302
 
 
1303
 
    // Caret handling (Windows only)
1304
 
 
1305
 
    bool ShowNativeCaret(bool show = true);
1306
 
    bool HideNativeCaret() { return ShowNativeCaret(false); }
1307
 
 
1308
 
    // Implementation from now on
1309
 
    // --------------------------
1310
 
 
1311
 
    virtual void SetWindowStyleFlag(long style);
1312
 
 
1313
 
    virtual void Command(wxCommandEvent& event);
1314
 
    virtual bool MSWCommand(WXUINT param, WXWORD id);
1315
 
    virtual WXHBRUSH MSWControlColor(WXHDC hDC);
1316
 
 
1317
 
#if wxUSE_RICHEDIT
1318
 
    virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
1319
 
 
1320
 
    int GetRichVersion() const { return m_verRichEdit; }
1321
 
    bool IsRich() const { return m_verRichEdit != 0; }
1322
 
 
1323
 
    // rich edit controls are not compatible with normal ones and wem ust set
1324
 
    // the colours for them otherwise
1325
 
    virtual bool SetBackgroundColour(const wxColour& colour);
1326
 
    virtual bool SetForegroundColour(const wxColour& colour);
1327
 
#endif // wxUSE_RICHEDIT
1328
 
 
1329
 
    virtual void AdoptAttributesFromHWND();
1330
 
 
1331
 
    virtual bool AcceptsFocus() const;
1332
 
 
1333
 
    // callbacks
1334
 
    void OnDropFiles(wxDropFilesEvent& event);
1335
 
    void OnChar(wxKeyEvent& event); // Process 'enter' if required
1336
 
 
1337
 
    void OnCut(wxCommandEvent& event);
1338
 
    void OnCopy(wxCommandEvent& event);
1339
 
    void OnPaste(wxCommandEvent& event);
1340
 
    void OnUndo(wxCommandEvent& event);
1341
 
    void OnRedo(wxCommandEvent& event);
1342
 
    void OnDelete(wxCommandEvent& event);
1343
 
    void OnSelectAll(wxCommandEvent& event);
1344
 
 
1345
 
    void OnUpdateCut(wxUpdateUIEvent& event);
1346
 
    void OnUpdateCopy(wxUpdateUIEvent& event);
1347
 
    void OnUpdatePaste(wxUpdateUIEvent& event);
1348
 
    void OnUpdateUndo(wxUpdateUIEvent& event);
1349
 
    void OnUpdateRedo(wxUpdateUIEvent& event);
1350
 
    void OnUpdateDelete(wxUpdateUIEvent& event);
1351
 
    void OnUpdateSelectAll(wxUpdateUIEvent& event);
1352
 
 
1353
 
    // Show a context menu for Rich Edit controls (the standard
1354
 
    // EDIT control has one already)
1355
 
    void OnContextMenu(wxContextMenuEvent& event);
1356
 
 
1357
 
    // be sure the caret remains invisible if the user
1358
 
    // called HideNativeCaret() before
1359
 
    void OnSetFocus(wxFocusEvent& event);
1360
 
 
1361
 
protected:
1362
 
 
1363
 
    // intercept WM_GETDLGCODE
1364
 
    virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
1365
 
 
1366
 
    // call this to increase the size limit (will do nothing if the current
1367
 
    // limit is big enough)
1368
 
    //
1369
 
    // returns true if we increased the limit to allow entering more text,
1370
 
    // false if we hit the limit set by SetMaxLength() and so didn't change it
1371
 
    bool AdjustSpaceLimit();
1372
 
 
1373
 
#if wxUSE_RICHEDIT && (!wxUSE_UNICODE || wxUSE_UNICODE_MSLU)
1374
 
    // replace the selection or the entire control contents with the given text
1375
 
    // in the specified encoding
1376
 
    bool StreamIn(const wxString& value, wxFontEncoding encoding, bool selOnly);
1377
 
 
1378
 
    // get the contents of the control out as text in the given encoding
1379
 
    wxString StreamOut(wxFontEncoding encoding, bool selOnly = false) const;
1380
 
#endif // wxUSE_RICHEDIT
1381
 
 
1382
 
    // replace the contents of the selection or of the entire control with the
1383
 
    // given text
1384
 
    void DoWriteText(const wxString& text, bool selectionOnly = true);
1385
 
 
1386
 
    // set the selection possibly without scrolling the caret into view
1387
 
    void DoSetSelection(long from, long to, bool scrollCaret = true);
1388
 
 
1389
 
    // return true if there is a non empty selection in the control
1390
 
    bool HasSelection() const;
1391
 
 
1392
 
    // get the length of the line containing the character at the given
1393
 
    // position
1394
 
    long GetLengthOfLineContainingPos(long pos) const;
1395
 
 
1396
 
    // send TEXT_UPDATED event, return true if it was handled, false otherwise
1397
 
    bool SendUpdateEvent();
1398
 
 
1399
 
    // override some base class virtuals
1400
 
    virtual bool MSWShouldPreProcessMessage(WXMSG* pMsg);
1401
 
    virtual wxSize DoGetBestSize() const;
1402
 
 
1403
 
    virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
1404
 
 
1405
 
#if wxUSE_RICHEDIT
1406
 
    // we're using RICHEDIT (and not simple EDIT) control if this field is not
1407
 
    // 0, it also gives the version of the RICHEDIT control being used (1, 2 or
1408
 
    // 3 so far)
1409
 
    int m_verRichEdit;
1410
 
#endif // wxUSE_RICHEDIT
1411
 
 
1412
 
    // number of EN_UPDATE events sent by Windows when we change the controls
1413
 
    // text ourselves: we want this to be exactly 1
1414
 
    int m_updatesCount;
1415
 
 
1416
 
    virtual wxVisualAttributes GetDefaultAttributes() const;
1417
 
 
1418
 
    wxMenu* m_privateContextMenu;
1419
 
 
1420
 
    bool m_isNativeCaretShown;
1421
 
*/
1422
 
 
1423
 
private:
1424
 
    DECLARE_EVENT_TABLE()
1425
 
    DECLARE_DYNAMIC_CLASS_NO_COPY(wxGenericTextCtrl)
1426
 
};
1427
 
 
1428
 
#endif
1429
 
 
1430
 
//
1431
 
// Undefine macros that are not needed outside library source files
1432
 
//
1433
 
#ifndef __wxCCM_SOURCE_FILE__
1434
 
# undef WXDLLIMPEXP_CC
1435
 
#endif
1436
 
 
1437
 
#endif // __WX_CUSTCTRL_H__