diff --git a/docs/changes.txt b/docs/changes.txt index 30145ad3d6..2bcff22574 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -637,7 +637,21 @@ wxOSX: - Fix length of text in wxTextDataObject. - Fix using wxHTTP and wxFTP from worker thread. - Fix wxFileDialog::GetFilterIndex() for file open dialogs (phsilva). +- Fix wxSearchCtrl appearance under 10.10 (John Roberts). +- Fix handling of "Cancel" button in wxSearchCtrl (John Roberts). +- Generate correct events for WXK_NUMPAD_ENTER (John Roberts). +- Fix handling of WXK_NUMPAD_ENTER in wxTextCtrl (John Roberts). +- Don't show wxDatePickerCtrl as being disabled when it isn't (John Roberts). +- Generate wxEVT_TEXT_ENTER for wxTE_PASSWORD controls too (mj_smoker). +- Send wxIconizeEvent when a window is iconized/restore (Rob Krakora). +- Use correct colour for disabled wxStaticText (sbrowne). +- Fix too large top and left margins inside wxStaticBox (sbrowne). +- Fix bottom margins sizes for several controls (sbrowne). +- Fix initial position of controls with layout insets (Tim Kosse). +- Don't allow pasting rich text in non-wxTE_RICH text controls (Tim Kosse). +- Fix printing all pages non-interactively (John Roberts). - Fix custom paper support (tijsv). +- Return false from wxSound::Create()/IsOk() if the file doesn't exist. 3.0.2: (released 2014-10-06) diff --git a/include/wx/osx/nonownedwnd.h b/include/wx/osx/nonownedwnd.h index edc3f04e62..9b0d3bea4e 100644 --- a/include/wx/osx/nonownedwnd.h +++ b/include/wx/osx/nonownedwnd.h @@ -113,7 +113,9 @@ public: virtual void HandleResized( double timestampsec ); virtual void HandleMoved( double timestampsec ); virtual void HandleResizing( double timestampsec, wxRect* rect ); - + + void OSXHandleMiniaturize(double WXUNUSED(timestampsec), bool miniaturized); + void WindowWasPainted(); virtual bool Destroy(); diff --git a/include/wx/osx/toplevel.h b/include/wx/osx/toplevel.h index 73b218fe75..d162b4121f 100644 --- a/include/wx/osx/toplevel.h +++ b/include/wx/osx/toplevel.h @@ -81,6 +81,9 @@ public: virtual void SetRepresentedFilename(const wxString& filename); + // do *not* call this to iconize the frame, this is a private function! + void OSXSetIconizeState(bool iconic); + protected: // common part of all ctors void Init(); diff --git a/interface/wx/event.h b/interface/wx/event.h index 52bb60970b..37eeae6093 100644 --- a/interface/wx/event.h +++ b/interface/wx/event.h @@ -4210,8 +4210,6 @@ public: An event being sent when the frame is iconized (minimized) or restored. - Currently only wxMSW and wxGTK generate such events. - @onlyfor{wxmsw,wxgtk} @beginEventTable{wxIconizeEvent} diff --git a/samples/sound/sound.cpp b/samples/sound/sound.cpp index de18ca59cf..85dca32f96 100644 --- a/samples/sound/sound.cpp +++ b/samples/sound/sound.cpp @@ -81,6 +81,7 @@ public: private: bool CreateSound(wxSound& snd) const; + wxSound* TryCreateSound() const; wxSound* m_sound; wxString m_soundFile; @@ -975,6 +976,17 @@ bool MyFrame::CreateSound(wxSound& snd) const return snd.Create(m_soundFile); } +wxSound* MyFrame::TryCreateSound() const +{ + wxSound* const sound = new wxSound; + if ( !CreateSound(*sound) ) + { + delete sound; + return NULL; + } + + return sound; +} void MyFrame::NotifyUsingFile(const wxString& name) { @@ -1054,12 +1066,9 @@ void MyFrame::OnPlaySync(wxCommandEvent& WXUNUSED(event)) { wxBusyCursor busy; if ( !m_sound ) - { - m_sound = new wxSound; - CreateSound(*m_sound); - } + m_sound = TryCreateSound(); - if (m_sound->IsOk()) + if (m_sound) m_sound->Play(wxSOUND_SYNC); } @@ -1067,12 +1076,9 @@ void MyFrame::OnPlayAsync(wxCommandEvent& WXUNUSED(event)) { wxBusyCursor busy; if ( !m_sound ) - { - m_sound = new wxSound; - CreateSound(*m_sound); - } + m_sound = TryCreateSound(); - if (m_sound->IsOk()) + if (m_sound) m_sound->Play(wxSOUND_ASYNC); } @@ -1089,10 +1095,7 @@ void MyFrame::OnPlayLoop(wxCommandEvent& WXUNUSED(event)) { wxBusyCursor busy; if ( !m_sound ) - { - m_sound = new wxSound; - CreateSound(*m_sound); - } + m_sound = TryCreateSound(); if (m_sound->IsOk()) m_sound->Play(wxSOUND_ASYNC | wxSOUND_LOOP); diff --git a/src/osx/cocoa/button.mm b/src/osx/cocoa/button.mm index d10797440e..f38947d96f 100644 --- a/src/osx/cocoa/button.mm +++ b/src/osx/cocoa/button.mm @@ -159,17 +159,17 @@ void wxButtonCocoaImpl::GetLayoutInset(int &left , int &top , int &right, int &b case NSRegularControlSize: left = right = 6; top = 4; - bottom = 8; + bottom = 7; break; case NSSmallControlSize: left = right = 5; top = 4; - bottom = 7; + bottom = 6; break; case NSMiniControlSize: left = right = 1; top = 0; - bottom = 2; + bottom = 1; break; } } diff --git a/src/osx/cocoa/choice.mm b/src/osx/cocoa/choice.mm index 0068d5d31d..52c12b7b6b 100644 --- a/src/osx/cocoa/choice.mm +++ b/src/osx/cocoa/choice.mm @@ -81,12 +81,12 @@ public: case NSRegularControlSize: left = right = 3; top = 2; - bottom = 4; + bottom = 3; break; case NSSmallControlSize: left = right = 3; top = 1; - bottom = 4; + bottom = 3; break; case NSMiniControlSize: left = 1; diff --git a/src/osx/cocoa/datetimectrl.mm b/src/osx/cocoa/datetimectrl.mm index 575a8a2b48..edee2965a4 100644 --- a/src/osx/cocoa/datetimectrl.mm +++ b/src/osx/cocoa/datetimectrl.mm @@ -128,6 +128,26 @@ public: } } + virtual void Enable(bool enable = true) + { + wxNSDatePicker* const nsdatePicker = View(); + + [nsdatePicker setEnabled: enable]; + + if ( enable ) + { + wxWindow* const wxpeer = GetWXPeer(); + if ( wxpeer ) + [nsdatePicker setTextColor: wxpeer->GetForegroundColour().OSXGetNSColor()]; + else + [nsdatePicker setTextColor: [NSColor controlTextColor]]; + } + else + { + [nsdatePicker setTextColor: [NSColor disabledControlTextColor]]; + } + } + private: wxNSDatePicker* View() const { @@ -170,6 +190,9 @@ wxDateTimeWidgetImpl::CreateDateTimePicker(wxDateTimePickerCtrl* wxpeer, [v setDatePickerStyle: NSTextFieldAndStepperDatePickerStyle]; + // Avoid a disabled looking transparent background for the text cells. + [v setDrawsBackground: YES]; + if ( dt.IsValid() ) { [v setDateValue: NSDateFromWX(dt)]; diff --git a/src/osx/cocoa/gauge.mm b/src/osx/cocoa/gauge.mm index fe15e849a5..24f9bedc01 100644 --- a/src/osx/cocoa/gauge.mm +++ b/src/osx/cocoa/gauge.mm @@ -81,13 +81,13 @@ public : case NSRegularControlSize: left = right = 2; top = 0; - bottom = 4; + bottom = 3; break; case NSMiniControlSize: case NSSmallControlSize: left = right = 1; top = 0; - bottom = 2; + bottom = 1; break; } } diff --git a/src/osx/cocoa/nonownedwnd.mm b/src/osx/cocoa/nonownedwnd.mm index 666c63c6a7..465e52be18 100644 --- a/src/osx/cocoa/nonownedwnd.mm +++ b/src/osx/cocoa/nonownedwnd.mm @@ -309,6 +309,8 @@ static NSResponder* s_formerFirstResponder = NULL; - (void)windowDidResignKey:(NSNotification *)notification; - (void)windowDidBecomeKey:(NSNotification *)notification; - (void)windowDidMove:(NSNotification *)notification; +- (void)windowDidMiniaturize:(NSNotification *)notification; +- (void)windowDidDeminiaturize:(NSNotification *)notification; - (BOOL)windowShouldClose:(id)window; - (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame; @@ -397,6 +399,28 @@ extern int wxOSXGetIdFromSelector(SEL action ); [self triggerMenu:_cmd]; } +- (void)windowDidMiniaturize:(NSNotification *)notification +{ + NSWindow* window = (NSWindow*) [notification object]; + wxNonOwnedWindowCocoaImpl* windowimpl = [window WX_implementation]; + if ( windowimpl ) + { + if ( wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer() ) + wxpeer->OSXHandleMiniaturize(0, [window isMiniaturized]); + } +} + +- (void)windowDidDeminiaturize:(NSNotification *)notification +{ + NSWindow* window = (NSWindow*) [notification object]; + wxNonOwnedWindowCocoaImpl* windowimpl = [window WX_implementation]; + if ( windowimpl ) + { + if ( wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer() ) + wxpeer->OSXHandleMiniaturize(0, [window isMiniaturized]); + } +} + - (BOOL)windowShouldClose:(id)nwindow { wxNonOwnedWindowCocoaImpl* windowimpl = [(NSWindow*) nwindow WX_implementation]; diff --git a/src/osx/cocoa/srchctrl.mm b/src/osx/cocoa/srchctrl.mm index 880d590773..8549d8d944 100644 --- a/src/osx/cocoa/srchctrl.mm +++ b/src/osx/cocoa/srchctrl.mm @@ -155,7 +155,7 @@ public : if ( wxpeer ) { NSString *searchString = [m_searchField stringValue]; - if ( searchString == nil ) + if ( searchString == nil || !searchString.length ) { wxpeer->HandleSearchFieldCancelHit(); } @@ -165,7 +165,25 @@ public : } } } - + + virtual void SetCentredLook( bool centre ) + { + SEL sel = @selector(setCenteredLook:); + if ( [m_searchFieldCell respondsToSelector: sel] ) + { + // all this avoids xcode parsing warnings when using + // [m_searchFieldCell setCenteredLook:NO]; + NSMethodSignature* signature = + [NSSearchFieldCell instanceMethodSignatureForSelector:sel]; + NSInvocation* invocation = + [NSInvocation invocationWithMethodSignature: signature]; + [invocation setTarget: m_searchFieldCell]; + [invocation setSelector:sel]; + [invocation setArgument:¢re atIndex:2]; + [invocation invoke]; + } + } + private: wxNSSearchField* m_searchField; NSSearchFieldCell* m_searchFieldCell; @@ -192,6 +210,7 @@ wxWidgetImplType* wxWidgetImpl::CreateSearchControl( wxSearchCtrl* wxpeer, wxNSSearchFieldControl* c = new wxNSSearchFieldControl( wxpeer, v ); c->SetNeedsFrame( false ); + c->SetCentredLook( false ); c->SetStringValue( str ); return c; } diff --git a/src/osx/cocoa/statbox.mm b/src/osx/cocoa/statbox.mm index 1a346a4d75..95852e7f7b 100644 --- a/src/osx/cocoa/statbox.mm +++ b/src/osx/cocoa/statbox.mm @@ -71,6 +71,9 @@ wxWidgetImplType* wxWidgetImpl::CreateGroupBox( wxWindowMac* wxpeer, { NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ; wxNSBox* v = [[wxNSBox alloc] initWithFrame:r]; + NSSize margin = { 0.0, 0.0 }; + [v setContentViewMargins: margin]; + [v sizeToFit]; wxStaticBoxCocoaImpl* c = new wxStaticBoxCocoaImpl( wxpeer, v ); #if !wxOSX_USE_NATIVE_FLIPPED c->SetFlipped(false); diff --git a/src/osx/cocoa/stattext.mm b/src/osx/cocoa/stattext.mm index f64b589f12..755bddfdc8 100644 --- a/src/osx/cocoa/stattext.mm +++ b/src/osx/cocoa/stattext.mm @@ -76,7 +76,7 @@ [m_textColor release]; m_textColor = [[self textColor] retain]; } - [self setTextColor: [NSColor secondarySelectedControlColor]]; + [self setTextColor: [NSColor disabledControlTextColor]]; } } } diff --git a/src/osx/cocoa/textctrl.mm b/src/osx/cocoa/textctrl.mm index a16023b024..a2caa6e71a 100644 --- a/src/osx/cocoa/textctrl.mm +++ b/src/osx/cocoa/textctrl.mm @@ -213,17 +213,29 @@ NSView* wxMacEditHelper::ms_viewCurrentlyEdited = nil; { if (commandSelector == @selector(insertNewline:)) { - wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(wxpeer), wxTopLevelWindow); - if ( tlw && tlw->GetDefaultItem() ) + if ( wxpeer->GetWindowStyle() & wxTE_PROCESS_ENTER ) { - wxButton *def = wxDynamicCast(tlw->GetDefaultItem(), wxButton); - if ( def && def->IsEnabled() ) + wxCommandEvent event(wxEVT_TEXT_ENTER, wxpeer->GetId()); + event.SetEventObject( wxpeer ); + wxTextWidgetImpl* impl = (wxNSTextFieldControl * ) wxWidgetImpl::FindFromWXWidget( self ); + wxTextEntry * const entry = impl->GetTextEntry(); + event.SetString( entry->GetValue() ); + handled = wxpeer->HandleWindowEvent( event ); + } + else + { + wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(wxpeer), wxTopLevelWindow); + if ( tlw && tlw->GetDefaultItem() ) { - wxCommandEvent event(wxEVT_BUTTON, def->GetId() ); - event.SetEventObject(def); - def->Command(event); - handled = YES; - } + wxButton *def = wxDynamicCast(tlw->GetDefaultItem(), wxButton); + if ( def && def->IsEnabled() ) + { + wxCommandEvent event(wxEVT_BUTTON, def->GetId() ); + event.SetEventObject(def); + def->Command(event); + handled = YES; + } + } } } } @@ -568,6 +580,11 @@ wxNSTextViewControl::wxNSTextViewControl( wxTextCtrl *wxPeer, WXWidget w ) [tv setHorizontallyResizable:NO]; [tv setAutoresizingMask:NSViewWidthSizable]; + if ( !wxPeer->HasFlag(wxTE_RICH | wxTE_RICH2) ) + { + [tv setRichText:NO]; + } + [m_scrollView setDocumentView: tv]; [tv setDelegate: tv]; diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm index 517ae4a53a..2b56a1b529 100644 --- a/src/osx/cocoa/window.mm +++ b/src/osx/cocoa/window.mm @@ -232,6 +232,10 @@ long wxOSXTranslateCocoaKey( NSEvent* event, int eventType ) { switch ( [s characterAtIndex:0] ) { + // numpad enter key End-of-text character ETX U+0003 + case 3: + retval = WXK_NUMPAD_ENTER; + break; // backspace key case 0x7F : case 8 : @@ -345,9 +349,6 @@ long wxOSXTranslateCocoaKey( NSEvent* event, int eventType ) case 69: // + retval = WXK_NUMPAD_ADD; break; - case 76: // Enter - retval = WXK_NUMPAD_ENTER; - break; case 65: // . retval = WXK_NUMPAD_DECIMAL; break; diff --git a/src/osx/core/printmac.cpp b/src/osx/core/printmac.cpp index be3eb63aaa..5f33c3ccc3 100644 --- a/src/osx/core/printmac.cpp +++ b/src/osx/core/printmac.cpp @@ -637,10 +637,21 @@ bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt) } // Only set min and max, because from and to will be - // set by the user + // set by the user if prompted for the print dialog above m_printDialogData.SetMinPage(minPage); m_printDialogData.SetMaxPage(maxPage); + // Set from and to pages if bypassing the print dialog + if ( !prompt ) + { + m_printDialogData.SetFromPage(fromPage); + + if( m_printDialogData.GetAllPages() ) + m_printDialogData.SetToPage(maxPage); + else + m_printDialogData.SetToPage(toPage); + } + printout->OnBeginPrinting(); bool keepGoing = true; diff --git a/src/osx/core/sound.cpp b/src/osx/core/sound.cpp index 0f84638e29..d96ca0f9a3 100644 --- a/src/osx/core/sound.cpp +++ b/src/osx/core/sound.cpp @@ -34,9 +34,9 @@ class wxOSXAudioToolboxSoundData : public wxSoundData { public: - wxOSXAudioToolboxSoundData(const wxString& fileName); + explicit wxOSXAudioToolboxSoundData(SystemSoundID soundID); - ~wxOSXAudioToolboxSoundData(); + virtual ~wxOSXAudioToolboxSoundData(); virtual bool Play(unsigned flags); @@ -46,14 +46,12 @@ protected: void SoundCompleted(); SystemSoundID m_soundID; - wxString m_sndname; //file path bool m_playing; }; -wxOSXAudioToolboxSoundData::wxOSXAudioToolboxSoundData(const wxString& fileName) : - m_soundID(0) +wxOSXAudioToolboxSoundData::wxOSXAudioToolboxSoundData(SystemSoundID soundID) : + m_soundID(soundID) { - m_sndname = fileName; m_playing = false; } @@ -108,20 +106,13 @@ bool wxOSXAudioToolboxSoundData::Play(unsigned flags) m_flags = flags; - wxCFRef cfMutableString(CFStringCreateMutableCopy(NULL, 0, wxCFStringRef(m_sndname))); - CFStringNormalize(cfMutableString,kCFStringNormalizationFormD); - wxCFRef url(CFURLCreateWithFileSystemPath(kCFAllocatorDefault, cfMutableString , kCFURLPOSIXPathStyle, false)); - - AudioServicesCreateSystemSoundID(url, &m_soundID); AudioServicesAddSystemSoundCompletion( m_soundID, CFRunLoopGetCurrent(), NULL, wxOSXAudioToolboxSoundData::CompletionCallback, (void *) this ); - bool sync = !(flags & wxSOUND_ASYNC); - m_playing = true; AudioServicesPlaySystemSound(m_soundID); - if ( sync ) + if ( !(flags & wxSOUND_ASYNC) ) { while ( m_playing ) { @@ -143,7 +134,20 @@ bool wxSound::Create(const wxString& fileName, bool isResource) { wxCHECK_MSG( !isResource, false, "not implemented" ); - m_data = new wxOSXAudioToolboxSoundData(fileName); + wxCFRef cfMutableString(CFStringCreateMutableCopy(NULL, 0, wxCFStringRef(fileName))); + CFStringNormalize(cfMutableString,kCFStringNormalizationFormD); + wxCFRef url(CFURLCreateWithFileSystemPath(kCFAllocatorDefault, cfMutableString , kCFURLPOSIXPathStyle, false)); + + SystemSoundID soundID; + OSStatus err = AudioServicesCreateSystemSoundID(url, &soundID); + if ( err != 0 ) + { + wxLogError(_("Failed to load sound from \"%s\" (error %d)."), fileName, err); + return false; + } + + m_data = new wxOSXAudioToolboxSoundData(soundID); + return true; } diff --git a/src/osx/nonownedwnd_osx.cpp b/src/osx/nonownedwnd_osx.cpp index 0e57c7f9f9..d70ebfe2b9 100644 --- a/src/osx/nonownedwnd_osx.cpp +++ b/src/osx/nonownedwnd_osx.cpp @@ -552,4 +552,12 @@ bool wxNonOwnedWindow::DoSetPathShape(const wxGraphicsPath& path) return DoSetRegionShape(wxRegion(bmp)); } +void +wxNonOwnedWindow::OSXHandleMiniaturize(double WXUNUSED(timestampsec), + bool miniaturized) +{ + if ( wxTopLevelWindowMac* top = (wxTopLevelWindowMac*) MacGetTopLevelWindow() ) + top->OSXSetIconizeState(miniaturized); +} + #endif // wxUSE_GRAPHICS_CONTEXT diff --git a/src/osx/textctrl_osx.cpp b/src/osx/textctrl_osx.cpp index 08346e5adb..7b42796c4d 100644 --- a/src/osx/textctrl_osx.cpp +++ b/src/osx/textctrl_osx.cpp @@ -366,8 +366,10 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) bool eat_key = false ; long from, to; - if ( !IsEditable() && !event.IsKeyInCategory(WXK_CATEGORY_ARROW | WXK_CATEGORY_TAB) && - !( key == WXK_RETURN && ( (m_windowStyle & wxTE_PROCESS_ENTER) || (m_windowStyle & wxTE_MULTILINE) ) ) + if ( !IsEditable() && + !event.IsKeyInCategory(WXK_CATEGORY_ARROW | WXK_CATEGORY_TAB) && + !( (key == WXK_RETURN || key == WXK_NUMPAD_ENTER) && + ( (m_windowStyle & wxTE_PROCESS_ENTER) || (m_windowStyle & wxTE_MULTILINE) ) ) // && key != WXK_PAGEUP && key != WXK_PAGEDOWN && key != WXK_HOME && key != WXK_END ) { @@ -382,7 +384,8 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) GetSelection( &from, &to ); if ( !IsMultiLine() && m_maxLength && GetValue().length() >= m_maxLength && !event.IsKeyInCategory(WXK_CATEGORY_ARROW | WXK_CATEGORY_TAB | WXK_CATEGORY_CUT) && - !( key == WXK_RETURN && (m_windowStyle & wxTE_PROCESS_ENTER) ) && + !( (key == WXK_RETURN || key == WXK_NUMPAD_ENTER) && + (m_windowStyle & wxTE_PROCESS_ENTER) ) && from == to ) { // eat it, we don't want to add more than allowed # of characters @@ -398,6 +401,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) switch ( key ) { case WXK_RETURN: + case WXK_NUMPAD_ENTER: if (m_windowStyle & wxTE_PROCESS_ENTER) { wxCommandEvent event(wxEVT_TEXT_ENTER, m_windowId); @@ -466,6 +470,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) ( key >= WXK_NUMPAD0 && key <= WXK_DIVIDE ) || key == WXK_RETURN || key == WXK_DELETE || + key == WXK_NUMPAD_ENTER || key == WXK_BACK) { wxCommandEvent event1(wxEVT_TEXT, m_windowId); diff --git a/src/osx/toplevel_osx.cpp b/src/osx/toplevel_osx.cpp index b0dc820904..548c6431a3 100644 --- a/src/osx/toplevel_osx.cpp +++ b/src/osx/toplevel_osx.cpp @@ -224,3 +224,12 @@ void wxTopLevelWindowMac::SetRepresentedFilename(const wxString& filename) { m_nowpeer->SetRepresentedFilename(filename); } + +void wxTopLevelWindowMac::OSXSetIconizeState(bool iconize) +{ + if ( iconize != m_iconized ) + { + m_iconized = iconize; + (void)SendIconizeEvent(iconize); + } +} diff --git a/src/osx/window_osx.cpp b/src/osx/window_osx.cpp index 6bfe8e2a17..5148658209 100644 --- a/src/osx/window_osx.cpp +++ b/src/osx/window_osx.cpp @@ -457,9 +457,16 @@ void wxWindowMac::MacChildAdded() #endif } -void wxWindowMac::MacPostControlCreate(const wxPoint& WXUNUSED(pos), +void wxWindowMac::MacPostControlCreate(const wxPoint& pos, const wxSize& WXUNUSED(size)) { + // Some controls may have a nonzero layout inset, + // so we may need to adjust control position. + if ( pos.IsFullySpecified() && GetPosition() != pos ) + { + SetPosition(pos); + } + // todo remove if refactoring works correctly #if 0 wxASSERT_MSG( GetPeer() != NULL && GetPeer()->IsOk() , wxT("No valid mac control") ) ;