#include "wx/univ/colschem.h"
#include "wx/mgl/private.h"
-#define MGL_DEBUG
-
-#if defined(MGL_DEBUG) && !defined(__WXDEBUG__)
-#undef MGL_DEBUG
-#endif
-
//-----------------------------------------------------------------------------
// Global data
//-----------------------------------------------------------------------------
refresh = wxSystemOptions::GetOptionInt(wxT("mgl.screen-refresh"));
#endif
- mode = MGL_findMode(displayMode.GetScreenSize().x,
- displayMode.GetScreenSize().y,
+ mode = MGL_findMode(displayMode.GetWidth(),
+ displayMode.GetHeight(),
displayMode.GetDepth());
if ( mode == -1 )
{
wxLogError(_("Mode %ix%i-%i not available."),
- displayMode.GetScreenSize().x,
- displayMode.GetScreenSize().y,
+ displayMode.GetWidth(),
+ displayMode.GetHeight(),
displayMode.GetDepth());
return FALSE;
}
if ( !wxAppBase::OnInitGui() )
return FALSE;
-#ifdef MGL_DEBUG
- // That damn MGL redirects stdin and stdout to physical console
- FILE *file = fopen("stderr", "wt");
- wxLog::SetActiveTarget(new wxLogStderr(file));
+#ifdef __WXDEBUG__
+ // MGL redirects stdout and stderr to physical console, so lets redirect
+ // it to file. Do it only when WXDEBUG environment variable is set
+ if ( wxGetEnv(wxT("WXDEBUG"), NULL) )
+ freopen("output.err", "wt", stderr);
#endif
+ wxLog *oldLog = wxLog::SetActiveTarget(new wxLogGui);
+ if ( oldLog ) delete oldLog;
+
return TRUE;
}
// 'Garbage' collection of windows deleted with Close().
DeletePendingObjects();
+#if wxUSE_LOG
+ // flush the logged messages if any
+ wxLog::FlushActive();
+#endif // wxUSE_LOG
+
// Send OnIdle events to all windows
if ( SendIdleEvents() )
event.RequestMore(TRUE);
void wxApp::CleanUp()
{
- delete gs_rootWindow;
-
#if wxUSE_LOG
- // flush the logged messages if any
- wxLog *log = wxLog::GetActiveTarget();
- if (log != NULL && log->HasPendingMessages())
- log->Flush();
-
// continuing to use user defined log target is unsafe from now on because
// some resources may be already unavailable, so replace it by something
// more safe
delete oldlog;
#endif // wxUSE_LOG
+ delete gs_rootWindow;
+
wxModule::CleanUpModules();
#if wxUSE_WX_RESOURCES
}
}
+#if wxUSE_LOG
+ // flush the logged messages if any
+ wxLog *log = wxLog::GetActiveTarget();
+ if (log != NULL && log->HasPendingMessages())
+ log->Flush();
+#endif // wxUSE_LOG
retValue = wxTheApp->OnExit();
}
}
IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandler,wxObject)
IMPLEMENT_DYNAMIC_CLASS(wxBitmap,wxBitmapBase)
-wxBitmap::wxBitmap()
-{
- if ( wxTheBitmapList ) wxTheBitmapList->AddBitmap(this);
-}
-
wxBitmap::wxBitmap(int width, int height, int depth)
{
Create(width, height, depth);
-
- if ( wxTheBitmapList ) wxTheBitmapList->AddBitmap(this);
}
*this = wxBitmap(img);
- if ( wxTheBitmapList ) wxTheBitmapList->AddBitmap(this);
-
return TRUE;
}
wxBitmap::wxBitmap(const wxBitmap& bmp)
{
Ref(bmp);
-
- if ( wxTheBitmapList ) wxTheBitmapList->AddBitmap(this);
}
wxBitmap::wxBitmap(const wxString &filename, wxBitmapType type)
{
LoadFile(filename, type);
-
- if ( wxTheBitmapList ) wxTheBitmapList->AddBitmap(this);
}
wxBitmap::wxBitmap(const char bits[], int width, int height, int depth)
bdc->clearDevice();
bdc->putMonoImage(0, 0, width, (width + 7) / 8, height, (void*)bits);
delete bdc;
-
- if ( wxTheBitmapList ) wxTheBitmapList->AddBitmap(this);
-}
-
-wxBitmap::~wxBitmap()
-{
- if ( wxTheBitmapList ) wxTheBitmapList->DeleteObject(this);
}
wxBitmap& wxBitmap::operator = (const wxBitmap& bmp)
IMPLEMENT_DYNAMIC_CLASS(wxBrush,wxGDIObject)
-wxBrush::wxBrush()
-{
- if (wxTheBrushList) wxTheBrushList->AddBrush(this);
-}
-
wxBrush::wxBrush(const wxColour &colour, int style)
{
m_refData = new wxBrushRefData();
M_BRUSHDATA->m_style = style;
M_BRUSHDATA->m_colour = colour;
-
- if (wxTheBrushList) wxTheBrushList->AddBrush(this);
}
wxBrush::wxBrush(const wxBitmap &stippleBitmap)
M_BRUSHDATA->m_style = wxSTIPPLE_MASK_OPAQUE;
else
M_BRUSHDATA->m_style = wxSTIPPLE;
-
- if (wxTheBrushList) wxTheBrushList->AddBrush(this);
}
wxBrush::wxBrush(const wxBrush &brush)
{
Ref(brush);
-
- if (wxTheBrushList) wxTheBrushList->AddBrush(this);
-}
-
-wxBrush::~wxBrush()
-{
- if (wxTheBrushList) wxTheBrushList->RemoveBrush(this);
}
wxBrush& wxBrush::operator = (const wxBrush& brush)
IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
-void wxFont::Init()
-{
- if (wxTheFontList)
- wxTheFontList->Append(this);
-}
-
bool wxFont::Create(const wxNativeFontInfo& info)
{
return Create(info.pointSize, info.family, info.style, info.weight,
}
}
-wxFont::~wxFont()
-{
- if (wxTheFontList)
- wxTheFontList->DeleteObject(this);
-}
-
// ----------------------------------------------------------------------------
// accessors
// ----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxPen,wxGDIObject)
-wxPen::wxPen()
-{
- if ( wxThePenList )
- wxThePenList->AddPen(this);
-}
-
wxPen::wxPen(const wxColour &colour, int width, int style)
{
m_refData = new wxPenRefData();
M_PENDATA->m_width = width;
M_PENDATA->m_style = style;
M_PENDATA->m_colour = colour;
-
- if ( wxThePenList )
- wxThePenList->AddPen(this);
}
wxPen::wxPen(const wxBitmap& stipple, int width)
M_PENDATA->m_style = wxSTIPPLE;
M_PENDATA->m_stipple = stipple;
wxBitmapToPixPattern(stipple, &(M_PENDATA->m_pixPattern), NULL);
-
- if ( wxThePenList )
- wxThePenList->AddPen(this);
}
wxPen::wxPen(const wxPen& pen)
{
Ref(pen);
- if ( wxThePenList )
- wxThePenList->AddPen(this);
-}
-
-wxPen::~wxPen()
-{
- if ( wxThePenList )
- wxThePenList->RemovePen(this);
}
wxPen& wxPen::operator = (const wxPen& pen)
static ibool wxWindowMouseHandler(window_t *wnd, event_t *e)
{
wxWindowMGL *win = (wxWindowMGL*)MGL_wmGetWindowUserData(wnd);
+ wxPoint orig(win->GetClientAreaOrigin());
wxPoint where;
MGL_wmCoordGlobalToLocal(win->GetHandle(),
wxMouseEvent event;
event.SetEventObject(win);
event.SetTimestamp(e->when);
- event.m_x = where.x;
- event.m_y = where.y;
+ event.m_x = where.x - orig.x;
+ event.m_y = where.y - orig.y;
event.m_shiftDown = e->modifiers & EVT_SHIFTKEY;
event.m_controlDown = e->modifiers & EVT_CTRLSTATE;
event.m_altDown = e->modifiers & EVT_LEFTALT;
e->where_x, e->where_y,
&event2.m_x, &event2.m_y);
+ wxPoint orig(gs_windowUnderMouse->GetClientAreaOrigin());
+ event2.m_x -= orig.x;
+ event2.m_y -= orig.y;
+
event2.SetEventObject(gs_windowUnderMouse);
event2.SetEventType(wxEVT_LEAVE_WINDOW);
gs_windowUnderMouse->GetEventHandler()->ProcessEvent(event2);
// First of all, make sure window manager is up and running. If it is
// not the case, initialize it in default display mode
if ( !g_winMng )
- wxTheApp->SetDisplayMode(wxDisplayModeInfo(wxSize(640, 480), 16));
+ wxTheApp->SetDisplayMode(wxDisplayModeInfo(640, 480, 16));
// generic:
InitBase();