More OS/2 changes and fixes. Getting there.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3732 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Webster
1999-09-20 17:19:25 +00:00
parent 22aed133d8
commit 86de7616de
7 changed files with 185 additions and 73 deletions

View File

@@ -1476,6 +1476,8 @@ typedef long WXLPARAM;
#else #else
# define WXWPARAM MPARAM # define WXWPARAM MPARAM
# define WXLPARAM MPARAM # define WXLPARAM MPARAM
# define RECT RECTL
# define LOGFONT FATTRS
#endif #endif
typedef unsigned long WXCOLORREF; typedef unsigned long WXCOLORREF;
typedef void * WXRGNDATA; typedef void * WXRGNDATA;

View File

@@ -63,10 +63,10 @@ typedef MRESULT (APIENTRY * WndProcCast) (HWND, ULONG, MPARAM, MPARAM);
#define IBS_HORZCAPTION 0x4000L #define IBS_HORZCAPTION 0x4000L
#define IBS_VERTCAPTION 0x8000L #define IBS_VERTCAPTION 0x8000L
UINT WINAPI ibGetCaptionSize( HWND hWnd ) ; UINT APIENTRY ibGetCaptionSize( HWND hWnd ) ;
UINT WINAPI ibSetCaptionSize( HWND hWnd, UINT nSize ) ; UINT APIENTRY ibSetCaptionSize( HWND hWnd, UINT nSize ) ;
LRESULT WINAPI ibDefWindowProc( HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam ) ; MRESULT APIENTRY ibDefWindowProc( HWND hWnd, ULONG ulMsg, MPARAM wParam, MPARAM lParam ) ;
VOID WINAPI ibAdjustWindowRect( HWND hWnd, LPRECT lprc ) ; VOID APIENTRY ibAdjustWindowRect( HWND hWnd, LPRECT lprc ) ;
#endif // wxUSE_ITSY_BITSY #endif // wxUSE_ITSY_BITSY
/* /*
@@ -76,10 +76,10 @@ typedef MRESULT (APIENTRY * WndProcCast) (HWND, ULONG, MPARAM, MPARAM);
#define STATIC_CLASS _T("STATIC") #define STATIC_CLASS _T("STATIC")
#define STATIC_FLAGS (SS_TEXT|DT_LEFT|SS_LEFT|WS_VISIBLE) #define STATIC_FLAGS (SS_TEXT|DT_LEFT|SS_LEFT|WS_VISIBLE)
#define CHECK_CLASS "BUTTON" #define CHECK_CLASS _T("BUTTON")
#define CHECK_FLAGS (BS_AUTOCHECKBOX|WS_TABSTOP) #define CHECK_FLAGS (BS_AUTOCHECKBOX|WS_TABSTOP)
#define CHECK_IS_FAFA FALSE #define CHECK_IS_FAFA FALSE
#define RADIO_CLASS "BUTTON" #define RADIO_CLASS _T("BUTTON" )
#define RADIO_FLAGS (BS_AUTORADIOBUTTON|WS_VISIBLE) #define RADIO_FLAGS (BS_AUTORADIOBUTTON|WS_VISIBLE)
#define RADIO_SIZE 20 #define RADIO_SIZE 20
#define RADIO_IS_FAFA FALSE #define RADIO_IS_FAFA FALSE
@@ -107,8 +107,7 @@ typedef MRESULT (APIENTRY * WndProcCast) (HWND, ULONG, MPARAM, MPARAM);
// Generic subclass proc, for panel item moving/sizing and intercept // Generic subclass proc, for panel item moving/sizing and intercept
// EDIT control VK_RETURN messages // EDIT control VK_RETURN messages
extern LONG APIENTRY _EXPORT extern LONG APIENTRY wxSubclassedGenericControlProc(WXHWND hWnd, WXDWORD message, WXWPARAM wParam, WXLPARAM lParam);
wxSubclassedGenericControlProc(WXHWND hWnd, WXDWORD message, WXWPARAM wParam, WXLPARAM lParam);
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// constants which might miss from some compilers' headers // constants which might miss from some compilers' headers
@@ -155,7 +154,7 @@ extern LONG APIENTRY _EXPORT
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// The MakeProcInstance version of the function wxSubclassedGenericControlProc // The MakeProcInstance version of the function wxSubclassedGenericControlProc
WXDLLEXPORT_DATA(extern FARPROC) wxGenericControlSubClassProc; WXDLLEXPORT_DATA(extern) wxGenericControlSubClassProc;
WXDLLEXPORT_DATA(extern wxChar*) wxBuffer; WXDLLEXPORT_DATA(extern wxChar*) wxBuffer;
WXDLLEXPORT_DATA(extern HINSTANCE) wxhInstance; WXDLLEXPORT_DATA(extern HINSTANCE) wxhInstance;

View File

@@ -146,7 +146,6 @@ public:
// same as DoSetSize() for the client size // same as DoSetSize() for the client size
virtual void DoSetClientSize(int width, int height); virtual void DoSetClientSize(int width, int height);
virtual bool DoPopupMenu( wxMenu *menu, int x, int y ); virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
virtual WXWidget GetHandle() const;
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// wxWindowBase virtual implementations that need to be overriden // wxWindowBase virtual implementations that need to be overriden
@@ -225,6 +224,11 @@ public:
void OnPaint(wxPaintEvent& event); void OnPaint(wxPaintEvent& event);
void OnIdle(wxIdleEvent& event); void OnIdle(wxIdleEvent& event);
// Accessors
WXHWND GetHWND() const { return m_hWnd; }
void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; }
virtual WXWidget GetHandle() const { return GetHWND(); }
public: public:
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -239,14 +243,25 @@ public:
// a toolbar that it manages itself). // a toolbar that it manages itself).
virtual void AdjustForParentClientOrigin(int& x, int& y, int sizeFlags); virtual void AdjustForParentClientOrigin(int& x, int& y, int sizeFlags);
// Windows subclassing
void SubclassWin(WXHWND hWnd);
void UnsubclassWin();
WXFARPROC OS2GetOldWndProc() const { return m_oldWndProc; }
void OS2SetOldWndProc(WXFARPROC proc) { m_oldWndProc = proc; }
wxWindow *FindItem(long id) const;
wxWindow *FindItemByHWND(WXHWND hWnd, bool controlOnly = FALSE) const;
// Determine whether 3D effects are wanted
WXDWORD Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D) const;
// PM only: TRUE if this control is part of the main control
virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return FALSE; };
// Executes the default message // Executes the default message
virtual long Default(); virtual long Default();
/* TODO: you may need something like this
// Determine whether 3D effects are wanted
virtual WXDWORD Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D);
*/
// Constraint implementation // Constraint implementation
void UnsetConstraints(wxLayoutConstraints *c); void UnsetConstraints(wxLayoutConstraints *c);
// Back-pointer to other windows we're involved with, so if we delete // Back-pointer to other windows we're involved with, so if we delete
@@ -268,6 +283,7 @@ protected:
wxButton * m_defaultItem; wxButton * m_defaultItem;
public: public:
WXFARPROC m_oldWndProc;
int m_returnCode; int m_returnCode;
bool m_isBeingDeleted; bool m_isBeingDeleted;
bool m_isShown; bool m_isShown;
@@ -287,8 +303,6 @@ DECLARE_EVENT_TABLE()
private: private:
void Init(); void Init();
void PMDetachWindowMenu(); void PMDetachWindowMenu();
WXHWND GetHwnd() const { return m_hWnd; }
void SetHwnd(WXHWND hWnd) { m_hWnd = hWnd; }
}; };
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////

