]> git.saurik.com Git - wxWidgets.git/commitdiff
Some OS/2 Modifications for coordinate normalizations and code for some common controls
authorDavid Webster <Dave.Webster@bhmi.com>
Mon, 22 Oct 2001 05:15:25 +0000 (05:15 +0000)
committerDavid Webster <Dave.Webster@bhmi.com>
Mon, 22 Oct 2001 05:15:25 +0000 (05:15 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12146 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

12 files changed:
src/os2/accel.cpp
src/os2/app.cpp
src/os2/button.cpp
src/os2/font.cpp
src/os2/frame.cpp
src/os2/gsocket.c
src/os2/makefile.va
src/os2/menu.cpp
src/os2/menuitem.cpp
src/os2/textctrl.cpp
src/os2/utils.cpp
src/os2/window.cpp

index a93f7f1af67c6493a25277ffdc68e6284b3fe8e9..8e1c6f43b6e2b8863c1e7aab5f2b9a1219b891e5 100644 (file)
@@ -208,10 +208,5 @@ bool wxAcceleratorTable::Translate(
         int x = 1;
     }
     return (Ok() && rc);
-//    ::WinTranslateAccel( vHabmain
-//                        ,(HWND)hWnd
-//                        ,GetHaccel()
-//                        ,pMsg
-//                       );
 } // end of wxAcceleratorTable::Translate
 
index 81d2ccbc1b4002397ae7db8d624c50a720b761f9..96d1531b5fc472820697ad4c07f2a51e0c918620 100644 (file)
@@ -332,7 +332,7 @@ bool wxApp::RegisterWindowClasses(
     if (!::WinRegisterClass( vHab
                             ,wxFrameClassName
                             ,wxFrameWndProc
-                            ,CS_SIZEREDRAW | CS_MOVENOTIFY | CS_SYNCPAINT  | CS_CLIPCHILDREN
+                            ,CS_SIZEREDRAW | CS_SYNCPAINT  | CS_CLIPCHILDREN
                             ,sizeof(ULONG)
                            ))
     {
@@ -423,7 +423,7 @@ bool wxApp::RegisterWindowClasses(
     if (!::WinRegisterClass( vHab
                             ,wxCanvasClassName
                             ,wxWndProc
-                            ,CS_MOVENOTIFY | CS_SIZEREDRAW | CS_HITTEST | CS_SAVEBITS | CS_SYNCPAINT | CS_CLIPCHILDREN
+                            ,CS_SIZEREDRAW | CS_HITTEST | CS_SYNCPAINT | CS_CLIPCHILDREN
                             ,sizeof(ULONG)
                            ))
     {
index cecadf63eed7905f6d846c068c84aadda6b33b03..3c1331876b77c6abaa1acbe248ab7c7cddc7e8ba 100644 (file)
 
 #include "wx/os2/private.h"
 
+#define BUTTON_HEIGHT_FROM_CHAR_HEIGHT(cy) (11*EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy)/10)
+
+//
+// Should be at the very least less than winDEFAULT_BUTTON_MARGIN
+//
+#define FOCUS_MARGIN 3
+
+#ifndef BST_CHECKED
+#define BST_CHECKED 0x0001
+#endif
+
 IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl)
 
 // Button
 
-bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label,
-           const wxPoint& pos,
-           const wxSize& size, long style,
+bool wxButton::Create(
+  wxWindow*                         pParent
+, wxWindowID                        vId
+, const wxString&                   rsLabel
+, const wxPoint&                    rPos
+, const wxSize&                     rSize
+, long                              lStyle
 #if wxUSE_VALIDATORS
-           const wxValidator& validator,
+, const wxValidator&                rValidator
 #endif
-           const wxString& name)
+, const wxString&                   rsName
+)
 {
-    SetName(name);
+    SetName(rsName);
 #if wxUSE_VALIDATORS
-    SetValidator(validator);
+    SetValidator(rValidator);
 #endif
-    m_windowStyle = style;
-
-    parent->AddChild((wxButton *)this);
-
-    if (id == -1)
+    m_windowStyle = lStyle;
+    pParent->AddChild((wxButton *)this);
+    if (vId == -1)
         m_windowId = NewControlId();
     else
-        m_windowId = id;
-
-    // TODO: create button
+        m_windowId = vId;
+    lStyle = WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON;
+
+    //
+    // OS/2 PM does not have Right/Left/Top/Bottom styles.
+    // We will have to define an additional style when we implement notebooks
+    // for a notebook page button
+    //
+    if (m_windowStyle & wxCLIP_SIBLINGS )
+        lStyle |= WS_CLIPSIBLINGS;
+    m_hWnd = (WXHWND)::WinCreateWindow( GetHwndOf(pParent)   // Parent handle
+                                       ,WC_BUTTON            // A Button class window
+                                       ,(PSZ)rsLabel.c_str() // Button text
+                                       ,lStyle               // Button style
+                                       ,0, 0, 0, 0           // Location and size
+                                       ,GetHwndOf(pParent)   // Owner handle
+                                       ,HWND_TOP             // Top of Z-Order
+                                       ,vId                  // Identifier
+                                       ,NULL                 // No control data
+                                       ,NULL                 // No Presentation parameters
+                                      );
+    if (m_hWnd == 0)
+    {
+        return FALSE;
+    }
 
-    return FALSE;
-}
+    //
+    // Subclass again for purposes of dialog editing mode
+    //
+    SubclassWin(m_hWnd);
+    SetFont(pParent->GetFont());
+    SetSize( rPos.x
+            ,rPos.y
+            ,rSize.x
+            ,rSize.y
+           );
+    return TRUE;
+} // end of wxButton::Create
 
 wxButton::~wxButton()
 {
-    wxPanel *panel = wxDynamicCast(GetParent(), wxPanel);
-    if ( panel )
+    wxPanel*                        pPanel = wxDynamicCast(GetParent(), wxPanel);
+
+    if (pPanel)
     {
-        if ( panel->GetDefaultItem() == this )
+        if (pPanel->GetDefaultItem() == this)
         {
-            // don't leave the panel with invalid default item
-            panel->SetDefaultItem(NULL);
+            //
+            // Don't leave the panel with invalid default item
+            //
+            pPanel->SetDefaultItem(NULL);
         }
     }
-}
+} // end of wxButton::~wxButton
 
 // ----------------------------------------------------------------------------
 // size management including autosizing
