1 /////////////////////////////////////////////////////////////////////////////
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "textctrl.h"
21 #include <sys/types.h>
30 #include "wx/button.h"
31 #include "wx/toplevel.h"
32 #include "wx/textctrl.h"
33 #include "wx/notebook.h"
34 #include "wx/tabctrl.h"
35 #include "wx/settings.h"
36 #include "wx/filefn.h"
39 #if defined(__BORLANDC__) && !defined(__WIN32__)
41 #elif !defined(__MWERKS__) && !defined(__GNUWIN32) && !defined(__DARWIN__)
48 #include <MacTextEditor.h>
49 #include "ATSUnicode.h"
50 #include "TextCommon.h"
51 #include "TextEncodingConverter.h"
52 #include "wx/mac/uma.h"
54 #define TE_UNLIMITED_LENGTH 0xFFFFFFFFUL
56 extern wxApp
*wxTheApp
;
58 // CS:TODO we still have a problem getting properly at the text events of a control because under Carbon
59 // the MLTE engine registers itself for the key events thus the normal flow never occurs, the only measure for the
60 // moment is to avoid setting the true focus on the control, the proper solution at the end would be to have
61 // an alternate path for carbon key events that routes automatically into the same wx flow of events
63 #include "MacTextEditor.h"
67 /* kmUPTextPart is the part code we return to indicate the user has clicked
68 in the text area of our control */
69 #define kmUPTextPart 1
71 /* kmUPScrollPart is the part code we return to indicate the user has clicked
72 in the scroll bar part of the control. */
73 #define kmUPScrollPart 2
76 /* routines for using existing user pane controls.
77 These routines are useful for cases where you would like to use an
78 existing user pane control in, say, a dialog window as a scrolling
81 /* mUPOpenControl initializes a user pane control so it will be drawn
82 and will behave as a scrolling text edit field inside of a window.
83 This routine performs all of the initialization steps necessary,
84 except it does not create the user pane control itself. theControl
85 should refer to a user pane control that you have either created
86 yourself or extracted from a dialog's control heirarchy using
87 the GetDialogItemAsControl routine. */
88 OSStatus
mUPOpenControl(ControlHandle theControl
, long wxStyle
);
90 /* Utility Routines */
96 /* kUserClickedToFocusPart is a part code we pass to the SetKeyboardFocus
97 routine. In our focus switching routine this part code is understood
98 as meaning 'the user has clicked in the control and we need to switch
99 the current focus to ourselves before we can continue'. */
100 #define kUserClickedToFocusPart 100
103 /* kmUPClickScrollDelayTicks is a time measurement in ticks used to
104 slow the speed of 'auto scrolling' inside of our clickloop routine.
105 This value prevents the text from wizzzzzing by while the mouse
106 is being held down inside of the text area. */
107 #define kmUPClickScrollDelayTicks 3
110 /* STPTextPaneVars is a structure used for storing the the mUP Control's
111 internal variables and state information. A handle to this record is
112 stored in the pane control's reference value field using the
113 SetControlReference routine. */
116 /* OS records referenced */
117 TXNObject fTXNRec
; /* the txn record */
118 TXNFrameID fTXNFrame
; /* the txn frame ID */
119 ControlHandle fUserPaneRec
; /* handle to the user pane control */
120 WindowPtr fOwner
; /* window containing control */
121 GrafPtr fDrawingEnvironment
; /* grafport where control is drawn */
123 Boolean fInFocus
; /* true while the focus rect is drawn around the control */
124 Boolean fIsActive
; /* true while the control is drawn in the active state */
125 Boolean fTEActive
; /* reflects the activation state of the text edit record */
126 Boolean fInDialogWindow
; /* true if displayed in a dialog window */
127 /* calculated locations */
128 Rect fRTextArea
; /* area where the text is drawn */
129 Rect fRFocusOutline
; /* rectangle used to draw the focus box */
130 Rect fRTextOutline
; /* rectangle used to draw the border */
131 RgnHandle fTextBackgroundRgn
; /* background region for the text, erased before calling TEUpdate */
132 /* our focus advance override routine */
133 EventHandlerUPP handlerUPP
;
134 EventHandlerRef handlerRef
;
141 /* Univerals Procedure Pointer variables used by the
142 mUP Control. These variables are set up
143 the first time that mUPOpenControl is called. */
144 ControlUserPaneDrawUPP gTPDrawProc
= NULL
;
145 ControlUserPaneHitTestUPP gTPHitProc
= NULL
;
146 ControlUserPaneTrackingUPP gTPTrackProc
= NULL
;
147 ControlUserPaneIdleUPP gTPIdleProc
= NULL
;
148 ControlUserPaneKeyDownUPP gTPKeyProc
= NULL
;
149 ControlUserPaneActivateUPP gTPActivateProc
= NULL
;
150 ControlUserPaneFocusUPP gTPFocusProc
= NULL
;
152 /* TPActivatePaneText activates or deactivates the text edit record
153 according to the value of setActive. The primary purpose of this
154 routine is to ensure each call is only made once. */
155 static void TPActivatePaneText(STPTextPaneVars
**tpvars
, Boolean setActive
) {
156 STPTextPaneVars
*varsp
;
158 if (varsp
->fTEActive
!= setActive
) {
160 varsp
->fTEActive
= setActive
;
162 TXNActivate(varsp
->fTXNRec
, varsp
->fTXNFrame
, varsp
->fTEActive
);
165 TXNFocus( varsp
->fTXNRec
, varsp
->fTEActive
);
170 /* TPFocusPaneText set the focus state for the text record. */
171 static void TPFocusPaneText(STPTextPaneVars
**tpvars
, Boolean setFocus
) {
172 STPTextPaneVars
*varsp
;
174 if (varsp
->fInFocus
!= setFocus
) {
175 varsp
->fInFocus
= setFocus
;
176 TXNFocus( varsp
->fTXNRec
, varsp
->fInFocus
);
181 /* TPPaneDrawProc is called to redraw the control and for update events
182 referring to the control. This routine erases the text area's background,
183 and redraws the text. This routine assumes the scroll bar has been
184 redrawn by a call to DrawControls. */
185 static pascal void TPPaneDrawProc(ControlRef theControl
, ControlPartCode thePart
) {
186 STPTextPaneVars
**tpvars
, *varsp
;
189 /* set up our globals */
191 tpvars
= (STPTextPaneVars
**) GetControlReference(theControl
);
192 if (tpvars
!= NULL
) {
193 state
= HGetState((Handle
) tpvars
);
194 HLock((Handle
) tpvars
);
197 /* save the drawing state */
198 SetPort((**tpvars
).fDrawingEnvironment
);
199 /* verify our boundary */
200 GetControlBounds(theControl
, &bounds
);
201 if ( ! EqualRect(&bounds
, &varsp
->fRFocusOutline
) ) {
202 // scrollbar is on the border, we add one
203 Rect oldbounds
= varsp
->fRFocusOutline
;
204 InsetRect( &oldbounds
, -1 , -1 ) ;
206 InvalWindowRect( GetControlOwner( theControl
) , &oldbounds
) ;
207 SetRect(&varsp
->fRFocusOutline
, bounds
.left
, bounds
.top
, bounds
.right
, bounds
.bottom
);
208 SetRect(&varsp
->fRTextOutline
, bounds
.left
, bounds
.top
, bounds
.right
, bounds
.bottom
);
209 SetRect(&varsp
->fRTextArea
, bounds
.left
+ 2 , bounds
.top
+ (varsp
->fMultiline
? 0 : 2) ,
210 bounds
.right
- (varsp
->fMultiline
? 0 : 2), bounds
.bottom
- (varsp
->fMultiline
? 0 : 2));
211 RectRgn(varsp
->fTextBackgroundRgn
, &varsp
->fRTextOutline
);
212 TXNSetFrameBounds( varsp
->fTXNRec
, varsp
->fRTextArea
.top
, varsp
->fRTextArea
.left
,
213 varsp
->fRTextArea
.bottom
, varsp
->fRTextArea
.right
, varsp
->fTXNFrame
);
216 /* update the text region */
217 RGBColor white
= { 65535 , 65535 , 65535 } ;
218 RGBBackColor( &white
) ;
219 EraseRgn(varsp
->fTextBackgroundRgn
);
220 TXNDraw(varsp
->fTXNRec
, NULL
);
221 /* restore the drawing environment */
222 /* draw the text frame and focus frame (if necessary) */
223 DrawThemeEditTextFrame(&varsp
->fRTextOutline
, varsp
->fIsActive
? kThemeStateActive
: kThemeStateInactive
);
224 if ((**tpvars
).fIsActive
&& varsp
->fInFocus
) DrawThemeFocusRect(&varsp
->fRFocusOutline
, true);
225 /* release our globals */
226 HSetState((Handle
) tpvars
, state
);
231 /* TPPaneHitTestProc is called when the control manager would
232 like to determine what part of the control the mouse resides over.
233 We also call this routine from our tracking proc to determine how
234 to handle mouse clicks. */
235 static pascal ControlPartCode
TPPaneHitTestProc(ControlHandle theControl
, Point where
) {
236 STPTextPaneVars
**tpvars
;
237 ControlPartCode result
;
239 /* set up our locals and lock down our globals*/
241 tpvars
= (STPTextPaneVars
**) GetControlReference(theControl
);
242 if (tpvars
!= NULL
) {
243 state
= HGetState((Handle
) tpvars
);
244 HLock((Handle
) tpvars
);
245 /* find the region where we clicked */
246 if (PtInRect(where
, &(**tpvars
).fRTextArea
)) {
247 result
= kmUPTextPart
;
249 /* release oure globals */
250 HSetState((Handle
) tpvars
, state
);
259 /* TPPaneTrackingProc is called when the mouse is being held down
260 over our control. This routine handles clicks in the text area
261 and in the scroll bar. */
262 static pascal ControlPartCode
TPPaneTrackingProc(ControlHandle theControl
, Point startPt
, ControlActionUPP actionProc
) {
263 STPTextPaneVars
**tpvars
, *varsp
;
265 ControlPartCode partCodeResult
;
266 /* make sure we have some variables... */
268 tpvars
= (STPTextPaneVars
**) GetControlReference(theControl
);
269 if (tpvars
!= NULL
) {
271 state
= HGetState((Handle
) tpvars
);
272 HLock((Handle
) tpvars
);
274 /* we don't do any of these functions unless we're in focus */
275 if ( ! varsp
->fInFocus
) {
277 owner
= GetControlOwner(theControl
);
278 ClearKeyboardFocus(owner
);
279 SetKeyboardFocus(owner
, theControl
, kUserClickedToFocusPart
);
281 /* find the location for the click */
282 switch (TPPaneHitTestProc(theControl
, startPt
)) {
284 /* handle clicks in the text part */
286 { SetPort((**tpvars
).fDrawingEnvironment
);
287 TXNClick( varsp
->fTXNRec
, (const EventRecord
*) wxTheApp
->MacGetCurrentEvent());
293 HSetState((Handle
) tpvars
, state
);
295 return partCodeResult
;
299 /* TPPaneIdleProc is our user pane idle routine. When our text field
300 is active and in focus, we use this routine to set the cursor. */
301 static pascal void TPPaneIdleProc(ControlHandle theControl
) {
302 STPTextPaneVars
**tpvars
, *varsp
;
304 tpvars
= (STPTextPaneVars
**) GetControlReference(theControl
);
305 if (tpvars
!= NULL
) {
306 /* if we're not active, then we have nothing to say about the cursor */
307 if ((**tpvars
).fIsActive
) {
311 /* lock down the globals */
312 state
= HGetState((Handle
) tpvars
);
313 HLock((Handle
) tpvars
);
315 /* get the current mouse coordinates (in our window) */
316 SetPortWindowPort(GetControlOwner(theControl
));
318 /* there's a 'focus thing' and an 'unfocused thing' */
319 if (varsp
->fInFocus
) {
320 /* flash the cursor */
321 SetPort((**tpvars
).fDrawingEnvironment
);
322 TXNIdle(varsp
->fTXNRec
);
324 if (PtInRect(mousep
, &varsp
->fRTextArea
)) {
326 RectRgn((theRgn
= NewRgn()), &varsp
->fRTextArea
);
327 TXNAdjustCursor(varsp
->fTXNRec
, theRgn
);
329 } else SetThemeCursor(kThemeArrowCursor
);
331 /* if it's in our bounds, set the cursor */
332 GetControlBounds(theControl
, &bounds
);
333 if (PtInRect(mousep
, &bounds
))
334 SetThemeCursor(kThemeArrowCursor
);
337 HSetState((Handle
) tpvars
, state
);
343 /* TPPaneKeyDownProc is called whenever a keydown event is directed
344 at our control. Here, we direct the keydown event to the text
345 edit record and redraw the scroll bar and text field as appropriate. */
346 static pascal ControlPartCode
TPPaneKeyDownProc(ControlHandle theControl
,
347 SInt16 keyCode
, SInt16 charCode
, SInt16 modifiers
) {
348 STPTextPaneVars
**tpvars
;
349 tpvars
= (STPTextPaneVars
**) GetControlReference(theControl
);
350 if (tpvars
!= NULL
) {
351 if ((**tpvars
).fInFocus
) {
352 /* turn autoscrolling on and send the key event to text edit */
353 SetPort((**tpvars
).fDrawingEnvironment
);
355 memset( &ev
, 0 , sizeof( ev
) ) ;
357 ev
.modifiers
= modifiers
;
358 ev
.message
= (( keyCode
<< 8 ) & keyCodeMask
) + ( charCode
& charCodeMask
) ;
359 TXNKeyDown( (**tpvars
).fTXNRec
, &ev
);
362 return kControlEntireControl
;
366 /* TPPaneActivateProc is called when the window containing
367 the user pane control receives activate events. Here, we redraw
368 the control and it's text as necessary for the activation state. */
369 static pascal void TPPaneActivateProc(ControlHandle theControl
, Boolean activating
) {
371 STPTextPaneVars
**tpvars
, *varsp
;
374 tpvars
= (STPTextPaneVars
**) GetControlReference(theControl
);
375 if (tpvars
!= NULL
) {
376 state
= HGetState((Handle
) tpvars
);
377 HLock((Handle
) tpvars
);
379 /* de/activate the text edit record */
380 SetPort((**tpvars
).fDrawingEnvironment
);
381 GetControlBounds(theControl
, &bounds
);
382 varsp
->fIsActive
= activating
;
383 TPActivatePaneText(tpvars
, varsp
->fIsActive
&& varsp
->fInFocus
);
384 /* redraw the frame */
385 DrawThemeEditTextFrame(&varsp
->fRTextOutline
, varsp
->fIsActive
? kThemeStateActive
: kThemeStateInactive
);
386 if (varsp
->fInFocus
) DrawThemeFocusRect(&varsp
->fRFocusOutline
, varsp
->fIsActive
);
387 HSetState((Handle
) tpvars
, state
);
392 /* TPPaneFocusProc is called when every the focus changes to or
393 from our control. Herein, switch the focus appropriately
394 according to the parameters and redraw the control as
396 static pascal ControlPartCode
TPPaneFocusProc(ControlHandle theControl
, ControlFocusPart action
) {
397 ControlPartCode focusResult
;
398 STPTextPaneVars
**tpvars
, *varsp
;
401 focusResult
= kControlFocusNoPart
;
402 tpvars
= (STPTextPaneVars
**) GetControlReference(theControl
);
403 if (tpvars
!= NULL
) {
404 state
= HGetState((Handle
) tpvars
);
405 HLock((Handle
) tpvars
);
407 /* if kControlFocusPrevPart and kControlFocusNextPart are received when the user is
408 tabbing forwards (or shift tabbing backwards) through the items in the dialog,
409 and kControlFocusNextPart will be received. When the user clicks in our field
410 and it is not the current focus, then the constant kUserClickedToFocusPart will
411 be received. The constant kControlFocusNoPart will be received when our control
412 is the current focus and the user clicks in another control. In your focus routine,
413 you should respond to these codes as follows:
415 kControlFocusNoPart - turn off focus and return kControlFocusNoPart. redraw
416 the control and the focus rectangle as necessary.
418 kControlFocusPrevPart or kControlFocusNextPart - toggle focus on or off
419 depending on its current state. redraw the control and the focus rectangle
420 as appropriate for the new focus state. If the focus state is 'off', return the constant
421 kControlFocusNoPart, otherwise return a non-zero part code.
422 kUserClickedToFocusPart - is a constant defined for this example. You should
423 define your own value for handling click-to-focus type events. */
424 /* save the drawing state */
425 SetPort((**tpvars
).fDrawingEnvironment
);
426 /* calculate the next highlight state */
429 case kControlFocusNoPart
:
430 TPFocusPaneText(tpvars
, false);
431 focusResult
= kControlFocusNoPart
;
433 case kUserClickedToFocusPart
:
434 TPFocusPaneText(tpvars
, true);
437 case kControlFocusPrevPart
:
438 case kControlFocusNextPart
:
439 TPFocusPaneText(tpvars
, ( ! varsp
->fInFocus
));
440 focusResult
= varsp
->fInFocus
? 1 : kControlFocusNoPart
;
443 TPActivatePaneText(tpvars
, varsp
->fIsActive
&& varsp
->fInFocus
);
444 /* redraw the text fram and focus rectangle to indicate the
446 DrawThemeEditTextFrame(&varsp
->fRTextOutline
, varsp
->fIsActive
? kThemeStateActive
: kThemeStateInactive
);
447 DrawThemeFocusRect(&varsp
->fRFocusOutline
, varsp
->fIsActive
&& varsp
->fInFocus
);
449 HSetState((Handle
) tpvars
, state
);
455 /* mUPOpenControl initializes a user pane control so it will be drawn
456 and will behave as a scrolling text edit field inside of a window.
457 This routine performs all of the initialization steps necessary,
458 except it does not create the user pane control itself. theControl
459 should refer to a user pane control that you have either created
460 yourself or extracted from a dialog's control heirarchy using
461 the GetDialogItemAsControl routine. */
462 OSStatus
mUPOpenControl(ControlHandle theControl
, long wxStyle
)
466 STPTextPaneVars
**tpvars
, *varsp
;
467 OSStatus err
= noErr
;
468 RGBColor rgbWhite
= {0xFFFF, 0xFFFF, 0xFFFF};
471 /* set up our globals */
472 if (gTPDrawProc
== NULL
) gTPDrawProc
= NewControlUserPaneDrawUPP(TPPaneDrawProc
);
473 if (gTPHitProc
== NULL
) gTPHitProc
= NewControlUserPaneHitTestUPP(TPPaneHitTestProc
);
474 if (gTPTrackProc
== NULL
) gTPTrackProc
= NewControlUserPaneTrackingUPP(TPPaneTrackingProc
);
475 if (gTPIdleProc
== NULL
) gTPIdleProc
= NewControlUserPaneIdleUPP(TPPaneIdleProc
);
476 if (gTPKeyProc
== NULL
) gTPKeyProc
= NewControlUserPaneKeyDownUPP(TPPaneKeyDownProc
);
477 if (gTPActivateProc
== NULL
) gTPActivateProc
= NewControlUserPaneActivateUPP(TPPaneActivateProc
);
478 if (gTPFocusProc
== NULL
) gTPFocusProc
= NewControlUserPaneFocusUPP(TPPaneFocusProc
);
480 /* allocate our private storage */
481 tpvars
= (STPTextPaneVars
**) NewHandleClear(sizeof(STPTextPaneVars
));
482 SetControlReference(theControl
, (long) tpvars
);
483 HLock((Handle
) tpvars
);
485 /* set the initial settings for our private data */
486 varsp
->fMultiline
= wxStyle
& wxTE_MULTILINE
;
487 varsp
->fInFocus
= false;
488 varsp
->fIsActive
= true;
489 varsp
->fTEActive
= true; // in order to get a deactivate
490 varsp
->fUserPaneRec
= theControl
;
491 theWindow
= varsp
->fOwner
= GetControlOwner(theControl
);
493 varsp
->fDrawingEnvironment
= (GrafPtr
) GetWindowPort(theWindow
);
495 varsp
->fInDialogWindow
= ( GetWindowKind(varsp
->fOwner
) == kDialogWindowKind
);
496 /* set up the user pane procedures */
497 SetControlData(theControl
, kControlEntireControl
, kControlUserPaneDrawProcTag
, sizeof(gTPDrawProc
), &gTPDrawProc
);
498 SetControlData(theControl
, kControlEntireControl
, kControlUserPaneHitTestProcTag
, sizeof(gTPHitProc
), &gTPHitProc
);
499 SetControlData(theControl
, kControlEntireControl
, kControlUserPaneTrackingProcTag
, sizeof(gTPTrackProc
), &gTPTrackProc
);
500 SetControlData(theControl
, kControlEntireControl
, kControlUserPaneIdleProcTag
, sizeof(gTPIdleProc
), &gTPIdleProc
);
501 SetControlData(theControl
, kControlEntireControl
, kControlUserPaneKeyDownProcTag
, sizeof(gTPKeyProc
), &gTPKeyProc
);
502 SetControlData(theControl
, kControlEntireControl
, kControlUserPaneActivateProcTag
, sizeof(gTPActivateProc
), &gTPActivateProc
);
503 SetControlData(theControl
, kControlEntireControl
, kControlUserPaneFocusProcTag
, sizeof(gTPFocusProc
), &gTPFocusProc
);
504 /* calculate the rectangles used by the control */
505 GetControlBounds(theControl
, &bounds
);
506 SetRect(&varsp
->fRFocusOutline
, bounds
.left
, bounds
.top
, bounds
.right
, bounds
.bottom
);
507 SetRect(&varsp
->fRTextOutline
, bounds
.left
, bounds
.top
, bounds
.right
, bounds
.bottom
);
508 SetRect(&varsp
->fRTextArea
, bounds
.left
+ 2 , bounds
.top
+ (varsp
->fMultiline
? 0 : 2) ,
509 bounds
.right
- (varsp
->fMultiline
? 0 : 2), bounds
.bottom
- (varsp
->fMultiline
? 0 : 2));
510 /* calculate the background region for the text. In this case, it's kindof
511 and irregular region because we're setting the scroll bar a little ways inside
513 RectRgn((varsp
->fTextBackgroundRgn
= NewRgn()), &varsp
->fRTextOutline
);
515 /* set up the drawing environment */
516 SetPort(varsp
->fDrawingEnvironment
);
518 /* create the new edit field */
520 TXNFrameOptions frameOptions
=
521 kTXNDontDrawCaretWhenInactiveMask
;
522 if ( ! ( wxStyle
& wxTE_NOHIDESEL
) )
523 frameOptions
|= kTXNDontDrawSelectionWhenInactiveMask
;
525 if ( wxStyle
& wxTE_MULTILINE
)
527 if ( ! ( wxStyle
& wxTE_DONTWRAP
) )
528 frameOptions
|= kTXNAlwaysWrapAtViewEdgeMask
;
531 frameOptions
|= kTXNAlwaysWrapAtViewEdgeMask
;
532 frameOptions
|= kTXNWantHScrollBarMask
;
535 if ( !(wxStyle
& wxTE_NO_VSCROLL
) )
536 frameOptions
|= kTXNWantVScrollBarMask
;
539 frameOptions
|= kTXNSingleLineOnlyMask
;
541 if ( wxStyle
& wxTE_READONLY
)
542 frameOptions
|= kTXNReadOnlyMask
;
544 TXNNewObject(NULL
, varsp
->fOwner
, &varsp
->fRTextArea
,
546 kTXNTextEditStyleFrameType
,
548 kTXNSystemDefaultEncoding
,
549 &varsp
->fTXNRec
, &varsp
->fTXNFrame
, (TXNObjectRefcon
) tpvars
);
555 GetThemeFont(kThemeSmallSystemFont
, GetApplicationScript() , fontName
, &fontSize
, &fontStyle
) ;
557 TXNTypeAttributes typeAttr
[] =
559 { kTXNQDFontNameAttribute
, kTXNQDFontNameAttributeSize
, { (void*) fontName
} } ,
560 { kTXNQDFontSizeAttribute
, kTXNFontSizeAttributeSize
, { (void*) (fontSize
<< 16) } } ,
561 { kTXNQDFontStyleAttribute
, kTXNQDFontStyleAttributeSize
, { (void*) normal
} } ,
564 err
= TXNSetTypeAttributes (varsp
->fTXNRec
, sizeof( typeAttr
) / sizeof(TXNTypeAttributes
) , typeAttr
,
567 /* set the field's background */
568 tback
.bgType
= kTXNBackgroundTypeRGB
;
569 tback
.bg
.color
= rgbWhite
;
570 TXNSetBackground( varsp
->fTXNRec
, &tback
);
572 /* unlock our storage */
573 HUnlock((Handle
) tpvars
);
574 /* perform final activations and setup for our text field. Here,
575 we assume that the window is going to be the 'active' window. */
576 TPActivatePaneText(tpvars
, varsp
->fIsActive
&& varsp
->fInFocus
);
584 #if !USE_SHARED_LIBRARY
585 IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl
, wxControl
)
587 BEGIN_EVENT_TABLE(wxTextCtrl
, wxControl
)
588 EVT_DROP_FILES(wxTextCtrl::OnDropFiles
)
589 EVT_CHAR(wxTextCtrl::OnChar
)
590 EVT_MENU(wxID_CUT
, wxTextCtrl::OnCut
)
591 EVT_MENU(wxID_COPY
, wxTextCtrl::OnCopy
)
592 EVT_MENU(wxID_PASTE
, wxTextCtrl::OnPaste
)
593 EVT_MENU(wxID_UNDO
, wxTextCtrl::OnUndo
)
594 EVT_MENU(wxID_REDO
, wxTextCtrl::OnRedo
)
596 EVT_UPDATE_UI(wxID_CUT
, wxTextCtrl::OnUpdateCut
)
597 EVT_UPDATE_UI(wxID_COPY
, wxTextCtrl::OnUpdateCopy
)
598 EVT_UPDATE_UI(wxID_PASTE
, wxTextCtrl::OnUpdatePaste
)
599 EVT_UPDATE_UI(wxID_UNDO
, wxTextCtrl::OnUpdateUndo
)
600 EVT_UPDATE_UI(wxID_REDO
, wxTextCtrl::OnUpdateRedo
)
605 wxTextCtrl::wxTextCtrl()
609 m_macTXNvars
= NULL
;
610 m_macUsesTXN
= false ;
612 m_maxLength
= TE_UNLIMITED_LENGTH
;
615 wxTextCtrl::~wxTextCtrl()
619 SetControlReference((ControlHandle
)m_macControl
, 0) ;
620 TXNDeleteObject((TXNObject
)m_macTXN
);
621 /* delete our private storage */
622 DisposeHandle((Handle
) m_macTXNvars
);
623 /* zero the control reference */
627 const short kVerticalMargin
= 2 ;
628 const short kHorizontalMargin
= 2 ;
630 bool wxTextCtrl::Create(wxWindow
*parent
, wxWindowID id
,
633 const wxSize
& size
, long style
,
634 const wxValidator
& validator
,
635 const wxString
& name
)
639 m_macTXNvars
= NULL
;
640 m_macUsesTXN
= false ;
643 m_macUsesTXN
= ! (style
& wxTE_PASSWORD
) ;
645 m_macUsesTXN
&= (TXNInitTextension
!= (void*) kUnresolvedCFragSymbolAddress
) ;
647 // base initialization
648 if ( !CreateBase(parent
, id
, pos
, size
, style
, validator
, name
) )
651 wxSize mySize
= size
;
654 m_macHorizontalBorder
= 5 ; // additional pixels around the real control
655 m_macVerticalBorder
= 3 ;
659 m_macHorizontalBorder
= 5 ; // additional pixels around the real control
660 m_macVerticalBorder
= 5 ;
667 if ( mySize.y == -1 )
670 if ( m_windowStyle & wxTE_MULTILINE )
673 mySize.y += 2 * m_macVerticalBorder ;
676 MacPreControlCreate( parent
, id
, "" , pos
, mySize
,style
, validator
, name
, &bounds
, title
) ;
678 if ( m_windowStyle
& wxTE_MULTILINE
)
680 wxASSERT_MSG( !(m_windowStyle
& wxTE_PROCESS_ENTER
),
681 wxT("wxTE_PROCESS_ENTER style is ignored for multiline text controls (they always process it)") );
683 m_windowStyle
|= wxTE_PROCESS_ENTER
;
686 if ( m_windowStyle
& wxTE_READONLY
)
693 m_macControl
= ::NewControl( MAC_WXHWND(parent
->MacGetRootWindow()) , &bounds
, "\p" , true , 0 , 0 , 1,
694 (style
& wxTE_PASSWORD
) ? kControlEditTextPasswordProc
: kControlEditTextProc
, (long) this ) ;
696 ::GetControlData((ControlHandle
) m_macControl
, 0, kControlEditTextTEHandleTag
, sizeof( TEHandle
) , (char*) &((TEHandle
) m_macTE
) , &size
) ;
703 featurSet
= kControlSupportsEmbedding
| kControlSupportsFocus
| kControlWantsIdle
704 | kControlWantsActivate
| kControlHandlesTracking
| kControlHasSpecialBackground
705 | kControlGetsFocusOnClick
| kControlSupportsLiveFeedback
;
706 /* create the control */
707 m_macControl
= NewControl(MAC_WXHWND(parent
->MacGetRootWindow()), &bounds
, "\p", true, featurSet
, 0, featurSet
, kControlUserPaneProc
, 0);
708 /* set up the mUP specific features and data */
709 mUPOpenControl((ControlHandle
) m_macControl
, m_windowStyle
);
712 parent
->MacGetTopLevelWindow()->MacInstallEventHandler() ;
715 MacPostControlCreate() ;
719 if( wxApp::s_macDefaultEncodingIsPC
)
720 value
= wxMacMakeMacStringFromPC( st
) ;
726 ::SetControlData( (ControlHandle
) m_macControl
, 0, ( m_windowStyle
& wxTE_PASSWORD
) ? kControlEditTextPasswordTag
: kControlEditTextTextTag
, value
.Length() , (char*) ((const char*)value
) ) ;
730 STPTextPaneVars
**tpvars
;
732 tpvars
= (STPTextPaneVars
**) GetControlReference((ControlHandle
) m_macControl
);
733 /* set the text in the record */
734 TXNSetData( (**tpvars
).fTXNRec
, kTXNTextData
, (void*)value
.c_str(), value
.Length(),
735 kTXNStartOffset
, kTXNEndOffset
);
736 m_macTXN
= (**tpvars
).fTXNRec
;
737 m_macTXNvars
= tpvars
;
738 m_macUsesTXN
= true ;
744 wxString
wxTextCtrl::GetValue() const
750 ::GetControlData( (ControlHandle
) m_macControl
, 0,
751 ( m_windowStyle
& wxTE_PASSWORD
) ? kControlEditTextPasswordTag
: kControlEditTextTextTag
,
752 32767 , wxBuffer
, &actualsize
) ;
757 OSStatus err
= TXNGetDataEncoded( ((TXNObject
) m_macTXN
), kTXNStartOffset
, kTXNEndOffset
, &theText
, kTXNTextData
);
765 actualsize
= GetHandleSize( theText
) ;
767 strncpy( wxBuffer
, *theText
, actualsize
) ;
768 DisposeHandle( theText
) ;
772 wxBuffer
[actualsize
] = 0 ;
776 if( wxApp::s_macDefaultEncodingIsPC
)
777 value
= wxMacMakePCStringFromMac( wxBuffer
) ;
781 value
.Replace( "\r", "\n" );
786 void wxTextCtrl::GetSelection(long* from
, long* to
) const
790 *from
= (**((TEHandle
) m_macTE
)).selStart
;
791 *to
= (**((TEHandle
) m_macTE
)).selEnd
;
795 TXNGetSelection( ((TXNObject
) m_macTXN
) , (TXNOffset
*) from
, (TXNOffset
*) to
) ;
799 void wxTextCtrl::SetValue(const wxString
& st
)
803 if( wxApp::s_macDefaultEncodingIsPC
)
804 value
= wxMacMakeMacStringFromPC( st
) ;
808 value
.Replace( "\n", "\r" );
812 ::SetControlData((ControlHandle
) m_macControl
, 0, ( m_windowStyle
& wxTE_PASSWORD
) ? kControlEditTextPasswordTag
: kControlEditTextTextTag
, value
.Length() , (char*) ((const char*)value
) ) ;
816 TXNSetData( ((TXNObject
) m_macTXN
), kTXNTextData
, (void*)value
.c_str(), value
.Length(),
817 kTXNStartOffset
, kTXNEndOffset
);
822 void wxTextCtrl::SetMaxLength(unsigned long len
)
827 bool wxTextCtrl::SetStyle(long start
, long end
, const wxTextAttr
& style
)
831 TXNTypeAttributes typeAttr
[4] ;
832 Str255 fontName
= "\pMonaco" ;
833 SInt16 fontSize
= 12 ;
834 Style fontStyle
= normal
;
836 int attrCounter
= 0 ;
837 if ( style
.HasFont() )
839 const wxFont
&font
= style
.GetFont() ;
840 CopyCStringToPascal( font
.GetFaceName().c_str() , fontName
) ;
841 fontSize
= font
.GetPointSize() ;
842 if ( font
.GetUnderlined() )
843 fontStyle
|= underline
;
844 if ( font
.GetWeight() == wxBOLD
)
846 if ( font
.GetStyle() == wxITALIC
)
847 fontStyle
|= italic
;
849 typeAttr
[attrCounter
].tag
= kTXNQDFontNameAttribute
;
850 typeAttr
[attrCounter
].size
= kTXNQDFontNameAttributeSize
;
851 typeAttr
[attrCounter
].data
.dataPtr
= (void*) fontName
;
852 typeAttr
[attrCounter
+1].tag
= kTXNQDFontSizeAttribute
;
853 typeAttr
[attrCounter
+1].size
= kTXNFontSizeAttributeSize
;
854 typeAttr
[attrCounter
+1].data
.dataValue
= (fontSize
<< 16) ;
855 typeAttr
[attrCounter
+2].tag
= kTXNQDFontStyleAttribute
;
856 typeAttr
[attrCounter
+2].size
= kTXNQDFontStyleAttributeSize
;
857 typeAttr
[attrCounter
+2].data
.dataValue
= fontStyle
;
861 if ( style
.HasTextColour() )
863 typeAttr
[attrCounter
].tag
= kTXNQDFontColorAttribute
;
864 typeAttr
[attrCounter
].size
= kTXNQDFontColorAttributeSize
;
865 typeAttr
[attrCounter
].data
.dataPtr
= (void*) &color
;
866 color
= MAC_WXCOLORREF(style
.GetTextColour().GetPixel()) ;
870 if ( attrCounter
> 0 )
872 OSStatus status
= TXNSetTypeAttributes ((TXNObject
)m_macTXN
, attrCounter
, typeAttr
,
879 bool wxTextCtrl::SetDefaultStyle(const wxTextAttr
& style
)
881 wxTextCtrlBase::SetDefaultStyle( style
) ;
882 SetStyle( kTXNUseCurrentSelection
, kTXNUseCurrentSelection
, GetDefaultStyle() ) ;
886 // Clipboard operations
887 void wxTextCtrl::Copy()
893 TECopy( ((TEHandle
) m_macTE
) ) ;
901 TXNCopy((TXNObject
)m_macTXN
);
902 TXNConvertToPublicScrap();
907 void wxTextCtrl::Cut()
913 TECut( ((TEHandle
) m_macTE
) ) ;
921 TXNCut((TXNObject
)m_macTXN
);
922 TXNConvertToPublicScrap();
924 wxCommandEvent
event(wxEVT_COMMAND_TEXT_UPDATED
, m_windowId
);
925 event
.SetString( GetValue() ) ;
926 event
.SetEventObject( this );
927 GetEventHandler()->ProcessEvent(event
);
931 void wxTextCtrl::Paste()
938 TEPaste( (TEHandle
) m_macTE
) ;
943 TXNConvertFromPublicScrap();
944 TXNPaste((TXNObject
)m_macTXN
);
946 wxCommandEvent
event(wxEVT_COMMAND_TEXT_UPDATED
, m_windowId
);
947 event
.SetString( GetValue() ) ;
948 event
.SetEventObject( this );
949 GetEventHandler()->ProcessEvent(event
);
953 bool wxTextCtrl::CanCopy() const
955 // Can copy if there's a selection
957 GetSelection(& from
, & to
);
961 bool wxTextCtrl::CanCut() const
967 // Can cut if there's a selection
969 GetSelection(& from
, & to
);
973 bool wxTextCtrl::CanPaste() const
980 OSStatus err
= noErr
;
983 err
= GetCurrentScrap( &scrapRef
);
984 if ( err
!= noTypeErr
&& err
!= memFullErr
)
986 ScrapFlavorFlags flavorFlags
;
989 if (( err
= GetScrapFlavorFlags( scrapRef
, 'TEXT', &flavorFlags
)) == noErr
)
991 if (( err
= GetScrapFlavorSize( scrapRef
, 'TEXT', &byteCount
)) == noErr
)
1000 if ( GetScrap( NULL
, 'TEXT' , &offset
) > 0 )
1008 void wxTextCtrl::SetEditable(bool editable
)
1010 if ( editable
!= m_editable
)
1012 m_editable
= editable
;
1014 UMAActivateControl( (ControlHandle
) m_macControl
) ;
1016 UMADeactivateControl((ControlHandle
) m_macControl
) ;
1020 void wxTextCtrl::SetInsertionPoint(long pos
)
1022 SetSelection( pos
, pos
) ;
1025 void wxTextCtrl::SetInsertionPointEnd()
1027 long pos
= GetLastPosition();
1028 SetInsertionPoint(pos
);
1031 long wxTextCtrl::GetInsertionPoint() const
1034 GetSelection( &begin
, &end
) ;
1038 long wxTextCtrl::GetLastPosition() const
1040 if ( !m_macUsesTXN
)
1042 return (**((TEHandle
) m_macTE
)).teLength
;
1048 OSErr err
= TXNGetDataEncoded( (TXNObject
) m_macTXN
, kTXNStartOffset
, kTXNEndOffset
, &theText
, kTXNTextData
);
1056 actualsize
= GetHandleSize( theText
) ;
1057 DisposeHandle( theText
) ;
1063 void wxTextCtrl::Replace(long from
, long to
, const wxString
& value
)
1065 if ( !m_macUsesTXN
)
1067 ControlEditTextSelectionRec selection
;
1069 selection
.selStart
= from
;
1070 selection
.selEnd
= to
;
1071 ::SetControlData((ControlHandle
) m_macControl
, 0, kControlEditTextSelectionTag
, sizeof( selection
) , (char*) &selection
) ;
1072 TESetSelect( from
, to
, ((TEHandle
) m_macTE
) ) ;
1073 TEDelete( ((TEHandle
) m_macTE
) ) ;
1074 TEInsert( value
, value
.Length() , ((TEHandle
) m_macTE
) ) ;
1078 TXNSetSelection( ((TXNObject
) m_macTXN
) , from
, to
) ;
1079 TXNClear( ((TXNObject
) m_macTXN
) ) ;
1080 TXNSetData( ((TXNObject
) m_macTXN
), kTXNTextData
, (void*)value
.c_str(), value
.Length(),
1081 kTXNUseCurrentSelection
, kTXNUseCurrentSelection
);
1086 void wxTextCtrl::Remove(long from
, long to
)
1088 if ( !m_macUsesTXN
)
1090 ControlEditTextSelectionRec selection
;
1092 selection
.selStart
= from
;
1093 selection
.selEnd
= to
;
1094 ::SetControlData( (ControlHandle
) m_macControl
, 0, kControlEditTextSelectionTag
, sizeof( selection
) , (char*) &selection
) ;
1095 TEDelete( ((TEHandle
) m_macTE
) ) ;
1099 TXNSetSelection( ((TXNObject
) m_macTXN
) , from
, to
) ;
1100 TXNClear( ((TXNObject
) m_macTXN
) ) ;
1105 void wxTextCtrl::SetSelection(long from
, long to
)
1108 if ( !m_macUsesTXN
)
1110 ControlEditTextSelectionRec selection
;
1111 selection
.selStart
= from
;
1112 selection
.selEnd
= to
;
1114 TESetSelect( selection
.selStart
, selection
.selEnd
, ((TEHandle
) m_macTE
) ) ;
1115 ::SetControlData((ControlHandle
) m_macControl
, 0, kControlEditTextSelectionTag
, sizeof( selection
) , (char*) &selection
) ;
1119 STPTextPaneVars
**tpvars
;
1120 /* set up our locals */
1121 tpvars
= (STPTextPaneVars
**) GetControlReference((ControlHandle
) m_macControl
);
1122 /* and our drawing environment as the operation
1123 may force a redraw in the text area. */
1124 SetPort((**tpvars
).fDrawingEnvironment
);
1125 /* change the selection */
1126 TXNSetSelection( (**tpvars
).fTXNRec
, from
, to
);
1130 bool wxTextCtrl::LoadFile(const wxString
& file
)
1132 if ( wxTextCtrlBase::LoadFile(file
) )
1140 void wxTextCtrl::WriteText(const wxString
& text
)
1143 if( wxApp::s_macDefaultEncodingIsPC
)
1144 value
= wxMacMakeMacStringFromPC( text
) ;
1147 if ( !m_macUsesTXN
)
1149 TEInsert( value
, value
.Length() , ((TEHandle
) m_macTE
) ) ;
1153 long start
, end
, dummy
;
1154 GetSelection( &start
, &dummy
) ;
1155 TXNSetData( ((TXNObject
) m_macTXN
), kTXNTextData
, (void*) (const char*)value
, value
.Length(),
1156 kTXNUseCurrentSelection
, kTXNUseCurrentSelection
);
1157 GetSelection( &dummy
, &end
) ;
1158 SetStyle( start
, end
, GetDefaultStyle() ) ;
1160 MacRedrawControl() ;
1163 void wxTextCtrl::AppendText(const wxString
& text
)
1165 SetInsertionPointEnd();
1169 void wxTextCtrl::Clear()
1171 if ( !IsEditable() )
1175 if ( !m_macUsesTXN
)
1177 ::SetControlData((ControlHandle
) m_macControl
, 0, ( m_windowStyle
& wxTE_PASSWORD
) ? kControlEditTextPasswordTag
: kControlEditTextTextTag
, 0 , (char*) ((const char*)NULL
) ) ;
1181 ClearCurrentScrap();
1182 TXNClear((TXNObject
)m_macTXN
);
1187 bool wxTextCtrl::IsModified() const
1192 bool wxTextCtrl::IsEditable() const
1194 return IsEnabled() && m_editable
;
1197 bool wxTextCtrl::AcceptsFocus() const
1199 // we don't want focus if we can't be edited
1200 return /*IsEditable() && */ wxControl::AcceptsFocus();
1203 wxSize
wxTextCtrl::DoGetBestSize() const
1218 wxGetCharSize(GetHWND(), &cx, &cy, &GetFont());
1220 int wText = DEFAULT_ITEM_WIDTH;
1222 int hText = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
1224 return wxSize(wText, hText);
1226 if ( m_windowStyle
& wxTE_MULTILINE
)
1230 hText
+= 2 * m_macVerticalBorder
;
1231 wText
+= 2 * m_macHorizontalBorder
;
1232 //else: for single line control everything is ok
1233 return wxSize(wText
, hText
);
1236 // ----------------------------------------------------------------------------
1238 // ----------------------------------------------------------------------------
1240 void wxTextCtrl::Undo()
1247 void wxTextCtrl::Redo()
1254 bool wxTextCtrl::CanUndo() const
1259 bool wxTextCtrl::CanRedo() const
1264 // Makes 'unmodified'
1265 void wxTextCtrl::DiscardEdits()
1270 int wxTextCtrl::GetNumberOfLines() const
1272 // TODO change this if possible to reflect real lines
1273 wxString content
= GetValue() ;
1276 for (int i
= 0; i
< content
.Length() ; i
++)
1278 if (content
[i
] == '\r') count
++;
1284 long wxTextCtrl::XYToPosition(long x
, long y
) const
1290 bool wxTextCtrl::PositionToXY(long pos
, long *x
, long *y
) const
1295 void wxTextCtrl::ShowPosition(long pos
)
1300 int wxTextCtrl::GetLineLength(long lineNo
) const
1302 // TODO change this if possible to reflect real lines
1303 wxString content
= GetValue() ;
1307 for (int i
= 0; i
< content
.Length() ; i
++)
1309 if (count
== lineNo
)
1311 // Count chars in line then
1313 for (int j
= i
; j
< content
.Length(); j
++)
1316 if (content
[j
] == '\r') return count
;
1321 if (content
[i
] == '\r') count
++;
1326 wxString
wxTextCtrl::GetLineText(long lineNo
) const
1328 // TODO change this if possible to reflect real lines
1329 wxString content
= GetValue() ;
1333 for (int i
= 0; i
< content
.Length() ; i
++)
1335 if (count
== lineNo
)
1337 // Add chars in line then
1340 for (int j
= i
; j
< content
.Length(); j
++)
1342 if (content
[j
] == '\r')
1350 if (content
[i
] == '\r') count
++;
1359 void wxTextCtrl::Command(wxCommandEvent
& event
)
1361 SetValue (event
.GetString());
1362 ProcessCommand (event
);
1365 void wxTextCtrl::OnDropFiles(wxDropFilesEvent
& event
)
1367 // By default, load the first file into the text window.
1368 if (event
.GetNumberOfFiles() > 0)
1370 LoadFile(event
.GetFiles()[0]);
1374 void wxTextCtrl::OnChar(wxKeyEvent
& event
)
1376 int key
= event
.GetKeyCode() ;
1377 bool eat_key
= false ;
1379 if ( !IsEditable() && key
!= WXK_LEFT
&& key
!= WXK_RIGHT
&& key
!= WXK_DOWN
&& key
!= WXK_UP
&& key
!= WXK_TAB
&&
1380 !( key
== WXK_RETURN
&& ( (m_windowStyle
& wxPROCESS_ENTER
) || (m_windowStyle
& wxTE_MULTILINE
) ) )
1381 /* && key != WXK_PRIOR && key != WXK_NEXT && key != WXK_HOME && key != WXK_END */
1390 if (m_windowStyle
& wxPROCESS_ENTER
)
1392 wxCommandEvent
event(wxEVT_COMMAND_TEXT_ENTER
, m_windowId
);
1393 event
.SetEventObject( this );
1394 event
.SetString( GetValue() );
1395 if ( GetEventHandler()->ProcessEvent(event
) )
1398 if ( !(m_windowStyle
& wxTE_MULTILINE
) )
1400 wxWindow
*parent
= GetParent();
1401 while( parent
&& !parent
->IsTopLevel() && parent
->GetDefaultItem() == NULL
) {
1402 parent
= parent
->GetParent() ;
1404 if ( parent
&& parent
->GetDefaultItem() )
1406 wxButton
*def
= wxDynamicCast(parent
->GetDefaultItem(),
1408 if ( def
&& def
->IsEnabled() )
1410 wxCommandEvent
event(wxEVT_COMMAND_BUTTON_CLICKED
, def
->GetId() );
1411 event
.SetEventObject(def
);
1412 def
->Command(event
);
1417 // this will make wxWindows eat the ENTER key so that
1418 // we actually prevent line wrapping in a single line
1426 // always produce navigation event - even if we process TAB
1427 // ourselves the fact that we got here means that the user code
1428 // decided to skip processing of this TAB - probably to let it
1429 // do its default job.
1431 wxNavigationKeyEvent eventNav
;
1432 eventNav
.SetDirection(!event
.ShiftDown());
1433 eventNav
.SetWindowChange(event
.ControlDown());
1434 eventNav
.SetEventObject(this);
1436 if ( GetParent()->GetEventHandler()->ProcessEvent(eventNav
) )
1451 key
== WXK_RETURN
||
1452 key
== WXK_DELETE
||
1455 wxCommandEvent
event1(wxEVT_COMMAND_TEXT_UPDATED
, m_windowId
);
1456 event1
.SetString( GetValue() ) ;
1457 event1
.SetEventObject( this );
1458 wxPostEvent(GetEventHandler(),event1
);
1462 void wxTextCtrl::MacSuperShown( bool show
)
1464 bool former
= m_macControlIsShown
;
1465 wxControl::MacSuperShown( show
) ;
1466 if ( (former
!= m_macControlIsShown
) && m_macUsesTXN
)
1468 if ( m_macControlIsShown
)
1469 TXNSetFrameBounds( (TXNObject
) m_macTXN
, (**(STPTextPaneVars
**)m_macTXNvars
).fRTextArea
.top
, (**(STPTextPaneVars
**)m_macTXNvars
).fRTextArea
.left
,
1470 (**(STPTextPaneVars
**)m_macTXNvars
).fRTextArea
.bottom
,(**(STPTextPaneVars
**)m_macTXNvars
).fRTextArea
.right
, (**(STPTextPaneVars
**)m_macTXNvars
).fTXNFrame
);
1472 TXNSetFrameBounds( (TXNObject
) m_macTXN
, (**(STPTextPaneVars
**)m_macTXNvars
).fRTextArea
.top
+ 30000, (**(STPTextPaneVars
**)m_macTXNvars
).fRTextArea
.left
,
1473 (**(STPTextPaneVars
**)m_macTXNvars
).fRTextArea
.bottom
+ 30000, (**(STPTextPaneVars
**)m_macTXNvars
).fRTextArea
.right
, (**(STPTextPaneVars
**)m_macTXNvars
).fTXNFrame
);
1477 bool wxTextCtrl::Show(bool show
)
1479 bool former
= m_macControlIsShown
;
1481 bool retval
= wxControl::Show( show
) ;
1483 if ( former
!= m_macControlIsShown
)
1485 if ( m_macControlIsShown
)
1486 TXNSetFrameBounds( (TXNObject
) m_macTXN
, (**(STPTextPaneVars
**)m_macTXNvars
).fRTextArea
.top
, (**(STPTextPaneVars
**)m_macTXNvars
).fRTextArea
.left
,
1487 (**(STPTextPaneVars
**)m_macTXNvars
).fRTextArea
.bottom
,(**(STPTextPaneVars
**)m_macTXNvars
).fRTextArea
.right
, (**(STPTextPaneVars
**)m_macTXNvars
).fTXNFrame
);
1489 TXNSetFrameBounds( (TXNObject
) m_macTXN
, (**(STPTextPaneVars
**)m_macTXNvars
).fRTextArea
.top
+ 30000, (**(STPTextPaneVars
**)m_macTXNvars
).fRTextArea
.left
,
1490 (**(STPTextPaneVars
**)m_macTXNvars
).fRTextArea
.bottom
+ 30000, (**(STPTextPaneVars
**)m_macTXNvars
).fRTextArea
.right
, (**(STPTextPaneVars
**)m_macTXNvars
).fTXNFrame
);
1496 // ----------------------------------------------------------------------------
1497 // standard handlers for standard edit menu events
1498 // ----------------------------------------------------------------------------
1500 void wxTextCtrl::OnCut(wxCommandEvent
& event
)
1505 void wxTextCtrl::OnCopy(wxCommandEvent
& event
)
1510 void wxTextCtrl::OnPaste(wxCommandEvent
& event
)
1515 void wxTextCtrl::OnUndo(wxCommandEvent
& event
)
1520 void wxTextCtrl::OnRedo(wxCommandEvent
& event
)
1525 void wxTextCtrl::OnUpdateCut(wxUpdateUIEvent
& event
)
1527 event
.Enable( CanCut() );
1530 void wxTextCtrl::OnUpdateCopy(wxUpdateUIEvent
& event
)
1532 event
.Enable( CanCopy() );
1535 void wxTextCtrl::OnUpdatePaste(wxUpdateUIEvent
& event
)
1537 event
.Enable( CanPaste() );
1540 void wxTextCtrl::OnUpdateUndo(wxUpdateUIEvent
& event
)
1542 event
.Enable( CanUndo() );
1545 void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent
& event
)
1547 event
.Enable( CanRedo() );