#include "wx/intl.h"
#include "wx/mac/uma.h"
+
IMPLEMENT_CLASS(wxMessageDialog, wxDialog)
-wxMessageDialog::wxMessageDialog(wxWindow *parent, const wxString& message, const wxString& caption,
- long style, const wxPoint& pos)
+
+wxMessageDialog::wxMessageDialog(
+ wxWindow *parent, const wxString& message, const wxString& caption,
+ long style, const wxPoint& pos )
{
m_caption = caption;
m_message = message;
int wxMessageDialog::ShowModal()
{
- int resultbutton = wxID_CANCEL ;
+ int resultbutton = wxID_CANCEL;
const long style = GetMessageDialogStyle();
- wxASSERT_MSG( ( style & 0x3F ) != wxYES , wxT("this style is not supported on mac") ) ;
+ wxASSERT_MSG( (style & 0x3F) != wxYES, wxT("this style is not supported on Mac") );
- AlertType alertType = kAlertPlainAlert ;
+ AlertType alertType = kAlertPlainAlert;
if (style & wxICON_EXCLAMATION)
- alertType = kAlertNoteAlert ;
+ alertType = kAlertNoteAlert;
else if (style & wxICON_HAND)
- alertType = kAlertStopAlert ;
+ alertType = kAlertStopAlert;
else if (style & wxICON_INFORMATION)
- alertType = kAlertNoteAlert ;
+ alertType = kAlertNoteAlert;
else if (style & wxICON_QUESTION)
- alertType = kAlertCautionAlert ;
+ alertType = kAlertCautionAlert;
#if TARGET_API_MAC_OSX
- CFStringRef defaultButtonTitle = NULL ;
- CFStringRef alternateButtonTitle = NULL ;
- CFStringRef otherButtonTitle = NULL ;
-
- wxMacCFStringHolder cfTitle(m_caption , m_font.GetEncoding());
- wxMacCFStringHolder cfText(m_message , m_font.GetEncoding());
-
- wxMacCFStringHolder cfNoString(_("No") , m_font.GetEncoding()) ;
- wxMacCFStringHolder cfYesString( _("Yes") , m_font.GetEncoding()) ;
- wxMacCFStringHolder cfCancelString( _("Cancel") , m_font.GetEncoding()) ;
-
- int buttonId[4] = { 0 , 0 , 0 , wxID_CANCEL /* time-out */ } ;
-
+ CFStringRef defaultButtonTitle = NULL;
+ CFStringRef alternateButtonTitle = NULL;
+ CFStringRef otherButtonTitle = NULL;
+
+ wxMacCFStringHolder cfTitle( m_caption, m_font.GetEncoding() );
+ wxMacCFStringHolder cfText( m_message, m_font.GetEncoding() );
+
+ wxMacCFStringHolder cfNoString( wxT("No"), m_font.GetEncoding() );
+ wxMacCFStringHolder cfYesString( wxT("Yes"), m_font.GetEncoding() );
+ wxMacCFStringHolder cfCancelString( wxT("Cancel"), m_font.GetEncoding() );
+
+ int buttonId[4] = { 0, 0, 0, wxID_CANCEL /* time-out */ };
+
if (style & wxYES_NO)
{
if ( style & wxNO_DEFAULT )
{
- defaultButtonTitle = cfNoString ;
- alternateButtonTitle = cfYesString ;
- buttonId[0] = wxID_NO ;
- buttonId[1] = wxID_YES ;
+ defaultButtonTitle = cfNoString;
+ alternateButtonTitle = cfYesString;
+ buttonId[0] = wxID_NO;
+ buttonId[1] = wxID_YES;
}
else
{
- defaultButtonTitle = cfYesString ;
- alternateButtonTitle = cfNoString ;
- buttonId[0] = wxID_YES ;
- buttonId[1] = wxID_NO ;
+ defaultButtonTitle = cfYesString;
+ alternateButtonTitle = cfNoString;
+ buttonId[0] = wxID_YES;
+ buttonId[1] = wxID_NO;
}
if (style & wxCANCEL)
{
- otherButtonTitle = cfCancelString ;
- buttonId[2] = wxID_CANCEL ;
+ otherButtonTitle = cfCancelString;
+ buttonId[2] = wxID_CANCEL;
}
}
else
{
- // the msw implementation even shows an ok button if it is not specified, we'll do the same
- buttonId[0] = wxID_OK ;
+ // the MSW implementation even shows an OK button if it is not specified, we'll do the same
+ buttonId[0] = wxID_OK;
if (style & wxCANCEL)
{
- alternateButtonTitle = cfCancelString ;
- buttonId[1] = wxID_CANCEL ;
+ alternateButtonTitle = cfCancelString;
+ buttonId[1] = wxID_CANCEL;
}
}
- CFOptionFlags exitButton ;
- OSStatus err = CFUserNotificationDisplayAlert ( 0 , alertType , NULL , NULL , NULL , cfTitle , cfText ,
- defaultButtonTitle , alternateButtonTitle , otherButtonTitle , &exitButton );
- if ( err == noErr )
- resultbutton = buttonId[exitButton] ;
+ CFOptionFlags exitButton;
+ OSStatus err = CFUserNotificationDisplayAlert(
+ 0, alertType, NULL, NULL, NULL, cfTitle, cfText,
+ defaultButtonTitle, alternateButtonTitle, otherButtonTitle, &exitButton );
+ if (err == noErr)
+ resultbutton = buttonId[exitButton];
#else
- short result ;
-
+ short result;
+
#if TARGET_CARBON
if ( UMAGetSystemVersion() >= 0x1000 )
{
- AlertStdCFStringAlertParamRec param ;
- wxMacCFStringHolder cfNoString(_("No") , m_font.GetEncoding()) ;
- wxMacCFStringHolder cfYesString( _("Yes") , m_font.GetEncoding()) ;
+ AlertStdCFStringAlertParamRec param;
+ wxMacCFStringHolder cfNoString( wxT("No"), m_font.GetEncoding() );
+ wxMacCFStringHolder cfYesString( wxT("Yes"), m_font.GetEncoding() );
- wxMacCFStringHolder cfTitle(m_caption , m_font.GetEncoding());
- wxMacCFStringHolder cfText(m_message , m_font.GetEncoding());
+ wxMacCFStringHolder cfTitle( m_caption, m_font.GetEncoding() );
+ wxMacCFStringHolder cfText( m_message, m_font.GetEncoding() );
param.movable = true;
- param.flags = 0 ;
- param.version = kStdCFStringAlertVersionOne ;
+ param.flags = 0;
+ param.version = kStdCFStringAlertVersionOne;
- bool skipDialog = false ;
+ bool skipDialog = false;
if (style & wxYES_NO)
{
if (style & wxCANCEL)
{
- param.defaultText = cfYesString ;
- param.cancelText = (CFStringRef) kAlertDefaultCancelText;
- param.otherText = cfNoString ;
- param.helpButton = false ;
+ param.defaultText = cfYesString;
+ param.cancelText = (CFStringRef) kAlertDefaultCancelText;
+ param.otherText = cfNoString;
+ param.helpButton = false;
param.defaultButton = style & wxNO_DEFAULT ? kAlertStdAlertOtherButton : kAlertStdAlertOKButton;
- param.cancelButton = kAlertStdAlertCancelButton;
+ param.cancelButton = kAlertStdAlertCancelButton;
}
else
{
- param.defaultText = cfYesString ;
- param.cancelText = NULL;
- param.otherText = cfNoString ;
- param.helpButton = false ;
+ param.defaultText = cfYesString;
+ param.cancelText = NULL;
+ param.otherText = cfNoString;
+ param.helpButton = false;
param.defaultButton = style & wxNO_DEFAULT ? kAlertStdAlertOtherButton : kAlertStdAlertOKButton;
- param.cancelButton = 0;
+ param.cancelButton = 0;
}
}
- // the msw implementation even shows an ok button if it is not specified, we'll do the same
+ // the MSW implementation even shows an OK button if it is not specified, we'll do the same
else
{
if (style & wxCANCEL)
{
- // thats a cancel missing
- param.defaultText = (CFStringRef) kAlertDefaultOKText ;
- param.cancelText = (CFStringRef) kAlertDefaultCancelText ;
- param.otherText = NULL;
- param.helpButton = false ;
+ // that's a cancel missing
+ param.defaultText = (CFStringRef) kAlertDefaultOKText;
+ param.cancelText = (CFStringRef) kAlertDefaultCancelText;
+ param.otherText = NULL;
+ param.helpButton = false;
param.defaultButton = kAlertStdAlertOKButton;
- param.cancelButton = 0;
+ param.cancelButton = 0;
}
else
{
- param.defaultText = (CFStringRef) kAlertDefaultOKText ;
- param.cancelText = NULL;
- param.otherText = NULL;
- param.helpButton = false ;
+ param.defaultText = (CFStringRef) kAlertDefaultOKText;
+ param.cancelText = NULL;
+ param.otherText = NULL;
+ param.helpButton = false;
param.defaultButton = kAlertStdAlertOKButton;
- param.cancelButton = 0;
+ param.cancelButton = 0;
}
}
- /*
+#if 0
else
{
- skipDialog = true ;
+ skipDialog = true;
}
- */
+#endif
param.position = kWindowDefaultPosition;
if ( !skipDialog )
{
- DialogRef alertRef ;
- CreateStandardAlert( alertType , cfTitle , cfText , ¶m , &alertRef ) ;
- RunStandardAlert( alertRef , NULL , &result ) ;
+ DialogRef alertRef;
+ CreateStandardAlert( alertType, cfTitle, cfText, ¶m, &alertRef );
+ RunStandardAlert( alertRef, NULL, &result );
+ }
+ else
+ {
+ return wxID_CANCEL;
}
- if ( skipDialog )
- return wxID_CANCEL ;
}
else
#endif
{
- AlertStdAlertParamRec param;
+ AlertStdAlertParamRec param;
+ Str255 yesPString, noPString;
+ Str255 pascalTitle, pascalText;
- Str255 yesPString ;
- Str255 noPString ;
+ wxMacStringToPascal( m_caption, pascalTitle );
+ wxMacStringToPascal( wxT("Yes"), yesPString );
+ wxMacStringToPascal( wxT("No"), noPString );
+ wxMacStringToPascal( m_message, pascalText );
- Str255 pascalTitle ;
- Str255 pascalText ;
- wxMacStringToPascal( m_caption , pascalTitle ) ;
- wxMacStringToPascal( _("Yes") , yesPString ) ;
- wxMacStringToPascal( _("No") , noPString ) ;
- wxMacStringToPascal( m_message , pascalText ) ;
+ param.movable = true;
+ param.filterProc = NULL;
- param.movable = true;
- param.filterProc = NULL ;
if (style & wxYES_NO)
{
if (style & wxCANCEL)
{
- param.defaultText = yesPString ;
- param.cancelText = (StringPtr) kAlertDefaultCancelText;
- param.otherText = noPString ;
- param.helpButton = false ;
+ param.defaultText = yesPString;
+ param.cancelText = (StringPtr) kAlertDefaultCancelText;
+ param.otherText = noPString;
+ param.helpButton = false;
param.defaultButton = kAlertStdAlertOKButton;
- param.cancelButton = kAlertStdAlertCancelButton;
+ param.cancelButton = kAlertStdAlertCancelButton;
}
else
{
- param.defaultText = yesPString ;
- param.cancelText = NULL;
- param.otherText = noPString ;
- param.helpButton = false ;
+ param.defaultText = yesPString;
+ param.cancelText = NULL;
+ param.otherText = noPString;
+ param.helpButton = false;
param.defaultButton = kAlertStdAlertOKButton;
- param.cancelButton = 0;
+ param.cancelButton = 0;
}
}
else if (style & wxOK)
{
if (style & wxCANCEL)
{
- param.defaultText = (StringPtr) kAlertDefaultOKText ;
- param.cancelText = (StringPtr) kAlertDefaultCancelText ;
- param.otherText = NULL;
- param.helpButton = false ;
+ param.defaultText = (StringPtr) kAlertDefaultOKText;
+ param.cancelText = (StringPtr) kAlertDefaultCancelText;
+ param.otherText = NULL;
+ param.helpButton = false;
param.defaultButton = kAlertStdAlertOKButton;
- param.cancelButton = 0;
+ param.cancelButton = 0;
}
else
{
- param.defaultText = (StringPtr) kAlertDefaultOKText ;
- param.cancelText = NULL;
- param.otherText = NULL;
- param.helpButton = false ;
+ param.defaultText = (StringPtr) kAlertDefaultOKText;
+ param.cancelText = NULL;
+ param.otherText = NULL;
+ param.helpButton = false;
param.defaultButton = kAlertStdAlertOKButton;
- param.cancelButton = 0;
+ param.cancelButton = 0;
}
}
else
{
- return resultbutton ;
+ return resultbutton;
}
- param.position = 0;
-
+ param.position = 0;
StandardAlert( alertType, pascalTitle, pascalText, ¶m, &result );
}
if (style & wxOK)
{
- if (style & wxCANCEL)
+ switch ( result )
{
- //TODO add Cancelbutton
- switch( result )
- {
- case 1 :
- resultbutton = wxID_OK ;
- break ;
- case 2 :
- break ;
- case 3 :
- break ;
- }
- }
- else
- {
- switch( result )
- {
- case 1 :
- resultbutton = wxID_OK ;
- break ;
- case 2 :
- break ;
- case 3 :
- break ;
- }
+ case 1:
+ resultbutton = wxID_OK;
+ break;
+
+ case 2:
+ // TODO: add Cancel button
+ // if (style & wxCANCEL)
+ // resultbutton = wxID_CANCEL;
+ break;
+
+ case 3:
+ default:
+ break;
}
}
else if (style & wxYES_NO)
{
- if (style & wxCANCEL)
+ switch ( result )
{
- switch( result )
- {
- case 1 :
- resultbutton = wxID_YES ;
- break ;
- case 2 :
- resultbutton = wxID_CANCEL ;
- break ;
- case 3 :
- resultbutton = wxID_NO ;
- break ;
- }
- }
- else
- {
- switch( result )
- {
- case 1 :
- resultbutton = wxID_YES ;
- break ;
- case 2 :
- break ;
- case 3 :
- resultbutton = wxID_NO ;
- break ;
- }
+ case 1:
+ resultbutton = wxID_YES;
+ break;
+
+ case 2:
+ if (!(style & wxCANCEL))
+ resultbutton = wxID_CANCEL;
+ break;
+
+ case 3:
+ resultbutton = wxID_NO;
+ break;
+
+ default:
+ break;
}
}
#endif
-
- return resultbutton ;
+
+ return resultbutton;
}
///////////////////////////////////////////////////////////////////////////////
-// Name: taskbar.cpp
-// Purpose: wxTaskBarIcon - OSX implementation
+// Name: src/mac/carbon/taskbar.cpp
+// Purpose: wxTaskBarIcon
// Author: Ryan Norton
// Modified by:
// Created: 09/25/2004
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
-//=============================================================================
-// Declarations
-//=============================================================================
-
-//-----------------------------------------------------------------------------
-// Includes
-//-----------------------------------------------------------------------------
-
#include "wx/wxprec.h"
#ifdef wxHAS_TASK_BAR_ICON
#include "wx/icon.h"
#include "wx/dcmemory.h"
-//-----------------------------------------------------------------------------
-//
-// wxTaskBarIconImpl
-//
-// Superclass of wxTaskBarIcon implementations
-//-----------------------------------------------------------------------------
class wxTaskBarIconImpl
{
virtual bool RemoveIcon() = 0;
virtual bool PopupMenu(wxMenu *menu) = 0;
- wxMenu* CreatePopupMenu()
+ wxMenu * CreatePopupMenu()
{ return m_parent->CreatePopupMenu(); }
- wxTaskBarIcon* m_parent;
- class wxTaskBarIconWindow* m_menuEventWindow;
+ wxTaskBarIcon *m_parent;
+ class wxTaskBarIconWindow *m_menuEventWindow;
DECLARE_NO_COPY_CLASS(wxTaskBarIconImpl)
};
// wxTaskBarIconWindow
//
// Event handler for menus
-// NB: Since wxWindows in mac HAVE to have parents we need this to be
+// NB: Since wxWindows in Mac HAVE to have parents we need this to be
// a top level window...
//-----------------------------------------------------------------------------
class wxTaskBarIconWindow : public wxTopLevelWindow
{
public:
- wxTaskBarIconWindow(wxTaskBarIconImpl* impl)
+ wxTaskBarIconWindow(wxTaskBarIconImpl *impl)
: wxTopLevelWindow(NULL, -1, wxT("")), m_impl(impl)
{
- Connect(-1, wxEVT_COMMAND_MENU_SELECTED,
- wxCommandEventHandler(wxTaskBarIconWindow::OnMenuEvent)
- );
+ Connect(
+ -1, wxEVT_COMMAND_MENU_SELECTED,
+ wxCommandEventHandler(wxTaskBarIconWindow::OnMenuEvent) );
}
void OnMenuEvent(wxCommandEvent& event)
}
private:
- wxTaskBarIconImpl* m_impl;
+ wxTaskBarIconImpl *m_impl;
};
-//-----------------------------------------------------------------------------
-//
-// wxDockBarIconImpl
-//
-//-----------------------------------------------------------------------------
-
class wxDockTaskBarIcon : public wxTaskBarIconImpl
{
public:
EventHandlerRef m_eventHandlerRef;
EventHandlerUPP m_eventupp;
- wxWindow* m_eventWindow;
- wxMenu* m_pMenu;
+ wxWindow *m_eventWindow;
+ wxMenu *m_pMenu;
MenuRef m_theLastMenu;
bool m_iconAdded;
};
// Forward declarations for utility functions for dock implementation
-pascal OSStatus wxDockEventHandler( EventHandlerCallRef inHandlerCallRef,
- EventRef inEvent, void* pData);
-wxMenu* wxDeepCopyMenu(wxMenu* menu);
+pascal OSStatus wxDockEventHandler(
+ EventHandlerCallRef inHandlerCallRef,
+ EventRef inEvent, void* pData );
+wxMenu * wxDeepCopyMenu( wxMenu *menu );
-//=============================================================================
-//
-// Implementation
-//
-//=============================================================================
-
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
// wxTaskBarIconImpl
//
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-//-----------------------------------------------------------------------------
-// wxTaskBarIconImpl Constructor
-//
-// Initializes members and creates the event window
-//-----------------------------------------------------------------------------
wxTaskBarIconImpl::wxTaskBarIconImpl(wxTaskBarIcon* parent)
: m_parent(parent), m_menuEventWindow(new wxTaskBarIconWindow(this))
{
}
-//-----------------------------------------------------------------------------
-// wxTaskBarIconImpl Destructor
-//
-// Cleans up the event window
-//-----------------------------------------------------------------------------
wxTaskBarIconImpl::~wxTaskBarIconImpl()
{
delete m_menuEventWindow;
//
// wxDockTaskBarIcon
//
-// OS X DOCK implementation of wxTaskBarIcon using carbon
+// OS X Dock implementation of wxTaskBarIcon using Carbon
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+//-----------------------------------------------------------------------------
// wxDockEventHandler
//
-// This is the global mac/carbon event handler for the dock.
+// This is the global Mac/Carbon event handler for the dock.
// We need this for two reasons:
// 1) To handle wxTaskBarIcon menu events (see below for why)
// 2) To handle events from the dock when it requests a menu
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+//-----------------------------------------------------------------------------
pascal OSStatus wxDockEventHandler( EventHandlerCallRef inHandlerCallRef,
- EventRef inEvent, void* pData)
+ EventRef inEvent, void *pData )
{
// Get the parameters we want from the event
wxDockTaskBarIcon* pTB = (wxDockTaskBarIcon*) pData;
// Handle wxTaskBar menu events (note that this is a global event handler
// so it will actually get called by all commands/menus)
- //
if ((eventClass == kEventClassCommand) && (eventKind == kEventCommandProcess))
{
// if we have no taskbar menu quickly pass it back to wxApp
if (pTB->m_pMenu == NULL)
return eventNotHandledErr;
- //
// This is the real reason why we need this. Normally menus
// get handled in wxMacAppEventHandler
//
// However, in the case of a taskbar menu call
// command.menu.menuRef IS NULL!
// Which causes the wxApp handler just to skip it.
- //
MenuRef taskbarMenuRef = MAC_WXHMENU(pTB->m_pMenu->GetHMenu());
- OSErr err;
+ OSStatus err;
// get the HICommand from the event
HICommand command;
- err = GetEventParameter(inEvent, kEventParamDirectObject,
- typeHICommand, NULL,
- sizeof(HICommand), NULL, &command);
+ err = GetEventParameter(
+ inEvent, kEventParamDirectObject,
+ typeHICommand, NULL,
+ sizeof(HICommand), NULL, &command );
if (err == noErr)
{
// Obtain the REAL menuRef and the menuItemIndex in the real menuRef
// NOTE: menuRef is generally used here for submenus, as
// GetMenuItemRefCon could give an incorrect wxMenuItem if we pass
// just the top level wxTaskBar menu
- //
MenuItemIndex menuItemIndex;
MenuRef menuRef;
- err = GetIndMenuItemWithCommandID(taskbarMenuRef,
- command.commandID,
- 1, &menuRef, &menuItemIndex);
+ err = GetIndMenuItemWithCommandID(
+ taskbarMenuRef,
+ command.commandID,
+ 1, &menuRef, &menuItemIndex );
if (err == noErr)
{
MenuCommand id = command.commandID;
- wxMenuItem* item = NULL;
+ wxMenuItem *item = NULL;
if (id != 0) // get the wxMenuItem reference from the MenuRef
- GetMenuItemRefCon(menuRef, menuItemIndex, (UInt32*) &item);
+ GetMenuItemRefCon( menuRef, menuItemIndex, (UInt32*) &item );
if (item)
{
// Handle items that are checkable
// FIXME: Doesn't work (at least on 10.2)!
if (item->IsCheckable())
- item->Check( !item->IsChecked() ) ;
+ item->Check( !item->IsChecked() );
// send the wxEvent to the wxMenu
- item->GetMenu()->SendEvent(id,
- item->IsCheckable() ?
- item->IsChecked() : -1
- );
- err = noErr; // successfully handled the event
+ item->GetMenu()->SendEvent( id, item->IsCheckable() ? item->IsChecked() : -1 );
+
+ // successfully handled the event
+ err = noErr;
}
}
} //end if noErr on getting HICommand from event
// process the right click events
// NB: This may result in double or even triple-creation of the menus
// We need to do this for 2.4 compat, however
- wxTaskBarIconEvent downevt(wxEVT_TASKBAR_RIGHT_DOWN,NULL);
+ wxTaskBarIconEvent downevt(wxEVT_TASKBAR_RIGHT_DOWN, NULL);
pTB->m_parent->ProcessEvent(downevt);
- wxTaskBarIconEvent upevt(wxEVT_TASKBAR_RIGHT_UP,NULL);
+ wxTaskBarIconEvent upevt(wxEVT_TASKBAR_RIGHT_UP, NULL);
pTB->m_parent->ProcessEvent(upevt);
// create popup menu
RetainMenu(hMenu);
// set the actual dock menu
- err = SetEventParameter(inEvent, kEventParamMenuRef,
- typeMenuRef, sizeof(MenuRef), &hMenu);
- wxASSERT(err == noErr);
+ err = SetEventParameter(
+ inEvent, kEventParamMenuRef,
+ typeMenuRef, sizeof(MenuRef), &hMenu );
+ verify_noerr( err );
}
return err;
}
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+//-----------------------------------------------------------------------------
// wxDeepCopyMenu
//
// Performs a top-to-bottom copy of the input menu and all of its
//
// This is mostly needed for 2.4 compatability. However wxPython and others
// still use this way of setting the taskbarmenu.
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-wxMenu* wxDeepCopyMenu(wxMenu* menu)
+//-----------------------------------------------------------------------------
+wxMenu * wxDeepCopyMenu( wxMenu *menu )
{
- if (!menu)
+ if (menu == NULL)
return NULL;
- //
// NB: Here we have to perform a deep copy of the menu,
// copying each and every menu item from menu to m_pMenu.
// Other implementations use wxWindow::PopupMenu here,
// which idle execution until the user selects something,
- // but since the mac handles this internally, we can't -
+ // but since the Mac handles this internally, we can't -
// and have no way at all to idle it while the dock menu
// is being shown before menu goes out of scope (it may
// not be on the heap, and may expire right after this function
// Also, since there is no equal (assignment) operator
// on either wxMenu or wxMenuItem, we have to do all the
// dirty work ourselves.
- //
// perform a deep copy of the menu
wxMenuItemList& theList = menu->GetMenuItems();
wxMenuItemList::compatibility_iterator theNode = theList.GetFirst();
// create the main menu
- wxMenu* m_pMenu = new wxMenu(menu->GetTitle());
+ wxMenu *m_pMenu = new wxMenu(menu->GetTitle());
while (theNode != NULL)
{
theItem->GetText(), // text label
theItem->GetHelp(), // status bar help string
theItem->GetKind(), // menu flags - checkable, separator, etc.
- wxDeepCopyMenu(theItem->GetSubMenu()) // submenu
- ));
+ wxDeepCopyMenu(theItem->GetSubMenu()) )); // submenu
+
theNode = theNode->GetNext();
}
//
// Initializes the dock implementation of wxTaskBarIcon.
//
-// Here we create some mac-specific event handlers and UPPs.
+// Here we create some Mac-specific event handlers and UPPs.
//-----------------------------------------------------------------------------
wxDockTaskBarIcon::wxDockTaskBarIcon(wxTaskBarIcon* parent)
: wxTaskBarIconImpl(parent),
m_eventupp = NewEventHandlerUPP(wxDockEventHandler);
wxASSERT(m_eventupp != NULL);
-#ifdef __WXDEBUG__
- OSStatus err =
-#endif
- InstallApplicationEventHandler(
+ OSStatus err = InstallApplicationEventHandler(
m_eventupp,
GetEventTypeCount(tbEventList), tbEventList,
this, &m_eventHandlerRef);
- wxASSERT( err == noErr );
+ verify_noerr( err );
}
//-----------------------------------------------------------------------------
// Helper function that handles a request from the dock event handler
// to get the menu for the dock
//-----------------------------------------------------------------------------
-wxMenu* wxDockTaskBarIcon::DoCreatePopupMenu()
+wxMenu * wxDockTaskBarIcon::DoCreatePopupMenu()
{
// get the menu from the parent
wxMenu* theNewMenu = CreatePopupMenu();
{
// convert the wxIcon into a wxBitmap so we can perform some
// wxBitmap operations with it
- wxBitmap bmp( icon ) ;
+ wxBitmap bmp( icon );
wxASSERT( bmp.Ok() );
// get the CGImageRef for the wxBitmap:
// actually set the dock image
OSStatus err = SetApplicationDockTileImage( pImage );
- wxASSERT( err == noErr );
+ verify_noerr( err );
// free the CGImage, now that it's referenced by the dock
if (pImage != NULL)
// restore old icon to the dock
OSStatus err = RestoreApplicationDockTileImage();
- wxASSERT(err == noErr);
+ verify_noerr( err );
// restore the old menu to the dock
- SetApplicationDockTileMenu(m_theLastMenu);
+ SetApplicationDockTileMenu( m_theLastMenu );
bool success = (err == noErr);
m_iconAdded = !success;
if (m_pMenu)
delete m_pMenu;
- //start copy of menu
+ // start copy of menu
m_pMenu = wxDeepCopyMenu(menu);
- //finish up
+ // finish up
m_pMenu->SetInvokingWindow(m_menuEventWindow);
return true;
//-----------------------------------------------------------------------------
wxTaskBarIcon::wxTaskBarIcon(wxTaskBarIconType nType)
{
- wxASSERT_MSG(nType == DOCK,
- wxT("Only the DOCK implementation of wxTaskBarIcon")
- wxT("on mac carbon is currently supported!"));
+ wxASSERT_MSG(
+ nType == DOCK,
+ wxT("Only the DOCK implementation of wxTaskBarIcon on Mac-Carbon is currently supported!") );
+
m_impl = new wxDockTaskBarIcon(this);
}
//-----------------------------------------------------------------------------
bool wxTaskBarIcon::IsIconInstalled() const
{ return m_impl->IsIconInstalled(); }
+
bool wxTaskBarIcon::SetIcon(const wxIcon& icon, const wxString& tooltip)
{ return m_impl->SetIcon(icon, tooltip); }
+
bool wxTaskBarIcon::RemoveIcon()
{ return m_impl->RemoveIcon(); }
+
bool wxTaskBarIcon::PopupMenu(wxMenu *menu)
{ return m_impl->PopupMenu(menu); }
-#endif //wxHAS_TASK_BAR_ICON
+#endif // wxHAS_TASK_BAR_ICON