bugfixes, bugfixes, bugfixes...

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11388 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2001-08-15 23:48:31 +00:00
parent 9b588fe10c
commit ef344ff862
11 changed files with 226 additions and 138 deletions

View File

@@ -23,6 +23,7 @@
class WXDLLEXPORT wxApp; class WXDLLEXPORT wxApp;
class WXDLLEXPORT wxLog; class WXDLLEXPORT wxLog;
class WXDLLEXPORT wxEventLoop;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxApp // wxApp
@@ -63,6 +64,8 @@ public:
private: private:
DECLARE_DYNAMIC_CLASS(wxApp) DECLARE_DYNAMIC_CLASS(wxApp)
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
wxEventLoop *m_mainLoop;
}; };
int WXDLLEXPORT wxEntry(int argc, char *argv[]); int WXDLLEXPORT wxEntry(int argc, char *argv[]);

View File

@@ -269,8 +269,7 @@ protected:
wxPalette m_oldPalette; wxPalette m_oldPalette;
wxRegion m_currentClippingRegion; wxRegion m_currentClippingRegion;
// clipping region m_MGLDC had when it was attached: wxRegion m_globalClippingRegion;
MGLRegion *m_globalClippingRegion;
// wxDC::Blit handles memoryDCs as special cases :( // wxDC::Blit handles memoryDCs as special cases :(
bool m_isMemDC; bool m_isMemDC;

View File

