- removed GDI lists from wxMGL
- friendlier wxApp::SetDisplayMode - redirects stdout and stderr to files if __WXDEBUG__ - wxLog initialization and flushing fixes git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12546 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
8b81a824c4
commit
d76048f514
@ -37,12 +37,6 @@
|
|||||||
#include "wx/univ/colschem.h"
|
#include "wx/univ/colschem.h"
|
||||||
#include "wx/mgl/private.h"
|
#include "wx/mgl/private.h"
|
||||||
|
|
||||||
#define MGL_DEBUG
|
|
||||||
|
|
||||||
#if defined(MGL_DEBUG) && !defined(__WXDEBUG__)
|
|
||||||
#undef MGL_DEBUG
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Global data
|
// Global data
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -166,14 +160,14 @@ static bool wxCreateMGL_WM(const wxDisplayModeInfo& displayMode)
|
|||||||
refresh = wxSystemOptions::GetOptionInt(wxT("mgl.screen-refresh"));
|
refresh = wxSystemOptions::GetOptionInt(wxT("mgl.screen-refresh"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mode = MGL_findMode(displayMode.GetScreenSize().x,
|
mode = MGL_findMode(displayMode.GetWidth(),
|
||||||
displayMode.GetScreenSize().y,
|
displayMode.GetHeight(),
|
||||||
displayMode.GetDepth());
|
displayMode.GetDepth());
|
||||||
if ( mode == -1 )
|
if ( mode == -1 )
|
||||||
{
|
{
|
||||||
wxLogError(_("Mode %ix%i-%i not available."),
|
wxLogError(_("Mode %ix%i-%i not available."),
|
||||||
displayMode.GetScreenSize().x,
|
displayMode.GetWidth(),
|
||||||
displayMode.GetScreenSize().y,
|
displayMode.GetHeight(),
|
||||||
displayMode.GetDepth());
|
displayMode.GetDepth());
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -253,12 +247,16 @@ bool wxApp::OnInitGui()
|
|||||||
if ( !wxAppBase::OnInitGui() )
|
if ( !wxAppBase::OnInitGui() )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
#ifdef MGL_DEBUG
|
#ifdef __WXDEBUG__
|
||||||
// That damn MGL redirects stdin and stdout to physical console
|
// MGL redirects stdout and stderr to physical console, so lets redirect
|
||||||
FILE *file = fopen("stderr", "wt");
|
// it to file. Do it only when WXDEBUG environment variable is set
|
||||||
wxLog::SetActiveTarget(new wxLogStderr(file));
|
if ( wxGetEnv(wxT("WXDEBUG"), NULL) )
|
||||||
|
freopen("output.err", "wt", stderr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
wxLog *oldLog = wxLog::SetActiveTarget(new wxLogGui);
|
||||||
|
if ( oldLog ) delete oldLog;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,6 +286,11 @@ void wxApp::OnIdle(wxIdleEvent &event)
|
|||||||
// 'Garbage' collection of windows deleted with Close().
|
// 'Garbage' collection of windows deleted with Close().
|
||||||
DeletePendingObjects();
|
DeletePendingObjects();
|
||||||
|
|
||||||
|
#if wxUSE_LOG
|
||||||
|
// flush the logged messages if any
|
||||||
|
wxLog::FlushActive();
|
||||||
|
#endif // wxUSE_LOG
|
||||||
|
|
||||||
// Send OnIdle events to all windows
|
// Send OnIdle events to all windows
|
||||||
if ( SendIdleEvents() )
|
if ( SendIdleEvents() )
|
||||||
event.RequestMore(TRUE);
|
event.RequestMore(TRUE);
|
||||||
@ -432,14 +435,7 @@ wxIcon wxApp::GetStdIcon(int which) const
|
|||||||
|
|
||||||
void wxApp::CleanUp()
|
void wxApp::CleanUp()
|
||||||
{
|
{
|
||||||
delete gs_rootWindow;
|
|
||||||
|
|
||||||
#if wxUSE_LOG
|
#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
|
// continuing to use user defined log target is unsafe from now on because
|
||||||
// some resources may be already unavailable, so replace it by something
|
// some resources may be already unavailable, so replace it by something
|
||||||
// more safe
|
// more safe
|
||||||
@ -448,6 +444,8 @@ void wxApp::CleanUp()
|
|||||||
delete oldlog;
|
delete oldlog;
|
||||||
#endif // wxUSE_LOG
|
#endif // wxUSE_LOG
|
||||||
|
|
||||||
|
delete gs_rootWindow;
|
||||||
|
|
||||||
wxModule::CleanUpModules();
|
wxModule::CleanUpModules();
|
||||||
|
|
||||||
#if wxUSE_WX_RESOURCES
|
#if wxUSE_WX_RESOURCES
|
||||||
@ -611,6 +609,12 @@ int wxEntry(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#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();
|
retValue = wxTheApp->OnExit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -191,16 +191,9 @@ wxBitmapRefData::~wxBitmapRefData()
|
|||||||
IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandler,wxObject)
|
IMPLEMENT_ABSTRACT_CLASS(wxBitmapHandler,wxObject)
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxBitmap,wxBitmapBase)
|
IMPLEMENT_DYNAMIC_CLASS(wxBitmap,wxBitmapBase)
|
||||||
|
|
||||||
wxBitmap::wxBitmap()
|
|
||||||
{
|
|
||||||
if ( wxTheBitmapList ) wxTheBitmapList->AddBitmap(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
wxBitmap::wxBitmap(int width, int height, int depth)
|
wxBitmap::wxBitmap(int width, int height, int depth)
|
||||||
{
|
{
|
||||||
Create(width, height, depth);
|
Create(width, height, depth);
|
||||||
|
|
||||||
if ( wxTheBitmapList ) wxTheBitmapList->AddBitmap(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -285,8 +278,6 @@ bool wxBitmap::CreateFromXpm(const char **bits)
|
|||||||
|
|
||||||
*this = wxBitmap(img);
|
*this = wxBitmap(img);
|
||||||
|
|
||||||
if ( wxTheBitmapList ) wxTheBitmapList->AddBitmap(this);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -370,15 +361,11 @@ wxImage wxBitmap::ConvertToImage() const
|
|||||||
wxBitmap::wxBitmap(const wxBitmap& bmp)
|
wxBitmap::wxBitmap(const wxBitmap& bmp)
|
||||||
{
|
{
|
||||||
Ref(bmp);
|
Ref(bmp);
|
||||||
|
|
||||||
if ( wxTheBitmapList ) wxTheBitmapList->AddBitmap(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmap::wxBitmap(const wxString &filename, wxBitmapType type)
|
wxBitmap::wxBitmap(const wxString &filename, wxBitmapType type)
|
||||||
{
|
{
|
||||||
LoadFile(filename, type);
|
LoadFile(filename, type);
|
||||||
|
|
||||||
if ( wxTheBitmapList ) wxTheBitmapList->AddBitmap(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmap::wxBitmap(const char bits[], int width, int height, int depth)
|
wxBitmap::wxBitmap(const char bits[], int width, int height, int depth)
|
||||||
@ -393,13 +380,6 @@ wxBitmap::wxBitmap(const char bits[], int width, int height, int depth)
|
|||||||
bdc->clearDevice();
|
bdc->clearDevice();
|
||||||
bdc->putMonoImage(0, 0, width, (width + 7) / 8, height, (void*)bits);
|
bdc->putMonoImage(0, 0, width, (width + 7) / 8, height, (void*)bits);
|
||||||
delete bdc;
|
delete bdc;
|
||||||
|
|
||||||
if ( wxTheBitmapList ) wxTheBitmapList->AddBitmap(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
wxBitmap::~wxBitmap()
|
|
||||||
{
|
|
||||||
if ( wxTheBitmapList ) wxTheBitmapList->DeleteObject(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmap& wxBitmap::operator = (const wxBitmap& bmp)
|
wxBitmap& wxBitmap::operator = (const wxBitmap& bmp)
|
||||||
|
@ -121,18 +121,11 @@ wxBrushRefData::wxBrushRefData(const wxBrushRefData& data)
|
|||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxBrush,wxGDIObject)
|
IMPLEMENT_DYNAMIC_CLASS(wxBrush,wxGDIObject)
|
||||||
|
|
||||||
wxBrush::wxBrush()
|
|
||||||
{
|
|
||||||
if (wxTheBrushList) wxTheBrushList->AddBrush(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
wxBrush::wxBrush(const wxColour &colour, int style)
|
wxBrush::wxBrush(const wxColour &colour, int style)
|
||||||
{
|
{
|
||||||
m_refData = new wxBrushRefData();
|
m_refData = new wxBrushRefData();
|
||||||
M_BRUSHDATA->m_style = style;
|
M_BRUSHDATA->m_style = style;
|
||||||
M_BRUSHDATA->m_colour = colour;
|
M_BRUSHDATA->m_colour = colour;
|
||||||
|
|
||||||
if (wxTheBrushList) wxTheBrushList->AddBrush(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBrush::wxBrush(const wxBitmap &stippleBitmap)
|
wxBrush::wxBrush(const wxBitmap &stippleBitmap)
|
||||||
@ -152,20 +145,11 @@ wxBrush::wxBrush(const wxBitmap &stippleBitmap)
|
|||||||
M_BRUSHDATA->m_style = wxSTIPPLE_MASK_OPAQUE;
|
M_BRUSHDATA->m_style = wxSTIPPLE_MASK_OPAQUE;
|
||||||
else
|
else
|
||||||
M_BRUSHDATA->m_style = wxSTIPPLE;
|
M_BRUSHDATA->m_style = wxSTIPPLE;
|
||||||
|
|
||||||
if (wxTheBrushList) wxTheBrushList->AddBrush(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBrush::wxBrush(const wxBrush &brush)
|
wxBrush::wxBrush(const wxBrush &brush)
|
||||||
{
|
{
|
||||||
Ref(brush);
|
Ref(brush);
|
||||||
|
|
||||||
if (wxTheBrushList) wxTheBrushList->AddBrush(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
wxBrush::~wxBrush()
|
|
||||||
{
|
|
||||||
if (wxTheBrushList) wxTheBrushList->RemoveBrush(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBrush& wxBrush::operator = (const wxBrush& brush)
|
wxBrush& wxBrush::operator = (const wxBrush& brush)
|
||||||
|
@ -150,12 +150,6 @@ wxFontRefData::~wxFontRefData()
|
|||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
|
IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
|
||||||
|
|
||||||
void wxFont::Init()
|
|
||||||
{
|
|
||||||
if (wxTheFontList)
|
|
||||||
wxTheFontList->Append(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxFont::Create(const wxNativeFontInfo& info)
|
bool wxFont::Create(const wxNativeFontInfo& info)
|
||||||
{
|
{
|
||||||
return Create(info.pointSize, info.family, info.style, info.weight,
|
return Create(info.pointSize, info.family, info.style, info.weight,
|
||||||
@ -206,12 +200,6 @@ void wxFont::Unshare()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFont::~wxFont()
|
|
||||||
{
|
|
||||||
if (wxTheFontList)
|
|
||||||
wxTheFontList->DeleteObject(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// accessors
|
// accessors
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@ -79,21 +79,12 @@ wxPenRefData::wxPenRefData(const wxPenRefData& data)
|
|||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxPen,wxGDIObject)
|
IMPLEMENT_DYNAMIC_CLASS(wxPen,wxGDIObject)
|
||||||
|
|
||||||
wxPen::wxPen()
|
|
||||||
{
|
|
||||||
if ( wxThePenList )
|
|
||||||
wxThePenList->AddPen(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
wxPen::wxPen(const wxColour &colour, int width, int style)
|
wxPen::wxPen(const wxColour &colour, int width, int style)
|
||||||
{
|
{
|
||||||
m_refData = new wxPenRefData();
|
m_refData = new wxPenRefData();
|
||||||
M_PENDATA->m_width = width;
|
M_PENDATA->m_width = width;
|
||||||
M_PENDATA->m_style = style;
|
M_PENDATA->m_style = style;
|
||||||
M_PENDATA->m_colour = colour;
|
M_PENDATA->m_colour = colour;
|
||||||
|
|
||||||
if ( wxThePenList )
|
|
||||||
wxThePenList->AddPen(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPen::wxPen(const wxBitmap& stipple, int width)
|
wxPen::wxPen(const wxBitmap& stipple, int width)
|
||||||
@ -107,22 +98,11 @@ wxPen::wxPen(const wxBitmap& stipple, int width)
|
|||||||
M_PENDATA->m_style = wxSTIPPLE;
|
M_PENDATA->m_style = wxSTIPPLE;
|
||||||
M_PENDATA->m_stipple = stipple;
|
M_PENDATA->m_stipple = stipple;
|
||||||
wxBitmapToPixPattern(stipple, &(M_PENDATA->m_pixPattern), NULL);
|
wxBitmapToPixPattern(stipple, &(M_PENDATA->m_pixPattern), NULL);
|
||||||
|
|
||||||
if ( wxThePenList )
|
|
||||||
wxThePenList->AddPen(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPen::wxPen(const wxPen& pen)
|
wxPen::wxPen(const wxPen& pen)
|
||||||
{
|
{
|
||||||
Ref(pen);
|
Ref(pen);
|
||||||
if ( wxThePenList )
|
|
||||||
wxThePenList->AddPen(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
wxPen::~wxPen()
|
|
||||||
{
|
|
||||||
if ( wxThePenList )
|
|
||||||
wxThePenList->RemovePen(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPen& wxPen::operator = (const wxPen& pen)
|
wxPen& wxPen::operator = (const wxPen& pen)
|
||||||
|
@ -132,6 +132,7 @@ static void wxWindowPainter(window_t *wnd, MGLDC *dc)
|
|||||||
static ibool wxWindowMouseHandler(window_t *wnd, event_t *e)
|
static ibool wxWindowMouseHandler(window_t *wnd, event_t *e)
|
||||||
{
|
{
|
||||||
wxWindowMGL *win = (wxWindowMGL*)MGL_wmGetWindowUserData(wnd);
|
wxWindowMGL *win = (wxWindowMGL*)MGL_wmGetWindowUserData(wnd);
|
||||||
|
wxPoint orig(win->GetClientAreaOrigin());
|
||||||
wxPoint where;
|
wxPoint where;
|
||||||
|
|
||||||
MGL_wmCoordGlobalToLocal(win->GetHandle(),
|
MGL_wmCoordGlobalToLocal(win->GetHandle(),
|
||||||
@ -149,8 +150,8 @@ static ibool wxWindowMouseHandler(window_t *wnd, event_t *e)
|
|||||||
wxMouseEvent event;
|
wxMouseEvent event;
|
||||||
event.SetEventObject(win);
|
event.SetEventObject(win);
|
||||||
event.SetTimestamp(e->when);
|
event.SetTimestamp(e->when);
|
||||||
event.m_x = where.x;
|
event.m_x = where.x - orig.x;
|
||||||
event.m_y = where.y;
|
event.m_y = where.y - orig.y;
|
||||||
event.m_shiftDown = e->modifiers & EVT_SHIFTKEY;
|
event.m_shiftDown = e->modifiers & EVT_SHIFTKEY;
|
||||||
event.m_controlDown = e->modifiers & EVT_CTRLSTATE;
|
event.m_controlDown = e->modifiers & EVT_CTRLSTATE;
|
||||||
event.m_altDown = e->modifiers & EVT_LEFTALT;
|
event.m_altDown = e->modifiers & EVT_LEFTALT;
|
||||||
@ -194,6 +195,10 @@ static ibool wxWindowMouseHandler(window_t *wnd, event_t *e)
|
|||||||
e->where_x, e->where_y,
|
e->where_x, e->where_y,
|
||||||
&event2.m_x, &event2.m_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.SetEventObject(gs_windowUnderMouse);
|
||||||
event2.SetEventType(wxEVT_LEAVE_WINDOW);
|
event2.SetEventType(wxEVT_LEAVE_WINDOW);
|
||||||
gs_windowUnderMouse->GetEventHandler()->ProcessEvent(event2);
|
gs_windowUnderMouse->GetEventHandler()->ProcessEvent(event2);
|
||||||
@ -469,7 +474,7 @@ void wxWindowMGL::Init()
|
|||||||
// First of all, make sure window manager is up and running. If it is
|
// First of all, make sure window manager is up and running. If it is
|
||||||
// not the case, initialize it in default display mode
|
// not the case, initialize it in default display mode
|
||||||
if ( !g_winMng )
|
if ( !g_winMng )
|
||||||
wxTheApp->SetDisplayMode(wxDisplayModeInfo(wxSize(640, 480), 16));
|
wxTheApp->SetDisplayMode(wxDisplayModeInfo(640, 480, 16));
|
||||||
|
|
||||||
// generic:
|
// generic:
|
||||||
InitBase();
|
InitBase();
|
||||||
|
Loading…
Reference in New Issue
Block a user