#else
# define WXWPARAM MPARAM
# define WXLPARAM MPARAM
+# define RECT RECTL
+# define LOGFONT FATTRS
#endif
typedef unsigned long WXCOLORREF;
typedef void * WXRGNDATA;
#define IBS_HORZCAPTION 0x4000L
#define IBS_VERTCAPTION 0x8000L
- UINT WINAPI ibGetCaptionSize( HWND hWnd ) ;
- UINT WINAPI ibSetCaptionSize( HWND hWnd, UINT nSize ) ;
- LRESULT WINAPI ibDefWindowProc( HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam ) ;
- VOID WINAPI ibAdjustWindowRect( HWND hWnd, LPRECT lprc ) ;
+ UINT APIENTRY ibGetCaptionSize( HWND hWnd ) ;
+ UINT APIENTRY ibSetCaptionSize( HWND hWnd, UINT nSize ) ;
+ MRESULT APIENTRY ibDefWindowProc( HWND hWnd, ULONG ulMsg, MPARAM wParam, MPARAM lParam ) ;
+ VOID APIENTRY ibAdjustWindowRect( HWND hWnd, LPRECT lprc ) ;
#endif // wxUSE_ITSY_BITSY
/*
#define STATIC_CLASS _T("STATIC")
#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_IS_FAFA FALSE
-#define RADIO_CLASS "BUTTON"
+#define RADIO_CLASS _T("BUTTON" )
#define RADIO_FLAGS (BS_AUTORADIOBUTTON|WS_VISIBLE)
#define RADIO_SIZE 20
#define RADIO_IS_FAFA FALSE
// Generic subclass proc, for panel item moving/sizing and intercept
// EDIT control VK_RETURN messages
-extern LONG APIENTRY _EXPORT
- wxSubclassedGenericControlProc(WXHWND hWnd, WXDWORD message, WXWPARAM wParam, WXLPARAM lParam);
+extern LONG APIENTRY wxSubclassedGenericControlProc(WXHWND hWnd, WXDWORD message, WXWPARAM wParam, WXLPARAM lParam);
// ---------------------------------------------------------------------------
// constants which might miss from some compilers' headers
// ---------------------------------------------------------------------------
// The MakeProcInstance version of the function wxSubclassedGenericControlProc
-WXDLLEXPORT_DATA(extern FARPROC) wxGenericControlSubClassProc;
+WXDLLEXPORT_DATA(extern) wxGenericControlSubClassProc;
WXDLLEXPORT_DATA(extern wxChar*) wxBuffer;
WXDLLEXPORT_DATA(extern HINSTANCE) wxhInstance;
// same as DoSetSize() for the client size
virtual void DoSetClientSize(int width, int height);
virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
- virtual WXWidget GetHandle() const;
// ---------------------------------------------------------------------------
// wxWindowBase virtual implementations that need to be overriden
void OnPaint(wxPaintEvent& 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:
// ---------------------------------------------------------------------------
// a toolbar that it manages itself).
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
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
void UnsetConstraints(wxLayoutConstraints *c);
// Back-pointer to other windows we're involved with, so if we delete
wxButton * m_defaultItem;
public:
+ WXFARPROC m_oldWndProc;
int m_returnCode;
bool m_isBeingDeleted;
bool m_isShown;
private:
void Init();
void PMDetachWindowMenu();
- WXHWND GetHwnd() const { return m_hWnd; }
- void SetHwnd(WXHWND hWnd) { m_hWnd = hWnd; }
};
////////////////////////////////////////////////////////////////////////
OS2LIBS=CPPOM30.lib CPPOOC3.LIB OS2386.LIB
# Change this to your WXWIN directory
-WXDIR=j:\dev\Wx2\wxwindows
+WXDIR=h:\dev\Wx2\wxwindows
WXSRC=$(WXDIR)\src\os2
WXINC=$(WXDIR)\include
#include "wx/app.h"
#include "wx/dcclient.h"
#endif
-
+#include "wx/os2/private.h"
#include "wx/control.h"
#if !USE_SHARED_LIBRARY
bool wxControl::OS2CreateControl(const wxChar *classname, WXDWORD style)
{
- m_hWnd = (WXHWND)::CreateWindowEx
- (
- GetExStyle(style), // extended style
- classname, // the kind of control to create
- NULL, // the window name
- style, // the window style
- 0, 0, 0, 0, // the window position and size
- GetHwndOf(GetParent()), // parent
- (HMENU)GetId(), // child id
- wxGetInstance(), // app instance
- NULL // creation parameters
- );
+ m_hWnd = (WXHWND)::WinCreateWindow( GetHwndOf(GetParent())
+ ,classname
+ ,NULL
+ ,style
+ ,0,0,0,0
+ ,NULLHANDLE
+ ,HWND_TOP
+ ,(HMENU)GetId()
+ ,NULL
+ ,NULL
+ );
+
if ( !m_hWnd )
{
{
wxCommandEvent event(wxEVT_NULL, m_windowId);
wxEventType eventType = wxEVT_NULL;
+/* TODO:
NMHDR *hdr1 = (NMHDR*) lParam;
switch ( hdr1->code )
{
default:
return wxWindow::OS2OnNotify(idCtrl, lParam, result);
}
-
+*/
event.SetEventType(eventType);
event.SetEventObject(this);
bool want3D;
WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ;
- // Even with extended styles, need to combine with WS_BORDER
- // for them to look right.
+ // Even with extended styles, need to combine with FS_BORDER
+ // 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) )
- style |= WS_BORDER;
+ style |= FS_BORDER;
return exStyle;
}
// to calculate largest bounding rectangle.
void wxFindMaxSize(WXHWND wnd, RECT *rect)
{
- int left = rect->left;
- int right = rect->right;
- int top = rect->top;
- int bottom = rect->bottom;
+ int left = rect->xLeft;
+ int right = rect->xRight;
+ int top = rect->yTop;
+ int bottom = rect->yBottom;
- GetWindowRect((HWND) wnd, rect);
+ ::WinQueryWindowRect((HWND) wnd, rect);
if (left < 0)
return;
- if (left < rect->left)
- rect->left = left;
+ if (left < rect->xLeft)
+ rect->xLeft = left;
- if (right > rect->right)
- rect->right = right;
+ if (right > rect->xRight)
+ rect->xRight = right;
- if (top < rect->top)
- rect->top = top;
+ if (top < rect->yTop)
+ rect->yTop = top;
- if (bottom > rect->bottom)
- rect->bottom = bottom;
+ if (bottom > rect->yBottom)
+ rect->yBottom = bottom;
}
#include "wx/timer.h"
#include "wx/intl.h"
-#define INCL_OS2
-#define INCL_PM
-
#include <ctype.h>
#include <direct.h>
#include <errno.h>
#include <stdarg.h>
+#define INCL_OS2
+#define INCL_PM
+#include <os2.h>
#include<netdb.h>
#include<upm.h>
// In the WIN.INI file
-static const wxChar WX_SECTION[] = "wxWindows";
-static const wxChar eHOSTNAME[] = "HostName";
-static const wxChar eUSERID[] = "UserId";
-static const wxChar eUSERNAME[] = "UserName";
+static const wxChar WX_SECTION[] = _T("wxWindows");
+static const wxChar eHOSTNAME[] = _T("HostName");
+static const wxChar eUSERID[] = _T("UserId");
+static const wxChar eUSERNAME[] = _T("UserName");
// For the following functions we SHOULD fill in support
// for Windows-NT (which I don't know) as I assume it begin
bool wxShell(const wxString& command)
{
wxChar *shell;
- if ((shell = wxGetenv("COMSPEC")) == NULL)
- shell = "\\CMD.EXE";
+ if ((shell = wxGetenv(_T("COMSPEC"))) == NULL)
+ shell = _T("\\CMD.EXE");
wxChar tmp[255];
if (command != "")
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 != "")
{
int n = GetPrivateProfileString((PCSZ)WXSTRINGCAST section, (PCSZ)WXSTRINGCAST entry, (PCSZ)defunkt,
void wxEndBusyCursor()
{
wxCHECK_RET( gs_wxBusyCursorCount > 0,
- "no matching wxBeginBusyCursor() for wxEndBusyCursor()");
+ _T("no matching wxBeginBusyCursor() for wxEndBusyCursor()"));
if ( --gs_wxBusyCursorCount == 0 )
{
wxChar tmp[64];
if (wxGetUserId(tmp, sizeof(tmp)/sizeof(char))) {
// Guests belong in the temp dir
- if (wxStricmp(tmp, "annonymous") == 0) {
- if ((home = wxGetenv("TMP")) != NULL ||
- (home = wxGetenv("TMPDIR")) != NULL ||
- (home = wxGetenv("TEMP")) != NULL)
+ if (wxStricmp(tmp, _T("annonymous")) == 0) {
+ if ((home = wxGetenv(_T("TMP"))) != NULL ||
+ (home = wxGetenv(_T("TMPDIR"))) != NULL ||
+ (home = wxGetenv(_T("TEMP"))) != NULL)
return *home ? home : (wxChar*)_T("\\");
}
if (wxStricmp(tmp, WXSTRINGCAST user1) == 0)
}
}
if (user1 == _T(""))
- if ((home = wxGetenv("HOME")) != NULL)
+ if ((home = wxGetenv(_T("HOME"))) != NULL)
{
wxStrcpy(wxBuffer, home);
Unix2DosFilename(wxBuffer);
return TRUE;//*** temporary?
}
else{
- wxFAIL_MSG("wnd==NULL !!!");
+ wxFAIL_MSG(_T("wnd==NULL !!!"));
return FALSE;//*** temporary?
}
DestroyChildren();
if (m_hWnd)
{
- if(!WinDestroyWindow(GetHwnd()))
- wxLogLastError("DestroyWindow");
+ if(!WinDestroyWindow(GetHWND()))
+ wxLogLastError(_T("DestroyWindow"));
// remove hWnd <-> wxWindow association
wxRemoveHandleAssociation(this);
}
return((wxObject*)this);
}
-WXWidget wxWindow::GetHandle() const
-{
- // TODO:
- return((WXWidget)m_hWnd);
-}
-
void wxWindow::PMDetachWindowMenu()
{
if ( m_hMenu )
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;
+}
+