@@ -28,6 +28,7 @@
#endif #endif
#include "wx/app.h" #include "wx/app.h"
#include "wx/fontutil.h"
#include "wx/mgl/private.h" #include "wx/mgl/private.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -37,8 +38,6 @@
wxApp *wxTheApp = NULL; wxApp *wxTheApp = NULL;
wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NULL; wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NULL;
static wxEventLoop *gs_mainEventLoop = NULL;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxExit // wxExit
@@ -70,8 +69,13 @@ bool wxYield()
wxLog::Suspend(); wxLog::Suspend();
while (gs_mainEventLoop->Pending()) if ( wxEventLoop::GetActive() )
gs_mainEventLoop->Dispatch(); {
while (wxEventLoop::GetActive()->Pending())
wxEventLoop::GetActive()->Dispatch();
}
else
MGL_wmUpdateDC(g_winMng); // FIXME_MGL -- temporary hack, please remove
/* it's necessary to call ProcessIdle() to update the frames sizes which /* it's necessary to call ProcessIdle() to update the frames sizes which
might have been changed (it also will update other things set from might have been changed (it also will update other things set from
@@ -124,7 +128,7 @@ BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
END_EVENT_TABLE() END_EVENT_TABLE()
wxApp::wxApp() wxApp::wxApp() : m_mainLoop(NULL)
{ {
} }
@@ -227,16 +231,19 @@ bool wxApp::SendIdleEvents(wxWindow* win)
int wxApp::MainLoop() int wxApp::MainLoop()
{ {
int rt; int rt;
gs_mainEventLoop = new wxEventLoop; m_mainLoop = new wxEventLoop;
rt = gs_mainEventLoop->Run();
delete gs_mainEventLoop; rt = m_mainLoop->Run();
gs_mainEventLoop = NULL;
delete m_mainLoop;
m_mainLoop = NULL;
return rt; return rt;
} }
void wxApp::ExitMainLoop() void wxApp::ExitMainLoop()
{ {
gs_mainEventLoop->Exit(0); if ( m_mainLoop )
m_mainLoop->Exit(0);
} }
bool wxApp::Initialized() bool wxApp::Initialized()
@@ -248,12 +255,12 @@ bool wxApp::Initialized()
bool wxApp::Pending() bool wxApp::Pending()
{ {
return gs_mainEventLoop->Pending(); return wxEventLoop::GetActive()->Pending();
} }
void wxApp::Dispatch() void wxApp::Dispatch()
{ {
gs_mainEventLoop->Dispatch(); wxEventLoop::GetActive()->Dispatch();
} }
void wxApp::DeletePendingObjects() void wxApp::DeletePendingObjects()
@@ -294,6 +301,9 @@ bool wxApp::Initialize()
wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING); wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
wxTheColourDatabase->Initialize(); wxTheColourDatabase->Initialize();
// Can't do this in wxModule, because fonts are needed by stock lists
wxTheFontsManager = new wxFontsManager;
wxInitializeStockLists(); wxInitializeStockLists();
wxInitializeStockObjects(); wxInitializeStockObjects();
@@ -358,9 +368,12 @@ void wxApp::CleanUp()
wxTheColourDatabase = (wxColourDatabase*) NULL; wxTheColourDatabase = (wxColourDatabase*) NULL;
wxDeleteStockObjects(); wxDeleteStockObjects();
wxDeleteStockLists(); wxDeleteStockLists();
// Can't do this in wxModule, because fonts are needed by stock lists
delete wxTheFontsManager;
wxTheFontsManager = (wxFontsManager*) NULL;
delete wxTheApp; delete wxTheApp;
wxTheApp = (wxApp*) NULL; wxTheApp = (wxApp*) NULL;

View File

@@ -48,10 +48,6 @@ static pixel_format_t gs_pixel_format_24 =
static pixel_format_t gs_pixel_format_32 = static pixel_format_t gs_pixel_format_32 =
{0xFF,0x18,0, 0xFF,0x10,0, 0xFF,0x08,0, 0xFF,0x00,0}; // RGBA 32bpp {0xFF,0x18,0, 0xFF,0x10,0, 0xFF,0x08,0, 0xFF,0x00,0}; // RGBA 32bpp
// FIXME_MGL -- these formats will probably have to go into another place,
// where wxApp could use them to initialize g_displayDC
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxMask // wxMask
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@@ -24,7 +24,7 @@
#include "wx/log.h" #include "wx/log.h"
#include "wx/intl.h" #include "wx/intl.h"
#include <mgraph.hpp> #include "wx/mgl/private.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -98,8 +98,6 @@ wxCursor::wxCursor(int cursorId)
case wxCURSOR_BLANK: cursorname = "blank.cur"; break; case wxCURSOR_BLANK: cursorname = "blank.cur"; break;
case wxCURSOR_NONE: case wxCURSOR_NONE:
// FIXME_MGL - make sure wxWindow uses cursor with
// GetMGLCursor() == NULL correctly, i.e. calls MS_hide()
*this = wxNullCursor; *this = wxNullCursor;
return; return;
break; break;
@@ -199,13 +197,14 @@ MGLCursor *wxCursor::GetMGLCursor() const
// Global cursor setting // Global cursor setting
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
static wxCursor g_globalCursor = wxNullCursor;
void wxSetCursor(const wxCursor& cursor) void wxSetCursor(const wxCursor& cursor)
{ {
if ( cursor.Ok() ) if ( cursor.Ok() )
{ {
//MGL_setGlobalCursor(cursor.GetMGLCursor()); MGL_wmSetGlobalCursor(g_winMng, *cursor.GetMGLCursor());
// FIXME_MGL -- needs MGL WM first g_globalCursor = cursor;
} }
} }
@@ -215,10 +214,7 @@ void wxSetCursor(const wxCursor& cursor)
// busy cursor routines // busy cursor routines
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// FIXME_MGL -- do we need this? It may be better to incorporate static wxCursor gs_savedCursor = wxNullCursor;
// support for it into MGL (a stack of global cursors?)
static wxCursor gs_savedCursor;
static wxCursor g_globalCursor;
static int gs_busyCount = 0; static int gs_busyCount = 0;
const wxCursor &wxBusyCursor::GetStoredCursor() const wxCursor &wxBusyCursor::GetStoredCursor()
@@ -237,10 +233,9 @@ void wxEndBusyCursor()
wxSetCursor(gs_savedCursor); wxSetCursor(gs_savedCursor);
gs_savedCursor = wxNullCursor; gs_savedCursor = wxNullCursor;
//wxYield(); FIXME_MGL - needed?
} }
void wxBeginBusyCursor(wxCursor *WXUNUSED(cursor)) void wxBeginBusyCursor(wxCursor *cursor)
{ {
if ( gs_busyCount++ > 0 ) return; if ( gs_busyCount++ > 0 ) return;
@@ -248,8 +243,10 @@ void wxBeginBusyCursor(wxCursor *WXUNUSED(cursor))
wxT("forgot to call wxEndBusyCursor, will leak memory") ); wxT("forgot to call wxEndBusyCursor, will leak memory") );
gs_savedCursor = g_globalCursor; gs_savedCursor = g_globalCursor;
if ( cursor->Ok() )
wxSetCursor(*cursor);
else
wxSetCursor(wxCursor(wxCURSOR_WAIT)); wxSetCursor(wxCursor(wxCURSOR_WAIT));
//wxYield(); FIXME_MGL - needed?
} }
bool wxIsBusy() bool wxIsBusy()

View File

@@ -152,16 +152,10 @@ wxDC::wxDC()
m_OwnsMGLDC = FALSE; m_OwnsMGLDC = FALSE;
m_ok = FALSE; // must call SetMGLDevCtx() before using it m_ok = FALSE; // must call SetMGLDevCtx() before using it
#if 0
m_mm_to_pix_x = (double)wxGetDisplaySize().GetWidth() / m_mm_to_pix_x = (double)wxGetDisplaySize().GetWidth() /
(double)wxGetDisplaySizeMM().GetWidth(); (double)wxGetDisplaySizeMM().GetWidth();
m_mm_to_pix_y = (double)wxGetDisplaySize().GetHeight() / m_mm_to_pix_y = (double)wxGetDisplaySize().GetHeight() /
(double)wxGetDisplaySizeMM().GetHeight(); (double)wxGetDisplaySizeMM().GetHeight();
#endif
// FIXME_MGL -- not in wxUniversal branch (and not implementend anyway,
// hardcode it for 75dpi for now)
m_mm_to_pix_x = ((double)wxGetDisplaySize().GetWidth() / 75) * inches2mm;
m_mm_to_pix_y = ((double)wxGetDisplaySize().GetHeight() / 75) * inches2mm;
m_pen = *wxBLACK_PEN; m_pen = *wxBLACK_PEN;
m_font = *wxNORMAL_FONT; m_font = *wxNORMAL_FONT;
@@ -172,7 +166,6 @@ wxDC::wxDC()
m_downloadedPatterns[0] = m_downloadedPatterns[1] = FALSE; m_downloadedPatterns[0] = m_downloadedPatterns[1] = FALSE;
m_mglFont = NULL; m_mglFont = NULL;
m_globalClippingRegion = NULL;
} }
@@ -180,7 +173,6 @@ wxDC::~wxDC()
{ {
if (m_OwnsMGLDC) if (m_OwnsMGLDC)
delete m_MGLDC; delete m_MGLDC;
delete m_globalClippingRegion;
} }
void wxDC::SetMGLDC(MGLDevCtx *mgldc, bool OwnsMGLDC) void wxDC::SetMGLDC(MGLDevCtx *mgldc, bool OwnsMGLDC)
@@ -193,11 +185,13 @@ void wxDC::SetMGLDC(MGLDevCtx *mgldc, bool OwnsMGLDC)
if ( mgldc->getDC()->a.clipRegion ) if ( mgldc->getDC()->a.clipRegion )
{ {
m_globalClippingRegion = new MGLRegion; MGLRegion clip;
mgldc->getClipRegion(*m_globalClippingRegion); mgldc->getClipRegion(clip);
m_globalClippingRegion = wxRegion(clip);
// FIXME_MGL -- reuse wxWindows::m_updateRegion ?
m_currentClippingRegion = m_globalClippingRegion;
m_clipping = TRUE;
} }
else
m_globalClippingRegion = NULL;
InitializeMGLDC(); InitializeMGLDC();
} }
@@ -237,12 +231,6 @@ void wxDC::DoSetClippingRegion(wxCoord cx, wxCoord cy, wxCoord cw, wxCoord ch)
else else
m_currentClippingRegion.Union(rect); m_currentClippingRegion.Union(rect);
if ( m_globalClippingRegion )
{
m_MGLDC->setClipRegion(m_currentClippingRegion.GetMGLRegion()
& *m_globalClippingRegion);
}
else
m_MGLDC->setClipRegion(m_currentClippingRegion.GetMGLRegion()); m_MGLDC->setClipRegion(m_currentClippingRegion.GetMGLRegion());
m_clipping = TRUE; m_clipping = TRUE;
@@ -253,7 +241,7 @@ void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region)
{ {
wxCHECK_RET( Ok(), wxT("invalid dc") ); wxCHECK_RET( Ok(), wxT("invalid dc") );
if ( region.Empty() ) if ( region.IsEmpty() )
{ {
DestroyClippingRegion(); DestroyClippingRegion();
return; return;
@@ -282,12 +270,6 @@ void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region)
else else
m_currentClippingRegion.Union(rg); m_currentClippingRegion.Union(rg);
if ( m_globalClippingRegion )
{
m_MGLDC->setClipRegion(m_currentClippingRegion.GetMGLRegion()
& *m_globalClippingRegion);
}
else
m_MGLDC->setClipRegion(m_currentClippingRegion.GetMGLRegion()); m_MGLDC->setClipRegion(m_currentClippingRegion.GetMGLRegion());
m_clipping = TRUE; m_clipping = TRUE;
@@ -298,12 +280,18 @@ void wxDC::DestroyClippingRegion()
{ {
wxCHECK_RET( Ok(), wxT("invalid dc") ); wxCHECK_RET( Ok(), wxT("invalid dc") );
if ( m_globalClippingRegion ) if ( !m_globalClippingRegion.IsNull() )
m_MGLDC->setClipRegion(*m_globalClippingRegion); {
m_MGLDC->setClipRegion(m_globalClippingRegion.GetMGLRegion());
m_currentClippingRegion = m_globalClippingRegion;
m_clipping = TRUE;
}
else else
{
m_MGLDC->setClipRect(MGLRect(0, 0, m_MGLDC->sizex(), m_MGLDC->sizey())); m_MGLDC->setClipRect(MGLRect(0, 0, m_MGLDC->sizex(), m_MGLDC->sizey()));
m_clipping = FALSE; m_clipping = FALSE;
m_currentClippingRegion.Clear(); m_currentClippingRegion.Clear();
}
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

View File

@@ -46,11 +46,11 @@ public:
SetKeepLooping(TRUE); SetKeepLooping(TRUE);
} }
// process a message // process an event
void ProcessEvent(event_t *evt); void Dispatch();
// generate an idle message, return TRUE if more idle time requested // generate an idle event, return TRUE if more idle time requested
bool SendIdleMessage(); bool SendIdleEvent();
// set/get the exit code // set/get the exit code
void SetExitCode(int exitcode) { m_exitcode = exitcode; } void SetExitCode(int exitcode) { m_exitcode = exitcode; }
@@ -71,12 +71,18 @@ private:
// wxEventLoopImpl implementation // wxEventLoopImpl implementation
// ============================================================================ // ============================================================================
void wxEventLoopImpl::ProcessEvent(event_t *evt) void wxEventLoopImpl::Dispatch()
{ {
MGL_wmProcessEvent(g_winMng, evt); event_t evt;
ibool rc;
MGL_wmUpdateDC(g_winMng);
EVT_halt(&evt, EVT_EVERYEVT);
MGL_wmProcessEvent(g_winMng, &evt);
} }
bool wxEventLoopImpl::SendIdleMessage() bool wxEventLoopImpl::SendIdleEvent()
{ {
wxIdleEvent event; wxIdleEvent event;
@@ -91,6 +97,8 @@ bool wxEventLoopImpl::SendIdleMessage()
// wxEventLoop running and exiting // wxEventLoop running and exiting
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
wxEventLoop *wxEventLoop::ms_activeLoop = NULL;
wxEventLoop::~wxEventLoop() wxEventLoop::~wxEventLoop()
{ {
wxASSERT_MSG( !m_impl, _T("should have been deleted in Run()") ); wxASSERT_MSG( !m_impl, _T("should have been deleted in Run()") );
@@ -108,6 +116,9 @@ int wxEventLoop::Run()
m_impl = new wxEventLoopImpl; m_impl = new wxEventLoopImpl;
wxEventLoop *oldLoop = ms_activeLoop;
ms_activeLoop = this;
for ( ;; ) for ( ;; )
{ {
#if wxUSE_THREADS #if wxUSE_THREADS
@@ -116,7 +127,7 @@ int wxEventLoop::Run()
// generate and process idle events for as long as we don't have // generate and process idle events for as long as we don't have
// anything else to do // anything else to do
while ( !Pending() && m_impl->SendIdleMessage() ) {} while ( !Pending() && m_impl->SendIdleEvent() ) {}
// a message came or no more idle processing to do, sit in Dispatch() // a message came or no more idle processing to do, sit in Dispatch()
// waiting for the next message // waiting for the next message
@@ -131,6 +142,8 @@ int wxEventLoop::Run()
delete m_impl; delete m_impl;
m_impl = NULL; m_impl = NULL;
ms_activeLoop = oldLoop;
return exitcode; return exitcode;
} }
@@ -156,19 +169,6 @@ bool wxEventLoop::Dispatch()
{ {
wxCHECK_MSG( IsRunning(), FALSE, _T("can't call Dispatch() if not running") ); wxCHECK_MSG( IsRunning(), FALSE, _T("can't call Dispatch() if not running") );
event_t evt; m_impl->Dispatch();
ibool rc;
rc = EVT_getNext(&evt, EVT_EVERYEVT);
while ( !rc )
{
wxUsleep(1000);
if ( !m_impl->GetKeepLooping() )
return FALSE;
rc = EVT_getNext(&evt, EVT_EVERYEVT);
}
m_impl->ProcessEvent(&evt);
return m_impl->GetKeepLooping(); return m_impl->GetKeepLooping();
} }

View File

@@ -125,6 +125,7 @@ wxFontRefData::wxFontRefData(const wxFontRefData& data)
m_valid = data.m_valid; m_valid = data.m_valid;
if ( m_library ) if ( m_library )
m_library->IncRef(); m_library->IncRef();
wxLogTrace("mgl_font", "created fntrefdata %p, library is %p", this, m_library);
} }
wxFontRefData::wxFontRefData(int size, int family, int style, wxFontRefData::wxFontRefData(int size, int family, int style,
@@ -133,10 +134,12 @@ wxFontRefData::wxFontRefData(int size, int family, int style,
wxFontEncoding encoding) wxFontEncoding encoding)
{ {
Init(size, family, style, weight, underlined, faceName, encoding); Init(size, family, style, weight, underlined, faceName, encoding);
wxLogTrace("mgl_font", "created fntrefdata %p, library is %p", this, m_library);
} }
wxFontRefData::~wxFontRefData() wxFontRefData::~wxFontRefData()
{ {
wxLogTrace("mgl_font", "destructing fntrefdata %p, library is %p", this, m_library);
if ( m_library ) if ( m_library )
m_library->DecRef(); m_library->DecRef();
} }

View File

@@ -21,16 +21,15 @@
#endif #endif
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/log.h"
#include "wx/fontutil.h"
#include "wx/fontmap.h"
#include "wx/tokenzr.h"
#include "wx/hash.h"
#endif // PCH #endif // PCH
#include "wx/fontutil.h"
#include "wx/fontmap.h"
#include "wx/tokenzr.h"
#include "wx/hash.h"
#include "wx/module.h"
#include "wx/listimpl.cpp" #include "wx/listimpl.cpp"
#include "wx/log.h"
#include "wx/mgl/private.h" #include "wx/mgl/private.h"
#include <mgraph.h> #include <mgraph.h>
@@ -430,24 +429,3 @@ wxMGLFontFamily *wxFontsManager::GetFamily(const wxString& name) const
wxFontsManager *wxTheFontsManager = NULL; wxFontsManager *wxTheFontsManager = NULL;
// A module that takes care of fonts DB initialization and destruction:
class wxFontutilModule: public wxModule
{
DECLARE_DYNAMIC_CLASS(wxFontutilModule)
public:
wxFontutilModule() {}
bool OnInit()
{
wxTheFontsManager = new wxFontsManager;
return TRUE;
}
void OnExit()
{
delete wxTheFontsManager;
}
};
IMPLEMENT_DYNAMIC_CLASS(wxFontutilModule, wxModule)

View File

@@ -18,13 +18,13 @@
wxColour wxSystemSettings::GetSystemColour(int WXUNUSED(index)) wxColour wxSystemSettings::GetSystemColour(int WXUNUSED(index))
{ {
// FIXME_MGL // FIXME_MGL
return wxColour(255,255,0); return wxColour(0,0,0);
} }
wxFont wxSystemSettings::GetSystemFont(int WXUNUSED(index)) wxFont wxSystemSettings::GetSystemFont(int WXUNUSED(index))
{ {
// FIXME_MGL // FIXME_MGL
return wxFont(12, wxSWISS, wxNORMAL, wxNORMAL); return wxFont(9, wxSWISS, wxNORMAL, wxNORMAL);
} }
int wxSystemSettings::GetSystemMetric(int WXUNUSED(index)) int wxSystemSettings::GetSystemMetric(int WXUNUSED(index))

View File

@@ -99,6 +99,14 @@ enum
// with desired settings // with desired settings
// FIXME_MGL -- move to app.cpp?? // FIXME_MGL -- move to app.cpp??
static void wxDesktopPainter(window_t *wnd, MGLDC *dc)
{
// FIXME_MGL - for now...
MGL_setColorRGB(0x63, 0x63, 0x96);
MGL_fillRectCoord(0, 0, wnd->width, wnd->height);
}
bool wxCreateMGL_WM() bool wxCreateMGL_WM()
{ {
int mode; int mode;
@@ -106,6 +114,7 @@ bool wxCreateMGL_WM()
int refresh = MGL_DEFAULT_REFRESH; int refresh = MGL_DEFAULT_REFRESH;
#if wxUSE_SYSTEM_OPTIONS #if wxUSE_SYSTEM_OPTIONS
// FIXME_MGL -- so what is The Proper Way?
if ( wxSystemOptions::HasOption(wxT("mgl.screen-width") ) if ( wxSystemOptions::HasOption(wxT("mgl.screen-width") )
width = wxSystemOptions::GetOptionInt(wxT("mgl.screen-width")); width = wxSystemOptions::GetOptionInt(wxT("mgl.screen-width"));
if ( wxSystemOptions::HasOption(wxT("mgl.screen-height") ) if ( wxSystemOptions::HasOption(wxT("mgl.screen-height") )
@@ -134,6 +143,8 @@ bool wxCreateMGL_WM()
if (!g_winMng) if (!g_winMng)
return FALSE; return FALSE;
MGL_wmSetWindowPainter(MGL_wmGetRootWindow(g_winMng), wxDesktopPainter);
return TRUE; return TRUE;
} }
@@ -163,14 +174,109 @@ static void wxWindowPainter(window_t *wnd, MGLDC *dc)
MGLDevCtx ctx(dc); MGLDevCtx ctx(dc);
w->HandlePaint(&ctx); w->HandlePaint(&ctx);
} }
// FIXME_MGL -- root window should be a regular window so that
// enter/leave and activate/deactivate events work correctly
}
static ibool wxWindowMouseHandler(window_t *wnd, event_t *e)
{
wxWindowMGL *win = (wxWindowMGL*)MGL_wmGetWindowUserData(wnd);
wxPoint where = win->ScreenToClient(wxPoint(e->where_x, e->where_y));
wxEventType type = wxEVT_NULL;
wxMouseEvent event;
event.SetEventObject(win);
event.SetTimestamp(e->when);
event.m_x = where.x;
event.m_y = where.y;
event.m_shiftDown = e->modifiers & EVT_SHIFTKEY;
event.m_controlDown = e->modifiers & EVT_CTRLSTATE;
event.m_altDown = e->modifiers & EVT_LEFTALT;
event.m_metaDown = e->modifiers & EVT_RIGHTALT;
event.m_leftDown = e->modifiers & EVT_LEFTBUT;
event.m_middleDown = e->modifiers & EVT_MIDDLEBUT;
event.m_rightDown = e->modifiers & EVT_RIGHTBUT;
switch (e->what)
{
case EVT_MOUSEDOWN:
if ( e->message & EVT_LEFTBMASK )
type = (e->message & EVT_DBLCLICK) ?
wxEVT_LEFT_DCLICK : wxEVT_LEFT_DOWN;
else if ( e->message & EVT_MIDDLEBMASK )
type = (e->message & EVT_DBLCLICK) ?
wxEVT_MIDDLE_DCLICK : wxEVT_MIDDLE_DOWN;
else if ( e->message & EVT_RIGHTBMASK )
type = (e->message & EVT_DBLCLICK) ?
wxEVT_RIGHT_DCLICK : wxEVT_RIGHT_DOWN;
break;
case EVT_MOUSEUP:
if ( e->message & EVT_LEFTBMASK )
type = wxEVT_LEFT_UP;
else if ( e->message & EVT_MIDDLEBMASK )
type = wxEVT_MIDDLE_UP;
else if ( e->message & EVT_RIGHTBMASK )
type = wxEVT_RIGHT_UP;
break;
case EVT_MOUSEMOVE:
if ( win != g_windowUnderMouse )
{
if ( g_windowUnderMouse )
{
wxMouseEvent event2(event);
wxPoint where2 = g_windowUnderMouse->ScreenToClient(
wxPoint(e->where_x, e->where_y));
event2.m_x = where2.x;
event2.m_y = where2.y;
event2.SetEventObject(g_windowUnderMouse);
event2.SetEventType(wxEVT_LEAVE_WINDOW);
g_windowUnderMouse->GetEventHandler()->ProcessEvent(event2);
}
wxMouseEvent event3(event);
event3.SetEventType(wxEVT_ENTER_WINDOW);
win->GetEventHandler()->ProcessEvent(event3);
g_windowUnderMouse = win;
}
type = wxEVT_MOTION;
break;
default:
break;
}
if ( type == wxEVT_NULL )
{
return FALSE;
}
else
{
event.SetEventType(type);
return win->GetEventHandler()->ProcessEvent(event);
}
}
static ibool wxWindowKeybHandler(window_t *wnd, event_t *e)
{
// FIXME_MGL
return FALSE;
}
static ibool wxWindowJoyHandler(window_t *wnd, event_t *e)
{
// FIXME_MGL
return FALSE;
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// event tables // event tables
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// in wxUniv/MSW this class is abstract because it doesn't have DoPopupMenu() // in wxUniv this class is abstract because it doesn't have DoPopupMenu()
// method
IMPLEMENT_ABSTRACT_CLASS(wxWindowMGL, wxWindowBase) IMPLEMENT_ABSTRACT_CLASS(wxWindowMGL, wxWindowBase)
BEGIN_EVENT_TABLE(wxWindowMGL, wxWindowBase) BEGIN_EVENT_TABLE(wxWindowMGL, wxWindowBase)
@@ -190,9 +296,6 @@ void wxWindowMGL::Init()
InitBase(); InitBase();
// mgl specific: // mgl specific:
if ( !g_winMng && !wxCreateMGL_WM() )
wxFatalError(_T("Can't initalize MGL, aborting!"));
m_wnd = NULL; m_wnd = NULL;
m_isShown = TRUE; m_isShown = TRUE;
m_isBeingDeleted = FALSE; m_isBeingDeleted = FALSE;
@@ -208,20 +311,8 @@ wxWindowMGL::~wxWindowMGL()
if ( g_focusedWindow == this ) if ( g_focusedWindow == this )
KillFocus(); KillFocus();
if ( g_windowUnderMouse == this )
#if 0 // -- fixme - do we need this? g_windowUnderMouse = NULL;
// VS: make sure there's no wxFrame with last focus set to us:
for (wxWindow *win = GetParent(); win; win = win->GetParent())
{
wxFrame *frame = wxDynamicCast(win, wxFrame);
if ( frame )
{
if ( frame->GetLastFocus() == this )
frame->SetLastFocus((wxWindow*)NULL);
break;
}
}
#endif
// VS: destroy children first and _then_ detach *this from its parent. // VS: destroy children first and _then_ detach *this from its parent.
// If we'd do it the other way around, children wouldn't be able // If we'd do it the other way around, children wouldn't be able
@@ -260,12 +351,28 @@ bool wxWindowMGL::Create(wxWindow *parent,
m_isShown = FALSE; m_isShown = FALSE;
} }
int x, y, w, h;
x = pos.x, y = pos.y;
if ( x == -1 )
x = 0; // FIXME_MGL, something better, see GTK+
if ( y == -1 )
y = 0; // FIXME_MGL, something better, see GTK+
w = WidthDefault(size.x);
h = HeightDefault(size.y);
m_wnd = MGL_wmCreateWindow(g_winMng, m_wnd = MGL_wmCreateWindow(g_winMng,
parent ? parent->GetHandle() : NULL, parent ? parent->GetHandle() : NULL,
pos.x, pos.y, size.x, size.y); x, y, w, h);
MGL_wmShowWindow(m_wnd, m_isShown);
MGL_wmSetWindowUserData(m_wnd, (void*) this); MGL_wmSetWindowUserData(m_wnd, (void*) this);
MGL_wmSetWindowPainter(m_wnd, wxWindowPainter); MGL_wmSetWindowPainter(m_wnd, wxWindowPainter);
MGL_wmShowWindow(m_wnd, m_isShown);
MGL_wmSetWindowCursor(m_wnd, *wxSTANDARD_CURSOR->GetMGLCursor());
MGL_wmPushWindowEventHandler(m_wnd, wxWindowMouseHandler, EVT_MOUSEEVT, 0);
MGL_wmPushWindowEventHandler(m_wnd, wxWindowKeybHandler, EVT_KEYEVT, 0);
MGL_wmPushWindowEventHandler(m_wnd, wxWindowJoyHandler, EVT_JOYEVT, 0);
return TRUE; return TRUE;
} }
@@ -280,7 +387,7 @@ void wxWindowMGL::SetFocus()
g_focusedWindow = this; g_focusedWindow = this;
MGL_wmCaptureEvents(GetHandle(), EVT_KEYEVT | EVT_JOYEVT, wxMGL_CAPTURE_KEYB); MGL_wmCaptureEvents(GetHandle(), EVT_KEYEVT|EVT_JOYEVT, wxMGL_CAPTURE_KEYB);
#if wxUSE_CARET #if wxUSE_CARET
// caret needs to be informed about focus change // caret needs to be informed about focus change
@@ -289,7 +396,7 @@ void wxWindowMGL::SetFocus()
caret->OnSetFocus(); caret->OnSetFocus();
#endif // wxUSE_CARET #endif // wxUSE_CARET
if (IsTopLevel()) if ( IsTopLevel() )
{ {
wxActivateEvent event(wxEVT_ACTIVATE, TRUE, GetId()); wxActivateEvent event(wxEVT_ACTIVATE, TRUE, GetId());
event.SetEventObject(this); event.SetEventObject(this);
@@ -389,6 +496,10 @@ bool wxWindowMGL::SetCursor(const wxCursor& cursor)
if ( m_cursor.Ok() ) if ( m_cursor.Ok() )
MGL_wmSetWindowCursor(m_wnd, *m_cursor.GetMGLCursor()); MGL_wmSetWindowCursor(m_wnd, *m_cursor.GetMGLCursor());
else
MGL_wmSetWindowCursor(m_wnd, *wxSTANDARD_CURSOR->GetMGLCursor());
// FIXME_MGL -- should it set children's cursor or not?!
return TRUE; return TRUE;
} }