wxMGL update (no, it still doesn't work, I'm backuping it just in case my disk burns)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11250 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -15,7 +15,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/dc.h"
|
#include "wx/dc.h"
|
||||||
#include "wx/window.h"
|
|
||||||
|
class WXDLLEXPORT wxWindowMGL;
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// classes
|
// classes
|
||||||
@@ -29,12 +30,15 @@ class WXDLLEXPORT wxClientDC;
|
|||||||
// wxWindowDC
|
// wxWindowDC
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
//FIXME_MGL
|
|
||||||
class WXDLLEXPORT wxWindowDC : public wxDC
|
class WXDLLEXPORT wxWindowDC : public wxDC
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxWindowDC() {}
|
wxWindowDC() {}
|
||||||
wxWindowDC( wxWindow *win ) {}
|
virtual ~wxWindowDC();
|
||||||
|
wxWindowDC(wxWindow *win);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
wxWindow *m_wnd;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxWindowDC)
|
DECLARE_DYNAMIC_CLASS(wxWindowDC)
|
||||||
@@ -47,10 +51,11 @@ private:
|
|||||||
class WXDLLEXPORT wxClientDC : public wxWindowDC
|
class WXDLLEXPORT wxClientDC : public wxWindowDC
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxClientDC() {}
|
wxClientDC() : wxWindowDC() {}
|
||||||
wxClientDC( wxWindow *win ) {}
|
wxClientDC(wxWindow *win);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
wxWindowMGL *m_wnd;
|
||||||
DECLARE_DYNAMIC_CLASS(wxClientDC)
|
DECLARE_DYNAMIC_CLASS(wxClientDC)
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -58,6 +63,7 @@ private:
|
|||||||
// wxPaintDC
|
// wxPaintDC
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// FIXME_MGL
|
||||||
class WXDLLEXPORT wxPaintDC : public wxClientDC
|
class WXDLLEXPORT wxPaintDC : public wxClientDC
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@@ -26,16 +26,15 @@ class WXDLLEXPORT wxScreenDC;
|
|||||||
// wxScreenDC
|
// wxScreenDC
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
//FIXME_MGL
|
class WXDLLEXPORT wxScreenDC: public wxDC
|
||||||
class WXDLLEXPORT wxScreenDC: public wxPaintDC
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxScreenDC() {}
|
wxScreenDC();
|
||||||
~wxScreenDC() {}
|
~wxScreenDC() {}
|
||||||
|
|
||||||
static bool StartDrawingOnTop( wxWindow *window ) {}
|
static bool StartDrawingOnTop(wxWindow *WXUNUSED(window)) { return TRUE; }
|
||||||
static bool StartDrawingOnTop( wxRect *rect = (wxRect *) NULL ) {}
|
static bool StartDrawingOnTop(wxRect *WXUNUSED(rect) = NULL) { return TRUE; }
|
||||||
static bool EndDrawingOnTop() {}
|
static bool EndDrawingOnTop() { return TRUE; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxScreenDC)
|
DECLARE_DYNAMIC_CLASS(wxScreenDC)
|
||||||
|
@@ -26,19 +26,19 @@ class WXDLLEXPORT wxMenuBar;
|
|||||||
class WXDLLEXPORT wxToolBar;
|
class WXDLLEXPORT wxToolBar;
|
||||||
class WXDLLEXPORT wxStatusBar;
|
class WXDLLEXPORT wxStatusBar;
|
||||||
|
|
||||||
class WXDLLEXPORT wxFrame;
|
class WXDLLEXPORT wxFrameMGL;
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// wxFrame
|
// wxFrame
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
//FIXME_MGL
|
//FIXME_MGL
|
||||||
class WXDLLEXPORT wxFrame : public wxFrameBase
|
class WXDLLEXPORT wxFrameMGL : public wxFrameBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// construction
|
// construction
|
||||||
wxFrame() { Init(); }
|
wxFrameMGL() { Init(); }
|
||||||
wxFrame(wxWindow *parent,
|
wxFrameMGL(wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxString& title,
|
const wxString& title,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
@@ -59,7 +59,7 @@ public:
|
|||||||
long style = wxDEFAULT_FRAME_STYLE,
|
long style = wxDEFAULT_FRAME_STYLE,
|
||||||
const wxString& name = wxFrameNameStr) {}
|
const wxString& name = wxFrameNameStr) {}
|
||||||
|
|
||||||
virtual ~wxFrame() {}
|
virtual ~wxFrameMGL() {}
|
||||||
|
|
||||||
// implement base class pure virtuals
|
// implement base class pure virtuals
|
||||||
virtual void Maximize(bool maximize = TRUE) {}
|
virtual void Maximize(bool maximize = TRUE) {}
|
||||||
@@ -126,7 +126,7 @@ protected:
|
|||||||
virtual void DoGetClientSize( int *width, int *height ) const {}
|
virtual void DoGetClientSize( int *width, int *height ) const {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxFrame)
|
DECLARE_DYNAMIC_CLASS(wxFrameMGL)
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __WX_FRAME_H__
|
#endif // __WX_FRAME_H__
|
||||||
|
@@ -23,6 +23,7 @@ class WXDLLEXPORT wxBitmap;
|
|||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
extern MGLDevCtx *g_displayDC;
|
extern MGLDevCtx *g_displayDC;
|
||||||
|
extern winmng_t *g_winMng;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// helper functions
|
// helper functions
|
||||||
@@ -48,4 +49,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
extern bool wxCreateMGL_WM();
|
||||||
|
extern void wxDestroyMGL_WM();
|
||||||
|
|
||||||
#endif // _WX_PRIVATE_H_
|
#endif // _WX_PRIVATE_H_
|
||||||
|
@@ -28,7 +28,7 @@ public:
|
|||||||
{ Init(); }
|
{ Init(); }
|
||||||
~wxTimer() {}
|
~wxTimer() {}
|
||||||
|
|
||||||
virtual bool Start( int millisecs = -1, bool oneShot = FALSE ) {}
|
virtual bool Start( int millisecs = -1, bool oneShot = FALSE ) { return TRUE; }
|
||||||
virtual void Stop() {}
|
virtual void Stop() {}
|
||||||
|
|
||||||
virtual bool IsRunning() const { return m_tag != -1; }
|
virtual bool IsRunning() const { return m_tag != -1; }
|
||||||
|
@@ -1,127 +1,159 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: window.h
|
// Name: wx/mgl/window.h
|
||||||
// Purpose:
|
// Purpose: wxWindow class
|
||||||
// Author: Vaclav Slavik
|
// Author: Vaclav Slavik
|
||||||
// Id: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
|
// Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef _WX_WINDOW_H_
|
||||||
|
#define _WX_WINDOW_H_
|
||||||
|
|
||||||
#ifndef __WX_WINDOW_H__
|
// ---------------------------------------------------------------------------
|
||||||
#define __WX_WINDOW_H__
|
// headers
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma interface "window.h"
|
#pragma interface "window.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "wx/font.h"
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
struct window_t;
|
||||||
// wxWindow
|
class MGLDevCtx;
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// wxWindow declaration for MGL
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
class WXDLLEXPORT wxWindowMGL : public wxWindowBase
|
class WXDLLEXPORT wxWindowMGL : public wxWindowBase
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxWindowMGL)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// creating the window
|
wxWindowMGL() { Init(); }
|
||||||
// -------------------
|
|
||||||
wxWindowMGL() {}
|
|
||||||
wxWindowMGL(wxWindow *parent,
|
wxWindowMGL(wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = 0,
|
long style = 0,
|
||||||
const wxString& name = wxPanelNameStr) {}
|
const wxString& name = wxPanelNameStr)
|
||||||
|
{
|
||||||
|
Init();
|
||||||
|
Create(parent, id, pos, size, style, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~wxWindowMGL();
|
||||||
|
|
||||||
bool Create(wxWindow *parent,
|
bool Create(wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = 0,
|
long style = 0,
|
||||||
const wxString& name = wxPanelNameStr) {}
|
const wxString& name = wxPanelNameStr);
|
||||||
virtual ~wxWindowMGL() {}
|
|
||||||
|
|
||||||
// implement base class (pure) virtual methods
|
virtual void Raise();
|
||||||
// -------------------------------------------
|
virtual void Lower();
|
||||||
virtual bool Destroy() {return TRUE;}
|
|
||||||
|
|
||||||
virtual void Raise() {}
|
virtual bool Show(bool show = TRUE);
|
||||||
virtual void Lower() {}
|
|
||||||
|
|
||||||
virtual bool Show( bool show = TRUE ) {return TRUE;}
|
virtual void SetFocus();
|
||||||
virtual bool Enable( bool enable = TRUE ) {return TRUE;}
|
|
||||||
|
|
||||||
virtual bool IsRetained() const {return TRUE;}
|
virtual bool Reparent(wxWindowBase *newParent);
|
||||||
|
|
||||||
virtual void SetFocus() {}
|
virtual void WarpPointer(int x, int y);
|
||||||
virtual bool AcceptsFocus() const {return TRUE;}
|
virtual void CaptureMouse();
|
||||||
|
virtual void ReleaseMouse();
|
||||||
|
|
||||||
virtual bool Reparent( wxWindowBase *newParent ) {return TRUE;}
|
virtual void Refresh(bool eraseBackground = TRUE,
|
||||||
|
const wxRect *rect = (const wxRect *) NULL);
|
||||||
|
virtual void Update();
|
||||||
|
virtual void Clear();
|
||||||
|
virtual void Freeze();
|
||||||
|
virtual void Thaw();
|
||||||
|
|
||||||
virtual void WarpPointer(int x, int y) {}
|
virtual bool SetCursor(const wxCursor &cursor);
|
||||||
virtual void CaptureMouse() {}
|
virtual bool SetFont(const wxFont &font) { m_font = font; return TRUE; }
|
||||||
virtual void ReleaseMouse() {}
|
|
||||||
|
|
||||||
virtual void Refresh( bool eraseBackground = TRUE,
|
virtual int GetCharHeight() const;
|
||||||
const wxRect *rect = (const wxRect *) NULL ) {}
|
virtual int GetCharWidth() const;
|
||||||
virtual void Clear() {}
|
|
||||||
|
|
||||||
virtual bool SetBackgroundColour( const wxColour &colour ) {return TRUE;}
|
|
||||||
virtual bool SetForegroundColour( const wxColour &colour ) {return TRUE;}
|
|
||||||
virtual bool SetCursor( const wxCursor &cursor ) {return TRUE;}
|
|
||||||
virtual bool SetFont( const wxFont &font ) {return TRUE;}
|
|
||||||
|
|
||||||
virtual int GetCharHeight() const {return 0;}
|
|
||||||
virtual int GetCharWidth() const {return 0;}
|
|
||||||
virtual void GetTextExtent(const wxString& string,
|
virtual void GetTextExtent(const wxString& string,
|
||||||
int *x, int *y,
|
int *x, int *y,
|
||||||
int *descent = (int *) NULL,
|
int *descent = (int *) NULL,
|
||||||
int *externalLeading = (int *) NULL,
|
int *externalLeading = (int *) NULL,
|
||||||
const wxFont *theFont = (const wxFont *) NULL)
|
const wxFont *theFont = (const wxFont *) NULL)
|
||||||
const {}
|
const;
|
||||||
|
|
||||||
virtual bool DoPopupMenu( wxMenu *menu, int x, int y ) {return TRUE;}
|
|
||||||
|
|
||||||
virtual void SetScrollbar( int orient, int pos, int thumbVisible,
|
|
||||||
int range, bool refresh = TRUE ) {}
|
|
||||||
virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE ) {}
|
|
||||||
virtual int GetScrollPos( int orient ) const {return 0;}
|
|
||||||
virtual int GetScrollThumb( int orient ) const {return 0;}
|
|
||||||
virtual int GetScrollRange( int orient ) const {return 0;}
|
|
||||||
virtual void ScrollWindow( int dx, int dy,
|
|
||||||
const wxRect* rect = (wxRect *) NULL ) {}
|
|
||||||
|
|
||||||
#if wxUSE_DRAG_AND_DROP
|
#if wxUSE_DRAG_AND_DROP
|
||||||
virtual void SetDropTarget( wxDropTarget *dropTarget ) {}
|
virtual void SetDropTarget(wxDropTarget *dropTarget);
|
||||||
#endif // wxUSE_DRAG_AND_DROP
|
#endif // wxUSE_DRAG_AND_DROP
|
||||||
|
|
||||||
virtual WXWidget GetHandle() const { return NULL; }
|
// Accept files for dragging
|
||||||
|
virtual void DragAcceptFiles(bool accept);
|
||||||
|
|
||||||
/* For compatibility across platforms (not in event table) */
|
#if WXWIN_COMPATIBILITY
|
||||||
void OnIdle(wxIdleEvent& WXUNUSED(event)) {};
|
// event handlers
|
||||||
|
// Handle a control command
|
||||||
|
virtual void OnCommand(wxWindow& win, wxCommandEvent& event);
|
||||||
|
|
||||||
|
// Override to define new behaviour for default action (e.g. double
|
||||||
|
// clicking on a listbox)
|
||||||
|
virtual void OnDefaultAction(wxControl * WXUNUSED(initiatingItem)) { }
|
||||||
|
#endif // WXWIN_COMPATIBILITY
|
||||||
|
|
||||||
|
virtual WXWidget GetHandle() const { return m_wnd; }
|
||||||
|
|
||||||
|
|
||||||
|
// implementation from now on
|
||||||
|
// --------------------------
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// the window handle
|
||||||
|
struct window_t *m_wnd;
|
||||||
|
// whether there should be wxEraseEvent before wxPaintEvent or not
|
||||||
|
// (see wxWindow::Refresh)
|
||||||
|
bool m_frozen;
|
||||||
|
bool m_refreshAfterThaw;
|
||||||
|
wxFont m_font;
|
||||||
|
|
||||||
// implement the base class pure virtuals
|
// implement the base class pure virtuals
|
||||||
virtual void DoClientToScreen( int *x, int *y ) const {}
|
virtual void DoClientToScreen( int *x, int *y ) const;
|
||||||
virtual void DoScreenToClient( int *x, int *y ) const {}
|
virtual void DoScreenToClient( int *x, int *y ) const;
|
||||||
virtual void DoGetPosition( int *x, int *y ) const {}
|
virtual void DoGetPosition( int *x, int *y ) const;
|
||||||
virtual void DoGetSize( int *width, int *height ) const {}
|
virtual void DoGetSize( int *width, int *height ) const;
|
||||||
virtual void DoGetClientSize( int *width, int *height ) const {}
|
virtual void DoGetClientSize( int *width, int *height ) const;
|
||||||
virtual void DoSetSize(int x, int y,
|
virtual void DoSetSize(int x, int y,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int sizeFlags = wxSIZE_AUTO) {}
|
int sizeFlags = wxSIZE_AUTO);
|
||||||
virtual void DoSetClientSize(int width, int height) {}
|
virtual void DoSetClientSize(int width, int height);
|
||||||
virtual void DoMoveWindow(int x, int y, int width, int height) {}
|
|
||||||
|
|
||||||
#if wxUSE_TOOLTIPS
|
// move the window to the specified location and resize it: this is called
|
||||||
virtual void DoSetToolTip( wxToolTip *tip ) {}
|
// from both DoSetSize() and DoSetClientSize() and would usually just call
|
||||||
#endif // wxUSE_TOOLTIPS
|
// ::MoveWindow() except for composite controls which will want to arrange
|
||||||
|
// themselves inside the given rectangle
|
||||||
// common part of all ctors (can't be virtual because called from ctor)
|
virtual void DoMoveWindow(int x, int y, int width, int height);
|
||||||
void Init() {}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// common part of all ctors
|
||||||
|
void Init();
|
||||||
|
// counterpart to SetFocus
|
||||||
|
void KillFocus();
|
||||||
|
|
||||||
|
MGLDevCtx *m_paintMGLDC;
|
||||||
|
friend class wxPaintDC;
|
||||||
|
|
||||||
|
void OnEraseBackground(wxEraseEvent& event);
|
||||||
|
void OnSetFocus(wxFocusEvent& event);
|
||||||
|
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxWindowMGL);
|
||||||
DECLARE_NO_COPY_CLASS(wxWindowMGL);
|
DECLARE_NO_COPY_CLASS(wxWindowMGL);
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
|
|
||||||
|
public:
|
||||||
|
void HandlePaint(MGLDevCtx *dc);
|
||||||
|
// needed by wxWindowPainter
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ___WX_WINDOW_H__
|
|
||||||
|
#endif
|
||||||
|
// _WX_WINDOW_H_
|
||||||
|
@@ -21,11 +21,6 @@
|
|||||||
// Global data
|
// Global data
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// MGL's display DC:
|
|
||||||
MGLDevCtx *g_displayDC = NULL;
|
|
||||||
|
|
||||||
// ----
|
|
||||||
|
|
||||||
wxApp *wxTheApp = (wxApp *) NULL;
|
wxApp *wxTheApp = (wxApp *) NULL;
|
||||||
wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NULL;
|
wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NULL;
|
||||||
|
|
||||||
|
@@ -306,7 +306,7 @@ wxImage wxBitmap::ConvertToImage() const
|
|||||||
{
|
{
|
||||||
wxCHECK_MSG( Ok(), FALSE, wxT("invalid bitmap") );
|
wxCHECK_MSG( Ok(), FALSE, wxT("invalid bitmap") );
|
||||||
|
|
||||||
long width, height;
|
int width, height;
|
||||||
width = GetWidth();
|
width = GetWidth();
|
||||||
height = GetHeight();
|
height = GetHeight();
|
||||||
|
|
||||||
@@ -517,6 +517,7 @@ MGLDevCtx *wxBitmap::CreateTmpDC() const
|
|||||||
case 4: cnt = 16; break;
|
case 4: cnt = 16; break;
|
||||||
case 8: cnt = 256; break;
|
case 8: cnt = 256; break;
|
||||||
default:
|
default:
|
||||||
|
cnt = 0;
|
||||||
wxFAIL_MSG( wxT("bitmap with this depth cannot have palette") );
|
wxFAIL_MSG( wxT("bitmap with this depth cannot have palette") );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -765,7 +765,7 @@ void wxDC::DrawAnyText(const wxString& text, wxCoord x, wxCoord y)
|
|||||||
if ( m_font.GetUnderlined() )
|
if ( m_font.GetUnderlined() )
|
||||||
{
|
{
|
||||||
int x1 = xx, y1 = yy;
|
int x1 = xx, y1 = yy;
|
||||||
int x2, y2;
|
int x2 = 0 , y2 = 0;
|
||||||
int w = m_MGLDC->textWidth(c_text);
|
int w = m_MGLDC->textWidth(c_text);
|
||||||
m_MGLDC->underScoreLocation(x1, y1, c_text);
|
m_MGLDC->underScoreLocation(x1, y1, c_text);
|
||||||
switch (m_MGLDC->getTextDirection())
|
switch (m_MGLDC->getTextDirection())
|
||||||
@@ -1397,7 +1397,7 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest,
|
|||||||
xsrc = source->LogicalToDeviceX(xsrc);
|
xsrc = source->LogicalToDeviceX(xsrc);
|
||||||
ysrc = source->LogicalToDeviceY(ysrc);
|
ysrc = source->LogicalToDeviceY(ysrc);
|
||||||
|
|
||||||
/* TODO: use the mask origin when drawing transparently */
|
/* FIXME_MGL: use the mask origin when drawing transparently */
|
||||||
if (xsrcMask == -1 && ysrcMask == -1)
|
if (xsrcMask == -1 && ysrcMask == -1)
|
||||||
{
|
{
|
||||||
xsrcMask = xsrc; ysrcMask = ysrc;
|
xsrcMask = xsrc; ysrcMask = ysrc;
|
||||||
|
@@ -11,9 +11,40 @@
|
|||||||
#pragma implementation "dcclient.h"
|
#pragma implementation "dcclient.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/dcclient.h"
|
// For compilers that support precompilation, includes "wx.h".
|
||||||
#include "wx/dcmemory.h"
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/dcclient.h"
|
||||||
|
#include "wx/window.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <mgraph.hpp>
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
|
IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxClientDC)
|
IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxClientDC)
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxClientDC,wxWindowDC)
|
IMPLEMENT_DYNAMIC_CLASS(wxClientDC,wxWindowDC)
|
||||||
|
|
||||||
|
wxWindowDC::wxWindowDC(wxWindow *win) : m_wnd(win)
|
||||||
|
{
|
||||||
|
MGLDC *dc = MGL_wmBeginPaint(m_wnd->GetHandle());
|
||||||
|
SetMGLDC(new MGLDevCtx(dc), FALSE);
|
||||||
|
// FIXME_MGL -- correctly handle setting device origin and
|
||||||
|
// clipping regions
|
||||||
|
}
|
||||||
|
|
||||||
|
wxWindowDC::~wxWindowDC()
|
||||||
|
{
|
||||||
|
MGL_wmEndPaint(m_wnd->GetHandle());
|
||||||
|
}
|
||||||
|
|
||||||
|
wxClientDC::wxClientDC(wxWindow *win) : wxWindowDC(win)
|
||||||
|
{
|
||||||
|
wxRect r = m_wnd->GetClientRect();
|
||||||
|
SetClippingRegion(r);
|
||||||
|
SetDeviceOrigin(r.x, r.y);
|
||||||
|
}
|
||||||
|
@@ -1,9 +1,8 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: dcscreen.cpp
|
// Name: dcscreen.cpp
|
||||||
// Purpose:
|
// Author: Vaclav Slavik
|
||||||
// Author: Robert Roebling
|
|
||||||
// Id: $Id$
|
// Id: $Id$
|
||||||
// Copyright: (c) 1998 Robert Roebling
|
// Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@@ -11,8 +10,19 @@
|
|||||||
#pragma implementation "dcscreen.h"
|
#pragma implementation "dcscreen.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// For compilers that support precompilation, includes "wx.h".
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "wx/dcscreen.h"
|
#include "wx/dcscreen.h"
|
||||||
#include "wx/window.h"
|
#include "wx/mgl/private.h"
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxDC)
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxScreenDC,wxPaintDC)
|
wxScreenDC::wxScreenDC() : wxDC()
|
||||||
|
{
|
||||||
|
SetMGLDC(g_displayDC, FALSE /* no ownership */);
|
||||||
|
}
|
||||||
|
@@ -20,4 +20,4 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/frame.h"
|
#include "wx/frame.h"
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxFrame,wxWindow)
|
IMPLEMENT_DYNAMIC_CLASS(wxFrameMGL,wxWindow)
|
||||||
|
@@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
#include "wx/intl.h"
|
#include "wx/intl.h"
|
||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
|
|
||||||
#include "wx/process.h"
|
#include "wx/process.h"
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@@ -26,6 +25,8 @@
|
|||||||
#include "wx/unix/execute.h"
|
#include "wx/unix/execute.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "wx/mgl/private.h"
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// misc.
|
// misc.
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@@ -39,20 +40,23 @@ void wxBell()
|
|||||||
// display characterstics
|
// display characterstics
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
extern MGLDevCtx *g_displayDC;
|
void wxDisplaySize(int *width, int *height)
|
||||||
|
|
||||||
void wxDisplaySize( int *width, int *height )
|
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( g_displayDC, wxT("MGL display DC not created yet.") );
|
wxASSERT_MSG( g_displayDC, wxT("MGL display DC not created yet.") );
|
||||||
if (width) *width = g_displayDC->sizex();
|
if (width) *width = g_displayDC->sizex();
|
||||||
if (height) *height = g_displayDC->sizey();
|
if (height) *height = g_displayDC->sizey();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGetMousePosition( int* x, int* y )
|
void wxGetMousePosition(int* x, int* y)
|
||||||
{
|
{
|
||||||
#if 0 // FIXME_MGL
|
MS_getPos(x, y);
|
||||||
gdk_window_get_pointer( (GdkWindow*) NULL, x, y, (GdkModifierType*) NULL );
|
}
|
||||||
#endif
|
|
||||||
|
wxPoint wxGetMousePosition()
|
||||||
|
{
|
||||||
|
wxPoint pt;
|
||||||
|
wxGetMousePosition(&pt.x, &pt.y);
|
||||||
|
return pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxColourDisplay()
|
bool wxColourDisplay()
|
||||||
@@ -72,7 +76,7 @@ int wxDisplayDepth()
|
|||||||
int wxGetOsVersion(int *majorVsn, int *minorVsn)
|
int wxGetOsVersion(int *majorVsn, int *minorVsn)
|
||||||
{
|
{
|
||||||
#if 0 // FIXME_MGL
|
#if 0 // FIXME_MGL
|
||||||
// FIXME_MGL : wxGetOsVersion, too
|
// FIXME_MGL : fix wxGetOsVersion, too
|
||||||
if (majorVsn) *majorVsn = GTK_MAJOR_VERSION;
|
if (majorVsn) *majorVsn = GTK_MAJOR_VERSION;
|
||||||
if (minorVsn) *minorVsn = GTK_MINOR_VERSION;
|
if (minorVsn) *minorVsn = GTK_MINOR_VERSION;
|
||||||
|
|
||||||
|
@@ -1,33 +1,787 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: gtk/window.cpp
|
// Name: src/mgl/window.cpp
|
||||||
// Purpose:
|
// Purpose: wxWindow
|
||||||
// Author: Robert Roebling
|
// Author: Vaclav Slavik
|
||||||
// Id: $Id$
|
// (based on GTK & MSW implementations)
|
||||||
// Copyright: (c) 1998 Robert Roebling, Julian Smart
|
// RCS-ID: $Id$
|
||||||
// Licence: wxWindows licence
|
// Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
|
||||||
|
// Licence: wxWindows license
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
// declarations
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// headers
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation "window.h"
|
#pragma implementation "window.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/defs.h"
|
// For compilers that support precompilation, includes "wx.h".
|
||||||
#include "wx/window.h"
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxWindowMGL, wxWindowBase)
|
#ifdef __BORLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
wxWindow *g_captureWindow = NULL;
|
#ifndef WX_PRECOMP
|
||||||
wxWindow *g_focusWindow = NULL;
|
#include "wx/window.h"
|
||||||
|
#include "wx/accel.h"
|
||||||
|
#include "wx/setup.h"
|
||||||
|
#include "wx/dc.h"
|
||||||
|
#include "wx/dcclient.h"
|
||||||
|
#include "wx/utils.h"
|
||||||
|
#include "wx/app.h"
|
||||||
|
#include "wx/panel.h"
|
||||||
|
#include "wx/caret.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/* static */
|
#if wxUSE_DRAG_AND_DROP
|
||||||
wxWindow *wxWindowBase::GetCapture()
|
#include "wx/dnd.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "wx/log.h"
|
||||||
|
#include "wx/sysopt.h"
|
||||||
|
#include "wx/mgl/private.h"
|
||||||
|
#include "wx/intl.h"
|
||||||
|
#include "wx/dcscreen.h"
|
||||||
|
|
||||||
|
#include <mgraph.hpp>
|
||||||
|
|
||||||
|
#if wxUSE_TOOLTIPS
|
||||||
|
#include "wx/tooltip.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// global variables
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// MGL window manager and associated DC.
|
||||||
|
winmng_t *g_winMng = NULL;
|
||||||
|
MGLDevCtx *g_displayDC = NULL;
|
||||||
|
|
||||||
|
extern wxList WXDLLEXPORT wxPendingDelete;
|
||||||
|
// FIXME_MGL -- ???
|
||||||
|
|
||||||
|
static wxWindowMGL *g_focusedWindow;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// constants
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Custom identifiers used to distinguish between various event handlers
|
||||||
|
// and capture handlers passed to MGL_wm
|
||||||
|
enum
|
||||||
{
|
{
|
||||||
return (wxWindow *)g_captureWindow;
|
wxMGL_CAPTURE_MOUSE = 1,
|
||||||
|
wxMGL_CAPTURE_KEYB = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// private functions
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static void wxWindowPainter(window_t *wnd, MGLDC *dc);
|
||||||
|
|
||||||
|
// wxCreateMGL_WM creates MGL display DC and associates it with winmng_t
|
||||||
|
// structure. Dimensions and depth of the DC are fetched from wxSystemOptions
|
||||||
|
// object.
|
||||||
|
// This function is *not* called from wxApp's initialization but rather at
|
||||||
|
// the time when WM is needed, i.e. when first wxWindow is created. This
|
||||||
|
// has two important effects:
|
||||||
|
// a) it is possible to write windowless wxMGL apps
|
||||||
|
// b) the app has plenty of time in wxApp::OnInit to feed wxSystemOptions
|
||||||
|
// with desired settings
|
||||||
|
|
||||||
|
bool wxCreateMGL_WM()
|
||||||
|
{
|
||||||
|
int mode;
|
||||||
|
int width = 640, height = 480, depth = 16;
|
||||||
|
int refresh = MGL_DEFAULT_REFRESH;
|
||||||
|
|
||||||
|
#if wxUSE_SYSTEM_OPTIONS
|
||||||
|
if ( wxSystemOptions::HasOption(wxT("mgl.screen-width") )
|
||||||
|
width = wxSystemOptions::GetOptionInt(wxT("mgl.screen-width"));
|
||||||
|
if ( wxSystemOptions::HasOption(wxT("mgl.screen-height") )
|
||||||
|
height = wxSystemOptions::GetOptionInt(wxT("mgl.screen-height"));
|
||||||
|
if ( wxSystemOptions::HasOption(wxT("mgl.screen-depth") )
|
||||||
|
depth = wxSystemOptions::GetOptionInt(wxT("mgl.screen-depth"));
|
||||||
|
if ( wxSystemOptions::HasOption(wxT("mgl.screen-refresh") )
|
||||||
|
refresh = wxSystemOptions::GetOptionInt(wxT("mgl.screen-refresh"));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
mode = MGL_findMode(width, height, depth);
|
||||||
|
if ( mode == -1 )
|
||||||
|
{
|
||||||
|
wxLogWarning(_("Mode %ix%i-%i not available, falling back to default mode."), width, height, depth);
|
||||||
|
mode = 0; // always available
|
||||||
|
}
|
||||||
|
g_displayDC = new MGLDisplayDC(mode, 1, refresh);
|
||||||
|
if ( !g_displayDC->isValid() )
|
||||||
|
{
|
||||||
|
delete g_displayDC;
|
||||||
|
g_displayDC = NULL;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_winMng = MGL_wmCreate(g_displayDC->getDC());
|
||||||
|
if (!g_winMng)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxDestroyMGL_WM()
|
||||||
|
{
|
||||||
|
if (g_winMng)
|
||||||
|
{
|
||||||
|
MGL_wmDestroy(g_winMng);
|
||||||
|
g_winMng = NULL;
|
||||||
|
}
|
||||||
|
delete g_displayDC;
|
||||||
|
g_displayDC = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// event tables
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// in wxUniv/MSW this class is abstract because it doesn't have DoPopupMenu()
|
||||||
|
// method
|
||||||
|
IMPLEMENT_ABSTRACT_CLASS(wxWindowMGL, wxWindowBase)
|
||||||
|
|
||||||
|
BEGIN_EVENT_TABLE(wxWindowMGL, wxWindowBase)
|
||||||
|
EVT_ERASE_BACKGROUND(wxWindowMGL::OnEraseBackground)
|
||||||
|
EVT_SET_FOCUS(wxWindowMGL::OnSetFocus)
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
// implementation
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// constructors and such
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void wxWindowMGL::Init()
|
||||||
|
{
|
||||||
|
// generic:
|
||||||
|
InitBase();
|
||||||
|
|
||||||
|
// mgl specific:
|
||||||
|
if ( !g_winMng && !wxCreateMGL_WM() )
|
||||||
|
wxFatalError(_T("Can't initalize MGL, aborting!"));
|
||||||
|
|
||||||
|
m_wnd = NULL;
|
||||||
|
m_isShown = TRUE;
|
||||||
|
m_isBeingDeleted = FALSE;
|
||||||
|
m_isEnabled = TRUE;
|
||||||
|
m_frozen = FALSE;
|
||||||
|
m_paintMGLDC = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
wxWindowMGL::~wxWindowMGL()
|
||||||
|
{
|
||||||
|
m_isBeingDeleted = TRUE;
|
||||||
|
|
||||||
|
if ( g_focusedWindow == this )
|
||||||
|
g_focusedWindow = NULL;
|
||||||
|
#if 0 // -- fixme - do we need this?
|
||||||
|
// 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.
|
||||||
|
// If we'd do it the other way around, children wouldn't be able
|
||||||
|
// find their parent frame (see above).
|
||||||
|
DestroyChildren();
|
||||||
|
|
||||||
|
if ( m_parent )
|
||||||
|
m_parent->RemoveChild(this);
|
||||||
|
|
||||||
|
if ( m_wnd )
|
||||||
|
MGL_wmDestroyWindow(m_wnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
// real construction (Init() must have been called before!)
|
||||||
|
bool wxWindowMGL::Create(wxWindow *parent,
|
||||||
|
wxWindowID id,
|
||||||
|
const wxPoint& pos,
|
||||||
|
const wxSize& size,
|
||||||
|
long style,
|
||||||
|
const wxString& name)
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( parent, FALSE, wxT("can't create wxWindow without parent") );
|
||||||
|
|
||||||
|
if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
parent->AddChild(this);
|
||||||
|
|
||||||
|
if ( style & wxPOPUP_WINDOW )
|
||||||
|
{
|
||||||
|
// it is created hidden as other top level windows
|
||||||
|
m_isShown = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_wnd = MGL_wmCreateWindow(g_winMng,
|
||||||
|
parent ? parent->GetHandle() : NULL,
|
||||||
|
pos.x, pos.y, size.x, size.y);
|
||||||
|
MGL_wmSetWindowUserData(m_wnd, (void*) this);
|
||||||
|
MGL_wmSetWindowPainter(m_wnd, wxWindowPainter);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// basic operations
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void wxWindowMGL::SetFocus()
|
||||||
|
{
|
||||||
|
if (g_focusedWindow)
|
||||||
|
g_focusedWindow->KillFocus();
|
||||||
|
|
||||||
|
g_focusedWindow = this;
|
||||||
|
|
||||||
|
MGL_wmCaptureEvents(GetHandle(), EVT_KEYEVT | EVT_JOYEVT, wxMGL_CAPTURE_KEYB);
|
||||||
|
|
||||||
|
wxPanel *panel = wxDynamicCast(GetParent(), wxPanel);
|
||||||
|
if (panel)
|
||||||
|
panel->SetLastFocus((wxWindow*)this);
|
||||||
|
|
||||||
|
#if wxUSE_CARET
|
||||||
|
// caret needs to be informed about focus change
|
||||||
|
wxCaret *caret = GetCaret();
|
||||||
|
if (caret)
|
||||||
|
caret->OnSetFocus();
|
||||||
|
#endif // wxUSE_CARET
|
||||||
|
|
||||||
|
if (IsTopLevel())
|
||||||
|
{
|
||||||
|
wxActivateEvent event(wxEVT_ACTIVATE, TRUE, GetId());
|
||||||
|
event.SetEventObject(this);
|
||||||
|
GetEventHandler()->ProcessEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxFocusEvent event(wxEVT_SET_FOCUS, GetId());
|
||||||
|
event.SetEventObject(this);
|
||||||
|
GetEventHandler()->ProcessEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxWindowMGL::KillFocus()
|
||||||
|
{
|
||||||
|
if ( g_focusedWindow != this ) return;
|
||||||
|
g_focusedWindow = NULL;
|
||||||
|
|
||||||
|
MGL_wmUncaptureEvents(GetHandle(), wxMGL_CAPTURE_KEYB);
|
||||||
|
|
||||||
|
#if wxUSE_CARET
|
||||||
|
// caret needs to be informed about focus change
|
||||||
|
wxCaret *caret = GetCaret();
|
||||||
|
if (caret)
|
||||||
|
caret->OnKillFocus();
|
||||||
|
#endif // wxUSE_CARET
|
||||||
|
|
||||||
|
if (IsTopLevel())
|
||||||
|
{
|
||||||
|
wxActivateEvent event(wxEVT_ACTIVATE, FALSE, GetId());
|
||||||
|
event.SetEventObject(this);
|
||||||
|
GetEventHandler()->ProcessEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxFocusEvent event(wxEVT_KILL_FOCUS, GetId());
|
||||||
|
event.SetEventObject(this);
|
||||||
|
GetEventHandler()->ProcessEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// this wxWindowBase function is implemented here (in platform-specific file)
|
||||||
|
// because it is static and so couldn't be made virtual
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
wxWindow *wxWindowBase::FindFocus()
|
wxWindow *wxWindowBase::FindFocus()
|
||||||
{
|
{
|
||||||
// the cast is necessary when we compile in wxUniversal mode
|
return (wxWindow*)g_focusedWindow;
|
||||||
return (wxWindow *)g_focusWindow;
|
}
|
||||||
|
|
||||||
|
bool wxWindowMGL::Show(bool show)
|
||||||
|
{
|
||||||
|
if ( !wxWindowBase::Show(show) )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
MGL_wmShowWindow(m_wnd, show);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Raise the window to the top of the Z order
|
||||||
|
void wxWindowMGL::Raise()
|
||||||
|
{
|
||||||
|
MGL_wmRaiseWindow(m_wnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lower the window to the bottom of the Z order
|
||||||
|
void wxWindowMGL::Lower()
|
||||||
|
{
|
||||||
|
MGL_wmLowerWindow(m_wnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxWindowMGL::CaptureMouse()
|
||||||
|
{
|
||||||
|
MGL_wmCaptureEvents(m_wnd, EVT_MOUSEEVT, wxMGL_CAPTURE_MOUSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxWindowMGL::ReleaseMouse()
|
||||||
|
{
|
||||||
|
MGL_wmUncaptureEvents(m_wnd, wxMGL_CAPTURE_MOUSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* static */ wxWindow *wxWindowBase::GetCapture()
|
||||||
|
{
|
||||||
|
for (captureentry_t *c = g_winMng->capturedEvents; c; c = c->next)
|
||||||
|
{
|
||||||
|
if ( c->id == wxMGL_CAPTURE_MOUSE )
|
||||||
|
return (wxWindow*)c->wnd->userData;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxWindowMGL::SetCursor(const wxCursor& cursor)
|
||||||
|
{
|
||||||
|
if ( !wxWindowBase::SetCursor(cursor) )
|
||||||
|
{
|
||||||
|
// no change
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( m_cursor.Ok() )
|
||||||
|
MGL_wmSetWindowCursor(m_wnd, *m_cursor.GetMGLCursor());
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxWindowMGL::WarpPointer(int x, int y)
|
||||||
|
{
|
||||||
|
ClientToScreen(&x, &y);
|
||||||
|
EVT_setMousePos(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if WXWIN_COMPATIBILITY
|
||||||
|
// If nothing defined for this, try the parent.
|
||||||
|
// E.g. we may be a button loaded from a resource, with no callback function
|
||||||
|
// defined.
|
||||||
|
void wxWindowMGL::OnCommand(wxWindow& win, wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
if ( GetEventHandler()->ProcessEvent(event) )
|
||||||
|
return;
|
||||||
|
if ( m_parent )
|
||||||
|
m_parent->GetEventHandler()->OnCommand(win, event);
|
||||||
|
}
|
||||||
|
#endif // WXWIN_COMPATIBILITY_2
|
||||||
|
|
||||||
|
#if WXWIN_COMPATIBILITY
|
||||||
|
wxObject* wxWindowMGL::GetChild(int number) const
|
||||||
|
{
|
||||||
|
// Return a pointer to the Nth object in the Panel
|
||||||
|
wxNode *node = GetChildren().First();
|
||||||
|
int n = number;
|
||||||
|
while (node && n--)
|
||||||
|
node = node->Next();
|
||||||
|
if ( node )
|
||||||
|
{
|
||||||
|
wxObject *obj = (wxObject *)node->Data();
|
||||||
|
return(obj);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif // WXWIN_COMPATIBILITY
|
||||||
|
|
||||||
|
// Set this window to be the child of 'parent'.
|
||||||
|
bool wxWindowMGL::Reparent(wxWindowBase *parent)
|
||||||
|
{
|
||||||
|
if ( !wxWindowBase::Reparent(parent) )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
MGL_wmReparentWindow(m_wnd, parent->GetHandle());
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// drag and drop
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#if wxUSE_DRAG_AND_DROP
|
||||||
|
|
||||||
|
void wxWindowMGL::SetDropTarget(wxDropTarget *pDropTarget)
|
||||||
|
{
|
||||||
|
if ( m_dropTarget != 0 ) {
|
||||||
|
m_dropTarget->Revoke(m_hWnd);
|
||||||
|
delete m_dropTarget;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_dropTarget = pDropTarget;
|
||||||
|
if ( m_dropTarget != 0 )
|
||||||
|
m_dropTarget->Register(m_hWnd);
|
||||||
|
}
|
||||||
|
// FIXME_MGL
|
||||||
|
#endif // wxUSE_DRAG_AND_DROP
|
||||||
|
|
||||||
|
// old style file-manager drag&drop support: we retain the old-style
|
||||||
|
// DragAcceptFiles in parallel with SetDropTarget.
|
||||||
|
void wxWindowMGL::DragAcceptFiles(bool accept)
|
||||||
|
{
|
||||||
|
#if 0 // FIXME_MGL
|
||||||
|
HWND hWnd = GetHwnd();
|
||||||
|
if ( hWnd )
|
||||||
|
::DragAcceptFiles(hWnd, (BOOL)accept);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// moving and resizing
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Get total size
|
||||||
|
void wxWindowMGL::DoGetSize(int *x, int *y) const
|
||||||
|
{
|
||||||
|
if (x) *x = m_wnd->width;
|
||||||
|
if (y) *y = m_wnd->height;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxWindowMGL::DoGetPosition(int *x, int *y) const
|
||||||
|
{
|
||||||
|
if (x) *x = m_wnd->x;
|
||||||
|
if (y) *y = m_wnd->y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxWindowMGL::DoScreenToClient(int *x, int *y) const
|
||||||
|
{
|
||||||
|
int ax, ay;
|
||||||
|
wxPoint co = GetClientAreaOrigin();
|
||||||
|
|
||||||
|
MGL_wmCoordGlobalToLocal(m_wnd, m_wnd->x, m_wnd->y, &ax, &ay);
|
||||||
|
ax -= co.x;
|
||||||
|
ay -= co.y;
|
||||||
|
if (x)
|
||||||
|
*x = ax;
|
||||||
|
if (y)
|
||||||
|
*y = ay;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxWindowMGL::DoClientToScreen(int *x, int *y) const
|
||||||
|
{
|
||||||
|
int ax, ay;
|
||||||
|
wxPoint co = GetClientAreaOrigin();
|
||||||
|
|
||||||
|
MGL_wmCoordGlobalToLocal(m_wnd, m_wnd->x+co.x, m_wnd->y+co.y, &ax, &ay);
|
||||||
|
if (x)
|
||||||
|
*x = ax;
|
||||||
|
if (y)
|
||||||
|
*y = ay;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get size *available for subwindows* i.e. excluding menu bar etc.
|
||||||
|
void wxWindowMGL::DoGetClientSize(int *x, int *y) const
|
||||||
|
{
|
||||||
|
DoGetSize(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxWindowMGL::DoMoveWindow(int x, int y, int width, int height)
|
||||||
|
{
|
||||||
|
MGL_wmSetWindowPosition(GetHandle(), x, y, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set the size of the window: if the dimensions are positive, just use them,
|
||||||
|
// but if any of them is equal to -1, it means that we must find the value for
|
||||||
|
// it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
|
||||||
|
// which case -1 is a valid value for x and y)
|
||||||
|
//
|
||||||
|
// If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
|
||||||
|
// the width/height to best suit our contents, otherwise we reuse the current
|
||||||
|
// width/height
|
||||||
|
void wxWindowMGL::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||||
|
{
|
||||||
|
// get the current size and position...
|
||||||
|
int currentX, currentY;
|
||||||
|
GetPosition(¤tX, ¤tY);
|
||||||
|
int currentW,currentH;
|
||||||
|
GetSize(¤tW, ¤tH);
|
||||||
|
|
||||||
|
// ... and don't do anything (avoiding flicker) if it's already ok
|
||||||
|
if ( x == currentX && y == currentY &&
|
||||||
|
width == currentW && height == currentH )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( x == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
|
||||||
|
x = currentX;
|
||||||
|
if ( y == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
|
||||||
|
y = currentY;
|
||||||
|
|
||||||
|
#if 0 // FIXME_MGL -- what's this good for?
|
||||||
|
AdjustForParentClientOrigin(x, y, sizeFlags);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
wxSize size(-1, -1);
|
||||||
|
if ( width == -1 )
|
||||||
|
{
|
||||||
|
if ( sizeFlags & wxSIZE_AUTO_WIDTH )
|
||||||
|
{
|
||||||
|
size = DoGetBestSize();
|
||||||
|
width = size.x;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// just take the current one
|
||||||
|
width = currentW;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( height == -1 )
|
||||||
|
{
|
||||||
|
if ( sizeFlags & wxSIZE_AUTO_HEIGHT )
|
||||||
|
{
|
||||||
|
if ( size.x == -1 )
|
||||||
|
{
|
||||||
|
size = DoGetBestSize();
|
||||||
|
}
|
||||||
|
//else: already called DoGetBestSize() above
|
||||||
|
|
||||||
|
height = size.y;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// just take the current one
|
||||||
|
height = currentH;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DoMoveWindow(x, y, width, height);
|
||||||
|
|
||||||
|
wxSizeEvent event(wxSize(width, height), GetId());
|
||||||
|
event.SetEventObject(this);
|
||||||
|
GetEventHandler()->ProcessEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxWindowMGL::DoSetClientSize(int width, int height)
|
||||||
|
{
|
||||||
|
SetSize(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// text metrics
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
int wxWindowMGL::GetCharHeight() const
|
||||||
|
{
|
||||||
|
wxScreenDC dc;
|
||||||
|
dc.SetFont(m_font);
|
||||||
|
return dc.GetCharHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxWindowMGL::GetCharWidth() const
|
||||||
|
{
|
||||||
|
wxScreenDC dc;
|
||||||
|
dc.SetFont(m_font);
|
||||||
|
return dc.GetCharWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxWindowMGL::GetTextExtent(const wxString& string,
|
||||||
|
int *x, int *y,
|
||||||
|
int *descent, int *externalLeading,
|
||||||
|
const wxFont *theFont) const
|
||||||
|
{
|
||||||
|
wxScreenDC dc;
|
||||||
|
if (!theFont)
|
||||||
|
theFont = &m_font;
|
||||||
|
dc.GetTextExtent(string, x, y, descent, externalLeading, (wxFont*)theFont);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if wxUSE_CARET && WXWIN_COMPATIBILITY
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Caret manipulation
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void wxWindowMGL::CreateCaret(int w, int h)
|
||||||
|
{
|
||||||
|
SetCaret(new wxCaret(this, w, h));
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxWindowMGL::CreateCaret(const wxBitmap *WXUNUSED(bitmap))
|
||||||
|
{
|
||||||
|
wxFAIL_MSG("not implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxWindowMGL::ShowCaret(bool show)
|
||||||
|
{
|
||||||
|
wxCHECK_RET( m_caret, "no caret to show" );
|
||||||
|
|
||||||
|
m_caret->Show(show);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxWindowMGL::DestroyCaret()
|
||||||
|
{
|
||||||
|
SetCaret(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxWindowMGL::SetCaretPos(int x, int y)
|
||||||
|
{
|
||||||
|
wxCHECK_RET( m_caret, "no caret to move" );
|
||||||
|
|
||||||
|
m_caret->Move(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxWindowMGL::GetCaretPos(int *x, int *y) const
|
||||||
|
{
|
||||||
|
wxCHECK_RET( m_caret, "no caret to get position of" );
|
||||||
|
|
||||||
|
m_caret->GetPosition(x, y);
|
||||||
|
}
|
||||||
|
#endif // wxUSE_CARET
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// activation/focus
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void wxWindowMGL::OnSetFocus(wxFocusEvent& event)
|
||||||
|
{
|
||||||
|
// panel wants to track the window which was the last to have focus in it,
|
||||||
|
// so we want to set ourselves as the window which last had focus
|
||||||
|
//
|
||||||
|
// notice that it's also important to do it upwards the tree becaus
|
||||||
|
// otherwise when the top level panel gets focus, it won't set it back to
|
||||||
|
// us, but to some other sibling
|
||||||
|
wxWindow *win = (wxWindow *)this;
|
||||||
|
while ( win )
|
||||||
|
{
|
||||||
|
wxWindow *parent = win->GetParent();
|
||||||
|
wxPanel *panel = wxDynamicCast(parent, wxPanel);
|
||||||
|
if ( panel )
|
||||||
|
{
|
||||||
|
panel->SetLastFocus(win);
|
||||||
|
}
|
||||||
|
|
||||||
|
win = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// painting
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void wxWindowMGL::Clear()
|
||||||
|
{
|
||||||
|
wxClientDC dc((wxWindow *)this);
|
||||||
|
wxBrush brush(GetBackgroundColour(), wxSOLID);
|
||||||
|
dc.SetBackground(brush);
|
||||||
|
dc.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxWindowMGL::Refresh(bool WXUNUSED(eraseBack), const wxRect *rect)
|
||||||
|
{
|
||||||
|
if ( rect )
|
||||||
|
{
|
||||||
|
rect_t r;
|
||||||
|
r.left = rect->GetLeft(), r.right = rect->GetRight();
|
||||||
|
r.top = rect->GetTop(), r.bottom = rect->GetBottom();
|
||||||
|
MGL_wmInvalidateWindowRect(GetHandle(), &r);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
MGL_wmInvalidateWindow(GetHandle());
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxWindowMGL::Update()
|
||||||
|
{
|
||||||
|
Refresh();
|
||||||
|
if ( !m_frozen )
|
||||||
|
MGL_wmUpdateDC(g_winMng);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxWindowMGL::Freeze()
|
||||||
|
{
|
||||||
|
m_frozen = TRUE;
|
||||||
|
m_refreshAfterThaw = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxWindowMGL::Thaw()
|
||||||
|
{
|
||||||
|
m_frozen = FALSE;
|
||||||
|
if ( m_refreshAfterThaw )
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void wxWindowPainter(window_t *wnd, MGLDC *dc)
|
||||||
|
{
|
||||||
|
wxWindow *w = (wxWindow*) wnd->userData;
|
||||||
|
if (w)
|
||||||
|
{
|
||||||
|
MGLDevCtx ctx(dc);
|
||||||
|
w->HandlePaint(&ctx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxWindowMGL::HandlePaint(MGLDevCtx *dc)
|
||||||
|
{
|
||||||
|
if ( m_frozen )
|
||||||
|
{
|
||||||
|
// Don't paint anything if the window is frozen.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
region_t *clip = NULL;
|
||||||
|
MGL_getClipRegionDC(*dc, clip);
|
||||||
|
m_updateRegion = wxRegion(MGLRegion(clip));
|
||||||
|
m_paintMGLDC = dc;
|
||||||
|
|
||||||
|
wxEraseEvent eventEr(m_windowId, NULL);
|
||||||
|
eventEr.SetEventObject(this);
|
||||||
|
GetEventHandler()->ProcessEvent(eventEr);
|
||||||
|
|
||||||
|
wxNcPaintEvent eventNc(GetId());
|
||||||
|
eventNc.SetEventObject(this);
|
||||||
|
GetEventHandler()->ProcessEvent(eventNc);
|
||||||
|
|
||||||
|
wxPaintEvent eventPt(GetId());
|
||||||
|
eventPt.SetEventObject(this);
|
||||||
|
GetEventHandler()->ProcessEvent(eventPt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxWindowMGL::OnEraseBackground(wxEraseEvent& event)
|
||||||
|
{
|
||||||
|
Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Find the wxWindow at the current mouse position, returning the mouse
|
||||||
|
// position.
|
||||||
|
wxWindow* wxFindWindowAtPointer(wxPoint& pt)
|
||||||
|
{
|
||||||
|
return wxFindWindowAtPoint(pt = wxGetMousePosition());
|
||||||
|
}
|
||||||
|
|
||||||
|
wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
|
||||||
|
{
|
||||||
|
window_t *wnd = MGL_wmGetWindowAtPosition(g_winMng, pt.x, pt.y);
|
||||||
|
return (wxWindow*)wnd->userData;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user