@@ -72,33 +121,59 @@ wxButton::~wxButton()
 
 wxSize wxButton::DoGetBestSize() const
 {
-    wxString label = wxGetWindowText(GetHWND());
-    int wBtn;
-    GetTextExtent(label, &wBtn, NULL);
-
-    int wChar, hChar;
-    wxGetCharSize(GetHWND(), &wChar, &hChar, (wxFont*)&GetFont());
-
-    // add a margin - the button is wider than just its label
-    wBtn += 3*wChar;
-
-    // the button height is proportional to the height of the font used
-    int hBtn = 0;// TODO: BUTTON_HEIGHT_FROM_CHAR_HEIGHT(hChar);
-
-    return wxSize(wBtn, hBtn);
-}
+    wxString                        rsLabel = wxGetWindowText(GetHWND());
+    int                             nWidthButton;
+    int                             nWidthChar;
+    int                             nHeightChar;
+
+    GetTextExtent( rsLabel
+                  ,&nWidthButton
+                  ,NULL
+                 );
+
+    wxGetCharSize( GetHWND()
+                  ,&nWidthChar
+                  ,&nHeightChar
+                  ,(wxFont*)&GetFont()
+                 );
+
+    //
+    // Add a margin - the button is wider than just its label
+    //
+    nWidthButton += 3 * nWidthChar;
+
+    //
+    // The button height is proportional to the height of the font used
+    //
+    int                             nHeightButton = BUTTON_HEIGHT_FROM_CHAR_HEIGHT(nHeightChar);
+
+    //
+    // Need a little extra to make it look right
+    //
+    nHeightButton += nHeightChar/1.5;
+
+    wxSize                          vSize = GetDefaultSize();
+
+    if (nWidthButton > vSize.x)
+        vSize.x = nWidthButton;
+    if (nHeightButton > vSize.y)
+        vSize.y = nHeightButton;
+    return vSize;
+} // end of wxButton::DoGetBestSize
 
 /* static */
 wxSize wxButton::GetDefaultSize()
 {
-    static wxSize s_sizeBtn;
+    static wxSize                   vSizeBtn;
 
-    if ( s_sizeBtn.x == 0 )
+    if (vSizeBtn.x == 0)
     {
-        wxScreenDC dc;
-        dc.SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
+        wxScreenDC                  vDc;
 
-        // the size of a standard button in the dialog units is 50x14,
+        vDc.SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
+
+        //
+        // The size of a standard button in the dialog units is 50x14,
         // translate this to pixels
         // NB1: the multipliers come from the Windows convention
         // NB2: the extra +1/+2 were needed to get the size be the same as the
@@ -106,17 +181,18 @@ wxSize wxButton::GetDefaultSize()
         //      this happens, but on my system this size is 75x23 in pixels and
         //      23*8 isn't even divisible by 14... Would be nice to understand
         //      why these constants are needed though!
-        s_sizeBtn.x = (50 * (dc.GetCharWidth() + 1))/4;
-        s_sizeBtn.y = ((14 * dc.GetCharHeight()) + 2)/8;
+        vSizeBtn.x = (50 * (vDc.GetCharWidth() + 1))/4;
+        vSizeBtn.y = ((14 * vDc.GetCharHeight()) + 2)/8;
     }
+    return vSizeBtn;
+} // end of wxButton::GetDefaultSize
 
-    return s_sizeBtn;
-}
-
-void wxButton::Command (wxCommandEvent & event)
+void wxButton::Command (
+  wxCommandEvent&                   rEvent
+)
 {
-    ProcessCommand (event);
-}
+    ProcessCommand (rEvent);
+} // end of wxButton::Command
 
 // ----------------------------------------------------------------------------
 // helpers
@@ -124,53 +200,157 @@ void wxButton::Command (wxCommandEvent & event)
 
 bool wxButton::SendClickEvent()
 {
-    wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, GetId());
-    event.SetEventObject(this);
+    wxCommandEvent                  vEvent( wxEVT_COMMAND_BUTTON_CLICKED
+                                           ,GetId()
+                                          );
 
