renaming clickedAction callbacks to more generic controlAction, textctrl updates
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58840 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
c0f6cd1924
commit
e32090bacd
@ -145,8 +145,8 @@ public :
|
||||
virtual bool isFlipped(WXWidget slf, void* _cmd);
|
||||
virtual void drawRect(void* rect, WXWidget slf, void* _cmd);
|
||||
|
||||
virtual void clickedAction(WXWidget slf, void* _cmd, void* sender);
|
||||
virtual void doubleClickedAction(WXWidget slf, void* _cmd, void *sender);
|
||||
virtual void controlAction(WXWidget slf, void* _cmd, void* sender);
|
||||
virtual void controlDoubleAction(WXWidget slf, void* _cmd, void *sender);
|
||||
|
||||
protected:
|
||||
WXWidget m_osxView;
|
||||
|
@ -32,6 +32,10 @@ public :
|
||||
virtual void GetSelection( long* from, long* to) const ;
|
||||
virtual void SetSelection( long from , long to );
|
||||
virtual void WriteText(const wxString& str) ;
|
||||
|
||||
virtual void controlAction(WXWidget slf, void* _cmd, void *sender);
|
||||
protected :
|
||||
NSTextField* m_textField;
|
||||
};
|
||||
|
||||
#endif // _WX_OSX_COCOA_PRIVATE_TEXTIMPL_H_
|
||||
|
@ -143,8 +143,8 @@ public :
|
||||
virtual void UpdateLine( unsigned int n, wxListWidgetColumn* col = NULL ) ;
|
||||
virtual void UpdateLineToEnd( unsigned int n);
|
||||
|
||||
virtual void clickedAction(WXWidget slf, void* _cmd, void *sender);
|
||||
virtual void doubleClickedAction(void* _cmd);
|
||||
virtual void controlAction(WXWidget slf, void* _cmd, void *sender);
|
||||
virtual void controlDoubleAction(void* _cmd);
|
||||
protected :
|
||||
wxNSTableView* m_tableView ;
|
||||
|
||||
@ -326,8 +326,17 @@ wxListWidgetColumn* wxListWidgetCocoaImpl::InsertTextColumn( unsigned pos, const
|
||||
{
|
||||
[col1 setMaxWidth:defaultWidth];
|
||||
[col1 setMinWidth:defaultWidth];
|
||||
[col1 setWidth:defaultWidth];
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
[col1 setMaxWidth:1000];
|
||||
[col1 setMinWidth:10];
|
||||
// temporary hack, because I cannot get the automatic column resizing
|
||||
// to work properly
|
||||
[col1 setWidth:1000];
|
||||
}
|
||||
[col1 setResizingMask: NSTableColumnAutoresizingMask];
|
||||
wxCocoaTableColumn* wxcol = new wxCocoaTableColumn( col1, editable );
|
||||
[col1 setColumn:wxcol];
|
||||
|
||||
@ -360,8 +369,10 @@ wxListWidgetColumn* wxListWidgetCocoaImpl::InsertCheckColumn( unsigned pos , con
|
||||
{
|
||||
[col1 setMaxWidth:defaultWidth];
|
||||
[col1 setMinWidth:defaultWidth];
|
||||
[col1 setWidth:defaultWidth];
|
||||
}
|
||||
|
||||
[col1 setResizingMask: NSTableColumnNoResizing];
|
||||
wxCocoaTableColumn* wxcol = new wxCocoaTableColumn( col1, editable );
|
||||
[col1 setColumn:wxcol];
|
||||
|
||||
@ -471,7 +482,7 @@ void wxListWidgetCocoaImpl::UpdateLineToEnd( unsigned int n)
|
||||
[m_tableView reloadData];
|
||||
}
|
||||
|
||||
void wxListWidgetCocoaImpl::clickedAction(WXWidget slf,void* _cmd, void *sender)
|
||||
void wxListWidgetCocoaImpl::controlAction(WXWidget slf,void* _cmd, void *sender)
|
||||
{
|
||||
wxListBox *list = static_cast<wxListBox*> ( GetWXPeer());
|
||||
wxCHECK_RET( list != NULL , wxT("Listbox expected"));
|
||||
@ -485,7 +496,7 @@ void wxListWidgetCocoaImpl::clickedAction(WXWidget slf,void* _cmd, void *sender)
|
||||
list->HandleLineEvent( sel, false );
|
||||
}
|
||||
|
||||
void wxListWidgetCocoaImpl::doubleClickedAction(void* _cmd)
|
||||
void wxListWidgetCocoaImpl::controlDoubleAction(void* _cmd)
|
||||
{
|
||||
wxListBox *list = static_cast<wxListBox*> ( GetWXPeer());
|
||||
wxCHECK_RET( list != NULL , wxT("Listbox expected"));
|
||||
@ -519,13 +530,10 @@ wxWidgetImplType* wxWidgetImpl::CreateListBox( wxWindowMac* wxpeer,
|
||||
[scrollview setHasHorizontalScroller:YES];
|
||||
|
||||
[scrollview setAutohidesScrollers: ((style & wxLB_ALWAYS_SB) ? NO : YES)];
|
||||
|
||||
|
||||
// setting up the true table
|
||||
|
||||
wxNSTableView* tableview = [[wxNSTableView alloc] init];
|
||||
[scrollview setDocumentView:tableview];
|
||||
[tableview release];
|
||||
|
||||
// only one multi-select mode available
|
||||
if ( (style & wxLB_EXTENDED) || (style & wxLB_MULTIPLE) )
|
||||
[tableview setAllowsMultipleSelection:YES];
|
||||
@ -533,9 +541,16 @@ wxWidgetImplType* wxWidgetImpl::CreateListBox( wxWindowMac* wxpeer,
|
||||
// simple listboxes have no header row
|
||||
[tableview setHeaderView:nil];
|
||||
|
||||
[tableview setColumnAutoresizingStyle:NSTableViewLastColumnOnlyAutoresizingStyle];
|
||||
if ( style & wxLB_HSCROLL )
|
||||
[tableview setColumnAutoresizingStyle:NSTableViewNoColumnAutoresizing];
|
||||
else
|
||||
[tableview setColumnAutoresizingStyle:NSTableViewLastColumnOnlyAutoresizingStyle];
|
||||
|
||||
wxNSTableDataSource* ds = [[ wxNSTableDataSource alloc] init];
|
||||
[tableview setDataSource:ds];
|
||||
[scrollview setDocumentView:tableview];
|
||||
[tableview release];
|
||||
|
||||
wxListWidgetCocoaImpl* c = new wxListWidgetCocoaImpl( wxpeer, scrollview, tableview, ds );
|
||||
|
||||
// temporary hook for dnd
|
||||
|
@ -75,7 +75,7 @@ public :
|
||||
return m_maximum;
|
||||
}
|
||||
|
||||
virtual void clickedAction(WXWidget slf, void* _cmd, void *sender);
|
||||
virtual void controlAction(WXWidget slf, void* _cmd, void *sender);
|
||||
virtual void mouseEvent(WX_NSEvent event, WXWidget slf, void* _cmd);
|
||||
protected:
|
||||
wxInt32 m_maximum;
|
||||
@ -87,7 +87,7 @@ protected:
|
||||
// to thumbtrack and only after super mouseDown
|
||||
// returns we will call the thumbrelease
|
||||
|
||||
void wxOSXScrollBarCocoaImpl::clickedAction( WXWidget slf, void *_cmd, void *sender)
|
||||
void wxOSXScrollBarCocoaImpl::controlAction( WXWidget slf, void *_cmd, void *sender)
|
||||
{
|
||||
wxEventType scrollEvent = wxEVT_NULL;
|
||||
switch ([(NSScroller*)m_osxView hitPart])
|
||||
|
@ -47,7 +47,7 @@ public :
|
||||
{
|
||||
}
|
||||
|
||||
virtual void clickedAction(WXWidget slf, void* _cmd, void *sender);
|
||||
virtual void controlAction(WXWidget slf, void* _cmd, void *sender);
|
||||
virtual void mouseEvent(WX_NSEvent event, WXWidget slf, void* _cmd);
|
||||
};
|
||||
|
||||
@ -57,7 +57,7 @@ public :
|
||||
// to thumbtrack and only after super mouseDown
|
||||
// returns we will call the thumbrelease
|
||||
|
||||
void wxSliderCocoaImpl::clickedAction( WXWidget slf, void *_cmd, void *sender)
|
||||
void wxSliderCocoaImpl::controlAction( WXWidget slf, void *_cmd, void *sender)
|
||||
{
|
||||
wxWindow* wxpeer = (wxWindow*) GetWXPeer();
|
||||
if ( wxpeer )
|
||||
|
@ -48,7 +48,7 @@ public :
|
||||
{
|
||||
}
|
||||
|
||||
virtual void clickedAction(WXWidget slf, void* _cmd, void *sender);
|
||||
virtual void controlAction(WXWidget slf, void* _cmd, void *sender);
|
||||
virtual void mouseEvent(WX_NSEvent event, WXWidget slf, void* _cmd);
|
||||
private:
|
||||
int m_formerValue;
|
||||
@ -66,7 +66,7 @@ void wxSpinButtonCocoaImpl::mouseEvent(WX_NSEvent event, WXWidget slf, void *_cm
|
||||
wxWidgetCocoaImpl::mouseEvent(event, slf, _cmd);
|
||||
}
|
||||
|
||||
void wxSpinButtonCocoaImpl::clickedAction( WXWidget slf, void *_cmd, void *sender)
|
||||
void wxSpinButtonCocoaImpl::controlAction( WXWidget slf, void *_cmd, void *sender)
|
||||
{
|
||||
wxWindow* wxpeer = (wxWindow*) GetWXPeer();
|
||||
if ( wxpeer )
|
||||
|
@ -55,12 +55,6 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
// use our common calls
|
||||
- (void) setTitle:(NSString *) title
|
||||
{
|
||||
[self setStringValue: title];
|
||||
}
|
||||
|
||||
- (void) searchAction: (id) sender
|
||||
{
|
||||
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
|
||||
|
@ -49,6 +49,24 @@
|
||||
#include "wx/osx/private.h"
|
||||
#include "wx/osx/cocoa/private/textimpl.h"
|
||||
|
||||
@interface wxNSSecureTextField : NSSecureTextField
|
||||
|
||||
@end
|
||||
|
||||
@implementation wxNSSecureTextField
|
||||
|
||||
+ (void)initialize
|
||||
{
|
||||
static BOOL initialized = NO;
|
||||
if (!initialized)
|
||||
{
|
||||
initialized = YES;
|
||||
wxOSXCocoaClassAddWXMethods( self );
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation wxNSTextField
|
||||
|
||||
+ (void)initialize
|
||||
@ -61,20 +79,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(NSRect)frame
|
||||
{
|
||||
[super initWithFrame:frame];
|
||||
[self setDelegate: self];
|
||||
[self setTarget: self];
|
||||
// [self setAction: @selector(enterAction:)];
|
||||
return self;
|
||||
}
|
||||
|
||||
// use our common calls
|
||||
- (void) setTitle:(NSString *) title
|
||||
{
|
||||
[self setStringValue: title];
|
||||
}
|
||||
/*
|
||||
- (void)controlTextDidChange:(NSNotification *)aNotification
|
||||
{
|
||||
@ -103,25 +107,13 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) enterAction: (id) sender
|
||||
{
|
||||
if ( impl )
|
||||
{
|
||||
wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
|
||||
if ( wxpeer && (wxpeer->GetWindowStyle() & wxTE_PROCESS_ENTER) ) {
|
||||
wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, wxpeer->GetId());
|
||||
event.SetEventObject( wxpeer );
|
||||
event.SetString( static_cast<wxTextCtrl*>(wxpeer)->GetValue() );
|
||||
wxpeer->HandleWindowEvent( event );
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@end
|
||||
|
||||
wxNSTextFieldControl::wxNSTextFieldControl( wxTextCtrl *wxPeer, WXWidget w ) : wxWidgetCocoaImpl(wxPeer, w)
|
||||
{
|
||||
m_textField = (NSTextField*) w;
|
||||
[m_textField setDelegate: w];
|
||||
}
|
||||
|
||||
wxNSTextFieldControl::~wxNSTextFieldControl()
|
||||
@ -130,41 +122,68 @@ wxNSTextFieldControl::~wxNSTextFieldControl()
|
||||
|
||||
wxString wxNSTextFieldControl::GetStringValue() const
|
||||
{
|
||||
wxCFStringRef cf( (CFStringRef) [[(wxNSTextField*) m_osxView stringValue] retain] );
|
||||
wxCFStringRef cf( (CFStringRef) [[m_textField stringValue] retain] );
|
||||
return cf.AsString(m_wxPeer->GetFont().GetEncoding());
|
||||
}
|
||||
void wxNSTextFieldControl::SetStringValue( const wxString &str)
|
||||
{
|
||||
[(wxNSTextField*) m_osxView setStringValue: wxCFStringRef( str , m_wxPeer->GetFont().GetEncoding() ).AsNSString()];
|
||||
[m_textField setStringValue: wxCFStringRef( str , m_wxPeer->GetFont().GetEncoding() ).AsNSString()];
|
||||
}
|
||||
void wxNSTextFieldControl::Copy()
|
||||
{
|
||||
NSText* editor = [m_textField currentEditor];
|
||||
if ( editor )
|
||||
{
|
||||
[editor copy:nil];
|
||||
}
|
||||
}
|
||||
|
||||
void wxNSTextFieldControl::Cut()
|
||||
{
|
||||
NSText* editor = [m_textField currentEditor];
|
||||
if ( editor )
|
||||
{
|
||||
[editor cut:nil];
|
||||
}
|
||||
}
|
||||
|
||||
void wxNSTextFieldControl::Paste()
|
||||
{
|
||||
NSText* editor = [m_textField currentEditor];
|
||||
if ( editor )
|
||||
{
|
||||
[editor paste:nil];
|
||||
}
|
||||
}
|
||||
|
||||
bool wxNSTextFieldControl::CanPaste() const
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxNSTextFieldControl::SetEditable(bool editable)
|
||||
{
|
||||
[(wxNSTextField*) m_osxView setEditable:editable];
|
||||
[m_textField setEditable:editable];
|
||||
}
|
||||
|
||||
void wxNSTextFieldControl::GetSelection( long* from, long* to) const
|
||||
{
|
||||
NSText* editor = [m_textField currentEditor];
|
||||
if ( editor )
|
||||
{
|
||||
NSRange range = [editor selectedRange];
|
||||
*from = range.location;
|
||||
*to = range.location + range.length;
|
||||
}
|
||||
}
|
||||
|
||||
void wxNSTextFieldControl::SetSelection( long from , long to )
|
||||
{
|
||||
NSText* editor = [m_textField currentEditor];
|
||||
if ( editor )
|
||||
{
|
||||
[editor setSelectedRange:NSMakeRange(from, to-from)];
|
||||
}
|
||||
}
|
||||
|
||||
void wxNSTextFieldControl::WriteText(const wxString& str)
|
||||
@ -174,6 +193,22 @@ void wxNSTextFieldControl::WriteText(const wxString& str)
|
||||
SetStringValue( former + str );
|
||||
}
|
||||
|
||||
void wxNSTextFieldControl::controlAction(WXWidget slf, void* _cmd, void *sender)
|
||||
{
|
||||
wxWindow* wxpeer = (wxWindow*) GetWXPeer();
|
||||
if ( wxpeer && (wxpeer->GetWindowStyle() & wxTE_PROCESS_ENTER) )
|
||||
{
|
||||
wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, wxpeer->GetId());
|
||||
event.SetEventObject( wxpeer );
|
||||
event.SetString( static_cast<wxTextCtrl*>(wxpeer)->GetValue() );
|
||||
wxpeer->HandleWindowEvent( event );
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer,
|
||||
wxWindowMac* parent,
|
||||
wxWindowID id,
|
||||
@ -184,7 +219,12 @@ wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer,
|
||||
long extraStyle)
|
||||
{
|
||||
NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
|
||||
wxNSTextField* v = [[wxNSTextField alloc] initWithFrame:r];
|
||||
NSTextField* v = nil;
|
||||
|
||||
if ( style & wxTE_PASSWORD )
|
||||
v =[[wxNSSecureTextField alloc] initWithFrame:r];
|
||||
else
|
||||
v= [[wxNSTextField alloc] initWithFrame:r];
|
||||
|
||||
if ( style & wxNO_BORDER )
|
||||
{
|
||||
@ -192,6 +232,8 @@ wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer,
|
||||
[v setBordered:NO];
|
||||
}
|
||||
|
||||
[v setBezeled:NO];
|
||||
[v setBordered:NO];
|
||||
//[v setBezeled:NO];
|
||||
//[v setEditable:NO];
|
||||
//[v setDrawsBackground:NO];
|
||||
|
@ -316,16 +316,17 @@ void SetupMouseEvent( wxMouseEvent &wxevent , NSEvent * nsEvent )
|
||||
case NSScrollWheel :
|
||||
{
|
||||
wxevent.SetEventType( wxEVT_MOUSEWHEEL ) ;
|
||||
wxevent.m_wheelDelta = 1;
|
||||
wxevent.m_wheelDelta = 10;
|
||||
wxevent.m_linesPerAction = 1;
|
||||
NSLog(@"deltaX %f, deltaY %f",[nsEvent deltaX], [nsEvent deltaY]);
|
||||
if ( abs([nsEvent deltaX]) > abs([nsEvent deltaY]) )
|
||||
{
|
||||
wxevent.m_wheelAxis = 1;
|
||||
wxevent.m_wheelRotation = [nsEvent deltaX] > 0.0 ? 1 : -1;
|
||||
wxevent.m_wheelRotation = [nsEvent deltaX] * 10.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
wxevent.m_wheelRotation = [nsEvent deltaY] > 0.0 ? 1 : -1;
|
||||
wxevent.m_wheelRotation = [nsEvent deltaY] * 10.0;
|
||||
}
|
||||
}
|
||||
break ;
|
||||
@ -479,22 +480,22 @@ void wxOSX_drawRect(NSView* self, SEL _cmd, NSRect rect)
|
||||
return impl->drawRect(&rect, self, _cmd);
|
||||
}
|
||||
|
||||
void wxOSX_clickedAction(NSView* self, SEL _cmd, id sender)
|
||||
void wxOSX_controlAction(NSView* self, SEL _cmd, id sender)
|
||||
{
|
||||
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
|
||||
if (impl == NULL)
|
||||
return;
|
||||
|
||||
impl->clickedAction(self, _cmd, sender);
|
||||
impl->controlAction(self, _cmd, sender);
|
||||
}
|
||||
|
||||
void wxOSX_doubleClickedAction(NSView* self, SEL _cmd, id sender)
|
||||
void wxOSX_controlDoubleAction(NSView* self, SEL _cmd, id sender)
|
||||
{
|
||||
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
|
||||
if (impl == NULL)
|
||||
return;
|
||||
|
||||
impl->doubleClickedAction(self, _cmd, sender);
|
||||
impl->controlDoubleAction(self, _cmd, sender);
|
||||
}
|
||||
|
||||
unsigned int wxWidgetCocoaImpl::draggingEntered(void* s, WXWidget slf, void *_cmd)
|
||||
@ -774,14 +775,14 @@ void wxWidgetCocoaImpl::drawRect(void* rect, WXWidget slf, void *_cmd)
|
||||
CGContextRestoreGState( context );
|
||||
}
|
||||
|
||||
void wxWidgetCocoaImpl::clickedAction( WXWidget slf, void *_cmd, void *sender)
|
||||
void wxWidgetCocoaImpl::controlAction( WXWidget slf, void *_cmd, void *sender)
|
||||
{
|
||||
wxWindow* wxpeer = (wxWindow*) GetWXPeer();
|
||||
if ( wxpeer )
|
||||
wxpeer->OSXHandleClicked(0);
|
||||
}
|
||||
|
||||
void wxWidgetCocoaImpl::doubleClickedAction( WXWidget slf, void *_cmd, void *sender)
|
||||
void wxWidgetCocoaImpl::controlDoubleAction( WXWidget slf, void *_cmd, void *sender)
|
||||
{
|
||||
}
|
||||
|
||||
@ -839,8 +840,8 @@ void wxOSXCocoaClassAddWXMethods(Class c)
|
||||
wxOSX_CLASS_ADD_METHOD(c, @selector(isFlipped), (IMP) wxOSX_isFlipped, "c@:" )
|
||||
wxOSX_CLASS_ADD_METHOD(c, @selector(drawRect:), (IMP) wxOSX_drawRect, "v@:{_NSRect={_NSPoint=ff}{_NSSize=ff}}" )
|
||||
|
||||
wxOSX_CLASS_ADD_METHOD(c, @selector(clickedAction:), (IMP) wxOSX_clickedAction, "v@:@" )
|
||||
wxOSX_CLASS_ADD_METHOD(c, @selector(doubleClickedAction:), (IMP) wxOSX_doubleClickedAction, "v@:@" )
|
||||
wxOSX_CLASS_ADD_METHOD(c, @selector(controlAction:), (IMP) wxOSX_controlAction, "v@:@" )
|
||||
wxOSX_CLASS_ADD_METHOD(c, @selector(controlDoubleAction:), (IMP) wxOSX_controlDoubleAction, "v@:@" )
|
||||
|
||||
#if wxUSE_DRAG_AND_DROP
|
||||
wxOSX_CLASS_ADD_METHOD(c, @selector(draggingEntered:), (IMP) wxOSX_draggingEntered, "I@:@" )
|
||||
@ -1046,6 +1047,11 @@ void wxWidgetCocoaImpl::SetLabel( const wxString& title, wxFontEncoding encoding
|
||||
wxCFStringRef cf( title , m_wxPeer->GetFont().GetEncoding() );
|
||||
[m_osxView setTitle:cf.AsNSString()];
|
||||
}
|
||||
else if ( [m_osxView respondsToSelector:@selector(setStringValue:) ] )
|
||||
{
|
||||
wxCFStringRef cf( title , m_wxPeer->GetFont().GetEncoding() );
|
||||
[m_osxView setStringValue:cf.AsNSString()];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1202,10 +1208,10 @@ void wxWidgetCocoaImpl::InstallEventHandler( WXWidget control )
|
||||
if ([c respondsToSelector:@selector(setAction:)])
|
||||
{
|
||||
[c setTarget: c];
|
||||
[c setAction: @selector(clickedAction:)];
|
||||
[c setAction: @selector(controlAction:)];
|
||||
if ([c respondsToSelector:@selector(setDoubleAction:)])
|
||||
{
|
||||
[c setDoubleAction: @selector(doubleClickedAction:)];
|
||||
[c setDoubleAction: @selector(controlDoubleAction:)];
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user