]> git.saurik.com Git - wxWidgets.git/commitdiff
More OS/2 changes and fixes. Getting there.
authorDavid Webster <Dave.Webster@bhmi.com>
Mon, 20 Sep 1999 17:19:25 +0000 (17:19 +0000)
committerDavid Webster <Dave.Webster@bhmi.com>
Mon, 20 Sep 1999 17:19:25 +0000 (17:19 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3732 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/defs.h
include/wx/os2/private.h
include/wx/os2/window.h
src/makeva.env
src/os2/control.cpp
src/os2/utils.cpp
src/os2/window.cpp

index da04f7bc4864a8898a02270578ad70f8504f6e20..aa70434c846c663319ec630d03c5679ccabe93f4 100644 (file)
@@ -1476,6 +1476,8 @@ typedef long            WXLPARAM;
 #else
 #  define WXWPARAM      MPARAM
 #  define WXLPARAM      MPARAM
+#  define RECT          RECTL
+#  define LOGFONT       FATTRS
 #endif
 typedef unsigned long   WXCOLORREF;
 typedef void *          WXRGNDATA;
index 655a4d21a276bad0f49bcb1b6c5a331683cb6727..d4bdf02be6c29ee8c3cc32821fc6a8e1731511fc 100644 (file)
@@ -63,10 +63,10 @@ typedef MRESULT (APIENTRY * WndProcCast) (HWND, ULONG, MPARAM, MPARAM);
     #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
 
 /*
@@ -76,10 +76,10 @@ typedef MRESULT (APIENTRY * WndProcCast) (HWND, ULONG, MPARAM, MPARAM);
 
 #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
@@ -107,8 +107,7 @@ typedef MRESULT (APIENTRY * WndProcCast) (HWND, ULONG, MPARAM, MPARAM);
 
 // 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
@@ -155,7 +154,7 @@ extern LONG APIENTRY _EXPORT
 // ---------------------------------------------------------------------------
 
 // 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;
 
index f4b17984685d96504e64dd1337005fb5f4cb7456..fe491594e3a20d35ddfae3313c48aefca293facf 100644 (file)
@@ -146,7 +146,6 @@ public:
     // 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
@@ -225,6 +224,11 @@ public:
     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:
 // ---------------------------------------------------------------------------
@@ -239,14 +243,25 @@ 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
@@ -268,6 +283,7 @@ protected:
     wxButton *            m_defaultItem;
 
 public:
+    WXFARPROC             m_oldWndProc;
     int                   m_returnCode;
     bool                  m_isBeingDeleted;
     bool                  m_isShown;
@@ -287,8 +303,6 @@ DECLARE_EVENT_TABLE()
 private:
     void   Init();
     void   PMDetachWindowMenu();
-    WXHWND GetHwnd() const { return m_hWnd; }
-    void   SetHwnd(WXHWND hWnd) { m_hWnd = hWnd; }
 };
 
 ////////////////////////////////////////////////////////////////////////
index af5011b3407a804a214382bd017b57875299dc01..f82e994c3a76253e4d0700ad071caca0b0874fbb 100644 (file)
@@ -17,7 +17,7 @@ OS2LIBFLAGS=/NOL /NOE
 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
index 9d80a1c83bc0ba8fecad9d9749c7521d157f81ed..4981257808d10c5c99f0482ec612a9042f9c7f61 100644 (file)
@@ -21,7 +21,7 @@
 #include "wx/app.h"
 #include "wx/dcclient.h"
 #endif
-
+#include "wx/os2/private.h"
 #include "wx/control.h"
 
 #if !USE_SHARED_LIBRARY
@@ -50,18 +50,18 @@ wxControl::~wxControl()
 
 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 )
     {
@@ -107,6 +107,7 @@ bool wxControl::OS2OnNotify(int idCtrl,
 {
     wxCommandEvent event(wxEVT_NULL, m_windowId);
     wxEventType eventType = wxEVT_NULL;
+/* TODO:
     NMHDR *hdr1 = (NMHDR*) lParam;
     switch ( hdr1->code )
     {
@@ -141,7 +142,7 @@ bool wxControl::OS2OnNotify(int idCtrl,
         default:
             return wxWindow::OS2OnNotify(idCtrl, lParam, result);
     }
-
+*/
     event.SetEventType(eventType);
     event.SetEventObject(this);
 
@@ -177,10 +178,12 @@ WXDWORD wxControl::GetExStyle(WXDWORD& style) const
     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;
 }
@@ -196,26 +199,26 @@ WXDWORD wxControl::GetExStyle(WXDWORD& style) const
 // 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;
 }
 
index 34ae33543ad92bdd8b1c3c27277a7f0fcf181598..10100cb58ae40cd742873087dd5bfa565ac4bd27 100644 (file)
@@ -27,9 +27,6 @@
 #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
@@ -125,8 +125,8 @@ int wxKill(long pid, int sig)
 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 != "")
@@ -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)
 {
-  static const wxChar defunkt[] = "$$default";
+  static const wxChar defunkt[] = _T("$$default");
   if (file != "")
   {
     int n = GetPrivateProfileString((PCSZ)WXSTRINGCAST section, (PCSZ)WXSTRINGCAST entry, (PCSZ)defunkt,
@@ -373,7 +373,7 @@ void wxBeginBusyCursor(wxCursor *cursor)
 void wxEndBusyCursor()
 {
     wxCHECK_RET( gs_wxBusyCursorCount > 0,
-                 "no matching wxBeginBusyCursor() for wxEndBusyCursor()");
+                 _T("no matching wxBeginBusyCursor() for wxEndBusyCursor()"));
 
     if ( --gs_wxBusyCursorCount == 0 )
     {
@@ -420,10 +420,10 @@ wxChar *wxGetUserHome (const wxString& user)
     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)
@@ -431,7 +431,7 @@ wxChar *wxGetUserHome (const wxString& user)
     }
   }
   if (user1 == _T(""))
-    if ((home = wxGetenv("HOME")) != NULL)
+    if ((home = wxGetenv(_T("HOME"))) != NULL)
     {
       wxStrcpy(wxBuffer, home);
       Unix2DosFilename(wxBuffer);
@@ -457,7 +457,7 @@ bool wxCheckForInterrupt(wxWindow *wnd)
     return TRUE;//*** temporary?
   }
   else{
-    wxFAIL_MSG("wnd==NULL !!!");
+    wxFAIL_MSG(_T("wnd==NULL !!!"));
 
     return FALSE;//*** temporary?
   }
index 1cbf08b8c169a5f2046b62fb70cb10bdfd648223..1ef7d38f2acfd46571cdd3fcbc8bc08847f23a28 100644 (file)
@@ -173,8 +173,8 @@ wxWindow::~wxWindow()
     DestroyChildren();
     if (m_hWnd)
     {
-        if(!WinDestroyWindow(GetHwnd()))
-            wxLogLastError("DestroyWindow");
+        if(!WinDestroyWindow(GetHWND()))
+            wxLogLastError(_T("DestroyWindow"));
         // remove hWnd <-> wxWindow association
         wxRemoveHandleAssociation(this);
     }
@@ -495,12 +495,6 @@ wxObject* wxWindow::GetChild(int number) const
     return((wxObject*)this);
 }
 
-WXWidget wxWindow::GetHandle() const
-{
-    // TODO:
-    return((WXWidget)m_hWnd);
-}
-
 void wxWindow::PMDetachWindowMenu()
 {
     if ( m_hMenu )
@@ -553,3 +547,103 @@ void wxRemoveHandleAssociation(wxWindow *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;
+}
+