-    return ProcessCommand(event);
-}
+    vEvent.SetEventObject(this);
+    return ProcessCommand(vEvent);
+} // end of wxButton::SendClickEvent
 
 void wxButton::SetDefault()
 {
-    wxWindow *parent = GetParent();
-    wxButton *btnOldDefault = NULL;
-    wxPanel *panel = wxDynamicCast(parent, wxPanel);
-    if (panel)
-        panel->SetDefaultItem(this);
+    wxWindow*                       pParent = GetParent();
+    wxButton*                       pBtnOldDefault = NULL;
+    wxPanel*                        pPanel = wxDynamicCast(pParent, wxPanel);
+    long                            lStyle = 0L;
+
+    if (pParent)
+    {
+        wxWindow*                   pWinOldDefault = pParent->SetDefaultItem(this);
+
+        pBtnOldDefault = wxDynamicCast(pWinOldDefault, wxButton);
+    }
+    if (pBtnOldDefault && pBtnOldDefault != this)
+    {
+        //
+        // Remove the BS_DEFPUSHBUTTON style from the other button
+        //
+        lStyle = ::WinQueryWindowULong(GetHwndOf(pBtnOldDefault), QWL_STYLE);
+
+        //
+        // Don't do it with the owner drawn buttons because it will reset
+        // BS_OWNERDRAW style bit too (BS_OWNERDRAW & BS_DEFPUSHBUTTON != 0)!
+        //
+        if ((lStyle & BS_USERBUTTON) != BS_USERBUTTON)
+        {
+            lStyle &= ~BS_DEFAULT;
+            ::WinSetWindowULong(GetHwndOf(pBtnOldDefault), QWL_STYLE, lStyle);
+        }
+        else
+        {
+            //
+            // Redraw the button - it will notice itself that it's not the
+            // default one any longer
+            //
+            pBtnOldDefault->Refresh();
+        }
+    }
 
-    // TODO: make button the default
-}
+    //
+    // Set this button as the default
+    //
+    lStyle = ::WinQueryWindowULong(GetHwnd(), QWL_STYLE);
+    if ((lStyle & BS_USERBUTTON) != BS_USERBUTTON)
+    {
+        lStyle != BS_DEFAULT;
+        ::WinSetWindowULong(GetHwnd(), QWL_STYLE, lStyle);
+    }
+} // end of wxButton::SetDefault
 
 // ----------------------------------------------------------------------------
 // event/message handlers
 // ----------------------------------------------------------------------------
 
-bool wxButton::OS2Command(WXUINT param, WXWORD id)
+bool wxButton::OS2Command(
+  WXUINT                            uParam
+, WXWORD                            wId
+)
 {
-    bool processed = FALSE;
-    // TODO
-    /*
-    switch ( param )
+    bool                            bProcessed = FALSE;
+
+    switch (uParam)
     {
-        case 1:                                             // 1 for accelerator
-        case BN_CLICKED:
-            processed = SendClickEvent();
+        case BN_CLICKED:            // normal buttons send this
+        case BN_DBLCLICKED:         // owner-drawn ones also send this
+            bProcessed = SendClickEvent();
             break;
     }
-    */
-    return processed;
-}
-
-WXHBRUSH wxButton::OnCtlColor(WXHDC pDC,
-                              WXHWND pWnd,
-                              WXUINT nCtlColor,
-                              WXUINT message,
-                              WXWPARAM wParam,
-                              WXLPARAM lParam)
+    return bProcessed;
+} // end of wxButton::OS2Command
+
+WXHBRUSH wxButton::OnCtlColor(
+  WXHDC                             pDC
+, WXHWND                            pWnd
+, WXUINT                            nCtlColor
+, WXUINT                            uMessage
+, WXWPARAM                          wParam
+, WXLPARAM                          lParam
+)
+{
+    wxBrush*                        pBackgroundBrush = wxTheBrushList->FindOrCreateBrush( GetBackgroundColour()
+                                                                                         ,wxSOLID
+                                                                                        );
+
+    return (WXHBRUSH)pBackgroundBrush->GetResourceHandle();
+} // end of wxButton::OnCtlColor
+
+void wxButton::MakeOwnerDrawn()
 {
-  wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID);
+    long                            lStyle = 0L;
 
-  return (WXHBRUSH) backgroundBrush->GetResourceHandle();
-}
+    lStyle = ::WinQueryWindowULong(GetHwnd(), QWL_STYLE);
+    if ((lStyle & BS_USERBUTTON) != BS_USERBUTTON)
+    {
+        //
+        // Make it so
+        //
+        lStyle |= BS_USERBUTTON;
+        ::WinSetWindowULong(GetHwnd(), QWL_STYLE, lStyle);
+    }
+} // end of wxCButton::MakeOwnerDrawn
+
+MRESULT wxButton::WindowProc(
+  WXUINT                            uMsg
+, WXWPARAM                          wParam
+, WXLPARAM                          lParam
+)
+{
+    //
+    // When we receive focus, we want to become the default button in our
+    // parent panel
+    //
+    if (uMsg == WM_SETFOCUS)
+    {
+        SetDefault();
+
+        //
+        // Let the default processign take place too
+        //
+    }
+
+    else if (uMsg == WM_BUTTON1DBLCLK)
+    {
+        //
+        // Emulate a click event to force an owner-drawn button to change its
+        // appearance - without this, it won't do it
+        //
+        (void)wxControl::OS2WindowProc( WM_BUTTON1DOWN
+                                       ,wParam
+                                       ,lParam
+                                      );
+
+        //
+        // And conitnue with processing the message normally as well
+        //
+    }
 
+    //
+    // Let the base class do all real processing
+    //
+    return (wxControl::OS2WindowProc( uMsg
+                                     ,wParam
+                                     ,lParam
+                                    ));
+} // end of wxW indowProc
 
index 5f42a49ab85a6857f5b591553089d7ac67f46ad6..d33d991d89a827520a65ab64a66223b235e5eeaa 100644 (file)
@@ -370,7 +370,7 @@ bool wxFont::RealizeResource()
         vError = ::WinGetLastError(vHabmain);
     }
 
-    strcpy(zFacename, M_FONTDATA->m_vFattrs.szFacename);
+    M_FONTDATA->m_sFaceName = zFacename;
 
     if(::GpiCreateLogFont( M_FONTDATA->m_hPS
                           ,NULL
index e948ffeaf380a95d3fa49487f6241623f55163f7..ee36faa2b6322e751bf474e21cbcd1b25b9db456 100644 (file)
@@ -236,6 +236,53 @@ wxFrame::~wxFrame()
     }
 } // end of wxFrame::~wxFrame
 
