cleanup - refomatting
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37569 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -16,9 +16,12 @@
|
|||||||
#include "wx/intl.h"
|
#include "wx/intl.h"
|
||||||
#include "wx/mac/uma.h"
|
#include "wx/mac/uma.h"
|
||||||
|
|
||||||
|
|
||||||
IMPLEMENT_CLASS(wxMessageDialog, wxDialog)
|
IMPLEMENT_CLASS(wxMessageDialog, wxDialog)
|
||||||
|
|
||||||
wxMessageDialog::wxMessageDialog(wxWindow *parent, const wxString& message, const wxString& caption,
|
|
||||||
|
wxMessageDialog::wxMessageDialog(
|
||||||
|
wxWindow *parent, const wxString& message, const wxString& caption,
|
||||||
long style, const wxPoint& pos )
|
long style, const wxPoint& pos )
|
||||||
{
|
{
|
||||||
m_caption = caption;
|
m_caption = caption;
|
||||||
@@ -33,7 +36,7 @@ int wxMessageDialog::ShowModal()
|
|||||||
|
|
||||||
const long style = GetMessageDialogStyle();
|
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)
|
if (style & wxICON_EXCLAMATION)
|
||||||
@@ -53,9 +56,9 @@ int wxMessageDialog::ShowModal()
|
|||||||
wxMacCFStringHolder cfTitle( m_caption, m_font.GetEncoding() );
|
wxMacCFStringHolder cfTitle( m_caption, m_font.GetEncoding() );
|
||||||
wxMacCFStringHolder cfText( m_message, m_font.GetEncoding() );
|
wxMacCFStringHolder cfText( m_message, m_font.GetEncoding() );
|
||||||
|
|
||||||
wxMacCFStringHolder cfNoString(_("No") , m_font.GetEncoding()) ;
|
wxMacCFStringHolder cfNoString( wxT("No"), m_font.GetEncoding() );
|
||||||
wxMacCFStringHolder cfYesString( _("Yes") , m_font.GetEncoding()) ;
|
wxMacCFStringHolder cfYesString( wxT("Yes"), m_font.GetEncoding() );
|
||||||
wxMacCFStringHolder cfCancelString( _("Cancel") , m_font.GetEncoding()) ;
|
wxMacCFStringHolder cfCancelString( wxT("Cancel"), m_font.GetEncoding() );
|
||||||
|
|
||||||
int buttonId[4] = { 0, 0, 0, wxID_CANCEL /* time-out */ };
|
int buttonId[4] = { 0, 0, 0, wxID_CANCEL /* time-out */ };
|
||||||
|
|
||||||
@@ -83,7 +86,7 @@ int wxMessageDialog::ShowModal()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 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
|
||||||
buttonId[0] = wxID_OK;
|
buttonId[0] = wxID_OK;
|
||||||
if (style & wxCANCEL)
|
if (style & wxCANCEL)
|
||||||
{
|
{
|
||||||
@@ -93,7 +96,8 @@ int wxMessageDialog::ShowModal()
|
|||||||
}
|
}
|
||||||
|
|
||||||
CFOptionFlags exitButton;
|
CFOptionFlags exitButton;
|
||||||
OSStatus err = CFUserNotificationDisplayAlert ( 0 , alertType , NULL , NULL , NULL , cfTitle , cfText ,
|
OSStatus err = CFUserNotificationDisplayAlert(
|
||||||
|
0, alertType, NULL, NULL, NULL, cfTitle, cfText,
|
||||||
defaultButtonTitle, alternateButtonTitle, otherButtonTitle, &exitButton );
|
defaultButtonTitle, alternateButtonTitle, otherButtonTitle, &exitButton );
|
||||||
if (err == noErr)
|
if (err == noErr)
|
||||||
resultbutton = buttonId[exitButton];
|
resultbutton = buttonId[exitButton];
|
||||||
@@ -105,8 +109,8 @@ int wxMessageDialog::ShowModal()
|
|||||||
if ( UMAGetSystemVersion() >= 0x1000 )
|
if ( UMAGetSystemVersion() >= 0x1000 )
|
||||||
{
|
{
|
||||||
AlertStdCFStringAlertParamRec param;
|
AlertStdCFStringAlertParamRec param;
|
||||||
wxMacCFStringHolder cfNoString(_("No") , m_font.GetEncoding()) ;
|
wxMacCFStringHolder cfNoString( wxT("No"), m_font.GetEncoding() );
|
||||||
wxMacCFStringHolder cfYesString( _("Yes") , m_font.GetEncoding()) ;
|
wxMacCFStringHolder cfYesString( wxT("Yes"), m_font.GetEncoding() );
|
||||||
|
|
||||||
wxMacCFStringHolder cfTitle( m_caption, m_font.GetEncoding() );
|
wxMacCFStringHolder cfTitle( m_caption, m_font.GetEncoding() );
|
||||||
wxMacCFStringHolder cfText( m_message, m_font.GetEncoding() );
|
wxMacCFStringHolder cfText( m_message, m_font.GetEncoding() );
|
||||||
@@ -138,12 +142,12 @@ int wxMessageDialog::ShowModal()
|
|||||||
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
|
else
|
||||||
{
|
{
|
||||||
if (style & wxCANCEL)
|
if (style & wxCANCEL)
|
||||||
{
|
{
|
||||||
// thats a cancel missing
|
// that's a cancel missing
|
||||||
param.defaultText = (CFStringRef) kAlertDefaultOKText;
|
param.defaultText = (CFStringRef) kAlertDefaultOKText;
|
||||||
param.cancelText = (CFStringRef) kAlertDefaultCancelText;
|
param.cancelText = (CFStringRef) kAlertDefaultCancelText;
|
||||||
param.otherText = NULL;
|
param.otherText = NULL;
|
||||||
@@ -161,12 +165,12 @@ int wxMessageDialog::ShowModal()
|
|||||||
param.cancelButton = 0;
|
param.cancelButton = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
#if 0
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
skipDialog = true;
|
skipDialog = true;
|
||||||
}
|
}
|
||||||
*/
|
#endif
|
||||||
|
|
||||||
param.position = kWindowDefaultPosition;
|
param.position = kWindowDefaultPosition;
|
||||||
if ( !skipDialog )
|
if ( !skipDialog )
|
||||||
@@ -175,26 +179,26 @@ int wxMessageDialog::ShowModal()
|
|||||||
CreateStandardAlert( alertType, cfTitle, cfText, ¶m, &alertRef );
|
CreateStandardAlert( alertType, cfTitle, cfText, ¶m, &alertRef );
|
||||||
RunStandardAlert( alertRef, NULL, &result );
|
RunStandardAlert( alertRef, NULL, &result );
|
||||||
}
|
}
|
||||||
if ( skipDialog )
|
else
|
||||||
|
{
|
||||||
return wxID_CANCEL;
|
return wxID_CANCEL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
AlertStdAlertParamRec param;
|
AlertStdAlertParamRec param;
|
||||||
|
Str255 yesPString, noPString;
|
||||||
|
Str255 pascalTitle, pascalText;
|
||||||
|
|
||||||
Str255 yesPString ;
|
|
||||||
Str255 noPString ;
|
|
||||||
|
|
||||||
Str255 pascalTitle ;
|
|
||||||
Str255 pascalText ;
|
|
||||||
wxMacStringToPascal( m_caption, pascalTitle );
|
wxMacStringToPascal( m_caption, pascalTitle );
|
||||||
wxMacStringToPascal( _("Yes") , yesPString ) ;
|
wxMacStringToPascal( wxT("Yes"), yesPString );
|
||||||
wxMacStringToPascal( _("No") , noPString ) ;
|
wxMacStringToPascal( wxT("No"), noPString );
|
||||||
wxMacStringToPascal( m_message, pascalText );
|
wxMacStringToPascal( m_message, pascalText );
|
||||||
|
|
||||||
param.movable = true;
|
param.movable = true;
|
||||||
param.filterProc = NULL;
|
param.filterProc = NULL;
|
||||||
|
|
||||||
if (style & wxYES_NO)
|
if (style & wxYES_NO)
|
||||||
{
|
{
|
||||||
if (style & wxCANCEL)
|
if (style & wxCANCEL)
|
||||||
@@ -243,70 +247,47 @@ int wxMessageDialog::ShowModal()
|
|||||||
}
|
}
|
||||||
|
|
||||||
param.position = 0;
|
param.position = 0;
|
||||||
|
|
||||||
StandardAlert( alertType, pascalTitle, pascalText, ¶m, &result );
|
StandardAlert( alertType, pascalTitle, pascalText, ¶m, &result );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (style & wxOK)
|
if (style & wxOK)
|
||||||
{
|
{
|
||||||
if (style & wxCANCEL)
|
|
||||||
{
|
|
||||||
//TODO add Cancelbutton
|
|
||||||
switch ( result )
|
switch ( result )
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
resultbutton = wxID_OK;
|
resultbutton = wxID_OK;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
// TODO: add Cancel button
|
||||||
|
// if (style & wxCANCEL)
|
||||||
|
// resultbutton = wxID_CANCEL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
switch( result )
|
|
||||||
{
|
|
||||||
case 1 :
|
|
||||||
resultbutton = wxID_OK ;
|
|
||||||
break ;
|
|
||||||
case 2 :
|
|
||||||
break ;
|
|
||||||
case 3 :
|
|
||||||
break ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (style & wxYES_NO)
|
else if (style & wxYES_NO)
|
||||||
{
|
|
||||||
if (style & wxCANCEL)
|
|
||||||
{
|
{
|
||||||
switch ( result )
|
switch ( result )
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
resultbutton = wxID_YES;
|
resultbutton = wxID_YES;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
if (!(style & wxCANCEL))
|
||||||
resultbutton = wxID_CANCEL;
|
resultbutton = wxID_CANCEL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
resultbutton = wxID_NO;
|
resultbutton = wxID_NO;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
default:
|
||||||
else
|
|
||||||
{
|
|
||||||
switch( result )
|
|
||||||
{
|
|
||||||
case 1 :
|
|
||||||
resultbutton = wxID_YES ;
|
|
||||||
break;
|
break;
|
||||||
case 2 :
|
|
||||||
break ;
|
|
||||||
case 3 :
|
|
||||||
resultbutton = wxID_NO ;
|
|
||||||
break ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: taskbar.cpp
|
// Name: src/mac/carbon/taskbar.cpp
|
||||||
// Purpose: wxTaskBarIcon - OSX implementation
|
// Purpose: wxTaskBarIcon
|
||||||
// Author: Ryan Norton
|
// Author: Ryan Norton
|
||||||
// Modified by:
|
// Modified by:
|
||||||
// Created: 09/25/2004
|
// Created: 09/25/2004
|
||||||
@@ -9,14 +9,6 @@
|
|||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
// Declarations
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Includes
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "wx/wxprec.h"
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
#ifdef wxHAS_TASK_BAR_ICON
|
#ifdef wxHAS_TASK_BAR_ICON
|
||||||
@@ -28,12 +20,6 @@
|
|||||||
#include "wx/icon.h"
|
#include "wx/icon.h"
|
||||||
#include "wx/dcmemory.h"
|
#include "wx/dcmemory.h"
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// wxTaskBarIconImpl
|
|
||||||
//
|
|
||||||
// Superclass of wxTaskBarIcon implementations
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class wxTaskBarIconImpl
|
class wxTaskBarIconImpl
|
||||||
{
|
{
|
||||||
@@ -60,7 +46,7 @@ public:
|
|||||||
// wxTaskBarIconWindow
|
// wxTaskBarIconWindow
|
||||||
//
|
//
|
||||||
// Event handler for menus
|
// 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...
|
// a top level window...
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -70,9 +56,9 @@ public:
|
|||||||
wxTaskBarIconWindow(wxTaskBarIconImpl *impl)
|
wxTaskBarIconWindow(wxTaskBarIconImpl *impl)
|
||||||
: wxTopLevelWindow(NULL, -1, wxT("")), m_impl(impl)
|
: wxTopLevelWindow(NULL, -1, wxT("")), m_impl(impl)
|
||||||
{
|
{
|
||||||
Connect(-1, wxEVT_COMMAND_MENU_SELECTED,
|
Connect(
|
||||||
wxCommandEventHandler(wxTaskBarIconWindow::OnMenuEvent)
|
-1, wxEVT_COMMAND_MENU_SELECTED,
|
||||||
);
|
wxCommandEventHandler(wxTaskBarIconWindow::OnMenuEvent) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnMenuEvent(wxCommandEvent& event)
|
void OnMenuEvent(wxCommandEvent& event)
|
||||||
@@ -84,12 +70,6 @@ private:
|
|||||||
wxTaskBarIconImpl *m_impl;
|
wxTaskBarIconImpl *m_impl;
|
||||||
};
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// wxDockBarIconImpl
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class wxDockTaskBarIcon : public wxTaskBarIconImpl
|
class wxDockTaskBarIcon : public wxTaskBarIconImpl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -112,38 +92,23 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Forward declarations for utility functions for dock implementation
|
// Forward declarations for utility functions for dock implementation
|
||||||
pascal OSStatus wxDockEventHandler( EventHandlerCallRef inHandlerCallRef,
|
pascal OSStatus wxDockEventHandler(
|
||||||
|
EventHandlerCallRef inHandlerCallRef,
|
||||||
EventRef inEvent, void* pData );
|
EventRef inEvent, void* pData );
|
||||||
wxMenu * wxDeepCopyMenu( wxMenu *menu );
|
wxMenu * wxDeepCopyMenu( wxMenu *menu );
|
||||||
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//
|
|
||||||
// Implementation
|
|
||||||
//
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
//
|
//
|
||||||
// wxTaskBarIconImpl
|
// wxTaskBarIconImpl
|
||||||
//
|
//
|
||||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// wxTaskBarIconImpl Constructor
|
|
||||||
//
|
|
||||||
// Initializes members and creates the event window
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
wxTaskBarIconImpl::wxTaskBarIconImpl(wxTaskBarIcon* parent)
|
wxTaskBarIconImpl::wxTaskBarIconImpl(wxTaskBarIcon* parent)
|
||||||
: m_parent(parent), m_menuEventWindow(new wxTaskBarIconWindow(this))
|
: m_parent(parent), m_menuEventWindow(new wxTaskBarIconWindow(this))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// wxTaskBarIconImpl Destructor
|
|
||||||
//
|
|
||||||
// Cleans up the event window
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
wxTaskBarIconImpl::~wxTaskBarIconImpl()
|
wxTaskBarIconImpl::~wxTaskBarIconImpl()
|
||||||
{
|
{
|
||||||
delete m_menuEventWindow;
|
delete m_menuEventWindow;
|
||||||
@@ -153,17 +118,17 @@ wxTaskBarIconImpl::~wxTaskBarIconImpl()
|
|||||||
//
|
//
|
||||||
// wxDockTaskBarIcon
|
// wxDockTaskBarIcon
|
||||||
//
|
//
|
||||||
// OS X DOCK implementation of wxTaskBarIcon using carbon
|
// OS X Dock implementation of wxTaskBarIcon using Carbon
|
||||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
//-----------------------------------------------------------------------------
|
||||||
// wxDockEventHandler
|
// 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:
|
// We need this for two reasons:
|
||||||
// 1) To handle wxTaskBarIcon menu events (see below for why)
|
// 1) To handle wxTaskBarIcon menu events (see below for why)
|
||||||
// 2) To handle events from the dock when it requests a menu
|
// 2) To handle events from the dock when it requests a menu
|
||||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
//-----------------------------------------------------------------------------
|
||||||
pascal OSStatus wxDockEventHandler( EventHandlerCallRef inHandlerCallRef,
|
pascal OSStatus wxDockEventHandler( EventHandlerCallRef inHandlerCallRef,
|
||||||
EventRef inEvent, void *pData )
|
EventRef inEvent, void *pData )
|
||||||
{
|
{
|
||||||
@@ -174,14 +139,12 @@ pascal OSStatus wxDockEventHandler( EventHandlerCallRef inHandlerCallRef,
|
|||||||
|
|
||||||
// Handle wxTaskBar menu events (note that this is a global event handler
|
// Handle wxTaskBar menu events (note that this is a global event handler
|
||||||
// so it will actually get called by all commands/menus)
|
// so it will actually get called by all commands/menus)
|
||||||
//
|
|
||||||
if ((eventClass == kEventClassCommand) && (eventKind == kEventCommandProcess))
|
if ((eventClass == kEventClassCommand) && (eventKind == kEventCommandProcess))
|
||||||
{
|
{
|
||||||
// if we have no taskbar menu quickly pass it back to wxApp
|
// if we have no taskbar menu quickly pass it back to wxApp
|
||||||
if (pTB->m_pMenu == NULL)
|
if (pTB->m_pMenu == NULL)
|
||||||
return eventNotHandledErr;
|
return eventNotHandledErr;
|
||||||
|
|
||||||
//
|
|
||||||
// This is the real reason why we need this. Normally menus
|
// This is the real reason why we need this. Normally menus
|
||||||
// get handled in wxMacAppEventHandler
|
// get handled in wxMacAppEventHandler
|
||||||
//
|
//
|
||||||
@@ -191,13 +154,13 @@ pascal OSStatus wxDockEventHandler( EventHandlerCallRef inHandlerCallRef,
|
|||||||
// However, in the case of a taskbar menu call
|
// However, in the case of a taskbar menu call
|
||||||
// command.menu.menuRef IS NULL!
|
// command.menu.menuRef IS NULL!
|
||||||
// Which causes the wxApp handler just to skip it.
|
// Which causes the wxApp handler just to skip it.
|
||||||
//
|
|
||||||
MenuRef taskbarMenuRef = MAC_WXHMENU(pTB->m_pMenu->GetHMenu());
|
MenuRef taskbarMenuRef = MAC_WXHMENU(pTB->m_pMenu->GetHMenu());
|
||||||
OSErr err;
|
OSStatus err;
|
||||||
|
|
||||||
// get the HICommand from the event
|
// get the HICommand from the event
|
||||||
HICommand command;
|
HICommand command;
|
||||||
err = GetEventParameter(inEvent, kEventParamDirectObject,
|
err = GetEventParameter(
|
||||||
|
inEvent, kEventParamDirectObject,
|
||||||
typeHICommand, NULL,
|
typeHICommand, NULL,
|
||||||
sizeof(HICommand), NULL, &command );
|
sizeof(HICommand), NULL, &command );
|
||||||
if (err == noErr)
|
if (err == noErr)
|
||||||
@@ -207,11 +170,11 @@ pascal OSStatus wxDockEventHandler( EventHandlerCallRef inHandlerCallRef,
|
|||||||
// NOTE: menuRef is generally used here for submenus, as
|
// NOTE: menuRef is generally used here for submenus, as
|
||||||
// GetMenuItemRefCon could give an incorrect wxMenuItem if we pass
|
// GetMenuItemRefCon could give an incorrect wxMenuItem if we pass
|
||||||
// just the top level wxTaskBar menu
|
// just the top level wxTaskBar menu
|
||||||
//
|
|
||||||
MenuItemIndex menuItemIndex;
|
MenuItemIndex menuItemIndex;
|
||||||
MenuRef menuRef;
|
MenuRef menuRef;
|
||||||
|
|
||||||
err = GetIndMenuItemWithCommandID(taskbarMenuRef,
|
err = GetIndMenuItemWithCommandID(
|
||||||
|
taskbarMenuRef,
|
||||||
command.commandID,
|
command.commandID,
|
||||||
1, &menuRef, &menuItemIndex );
|
1, &menuRef, &menuItemIndex );
|
||||||
if (err == noErr)
|
if (err == noErr)
|
||||||
@@ -230,11 +193,10 @@ pascal OSStatus wxDockEventHandler( EventHandlerCallRef inHandlerCallRef,
|
|||||||
item->Check( !item->IsChecked() );
|
item->Check( !item->IsChecked() );
|
||||||
|
|
||||||
// send the wxEvent to the wxMenu
|
// send the wxEvent to the wxMenu
|
||||||
item->GetMenu()->SendEvent(id,
|
item->GetMenu()->SendEvent( id, item->IsCheckable() ? item->IsChecked() : -1 );
|
||||||
item->IsCheckable() ?
|
|
||||||
item->IsChecked() : -1
|
// successfully handled the event
|
||||||
);
|
err = noErr;
|
||||||
err = noErr; // successfully handled the event
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} //end if noErr on getting HICommand from event
|
} //end if noErr on getting HICommand from event
|
||||||
@@ -273,15 +235,16 @@ pascal OSStatus wxDockEventHandler( EventHandlerCallRef inHandlerCallRef,
|
|||||||
RetainMenu(hMenu);
|
RetainMenu(hMenu);
|
||||||
|
|
||||||
// set the actual dock menu
|
// set the actual dock menu
|
||||||
err = SetEventParameter(inEvent, kEventParamMenuRef,
|
err = SetEventParameter(
|
||||||
|
inEvent, kEventParamMenuRef,
|
||||||
typeMenuRef, sizeof(MenuRef), &hMenu );
|
typeMenuRef, sizeof(MenuRef), &hMenu );
|
||||||
wxASSERT(err == noErr);
|
verify_noerr( err );
|
||||||
}
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
//-----------------------------------------------------------------------------
|
||||||
// wxDeepCopyMenu
|
// wxDeepCopyMenu
|
||||||
//
|
//
|
||||||
// Performs a top-to-bottom copy of the input menu and all of its
|
// Performs a top-to-bottom copy of the input menu and all of its
|
||||||
@@ -289,18 +252,17 @@ pascal OSStatus wxDockEventHandler( EventHandlerCallRef inHandlerCallRef,
|
|||||||
//
|
//
|
||||||
// This is mostly needed for 2.4 compatability. However wxPython and others
|
// This is mostly needed for 2.4 compatability. However wxPython and others
|
||||||
// still use this way of setting the taskbarmenu.
|
// still use this way of setting the taskbarmenu.
|
||||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
//-----------------------------------------------------------------------------
|
||||||
wxMenu * wxDeepCopyMenu( wxMenu *menu )
|
wxMenu * wxDeepCopyMenu( wxMenu *menu )
|
||||||
{
|
{
|
||||||
if (!menu)
|
if (menu == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
//
|
|
||||||
// NB: Here we have to perform a deep copy of the menu,
|
// NB: Here we have to perform a deep copy of the menu,
|
||||||
// copying each and every menu item from menu to m_pMenu.
|
// copying each and every menu item from menu to m_pMenu.
|
||||||
// Other implementations use wxWindow::PopupMenu here,
|
// Other implementations use wxWindow::PopupMenu here,
|
||||||
// which idle execution until the user selects something,
|
// 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
|
// and have no way at all to idle it while the dock menu
|
||||||
// is being shown before menu goes out of scope (it may
|
// is being shown before menu goes out of scope (it may
|
||||||
// not be on the heap, and may expire right after this function
|
// not be on the heap, and may expire right after this function
|
||||||
@@ -310,7 +272,6 @@ wxMenu* wxDeepCopyMenu(wxMenu* menu)
|
|||||||
// Also, since there is no equal (assignment) operator
|
// Also, since there is no equal (assignment) operator
|
||||||
// on either wxMenu or wxMenuItem, we have to do all the
|
// on either wxMenu or wxMenuItem, we have to do all the
|
||||||
// dirty work ourselves.
|
// dirty work ourselves.
|
||||||
//
|
|
||||||
|
|
||||||
// perform a deep copy of the menu
|
// perform a deep copy of the menu
|
||||||
wxMenuItemList& theList = menu->GetMenuItems();
|
wxMenuItemList& theList = menu->GetMenuItems();
|
||||||
@@ -329,8 +290,8 @@ wxMenu* wxDeepCopyMenu(wxMenu* menu)
|
|||||||
theItem->GetText(), // text label
|
theItem->GetText(), // text label
|
||||||
theItem->GetHelp(), // status bar help string
|
theItem->GetHelp(), // status bar help string
|
||||||
theItem->GetKind(), // menu flags - checkable, separator, etc.
|
theItem->GetKind(), // menu flags - checkable, separator, etc.
|
||||||
wxDeepCopyMenu(theItem->GetSubMenu()) // submenu
|
wxDeepCopyMenu(theItem->GetSubMenu()) )); // submenu
|
||||||
));
|
|
||||||
theNode = theNode->GetNext();
|
theNode = theNode->GetNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,7 +303,7 @@ wxMenu* wxDeepCopyMenu(wxMenu* menu)
|
|||||||
//
|
//
|
||||||
// Initializes the dock implementation of wxTaskBarIcon.
|
// 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)
|
wxDockTaskBarIcon::wxDockTaskBarIcon(wxTaskBarIcon* parent)
|
||||||
: wxTaskBarIconImpl(parent),
|
: wxTaskBarIconImpl(parent),
|
||||||
@@ -359,14 +320,11 @@ wxDockTaskBarIcon::wxDockTaskBarIcon(wxTaskBarIcon* parent)
|
|||||||
m_eventupp = NewEventHandlerUPP(wxDockEventHandler);
|
m_eventupp = NewEventHandlerUPP(wxDockEventHandler);
|
||||||
wxASSERT(m_eventupp != NULL);
|
wxASSERT(m_eventupp != NULL);
|
||||||
|
|
||||||
#ifdef __WXDEBUG__
|
OSStatus err = InstallApplicationEventHandler(
|
||||||
OSStatus err =
|
|
||||||
#endif
|
|
||||||
InstallApplicationEventHandler(
|
|
||||||
m_eventupp,
|
m_eventupp,
|
||||||
GetEventTypeCount(tbEventList), tbEventList,
|
GetEventTypeCount(tbEventList), tbEventList,
|
||||||
this, &m_eventHandlerRef);
|
this, &m_eventHandlerRef);
|
||||||
wxASSERT( err == noErr );
|
verify_noerr( err );
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -441,7 +399,7 @@ bool wxDockTaskBarIcon::SetIcon(const wxIcon& icon, const wxString& tooltip)
|
|||||||
|
|
||||||
// actually set the dock image
|
// actually set the dock image
|
||||||
OSStatus err = SetApplicationDockTileImage( pImage );
|
OSStatus err = SetApplicationDockTileImage( pImage );
|
||||||
wxASSERT( err == noErr );
|
verify_noerr( err );
|
||||||
|
|
||||||
// free the CGImage, now that it's referenced by the dock
|
// free the CGImage, now that it's referenced by the dock
|
||||||
if (pImage != NULL)
|
if (pImage != NULL)
|
||||||
@@ -468,7 +426,7 @@ bool wxDockTaskBarIcon::RemoveIcon()
|
|||||||
|
|
||||||
// restore old icon to the dock
|
// restore old icon to the dock
|
||||||
OSStatus err = RestoreApplicationDockTileImage();
|
OSStatus err = RestoreApplicationDockTileImage();
|
||||||
wxASSERT(err == noErr);
|
verify_noerr( err );
|
||||||
|
|
||||||
// restore the old menu to the dock
|
// restore the old menu to the dock
|
||||||
SetApplicationDockTileMenu( m_theLastMenu );
|
SetApplicationDockTileMenu( m_theLastMenu );
|
||||||
@@ -524,9 +482,10 @@ IMPLEMENT_DYNAMIC_CLASS(wxTaskBarIcon, wxEvtHandler)
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
wxTaskBarIcon::wxTaskBarIcon(wxTaskBarIconType nType)
|
wxTaskBarIcon::wxTaskBarIcon(wxTaskBarIconType nType)
|
||||||
{
|
{
|
||||||
wxASSERT_MSG(nType == DOCK,
|
wxASSERT_MSG(
|
||||||
wxT("Only the DOCK implementation of wxTaskBarIcon")
|
nType == DOCK,
|
||||||
wxT("on mac carbon is currently supported!"));
|
wxT("Only the DOCK implementation of wxTaskBarIcon on Mac-Carbon is currently supported!") );
|
||||||
|
|
||||||
m_impl = new wxDockTaskBarIcon(this);
|
m_impl = new wxDockTaskBarIcon(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -549,10 +508,13 @@ wxTaskBarIcon::~wxTaskBarIcon()
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool wxTaskBarIcon::IsIconInstalled() const
|
bool wxTaskBarIcon::IsIconInstalled() const
|
||||||
{ return m_impl->IsIconInstalled(); }
|
{ return m_impl->IsIconInstalled(); }
|
||||||
|
|
||||||
bool wxTaskBarIcon::SetIcon(const wxIcon& icon, const wxString& tooltip)
|
bool wxTaskBarIcon::SetIcon(const wxIcon& icon, const wxString& tooltip)
|
||||||
{ return m_impl->SetIcon(icon, tooltip); }
|
{ return m_impl->SetIcon(icon, tooltip); }
|
||||||
|
|
||||||
bool wxTaskBarIcon::RemoveIcon()
|
bool wxTaskBarIcon::RemoveIcon()
|
||||||
{ return m_impl->RemoveIcon(); }
|
{ return m_impl->RemoveIcon(); }
|
||||||
|
|
||||||
bool wxTaskBarIcon::PopupMenu(wxMenu *menu)
|
bool wxTaskBarIcon::PopupMenu(wxMenu *menu)
|
||||||
{ return m_impl->PopupMenu(menu); }
|
{ return m_impl->PopupMenu(menu); }
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user