~ubuntu-branches/ubuntu/maverick/wxwidgets2.8/maverick-proposed

« back to all changes in this revision

Viewing changes to src/cocoa/textctrl.mm

  • Committer: Bazaar Package Importer
  • Author(s): Devid Filoni
  • Date: 2008-06-30 22:02:17 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080630220217-vag3tkfp91t0453d
Tags: 2.8.8.0-0ubuntu1
* New upstream version, based on the upstream tarball
  wxPython-src-2.8.8.0.tar.bz2, remove upstream debian dir (LP: #244355).
* Add debian/watch file, LP: #242164.
* Edit get-orig-source target to provide a .orig.tar.gz with the same md5 for
  each .orig.tar.gz generated.
* debian/rules: remove get-orig-source from .PHONY target.
* debian/control.in: add python-wxtools in python-wxgtk=V=U Suggests field.
* Do not apply fix_from_upstream_svn_r52465 patch, not needed.
* Regenerate octave_oct, tcl_tk_tcl patches for the new version.
* Fix spelling-error-in-description lintian warning.
* Fix depends-on-obsolete-package lintian error.
* Fix executable-not-elf-or-script lintian warnings.
* Fix script-not-executable lintian warnings.
* Fix missing-dependency-on-libc lintian error.
* Fix dbg-package-missing-depends lintian warnings.
* Fix package-contains-empty-directory lintian warnings.
* Fix manpage-has-errors-from-man lintian warning.
* Fix image-file-in-usr-lib lintian warnings:
  - add editra_pixmaps patch
  - add xrced_bitmaps patch
* Fix unused-override lintian info.
* Fix malformed-override lintian errors.
* Fix extra-license-file lintian warnings.
* Install upstream wx.pth instead of generated file links (LP: #211553).
* Add editra.png, pyshell.png (encoded using uuencode) icons, LP: #236876:
  - debian/rules: use uudecode to decode .png icons.
* Add a new pyshell.xpm icon.
* Fix doc-base-file-references-missing-file lintian error.
* Fix doc-base-unknown-section lintian warning.
* Fix ruby-script-but-no-ruby-dep lintian errors.
* Fix wish-script-but-no-wish-dep lintian errors.
* Fix missing-dep-for-interpreter errors.
* Bump Standards-Version to 3.8.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
// Author:      David Elliott
5
5
// Modified by: Mark Oxenham
6
6
// Created:     2003/03/16
7
 
// RCS-ID:      $Id: textctrl.mm 48754 2007-09-17 16:43:30Z DE $
 
7
// RCS-ID:      $Id: textctrl.mm 50334 2007-11-30 05:08:21Z DE $
8
8
// Copyright:   (c) 2003 David Elliott
9
9
// Licence:     wxWidgets licence
10
10
/////////////////////////////////////////////////////////////////////////////
21
21
#include "wx/cocoa/string.h"
22
22
 
23
23
#include "wx/cocoa/autorelease.h"
 
24
#include "wx/cocoa/ObjcRef.h"
24
25
 
25
26
#import <Foundation/NSString.h>
26
27
#import <AppKit/NSTextField.h>
32
33
IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxTextCtrlBase)
33
34
BEGIN_EVENT_TABLE(wxTextCtrl, wxTextCtrlBase)
34
35
END_EVENT_TABLE()
35
 
WX_IMPLEMENT_COCOA_OWNER(wxTextCtrl,NSTextField,NSControl,NSView)
36
36
 
 
37
// Replaced by special 2.8 code:
 
38
//WX_IMPLEMENT_COCOA_OWNER(wxTextCtrl,NSTextField,NSControl,NSView)
37
39
bool wxTextCtrl::Create(wxWindow *parent, wxWindowID winid,
38
40
            const wxString& value,
39
41
            const wxPoint& pos,
270
272
    wxLogTrace(wxTRACE_COCOA_Window_Size,wxT("wxTextCtrl=%p::DoGetBestSize()==(%d,%d)"),this,size.x,size.y);
271
273
    return size;
272
274
}
 
275
 
 
276
///////////////////////////////////////////////////////////////////////////
 
277
// Added within the 2.8 release cycle, just after 2.8.7:
 
278
 
 
279
@interface WXNSTextFieldDelegate : NSObject
 
280
{
 
281
}
 
282
 
 
283
- (void)controlTextDidChange:(NSNotification*)notification;
 
284
@end // @interface WXNSTextFieldDelegate : NSObject
 
285
 
 
286
WX_DECLARE_HASH_MAP(WX_NSTextField, wxTextCtrl*, wxPointerHash, wxPointerEqual, wxCocoaNSTextField_wxTextCtrl_Hash);
 
287
 
 
288
static wxCocoaNSTextField_wxTextCtrl_Hash sg_textField_textCtrl_hash;
 
289
static wxObjcAutoRefFromAlloc<WXNSTextFieldDelegate*> sg_cocoaDelegate([[WXNSTextFieldDelegate alloc] init]);
 
290
 
 
291
static inline wxTextCtrl* GetTextCtrlFromCocoaTextField(WX_NSTextField cocoaObjcClass)
 
292
{
 
293
    wxCocoaNSTextField_wxTextCtrl_Hash::iterator iter = sg_textField_textCtrl_hash.find(cocoaObjcClass);
 
294
    if(iter != sg_textField_textCtrl_hash.end())
 
295
        return iter->second;
 
296
    return NULL;
 
297
}
 
298
 
 
299
void wxTextCtrl::SetNSTextField(WX_NSTextField cocoaObjcClass)
 
300
{
 
301
    DisassociateNSTextField((WX_NSTextField)m_cocoaNSView);
 
302
    if(m_cocoaNSView)
 
303
    {
 
304
        sg_textField_textCtrl_hash.erase((WX_NSTextField)m_cocoaNSView);
 
305
        [(WX_NSTextField)m_cocoaNSView setDelegate:nil];
 
306
    }
 
307
    SetNSControl(cocoaObjcClass);
 
308
    AssociateNSTextField((WX_NSTextField)m_cocoaNSView);
 
309
    if(m_cocoaNSView)
 
310
    {
 
311
        sg_textField_textCtrl_hash.insert(wxCocoaNSTextField_wxTextCtrl_Hash::value_type((WX_NSTextField)m_cocoaNSView, this));
 
312
        [(WX_NSTextField)m_cocoaNSView setDelegate:sg_cocoaDelegate];
 
313
    }
 
314
}
 
315
 
 
316
inline void wxTextCtrl::CocoaNotification_controlTextDidChange(WX_NSNotification notification)
 
317
{
 
318
    wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, GetId());
 
319
 
 
320
    // See wxTextCtrlBase::SendTextUpdatedEvent for why we don't set the string.
 
321
    //event.SetString(GetValue());
 
322
 
 
323
    event.SetEventObject(this);
 
324
    GetEventHandler()->ProcessEvent(event);
 
325
}
 
326
 
 
327
@implementation WXNSTextFieldDelegate : NSObject
 
328
 
 
329
- (void)controlTextDidChange:(NSNotification*)notification
 
330
{
 
331
    wxTextCtrl *tc = GetTextCtrlFromCocoaTextField([notification object]);
 
332
    if(tc != NULL)
 
333
        tc->CocoaNotification_controlTextDidChange(notification);
 
334
}
 
335
 
 
336
 
 
337
@end // @implementation WXNSTextFieldDelegate : NSObject
 
338