small adaptions
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4882 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
142
src/mac/app.cpp
142
src/mac/app.cpp
@@ -504,6 +504,17 @@ void wxApp::CleanUp()
|
|||||||
|
|
||||||
int wxEntry( int argc, char *argv[] )
|
int wxEntry( int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
|
#ifdef __MWERKS__
|
||||||
|
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
|
||||||
|
// This seems to be necessary since there are 'rogue'
|
||||||
|
// objects present at this point (perhaps global objects?)
|
||||||
|
// Setting a checkpoint will ignore them as far as the
|
||||||
|
// memory checking facility is concerned.
|
||||||
|
// Of course you may argue that memory allocated in globals should be
|
||||||
|
// checked, but this is a reasonable compromise.
|
||||||
|
wxDebugContext::SetCheckpoint();
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
if (!wxApp::Initialize())
|
if (!wxApp::Initialize())
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!wxTheApp)
|
if (!wxTheApp)
|
||||||
@@ -1021,109 +1032,112 @@ void wxApp::MacHandleMouseUpEvent( EventRecord *ev )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
long wxMacTranslateKey(char key, char code)
|
long wxMacTranslateKey(unsigned char key, unsigned char code)
|
||||||
{
|
{
|
||||||
|
long retval = key ;
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
case 0x01 :
|
case 0x01 :
|
||||||
key = WXK_HOME;
|
retval = WXK_HOME;
|
||||||
break;
|
break;
|
||||||
case 0x03 :
|
case 0x03 :
|
||||||
key = WXK_RETURN;
|
retval = WXK_RETURN;
|
||||||
break;
|
break;
|
||||||
case 0x04 :
|
case 0x04 :
|
||||||
key = WXK_END;
|
retval = WXK_END;
|
||||||
break;
|
break;
|
||||||
case 0x05 :
|
case 0x05 :
|
||||||
key = WXK_HELP;
|
retval = WXK_HELP;
|
||||||
break;
|
break;
|
||||||
case 0x08 :
|
case 0x08 :
|
||||||
key = WXK_BACK;
|
retval = WXK_BACK;
|
||||||
break;
|
break;
|
||||||
case 0x09 :
|
case 0x09 :
|
||||||
key = WXK_TAB;
|
retval = WXK_TAB;
|
||||||
break;
|
break;
|
||||||
case 0x0b :
|
case 0x0b :
|
||||||
key = WXK_PAGEUP;
|
retval = WXK_PAGEUP;
|
||||||
break;
|
break;
|
||||||
case 0x0c :
|
case 0x0c :
|
||||||
key = WXK_PAGEDOWN;
|
retval = WXK_PAGEDOWN;
|
||||||
break;
|
break;
|
||||||
case 0x0d :
|
case 0x0d :
|
||||||
key = WXK_RETURN;
|
retval = WXK_RETURN;
|
||||||
break;
|
break;
|
||||||
case 0x10 :
|
case 0x10 :
|
||||||
{
|
{
|
||||||
switch( code )
|
switch( code )
|
||||||
{
|
{
|
||||||
case 0x7a :
|
case 0x7a :
|
||||||
key = WXK_F1 ;
|
retval = WXK_F1 ;
|
||||||
break;
|
break;
|
||||||
case 0x78 :
|
case 0x78 :
|
||||||
key = WXK_F2 ;
|
retval = WXK_F2 ;
|
||||||
break;
|
break;
|
||||||
case 0x63 :
|
case 0x63 :
|
||||||
key = WXK_F3 ;
|
retval = WXK_F3 ;
|
||||||
break;
|
break;
|
||||||
case 0x76 :
|
case 0x76 :
|
||||||
key = WXK_F4 ;
|
retval = WXK_F4 ;
|
||||||
break;
|
break;
|
||||||
case 0x60 :
|
case 0x60 :
|
||||||
key = WXK_F5 ;
|
retval = WXK_F5 ;
|
||||||
break;
|
break;
|
||||||
case 0x61 :
|
case 0x61 :
|
||||||
key = WXK_F6 ;
|
retval = WXK_F6 ;
|
||||||
break;
|
break;
|
||||||
case 0x62:
|
case 0x62:
|
||||||
key = WXK_F7 ;
|
retval = WXK_F7 ;
|
||||||
break;
|
break;
|
||||||
case 0x64 :
|
case 0x64 :
|
||||||
key = WXK_F8 ;
|
retval = WXK_F8 ;
|
||||||
break;
|
break;
|
||||||
case 0x65 :
|
case 0x65 :
|
||||||
key = WXK_F9 ;
|
retval = WXK_F9 ;
|
||||||
break;
|
break;
|
||||||
case 0x6D :
|
case 0x6D :
|
||||||
key = WXK_F10 ;
|
retval = WXK_F10 ;
|
||||||
break;
|
break;
|
||||||
case 0x67 :
|
case 0x67 :
|
||||||
key = WXK_F11 ;
|
retval = WXK_F11 ;
|
||||||
break;
|
break;
|
||||||
case 0x6F :
|
case 0x6F :
|
||||||
key = WXK_F12 ;
|
retval = WXK_F12 ;
|
||||||
break;
|
break;
|
||||||
case 0x69 :
|
case 0x69 :
|
||||||
key = WXK_F13 ;
|
retval = WXK_F13 ;
|
||||||
break;
|
break;
|
||||||
case 0x6B :
|
case 0x6B :
|
||||||
key = WXK_F14 ;
|
retval = WXK_F14 ;
|
||||||
break;
|
break;
|
||||||
case 0x71 :
|
case 0x71 :
|
||||||
key = WXK_F15 ;
|
retval = WXK_F15 ;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break ;
|
break ;
|
||||||
case 0x1b :
|
case 0x1b :
|
||||||
key = WXK_DELETE ;
|
retval = WXK_ESCAPE ;
|
||||||
break ;
|
break ;
|
||||||
case 0x1c :
|
case 0x1c :
|
||||||
key = WXK_LEFT ;
|
retval = WXK_LEFT ;
|
||||||
break ;
|
break ;
|
||||||
case 0x1d :
|
case 0x1d :
|
||||||
key = WXK_RIGHT ;
|
retval = WXK_RIGHT ;
|
||||||
break ;
|
break ;
|
||||||
case 0x1e :
|
case 0x1e :
|
||||||
key = WXK_UP ;
|
retval = WXK_UP ;
|
||||||
break ;
|
break ;
|
||||||
case 0x1f :
|
case 0x1f :
|
||||||
key = WXK_DOWN ;
|
retval = WXK_DOWN ;
|
||||||
break ;
|
break ;
|
||||||
|
case 0x7F :
|
||||||
|
retval = WXK_DELETE ;
|
||||||
default:
|
default:
|
||||||
break ;
|
break ;
|
||||||
} // end switch
|
} // end switch
|
||||||
|
|
||||||
return key;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxApp::MacHandleKeyDownEvent( EventRecord *ev )
|
void wxApp::MacHandleKeyDownEvent( EventRecord *ev )
|
||||||
@@ -1140,18 +1154,80 @@ void wxApp::MacHandleKeyDownEvent( EventRecord *ev )
|
|||||||
|
|
||||||
wxWindow* focus = wxWindow::FindFocus() ;
|
wxWindow* focus = wxWindow::FindFocus() ;
|
||||||
if ( focus )
|
if ( focus )
|
||||||
|
{
|
||||||
|
long keyval = wxMacTranslateKey(keychar, keycode) ;
|
||||||
|
|
||||||
|
wxKeyEvent event(wxEVT_KEY_DOWN);
|
||||||
|
event.m_shiftDown = ev->modifiers & shiftKey;
|
||||||
|
event.m_controlDown = ev->modifiers & controlKey;
|
||||||
|
event.m_altDown = ev->modifiers & optionKey;
|
||||||
|
event.m_metaDown = ev->modifiers & cmdKey;
|
||||||
|
event.m_keyCode = keyval;
|
||||||
|
event.m_x = ev->where.h;
|
||||||
|
event.m_y = ev->where.v;
|
||||||
|
event.m_timeStamp = ev->when;
|
||||||
|
event.SetEventObject(focus);
|
||||||
|
bool handled = focus->GetEventHandler()->ProcessEvent( event ) ;
|
||||||
|
if ( !handled )
|
||||||
|
{
|
||||||
|
#if wxUSE_ACCEL
|
||||||
|
if (!handled)
|
||||||
|
{
|
||||||
|
wxWindow *ancestor = focus;
|
||||||
|
/*
|
||||||
|
while (ancestor)
|
||||||
|
{
|
||||||
|
int command = ancestor->GetAcceleratorTable()->GetCommand( event );
|
||||||
|
if (command != -1)
|
||||||
|
{
|
||||||
|
wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command );
|
||||||
|
handled = ancestor->GetEventHandler()->ProcessEvent( command_event );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (ancestor->m_isFrame)
|
||||||
|
break;
|
||||||
|
ancestor = ancestor->GetParent();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
#endif // wxUSE_ACCEL
|
||||||
|
}
|
||||||
|
if (!handled)
|
||||||
{
|
{
|
||||||
wxKeyEvent event(wxEVT_CHAR);
|
wxKeyEvent event(wxEVT_CHAR);
|
||||||
event.m_shiftDown = ev->modifiers & shiftKey;
|
event.m_shiftDown = ev->modifiers & shiftKey;
|
||||||
event.m_controlDown = ev->modifiers & controlKey;
|
event.m_controlDown = ev->modifiers & controlKey;
|
||||||
event.m_altDown = ev->modifiers & optionKey;
|
event.m_altDown = ev->modifiers & optionKey;
|
||||||
event.m_metaDown = ev->modifiers & cmdKey;
|
event.m_metaDown = ev->modifiers & cmdKey;
|
||||||
event.m_keyCode = wxMacTranslateKey(keychar, keycode);
|
event.m_keyCode = keyval;
|
||||||
event.m_x = ev->where.h;
|
event.m_x = ev->where.h;
|
||||||
event.m_y = ev->where.v;
|
event.m_y = ev->where.v;
|
||||||
event.m_timeStamp = ev->when;
|
event.m_timeStamp = ev->when;
|
||||||
event.SetEventObject(focus);
|
event.SetEventObject(focus);
|
||||||
focus->GetEventHandler()->ProcessEvent( event ) ;
|
handled = focus->GetEventHandler()->ProcessEvent( event ) ;
|
||||||
|
}
|
||||||
|
if ( !handled &&
|
||||||
|
(keyval == WXK_TAB) &&
|
||||||
|
(!focus->HasFlag(wxTE_PROCESS_TAB)) &&
|
||||||
|
(focus->GetParent()) &&
|
||||||
|
(focus->GetParent()->HasFlag( wxTAB_TRAVERSAL)) )
|
||||||
|
{
|
||||||
|
wxNavigationKeyEvent new_event;
|
||||||
|
new_event.SetEventObject( focus );
|
||||||
|
new_event.SetDirection( !event.ShiftDown() );
|
||||||
|
/* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
|
||||||
|
new_event.SetWindowChange( event.ControlDown() );
|
||||||
|
new_event.SetCurrentFocus( focus );
|
||||||
|
handled = focus->GetEventHandler()->ProcessEvent( new_event );
|
||||||
|
}
|
||||||
|
/* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */
|
||||||
|
if ( (!handled) &&
|
||||||
|
(keyval == '.' && event.ControlDown() ) )
|
||||||
|
{
|
||||||
|
wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL);
|
||||||
|
new_event.SetEventObject( focus );
|
||||||
|
handled = focus->GetEventHandler()->ProcessEvent( new_event );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,6 +19,10 @@
|
|||||||
IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton, wxButton)
|
IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton, wxButton)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <wx/mac/uma.h>
|
||||||
|
|
||||||
|
PicHandle MakePict(GWorldPtr wp) ;
|
||||||
|
|
||||||
bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap,
|
bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap,
|
||||||
const wxPoint& pos,
|
const wxPoint& pos,
|
||||||
const wxSize& size, long style,
|
const wxSize& size, long style,
|
||||||
@@ -26,13 +30,7 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
|
|||||||
const wxString& name)
|
const wxString& name)
|
||||||
{
|
{
|
||||||
m_buttonBitmap = bitmap;
|
m_buttonBitmap = bitmap;
|
||||||
SetName(name);
|
|
||||||
SetValidator(validator);
|
|
||||||
parent->AddChild(this);
|
|
||||||
|
|
||||||
m_backgroundColour = parent->GetBackgroundColour() ;
|
|
||||||
m_foregroundColour = parent->GetForegroundColour() ;
|
|
||||||
m_windowStyle = style;
|
|
||||||
m_marginX = 0;
|
m_marginX = 0;
|
||||||
m_marginY = 0;
|
m_marginY = 0;
|
||||||
|
|
||||||
@@ -52,14 +50,60 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
|
|||||||
if ( height == -1 && bitmap.Ok())
|
if ( height == -1 && bitmap.Ok())
|
||||||
height = bitmap.GetHeight() + 2*m_marginY;
|
height = bitmap.GetHeight() + 2*m_marginY;
|
||||||
|
|
||||||
/* TODO: create bitmap button
|
m_macHorizontalBorder = 2 ; // additional pixels around the real control
|
||||||
*/
|
m_macVerticalBorder = 2 ;
|
||||||
|
Rect bounds ;
|
||||||
|
Str255 title ;
|
||||||
|
MacPreControlCreate( parent , id , "" , pos , wxSize( width , height ) ,style, validator , name , &bounds , title ) ;
|
||||||
|
|
||||||
return FALSE;
|
m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 ,
|
||||||
|
kControlBehaviorOffsetContents + kControlContentPictHandle , 0,
|
||||||
|
kControlBevelButtonNormalBevelProc , (long) this ) ;
|
||||||
|
wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ;
|
||||||
|
|
||||||
|
m_buttonBitmap = bitmap;
|
||||||
|
PicHandle icon = NULL ;
|
||||||
|
if ( m_buttonBitmap.Ok() )
|
||||||
|
{
|
||||||
|
wxBitmapRefData * bmap = (wxBitmapRefData*) ( m_buttonBitmap.GetRefData()) ;
|
||||||
|
if ( bmap->m_bitmapType == kMacBitmapTypePict )
|
||||||
|
icon = bmap->m_hPict ;
|
||||||
|
else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld )
|
||||||
|
{
|
||||||
|
icon = MakePict( bmap->m_hBitmap ) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ControlButtonContentInfo info ;
|
||||||
|
|
||||||
|
info.contentType = kControlContentPictHandle ;
|
||||||
|
info.u.picture = icon ;
|
||||||
|
|
||||||
|
UMASetControlData( m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
|
||||||
|
|
||||||
|
MacPostControlCreate() ;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap)
|
void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap)
|
||||||
{
|
{
|
||||||
m_buttonBitmap = bitmap;
|
m_buttonBitmap = bitmap;
|
||||||
|
PicHandle icon = NULL ;
|
||||||
|
if ( m_buttonBitmap.Ok() )
|
||||||
|
{
|
||||||
|
wxBitmapRefData * bmap = (wxBitmapRefData*) ( m_buttonBitmap.GetRefData()) ;
|
||||||
|
if ( bmap->m_bitmapType == kMacBitmapTypePict )
|
||||||
|
icon = bmap->m_hPict ;
|
||||||
|
else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld )
|
||||||
|
{
|
||||||
|
icon = MakePict( bmap->m_hBitmap ) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ControlButtonContentInfo info ;
|
||||||
|
|
||||||
|
info.contentType = kControlContentPictHandle ;
|
||||||
|
info.u.picture = icon ;
|
||||||
|
|
||||||
|
UMASetControlData( m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -504,6 +504,17 @@ void wxApp::CleanUp()
|
|||||||
|
|
||||||
int wxEntry( int argc, char *argv[] )
|
int wxEntry( int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
|
#ifdef __MWERKS__
|
||||||
|
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
|
||||||
|
// This seems to be necessary since there are 'rogue'
|
||||||
|
// objects present at this point (perhaps global objects?)
|
||||||
|
// Setting a checkpoint will ignore them as far as the
|
||||||
|
// memory checking facility is concerned.
|
||||||
|
// Of course you may argue that memory allocated in globals should be
|
||||||
|
// checked, but this is a reasonable compromise.
|
||||||
|
wxDebugContext::SetCheckpoint();
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
if (!wxApp::Initialize())
|
if (!wxApp::Initialize())
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!wxTheApp)
|
if (!wxTheApp)
|
||||||
@@ -1021,109 +1032,112 @@ void wxApp::MacHandleMouseUpEvent( EventRecord *ev )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
long wxMacTranslateKey(char key, char code)
|
long wxMacTranslateKey(unsigned char key, unsigned char code)
|
||||||
{
|
{
|
||||||
|
long retval = key ;
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
case 0x01 :
|
case 0x01 :
|
||||||
key = WXK_HOME;
|
retval = WXK_HOME;
|
||||||
break;
|
break;
|
||||||
case 0x03 :
|
case 0x03 :
|
||||||
key = WXK_RETURN;
|
retval = WXK_RETURN;
|
||||||
break;
|
break;
|
||||||
case 0x04 :
|
case 0x04 :
|
||||||
key = WXK_END;
|
retval = WXK_END;
|
||||||
break;
|
break;
|
||||||
case 0x05 :
|
case 0x05 :
|
||||||
key = WXK_HELP;
|
retval = WXK_HELP;
|
||||||
break;
|
break;
|
||||||
case 0x08 :
|
case 0x08 :
|
||||||
key = WXK_BACK;
|
retval = WXK_BACK;
|
||||||
break;
|
break;
|
||||||
case 0x09 :
|
case 0x09 :
|
||||||
key = WXK_TAB;
|
retval = WXK_TAB;
|
||||||
break;
|
break;
|
||||||
case 0x0b :
|
case 0x0b :
|
||||||
key = WXK_PAGEUP;
|
retval = WXK_PAGEUP;
|
||||||
break;
|
break;
|
||||||
case 0x0c :
|
case 0x0c :
|
||||||
key = WXK_PAGEDOWN;
|
retval = WXK_PAGEDOWN;
|
||||||
break;
|
break;
|
||||||
case 0x0d :
|
case 0x0d :
|
||||||
key = WXK_RETURN;
|
retval = WXK_RETURN;
|
||||||
break;
|
break;
|
||||||
case 0x10 :
|
case 0x10 :
|
||||||
{
|
{
|
||||||
switch( code )
|
switch( code )
|
||||||
{
|
{
|
||||||
case 0x7a :
|
case 0x7a :
|
||||||
key = WXK_F1 ;
|
retval = WXK_F1 ;
|
||||||
break;
|
break;
|
||||||
case 0x78 :
|
case 0x78 :
|
||||||
key = WXK_F2 ;
|
retval = WXK_F2 ;
|
||||||
break;
|
break;
|
||||||
case 0x63 :
|
case 0x63 :
|
||||||
key = WXK_F3 ;
|
retval = WXK_F3 ;
|
||||||
break;
|
break;
|
||||||
case 0x76 :
|
case 0x76 :
|
||||||
key = WXK_F4 ;
|
retval = WXK_F4 ;
|
||||||
break;
|
break;
|
||||||
case 0x60 :
|
case 0x60 :
|
||||||
key = WXK_F5 ;
|
retval = WXK_F5 ;
|
||||||
break;
|
break;
|
||||||
case 0x61 :
|
case 0x61 :
|
||||||
key = WXK_F6 ;
|
retval = WXK_F6 ;
|
||||||
break;
|
break;
|
||||||
case 0x62:
|
case 0x62:
|
||||||
key = WXK_F7 ;
|
retval = WXK_F7 ;
|
||||||
break;
|
break;
|
||||||
case 0x64 :
|
case 0x64 :
|
||||||
key = WXK_F8 ;
|
retval = WXK_F8 ;
|
||||||
break;
|
break;
|
||||||
case 0x65 :
|
case 0x65 :
|
||||||
key = WXK_F9 ;
|
retval = WXK_F9 ;
|
||||||
break;
|
break;
|
||||||
case 0x6D :
|
case 0x6D :
|
||||||
key = WXK_F10 ;
|
retval = WXK_F10 ;
|
||||||
break;
|
break;
|
||||||
case 0x67 :
|
case 0x67 :
|
||||||
key = WXK_F11 ;
|
retval = WXK_F11 ;
|
||||||
break;
|
break;
|
||||||
case 0x6F :
|
case 0x6F :
|
||||||
key = WXK_F12 ;
|
retval = WXK_F12 ;
|
||||||
break;
|
break;
|
||||||
case 0x69 :
|
case 0x69 :
|
||||||
key = WXK_F13 ;
|
retval = WXK_F13 ;
|
||||||
break;
|
break;
|
||||||
case 0x6B :
|
case 0x6B :
|
||||||
key = WXK_F14 ;
|
retval = WXK_F14 ;
|
||||||
break;
|
break;
|
||||||
case 0x71 :
|
case 0x71 :
|
||||||
key = WXK_F15 ;
|
retval = WXK_F15 ;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break ;
|
break ;
|
||||||
case 0x1b :
|
case 0x1b :
|
||||||
key = WXK_DELETE ;
|
retval = WXK_ESCAPE ;
|
||||||
break ;
|
break ;
|
||||||
case 0x1c :
|
case 0x1c :
|
||||||
key = WXK_LEFT ;
|
retval = WXK_LEFT ;
|
||||||
break ;
|
break ;
|
||||||
case 0x1d :
|
case 0x1d :
|
||||||
key = WXK_RIGHT ;
|
retval = WXK_RIGHT ;
|
||||||
break ;
|
break ;
|
||||||
case 0x1e :
|
case 0x1e :
|
||||||
key = WXK_UP ;
|
retval = WXK_UP ;
|
||||||
break ;
|
break ;
|
||||||
case 0x1f :
|
case 0x1f :
|
||||||
key = WXK_DOWN ;
|
retval = WXK_DOWN ;
|
||||||
break ;
|
break ;
|
||||||
|
case 0x7F :
|
||||||
|
retval = WXK_DELETE ;
|
||||||
default:
|
default:
|
||||||
break ;
|
break ;
|
||||||
} // end switch
|
} // end switch
|
||||||
|
|
||||||
return key;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxApp::MacHandleKeyDownEvent( EventRecord *ev )
|
void wxApp::MacHandleKeyDownEvent( EventRecord *ev )
|
||||||
@@ -1140,18 +1154,80 @@ void wxApp::MacHandleKeyDownEvent( EventRecord *ev )
|
|||||||
|
|
||||||
wxWindow* focus = wxWindow::FindFocus() ;
|
wxWindow* focus = wxWindow::FindFocus() ;
|
||||||
if ( focus )
|
if ( focus )
|
||||||
|
{
|
||||||
|
long keyval = wxMacTranslateKey(keychar, keycode) ;
|
||||||
|
|
||||||
|
wxKeyEvent event(wxEVT_KEY_DOWN);
|
||||||
|
event.m_shiftDown = ev->modifiers & shiftKey;
|
||||||
|
event.m_controlDown = ev->modifiers & controlKey;
|
||||||
|
event.m_altDown = ev->modifiers & optionKey;
|
||||||
|
event.m_metaDown = ev->modifiers & cmdKey;
|
||||||
|
event.m_keyCode = keyval;
|
||||||
|
event.m_x = ev->where.h;
|
||||||
|
event.m_y = ev->where.v;
|
||||||
|
event.m_timeStamp = ev->when;
|
||||||
|
event.SetEventObject(focus);
|
||||||
|
bool handled = focus->GetEventHandler()->ProcessEvent( event ) ;
|
||||||
|
if ( !handled )
|
||||||
|
{
|
||||||
|
#if wxUSE_ACCEL
|
||||||
|
if (!handled)
|
||||||
|
{
|
||||||
|
wxWindow *ancestor = focus;
|
||||||
|
/*
|
||||||
|
while (ancestor)
|
||||||
|
{
|
||||||
|
int command = ancestor->GetAcceleratorTable()->GetCommand( event );
|
||||||
|
if (command != -1)
|
||||||
|
{
|
||||||
|
wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command );
|
||||||
|
handled = ancestor->GetEventHandler()->ProcessEvent( command_event );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (ancestor->m_isFrame)
|
||||||
|
break;
|
||||||
|
ancestor = ancestor->GetParent();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
#endif // wxUSE_ACCEL
|
||||||
|
}
|
||||||
|
if (!handled)
|
||||||
{
|
{
|
||||||
wxKeyEvent event(wxEVT_CHAR);
|
wxKeyEvent event(wxEVT_CHAR);
|
||||||
event.m_shiftDown = ev->modifiers & shiftKey;
|
event.m_shiftDown = ev->modifiers & shiftKey;
|
||||||
event.m_controlDown = ev->modifiers & controlKey;
|
event.m_controlDown = ev->modifiers & controlKey;
|
||||||
event.m_altDown = ev->modifiers & optionKey;
|
event.m_altDown = ev->modifiers & optionKey;
|
||||||
event.m_metaDown = ev->modifiers & cmdKey;
|
event.m_metaDown = ev->modifiers & cmdKey;
|
||||||
event.m_keyCode = wxMacTranslateKey(keychar, keycode);
|
event.m_keyCode = keyval;
|
||||||
event.m_x = ev->where.h;
|
event.m_x = ev->where.h;
|
||||||
event.m_y = ev->where.v;
|
event.m_y = ev->where.v;
|
||||||
event.m_timeStamp = ev->when;
|
event.m_timeStamp = ev->when;
|
||||||
event.SetEventObject(focus);
|
event.SetEventObject(focus);
|
||||||
focus->GetEventHandler()->ProcessEvent( event ) ;
|
handled = focus->GetEventHandler()->ProcessEvent( event ) ;
|
||||||
|
}
|
||||||
|
if ( !handled &&
|
||||||
|
(keyval == WXK_TAB) &&
|
||||||
|
(!focus->HasFlag(wxTE_PROCESS_TAB)) &&
|
||||||
|
(focus->GetParent()) &&
|
||||||
|
(focus->GetParent()->HasFlag( wxTAB_TRAVERSAL)) )
|
||||||
|
{
|
||||||
|
wxNavigationKeyEvent new_event;
|
||||||
|
new_event.SetEventObject( focus );
|
||||||
|
new_event.SetDirection( !event.ShiftDown() );
|
||||||
|
/* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
|
||||||
|
new_event.SetWindowChange( event.ControlDown() );
|
||||||
|
new_event.SetCurrentFocus( focus );
|
||||||
|
handled = focus->GetEventHandler()->ProcessEvent( new_event );
|
||||||
|
}
|
||||||
|
/* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */
|
||||||
|
if ( (!handled) &&
|
||||||
|
(keyval == '.' && event.ControlDown() ) )
|
||||||
|
{
|
||||||
|
wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL);
|
||||||
|
new_event.SetEventObject( focus );
|
||||||
|
handled = focus->GetEventHandler()->ProcessEvent( new_event );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,6 +19,10 @@
|
|||||||
IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton, wxButton)
|
IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton, wxButton)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <wx/mac/uma.h>
|
||||||
|
|
||||||
|
PicHandle MakePict(GWorldPtr wp) ;
|
||||||
|
|
||||||
bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap,
|
bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap,
|
||||||
const wxPoint& pos,
|
const wxPoint& pos,
|
||||||
const wxSize& size, long style,
|
const wxSize& size, long style,
|
||||||
@@ -26,13 +30,7 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
|
|||||||
const wxString& name)
|
const wxString& name)
|
||||||
{
|
{
|
||||||
m_buttonBitmap = bitmap;
|
m_buttonBitmap = bitmap;
|
||||||
SetName(name);
|
|
||||||
SetValidator(validator);
|
|
||||||
parent->AddChild(this);
|
|
||||||
|
|
||||||
m_backgroundColour = parent->GetBackgroundColour() ;
|
|
||||||
m_foregroundColour = parent->GetForegroundColour() ;
|
|
||||||
m_windowStyle = style;
|
|
||||||
m_marginX = 0;
|
m_marginX = 0;
|
||||||
m_marginY = 0;
|
m_marginY = 0;
|
||||||
|
|
||||||
@@ -52,14 +50,60 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
|
|||||||
if ( height == -1 && bitmap.Ok())
|
if ( height == -1 && bitmap.Ok())
|
||||||
height = bitmap.GetHeight() + 2*m_marginY;
|
height = bitmap.GetHeight() + 2*m_marginY;
|
||||||
|
|
||||||
/* TODO: create bitmap button
|
m_macHorizontalBorder = 2 ; // additional pixels around the real control
|
||||||
*/
|
m_macVerticalBorder = 2 ;
|
||||||
|
Rect bounds ;
|
||||||
|
Str255 title ;
|
||||||
|
MacPreControlCreate( parent , id , "" , pos , wxSize( width , height ) ,style, validator , name , &bounds , title ) ;
|
||||||
|
|
||||||
return FALSE;
|
m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 ,
|
||||||
|
kControlBehaviorOffsetContents + kControlContentPictHandle , 0,
|
||||||
|
kControlBevelButtonNormalBevelProc , (long) this ) ;
|
||||||
|
wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ;
|
||||||
|
|
||||||
|
m_buttonBitmap = bitmap;
|
||||||
|
PicHandle icon = NULL ;
|
||||||
|
if ( m_buttonBitmap.Ok() )
|
||||||
|
{
|
||||||
|
wxBitmapRefData * bmap = (wxBitmapRefData*) ( m_buttonBitmap.GetRefData()) ;
|
||||||
|
if ( bmap->m_bitmapType == kMacBitmapTypePict )
|
||||||
|
icon = bmap->m_hPict ;
|
||||||
|
else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld )
|
||||||
|
{
|
||||||
|
icon = MakePict( bmap->m_hBitmap ) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ControlButtonContentInfo info ;
|
||||||
|
|
||||||
|
info.contentType = kControlContentPictHandle ;
|
||||||
|
info.u.picture = icon ;
|
||||||
|
|
||||||
|
UMASetControlData( m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
|
||||||
|
|
||||||
|
MacPostControlCreate() ;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap)
|
void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap)
|
||||||
{
|
{
|
||||||
m_buttonBitmap = bitmap;
|
m_buttonBitmap = bitmap;
|
||||||
|
PicHandle icon = NULL ;
|
||||||
|
if ( m_buttonBitmap.Ok() )
|
||||||
|
{
|
||||||
|
wxBitmapRefData * bmap = (wxBitmapRefData*) ( m_buttonBitmap.GetRefData()) ;
|
||||||
|
if ( bmap->m_bitmapType == kMacBitmapTypePict )
|
||||||
|
icon = bmap->m_hPict ;
|
||||||
|
else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld )
|
||||||
|
{
|
||||||
|
icon = MakePict( bmap->m_hBitmap ) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ControlButtonContentInfo info ;
|
||||||
|
|
||||||
|
info.contentType = kControlContentPictHandle ;
|
||||||
|
info.u.picture = icon ;
|
||||||
|
|
||||||
|
UMASetControlData( m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -89,9 +89,8 @@ void wxChoice::MacHandleControlClick( ControlHandle control , SInt16 controlpart
|
|||||||
wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, m_windowId );
|
wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, m_windowId );
|
||||||
event.SetInt(GetSelection());
|
event.SetInt(GetSelection());
|
||||||
event.SetEventObject(this);
|
event.SetEventObject(this);
|
||||||
event.SetString(copystring(GetStringSelection()));
|
event.SetString(GetStringSelection());
|
||||||
ProcessCommand(event);
|
ProcessCommand(event);
|
||||||
delete[] event.GetString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -106,14 +106,15 @@ wxPNGReader::Create(int width, int height, int depth, int colortype)
|
|||||||
{
|
{
|
||||||
Width = width; Height = height; Depth = depth;
|
Width = width; Height = height; Depth = depth;
|
||||||
ColorType = (colortype>=0) ? colortype: ((Depth>8) ? COLORTYPE_COLOR: 0);
|
ColorType = (colortype>=0) ? colortype: ((Depth>8) ? COLORTYPE_COLOR: 0);
|
||||||
|
delete Palette;
|
||||||
|
delete[] RawImage ;
|
||||||
|
RawImage = 0;
|
||||||
|
Palette = 0;
|
||||||
|
|
||||||
if (lpbi)
|
if (lpbi)
|
||||||
{
|
{
|
||||||
wxMacDestroyGWorld( lpbi ) ;
|
wxMacDestroyGWorld( lpbi ) ;
|
||||||
// delete Palette;
|
|
||||||
}
|
}
|
||||||
RawImage = 0;
|
|
||||||
Palette = 0;
|
|
||||||
if (lpbi = wxMacCreateGWorld( Width , Height , Depth) )
|
if (lpbi = wxMacCreateGWorld( Width , Height , Depth) )
|
||||||
{
|
{
|
||||||
EfeWidth = (long)(((long)Width*Depth + 31) / 32) * 4;
|
EfeWidth = (long)(((long)Width*Depth + 31) / 32) * 4;
|
||||||
@@ -197,10 +198,11 @@ bool wxPNGReader::SetRGB(int x, int y, byte r, byte g, byte b)
|
|||||||
|
|
||||||
bool wxPNGReader::SetPalette(wxPalette* colourmap)
|
bool wxPNGReader::SetPalette(wxPalette* colourmap)
|
||||||
{
|
{
|
||||||
|
delete Palette ;
|
||||||
if (!colourmap)
|
if (!colourmap)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR);
|
ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR);
|
||||||
Palette = colourmap;
|
Palette = new wxPalette( *colourmap );
|
||||||
return true ;
|
return true ;
|
||||||
// return (DibSetUsage(lpbi, (HPALETTE) Palette->GetHPALETTE(), WXIMA_COLORS ) != 0);
|
// return (DibSetUsage(lpbi, (HPALETTE) Palette->GetHPALETTE(), WXIMA_COLORS ) != 0);
|
||||||
}
|
}
|
||||||
@@ -208,6 +210,7 @@ bool wxPNGReader::SetPalette(wxPalette* colourmap)
|
|||||||
bool
|
bool
|
||||||
wxPNGReader::SetPalette(int n, byte *r, byte *g, byte *b)
|
wxPNGReader::SetPalette(int n, byte *r, byte *g, byte *b)
|
||||||
{
|
{
|
||||||
|
delete Palette ;
|
||||||
Palette = new wxPalette();
|
Palette = new wxPalette();
|
||||||
if (!Palette)
|
if (!Palette)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -223,6 +226,7 @@ wxPNGReader::SetPalette(int n, byte *r, byte *g, byte *b)
|
|||||||
bool
|
bool
|
||||||
wxPNGReader::SetPalette(int n, rgb_color_struct *rgb_struct)
|
wxPNGReader::SetPalette(int n, rgb_color_struct *rgb_struct)
|
||||||
{
|
{
|
||||||
|
delete Palette ;
|
||||||
Palette = new wxPalette();
|
Palette = new wxPalette();
|
||||||
if (!Palette)
|
if (!Palette)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -249,6 +253,10 @@ wxPNGReader::SetPalette(int n, rgb_color_struct *rgb_struct)
|
|||||||
|
|
||||||
void wxPNGReader::NullData()
|
void wxPNGReader::NullData()
|
||||||
{
|
{
|
||||||
|
if (lpbi) {
|
||||||
|
wxMacDestroyGWorld( lpbi ) ;
|
||||||
|
}
|
||||||
|
delete Palette;
|
||||||
lpbi = NULL;
|
lpbi = NULL;
|
||||||
Palette = NULL;
|
Palette = NULL;
|
||||||
}
|
}
|
||||||
@@ -516,30 +524,47 @@ bool wxPNGReader::ReadFile(char * ImageFileName)
|
|||||||
{
|
{
|
||||||
if ( pixel_depth == 8 )
|
if ( pixel_depth == 8 )
|
||||||
{
|
{
|
||||||
|
for ( int i = 0 ; i < info_ptr->width ; ++i )
|
||||||
|
{
|
||||||
|
png_color_struct* color ;
|
||||||
|
RGBColor col ;
|
||||||
|
|
||||||
|
int index = row_pointers[i] ;
|
||||||
|
color = &info_ptr->palette[index] ;
|
||||||
|
col.red = (((int)color->red) << 8) | ((int)color->red) ;
|
||||||
|
col.green = (((int)color->green) << 8) | ((int)color->green) ;
|
||||||
|
col.blue = (((int)color->blue) << 8) | ((int)color->blue) ;
|
||||||
|
SetCPixel( i, y, &col);
|
||||||
|
}
|
||||||
|
/*
|
||||||
png_color_struct* color ;
|
png_color_struct* color ;
|
||||||
RGBColor col ;
|
RGBColor col ;
|
||||||
unsigned char* p = &row_pointers[0] ;
|
unsigned char* p = &row_pointers[0] ;
|
||||||
|
PenNormal() ;
|
||||||
MoveTo( 0 , y ) ;
|
MoveTo( 0 , y ) ;
|
||||||
unsigned char lastcol = *p ;
|
int index = *p ;
|
||||||
color = &info_ptr->palette[lastcol] ;
|
color = &info_ptr->palette[index] ;
|
||||||
col.red = (color->red << 8) | color->red ;
|
col.red = (color->red << 8) | color->red ;
|
||||||
col.green = (color->green << 8) | color->green ;
|
col.green = (color->green << 8) | color->green ;
|
||||||
col.blue = (color->blue << 8) | color->blue ;
|
col.blue = (color->blue << 8) | color->blue ;
|
||||||
RGBForeColor( &col ) ;
|
RGBForeColor( &col ) ;
|
||||||
|
col.red = col.green = col.blue = 0xFFFF ;
|
||||||
|
RGBBackColor( &col ) ;
|
||||||
for ( int i = 0 ; i < info_ptr->width ; ++i , ++p)
|
for ( int i = 0 ; i < info_ptr->width ; ++i , ++p)
|
||||||
{
|
{
|
||||||
if ( *p != lastcol )
|
if ( *p != index )
|
||||||
{
|
{
|
||||||
LineTo( i , y ) ;
|
LineTo( i , y ) ;
|
||||||
lastcol = *p ;
|
index = *p ;
|
||||||
color = &info_ptr->palette[lastcol] ;
|
color = &info_ptr->palette[index] ;
|
||||||
col.red = (color->red << 8) | color->red ;
|
col.red = (((int)color->red) << 8) | ((int)color->red) ;
|
||||||
col.green = (color->green << 8) | color->green ;
|
col.green = (((int)color->green) << 8) | ((int)color->green) ;
|
||||||
col.blue = (color->blue << 8) | color->blue ;
|
col.blue = (((int)color->blue) << 8) | ((int)color->blue) ;
|
||||||
RGBForeColor( &col ) ;
|
RGBForeColor( &col ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LineTo( info_ptr->width - 1 , y ) ;
|
LineTo( info_ptr->width , y ) ;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -553,9 +578,9 @@ bool wxPNGReader::ReadFile(char * ImageFileName)
|
|||||||
|
|
||||||
int index = ( row_pointers[byte] >> offset ) & ( 0xFF >> ( 8 - pixel_depth ) );
|
int index = ( row_pointers[byte] >> offset ) & ( 0xFF >> ( 8 - pixel_depth ) );
|
||||||
color = &info_ptr->palette[index] ;
|
color = &info_ptr->palette[index] ;
|
||||||
col.red = (color->red << 8) | color->red ;
|
col.red = (((int)color->red) << 8) | ((int)color->red) ;
|
||||||
col.green = (color->green << 8) | color->green ;
|
col.green = (((int)color->green) << 8) | ((int)color->green) ;
|
||||||
col.blue = (color->blue << 8) | color->blue ;
|
col.blue = (((int)color->blue) << 8) | ((int)color->blue) ;
|
||||||
SetCPixel( i, y, &col);
|
SetCPixel( i, y, &col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -567,9 +592,9 @@ bool wxPNGReader::ReadFile(char * ImageFileName)
|
|||||||
png_color_struct* color ;
|
png_color_struct* color ;
|
||||||
RGBColor col ;
|
RGBColor col ;
|
||||||
color =(png_color_struct*) (&row_pointers[i*3]) ;
|
color =(png_color_struct*) (&row_pointers[i*3]) ;
|
||||||
col.red = (color->red << 8) | color->red ;
|
col.red = (((int)color->red) << 8) | ((int)color->red) ;
|
||||||
col.green = (color->green << 8) | color->green ;
|
col.green = (((int)color->green) << 8) | ((int)color->green) ;
|
||||||
col.blue = (color->blue << 8) | color->blue ;
|
col.blue = (((int)color->blue) << 8) | ((int)color->blue) ;
|
||||||
SetCPixel( i, y, &col);
|
SetCPixel( i, y, &col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -34,9 +34,12 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
|
|||||||
long style,
|
long style,
|
||||||
const wxString& name)
|
const wxString& name)
|
||||||
{
|
{
|
||||||
m_messageBitmap = bitmap;
|
|
||||||
SetName(name);
|
SetName(name);
|
||||||
if (parent) parent->AddChild(this);
|
|
||||||
|
m_backgroundColour = parent->GetBackgroundColour() ;
|
||||||
|
m_foregroundColour = parent->GetForegroundColour() ;
|
||||||
|
|
||||||
|
m_messageBitmap = bitmap;
|
||||||
|
|
||||||
if ( id == -1 )
|
if ( id == -1 )
|
||||||
m_windowId = (int)NewControlId();
|
m_windowId = (int)NewControlId();
|
||||||
@@ -47,6 +50,8 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
|
|||||||
|
|
||||||
bool ret = wxControl::Create( parent, id, pos, size, style , name );
|
bool ret = wxControl::Create( parent, id, pos, size, style , name );
|
||||||
|
|
||||||
|
SetSizeOrDefault() ;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,8 +63,7 @@ void wxStaticBitmap::SetSize(int x, int y, int width, int height, int sizeFlags)
|
|||||||
void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
|
void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
|
||||||
{
|
{
|
||||||
m_messageBitmap = bitmap;
|
m_messageBitmap = bitmap;
|
||||||
|
SetSizeOrDefault();
|
||||||
Refresh() ;
|
|
||||||
}
|
}
|
||||||
void wxStaticBitmap::OnPaint( wxPaintEvent &event )
|
void wxStaticBitmap::OnPaint( wxPaintEvent &event )
|
||||||
{
|
{
|
||||||
@@ -69,3 +73,11 @@ void wxStaticBitmap::OnPaint( wxPaintEvent &event )
|
|||||||
dc.DrawBitmap( m_messageBitmap , 0 , 0 ) ;
|
dc.DrawBitmap( m_messageBitmap , 0 , 0 ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxSize wxStaticBitmap::DoGetBestSize() const
|
||||||
|
{
|
||||||
|
if ( m_messageBitmap.Ok() )
|
||||||
|
return wxSize(m_messageBitmap.GetWidth(), m_messageBitmap.GetHeight());
|
||||||
|
else
|
||||||
|
return wxSize(16, 16); // completely arbitrary
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -40,8 +40,7 @@ wxToolBar::wxToolBar()
|
|||||||
bool wxToolBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
|
bool wxToolBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
|
||||||
long style, const wxString& name)
|
long style, const wxString& name)
|
||||||
{
|
{
|
||||||
m_maxWidth = -1;
|
m_maxWidth = m_maxHeight = 0;
|
||||||
m_maxHeight = -1;
|
|
||||||
|
|
||||||
m_defaultWidth = 24;
|
m_defaultWidth = 24;
|
||||||
m_defaultHeight = 22;
|
m_defaultHeight = 22;
|
||||||
@@ -152,7 +151,9 @@ bool wxToolBar::CreateTools()
|
|||||||
wxNode *node = m_tools.First();
|
wxNode *node = m_tools.First();
|
||||||
int noButtons = 0;
|
int noButtons = 0;
|
||||||
int x = 0 ;
|
int x = 0 ;
|
||||||
|
wxSize toolSize = GetToolSize() ;
|
||||||
|
int tw, th;
|
||||||
|
GetSize(& tw, & th);
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
wxToolBarTool *tool = (wxToolBarTool *)node->Data();
|
wxToolBarTool *tool = (wxToolBarTool *)node->Data();
|
||||||
@@ -161,8 +162,8 @@ bool wxToolBar::CreateTools()
|
|||||||
if( tool->m_toolStyle != wxTOOL_STYLE_SEPARATOR )
|
if( tool->m_toolStyle != wxTOOL_STYLE_SEPARATOR )
|
||||||
{
|
{
|
||||||
Rect toolrect = { toolbarrect.top + kwxMacToolBarTopMargin , toolbarrect.left + x + kwxMacToolBarLeftMargin , 0 , 0 } ;
|
Rect toolrect = { toolbarrect.top + kwxMacToolBarTopMargin , toolbarrect.left + x + kwxMacToolBarLeftMargin , 0 , 0 } ;
|
||||||
toolrect.right = toolrect.left + m_defaultWidth ;
|
toolrect.right = toolrect.left + toolSize.x ;
|
||||||
toolrect.bottom = toolrect.top + m_defaultHeight ;
|
toolrect.bottom = toolrect.top + toolSize.y ;
|
||||||
|
|
||||||
PicHandle icon = NULL ;
|
PicHandle icon = NULL ;
|
||||||
if ( bmap )
|
if ( bmap )
|
||||||
@@ -197,17 +198,37 @@ bool wxToolBar::CreateTools()
|
|||||||
UMASetControlFontStyle( m_macToolHandle , &controlstyle ) ;
|
UMASetControlFontStyle( m_macToolHandle , &controlstyle ) ;
|
||||||
UMAEmbedControl( m_macToolHandle , m_macControl ) ;
|
UMAEmbedControl( m_macToolHandle , m_macControl ) ;
|
||||||
|
|
||||||
x += (int)m_defaultWidth;
|
x += (int)toolSize.x;
|
||||||
noButtons ++;
|
noButtons ++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_macToolHandles.Add( NULL ) ;
|
m_macToolHandles.Add( NULL ) ;
|
||||||
x += (int)m_defaultWidth / 4;
|
x += (int)toolSize.x / 4;
|
||||||
}
|
}
|
||||||
|
if ( toolbarrect.left + x + kwxMacToolBarLeftMargin > m_maxWidth)
|
||||||
|
m_maxWidth = toolbarrect.left + x + kwxMacToolBarLeftMargin;
|
||||||
|
if (toolbarrect.top + kwxMacToolBarTopMargin + toolSize.y > m_maxHeight)
|
||||||
|
m_maxHeight = toolbarrect.top + kwxMacToolBarTopMargin ;
|
||||||
|
|
||||||
node = node->Next();
|
node = node->Next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( GetWindowStyleFlag() & wxTB_HORIZONTAL )
|
||||||
|
{
|
||||||
|
m_maxWidth = tw ; // +=toolSize.x;
|
||||||
|
m_maxHeight += toolSize.y;
|
||||||
|
m_maxHeight += m_yMargin;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_maxHeight = th ;// += toolSize.y;
|
||||||
|
m_maxWidth += toolSize.x;
|
||||||
|
m_maxWidth += m_xMargin;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetSize(m_maxWidth, m_maxHeight);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,8 +239,7 @@ void wxToolBar::SetToolBitmapSize(const wxSize& size)
|
|||||||
|
|
||||||
wxSize wxToolBar::GetMaxSize() const
|
wxSize wxToolBar::GetMaxSize() const
|
||||||
{
|
{
|
||||||
// TODO
|
return wxSize(m_maxWidth, m_maxHeight);
|
||||||
return wxSize(0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The button size is bigger than the bitmap size
|
// The button size is bigger than the bitmap size
|
||||||
@@ -291,7 +311,13 @@ wxToolBarTool *wxToolBar::AddTool(int index, const wxBitmap& bitmap, const wxBit
|
|||||||
else
|
else
|
||||||
tool->m_y = m_yMargin;
|
tool->m_y = m_yMargin;
|
||||||
|
|
||||||
tool->SetSize(m_defaultWidth, m_defaultHeight);
|
tool->SetSize(GetToolSize().x, GetToolSize().y);
|
||||||
|
|
||||||
|
if ((tool->m_x + bitmap.GetWidth() + m_xMargin) > m_maxWidth)
|
||||||
|
m_maxWidth = (tool->m_x + tool->GetWidth() + m_xMargin);
|
||||||
|
|
||||||
|
if ((tool->m_y + bitmap.GetHeight() + m_yMargin) > m_maxHeight)
|
||||||
|
m_maxHeight = (tool->m_y + tool->GetHeight() + m_yMargin);
|
||||||
|
|
||||||
m_tools.Append((long)index, tool);
|
m_tools.Append((long)index, tool);
|
||||||
return tool;
|
return tool;
|
||||||
|
@@ -35,6 +35,10 @@
|
|||||||
#include "wx/menuitem.h"
|
#include "wx/menuitem.h"
|
||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
|
|
||||||
|
#if wxUSE_CARET
|
||||||
|
#include "wx/caret.h"
|
||||||
|
#endif // wxUSE_CARET
|
||||||
|
|
||||||
#define wxWINDOW_HSCROLL 5998
|
#define wxWINDOW_HSCROLL 5998
|
||||||
#define wxWINDOW_VSCROLL 5997
|
#define wxWINDOW_VSCROLL 5997
|
||||||
#define MAC_SCROLLBAR_SIZE 16
|
#define MAC_SCROLLBAR_SIZE 16
|
||||||
@@ -198,6 +202,13 @@ void wxWindow::SetFocus()
|
|||||||
{
|
{
|
||||||
if (gFocusWindow )
|
if (gFocusWindow )
|
||||||
{
|
{
|
||||||
|
#if wxUSE_CARET
|
||||||
|
// Deal with caret
|
||||||
|
if ( gFocusWindow->m_caret )
|
||||||
|
{
|
||||||
|
gFocusWindow->m_caret->OnKillFocus();
|
||||||
|
}
|
||||||
|
#endif // wxUSE_CARET
|
||||||
wxControl* control = wxDynamicCast( gFocusWindow , wxControl ) ;
|
wxControl* control = wxDynamicCast( gFocusWindow , wxControl ) ;
|
||||||
if ( control && control->GetMacControl() )
|
if ( control && control->GetMacControl() )
|
||||||
{
|
{
|
||||||
@@ -209,6 +220,19 @@ void wxWindow::SetFocus()
|
|||||||
}
|
}
|
||||||
gFocusWindow = this ;
|
gFocusWindow = this ;
|
||||||
{
|
{
|
||||||
|
#if wxUSE_CARET
|
||||||
|
// Deal with caret
|
||||||
|
if ( m_caret )
|
||||||
|
{
|
||||||
|
m_caret->OnSetFocus();
|
||||||
|
}
|
||||||
|
#endif // wxUSE_CARET
|
||||||
|
// panel wants to track the window which was the last to have focus in it
|
||||||
|
wxPanel *panel = wxDynamicCast(GetParent(), wxPanel);
|
||||||
|
if ( panel )
|
||||||
|
{
|
||||||
|
panel->SetLastFocus(this);
|
||||||
|
}
|
||||||
wxControl* control = wxDynamicCast( gFocusWindow , wxControl ) ;
|
wxControl* control = wxDynamicCast( gFocusWindow , wxControl ) ;
|
||||||
if ( control && control->GetMacControl() )
|
if ( control && control->GetMacControl() )
|
||||||
{
|
{
|
||||||
@@ -1348,6 +1372,9 @@ void wxWindow::MacRedraw( RgnHandle updatergn , long time)
|
|||||||
if ( focus.Ok() )
|
if ( focus.Ok() )
|
||||||
{
|
{
|
||||||
WindowRef window = GetMacRootWindow() ;
|
WindowRef window = GetMacRootWindow() ;
|
||||||
|
bool eraseBackground = false ;
|
||||||
|
if ( m_macWindowData )
|
||||||
|
eraseBackground = true ;
|
||||||
if ( m_backgroundColour == wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE) )
|
if ( m_backgroundColour == wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE) )
|
||||||
{
|
{
|
||||||
UMASetThemeWindowBackground( window , kThemeBrushDocumentWindowBackground , false ) ;
|
UMASetThemeWindowBackground( window , kThemeBrushDocumentWindowBackground , false ) ;
|
||||||
@@ -1380,7 +1407,7 @@ void wxWindow::MacRedraw( RgnHandle updatergn , long time)
|
|||||||
// if we have the normal colours in the hierarchy but another control etc. -> use it's background
|
// if we have the normal colours in the hierarchy but another control etc. -> use it's background
|
||||||
if ( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) ))
|
if ( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) ))
|
||||||
{
|
{
|
||||||
ApplyThemeBackground (kThemeBackgroundTabPane, &(**updatergn).rgnBBox , kThemeStateActive,8,true);
|
ApplyThemeBackground(kThemeBackgroundTabPane, &(**updatergn).rgnBBox , kThemeStateActive,8,true);
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1401,10 +1428,15 @@ void wxWindow::MacRedraw( RgnHandle updatergn , long time)
|
|||||||
{
|
{
|
||||||
RGBBackColor( &m_backgroundColour.GetPixel()) ;
|
RGBBackColor( &m_backgroundColour.GetPixel()) ;
|
||||||
}
|
}
|
||||||
|
if ( GetParent() && m_backgroundColour != GetParent()->GetBackgroundColour() )
|
||||||
|
eraseBackground = true ;
|
||||||
SetClip( updatergn ) ;
|
SetClip( updatergn ) ;
|
||||||
|
if ( eraseBackground )
|
||||||
|
{
|
||||||
EraseRgn( updatergn ) ;
|
EraseRgn( updatergn ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
m_updateRegion = updatergn ;
|
m_updateRegion = updatergn ;
|
||||||
@@ -1553,7 +1585,10 @@ void wxWindow::MacKeyDown( EventRecord *ev )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool wxWindow::AcceptsFocus() const
|
||||||
|
{
|
||||||
|
return MacCanFocus() && wxWindowBase::AcceptsFocus();
|
||||||
|
}
|
||||||
|
|
||||||
ControlHandle wxWindow::MacGetContainerForEmbedding()
|
ControlHandle wxWindow::MacGetContainerForEmbedding()
|
||||||
{
|
{
|
||||||
|
@@ -89,9 +89,8 @@ void wxChoice::MacHandleControlClick( ControlHandle control , SInt16 controlpart
|
|||||||
wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, m_windowId );
|
wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, m_windowId );
|
||||||
event.SetInt(GetSelection());
|
event.SetInt(GetSelection());
|
||||||
event.SetEventObject(this);
|
event.SetEventObject(this);
|
||||||
event.SetString(copystring(GetStringSelection()));
|
event.SetString(GetStringSelection());
|
||||||
ProcessCommand(event);
|
ProcessCommand(event);
|
||||||
delete[] event.GetString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
91
src/mac/ldef/extldef.c
Normal file
91
src/mac/ldef/extldef.c
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
#include "extldef.h"
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
|
||||||
|
function prototypes
|
||||||
|
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
void DrawMsg(Boolean fSelect, Rect *r, Cell cell, ListHandle lh);
|
||||||
|
void HiliteMsg(Boolean fSelect, Rect *r);
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
|
||||||
|
main
|
||||||
|
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
pascal void main(short message, Boolean fSelect, Rect *r, Cell cell,
|
||||||
|
short dataOffset, short dataLen, ListHandle lh)
|
||||||
|
{
|
||||||
|
|
||||||
|
switch(message) {
|
||||||
|
case lInitMsg:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case lDrawMsg:
|
||||||
|
DrawMsg(fSelect, r, cell, lh);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case lHiliteMsg:
|
||||||
|
HiliteMsg(fSelect, r);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case lCloseMsg:
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
|
||||||
|
DrawMsg
|
||||||
|
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
void DrawMsg(Boolean fSelect, Rect *r, Cell cell, ListHandle lh)
|
||||||
|
{
|
||||||
|
ExtLDEFInfo* info = (ExtLDEFInfo*) (**lh).refCon ;
|
||||||
|
GrafPtr savePort;
|
||||||
|
|
||||||
|
// set up the port
|
||||||
|
GetPort(&savePort);
|
||||||
|
SetPort((**lh).port);
|
||||||
|
PenNormal();
|
||||||
|
ForeColor( blackColor ) ;
|
||||||
|
BackColor( whiteColor ) ;
|
||||||
|
|
||||||
|
EraseRect(r);
|
||||||
|
if ( info )
|
||||||
|
{
|
||||||
|
if ( info->drawProc)
|
||||||
|
{
|
||||||
|
CallExtLDEFDrawProc(info->drawProc, r, cell, lh, info->refCon );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// hilite if selected
|
||||||
|
if (fSelect)
|
||||||
|
HiliteMsg(fSelect, r);
|
||||||
|
|
||||||
|
SetPort(savePort);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
|
||||||
|
HiliteMsg
|
||||||
|
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
void HiliteMsg(Boolean fSelect, Rect *r)
|
||||||
|
{
|
||||||
|
unsigned char hMode;
|
||||||
|
|
||||||
|
hMode = LMGetHiliteMode();
|
||||||
|
BitClr((Ptr)(&hMode),(long)pHiliteBit);
|
||||||
|
LMSetHiliteMode(hMode);
|
||||||
|
InvertRect(r);
|
||||||
|
}
|
59
src/mac/ldef/extldef.h
Normal file
59
src/mac/ldef/extldef.h
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Lists.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#define kExtLDEFID 128 // resource id of our LDEF resource
|
||||||
|
|
||||||
|
typedef void (*ExtLDEFDrawProcType)(Rect *r, Cell cell, ListHandle lh, long refcon);
|
||||||
|
|
||||||
|
enum {
|
||||||
|
uppExtLDEFDrawProcInfo = kCStackBased
|
||||||
|
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(Rect *)))
|
||||||
|
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Cell)))
|
||||||
|
| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(ListHandle)))
|
||||||
|
| STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
|
||||||
|
};
|
||||||
|
|
||||||
|
#if USESROUTINEDESCRIPTORS
|
||||||
|
typedef UniversalProcPtr ExtLDEFDrawProcUPP;
|
||||||
|
|
||||||
|
#define CallExtLDEFDrawProc(userRoutine, r, cell, lh , refcon ) \
|
||||||
|
CallUniversalProc((UniversalProcPtr)(userRoutine), uppExtLDEFDrawProcInfo, r, cell, lh , refcon )
|
||||||
|
#define NewExtLDEFDrawProc(userRoutine) \
|
||||||
|
(ExtLDEFDrawProcUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppExtLDEFDrawProcInfo, GetCurrentISA())
|
||||||
|
|
||||||
|
#else
|
||||||
|
typedef ExtLDEFDrawProcType ExtLDEFDrawProcUPP;
|
||||||
|
|
||||||
|
#define CallExtLDEFDrawProc(userRoutine, r, cell, lh , refcon) \
|
||||||
|
(*(userRoutine))(r, cell, lh, refcon)
|
||||||
|
#define NewExtLDEFDrawProc(userRoutine) \
|
||||||
|
(ExtLDEFDrawProcUPP)(userRoutine)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
long refCon ;
|
||||||
|
ExtLDEFDrawProcUPP drawProc ;
|
||||||
|
} ExtLDEFInfo ;
|
||||||
|
|
||||||
|
static void NewExtLDEFInfo( ListHandle lh , ExtLDEFDrawProcType drawproc , long refcon ) ;
|
||||||
|
static void NewExtLDEFInfo( ListHandle lh , ExtLDEFDrawProcType drawproc , long refcon )
|
||||||
|
{
|
||||||
|
ExtLDEFInfo* info = (ExtLDEFInfo* ) malloc( sizeof( ExtLDEFInfo ) ) ;
|
||||||
|
info->drawProc = NewExtLDEFDrawProc( drawproc ) ;
|
||||||
|
info->refCon = refcon ;
|
||||||
|
(**lh).refCon = (long) info ;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void DisposeExtLDEFInfo( ListHandle lh) ;
|
||||||
|
static void DisposeExtLDEFInfo( ListHandle lh)
|
||||||
|
{
|
||||||
|
ExtLDEFInfo* info = (ExtLDEFInfo* ) (**lh).refCon ;
|
||||||
|
if ( info )
|
||||||
|
{
|
||||||
|
DisposeRoutineDescriptor( (RoutineDescriptor*) info->drawProc ) ;
|
||||||
|
free( (void*) (**lh).refCon ) ;
|
||||||
|
}
|
||||||
|
}
|
BIN
src/mac/ldef/extldef.mcp
Normal file
BIN
src/mac/ldef/extldef.mcp
Normal file
Binary file not shown.
@@ -106,14 +106,15 @@ wxPNGReader::Create(int width, int height, int depth, int colortype)
|
|||||||
{
|
{
|
||||||
Width = width; Height = height; Depth = depth;
|
Width = width; Height = height; Depth = depth;
|
||||||
ColorType = (colortype>=0) ? colortype: ((Depth>8) ? COLORTYPE_COLOR: 0);
|
ColorType = (colortype>=0) ? colortype: ((Depth>8) ? COLORTYPE_COLOR: 0);
|
||||||
|
delete Palette;
|
||||||
|
delete[] RawImage ;
|
||||||
|
RawImage = 0;
|
||||||
|
Palette = 0;
|
||||||
|
|
||||||
if (lpbi)
|
if (lpbi)
|
||||||
{
|
{
|
||||||
wxMacDestroyGWorld( lpbi ) ;
|
wxMacDestroyGWorld( lpbi ) ;
|
||||||
// delete Palette;
|
|
||||||
}
|
}
|
||||||
RawImage = 0;
|
|
||||||
Palette = 0;
|
|
||||||
if (lpbi = wxMacCreateGWorld( Width , Height , Depth) )
|
if (lpbi = wxMacCreateGWorld( Width , Height , Depth) )
|
||||||
{
|
{
|
||||||
EfeWidth = (long)(((long)Width*Depth + 31) / 32) * 4;
|
EfeWidth = (long)(((long)Width*Depth + 31) / 32) * 4;
|
||||||
@@ -197,10 +198,11 @@ bool wxPNGReader::SetRGB(int x, int y, byte r, byte g, byte b)
|
|||||||
|
|
||||||
bool wxPNGReader::SetPalette(wxPalette* colourmap)
|
bool wxPNGReader::SetPalette(wxPalette* colourmap)
|
||||||
{
|
{
|
||||||
|
delete Palette ;
|
||||||
if (!colourmap)
|
if (!colourmap)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR);
|
ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR);
|
||||||
Palette = colourmap;
|
Palette = new wxPalette( *colourmap );
|
||||||
return true ;
|
return true ;
|
||||||
// return (DibSetUsage(lpbi, (HPALETTE) Palette->GetHPALETTE(), WXIMA_COLORS ) != 0);
|
// return (DibSetUsage(lpbi, (HPALETTE) Palette->GetHPALETTE(), WXIMA_COLORS ) != 0);
|
||||||
}
|
}
|
||||||
@@ -208,6 +210,7 @@ bool wxPNGReader::SetPalette(wxPalette* colourmap)
|
|||||||
bool
|
bool
|
||||||
wxPNGReader::SetPalette(int n, byte *r, byte *g, byte *b)
|
wxPNGReader::SetPalette(int n, byte *r, byte *g, byte *b)
|
||||||
{
|
{
|
||||||
|
delete Palette ;
|
||||||
Palette = new wxPalette();
|
Palette = new wxPalette();
|
||||||
if (!Palette)
|
if (!Palette)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -223,6 +226,7 @@ wxPNGReader::SetPalette(int n, byte *r, byte *g, byte *b)
|
|||||||
bool
|
bool
|
||||||
wxPNGReader::SetPalette(int n, rgb_color_struct *rgb_struct)
|
wxPNGReader::SetPalette(int n, rgb_color_struct *rgb_struct)
|
||||||
{
|
{
|
||||||
|
delete Palette ;
|
||||||
Palette = new wxPalette();
|
Palette = new wxPalette();
|
||||||
if (!Palette)
|
if (!Palette)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -249,6 +253,10 @@ wxPNGReader::SetPalette(int n, rgb_color_struct *rgb_struct)
|
|||||||
|
|
||||||
void wxPNGReader::NullData()
|
void wxPNGReader::NullData()
|
||||||
{
|
{
|
||||||
|
if (lpbi) {
|
||||||
|
wxMacDestroyGWorld( lpbi ) ;
|
||||||
|
}
|
||||||
|
delete Palette;
|
||||||
lpbi = NULL;
|
lpbi = NULL;
|
||||||
Palette = NULL;
|
Palette = NULL;
|
||||||
}
|
}
|
||||||
@@ -516,30 +524,47 @@ bool wxPNGReader::ReadFile(char * ImageFileName)
|
|||||||
{
|
{
|
||||||
if ( pixel_depth == 8 )
|
if ( pixel_depth == 8 )
|
||||||
{
|
{
|
||||||
|
for ( int i = 0 ; i < info_ptr->width ; ++i )
|
||||||
|
{
|
||||||
|
png_color_struct* color ;
|
||||||
|
RGBColor col ;
|
||||||
|
|
||||||
|
int index = row_pointers[i] ;
|
||||||
|
color = &info_ptr->palette[index] ;
|
||||||
|
col.red = (((int)color->red) << 8) | ((int)color->red) ;
|
||||||
|
col.green = (((int)color->green) << 8) | ((int)color->green) ;
|
||||||
|
col.blue = (((int)color->blue) << 8) | ((int)color->blue) ;
|
||||||
|
SetCPixel( i, y, &col);
|
||||||
|
}
|
||||||
|
/*
|
||||||
png_color_struct* color ;
|
png_color_struct* color ;
|
||||||
RGBColor col ;
|
RGBColor col ;
|
||||||
unsigned char* p = &row_pointers[0] ;
|
unsigned char* p = &row_pointers[0] ;
|
||||||
|
PenNormal() ;
|
||||||
MoveTo( 0 , y ) ;
|
MoveTo( 0 , y ) ;
|
||||||
unsigned char lastcol = *p ;
|
int index = *p ;
|
||||||
color = &info_ptr->palette[lastcol] ;
|
color = &info_ptr->palette[index] ;
|
||||||
col.red = (color->red << 8) | color->red ;
|
col.red = (color->red << 8) | color->red ;
|
||||||
col.green = (color->green << 8) | color->green ;
|
col.green = (color->green << 8) | color->green ;
|
||||||
col.blue = (color->blue << 8) | color->blue ;
|
col.blue = (color->blue << 8) | color->blue ;
|
||||||
RGBForeColor( &col ) ;
|
RGBForeColor( &col ) ;
|
||||||
|
col.red = col.green = col.blue = 0xFFFF ;
|
||||||
|
RGBBackColor( &col ) ;
|
||||||
for ( int i = 0 ; i < info_ptr->width ; ++i , ++p)
|
for ( int i = 0 ; i < info_ptr->width ; ++i , ++p)
|
||||||
{
|
{
|
||||||
if ( *p != lastcol )
|
if ( *p != index )
|
||||||
{
|
{
|
||||||
LineTo( i , y ) ;
|
LineTo( i , y ) ;
|
||||||
lastcol = *p ;
|
index = *p ;
|
||||||
color = &info_ptr->palette[lastcol] ;
|
color = &info_ptr->palette[index] ;
|
||||||
col.red = (color->red << 8) | color->red ;
|
col.red = (((int)color->red) << 8) | ((int)color->red) ;
|
||||||
col.green = (color->green << 8) | color->green ;
|
col.green = (((int)color->green) << 8) | ((int)color->green) ;
|
||||||
col.blue = (color->blue << 8) | color->blue ;
|
col.blue = (((int)color->blue) << 8) | ((int)color->blue) ;
|
||||||
RGBForeColor( &col ) ;
|
RGBForeColor( &col ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LineTo( info_ptr->width - 1 , y ) ;
|
LineTo( info_ptr->width , y ) ;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -553,9 +578,9 @@ bool wxPNGReader::ReadFile(char * ImageFileName)
|
|||||||
|
|
||||||
int index = ( row_pointers[byte] >> offset ) & ( 0xFF >> ( 8 - pixel_depth ) );
|
int index = ( row_pointers[byte] >> offset ) & ( 0xFF >> ( 8 - pixel_depth ) );
|
||||||
color = &info_ptr->palette[index] ;
|
color = &info_ptr->palette[index] ;
|
||||||
col.red = (color->red << 8) | color->red ;
|
col.red = (((int)color->red) << 8) | ((int)color->red) ;
|
||||||
col.green = (color->green << 8) | color->green ;
|
col.green = (((int)color->green) << 8) | ((int)color->green) ;
|
||||||
col.blue = (color->blue << 8) | color->blue ;
|
col.blue = (((int)color->blue) << 8) | ((int)color->blue) ;
|
||||||
SetCPixel( i, y, &col);
|
SetCPixel( i, y, &col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -567,9 +592,9 @@ bool wxPNGReader::ReadFile(char * ImageFileName)
|
|||||||
png_color_struct* color ;
|
png_color_struct* color ;
|
||||||
RGBColor col ;
|
RGBColor col ;
|
||||||
color =(png_color_struct*) (&row_pointers[i*3]) ;
|
color =(png_color_struct*) (&row_pointers[i*3]) ;
|
||||||
col.red = (color->red << 8) | color->red ;
|
col.red = (((int)color->red) << 8) | ((int)color->red) ;
|
||||||
col.green = (color->green << 8) | color->green ;
|
col.green = (((int)color->green) << 8) | ((int)color->green) ;
|
||||||
col.blue = (color->blue << 8) | color->blue ;
|
col.blue = (((int)color->blue) << 8) | ((int)color->blue) ;
|
||||||
SetCPixel( i, y, &col);
|
SetCPixel( i, y, &col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -34,9 +34,12 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
|
|||||||
long style,
|
long style,
|
||||||
const wxString& name)
|
const wxString& name)
|
||||||
{
|
{
|
||||||
m_messageBitmap = bitmap;
|
|
||||||
SetName(name);
|
SetName(name);
|
||||||
if (parent) parent->AddChild(this);
|
|
||||||
|
m_backgroundColour = parent->GetBackgroundColour() ;
|
||||||
|
m_foregroundColour = parent->GetForegroundColour() ;
|
||||||
|
|
||||||
|
m_messageBitmap = bitmap;
|
||||||
|
|
||||||
if ( id == -1 )
|
if ( id == -1 )
|
||||||
m_windowId = (int)NewControlId();
|
m_windowId = (int)NewControlId();
|
||||||
@@ -47,6 +50,8 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
|
|||||||
|
|
||||||
bool ret = wxControl::Create( parent, id, pos, size, style , name );
|
bool ret = wxControl::Create( parent, id, pos, size, style , name );
|
||||||
|
|
||||||
|
SetSizeOrDefault() ;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,8 +63,7 @@ void wxStaticBitmap::SetSize(int x, int y, int width, int height, int sizeFlags)
|
|||||||
void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
|
void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
|
||||||
{
|
{
|
||||||
m_messageBitmap = bitmap;
|
m_messageBitmap = bitmap;
|
||||||
|
SetSizeOrDefault();
|
||||||
Refresh() ;
|
|
||||||
}
|
}
|
||||||
void wxStaticBitmap::OnPaint( wxPaintEvent &event )
|
void wxStaticBitmap::OnPaint( wxPaintEvent &event )
|
||||||
{
|
{
|
||||||
@@ -69,3 +73,11 @@ void wxStaticBitmap::OnPaint( wxPaintEvent &event )
|
|||||||
dc.DrawBitmap( m_messageBitmap , 0 , 0 ) ;
|
dc.DrawBitmap( m_messageBitmap , 0 , 0 ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxSize wxStaticBitmap::DoGetBestSize() const
|
||||||
|
{
|
||||||
|
if ( m_messageBitmap.Ok() )
|
||||||
|
return wxSize(m_messageBitmap.GetWidth(), m_messageBitmap.GetHeight());
|
||||||
|
else
|
||||||
|
return wxSize(16, 16); // completely arbitrary
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -40,8 +40,7 @@ wxToolBar::wxToolBar()
|
|||||||
bool wxToolBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
|
bool wxToolBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
|
||||||
long style, const wxString& name)
|
long style, const wxString& name)
|
||||||
{
|
{
|
||||||
m_maxWidth = -1;
|
m_maxWidth = m_maxHeight = 0;
|
||||||
m_maxHeight = -1;
|
|
||||||
|
|
||||||
m_defaultWidth = 24;
|
m_defaultWidth = 24;
|
||||||
m_defaultHeight = 22;
|
m_defaultHeight = 22;
|
||||||
@@ -152,7 +151,9 @@ bool wxToolBar::CreateTools()
|
|||||||
wxNode *node = m_tools.First();
|
wxNode *node = m_tools.First();
|
||||||
int noButtons = 0;
|
int noButtons = 0;
|
||||||
int x = 0 ;
|
int x = 0 ;
|
||||||
|
wxSize toolSize = GetToolSize() ;
|
||||||
|
int tw, th;
|
||||||
|
GetSize(& tw, & th);
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
wxToolBarTool *tool = (wxToolBarTool *)node->Data();
|
wxToolBarTool *tool = (wxToolBarTool *)node->Data();
|
||||||
@@ -161,8 +162,8 @@ bool wxToolBar::CreateTools()
|
|||||||
if( tool->m_toolStyle != wxTOOL_STYLE_SEPARATOR )
|
if( tool->m_toolStyle != wxTOOL_STYLE_SEPARATOR )
|
||||||
{
|
{
|
||||||
Rect toolrect = { toolbarrect.top + kwxMacToolBarTopMargin , toolbarrect.left + x + kwxMacToolBarLeftMargin , 0 , 0 } ;
|
Rect toolrect = { toolbarrect.top + kwxMacToolBarTopMargin , toolbarrect.left + x + kwxMacToolBarLeftMargin , 0 , 0 } ;
|
||||||
toolrect.right = toolrect.left + m_defaultWidth ;
|
toolrect.right = toolrect.left + toolSize.x ;
|
||||||
toolrect.bottom = toolrect.top + m_defaultHeight ;
|
toolrect.bottom = toolrect.top + toolSize.y ;
|
||||||
|
|
||||||
PicHandle icon = NULL ;
|
PicHandle icon = NULL ;
|
||||||
if ( bmap )
|
if ( bmap )
|
||||||
@@ -197,17 +198,37 @@ bool wxToolBar::CreateTools()
|
|||||||
UMASetControlFontStyle( m_macToolHandle , &controlstyle ) ;
|
UMASetControlFontStyle( m_macToolHandle , &controlstyle ) ;
|
||||||
UMAEmbedControl( m_macToolHandle , m_macControl ) ;
|
UMAEmbedControl( m_macToolHandle , m_macControl ) ;
|
||||||
|
|
||||||
x += (int)m_defaultWidth;
|
x += (int)toolSize.x;
|
||||||
noButtons ++;
|
noButtons ++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_macToolHandles.Add( NULL ) ;
|
m_macToolHandles.Add( NULL ) ;
|
||||||
x += (int)m_defaultWidth / 4;
|
x += (int)toolSize.x / 4;
|
||||||
}
|
}
|
||||||
|
if ( toolbarrect.left + x + kwxMacToolBarLeftMargin > m_maxWidth)
|
||||||
|
m_maxWidth = toolbarrect.left + x + kwxMacToolBarLeftMargin;
|
||||||
|
if (toolbarrect.top + kwxMacToolBarTopMargin + toolSize.y > m_maxHeight)
|
||||||
|
m_maxHeight = toolbarrect.top + kwxMacToolBarTopMargin ;
|
||||||
|
|
||||||
node = node->Next();
|
node = node->Next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( GetWindowStyleFlag() & wxTB_HORIZONTAL )
|
||||||
|
{
|
||||||
|
m_maxWidth = tw ; // +=toolSize.x;
|
||||||
|
m_maxHeight += toolSize.y;
|
||||||
|
m_maxHeight += m_yMargin;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_maxHeight = th ;// += toolSize.y;
|
||||||
|
m_maxWidth += toolSize.x;
|
||||||
|
m_maxWidth += m_xMargin;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetSize(m_maxWidth, m_maxHeight);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,8 +239,7 @@ void wxToolBar::SetToolBitmapSize(const wxSize& size)
|
|||||||
|
|
||||||
wxSize wxToolBar::GetMaxSize() const
|
wxSize wxToolBar::GetMaxSize() const
|
||||||
{
|
{
|
||||||
// TODO
|
return wxSize(m_maxWidth, m_maxHeight);
|
||||||
return wxSize(0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The button size is bigger than the bitmap size
|
// The button size is bigger than the bitmap size
|
||||||
@@ -291,7 +311,13 @@ wxToolBarTool *wxToolBar::AddTool(int index, const wxBitmap& bitmap, const wxBit
|
|||||||
else
|
else
|
||||||
tool->m_y = m_yMargin;
|
tool->m_y = m_yMargin;
|
||||||
|
|
||||||
tool->SetSize(m_defaultWidth, m_defaultHeight);
|
tool->SetSize(GetToolSize().x, GetToolSize().y);
|
||||||
|
|
||||||
|
if ((tool->m_x + bitmap.GetWidth() + m_xMargin) > m_maxWidth)
|
||||||
|
m_maxWidth = (tool->m_x + tool->GetWidth() + m_xMargin);
|
||||||
|
|
||||||
|
if ((tool->m_y + bitmap.GetHeight() + m_yMargin) > m_maxHeight)
|
||||||
|
m_maxHeight = (tool->m_y + tool->GetHeight() + m_yMargin);
|
||||||
|
|
||||||
m_tools.Append((long)index, tool);
|
m_tools.Append((long)index, tool);
|
||||||
return tool;
|
return tool;
|
||||||
|
@@ -35,6 +35,10 @@
|
|||||||
#include "wx/menuitem.h"
|
#include "wx/menuitem.h"
|
||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
|
|
||||||
|
#if wxUSE_CARET
|
||||||
|
#include "wx/caret.h"
|
||||||
|
#endif // wxUSE_CARET
|
||||||
|
|
||||||
#define wxWINDOW_HSCROLL 5998
|
#define wxWINDOW_HSCROLL 5998
|
||||||
#define wxWINDOW_VSCROLL 5997
|
#define wxWINDOW_VSCROLL 5997
|
||||||
#define MAC_SCROLLBAR_SIZE 16
|
#define MAC_SCROLLBAR_SIZE 16
|
||||||
@@ -198,6 +202,13 @@ void wxWindow::SetFocus()
|
|||||||
{
|
{
|
||||||
if (gFocusWindow )
|
if (gFocusWindow )
|
||||||
{
|
{
|
||||||
|
#if wxUSE_CARET
|
||||||
|
// Deal with caret
|
||||||
|
if ( gFocusWindow->m_caret )
|
||||||
|
{
|
||||||
|
gFocusWindow->m_caret->OnKillFocus();
|
||||||
|
}
|
||||||
|
#endif // wxUSE_CARET
|
||||||
wxControl* control = wxDynamicCast( gFocusWindow , wxControl ) ;
|
wxControl* control = wxDynamicCast( gFocusWindow , wxControl ) ;
|
||||||
if ( control && control->GetMacControl() )
|
if ( control && control->GetMacControl() )
|
||||||
{
|
{
|
||||||
@@ -209,6 +220,19 @@ void wxWindow::SetFocus()
|
|||||||
}
|
}
|
||||||
gFocusWindow = this ;
|
gFocusWindow = this ;
|
||||||
{
|
{
|
||||||
|
#if wxUSE_CARET
|
||||||
|
// Deal with caret
|
||||||
|
if ( m_caret )
|
||||||
|
{
|
||||||
|
m_caret->OnSetFocus();
|
||||||
|
}
|
||||||
|
#endif // wxUSE_CARET
|
||||||
|
// panel wants to track the window which was the last to have focus in it
|
||||||
|
wxPanel *panel = wxDynamicCast(GetParent(), wxPanel);
|
||||||
|
if ( panel )
|
||||||
|
{
|
||||||
|
panel->SetLastFocus(this);
|
||||||
|
}
|
||||||
wxControl* control = wxDynamicCast( gFocusWindow , wxControl ) ;
|
wxControl* control = wxDynamicCast( gFocusWindow , wxControl ) ;
|
||||||
if ( control && control->GetMacControl() )
|
if ( control && control->GetMacControl() )
|
||||||
{
|
{
|
||||||
@@ -1348,6 +1372,9 @@ void wxWindow::MacRedraw( RgnHandle updatergn , long time)
|
|||||||
if ( focus.Ok() )
|
if ( focus.Ok() )
|
||||||
{
|
{
|
||||||
WindowRef window = GetMacRootWindow() ;
|
WindowRef window = GetMacRootWindow() ;
|
||||||
|
bool eraseBackground = false ;
|
||||||
|
if ( m_macWindowData )
|
||||||
|
eraseBackground = true ;
|
||||||
if ( m_backgroundColour == wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE) )
|
if ( m_backgroundColour == wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE) )
|
||||||
{
|
{
|
||||||
UMASetThemeWindowBackground( window , kThemeBrushDocumentWindowBackground , false ) ;
|
UMASetThemeWindowBackground( window , kThemeBrushDocumentWindowBackground , false ) ;
|
||||||
@@ -1380,7 +1407,7 @@ void wxWindow::MacRedraw( RgnHandle updatergn , long time)
|
|||||||
// if we have the normal colours in the hierarchy but another control etc. -> use it's background
|
// if we have the normal colours in the hierarchy but another control etc. -> use it's background
|
||||||
if ( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) ))
|
if ( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) ))
|
||||||
{
|
{
|
||||||
ApplyThemeBackground (kThemeBackgroundTabPane, &(**updatergn).rgnBBox , kThemeStateActive,8,true);
|
ApplyThemeBackground(kThemeBackgroundTabPane, &(**updatergn).rgnBBox , kThemeStateActive,8,true);
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1401,10 +1428,15 @@ void wxWindow::MacRedraw( RgnHandle updatergn , long time)
|
|||||||
{
|
{
|
||||||
RGBBackColor( &m_backgroundColour.GetPixel()) ;
|
RGBBackColor( &m_backgroundColour.GetPixel()) ;
|
||||||
}
|
}
|
||||||
|
if ( GetParent() && m_backgroundColour != GetParent()->GetBackgroundColour() )
|
||||||
|
eraseBackground = true ;
|
||||||
SetClip( updatergn ) ;
|
SetClip( updatergn ) ;
|
||||||
|
if ( eraseBackground )
|
||||||
|
{
|
||||||
EraseRgn( updatergn ) ;
|
EraseRgn( updatergn ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
m_updateRegion = updatergn ;
|
m_updateRegion = updatergn ;
|
||||||
@@ -1553,7 +1585,10 @@ void wxWindow::MacKeyDown( EventRecord *ev )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool wxWindow::AcceptsFocus() const
|
||||||
|
{
|
||||||
|
return MacCanFocus() && wxWindowBase::AcceptsFocus();
|
||||||
|
}
|
||||||
|
|
||||||
ControlHandle wxWindow::MacGetContainerForEmbedding()
|
ControlHandle wxWindow::MacGetContainerForEmbedding()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user