View File

@@ -17,7 +17,7 @@ OS2LIBFLAGS=/NOL /NOE
OS2LIBS=CPPOM30.lib CPPOOC3.LIB OS2386.LIB OS2LIBS=CPPOM30.lib CPPOOC3.LIB OS2386.LIB
# Change this to your WXWIN directory # Change this to your WXWIN directory
WXDIR=j:\dev\Wx2\wxwindows WXDIR=h:\dev\Wx2\wxwindows
WXSRC=$(WXDIR)\src\os2 WXSRC=$(WXDIR)\src\os2
WXINC=$(WXDIR)\include WXINC=$(WXDIR)\include

View File

@@ -21,7 +21,7 @@
#include "wx/app.h" #include "wx/app.h"
#include "wx/dcclient.h" #include "wx/dcclient.h"
#endif #endif
#include "wx/os2/private.h"
#include "wx/control.h" #include "wx/control.h"
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
@@ -50,18 +50,18 @@ wxControl::~wxControl()
bool wxControl::OS2CreateControl(const wxChar *classname, WXDWORD style) bool wxControl::OS2CreateControl(const wxChar *classname, WXDWORD style)
{ {
m_hWnd = (WXHWND)::CreateWindowEx m_hWnd = (WXHWND)::WinCreateWindow( GetHwndOf(GetParent())
( ,classname
GetExStyle(style), // extended style ,NULL
classname, // the kind of control to create ,style
NULL, // the window name ,0,0,0,0
style, // the window style ,NULLHANDLE
0, 0, 0, 0, // the window position and size ,HWND_TOP
GetHwndOf(GetParent()), // parent ,(HMENU)GetId()
(HMENU)GetId(), // child id ,NULL
wxGetInstance(), // app instance ,NULL
NULL // creation parameters );
);
if ( !m_hWnd ) if ( !m_hWnd )
{ {
@@ -107,6 +107,7 @@ bool wxControl::OS2OnNotify(int idCtrl,
{ {
wxCommandEvent event(wxEVT_NULL, m_windowId); wxCommandEvent event(wxEVT_NULL, m_windowId);
wxEventType eventType = wxEVT_NULL; wxEventType eventType = wxEVT_NULL;
/* TODO:
NMHDR *hdr1 = (NMHDR*) lParam; NMHDR *hdr1 = (NMHDR*) lParam;
switch ( hdr1->code ) switch ( hdr1->code )
{ {
@@ -141,7 +142,7 @@ bool wxControl::OS2OnNotify(int idCtrl,
default: default:
return wxWindow::OS2OnNotify(idCtrl, lParam, result); return wxWindow::OS2OnNotify(idCtrl, lParam, result);
} }
*/
event.SetEventType(eventType); event.SetEventType(eventType);
event.SetEventObject(this); event.SetEventObject(this);
@@ -177,10 +178,12 @@ WXDWORD wxControl::GetExStyle(WXDWORD& style) const
bool want3D; bool want3D;
WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ; WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ;
// Even with extended styles, need to combine with WS_BORDER // Even with extended styles, need to combine with FS_BORDER
// for them to look right. // for them to look right. Check it out later, base window style does
// not designate BORDERS. Down in Frame and And controls.
if ( want3D || wxStyleHasBorder(m_windowStyle) ) if ( want3D || wxStyleHasBorder(m_windowStyle) )
style |= WS_BORDER; style |= FS_BORDER;
return exStyle; return exStyle;
} }
@@ -196,26 +199,26 @@ WXDWORD wxControl::GetExStyle(WXDWORD& style) const
// to calculate largest bounding rectangle. // to calculate largest bounding rectangle.
void wxFindMaxSize(WXHWND wnd, RECT *rect) void wxFindMaxSize(WXHWND wnd, RECT *rect)
{ {
int left = rect->left; int left = rect->xLeft;
int right = rect->right; int right = rect->xRight;
int top = rect->top; int top = rect->yTop;
int bottom = rect->bottom; int bottom = rect->yBottom;
GetWindowRect((HWND) wnd, rect); ::WinQueryWindowRect((HWND) wnd, rect);
if (left < 0) if (left < 0)
return; return;
if (left < rect->left) if (left < rect->xLeft)
rect->left = left; rect->xLeft = left;
if (right > rect->right) if (right > rect->xRight)
rect->right = right; rect->xRight = right;
if (top < rect->top) if (top < rect->yTop)
rect->top = top; rect->yTop = top;
if (bottom > rect->bottom) if (bottom > rect->yBottom)
rect->bottom = bottom; rect->yBottom = bottom;
} }

View File

@@ -27,9 +27,6 @@
#include "wx/timer.h" #include "wx/timer.h"
#include "wx/intl.h" #include "wx/intl.h"
#define INCL_OS2
#define INCL_PM
#include <ctype.h> #include <ctype.h>
#include <direct.h> #include <direct.h>
@@ -43,14 +40,17 @@
#include <errno.h> #include <errno.h>
#include <stdarg.h> #include <stdarg.h>
#define INCL_OS2
#define INCL_PM
#include <os2.h>
#include<netdb.h> #include<netdb.h>
#include<upm.h> #include<upm.h>
// In the WIN.INI file // In the WIN.INI file
static const wxChar WX_SECTION[] = "wxWindows"; static const wxChar WX_SECTION[] = _T("wxWindows");
static const wxChar eHOSTNAME[] = "HostName"; static const wxChar eHOSTNAME[] = _T("HostName");
static const wxChar eUSERID[] = "UserId"; static const wxChar eUSERID[] = _T("UserId");
static const wxChar eUSERNAME[] = "UserName"; static const wxChar eUSERNAME[] = _T("UserName");
// For the following functions we SHOULD fill in support // For the following functions we SHOULD fill in support
// for Windows-NT (which I don't know) as I assume it begin // for Windows-NT (which I don't know) as I assume it begin
@@ -125,8 +125,8 @@ int wxKill(long pid, int sig)
bool wxShell(const wxString& command) bool wxShell(const wxString& command)
{ {
wxChar *shell; wxChar *shell;
if ((shell = wxGetenv("COMSPEC")) == NULL) if ((shell = wxGetenv(_T("COMSPEC"))) == NULL)
shell = "\\CMD.EXE"; shell = _T("\\CMD.EXE");
wxChar tmp[255]; wxChar tmp[255];
if (command != "") if (command != "")
@@ -290,7 +290,7 @@ bool wxWriteResource(const wxString& section, const wxString& entry, int value,
bool wxGetResource(const wxString& section, const wxString& entry, wxChar **value, const wxString& file) bool wxGetResource(const wxString& section, const wxString& entry, wxChar **value, const wxString& file)
{ {
static const wxChar defunkt[] = "$$default"; static const wxChar defunkt[] = _T("$$default");
if (file != "") if (file != "")
{ {
int n = GetPrivateProfileString((PCSZ)WXSTRINGCAST section, (PCSZ)WXSTRINGCAST entry, (PCSZ)defunkt, int n = GetPrivateProfileString((PCSZ)WXSTRINGCAST section, (PCSZ)WXSTRINGCAST entry, (PCSZ)defunkt,
@@ -373,7 +373,7 @@ void wxBeginBusyCursor(wxCursor *cursor)
void wxEndBusyCursor() void wxEndBusyCursor()
{ {
wxCHECK_RET( gs_wxBusyCursorCount > 0, wxCHECK_RET( gs_wxBusyCursorCount > 0,
"no matching wxBeginBusyCursor() for wxEndBusyCursor()"); _T("no matching wxBeginBusyCursor() for wxEndBusyCursor()"));
if ( --gs_wxBusyCursorCount == 0 ) if ( --gs_wxBusyCursorCount == 0 )
{ {
@@ -420,10 +420,10 @@ wxChar *wxGetUserHome (const wxString& user)
wxChar tmp[64]; wxChar tmp[64];
if (wxGetUserId(tmp, sizeof(tmp)/sizeof(char))) { if (wxGetUserId(tmp, sizeof(tmp)/sizeof(char))) {
// Guests belong in the temp dir // Guests belong in the temp dir
if (wxStricmp(tmp, "annonymous") == 0) { if (wxStricmp(tmp, _T("annonymous")) == 0) {
if ((home = wxGetenv("TMP")) != NULL || if ((home = wxGetenv(_T("TMP"))) != NULL ||
(home = wxGetenv("TMPDIR")) != NULL || (home = wxGetenv(_T("TMPDIR"))) != NULL ||
(home = wxGetenv("TEMP")) != NULL) (home = wxGetenv(_T("TEMP"))) != NULL)
return *home ? home : (wxChar*)_T("\\"); return *home ? home : (wxChar*)_T("\\");
} }
if (wxStricmp(tmp, WXSTRINGCAST user1) == 0) if (wxStricmp(tmp, WXSTRINGCAST user1) == 0)
@@ -431,7 +431,7 @@ wxChar *wxGetUserHome (const wxString& user)
} }
} }
if (user1 == _T("")) if (user1 == _T(""))
if ((home = wxGetenv("HOME")) != NULL) if ((home = wxGetenv(_T("HOME"))) != NULL)
{ {
wxStrcpy(wxBuffer, home); wxStrcpy(wxBuffer, home);
Unix2DosFilename(wxBuffer); Unix2DosFilename(wxBuffer);
@@ -457,7 +457,7 @@ bool wxCheckForInterrupt(wxWindow *wnd)
return TRUE;//*** temporary? return TRUE;//*** temporary?
} }
else{ else{
wxFAIL_MSG("wnd==NULL !!!"); wxFAIL_MSG(_T("wnd==NULL !!!"));
return FALSE;//*** temporary? return FALSE;//*** temporary?
} }

View File

@@ -173,8 +173,8 @@ wxWindow::~wxWindow()
DestroyChildren(); DestroyChildren();
if (m_hWnd) if (m_hWnd)
{ {
if(!WinDestroyWindow(GetHwnd())) if(!WinDestroyWindow(GetHWND()))
wxLogLastError("DestroyWindow"); wxLogLastError(_T("DestroyWindow"));
// remove hWnd <-> wxWindow association // remove hWnd <-> wxWindow association
wxRemoveHandleAssociation(this); wxRemoveHandleAssociation(this);
} }
@@ -495,12 +495,6 @@ wxObject* wxWindow::GetChild(int number) const
return((wxObject*)this); return((wxObject*)this);
} }
WXWidget wxWindow::GetHandle() const
{
// TODO:
return((WXWidget)m_hWnd);
}
void wxWindow::PMDetachWindowMenu() void wxWindow::PMDetachWindowMenu()
{ {
if ( m_hMenu ) if ( m_hMenu )
@@ -553,3 +547,103 @@ void wxRemoveHandleAssociation(wxWindow *win)
wxWinHandleList->DeleteObject(win); wxWinHandleList->DeleteObject(win);
} }
void wxWindow::SubclassWin(WXHWND hWnd)
{
wxASSERT_MSG( !m_oldWndProc, _T("subclassing window twice?") );
HWND hwnd = (HWND)hWnd;
/*
* TODO: implement something like this:
* wxCHECK_RET( ::IsWindow(hwnd), _T("invalid HWND in SubclassWin") );
*
* wxAssociateWinWithHandle(hwnd, this);
*
* m_oldWndProc = (WXFARPROC) GetWindowLong(hwnd, GWL_WNDPROC);
* SetWindowLong(hwnd, GWL_WNDPROC, (LONG) wxWndProc);
*/
}
void wxWindow::UnsubclassWin()
{
/*
* TODO:
wxRemoveHandleAssociation(this);
// Restore old Window proc
HWND hwnd = GetHwnd();
if ( hwnd )
{
m_hWnd = 0;
wxCHECK_RET( ::IsWindow(hwnd), _T("invalid HWND in UnsubclassWin") );
FARPROC farProc = (FARPROC) GetWindowLong(hwnd, GWL_WNDPROC);
if ( (m_oldWndProc != 0) && (farProc != (FARPROC) m_oldWndProc) )
{
SetWindowLong(hwnd, GWL_WNDPROC, (LONG) m_oldWndProc);
m_oldWndProc = 0;
}
}
*/
}
WXDWORD wxWindow::Determine3DEffects(WXDWORD defaultBorderStyle,
bool *want3D) const
{
DWORD exStyle; // remove after implementation doe
/* TODO: this ought to be fun
*
// If matches certain criteria, then assume no 3D effects
// unless specifically requested (dealt with in MakeExtendedStyle)
if ( !GetParent() || !IsKindOf(CLASSINFO(wxControl)) || (m_windowStyle & wxNO_BORDER) )
{
*want3D = FALSE;
return MakeExtendedStyle(m_windowStyle, FALSE);
}
// Determine whether we should be using 3D effects or not.
bool nativeBorder = FALSE; // by default, we don't want a Win95 effect
// 1) App can specify global 3D effects
*want3D = wxTheApp->GetAuto3D();
// 2) If the parent is being drawn with user colours, or simple border specified,
// switch effects off. TODO: replace wxUSER_COLOURS with wxNO_3D
if ( GetParent() && (GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS) || (m_windowStyle & wxSIMPLE_BORDER) )
*want3D = FALSE;
// 3) Control can override this global setting by defining
// a border style, e.g. wxSUNKEN_BORDER
if ( m_windowStyle & wxSUNKEN_BORDER )
*want3D = TRUE;
// 4) If it's a special border, CTL3D can't cope so we want a native border
if ( (m_windowStyle & wxDOUBLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
(m_windowStyle & wxSTATIC_BORDER) )
{
*want3D = TRUE;
nativeBorder = TRUE;
}
// 5) If this isn't a Win95 app, and we are using CTL3D, remove border
// effects from extended style
#if wxUSE_CTL3D
if ( *want3D )
nativeBorder = FALSE;
#endif
DWORD exStyle = MakeExtendedStyle(m_windowStyle, !nativeBorder);
// If we want 3D, but haven't specified a border here,
// apply the default border style specified.
// TODO what about non-Win95 WIN32? Does it have borders?
#if defined(__WIN95__) && !wxUSE_CTL3D
if ( defaultBorderStyle && (*want3D) && ! ((m_windowStyle & wxDOUBLE_BORDER) || (m_windowStyle & wxRAISED_BORDER ) ||
(m_windowStyle & wxSTATIC_BORDER) || (m_windowStyle & wxSIMPLE_BORDER) ))
exStyle |= defaultBorderStyle; // WS_EX_CLIENTEDGE;
#endif
*/
return exStyle;
}