cleanup - reformat
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36670 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/mac/carbon/combobox.cpp
|
||||
// Purpose: wxComboBox class
|
||||
// Author: Stefan Csomor
|
||||
// Author: Stefan Csomor, Dan "Bud" Keith (composite combobox)
|
||||
// Modified by:
|
||||
// Created: 1998-01-01
|
||||
// RCS-ID: $Id$
|
||||
@@ -20,14 +20,14 @@
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxControl)
|
||||
|
||||
// composite combobox implementation by Dan "Bud" Keith bud@otsys.com
|
||||
|
||||
|
||||
static int nextPopUpMenuId = 1000 ;
|
||||
|
||||
MenuHandle NewUniqueMenu()
|
||||
{
|
||||
MenuHandle handle = NewMenu( nextPopUpMenuId , "\pMenu" ) ;
|
||||
nextPopUpMenuId++ ;
|
||||
|
||||
return handle ;
|
||||
}
|
||||
|
||||
@@ -93,19 +93,17 @@ protected:
|
||||
event.SetInt( m_cb->GetSelection() );
|
||||
event.SetEventObject( m_cb );
|
||||
|
||||
// This will invoke the dialog default action, such
|
||||
// as the clicking the default button.
|
||||
|
||||
// This will invoke the dialog default action,
|
||||
// such as the clicking the default button.
|
||||
if (!m_cb->GetEventHandler()->ProcessEvent( event ))
|
||||
{
|
||||
wxWindow *parent = GetParent();
|
||||
while( parent && !parent->IsTopLevel() && parent->GetDefaultItem() == NULL ) {
|
||||
while ( parent && !parent->IsTopLevel() && parent->GetDefaultItem() == NULL )
|
||||
parent = parent->GetParent() ;
|
||||
}
|
||||
|
||||
if ( parent && parent->GetDefaultItem() )
|
||||
{
|
||||
wxButton *def = wxDynamicCast(parent->GetDefaultItem(),
|
||||
wxButton);
|
||||
wxButton *def = wxDynamicCast(parent->GetDefaultItem(), wxButton);
|
||||
if ( def && def->IsEnabled() )
|
||||
{
|
||||
wxCommandEvent event( wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() );
|
||||
@@ -166,6 +164,7 @@ public:
|
||||
{
|
||||
m_cb = cb;
|
||||
}
|
||||
|
||||
int GetPopupWidth() const
|
||||
{
|
||||
switch ( GetWindowVariant() )
|
||||
@@ -173,6 +172,7 @@ public:
|
||||
case wxWINDOW_VARIANT_NORMAL :
|
||||
case wxWINDOW_VARIANT_LARGE :
|
||||
return 24 ;
|
||||
|
||||
default :
|
||||
return 21 ;
|
||||
}
|
||||
@@ -197,11 +197,13 @@ protected:
|
||||
TextEvent.SetEventObject( m_cb );
|
||||
m_cb->ProcessCommand( TextEvent );
|
||||
}
|
||||
|
||||
virtual wxSize DoGetBestSize() const
|
||||
{
|
||||
wxSize sz = wxChoice::DoGetBestSize() ;
|
||||
if (! m_cb->HasFlag(wxCB_READONLY) )
|
||||
sz.x = GetPopupWidth() ;
|
||||
|
||||
return sz ;
|
||||
}
|
||||
|
||||
@@ -223,17 +225,19 @@ wxComboBox::~wxComboBox()
|
||||
// delete the controls now, don't leave them alive even though they would
|
||||
// still be eventually deleted by our parent - but it will be too late, the
|
||||
// user code expects them to be gone now
|
||||
if (m_text != NULL) {
|
||||
if (m_text != NULL)
|
||||
{
|
||||
delete m_text;
|
||||
m_text = NULL;
|
||||
}
|
||||
if (m_choice != NULL) {
|
||||
|
||||
if (m_choice != NULL)
|
||||
{
|
||||
delete m_choice;
|
||||
m_choice = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// geometry
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -242,6 +246,7 @@ wxSize wxComboBox::DoGetBestSize() const
|
||||
{
|
||||
if (!m_choice && !m_text)
|
||||
return GetSize();
|
||||
|
||||
wxSize size = m_choice->GetBestSize();
|
||||
|
||||
if ( m_text != NULL )
|
||||
@@ -249,6 +254,7 @@ wxSize wxComboBox::DoGetBestSize() const
|
||||
wxSize sizeText = m_text->GetBestSize();
|
||||
if (sizeText.y > size.y)
|
||||
size.y = sizeText.y;
|
||||
|
||||
size.x = m_choice->GetPopupWidth() + sizeText.x + MARGIN;
|
||||
size.x += TEXTFOCUSBORDER ;
|
||||
size.y += 2 * TEXTFOCUSBORDER ;
|
||||
@@ -258,6 +264,7 @@ wxSize wxComboBox::DoGetBestSize() const
|
||||
// clipping is too tight
|
||||
size.y += 1 ;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -275,13 +282,12 @@ void wxComboBox::DoMoveWindow(int x, int y, int width, int height)
|
||||
{
|
||||
wxCoord wText = width - m_choice->GetPopupWidth() - MARGIN;
|
||||
m_text->SetSize(TEXTFOCUSBORDER, TEXTFOCUSBORDER, wText, -1);
|
||||
|
||||
// put it at an inset of 1 to have outer area shadows drawn as well
|
||||
m_choice->SetSize(TEXTFOCUSBORDER + wText + MARGIN - 1 , TEXTFOCUSBORDER, m_choice->GetPopupWidth() , -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// operations forwarded to the subcontrols
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -307,25 +313,22 @@ bool wxComboBox::Show(bool show)
|
||||
|
||||
void wxComboBox::SetFocus()
|
||||
{
|
||||
if ( m_text != NULL) {
|
||||
if ( m_text != NULL)
|
||||
m_text->SetFocus();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void wxComboBox::DelegateTextChanged( const wxString& value )
|
||||
{
|
||||
SetStringSelection( value );
|
||||
}
|
||||
|
||||
|
||||
void wxComboBox::DelegateChoice( const wxString& value )
|
||||
{
|
||||
SetStringSelection( value );
|
||||
}
|
||||
|
||||
|
||||
bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
|
||||
bool wxComboBox::Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxString& value,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
@@ -340,12 +343,13 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
|
||||
chs.GetStrings(), style, validator, name );
|
||||
}
|
||||
|
||||
|
||||
bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
|
||||
bool wxComboBox::Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxString& value,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
int n, const wxString choices[],
|
||||
int n,
|
||||
const wxString choices[],
|
||||
long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
@@ -379,7 +383,8 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
|
||||
m_choice->DoAppend( choices[ i ] );
|
||||
}
|
||||
|
||||
SetBestSize(size); // Needed because it is a wxControlWithItems
|
||||
// Needed because it is a wxControlWithItems
|
||||
SetBestSize(size);
|
||||
SetStringSelection(value);
|
||||
|
||||
return true;
|
||||
@@ -390,13 +395,9 @@ wxString wxComboBox::GetValue() const
|
||||
wxString result;
|
||||
|
||||
if ( m_text == NULL )
|
||||
{
|
||||
result = m_choice->GetString( m_choice->GetSelection() );
|
||||
}
|
||||
else
|
||||
{
|
||||
result = m_text->GetValue();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -415,29 +416,24 @@ void wxComboBox::SetValue(const wxString& value)
|
||||
}
|
||||
|
||||
// Clipboard operations
|
||||
|
||||
void wxComboBox::Copy()
|
||||
{
|
||||
if ( m_text != NULL )
|
||||
{
|
||||
m_text->Copy();
|
||||
}
|
||||
}
|
||||
|
||||
void wxComboBox::Cut()
|
||||
{
|
||||
if ( m_text != NULL )
|
||||
{
|
||||
m_text->Cut();
|
||||
}
|
||||
}
|
||||
|
||||
void wxComboBox::Paste()
|
||||
{
|
||||
if ( m_text != NULL )
|
||||
{
|
||||
m_text->Paste();
|
||||
}
|
||||
}
|
||||
|
||||
void wxComboBox::SetEditable(bool editable)
|
||||
{
|
||||
@@ -563,10 +559,8 @@ void wxComboBox::SetSelection(int n)
|
||||
m_choice->SetSelection( n );
|
||||
|
||||
if ( m_text != NULL )
|
||||
{
|
||||
m_text->SetValue( GetString( n ) );
|
||||
}
|
||||
}
|
||||
|
||||
int wxComboBox::FindString(const wxString& s, bool bCase) const
|
||||
{
|
||||
@@ -657,12 +651,15 @@ bool wxComboBox::CanRedo() const
|
||||
|
||||
wxInt32 wxComboBox::MacControlHit( WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) )
|
||||
{
|
||||
/* For consistency with other platforms, clicking in the text area does not constitute a selection
|
||||
/*
|
||||
For consistency with other platforms, clicking in the text area does not constitute a selection
|
||||
wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_SELECTED, m_windowId );
|
||||
event.SetInt(GetSelection());
|
||||
event.SetEventObject(this);
|
||||
event.SetString(GetStringSelection());
|
||||
ProcessCommand(event);*/
|
||||
ProcessCommand(event);
|
||||
*/
|
||||
|
||||
return noErr ;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: dnd.cpp
|
||||
// Purpose: wxDropTarget, wxDropSource, wxDataObject implementation
|
||||
// Purpose: wxDropTarget, wxDropSource implementations
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 1998-01-01
|
||||
@@ -25,20 +25,21 @@
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// global
|
||||
// globals
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxMacEnsureTrackingHandlersInstalled() ;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
wxWindow* m_currentTargetWindow ;
|
||||
wxDropTarget* m_currentTarget ;
|
||||
wxDropSource* m_currentSource ;
|
||||
} MacTrackingGlobals ;
|
||||
}
|
||||
MacTrackingGlobals ;
|
||||
|
||||
MacTrackingGlobals gTrackingGlobals ;
|
||||
|
||||
void wxMacEnsureTrackingHandlersInstalled() ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// wxDropTarget
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -53,14 +54,13 @@ wxDragResult wxDropTarget::OnDragOver( wxCoord WXUNUSED(x),
|
||||
wxCoord WXUNUSED(y),
|
||||
wxDragResult def )
|
||||
{
|
||||
|
||||
return CurrentDragHasSupportedFormat() ? def : wxDragNone;
|
||||
}
|
||||
|
||||
bool wxDropTarget::OnDrop( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y) )
|
||||
{
|
||||
if (!m_dataObject)
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
return CurrentDragHasSupportedFormat() ;
|
||||
}
|
||||
@@ -98,21 +98,26 @@ bool wxDropTarget::CurrentDragHasSupportedFormat()
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
delete [] array ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !supported )
|
||||
{
|
||||
UInt16 items ;
|
||||
OSErr result;
|
||||
CountDragItems((DragReference)m_currentDrag, &items);
|
||||
for (UInt16 index = 1; index <= items && supported == false ; ++index)
|
||||
{
|
||||
ItemReference theItem;
|
||||
FlavorType theType ;
|
||||
UInt16 flavors = 0 ;
|
||||
|
||||
CountDragItems((DragReference)m_currentDrag, &items);
|
||||
for (UInt16 index = 1; index <= items && !supported ; ++index)
|
||||
{
|
||||
flavors = 0 ;
|
||||
GetDragItemReferenceNumber((DragReference)m_currentDrag, index, &theItem);
|
||||
CountDragItemFlavors( (DragReference)m_currentDrag, theItem , &flavors ) ;
|
||||
|
||||
for ( UInt16 flavor = 1 ; flavor <= flavors ; ++flavor )
|
||||
{
|
||||
result = GetFlavorType((DragReference)m_currentDrag, theItem, flavor , &theType);
|
||||
@@ -124,16 +129,17 @@ bool wxDropTarget::CurrentDragHasSupportedFormat()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return supported ;
|
||||
}
|
||||
|
||||
bool wxDropTarget::GetData()
|
||||
{
|
||||
if (!m_dataObject)
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
if ( !CurrentDragHasSupportedFormat() )
|
||||
return FALSE ;
|
||||
return false ;
|
||||
|
||||
bool transferred = false ;
|
||||
if ( gTrackingGlobals.m_currentSource != NULL )
|
||||
@@ -166,20 +172,25 @@ bool wxDropTarget::GetData()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete [] array ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !transferred )
|
||||
{
|
||||
UInt16 items ;
|
||||
OSErr result;
|
||||
ItemReference theItem;
|
||||
FlavorType theType ;
|
||||
FlavorFlags theFlags;
|
||||
UInt16 flavors ;
|
||||
bool firstFileAdded = false ;
|
||||
|
||||
CountDragItems((DragReference)m_currentDrag, &items);
|
||||
for (UInt16 index = 1; index <= items; ++index)
|
||||
{
|
||||
ItemReference theItem;
|
||||
FlavorType theType ;
|
||||
UInt16 flavors = 0 ;
|
||||
flavors = 0 ;
|
||||
GetDragItemReferenceNumber((DragReference)m_currentDrag, index, &theItem);
|
||||
CountDragItemFlavors( (DragReference)m_currentDrag, theItem , &flavors ) ;
|
||||
bool hasPreferredFormat = false ;
|
||||
@@ -202,12 +213,12 @@ bool wxDropTarget::GetData()
|
||||
wxDataFormat format(theType) ;
|
||||
if ( (hasPreferredFormat && format == preferredFormat) || (!hasPreferredFormat && m_dataObject->IsSupportedFormat( format )))
|
||||
{
|
||||
FlavorFlags theFlags;
|
||||
result = GetFlavorFlags((DragReference)m_currentDrag, theItem, theType, &theFlags);
|
||||
if (result == noErr)
|
||||
{
|
||||
Size dataSize ;
|
||||
Ptr theData ;
|
||||
|
||||
GetFlavorDataSize((DragReference)m_currentDrag, theItem, theType, &dataSize);
|
||||
if ( theType == kScrapFlavorTypeText )
|
||||
{
|
||||
@@ -222,6 +233,7 @@ bool wxDropTarget::GetData()
|
||||
dataSize++ ;
|
||||
dataSize++ ;
|
||||
}
|
||||
|
||||
theData = new char[dataSize];
|
||||
GetFlavorData((DragReference)m_currentDrag, theItem, theType, (void*) theData, &dataSize, 0L);
|
||||
if ( theType == kScrapFlavorTypeText )
|
||||
@@ -247,12 +259,14 @@ bool wxDropTarget::GetData()
|
||||
((wxFileDataObject*)m_dataObject)->SetData( 0 , "" ) ;
|
||||
firstFileAdded = true ;
|
||||
}
|
||||
|
||||
((wxFileDataObject*)m_dataObject)->AddFile( name ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_dataObject->SetData( format, dataSize, theData );
|
||||
}
|
||||
|
||||
delete [] theData;
|
||||
}
|
||||
break ;
|
||||
@@ -260,7 +274,8 @@ bool wxDropTarget::GetData()
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
@@ -296,29 +311,27 @@ wxDropSource::~wxDropSource()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
wxDragResult wxDropSource::DoDragDrop(int flags)
|
||||
{
|
||||
wxASSERT_MSG( m_data, wxT("Drop source: no data") );
|
||||
|
||||
if (!m_data)
|
||||
return (wxDragResult) wxDragNone;
|
||||
|
||||
if (m_data->GetFormatCount() == 0)
|
||||
return (wxDragResult) wxDragNone;
|
||||
|
||||
OSErr result;
|
||||
DragReference theDrag;
|
||||
RgnHandle dragRegion;
|
||||
if ((result = NewDrag(&theDrag)))
|
||||
{
|
||||
if ((result = NewDrag(&theDrag)) != noErr)
|
||||
return wxDragNone ;
|
||||
}
|
||||
|
||||
// add data to drag
|
||||
size_t formatCount = m_data->GetFormatCount() ;
|
||||
wxDataFormat *formats = new wxDataFormat[formatCount] ;
|
||||
m_data->GetAllFormats( formats ) ;
|
||||
ItemReference theItem = 1 ;
|
||||
|
||||
for ( size_t i = 0 ; i < formatCount ; ++i )
|
||||
{
|
||||
size_t dataSize = m_data->GetDataSize( formats[i] ) ;
|
||||
@@ -336,6 +349,7 @@ wxDragResult wxDropSource::DoDragDrop(int flags)
|
||||
dataSize-- ;
|
||||
dataPtr[ dataSize ] = 0 ;
|
||||
}
|
||||
|
||||
AddDragItemFlavor(theDrag, theItem, type , dataPtr, dataSize, 0);
|
||||
}
|
||||
else if (type == kDragFlavorTypeHFS )
|
||||
@@ -346,6 +360,7 @@ wxDragResult wxDropSource::DoDragDrop(int flags)
|
||||
|
||||
wxMacFilename2FSSpec( wxString( dataPtr , *wxConvCurrent ) , &theFlavor.fileSpec ) ;
|
||||
|
||||
memset( &cat, 0, sizeof(cat) );
|
||||
cat.hFileInfo.ioNamePtr = theFlavor.fileSpec.name;
|
||||
cat.hFileInfo.ioVRefNum = theFlavor.fileSpec.vRefNum;
|
||||
cat.hFileInfo.ioDirID = theFlavor.fileSpec.parID;
|
||||
@@ -354,16 +369,22 @@ wxDragResult wxDropSource::DoDragDrop(int flags)
|
||||
if (err == noErr)
|
||||
{
|
||||
theFlavor.fdFlags = cat.hFileInfo.ioFlFndrInfo.fdFlags;
|
||||
if (theFlavor.fileSpec.parID == fsRtParID) {
|
||||
if (theFlavor.fileSpec.parID == fsRtParID)
|
||||
{
|
||||
theFlavor.fileCreator = 'MACS';
|
||||
theFlavor.fileType = 'disk';
|
||||
} else if ((cat.hFileInfo.ioFlAttrib & ioDirMask) != 0) {
|
||||
}
|
||||
else if ((cat.hFileInfo.ioFlAttrib & ioDirMask) != 0)
|
||||
{
|
||||
theFlavor.fileCreator = 'MACS';
|
||||
theFlavor.fileType = 'fold';
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
theFlavor.fileCreator = cat.hFileInfo.ioFlFndrInfo.fdCreator;
|
||||
theFlavor.fileType = cat.hFileInfo.ioFlFndrInfo.fdType;
|
||||
}
|
||||
|
||||
AddDragItemFlavor(theDrag, theItem, type , &theFlavor, sizeof(theFlavor), 0);
|
||||
}
|
||||
}
|
||||
@@ -371,30 +392,38 @@ wxDragResult wxDropSource::DoDragDrop(int flags)
|
||||
{
|
||||
AddDragItemFlavor(theDrag, theItem, type , dataPtr, dataSize, 0);
|
||||
}
|
||||
|
||||
delete [] dataPtr ;
|
||||
}
|
||||
|
||||
delete [] formats ;
|
||||
|
||||
dragRegion = NewRgn();
|
||||
RgnHandle tempRgn = NewRgn() ;
|
||||
|
||||
EventRecord* ev = NULL ;
|
||||
|
||||
#if !TARGET_CARBON // TODO
|
||||
ev = (EventRecord*) wxTheApp->MacGetCurrentEvent() ;
|
||||
#else
|
||||
{
|
||||
EventRecord rec ;
|
||||
ev = &rec ;
|
||||
wxMacConvertEventToRecord( (EventRef) wxTheApp->MacGetCurrentEvent() , &rec ) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
const short dragRegionOuterBoundary = 10 ;
|
||||
const short dragRegionInnerBoundary = 9 ;
|
||||
|
||||
SetRectRgn( dragRegion , ev->where.h - dragRegionOuterBoundary ,
|
||||
SetRectRgn(
|
||||
dragRegion , ev->where.h - dragRegionOuterBoundary ,
|
||||
ev->where.v - dragRegionOuterBoundary ,
|
||||
ev->where.h + dragRegionOuterBoundary ,
|
||||
ev->where.v + dragRegionOuterBoundary ) ;
|
||||
|
||||
SetRectRgn( tempRgn , ev->where.h - dragRegionInnerBoundary ,
|
||||
SetRectRgn(
|
||||
tempRgn , ev->where.h - dragRegionInnerBoundary ,
|
||||
ev->where.v - dragRegionInnerBoundary ,
|
||||
ev->where.h + dragRegionInnerBoundary ,
|
||||
ev->where.v + dragRegionInnerBoundary ) ;
|
||||
@@ -414,26 +443,21 @@ wxDragResult wxDropSource::DoDragDrop(int flags)
|
||||
bool optionDown = GetCurrentKeyModifiers() & optionKey ;
|
||||
wxDragResult dndresult = wxDragCopy ;
|
||||
if ( flags != wxDrag_CopyOnly )
|
||||
{
|
||||
// on mac the option key is always the indication for copy
|
||||
dndresult = optionDown ? wxDragCopy : wxDragMove;
|
||||
}
|
||||
|
||||
return dndresult;
|
||||
}
|
||||
|
||||
bool wxDropSource::MacInstallDefaultCursor(wxDragResult effect)
|
||||
{
|
||||
const wxCursor& cursor = GetCursor(effect);
|
||||
if ( cursor.Ok() )
|
||||
{
|
||||
bool result = cursor.Ok();
|
||||
|
||||
if ( result )
|
||||
cursor.MacInstall() ;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool gTrackingGlobalsInstalled = false ;
|
||||
@@ -441,9 +465,11 @@ bool gTrackingGlobalsInstalled = false ;
|
||||
// passing the globals via refcon is not needed by the CFM and later architectures anymore
|
||||
// but I'll leave it in there, just in case...
|
||||
|
||||
pascal OSErr wxMacWindowDragTrackingHandler(DragTrackingMessage theMessage, WindowPtr theWindow,
|
||||
pascal OSErr wxMacWindowDragTrackingHandler(
|
||||
DragTrackingMessage theMessage, WindowPtr theWindow,
|
||||
void *handlerRefCon, DragReference theDrag) ;
|
||||
pascal OSErr wxMacWindowDragReceiveHandler(WindowPtr theWindow, void *handlerRefCon,
|
||||
pascal OSErr wxMacWindowDragReceiveHandler(
|
||||
WindowPtr theWindow, void *handlerRefCon,
|
||||
DragReference theDrag) ;
|
||||
|
||||
void wxMacEnsureTrackingHandlersInstalled()
|
||||
@@ -454,6 +480,7 @@ void wxMacEnsureTrackingHandlersInstalled()
|
||||
|
||||
result = InstallTrackingHandler(NewDragTrackingHandlerUPP(wxMacWindowDragTrackingHandler), 0L,&gTrackingGlobals);
|
||||
wxASSERT( result == noErr ) ;
|
||||
|
||||
result = InstallReceiveHandler(NewDragReceiveHandlerUPP(wxMacWindowDragReceiveHandler), 0L, &gTrackingGlobals);
|
||||
wxASSERT( result == noErr ) ;
|
||||
|
||||
@@ -461,7 +488,8 @@ void wxMacEnsureTrackingHandlersInstalled()
|
||||
}
|
||||
}
|
||||
|
||||
pascal OSErr wxMacWindowDragTrackingHandler(DragTrackingMessage theMessage, WindowPtr theWindow,
|
||||
pascal OSErr wxMacWindowDragTrackingHandler(
|
||||
DragTrackingMessage theMessage, WindowPtr theWindow,
|
||||
void *handlerRefCon, DragReference theDrag)
|
||||
{
|
||||
MacTrackingGlobals* trackingGlobals = (MacTrackingGlobals*) handlerRefCon;
|
||||
@@ -476,13 +504,14 @@ pascal OSErr wxMacWindowDragTrackingHandler(DragTrackingMessage theMessage, Wind
|
||||
switch (theMessage)
|
||||
{
|
||||
case kDragTrackingEnterHandler:
|
||||
break;
|
||||
case kDragTrackingLeaveHandler:
|
||||
break;
|
||||
|
||||
case kDragTrackingEnterWindow:
|
||||
trackingGlobals->m_currentTargetWindow = NULL ;
|
||||
trackingGlobals->m_currentTarget = NULL ;
|
||||
break;
|
||||
|
||||
case kDragTrackingInWindow:
|
||||
if (toplevel == NULL)
|
||||
break;
|
||||
@@ -491,12 +520,11 @@ pascal OSErr wxMacWindowDragTrackingHandler(DragTrackingMessage theMessage, Wind
|
||||
localMouse = mouse;
|
||||
GlobalToLocal(&localMouse);
|
||||
|
||||
|
||||
|
||||
{
|
||||
wxWindow *win = NULL ;
|
||||
ControlPartCode controlPart ;
|
||||
ControlRef control = wxMacFindControlUnderMouse( toplevel , localMouse ,
|
||||
ControlRef control = wxMacFindControlUnderMouse(
|
||||
toplevel , localMouse ,
|
||||
theWindow , &controlPart ) ;
|
||||
if ( control )
|
||||
win = wxFindControlFromMacControl( control ) ;
|
||||
@@ -523,24 +551,23 @@ pascal OSErr wxMacWindowDragTrackingHandler(DragTrackingMessage theMessage, Wind
|
||||
trackingGlobals->m_currentTargetWindow = NULL ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( win )
|
||||
{
|
||||
// this window is entered
|
||||
trackingGlobals->m_currentTargetWindow = win ;
|
||||
trackingGlobals->m_currentTarget = win->GetDropTarget() ;
|
||||
{
|
||||
|
||||
if ( trackingGlobals->m_currentTarget )
|
||||
{
|
||||
trackingGlobals->m_currentTarget->SetCurrentDrag( theDrag ) ;
|
||||
result = trackingGlobals->m_currentTarget->OnEnter(
|
||||
localx , localy , result ) ;
|
||||
result = trackingGlobals->m_currentTarget->OnEnter( localx , localy , result ) ;
|
||||
}
|
||||
|
||||
|
||||
if ( result != wxDragNone )
|
||||
{
|
||||
int x , y ;
|
||||
|
||||
x = y = 0 ;
|
||||
win->MacWindowToRootWindow( &x , &y ) ;
|
||||
RgnHandle hiliteRgn = NewRgn() ;
|
||||
@@ -557,15 +584,14 @@ pascal OSErr wxMacWindowDragTrackingHandler(DragTrackingMessage theMessage, Wind
|
||||
if ( trackingGlobals->m_currentTarget )
|
||||
{
|
||||
trackingGlobals->m_currentTarget->SetCurrentDrag( theDrag ) ;
|
||||
trackingGlobals->m_currentTarget->OnDragOver(
|
||||
localx , localy , result ) ;
|
||||
trackingGlobals->m_currentTarget->OnDragOver( localx , localy , result ) ;
|
||||
}
|
||||
}
|
||||
|
||||
// set cursor for OnEnter and OnDragOver
|
||||
if ( trackingGlobals->m_currentSource && trackingGlobals->m_currentSource->GiveFeedback( result ) == FALSE )
|
||||
if ( !trackingGlobals->m_currentSource && trackingGlobals->m_currentSource->GiveFeedback( result ) )
|
||||
{
|
||||
if ( trackingGlobals->m_currentSource->MacInstallDefaultCursor( result ) == FALSE )
|
||||
if ( !trackingGlobals->m_currentSource->MacInstallDefaultCursor( result ) )
|
||||
{
|
||||
switch ( result )
|
||||
{
|
||||
@@ -575,12 +601,14 @@ pascal OSErr wxMacWindowDragTrackingHandler(DragTrackingMessage theMessage, Wind
|
||||
cursor.MacInstall() ;
|
||||
}
|
||||
break ;
|
||||
|
||||
case wxDragMove :
|
||||
{
|
||||
wxCursor cursor(wxCURSOR_ARROW) ;
|
||||
cursor.MacInstall() ;
|
||||
}
|
||||
break ;
|
||||
|
||||
case wxDragNone :
|
||||
{
|
||||
wxCursor cursor(wxCURSOR_NO_ENTRY) ;
|
||||
@@ -591,14 +619,15 @@ pascal OSErr wxMacWindowDragTrackingHandler(DragTrackingMessage theMessage, Wind
|
||||
case wxDragError:
|
||||
case wxDragLink:
|
||||
case wxDragCancel:
|
||||
default:
|
||||
// put these here to make gcc happy
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case kDragTrackingLeaveWindow:
|
||||
if (trackingGlobals->m_currentTarget)
|
||||
{
|
||||
@@ -609,11 +638,16 @@ pascal OSErr wxMacWindowDragTrackingHandler(DragTrackingMessage theMessage, Wind
|
||||
}
|
||||
trackingGlobals->m_currentTargetWindow = NULL ;
|
||||
break;
|
||||
}
|
||||
return(noErr);
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
pascal OSErr wxMacWindowDragReceiveHandler(WindowPtr theWindow,
|
||||
return noErr;
|
||||
}
|
||||
|
||||
pascal OSErr wxMacWindowDragReceiveHandler(
|
||||
WindowPtr theWindow,
|
||||
void *handlerRefCon,
|
||||
DragReference theDrag)
|
||||
{
|
||||
@@ -629,7 +663,8 @@ pascal OSErr wxMacWindowDragReceiveHandler(WindowPtr theWindow,
|
||||
GlobalToLocal(&localMouse);
|
||||
localx = localMouse.h ;
|
||||
localy = localMouse.v ;
|
||||
//TODO : should we use client coordinates
|
||||
|
||||
// TODO : should we use client coordinates?
|
||||
if ( trackingGlobals->m_currentTargetWindow )
|
||||
trackingGlobals->m_currentTargetWindow->MacRootWindowToWindow( &localx , &localy ) ;
|
||||
if ( trackingGlobals->m_currentTarget->OnDrop( localx , localy ) )
|
||||
@@ -639,6 +674,8 @@ pascal OSErr wxMacWindowDragReceiveHandler(WindowPtr theWindow,
|
||||
trackingGlobals->m_currentTarget->OnData( localx , localy , result ) ;
|
||||
}
|
||||
}
|
||||
return(noErr);
|
||||
|
||||
return noErr;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user