wxWindow split (MSW part of changes)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2384 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-05-10 00:42:57 +00:00
parent f03fc89fff
commit cc2b747254
27 changed files with 899 additions and 2160 deletions
+3 -3
View File
@@ -54,9 +54,9 @@ public:
virtual bool Ok(void) const { return (m_refData != NULL && M_CURSORDATA->m_hCursor) ; }
inline wxCursor& operator = (const wxCursor& cursor) { if (*this == cursor) return (*this); Ref(cursor); return *this; }
inline bool operator == (const wxCursor& cursor) { return m_refData == cursor.m_refData; }
inline bool operator != (const wxCursor& cursor) { return m_refData != cursor.m_refData; }
wxCursor& operator = (const wxCursor& cursor) { if (*this == cursor) return (*this); Ref(cursor); return *this; }
bool operator == (const wxCursor& cursor) const { return m_refData == cursor.m_refData; }
bool operator != (const wxCursor& cursor) const { return m_refData != cursor.m_refData; }
void SetHCURSOR(WXHCURSOR cursor);
inline WXHCURSOR GetHCURSOR(void) const { return (M_CURSORDATA ? M_CURSORDATA->m_hCursor : 0); }
+5
View File
@@ -60,6 +60,9 @@ public:
~wxDialog();
void SetReturnCode(int returnCode) { m_returnCode = returnCode; }
int GetReturnCode() const { return m_returnCode; }
virtual bool Destroy();
virtual void DoSetClientSize(int width, int height);
@@ -125,6 +128,8 @@ protected:
WXHWND m_hwndToolTip;
#endif // tooltips
int m_returnCode;
DECLARE_EVENT_TABLE()
};
+3 -3
View File
@@ -89,9 +89,9 @@ public:
void SetFaceName(const wxString& faceName);
void SetUnderlined(bool underlined);
inline wxFont& operator = (const wxFont& font) { if (*this == font) return (*this); Ref(font); return *this; }
inline bool operator == (const wxFont& font) { return m_refData == font.m_refData; }
inline bool operator != (const wxFont& font) { return m_refData != font.m_refData; }
wxFont& operator = (const wxFont& font) { if (*this == font) return (*this); Ref(font); return *this; }
bool operator == (const wxFont& font) const { return m_refData == font.m_refData; }
bool operator != (const wxFont& font) const { return m_refData != font.m_refData; }
protected:
void Unshare();
+5 -9
View File
@@ -19,6 +19,7 @@
#include "wx/window.h"
#include "wx/toolbar.h"
#include "wx/msw/accel.h"
#include "wx/icon.h"
WXDLLEXPORT_DATA(extern const wxChar*) wxFrameNameStr;
WXDLLEXPORT_DATA(extern const wxChar*) wxToolBarNameStr;
@@ -56,15 +57,6 @@ public:
virtual bool Destroy();
void GetClientSize(int *width, int *height) const;
void GetSize(int *width, int *height) const ;
void GetPosition(int *x, int *y) const ;
wxSize GetSize() const { return wxWindow::GetSize(); }
wxPoint GetPosition() const { return wxWindow::GetPosition(); }
wxSize GetClientSize() const { return wxWindow::GetClientSize(); }
wxRect GetClientRect() const { return wxWindow::GetClientRect(); }
virtual void ClientToScreen(int *x, int *y) const;
virtual void ScreenToClient(int *x, int *y) const;
@@ -182,6 +174,10 @@ public:
#endif // tooltips
protected:
void DoGetClientSize(int *width, int *height) const;
void DoGetSize(int *width, int *height) const ;
void DoGetPosition(int *x, int *y) const ;
// propagate our state change to all child frames
void IconizeChildFrames(bool bIconize);
+2 -2
View File
@@ -57,8 +57,8 @@ public:
int GetRange(void) const ;
int GetValue(void) const ;
void SetForegroundColour(const wxColour& col);
void SetBackgroundColour(const wxColour& col);
bool SetForegroundColour(const wxColour& col);
bool SetBackgroundColour(const wxColour& col);
// Backward compatibility
#if WXWIN_COMPATIBILITY
+1 -1
View File
@@ -204,7 +204,7 @@ class WXDLLEXPORT wxListCtrl: public wxControl
// Sets the background colour (GetBackgroundColour already implicit in
// wxWindow class)
void SetBackgroundColour(const wxColour& col);
bool SetBackgroundColour(const wxColour& col);
// Gets information about this column
bool GetColumn(int col, wxListItem& item) const;
+9 -14
View File
@@ -65,12 +65,6 @@ class WXDLLEXPORT wxMDIParentFrame: public wxFrame
void SetMenuBar(wxMenuBar *menu_bar);
// Gets the size available for subwindows after menu size, toolbar size
// and status bar size have been subtracted. If you want to manage your own
// toolbar(s), don't call SetToolBar.
void GetClientSize(int *width, int *height) const;
wxSize GetClientSize() const { return wxWindow::GetClientSize(); }
// Get the active MDI child window (Windows only)
wxMDIChildFrame *GetActiveChild(void) const ;
@@ -106,6 +100,11 @@ class WXDLLEXPORT wxMDIParentFrame: public wxFrame
void OnSysColourChanged(wxSysColourChangedEvent& event);
protected:
// Gets the size available for subwindows after menu size, toolbar size
// and status bar size have been subtracted. If you want to manage your own
// toolbar(s), don't call SetToolBar.
void DoGetClientSize(int *width, int *height) const;
wxMDIClientWindow * m_clientWindow;
wxMDIChildFrame * m_currentChild;
WXHMENU m_windowMenu;
@@ -148,12 +147,6 @@ class WXDLLEXPORT wxMDIChildFrame: public wxFrame
// Set menu bar
void SetMenuBar(wxMenuBar *menu_bar);
void SetClientSize(int width, int height);
void SetClientSize(const wxSize& sz) { wxWindow::SetClientSize(sz); }
void GetPosition(int *x, int *y) const ;
wxPoint GetPosition() const { return wxWindow::GetPosition(); }
// MDI operations
virtual void Maximize(void);
virtual void Restore(void);
@@ -172,8 +165,10 @@ class WXDLLEXPORT wxMDIChildFrame: public wxFrame
// Implementation
bool ResetWindowStyle(void *vrect);
protected:
// bool m_active;
protected:
void DoGetPosition(int *x, int *y) const ;
void DoSetClientSize(int width, int height);
};
class WXDLLEXPORT wxMDIClientWindow: public wxWindow
+21 -12
View File
@@ -84,10 +84,10 @@ typedef signed short int SHORT ;
#endif
#if wxUSE_PENWIN
WXDLLEXPORT void wxRegisterPenWin();
WXDLLEXPORT void wxCleanUpPenWin();
WXDLLEXPORT void wxEnablePenAppHooks (bool hook);
#endif
WXDLLEXPORT void wxRegisterPenWin();
WXDLLEXPORT void wxCleanUpPenWin();
WXDLLEXPORT void wxEnablePenAppHooks (bool hook);
#endif // wxUSE_PENWIN
#if wxUSE_ITSY_BITSY
#define IBS_HORZCAPTION 0x4000L
@@ -167,6 +167,12 @@ WXDLLEXPORT void wxAddControlHandle(WXHWND hWnd, wxWindow *item);
// Safely get the window text (i.e. without using fixed size buffer)
WXDLLEXPORT extern wxString wxGetWindowText(WXHWND hWnd);
// get the window class name
WXDLLEXPORT extern wxString wxGetWindowClass(WXHWND hWnd);
// get the window id
WXDLLEXPORT extern wxWindowID wxGetWindowId(WXHWND hWnd);
// Does this window style specify any border?
inline bool wxStyleHasBorder(long style)
{
@@ -182,18 +188,21 @@ inline bool wxStyleHasBorder(long style)
#define WS_EX_CLIENTEDGE 0x00000200L
#endif
// ---------------------------------------------------------------------------
// debug messages
// ---------------------------------------------------------------------------
#if defined(__WIN95__) && defined(__WXDEBUG__) && wxUSE_DBWIN32
#ifndef __TWIN32__
#ifdef OutputDebugString
#undef OutputDebugString
#endif
#ifndef __TWIN32__
#ifdef OutputDebugString
#undef OutputDebugString
#endif
#define OutputDebugString OutputDebugStringW95
#endif
#define OutputDebugString OutputDebugStringW95
#endif // __TWIN32__
extern void OutputDebugStringW95(const wxChar*, ...);
#endif
extern void OutputDebugStringW95(const wxChar*, ...);
#endif // USE_DBWIN32
#endif
// _WX_PRIVATE_H_
+1 -1
View File
@@ -73,7 +73,7 @@ public:
wxString GetLabel(int item) const;
bool Show(bool show);
void SetFocus();
void Enable(bool enable);
bool Enable(bool enable);
void Enable(int item, bool enable);
void Show(int item, bool show);
void SetLabelFont(const wxFont& WXUNUSED(font)) {};
+1 -2
View File
@@ -70,14 +70,13 @@ class WXDLLEXPORT wxToolBar95: public wxToolBarBase
wxSize GetMaxSize(void) const;
void GetSize(int *w, int *y) const;
wxSize GetSize() const { return wxWindow::GetSize(); }
virtual bool GetToolState(int toolIndex) const;
// Add all the buttons: required for Win95.
virtual bool CreateTools(void);
virtual void SetRows(int nRows);
virtual void Layout(void) {}
virtual void LayoutButtons(void) {}
// The post-tool-addition call
bool Realize() { return CreateTools(); };
+1 -1
View File
@@ -65,7 +65,7 @@ public:
// The button size is bigger than the bitmap size
wxSize GetToolSize(void) const;
void Layout(void);
void LayoutTools();
// The post-tool-addition call
bool Realize() { Layout(); return TRUE; };
+150 -629
View File
File diff suppressed because it is too large Load Diff
+9 -1
View File
@@ -602,7 +602,14 @@ protected:
// the window handle (for the underlying windowing system) and the window
// id - a number which uniquely identifies a window among its siblings
// unless it is -1
WXWidget m_widget;
union
{
// we have 2 common names for this member, one for MSW and the other
// for the rest of the world
WXWidget m_widget;
WXWidget m_hWnd;
};
wxWindowID m_windowId;
// the parent window of this window (or NULL) and the list of the children
@@ -753,6 +760,7 @@ wxWindow *wxWindowBase::GetGrandParent() const
// ----------------------------------------------------------------------------
extern wxWindow* WXDLLEXPORT wxGetActiveWindow();
inline int WXDLLEXPORT NewControlId() { return wxWindowBase::NewControlId(); }
#endif
// _WX_WINDOW_H_BASE_
+1 -2
View File
@@ -241,13 +241,12 @@ bool wxWindowBase::Close(bool force)
bool wxWindowBase::DestroyChildren()
{
wxWindowList::Node *node;
for ( node = m_children.GetFirst(); node; node = node->GetNext() )
for ( node = GetChildren().GetFirst(); node; node = node->GetNext() )
{
wxWindow *child = node->GetData();
if ( child )
{
delete child;
delete node;
}
}
+2 -2
View File
@@ -319,8 +319,8 @@ void wxCheckListBox::InsertItems(int nItems, const wxString items[], int pos)
wxOwnerDrawn *wxCheckListBox::CreateItem(size_t nIndex)
{
wxCheckListBoxItem *pItem = new wxCheckListBoxItem(this, nIndex);
if ( m_windowFont.Ok() )
pItem->SetFont(m_windowFont);
if ( m_font.Ok() )
pItem->SetFont(m_font);
return pItem;
}
+7 -19
View File
@@ -168,17 +168,17 @@ void wxControl::MSWOnMouseMove(int x, int y, WXUINT flags)
// Window gets a click down message followed by a mouse move
// message even if position isn't changed! We want to discard
// the trailing move event if x and y are the same.
if ((m_lastEvent == wxEVT_RIGHT_DOWN || m_lastEvent == wxEVT_LEFT_DOWN ||
m_lastEvent == wxEVT_MIDDLE_DOWN) &&
(m_lastXPos == event.GetX() && m_lastYPos == event.GetY()))
if ((m_lastMouseEvent == wxEVT_RIGHT_DOWN || m_lastMouseEvent == wxEVT_LEFT_DOWN ||
m_lastMouseEvent == wxEVT_MIDDLE_DOWN) &&
(m_lastMouseX == event.GetX() && m_lastMouseY == event.GetY()))
{
m_lastXPos = event.GetX(); m_lastYPos = event.GetY();
m_lastEvent = wxEVT_MOTION;
m_lastMouseX = event.GetX(); m_lastMouseY = event.GetY();
m_lastMouseEvent = wxEVT_MOTION;
return;
}
m_lastEvent = wxEVT_MOTION;
m_lastXPos = event.GetX(); m_lastYPos = event.GetY();
m_lastMouseEvent = wxEVT_MOTION;
m_lastMouseX = event.GetX(); m_lastMouseY = event.GetY();
if (!GetEventHandler()->ProcessEvent(event))
Default();
@@ -250,18 +250,6 @@ bool wxControl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam,
#endif
}
/*
* Allocates control IDs within the appropriate range
*/
int NewControlId(void)
{
static int controlId = 0;
controlId ++;
return controlId;
}
void wxControl::ProcessCommand (wxCommandEvent & event)
{
// Tries:
+2 -2
View File
@@ -803,7 +803,7 @@ void wxDC::SetBackground(const wxBrush& brush)
{
if (m_backgroundBrush.GetStyle()==wxTRANSPARENT)
{
m_canvas->m_backgroundTransparent = TRUE;
m_canvas->SetTransparent(TRUE);
}
else
{
@@ -815,7 +815,7 @@ void wxDC::SetBackground(const wxBrush& brush)
// wxWindow::SetTransparency(). Should that apply to the child itself, or the
// parent?
// m_canvas->SetBackgroundColour(m_backgroundBrush.GetColour());
m_canvas->m_backgroundTransparent = FALSE;
m_canvas->SetTransparent(FALSE);
}
}
}
+7 -1
View File
@@ -415,9 +415,13 @@ bool wxDialog::Show(bool show)
// enable it, else we enable all modeless windows
if (last)
{
// VZ: I don't understand what this is supposed to do, so I'll leave
// it out for now and look for horrible consequences
wxDialog *box = (wxDialog *)last->Data();
HWND hwnd = (HWND) box->GetHWND();
if (box->m_winEnabled)
#if 0
if (box->IsUserEnabled())
#endif // 0
EnableWindow(hwnd, TRUE);
BringWindowToTop(hwnd);
}
@@ -429,7 +433,9 @@ bool wxDialog::Show(bool show)
wxWindow *win = (wxWindow *)node->Data();
HWND hwnd = (HWND) win->GetHWND();
// Only enable again if not user-disabled.
#if 0
if (win->IsUserEnabled())
#endif // 0
EnableWindow(hwnd, TRUE);
node = node->Next();
}
+3 -4
View File
@@ -75,7 +75,6 @@ wxFrame::wxFrame()
m_frameMenuBar = NULL;
m_frameStatusBar = NULL;
m_windowParent = NULL;
m_iconized = FALSE;
}
@@ -170,7 +169,7 @@ WXHMENU wxFrame::GetWinMenu() const
}
// Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
void wxFrame::GetClientSize(int *x, int *y) const
void wxFrame::DoGetClientSize(int *x, int *y) const
{
RECT rect;
::GetClientRect((HWND) GetHWND(), &rect);
@@ -230,7 +229,7 @@ void wxFrame::DoSetClientSize(int width, int height)
GetEventHandler()->ProcessEvent(event);
}
void wxFrame::GetSize(int *width, int *height) const
void wxFrame::DoGetSize(int *width, int *height) const
{
RECT rect;
GetWindowRect((HWND) GetHWND(), &rect);
@@ -238,7 +237,7 @@ void wxFrame::GetSize(int *width, int *height) const
*height = rect.bottom - rect.top;
}
void wxFrame::GetPosition(int *x, int *y) const
void wxFrame::DoGetPosition(int *x, int *y) const
{
RECT rect;
GetWindowRect((HWND) GetHWND(), &rect);
+14 -4
View File
@@ -182,14 +182,24 @@ int wxGauge95::GetValue(void) const
return m_gaugePos;
}
void wxGauge95::SetForegroundColour(const wxColour& col)
bool wxGauge95::SetForegroundColour(const wxColour& col)
{
m_foregroundColour = col ;
if ( !wxControl::SetForegroundColour(col) )
return FALSE;
m_foregroundColour = col ;
return TRUE;
}
void wxGauge95::SetBackgroundColour(const wxColour& col)
bool wxGauge95::SetBackgroundColour(const wxColour& col)
{
m_backgroundColour = col ;
if ( !wxControl::SetBackgroundColour(col) )
return FALSE;
m_backgroundColour = col ;
return TRUE;
}
#endif // wxUSE_GAUGE
+5 -2
View File
@@ -360,11 +360,14 @@ long wxListCtrl::ConvertToMSWStyle(long& oldStyle, long style) const
// Sets the background colour (GetBackgroundColour already implicit in
// wxWindow class)
void wxListCtrl::SetBackgroundColour(const wxColour& col)
bool wxListCtrl::SetBackgroundColour(const wxColour& col)
{
wxWindow::SetBackgroundColour(col);
if ( !wxWindow::SetBackgroundColour(col) )
return FALSE;
ListView_SetBkColor((HWND) GetHWND(), PALETTERGB(col.Red(), col.Green(), col.Blue()));
return TRUE;
}
// Gets information about this column
+5 -5
View File
@@ -159,12 +159,12 @@ wxMDIParentFrame::~wxMDIParentFrame()
if (m_clientWindow->MSWGetOldWndProc())
m_clientWindow->UnsubclassWin();
m_clientWindow->m_hWnd = 0;
m_clientWindow->SetHWND(0);
delete m_clientWindow;
}
// Get size *available for subwindows* i.e. excluding menu bar.
void wxMDIParentFrame::GetClientSize(int *x, int *y) const
void wxMDIParentFrame::DoGetClientSize(int *x, int *y) const
{
RECT rect;
::GetClientRect((HWND) GetHWND(), &rect);
@@ -662,7 +662,7 @@ wxMDIChildFrame::~wxMDIChildFrame()
// Set the client size (i.e. leave the calculation of borders etc.
// to wxWindows)
void wxMDIChildFrame::SetClientSize(int width, int height)
void wxMDIChildFrame::DoSetClientSize(int width, int height)
{
HWND hWnd = (HWND) GetHWND();
@@ -701,7 +701,7 @@ void wxMDIChildFrame::SetClientSize(int width, int height)
GetEventHandler()->ProcessEvent(event);
}
void wxMDIChildFrame::GetPosition(int *x, int *y) const
void wxMDIChildFrame::DoGetPosition(int *x, int *y) const
{
RECT rect;
GetWindowRect((HWND) GetHWND(), &rect);
@@ -1065,7 +1065,7 @@ bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style)
CLIENTCREATESTRUCT ccs;
m_windowStyle = style;
m_windowParent = parent;
m_parent = parent;
ccs.hWindowMenu = (HMENU) parent->GetWindowMenu();
ccs.idFirstChild = wxFIRST_MDI_CHILD;
+211 -203
View File
@@ -6,288 +6,296 @@
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
// ===========================================================================
// declarations
// ===========================================================================
// ---------------------------------------------------------------------------
// headers
// ---------------------------------------------------------------------------
#ifdef __GNUG__
#pragma implementation
#pragma implementation
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include <stdio.h>
#include "wx/wx.h"
#include <stdio.h>
#include "wx/wx.h"
#endif
#include "wx/spinbutt.h"
#include "wx/msw/private.h"
// ---------------------------------------------------------------------------
// global functions
// ---------------------------------------------------------------------------
extern wxWindow *wxWndHook;
extern LONG APIENTRY _EXPORT wxDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
extern LONG APIENTRY _EXPORT wxDlgProc(HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam);
// ===========================================================================
// implementation
// ===========================================================================
bool wxWindow::LoadNativeDialog(wxWindow* parent, wxWindowID& id)
{
m_windowId = id;
m_windowId = id;
wxWndHook = this;
m_hWnd = (WXHWND) ::CreateDialog((HINSTANCE) wxGetInstance(), MAKEINTRESOURCE(id),
(HWND) (parent ? parent->GetHWND() : (WXHWND) NULL), (DLGPROC) wxDlgProc);
m_hWnd = (WXHWND)::CreateDialog((HINSTANCE)wxGetInstance(),
MAKEINTRESOURCE(id),
parent ? (HWND)parent->GetHWND() : 0,
(DLGPROC) wxDlgProc);
wxWndHook = NULL;
if ( !m_hWnd )
return FALSE;
if ( !m_hWnd )
return FALSE;
SubclassWin(GetHWND());
SubclassWin(GetHWND());
if (!parent)
wxTopLevelWindows.Append(this);
if ( parent )
parent->AddChild(this);
else
wxTopLevelWindows.Append(this);
if ( parent )
parent->AddChild(this);
// Enumerate all children
// Enumerate all children
HWND hWndNext;
hWndNext = ::GetWindow((HWND) m_hWnd, GW_CHILD);
wxWindow* child = NULL;
if (hWndNext)
child = CreateWindowFromHWND(this, (WXHWND) hWndNext);
wxWindow* child = NULL;
if (hWndNext)
child = CreateWindowFromHWND(this, (WXHWND) hWndNext);
while (hWndNext != (HWND) NULL)
{
hWndNext = ::GetWindow(hWndNext, GW_HWNDNEXT);
if (hWndNext)
child = CreateWindowFromHWND(this, (WXHWND) hWndNext);
hWndNext = ::GetWindow(hWndNext, GW_HWNDNEXT);
if (hWndNext)
child = CreateWindowFromHWND(this, (WXHWND) hWndNext);
}
return TRUE;
return TRUE;
}
bool wxWindow::LoadNativeDialog(wxWindow* parent, const wxString& name)
{
SetName(name);
SetName(name);
wxWndHook = this;
m_hWnd = (WXHWND) ::CreateDialog((HINSTANCE) wxGetInstance(), (const char *) name,
(HWND) (parent ? parent->GetHWND() : (WXHWND) NULL), (DLGPROC) wxDlgProc);
m_hWnd = (WXHWND)::CreateDialog((HINSTANCE) wxGetInstance(),
name.c_str(),
parent ? (HWND)parent->GetHWND() : 0,
(DLGPROC)wxDlgProc);
wxWndHook = NULL;
if ( !m_hWnd )
return FALSE;
if ( !m_hWnd )
return FALSE;
SubclassWin(GetHWND());
SubclassWin(GetHWND());
if (!parent)
wxTopLevelWindows.Append(this);
if ( parent )
parent->AddChild(this);
else
wxTopLevelWindows.Append(this);
if ( parent )
parent->AddChild(this);
// FIXME why don't we enum all children here?
return TRUE;
return TRUE;
}
wxWindow* wxWindow::GetWindowChild1(wxWindowID& id)
// ---------------------------------------------------------------------------
// look for child by id
// ---------------------------------------------------------------------------
wxWindow* wxWindow::GetWindowChild1(wxWindowID id)
{
if ( m_windowId == id )
return this;
if ( m_windowId == id )
return this;
wxNode *node = GetChildren().First();
while ( node )
{
wxWindow* child = (wxWindow*) node->Data();
wxWindow* win = child->GetWindowChild1(id);
if ( win )
return win;
node = node->Next();
}
wxWindowList::Node *node = GetChildren().GetFirst();
while ( node )
{
wxWindow* child = node->GetData();
wxWindow* win = child->GetWindowChild1(id);
if ( win )
return win;
return NULL;
node = node->GetNext();
}
return NULL;
}
wxWindow* wxWindow::GetWindowChild(wxWindowID& id)
wxWindow* wxWindow::GetWindowChild(wxWindowID id)
{
wxWindow* win = GetWindowChild1(id);
if ( !win )
{
HWND hWnd = ::GetDlgItem((HWND) GetHWND(), id);
wxWindow* win = GetWindowChild1(id);
if ( !win )
{
HWND hWnd = ::GetDlgItem((HWND) GetHWND(), id);
if (hWnd)
{
wxWindow* child = CreateWindowFromHWND(this, (WXHWND) hWnd);
if (child)
{
child->AddChild(this);
return child;
}
}
}
return NULL;
if (hWnd)
{
wxWindow* child = CreateWindowFromHWND(this, (WXHWND) hWnd);
if (child)
{
child->AddChild(this);
return child;
}
}
}
return NULL;
}
// ---------------------------------------------------------------------------
// create wxWin window from a native HWND
// ---------------------------------------------------------------------------
wxWindow* wxWindow::CreateWindowFromHWND(wxWindow* parent, WXHWND hWnd)
{
char buf[256];
wxString str(wxGetWindowClass(hWnd));
str.UpperCase();
#ifndef __WIN32__
GetClassName((HWND) hWnd, buf, 256);
#else
#ifdef UNICODE
GetClassNameW((HWND) hWnd, buf, 256);
#else
#ifdef __TWIN32__
GetClassName((HWND) hWnd, buf, 256);
#else
GetClassNameA((HWND) hWnd, buf, 256);
#endif
#endif
#endif
long id = wxGetWindowId(hWnd);
long style = GetWindowLong((HWND) hWnd, GWL_STYLE);
wxString str(buf);
str.UpperCase();
wxWindow* win = NULL;
#ifndef __WIN32__
long id = (long) GetWindowWord((HWND) hWnd, GWW_ID);
#else
long id = GetWindowLong((HWND) hWnd, GWL_ID);
#endif
long style = GetWindowLong((HWND) hWnd, GWL_STYLE);
wxWindow* win = NULL;
if (str == "BUTTON")
{
int style1 = (style & 0xFF);
if ((style1 == BS_3STATE) || (style1 == BS_AUTO3STATE) || (style1 == BS_AUTOCHECKBOX) ||
(style1 == BS_CHECKBOX))
{
win = new wxCheckBox;
}
else if ((style1 == BS_AUTORADIOBUTTON) || (style1 == BS_RADIOBUTTON))
{
win = new wxRadioButton;
}
if (str == "BUTTON")
{
int style1 = (style & 0xFF);
if ((style1 == BS_3STATE) || (style1 == BS_AUTO3STATE) || (style1 == BS_AUTOCHECKBOX) ||
(style1 == BS_CHECKBOX))
{
win = new wxCheckBox;
}
else if ((style1 == BS_AUTORADIOBUTTON) || (style1 == BS_RADIOBUTTON))
{
win = new wxRadioButton;
}
#if defined(__WIN32__) && defined(BS_BITMAP)
else if (style & BS_BITMAP)
{
// TODO: how to find the bitmap?
win = new wxBitmapButton;
wxLogError("Have not yet implemented bitmap button as BS_BITMAP button.");
}
else if (style & BS_BITMAP)
{
// TODO: how to find the bitmap?
win = new wxBitmapButton;
wxLogError("Have not yet implemented bitmap button as BS_BITMAP button.");
}
#endif
else if (style1 == BS_OWNERDRAW)
{
// TODO: how to find the bitmap?
// TODO: can't distinguish between bitmap button and bitmap static.
// Change implementation of wxStaticBitmap to SS_BITMAP.
// PROBLEM: this assumes that we're using resource-based bitmaps.
// So maybe need 2 implementations of bitmap buttons/static controls,
// with a switch in the drawing code. Call default proc if BS_BITMAP.
win = new wxBitmapButton;
}
else if ((style1 == BS_PUSHBUTTON) || (style1 == BS_DEFPUSHBUTTON))
{
win = new wxButton;
}
else if (style1 == BS_GROUPBOX)
{
win = new wxStaticBox;
}
else
{
char buf[256];
sprintf(buf, "Don't know what kind of button this is: id = %d", (int) id);
wxLogError(buf);
}
}
else if (str == "COMBOBOX")
{
win = new wxComboBox;
}
// TODO: Problem if the user creates a multiline - but not rich text - text control,
// since wxWin assumes RichEdit control for this. Should have m_isRichText in
// wxTextCtrl. Also, convert as much of the window style as is necessary
// for correct functioning.
// Could have wxWindow::AdoptAttributesFromHWND(WXHWND)
// to be overridden by each control class.
else if (str == "EDIT")
{
win = new wxTextCtrl;
}
else if (str == "LISTBOX")
{
win = new wxListBox;
}
else if (str == "SCROLLBAR")
{
win = new wxScrollBar;
}
else if (style1 == BS_OWNERDRAW)
{
// TODO: how to find the bitmap?
// TODO: can't distinguish between bitmap button and bitmap static.
// Change implementation of wxStaticBitmap to SS_BITMAP.
// PROBLEM: this assumes that we're using resource-based bitmaps.
// So maybe need 2 implementations of bitmap buttons/static controls,
// with a switch in the drawing code. Call default proc if BS_BITMAP.
win = new wxBitmapButton;
}
else if ((style1 == BS_PUSHBUTTON) || (style1 == BS_DEFPUSHBUTTON))
{
win = new wxButton;
}
else if (style1 == BS_GROUPBOX)
{
win = new wxStaticBox;
}
else
{
wxLogError(_T("Don't know what kind of button this is: id = %d"),
id);
}
}
else if (str == "COMBOBOX")
{
win = new wxComboBox;
}
// TODO: Problem if the user creates a multiline - but not rich text - text control,
// since wxWin assumes RichEdit control for this. Should have m_isRichText in
// wxTextCtrl. Also, convert as much of the window style as is necessary
// for correct functioning.
// Could have wxWindow::AdoptAttributesFromHWND(WXHWND)
// to be overridden by each control class.
else if (str == "EDIT")
{
win = new wxTextCtrl;
}
else if (str == "LISTBOX")
{
win = new wxListBox;
}
else if (str == "SCROLLBAR")
{
win = new wxScrollBar;
}
#if defined(__WIN95__) && !defined(__TWIN32__)
else if (str == "MSCTLS_UPDOWN32")
{
win = new wxSpinButton;
}
else if (str == "MSCTLS_UPDOWN32")
{
win = new wxSpinButton;
}
#endif
else if (str == "MSCTLS_TRACKBAR32")
{
// Need to ascertain if it's horiz or vert
win = new wxSlider;
}
else if (str == "STATIC")
{
int style1 = (style & 0xFF);
else if (str == "MSCTLS_TRACKBAR32")
{
// Need to ascertain if it's horiz or vert
win = new wxSlider;
}
else if (str == "STATIC")
{
int style1 = (style & 0xFF);
if ((style1 == SS_LEFT) || (style1 == SS_RIGHT) || (style1 == SS_SIMPLE))
win = new wxStaticText;
if ((style1 == SS_LEFT) || (style1 == SS_RIGHT) || (style1 == SS_SIMPLE))
win = new wxStaticText;
#if defined(__WIN32__) && defined(BS_BITMAP)
else if (style1 == SS_BITMAP)
{
win = new wxStaticBitmap;
else if (style1 == SS_BITMAP)
{
win = new wxStaticBitmap;
// Help! this doesn't correspond with the wxWin implementation.
wxLogError("Please make SS_BITMAP statics into owner-draw buttons.");
}
// Help! this doesn't correspond with the wxWin implementation.
wxLogError("Please make SS_BITMAP statics into owner-draw buttons.");
}
#endif
}
else
{
wxString msg("Don't know how to convert from Windows class ");
msg += str;
wxLogError(msg);
}
}
else
{
wxString msg("Don't know how to convert from Windows class ");
msg += str;
wxLogError(msg);
}
if (win)
{
parent->AddChild(win);
win->SetEventHandler(win);
win->SetHWND(hWnd);
win->SetId(id);
win->SubclassWin(hWnd);
win->AdoptAttributesFromHWND();
win->SetupColours();
if (win)
{
parent->AddChild(win);
win->SetEventHandler(win);
win->SetHWND(hWnd);
win->SetId(id);
win->SubclassWin(hWnd);
win->AdoptAttributesFromHWND();
win->SetupColours();
return win;
}
else
return NULL;
return win;
}
else
return NULL;
}
// Make sure the window style (etc.) reflects the HWND style (roughly)
void wxWindow::AdoptAttributesFromHWND(void)
{
HWND hWnd = (HWND) GetHWND();
long style = GetWindowLong((HWND) hWnd, GWL_STYLE);
HWND hWnd = (HWND) GetHWND();
long style = GetWindowLong((HWND) hWnd, GWL_STYLE);
if (style & WS_VSCROLL)
m_windowStyle |= wxVSCROLL;
if (style & WS_HSCROLL)
m_windowStyle |= wxHSCROLL;
if (style & WS_VSCROLL)
m_windowStyle |= wxVSCROLL;
if (style & WS_HSCROLL)
m_windowStyle |= wxHSCROLL;
}
+6 -10
View File
@@ -46,13 +46,6 @@
// private functions
// ---------------------------------------------------------------------------
// get the id of the window
#ifdef __WIN32__
#define GET_WIN_ID(hwnd) ::GetWindowLong((HWND)hwnd, GWL_ID)
#else // Win16
#define GET_WIN_ID(hwnd) ::GetWindowWord((HWND)hwnd, GWW_ID)
#endif // Win32/16
// wnd proc for radio buttons
#ifdef __WIN32__
LRESULT APIENTRY _EXPORT wxRadioBtnWndProc(HWND hWnd,
@@ -109,7 +102,7 @@ bool wxRadioBox::MSWCommand(WXUINT param, WXWORD id)
for ( int i = 0; i < m_noItems; i++ )
{
if ( id == GET_WIN_ID(m_radioButtons[i]) )
if ( id == wxGetWindowId(m_radioButtons[i]) )
{
selectedButton = i;
@@ -597,13 +590,16 @@ void wxRadioBox::Enable(int item, bool enable)
}
// Enable all controls
void wxRadioBox::Enable(bool enable)
bool wxRadioBox::Enable(bool enable)
{
wxControl::Enable(enable);
if ( !wxControl::Enable(enable) )
return FALSE;
int i;
for (i = 0; i < m_noItems; i++)
::EnableWindow((HWND) m_radioButtons[i], enable);
return TRUE;
}
// Show a specific button
+1 -1
View File
@@ -381,7 +381,7 @@ wxToolBarTool *wxToolBarMSW::AddTool(int index, const wxBitmap& bitmap, const wx
return tool;
}
void wxToolBarMSW::Layout(void)
void wxToolBarMSW::LayoutTools()
{
m_currentRowsOrColumns = 0;
m_lastX = m_xMargin;
+56
View File
@@ -796,6 +796,10 @@ bool wxDirExists(const wxString& dir)
#endif
}
// ---------------------------------------------------------------------------
// window information functions
// ---------------------------------------------------------------------------
wxString WXDLLEXPORT wxGetWindowText(WXHWND hWnd)
{
wxString str;
@@ -806,6 +810,58 @@ wxString WXDLLEXPORT wxGetWindowText(WXHWND hWnd)
return str;
}
wxString WXDLLEXPORT wxGetWindowClass(WXHWND hWnd)
{
wxString str;
int len = 256; // some starting value
for ( ;; )
{
// as we've #undefined GetClassName we must now manually choose the
// right function to call
int count =
#ifndef __WIN32__
GetClassName
#else // Win32
#ifdef UNICODE
GetClassNameW
#else // !Unicode
#ifdef __TWIN32__
GetClassName
#else // !Twin32
GetClassNameA
#endif // Twin32/!Twin32
#endif // Unicode/ANSI
#endif // Win16/32
((HWND)hWnd, str.GetWriteBuf(len), len);
str.UngetWriteBuf();
if ( count == len )
{
// the class name might have been truncated, retry with larger
// buffer
len *= 2;
}
else
{
break;
}
}
return str;
}
wxWindowID WXDLLEXPORT wxGetWindowId(WXHWND hWnd)
{
#ifndef __WIN32__
return (wxWindowID)GetWindowWord((HWND)hWnd, GWW_ID);
#else // Win32
return (wxWindowID)GetWindowLong((HWND)hWnd, GWL_ID);
#endif // Win16/32
}
#if 0
//------------------------------------------------------------------------
// wild character routines
+368 -1227
View File
File diff suppressed because it is too large Load Diff