PageRenderTime 63ms CodeModel.GetById 31ms RepoModel.GetById 1ms app.codeStats 0ms

/ExtLibs/wxWidgets/src/osx/iphone/textctrl.mm

https://bitbucket.org/lennonchan/cafu
Objective C++ | 749 lines | 535 code | 123 blank | 91 comment | 70 complexity | a5b335c8a280e1b691e1a61933504bb1 MD5 | raw file
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: src/osx/iphone/textctrl.mm
  3. // Purpose: wxTextCtrl
  4. // Author: Stefan Csomor
  5. // Modified by: Ryan Norton (MLTE GetLineLength and GetLineText)
  6. // Created: 1998-01-01
  7. // RCS-ID: $Id$
  8. // Copyright: (c) Stefan Csomor
  9. // Licence: wxWindows licence
  10. /////////////////////////////////////////////////////////////////////////////
  11. #include "wx/wxprec.h"
  12. #if wxUSE_TEXTCTRL
  13. #include "wx/textctrl.h"
  14. #ifndef WX_PRECOMP
  15. #include "wx/intl.h"
  16. #include "wx/app.h"
  17. #include "wx/utils.h"
  18. #include "wx/dc.h"
  19. #include "wx/button.h"
  20. #include "wx/menu.h"
  21. #include "wx/settings.h"
  22. #include "wx/msgdlg.h"
  23. #include "wx/toplevel.h"
  24. #endif
  25. #ifdef __DARWIN__
  26. #include <sys/types.h>
  27. #include <sys/stat.h>
  28. #else
  29. #include <stat.h>
  30. #endif
  31. #if wxUSE_STD_IOSTREAM
  32. #if wxUSE_IOSTREAMH
  33. #include <fstream.h>
  34. #else
  35. #include <fstream>
  36. #endif
  37. #endif
  38. #include "wx/filefn.h"
  39. #include "wx/sysopt.h"
  40. #include "wx/thread.h"
  41. #include "wx/osx/private.h"
  42. #include "wx/osx/iphone/private/textimpl.h"
  43. // currently for some reasong the UITextField leads to a recursion when the keyboard should be shown, so let's leave the code
  44. // in case this gets resolved...
  45. #define wxOSX_IPHONE_USE_TEXTFIELD 1
  46. class wxMacEditHelper
  47. {
  48. public :
  49. wxMacEditHelper( UITextView* textView )
  50. {
  51. m_textView = textView;
  52. m_formerState = YES;
  53. if ( textView )
  54. {
  55. m_formerState = [textView isEditable];
  56. [textView setEditable:YES];
  57. }
  58. }
  59. ~wxMacEditHelper()
  60. {
  61. if ( m_textView )
  62. [m_textView setEditable:m_formerState];
  63. }
  64. protected :
  65. BOOL m_formerState ;
  66. UITextView* m_textView;
  67. } ;
  68. #if wxOSX_IPHONE_USE_TEXTFIELD
  69. @interface wxUITextFieldDelegate : NSObject<UITextFieldDelegate>
  70. {
  71. }
  72. @end
  73. @interface wxUITextField : UITextField
  74. {
  75. }
  76. @end
  77. @interface wxNSSecureTextField : UITextField<UITextFieldDelegate>
  78. {
  79. }
  80. @end
  81. @implementation wxNSSecureTextField
  82. + (void)initialize
  83. {
  84. static BOOL initialized = NO;
  85. if (!initialized)
  86. {
  87. initialized = YES;
  88. wxOSXIPhoneClassAddWXMethods( self );
  89. }
  90. }
  91. - (void)controlTextDidChange:(NSNotification *)aNotification
  92. {
  93. wxUnusedVar(aNotification);
  94. wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( self );
  95. if ( impl )
  96. impl->controlTextDidChange();
  97. }
  98. - (void)controlTextDidEndEditing:(NSNotification *)aNotification
  99. {
  100. wxUnusedVar(aNotification);
  101. wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( self );
  102. if ( impl )
  103. {
  104. impl->DoNotifyFocusEvent( false, NULL );
  105. }
  106. }
  107. @end
  108. #if 0
  109. @implementation wxUITextFieldEditor
  110. - (void) keyDown:(NSEvent*) event
  111. {
  112. wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( (WXWidget) [self delegate] );
  113. lastKeyDownEvent = event;
  114. if ( impl == NULL || !impl->DoHandleKeyEvent(event) )
  115. [super keyDown:event];
  116. lastKeyDownEvent = nil;
  117. }
  118. - (void) keyUp:(NSEvent*) event
  119. {
  120. wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( (WXWidget) [self delegate] );
  121. if ( impl == NULL || !impl->DoHandleKeyEvent(event) )
  122. [super keyUp:event];
  123. }
  124. - (void) flagsChanged:(NSEvent*) event
  125. {
  126. wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( (WXWidget) [self delegate] );
  127. if ( impl == NULL || !impl->DoHandleKeyEvent(event) )
  128. [super flagsChanged:event];
  129. }
  130. - (BOOL) performKeyEquivalent:(NSEvent*) event
  131. {
  132. BOOL retval = [super performKeyEquivalent:event];
  133. return retval;
  134. }
  135. - (void) insertText:(id) str
  136. {
  137. wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( (WXWidget) [self delegate] );
  138. if ( impl == NULL || lastKeyDownEvent==nil || !impl->DoHandleCharEvent(lastKeyDownEvent, str) )
  139. {
  140. [super insertText:str];
  141. }
  142. }
  143. @end
  144. #endif
  145. @implementation wxUITextFieldDelegate
  146. - (BOOL)textFieldShouldReturn:(UITextField *)textField
  147. {
  148. // the user pressed the "Done" button, so dismiss the keyboard
  149. wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( textField );
  150. if ( impl )
  151. {
  152. wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
  153. if ( wxpeer && wxpeer->GetWindowStyle() & wxTE_PROCESS_ENTER )
  154. {
  155. wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, wxpeer->GetId());
  156. event.SetEventObject( wxpeer );
  157. event.SetString( static_cast<wxTextCtrl*>(wxpeer)->GetValue() );
  158. wxpeer->HandleWindowEvent( event );
  159. }
  160. }
  161. [textField resignFirstResponder];
  162. return YES;
  163. }
  164. /*
  165. - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField; // return NO to disallow editing.
  166. - (void)textFieldDidBeginEditing:(UITextField *)textField; // became first responder
  167. - (BOOL)textFieldShouldEndEditing:(UITextField *)textField; // return YES to allow editing to stop and to resign first responder status. NO to disallow the editing session to end
  168. - (void)textFieldDidEndEditing:(UITextField *)textField; // may be called if forced even if shouldEndEditing returns NO (e.g. view removed from window) or endEditing:YES called
  169. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string; // return NO to not change text
  170. - (BOOL)textFieldShouldClear:(UITextField *)textField; // called when clear button pressed. return NO to ignore (no notifications)
  171. */
  172. @end
  173. @implementation wxUITextField
  174. + (void)initialize
  175. {
  176. static BOOL initialized = NO;
  177. if (!initialized)
  178. {
  179. initialized = YES;
  180. wxOSXIPhoneClassAddWXMethods( self );
  181. }
  182. }
  183. #if 0
  184. - (void)controlTextDidChange:(NSNotification *)aNotification
  185. {
  186. wxUnusedVar(aNotification);
  187. wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( self );
  188. if ( impl )
  189. impl->controlTextDidChange();
  190. }
  191. #endif
  192. - (BOOL)textFieldShouldReturn:(UITextField *)textField
  193. {
  194. wxUnusedVar(textField);
  195. return NO;
  196. }
  197. - (void)controlTextDidEndEditing:(NSNotification *)aNotification
  198. {
  199. wxUnusedVar(aNotification);
  200. wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( self );
  201. if ( impl )
  202. {
  203. impl->DoNotifyFocusEvent( false, NULL );
  204. }
  205. }
  206. @end
  207. #endif
  208. @interface wxUITextViewDelegate : NSObject<UITextViewDelegate>
  209. {
  210. }
  211. - (void)textViewDidChange:(UITextView *)textView;
  212. - (void)textViewDidBeginEditing:(UITextView *)textView;
  213. - (void)textViewDidEndEditing:(UITextView *)textView;
  214. - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text;
  215. @end
  216. @implementation wxUITextViewDelegate
  217. - (void)textViewDidChange:(UITextView *)textView
  218. {
  219. wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( textView );
  220. if ( impl )
  221. impl->controlTextDidChange();
  222. }
  223. - (void)textViewDidBeginEditing:(UITextView *)textView
  224. {
  225. wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( textView );
  226. if ( impl )
  227. impl->DoNotifyFocusEvent(true, NULL);
  228. }
  229. - (void)textViewDidEndEditing:(UITextView *)textView
  230. {
  231. wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( textView );
  232. if ( impl )
  233. impl->DoNotifyFocusEvent(false, NULL);
  234. }
  235. - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
  236. {
  237. wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( textView );
  238. if ( impl )
  239. {
  240. if ( !impl->GetWXPeer()->HasFlag(wxTE_MULTILINE) && [text isEqualToString:@"\n"])
  241. {
  242. [textView resignFirstResponder];
  243. return NO;
  244. }
  245. }
  246. return YES;
  247. }
  248. @end
  249. //
  250. // wxUITextViewControl
  251. //
  252. wxUITextViewControl::wxUITextViewControl( wxTextCtrl *wxPeer, UITextView* v) :
  253. wxWidgetIPhoneImpl(wxPeer, v),
  254. wxTextWidgetImpl(wxPeer)
  255. {
  256. m_textView = v;
  257. m_delegate= [[wxUITextViewDelegate alloc] init];
  258. [m_textView setDelegate:m_delegate];
  259. }
  260. wxUITextViewControl::~wxUITextViewControl()
  261. {
  262. if (m_textView)
  263. {
  264. [m_textView setDelegate: nil];
  265. }
  266. [m_delegate release];
  267. }
  268. bool wxUITextViewControl::CanFocus() const
  269. {
  270. return true;
  271. }
  272. wxString wxUITextViewControl::GetStringValue() const
  273. {
  274. if (m_textView)
  275. {
  276. wxString result = wxCFStringRef::AsString([m_textView text], m_wxPeer->GetFont().GetEncoding());
  277. wxMacConvertNewlines13To10( &result ) ;
  278. return result;
  279. }
  280. return wxEmptyString;
  281. }
  282. void wxUITextViewControl::SetStringValue( const wxString &str)
  283. {
  284. wxString st = str;
  285. wxMacConvertNewlines10To13( &st );
  286. wxMacEditHelper helper(m_textView);
  287. if (m_textView)
  288. [m_textView setText: wxCFStringRef( st , m_wxPeer->GetFont().GetEncoding() ).AsNSString()];
  289. }
  290. void wxUITextViewControl::Copy()
  291. {
  292. if (m_textView)
  293. [m_textView copy:nil];
  294. }
  295. void wxUITextViewControl::Cut()
  296. {
  297. if (m_textView)
  298. [m_textView cut:nil];
  299. }
  300. void wxUITextViewControl::Paste()
  301. {
  302. if (m_textView)
  303. [m_textView paste:nil];
  304. }
  305. bool wxUITextViewControl::CanPaste() const
  306. {
  307. return true;
  308. }
  309. void wxUITextViewControl::SetEditable(bool editable)
  310. {
  311. if (m_textView)
  312. [m_textView setEditable: editable];
  313. }
  314. void wxUITextViewControl::GetSelection( long* from, long* to) const
  315. {
  316. if (m_textView)
  317. {
  318. NSRange range = [m_textView selectedRange];
  319. *from = range.location;
  320. *to = range.location + range.length;
  321. }
  322. }
  323. void wxUITextViewControl::SetSelection( long from , long to )
  324. {
  325. long textLength = [[m_textView text] length];
  326. if ((from == -1) && (to == -1))
  327. {
  328. from = 0 ;
  329. to = textLength ;
  330. }
  331. else
  332. {
  333. from = wxMin(textLength,wxMax(from,0)) ;
  334. if ( to == -1 )
  335. to = textLength;
  336. else
  337. to = wxMax(0,wxMin(textLength,to)) ;
  338. }
  339. NSRange selrange = NSMakeRange(from, to-from);
  340. [m_textView setSelectedRange:selrange];
  341. [m_textView scrollRangeToVisible:selrange];
  342. }
  343. void wxUITextViewControl::WriteText(const wxString& str)
  344. {
  345. wxString st = str;
  346. wxMacConvertNewlines10To13( &st );
  347. wxMacEditHelper helper(m_textView);
  348. wxCFStringRef insert( st , m_wxPeer->GetFont().GetEncoding() );
  349. NSMutableString* subst = [NSMutableString stringWithString:[m_textView text]];
  350. [subst replaceCharactersInRange:[m_textView selectedRange] withString:insert.AsNSString()];
  351. [m_textView setText:subst];
  352. }
  353. void wxUITextViewControl::SetFont( const wxFont & font , const wxColour& WXUNUSED(foreground) , long WXUNUSED(windowStyle), bool WXUNUSED(ignoreBlack) )
  354. {
  355. if ([m_textView respondsToSelector:@selector(setFont:)])
  356. [m_textView setFont: font.OSXGetUIFont()];
  357. }
  358. bool wxUITextViewControl::GetStyle(long position, wxTextAttr& style)
  359. {
  360. if (m_textView && position >=0)
  361. {
  362. // UIFont* font = NULL;
  363. // NSColor* bgcolor = NULL;
  364. // NSColor* fgcolor = NULL;
  365. // NOTE: It appears that other platforms accept GetStyle with the position == length
  366. // but that UITextStorage does not accept length as a valid position.
  367. // Therefore we return the default control style in that case.
  368. /*
  369. if (position < [[m_textView string] length])
  370. {
  371. UITextStorage* storage = [m_textView textStorage];
  372. font = [[storage attribute:NSFontAttributeName atIndex:position effectiveRange:NULL] autorelease];
  373. bgcolor = [[storage attribute:NSBackgroundColorAttributeName atIndex:position effectiveRange:NULL] autorelease];
  374. fgcolor = [[storage attribute:NSForegroundColorAttributeName atIndex:position effectiveRange:NULL] autorelease];
  375. }
  376. else
  377. {
  378. NSDictionary* attrs = [m_textView typingAttributes];
  379. font = [[attrs objectForKey:NSFontAttributeName] autorelease];
  380. bgcolor = [[attrs objectForKey:NSBackgroundColorAttributeName] autorelease];
  381. fgcolor = [[attrs objectForKey:NSForegroundColorAttributeName] autorelease];
  382. }
  383. */
  384. /*
  385. if (font)
  386. style.SetFont(wxFont(font));
  387. if (bgcolor)
  388. style.SetBackgroundColour(wxColour(bgcolor));
  389. if (fgcolor)
  390. style.SetTextColour(wxColour(fgcolor));
  391. */
  392. return true;
  393. }
  394. return false;
  395. }
  396. void wxUITextViewControl::SetStyle(long start,
  397. long end,
  398. const wxTextAttr& style)
  399. {
  400. if (m_textView) {
  401. NSRange range = NSMakeRange(start, end-start);
  402. if (start == -1 && end == -1)
  403. range = [m_textView selectedRange];
  404. /*
  405. UITextStorage* storage = [m_textView textStorage];
  406. wxFont font = style.GetFont();
  407. if (style.HasFont() && font.IsOk())
  408. [storage addAttribute:NSFontAttributeName value:font.OSXGetNSFont() range:range];
  409. wxColour bgcolor = style.GetBackgroundColour();
  410. if (style.HasBackgroundColour() && bgcolor.IsOk())
  411. [storage addAttribute:NSBackgroundColorAttributeName value:bgcolor.OSXGetNSColor() range:range];
  412. wxColour fgcolor = style.GetTextColour();
  413. if (style.HasTextColour() && fgcolor.IsOk())
  414. [storage addAttribute:NSForegroundColorAttributeName value:fgcolor.OSXGetNSColor() range:range];
  415. */
  416. }
  417. }
  418. void wxUITextViewControl::CheckSpelling(bool check)
  419. {
  420. }
  421. wxSize wxUITextViewControl::GetBestSize() const
  422. {
  423. wxRect r;
  424. GetBestRect(&r);
  425. /*
  426. if (m_textView && [m_textView layoutManager])
  427. {
  428. NSRect rect = [[m_textView layoutManager] usedRectForTextContainer: [m_textView textContainer]];
  429. wxSize size = wxSize(rect.size.width, rect.size.height);
  430. size.x += [m_textView textContainerInset].width;
  431. size.y += [m_textView textContainerInset].height;
  432. return size;
  433. }
  434. return wxSize(0,0);
  435. */
  436. wxSize sz = r.GetSize();
  437. if ( sz.y < 31 )
  438. sz.y = 31;
  439. return sz;
  440. }
  441. #if wxOSX_IPHONE_USE_TEXTFIELD
  442. //
  443. // wxUITextFieldControl
  444. //
  445. wxUITextFieldControl::wxUITextFieldControl( wxTextCtrl *wxPeer, UITextField* w ) :
  446. wxWidgetIPhoneImpl(wxPeer, w),
  447. wxTextWidgetImpl(wxPeer)
  448. {
  449. m_textField = w;
  450. m_delegate = [[wxUITextFieldDelegate alloc] init];
  451. [m_textField setDelegate: m_delegate];
  452. m_selStart = m_selEnd = 0;
  453. }
  454. wxUITextFieldControl::~wxUITextFieldControl()
  455. {
  456. if (m_textField)
  457. [m_textField setDelegate: nil];
  458. [m_delegate release];
  459. }
  460. wxString wxUITextFieldControl::GetStringValue() const
  461. {
  462. return wxCFStringRef::AsString([m_textField text], m_wxPeer->GetFont().GetEncoding());
  463. }
  464. void wxUITextFieldControl::SetStringValue( const wxString &str)
  465. {
  466. // wxMacEditHelper helper(m_textField);
  467. [m_textField setText: wxCFStringRef( str , m_wxPeer->GetFont().GetEncoding() ).AsNSString()];
  468. }
  469. wxSize wxUITextFieldControl::GetBestSize() const
  470. {
  471. wxRect r;
  472. GetBestRect(&r);
  473. wxSize sz = r.GetSize();
  474. if ( sz.y < 31 )
  475. sz.y = 31;
  476. return sz;
  477. }
  478. void wxUITextFieldControl::Copy()
  479. {
  480. [m_textField copy:nil];
  481. }
  482. void wxUITextFieldControl::Cut()
  483. {
  484. [m_textField cut:nil];
  485. }
  486. void wxUITextFieldControl::Paste()
  487. {
  488. [m_textField paste:nil];
  489. }
  490. bool wxUITextFieldControl::CanPaste() const
  491. {
  492. return true;
  493. }
  494. void wxUITextFieldControl::SetEditable(bool editable)
  495. {
  496. }
  497. void wxUITextFieldControl::GetSelection( long* from, long* to) const
  498. {
  499. *from = m_selStart;
  500. *to = m_selEnd;
  501. }
  502. void wxUITextFieldControl::SetSelection( long from , long to )
  503. {
  504. long textLength = [[m_textField text] length];
  505. if ((from == -1) && (to == -1))
  506. {
  507. from = 0 ;
  508. to = textLength ;
  509. }
  510. else
  511. {
  512. from = wxMin(textLength,wxMax(from,0)) ;
  513. if ( to == -1 )
  514. to = textLength;
  515. else
  516. to = wxMax(0,wxMin(textLength,to)) ;
  517. }
  518. m_selStart = from;
  519. m_selEnd = to;
  520. }
  521. void wxUITextFieldControl::WriteText(const wxString& str)
  522. {
  523. #if 0
  524. NSEvent* formerEvent = m_lastKeyDownEvent;
  525. UIText* editor = [m_textField currentEditor];
  526. if ( editor )
  527. {
  528. wxMacEditHelper helper(m_textField);
  529. [editor insertText:wxCFStringRef( str , m_wxPeer->GetFont().GetEncoding() ).AsNSString()];
  530. }
  531. else
  532. #endif
  533. {
  534. wxString val = GetStringValue() ;
  535. long start , end ;
  536. GetSelection( &start , &end ) ;
  537. val.Remove( start , end - start ) ;
  538. val.insert( start , str ) ;
  539. SetStringValue( val ) ;
  540. SetSelection( start + str.length() , start + str.length() ) ;
  541. }
  542. #if 0
  543. m_lastKeyDownEvent = formerEvent;
  544. #endif
  545. }
  546. void wxUITextFieldControl::controlAction(WXWidget WXUNUSED(slf),
  547. void* WXUNUSED(_cmd), void *WXUNUSED(sender))
  548. {
  549. wxWindow* wxpeer = (wxWindow*) GetWXPeer();
  550. if ( wxpeer && (wxpeer->GetWindowStyle() & wxTE_PROCESS_ENTER) )
  551. {
  552. wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, wxpeer->GetId());
  553. event.SetEventObject( wxpeer );
  554. event.SetString( static_cast<wxTextCtrl*>(wxpeer)->GetValue() );
  555. wxpeer->HandleWindowEvent( event );
  556. }
  557. }
  558. bool wxUITextFieldControl::SetHint(const wxString& hint)
  559. {
  560. wxCFStringRef hintstring(hint);
  561. [m_textField setPlaceholder:hintstring.AsNSString()];
  562. }
  563. #endif
  564. //
  565. //
  566. //
  567. wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer,
  568. wxWindowMac* WXUNUSED(parent),
  569. wxWindowID WXUNUSED(id),
  570. const wxString& str,
  571. const wxPoint& pos,
  572. const wxSize& size,
  573. long style,
  574. long WXUNUSED(extraStyle))
  575. {
  576. CGRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
  577. wxWidgetIPhoneImpl* c = NULL;
  578. wxTextWidgetImpl* t = NULL;
  579. id<UITextInputTraits> tv = nil;
  580. #if wxOSX_IPHONE_USE_TEXTFIELD
  581. if ( style & wxTE_MULTILINE || style & wxTE_RICH || style & wxTE_RICH2 )
  582. #endif
  583. {
  584. UITextView * v = nil;
  585. v = [[UITextView alloc] initWithFrame:r];
  586. tv = v;
  587. wxUITextViewControl* tc = new wxUITextViewControl( wxpeer, v );
  588. c = tc;
  589. t = tc;
  590. }
  591. #if wxOSX_IPHONE_USE_TEXTFIELD
  592. else
  593. {
  594. wxUITextField* v = [[wxUITextField alloc] initWithFrame:r];
  595. tv = v;
  596. v.textColor = [UIColor blackColor];
  597. v.font = [UIFont systemFontOfSize:17.0];
  598. v.backgroundColor = [UIColor whiteColor];
  599. v.clearButtonMode = UITextFieldViewModeNever;
  600. [v setBorderStyle:UITextBorderStyleBezel];
  601. if ( style & wxNO_BORDER )
  602. v.borderStyle = UITextBorderStyleNone;
  603. wxUITextFieldControl* tc = new wxUITextFieldControl( wxpeer, v );
  604. c = tc;
  605. t = tc;
  606. }
  607. #endif
  608. if ( style & wxTE_PASSWORD )
  609. [tv setSecureTextEntry:YES];
  610. if ( !(style & wxTE_MULTILINE) )
  611. {
  612. [tv setAutocorrectionType:UITextAutocorrectionTypeNo];
  613. [tv setReturnKeyType:UIReturnKeyDone];
  614. }
  615. [tv setKeyboardType:UIKeyboardTypeDefault];
  616. t->SetStringValue(str);
  617. return c;
  618. }
  619. #endif // wxUSE_TEXTCTRL