+//
+//  IF we have child controls in the Frame's client we need to alter
+//  the y position, because, OS/2 controls are positioned relative to
+//  wxWindows orgin (top left) not the OS/2 origin (bottom left)
+void wxFrame::AlterChildPos()
+{
+    //
+    // OS/2 is the only OS concerned about this
+    //
+    wxWindow*                               pChild = NULL;
+    wxControl*                              pCtrl = NULL;
+    RECTL                                   vRect;
+    SWP                                     vSwp;
+
+    ::WinQueryWindowRect(GetHwnd(), &vRect);
+    for (wxWindowList::Node* pNode = GetChildren().GetFirst();
+         pNode;
+         pNode = pNode->GetNext())
+    {
+        wxWindow*                   pChild = pNode->GetData();
+
+        ::WinQueryWindowPos(pChild->GetHWND(), &vSwp);
+        vSwp.y += (vRect.yTop - m_vSwpClient.cy);
+        if (pChild->IsKindOf(CLASSINFO(wxControl)))
+        {
+            pCtrl = wxDynamicCast(pChild, wxControl);
+            //
+            // Must deal with controls that have margins like ENTRYFIELD.  The SWP
+            // struct of such a control will have and origin offset from its intended
+            // position by the width of the margins.
+            //
+            vSwp.y -= pCtrl->GetYComp();
+            vSwp.x -= pCtrl->GetXComp();
+        }
+        ::WinSetWindowPos( pChild->GetHWND()
+                          ,HWND_TOP
+                          ,vSwp.x
+                          ,vSwp.y
+                          ,vSwp.cx
+                          ,vSwp.cy
+                          ,SWP_MOVE
+                         );
+        ::WinQueryWindowPos(pChild->GetHWND(), &vSwp);
+        pChild = NULL;
+    }
+} // end of wxFrame::AlterChildPos
+
 //
 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
 //
@@ -375,6 +422,7 @@ bool wxFrame::Show(
 
         ::WinQueryWindowPos(m_hFrame, &vSwp);
         m_bIconized = vSwp.fl & SWP_MINIMIZE;
+        ::WinQueryWindowPos(m_hWnd, &m_vSwpClient);
         ::WinSendMsg(m_hFrame, WM_UPDATEFRAME, (MPARAM)~0, 0);
         ::WinEnableWindow(m_hFrame, TRUE);
         vEvent.SetEventObject(this);
@@ -518,6 +566,7 @@ void wxFrame::PositionStatusBar()
     if (m_frameStatusBar)
     {
         int                         nWidth;
+        int                         nY;
         int                         nStatbarWidth;
         int                         nStatbarHeight;
         HWND                        hWndClient;
@@ -525,21 +574,24 @@ void wxFrame::PositionStatusBar()
         RECTL                       vFRect;
 
         ::WinQueryWindowRect(m_hFrame, &vRect);
+        nY = vRect.yTop;
         ::WinMapWindowPoints(m_hFrame, HWND_DESKTOP, (PPOINTL)&vRect, 2);
         vFRect = vRect;
         ::WinCalcFrameRect(m_hFrame, &vRect, TRUE);
         nWidth = vRect.xRight - vRect.xLeft;
+        nY = nY - (vRect.yBottom - vFRect.yBottom);
 
         m_frameStatusBar->GetSize( &nStatbarWidth
                                   ,&nStatbarHeight
                                  );
 
+        nY= nY - nStatbarHeight;
         //
         // Since we wish the status bar to be directly under the client area,
         // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
         //
         m_frameStatusBar->SetSize( vRect.xLeft - vFRect.xLeft
-                                  ,vRect.yBottom - vFRect.yBottom
+                                  ,nY
                                   ,nWidth
                                   ,nStatbarHeight
                                  );
@@ -1056,6 +1108,17 @@ bool wxFrame::OS2Create(
     // Now size everything.  If adding a menu the client will need to be resized.
     //
 
+    if (pParent)
+    {
+        nY = pParent->GetSize().y - (nY + nHeight);
+    }
+    else
+    {
+        RECTL                   vRect;
+
+        ::WinQueryWindowRect(HWND_DESKTOP, &vRect);
+        nY = vRect.yTop - (nY + nHeight);
+    }
     if (!::WinSetWindowPos( m_hFrame
                            ,HWND_TOP
                            ,nX
@@ -1070,23 +1133,6 @@ bool wxFrame::OS2Create(
         wxLogError("Error sizing frame. Error: %s\n", sError);
         return FALSE;
     }
-    //
-    // We may have to be smarter here when variable sized toolbars are added!
-    //
-    if (!::WinSetWindowPos( m_hWnd
-                           ,HWND_TOP
-                           ,nX // + 20
-                           ,nY // + 20
-                           ,nWidth // - 60
-                           ,nHeight // - 60
-                           ,SWP_SIZE | SWP_MOVE | SWP_ACTIVATE | SWP_ZORDER
-                          ))
-    {
-        vError = ::WinGetLastError(vHabmain);
-        sError = wxPMErrorToStr(vError);
-        wxLogError("Error sizing client. Error: %s\n", sError);
-        return FALSE;
-    }
     return TRUE;
 } // end of wxFrame::OS2Create
 
@@ -1446,6 +1492,7 @@ bool wxFrame::HandleSize(
 
         vEvent.SetEventObject(this);
         bProcessed = GetEventHandler()->ProcessEvent(vEvent);
+        AlterChildPos();
     }
     return bProcessed;
 } // end of wxFrame::HandleSize
index 222c0e24d1149e96e1dc67d01282de9eca769e50..13797e51cb2e3653d09823d45afe893175dc01c7 100644 (file)
@@ -1495,8 +1495,8 @@ GSocketError GAddress_INET_SetHostName(GAddress *address, const char *hostname)
   {
 #else
   /* Use gethostbyname by default */
-//  int val = 1;  //VA doesn't like constants in conditional expressions at all
-  if (1)
+  int val = 1;  //VA doesn't like constants in conditional expressions at all
+  if (val)
   {
 #endif
     struct in_addr *array_addr;
index da64a017cae7a982ae3040e42212d61141acdb0a..63af28dcc4ba16c3079b4e2dea99ec0ea4ca3664 100644 (file)
@@ -291,6 +291,7 @@ COMMONOBJS = \
   ..\common\$D\serbase.obj \
   ..\common\$D\sizer.obj \
   ..\common\$D\socket.obj \
+  ..\common\$D\statbar.obj \
   ..\common\$D\strconv.obj \
   ..\common\$D\stream.obj \
   ..\common\$D\string.obj \
@@ -418,6 +419,7 @@ COMLIBOBJS3 = \
   serbase.obj \
   sizer.obj \
   socket.obj \
+  statbar.obj \
   strconv.obj \
   stream.obj \
   string.obj \
@@ -780,6 +782,7 @@ $(COMLIBOBJS3):
   copy ..\common\$D\serbase.obj
   copy ..\common\$D\sizer.obj
   copy ..\common\$D\socket.obj
+  copy ..\common\$D\statbar.obj
   copy ..\common\$D\strconv.obj
   copy ..\common\$D\stream.obj
   copy ..\common\$D\string.obj
index 587a60a854e9984085f4ef69221eb710eee82c34..971cff759bad08895d762a46abd45e58b1654476 100644 (file)
@@ -73,7 +73,7 @@ static wxString TextToLabel(const wxString& rTitle)
 {
     wxString Title;
     const wxChar *pc;
-    for (pc = rTitle; *pc != wxT('\0'); pc++ )
+    for (pc = rTitle.c_str(); *pc != wxT('\0'); pc++ )
     {
         if (*pc == wxT('&') )
         {
@@ -85,10 +85,6 @@ static wxString TextToLabel(const wxString& rTitle)
             else
                 Title << wxT('~');
         }
-//         else if (*pc == wxT('/'))
-//         {
-//             Title << wxT('\\');
-//         }
         else
         {
             if ( *pc == wxT('~') )
index 16ea72e6a0f97ea21fd68ecdfa52d37191c7ba0c..6b4c37c65ae5c6ed02bb4fcdbee65442de8da1e7 100644 (file)
@@ -62,7 +62,7 @@ static wxString TextToLabel(const wxString& rTitle)
 {
     wxString Title;
     const wxChar *pc;
-    for (pc = rTitle; *pc != wxT('\0'); pc++ )
+    for (pc = rTitle.c_str(); *pc != wxT('\0'); pc++ )
     {
         if (*pc == wxT('&') )
         {
@@ -74,10 +74,6 @@ static wxString TextToLabel(const wxString& rTitle)
             else
                 Title << wxT('~');
         }
-//         else if (*pc == wxT('/'))
-//         {
-//             Title << wxT('\\');
-//         }
         else
         {
             if ( *pc == wxT('~') )
index 8fe19038cf05699b011c17dcb61240e65ade45cb..7aabef5045def4fe1b54f7cb2a98daa897a93d0d 100644 (file)
@@ -171,7 +171,7 @@ bool wxTextCtrl::Create(
     }
     else
     {
-        lSstyle |= ES_LEFT;
+        lSstyle |= ES_LEFT | ES_AUTOSCROLL | ES_MARGIN;
 
         if (m_windowStyle & wxHSCROLL)
             lSstyle |=  ES_AUTOSCROLL;
@@ -1130,7 +1130,7 @@ wxSize wxTextCtrl::DoGetBestSize() const
     wxGetCharSize(GetHWND(), &nCx, &nCy, (wxFont*)&GetFont());
 
     int                             wText = DEFAULT_ITEM_WIDTH;
-    int                             hText = EDIT_HEIGHT_FROM_CHAR_HEIGHT(nCy);
+    int                             hText = (EDIT_HEIGHT_FROM_CHAR_HEIGHT(nCy) * .8);
 
     if (m_windowStyle & wxTE_MULTILINE)
     {
index 5f9b616d9e6a419dd83043be7b526c380abcfe55..f49dced7e3ded4d0a6f6bec08eb183390fdde1eb 100644 (file)
@@ -762,7 +762,7 @@ bool wxColourDisplay()
 #else
     // I don't see how the PM display could not be color. Besides, this
     // was leaking DCs and PSs!!!  MN
-    return true;
+    return TRUE;
 #endif
 }
 
index 70e3b0958e5aeb6981ea452808b4b79023b12503..767e20d794021ead6fb232bffc3ecee19c6dbbde 100644 (file)
@@ -388,37 +388,12 @@ bool wxWindowOS2::Create(
 
         pParent->AddChild(this);
         hParent = GetWinHwnd(pParent);
-        //
-        // OS2 uses normal coordinates, no bassackwards Windows ones
-        //
-        if (pParent->IsKindOf(CLASSINFO(wxGenericScrolledWindow)) ||
-            pParent->IsKindOf(CLASSINFO(wxScrolledWindow))
-           )
-        {
-            wxWindow*               pGrandParent = NULL;
 
-            pGrandParent = pParent->GetParent();
-            if (pGrandParent)
-                nTempy = pGrandParent->GetSize().y - (vPos.y + rSize.y);
-            else
-                nTempy = pParent->GetSize().y - (vPos.y + rSize.y);
-        }
-        else
-            nTempy = pParent->GetSize().y - (vPos.y + rSize.y);
-        vPos.y = nTempy;
         if ( pParent->IsKindOf(CLASSINFO(wxGenericScrolledWindow)) ||
              pParent->IsKindOf(CLASSINFO(wxScrolledWindow))
            )
             ulCreateFlags |= WS_CLIPSIBLINGS;
     }
-    else
-    {
-        RECTL                   vRect;
-
-        ::WinQueryWindowRect(HWND_DESKTOP, &vRect);
-        hParent = HWND_DESKTOP;
-        vPos.y = vRect.yTop - (vPos.y + rSize.y);
-    }
 
     //
     // Most wxSTYLES are really PM Class specific styles and will be
@@ -614,10 +589,72 @@ bool wxWindowOS2::SetFont(
 
     if (hWnd != 0)
     {
-        wxChar                      zFont[128];
+        char                        zFont[128];
+        char                        zFacename[30];
+        char                        zWeight[30];
+        char                        zStyle[30];
+
+        //
+        // The fonts available for Presentation Params are just three
+        // outline fonts, the rest are available to the GPI, so we must
+        // map the families to one of these three
+        //
+        switch(rFont.GetFamily())
+        {
+            case wxSCRIPT:
+            case wxDECORATIVE:
+            case wxROMAN:
+                strcpy(zFacename,"Times New Roman");
+                break;
 
-        sprintf(zFont, "%d.%s", rFont.GetPointSize(), rFont.GetFaceName().c_str());
-        return (bool)::WinSetPresParam(hWnd, PP_FONTNAMESIZE, strlen(zFont), (PVOID)zFont);
+            case wxTELETYPE:
+            case wxMODERN:
+                strcpy(zFacename, "Courier");
+                break;
+
+            case wxSWISS:
+            case wxDEFAULT:
+            default:
+                strcpy(zFacename, "Helvetica");
+                break;
+        }
+
+        switch(rFont.GetWeight())
+        {
+            default:
+            case wxNORMAL:
+            case wxLIGHT:
+                zWeight[0] = '\0';
+                break;
+
+            case wxBOLD:
+            case wxFONTWEIGHT_MAX:
+                strcpy(zWeight, "Bold");
+                break;
+        }
+        switch(rFont.GetStyle())
+        {
+            case wxITALIC:
+            case wxSLANT:
+                strcpy(zStyle, "Italic");
+                break;
+
+            default:
+                zStyle[0] = '\0';
+                break;
+        }
+        sprintf(zFont, "%d.%s", rFont.GetPointSize(), zFacename);
+        if (zWeight[0] != '\0')
+        {
+            strcat(zFont, " ");
+            strcat(zFont, zWeight);
+        }
+        if (zStyle[0] != '\0')
+        {
+            strcat(zFont, " ");
+            strcat(zFont, zStyle);
+        }
+        ::WinSetPresParam(hWnd, PP_FONTNAMESIZE, strlen(zFont) + 1, (PVOID)zFont);
     }
     return(TRUE);
 }
@@ -1498,29 +1535,41 @@ void wxWindowOS2::DoMoveWindow(
 , int                               nHeight
 )
 {
-#if 0 // x and y coords should already be in os2 coordinates
     RECTL                           vRect;
     HWND                            hParent;
     wxWindow*                       pParent = GetParent();
 
     if (pParent)
+    {
         hParent = GetWinHwnd(pParent);
+        if (pParent->IsKindOf(CLASSINFO(wxFrame)))
+        {
+            if (IsKindOf(CLASSINFO(wxStatusBar)) ||
+                IsKindOf(CLASSINFO(wxMenuBar)) ||
+                IsKindOf(CLASSINFO(wxToolBar))
+               )
+                nY = pParent->GetSize().y - (nY + nHeight);
+            else
+                nY = pParent->GetClientSize().y - (nY + nHeight);
+        }
+        else
+            nY = pParent->GetSize().y - (nY + nHeight);
+    }
     else
-        hParent = HWND_DESKTOP;
-    ::WinQueryWindowRect(hParent, &vRect);
-    nY = vRect.yTop - (nY + nHeight);
-#endif
-    if ( !::WinSetWindowPos( GetHwnd()
-                            ,HWND_TOP
-                            ,(LONG)nX
-                            ,(LONG)nY
-                            ,(LONG)nWidth
-                            ,(LONG)nHeight
-                            ,SWP_SIZE | SWP_MOVE
-                           ))
     {
-        wxLogLastError("MoveWindow");
+        RECTL                       vRect;
+
+        ::WinQueryWindowRect(HWND_DESKTOP, &vRect);
+        nY = vRect.yTop - (nY + nHeight);
     }
+    ::WinSetWindowPos( GetHwnd()
+                      ,HWND_TOP
+                      ,(LONG)nX
+                      ,(LONG)nY
+                      ,(LONG)nWidth
+                      ,(LONG)nHeight
+                      ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW
+                     );
 } // end of wxWindowOS2::DoMoveWindow
 
 //
@@ -1745,55 +1794,94 @@ void wxWindowOS2::GetTextExtent(
 , const wxFont*                     pTheFont
 ) const
 {
-    const wxFont*                   pFontToUse = pTheFont;
-    HPS                             hPs;
-
-    hPs = ::WinGetPS(GetHwnd());
+    POINTL                          avPoint[TXTBOX_COUNT];
+    POINTL                          vPtMin;
+    POINTL                          vPtMax;
+    int                             i;
+    int                             l;
+    FONTMETRICS                     vFM; // metrics structure
+    BOOL                            bRc;
+    char*                           pStr;
+    ERRORID                         vErrorCode; // last error id code
+    HPS                             hPS;
 
-    // Just prevent compiler warnings
-    wxString dummy = rString;
-    pX = pX;
-    pY = pY;
-    pDescent = pDescent;
-    pExternalLeading = pExternalLeading;
-/*
-// TODO: Will have to play with fonts later
 
-    if (!pFontToUse)
-        pFontToUse = &m_font;
+    hPS = ::WinGetPS(GetHwnd());
 
-    HFONT                           hFnt = 0;
-    HFONT                           hFfontOld = 0;
+    l = rString.Length();
+    if (l > 0L)
+    {
+        pStr = (PCH)rString.c_str();
 
-    if (pFontToUse && pFontToUse->Ok())
+        //
+        // In world coordinates.
+        //
+        bRc = ::GpiQueryTextBox( hPS
+                                ,l
+                                ,pStr
+                                ,TXTBOX_COUNT // return maximum information
+                                ,avPoint      // array of coordinates points
+                               );
+        if (bRc)
+        {
+            vPtMin.x = avPoint[0].x;
+            vPtMax.x = avPoint[0].x;
+            vPtMin.y = avPoint[0].y;
+            vPtMax.y = avPoint[0].y;
+            for (i = 1; i < 4; i++)
+            {
+                if(vPtMin.x > avPoint[i].x) vPtMin.x = avPoint[i].x;
+                if(vPtMin.y > avPoint[i].y) vPtMin.y = avPoint[i].y;
+                if(vPtMax.x < avPoint[i].x) vPtMax.x = avPoint[i].x;
+                if(vPtMax.y < avPoint[i].y) vPtMax.y = avPoint[i].y;
+            }
+            bRc = ::GpiQueryFontMetrics( hPS
+                                        ,sizeof(FONTMETRICS)
+                                        ,&vFM
+                                       );
+            if (!bRc)
+            {
+                vPtMin.x = 0;
+                vPtMin.y = 0;
+                vPtMax.x = 0;
+                vPtMax.y = 0;
+            }
+        }
+        else
+        {
+            vPtMin.x = 0;
+            vPtMin.y = 0;
+            vPtMax.x = 0;
+            vPtMax.y = 0;
+        }
+    }
+    else
     {
-        ::GpiCreateLog
-        hFnt = (HFONT)((wxFont *)pFontToUse)->GetResourceHandle(); // const_cast
-        if (hFnt)
-            hFontOld = (HFONT)SelectObject(dc,fnt);
+        vPtMin.x = 0;
+        vPtMin.y = 0;
+        vPtMax.x = 0;
+        vPtMax.y = 0;
     }
-
-    SIZE sizeRect;
-    TEXTMETRIC tm;
-    GetTextExtentPoint(dc, string, (int)string.Length(), &sizeRect);
-    GetTextMetrics(dc, &tm);
-
-    if ( fontToUse && fnt && hfontOld )
-        SelectObject(dc, hfontOld);
-
-    ReleaseDC(hWnd, dc);
-
-    if ( x )
-        *x = sizeRect.cx;
-    if ( y )
-        *y = sizeRect.cy;
-    if ( descent )
-        *descent = tm.tmDescent;
-    if ( externalLeading )
-        *externalLeading = tm.tmExternalLeading;
-*/
-    ::WinReleasePS(hPs);
-}
+    if (pX)
+        *pX = (vPtMax.x - vPtMin.x + 1);
+    if (pY)
+        *pY = (vPtMax.y - vPtMin.y + 1);
+    if (pDescent)
+    {
+        if (bRc)
+            *pDescent = vFM.lMaxDescender;
+        else
+            *pDescent = 0;
+    }
+    if (pExternalLeading)
+    {
+        if (bRc)
+            *pExternalLeading = vFM.lExternalLeading;
+        else
+            *pExternalLeading = 0;
+    }
+    ::WinReleasePS(hPS);
+} // end of wxWindow::GetTextExtent
 
 #if wxUSE_CARET && WXWIN_COMPATIBILITY
 // ---------------------------------------------------------------------------
@@ -2448,7 +2536,7 @@ MRESULT wxWindowOS2::OS2WindowProc(
                 if (uKeyFlags & KC_KEYUP)
                 {
                     //TODO: check if the cast to WXWORD isn't causing trouble
-                    bProcessed = HandleKeyUp((WXWORD)wParam, lParam);
+                    bProcessed = HandleKeyUp((WXDWORD)wParam, lParam);
                     break;
                 }
                 else // keydown event
@@ -2458,7 +2546,7 @@ MRESULT wxWindowOS2::OS2WindowProc(
                     // return 0 now (we've handled it). DON't RETURN
                     // we still need to process further
                     //
-                    HandleKeyDown((WXWORD)wParam, lParam);
+                    HandleKeyDown((WXDWORD)wParam, lParam);
                     if (uKeyFlags & KC_VIRTUALKEY)
                     {
                         USHORT          uVk = SHORT2FROMMP((MPARAM)lParam);
@@ -2492,13 +2580,13 @@ MRESULT wxWindowOS2::OS2WindowProc(
                             case VK_DOWN:
                             case VK_UP:
                             default:
-                                bProcessed = HandleChar((WXWORD)wParam, lParam);
+                                bProcessed = HandleChar((WXDWORD)wParam, lParam);
                          }
                          break;
                     }
                     else // WM_CHAR -- Always an ASCII character
                     {
-                        bProcessed = HandleChar((WXWORD)wParam, lParam, TRUE);
+                        bProcessed = HandleChar((WXDWORD)wParam, lParam, TRUE);
                         break;
                     }
                 }
@@ -2542,20 +2630,6 @@ MRESULT wxWindowOS2::OS2WindowProc(
             mResult = (MRESULT)(FALSE);
             break;
 
-        //
-        // Instead of CTLCOLOR messages PM sends QUERYWINDOWPARAMS to
-        // things such as colors and fonts and such
-        //
-        case WM_QUERYWINDOWPARAMS:
-            {
-                PWNDPARAMS          pWndParams = (PWNDPARAMS)wParam;
-
-                bProcessed = HandleWindowParams( pWndParams
-                                                ,lParam
-                                               );
-            }
-            break;
-
             // the return value for this message is ignored
         case WM_SYSCOLORCHANGE:
             bProcessed = HandleSysColorChange();
@@ -2565,11 +2639,6 @@ MRESULT wxWindowOS2::OS2WindowProc(
             bProcessed = HandlePaletteChanged();
             break;
 
-        case WM_PRESPARAMCHANGED:
-            bProcessed = HandlePresParamChanged(wParam);
-            break;
-
-
         // move all drag and drops to wxDrg
         case WM_ENDDRAG:
             bProcessed = HandleEndDrag(wParam);
@@ -3282,14 +3351,6 @@ bool wxWindowOS2::HandleCtlColor(
     return TRUE;
 } // end of wxWindowOS2::HandleCtlColor
 
-bool wxWindowOS2::HandleWindowParams(
-  PWNDPARAMS                        WXUNUSED(pWndParams)
-, WXLPARAM                          WXUNUSED(lParam)
-)
-{
-// TODO: I'll do something here, just not sure what yet
-    return TRUE;
-}
 
 // Define for each class of dialog and control
 WXHBRUSH wxWindowOS2::OnCtlColor(WXHDC WXUNUSED(hDC),
@@ -3315,21 +3376,6 @@ bool wxWindowOS2::HandlePaletteChanged()
     return GetEventHandler()->ProcessEvent(vEvent);
 } // end of wxWindowOS2::HandlePaletteChanged
 
-bool wxWindowOS2::HandlePresParamChanged(
-  WXWPARAM                          WXUNUSED(wParam)
-)
-{
-    //
-    // TODO:  Once again I'll do something here when I need it
-    //
-    //wxQueryNewPaletteEvent event(GetId());
-    //event.SetEventObject(this);
-    // if the background is erased
-//            bProcessed = HandleEraseBkgnd((WXHDC)(HDC)wParam);
-
-    return FALSE; //GetEventHandler()->ProcessEvent(event) && event.GetPaletteRealized();
-}
-
 //
 // Responds to colour changes: passes event on to children.
 //
@@ -3385,65 +3431,6 @@ bool wxWindowOS2::HandlePaint()
     vEvent.SetEventObject(this);
     bProcessed = GetEventHandler()->ProcessEvent(vEvent);
 
-    if (!bProcessed)
-    {
-        HPS                         hPS;
-
-        hPS = ::WinBeginPaint( GetHwnd()
-                              ,NULLHANDLE
-                              ,&vRect
-                             );
-        if(hPS)
-        {
-#if 0
-            ::GpiCreateLogColorTable( hPS
-                                     ,0L
-                                     ,LCOLF_CONSECRGB
-                                     ,0L
-                                     ,(LONG)wxTheColourDatabase->m_nSize
-                                     ,(PLONG)wxTheColourDatabase->m_palTable
-                                    );
-#endif
-            ::GpiCreateLogColorTable( hPS
-                                     ,0L
-                                     ,LCOLF_RGB
-                                     ,0L
-                                     ,0L
-                                     ,NULL
-                                    );
-
-            ::WinFillRect(hPS, &vRect,  GetBackgroundColour().GetPixel());
-
-            if (m_dwExStyle)
-            {
-                LINEBUNDLE                      vLineBundle;
-
-                vLineBundle.lColor     = 0x00000000; // Black
-                vLineBundle.usMixMode  = FM_OVERPAINT;
-                vLineBundle.fxWidth    = 1;
-                vLineBundle.lGeomWidth = 1;
-                vLineBundle.usType     = LINETYPE_SOLID;
-                vLineBundle.usEnd      = 0;
-                vLineBundle.usJoin     = 0;
-                ::GpiSetAttrs( hPS
-                              ,PRIM_LINE
-                              ,LBB_COLOR | LBB_MIX_MODE | LBB_WIDTH | LBB_GEOM_WIDTH | LBB_TYPE
-                              ,0L
-                              ,&vLineBundle
-                             );
-                ::WinQueryWindowRect(GetHwnd(), &vRect);
-                wxDrawBorder( hPS
-                             ,vRect
-                             ,m_dwExStyle
-                            );
-            }
-            ::WinEndPaint(hPS);
-        }
-    }
-
-    ::GpiDestroyRegion(hPS, hRgn);
-    ::WinReleasePS(hPS);
-
     return GetEventHandler()->ProcessEvent(vEvent); //bProcessed;
 } // end of wxWindowOS2::HandlePaint
 
@@ -3755,7 +3742,7 @@ wxKeyEvent wxWindowOS2::CreateKeyEvent(
 // WM_KEYDOWN one
 //
 bool wxWindowOS2::HandleChar(
-  WXWORD                            wParam
+  WXDWORD                           wParam
 , WXLPARAM                          lParam
 , bool                              isASCII
 )
@@ -3849,7 +3836,7 @@ bool wxWindowOS2::HandleKeyDown(
 } // end of wxWindowOS2::HandleKeyDown
 
 bool wxWindowOS2::HandleKeyUp(
-  WXWORD                            wParam
+  WXDWORD                           wParam
 , WXLPARAM                          lParam
 )
 {
@@ -3946,13 +3933,34 @@ bool wxWindowOS2::OS2OnScroll(
 // ===========================================================================
 
 void wxGetCharSize(
-  WXHWND                            WXUNUSED(hWnd)
-, int*                              WXUNUSED(pX)
-, int*                              WXUNUSED(pY)
+  WXHWND                            hWnd
+, int*                              pX
+, int*                              pY
 ,wxFont*                            WXUNUSED(pTheFont)
 )
 {
-  // TODO: we'll do this later
+    FONTMETRICS                     vFM;
+    HPS                             hPS;
+    BOOL                            rc;
+
+    hPS =::WinGetPS(hWnd);
+
+    rc = ::GpiQueryFontMetrics(hPS, sizeof(FONTMETRICS), &vFM);
+    if (rc)
+    {
+        if (pX)
+            *pX = vFM.lAveCharWidth;
+        if (pY)
+            *pY = vFM.lEmHeight + vFM.lExternalLeading;
+    }
+    else
+    {
+        if (pX)
+            *pX = 10;
+        if (pY)
+            *pY = 15;
+    }
+    ::WinReleasePS(hPS);
 } // end of wxGetCharSize
 
 //