Changeset 2292 for trunk/src


Ignore:
Timestamp:
Jan 2, 2000, 8:30:47 PM (26 years ago)
Author:
cbratschi
Message:

* empty log message *

Location:
trunk/src/user32/new
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/new/controls.cpp

    r2290 r2292  
    1 /* $Id: controls.cpp,v 1.13 2000-01-01 14:57:10 cbratschi Exp $ */
     1/* $Id: controls.cpp,v 1.14 2000-01-02 19:30:42 cbratschi Exp $ */
    22/* File: controls.cpp -- Win32 common controls
    33 *
     
    116116
    117117
    118 BOOL WIDGETS_IsControl(Win32BaseWindow *window, int control)
     118BOOL CONTROLS_IsControl(Win32BaseWindow *window, int control)
    119119{
    120120  if(control >= MAX_CONTROLS || window == NULL || window->getClass() == NULL)
  • trunk/src/user32/new/controls.h

    r2290 r2292  
    1 /* $Id: controls.h,v 1.1 2000-01-01 14:54:51 cbratschi Exp $ */
     1/* $Id: controls.h,v 1.2 2000-01-02 19:30:42 cbratschi Exp $ */
    22/*
    33 * Win32 common controls
     
    3333#define MAX_CONTROLS            12
    3434
    35 BOOL WIDGETS_IsControl(Win32BaseWindow *window, int control);
     35BOOL CONTROLS_IsControl(Win32BaseWindow *window, int control);
    3636
    3737
  • trunk/src/user32/new/dc.cpp

    r2290 r2292  
    1 /* $Id: dc.cpp,v 1.6 2000-01-01 14:57:10 cbratschi Exp $ */
     1/* $Id: dc.cpp,v 1.7 2000-01-02 19:30:42 cbratschi Exp $ */
    22
    33/*
     
    12431243    }
    12441244    dprintf(("ScrollWindow %x %d %d %x %x", hwnd, dx, dy, pScroll, pClip));
    1245     mapWin32ToOS2Rect(window,window->getClientRect(), (PRECTLOS2)&clientRect);
     1245    mapWin32ToOS2Rect(window,window->getClientRectPtr(),(PRECTLOS2)&clientRect);
    12461246    //Rectangle could be relative to parent window, so fix this
    12471247    if(clientRect.yBottom != 0) {
  • trunk/src/user32/new/oslibmsgtranslate.cpp

    r2291 r2292  
    1 /* $Id: oslibmsgtranslate.cpp,v 1.2 2000-01-01 17:07:41 cbratschi Exp $ */
     1/* $Id: oslibmsgtranslate.cpp,v 1.3 2000-01-02 19:30:43 cbratschi Exp $ */
    22/*
    33 * Window message translation functions for OS/2
     
    113113  win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(os2Msg->hwnd);
    114114  //PostThreadMessage posts WIN32APP_POSTMSG msg without window handle
    115   if((win32wnd == 0 && os2Msg->msg != WM_CREATE && os2Msg->msg != WIN32APP_POSTMSG))
     115  if((win32wnd == 0) && (os2Msg->msg != WM_CREATE) && (os2Msg->msg != WIN32APP_POSTMSG))
    116116  {
    117117        goto dummymessage; //not a win32 client window
     
    298298
    299299        if (!win32wnd->CanReceiveSizeMsgs())    goto dummymessage;
    300 
     300//CB: todo: send WM_NCCALCSIZE
     301#if 0   //CB: ignore it
    301302        dprintf(("Set client rectangle to (%d,%d)(%d,%d)", swpOld.x, swpOld.y, swpOld.x + swpOld.cx, swpOld.y + swpOld.cy));
    302303        win32wnd->setClientRect(swpOld.x, swpOld.y, swpOld.x + swpOld.cx, swpOld.y + swpOld.cy);
     
    321322            goto dummymessage;
    322323        }
     324#else
     325        goto dummymessage;
     326#endif
    323327    }
    324328
  • trunk/src/user32/new/oslibwin.cpp

    r2291 r2292  
    1 /* $Id: oslibwin.cpp,v 1.30 2000-01-01 17:07:41 cbratschi Exp $ */
     1/* $Id: oslibwin.cpp,v 1.31 2000-01-02 19:30:43 cbratschi Exp $ */
    22/*
    33 * Window API wrappers for OS/2
     
    5252//******************************************************************************
    5353//******************************************************************************
    54 HWND OSLibWinCreateWindow(HWND hwndParent, ULONG dwWinStyle, ULONG dwFrameStyle,
     54HWND OSLibWinCreateWindow(HWND hwndParent,ULONG dwWinStyle,
    5555                          char *pszName, HWND Owner, ULONG fHWND_BOTTOM, HWND *hwndFrame,
    5656                          ULONG id, BOOL fTaskList)
     
    5858 HWND  hwndClient;
    5959
    60   dprintf(("WinCreateWindow %x %x %x %s", hwndParent, dwWinStyle, dwFrameStyle, pszName));
     60  dprintf(("WinCreateWindow %x %x %x %s", hwndParent, pszName));
    6161
    6262  if(pszName && *pszName == 0) {
     
    6969        Owner = HWND_DESKTOP;
    7070  }
    71   ULONG dwClientStyle;
     71  ULONG dwClientStyle = 0;
     72  ULONG dwFrameStyle = 0;
    7273#if 1
    7374
    7475  BOOL TopLevel = hwndParent == HWND_DESKTOP;
    75 //  if(dwFrameStyle & FCF_TITLEBAR)
    76 //      TopLevel = TRUE;
    7776
    7877  FRAMECDATA FCData = {sizeof (FRAMECDATA), 0, 0, 0};
     
    9493                                hwndParent, HWND_TOP,
    9594                                id, &FCData, NULL);
     95
    9696  if (*hwndFrame) {
    9797    hwndClient = WinCreateWindow (*hwndFrame, WIN32_STDCLASS,
    9898                                  NULL, dwClientStyle, 0, 0, 0, 0,
    9999                                  *hwndFrame, HWND_TOP, FID_CLIENT, NULL, NULL);
    100     if (hwndClient != NULLHANDLE)
    101       WinSendMsg (*hwndFrame, WM_UPDATEFRAME, 0, 0);
    102 
    103100    return hwndClient;
    104101  }
  • trunk/src/user32/new/oslibwin.h

    r2290 r2292  
    1 /* $Id: oslibwin.h,v 1.27 2000-01-01 14:54:53 cbratschi Exp $ */
     1/* $Id: oslibwin.h,v 1.28 2000-01-02 19:30:43 cbratschi Exp $ */
    22/*
    33 * Window API wrappers for OS/2
     
    3737
    3838
    39 HWND  OSLibWinCreateWindow(HWND hwndParent, ULONG dwWinStyle, ULONG dwFrameStyle,
     39HWND  OSLibWinCreateWindow(HWND hwndParent,ULONG dwWinStyle,
    4040                           char *pszName, HWND Owner, ULONG fBottom,
    4141                           HWND *hwndFrame, ULONG id, BOOL fTaskList);
  • trunk/src/user32/new/pmframe.cpp

    r2291 r2292  
    1 /* $Id: pmframe.cpp,v 1.2 2000-01-01 17:07:42 cbratschi Exp $ */
     1/* $Id: pmframe.cpp,v 1.3 2000-01-02 19:30:43 cbratschi Exp $ */
    22/*
    33 * Win32 Frame Managment Code for OS/2
     
    1616#include <os2wrap.h>
    1717#include <stdlib.h>
     18#include <string.h>
    1819#include "win32type.h"
    1920#include <misc.h>
     
    2425#include "oslibwin.h"
    2526#include "caret.h"
     27#include "oslibmsg.h"
    2628
    2729#define PMFRAMELOG
     
    216218 MRESULT          rc;
    217219 THDB            *thdb;
    218  MSG             *pWinMsg;
     220 MSG             *pWinMsg,winMsg;
    219221
    220222  SetWin32TIB();
     
    228230    goto RunDefWndProc;
    229231  }
    230   pWinMsg = &thdb->msg;
     232
     233  if((thdb->msgstate & 1) == 0)
     234  {//message that was sent directly to our window proc handler; translate it here
     235        QMSG qmsg;
     236
     237        qmsg.msg  = msg;
     238        qmsg.hwnd = hwnd;
     239        qmsg.mp1  = mp1;
     240        qmsg.mp2  = mp2;
     241        qmsg.time = WinQueryMsgTime(thdb->hab);
     242        WinQueryMsgPos(thdb->hab, &qmsg.ptl);
     243        qmsg.reserved = 0;
     244
     245        if(OS2ToWinMsgTranslate((PVOID)thdb, &qmsg, &winMsg, FALSE, MSG_REMOVE) == FALSE)
     246        {//message was not translated
     247            memset(&winMsg, 0, sizeof(MSG));
     248        }
     249        pWinMsg = &winMsg;
     250  }
     251  else {
     252        pWinMsg = &thdb->msg;
     253        thdb->msgstate++;
     254  }
    231255
    232256  OldFrameProc = (PFNWP)win32wnd->getOldFrameProc();
     
    236260    case WM_FORMATFRAME:
    237261    {
    238       RECTL *client;
    239 
     262      PSWP pswp = (PSWP)mp1,swpClient;
     263      RECTL *client = (PRECTL)mp2,rect;
     264      INT ccount;
     265
     266      if (!win32wnd->IsWindowCreated()) goto RunDefFrameProc;
    240267      dprintf(("PMFRAME: WM_FORMATFRAME %x",hwnd));
    241       client = (PRECTL)mp2;
    242 #if 0
    243 //CB: todo: client rect is wrong/not set with WM_NCCALCSIZE
    244       mapWin32ToOS2Rect(hwnd,win32wnd->getClientRectPtr(),(PRECTLOS2)client);
    245 
    246       RestorOS2TIB();
    247       return (MRESULT)1;
    248 #else
    249       goto RunDefFrameProc;
    250 #endif
     268      RestoreOS2TIB();
     269      ccount = (INT)OldFrameProc(hwnd,msg,mp1,mp2);
     270      SetWin32TIB();
     271      mapWin32ToOS2Rect(WinQueryWindow(hwnd,QW_PARENT),win32wnd->getClientRectPtr(),(PRECTLOS2)&rect);
     272      WinMapWindowPoints(WinQueryWindow(hwnd,QW_PARENT),hwnd,(PPOINTL)&rect,2);
     273      swpClient = &pswp[ccount-1];
     274      swpClient->x = rect.xLeft;
     275      swpClient->y = rect.yBottom;
     276      swpClient->cx = rect.xRight-rect.xLeft;
     277      swpClient->cy = rect.yTop-rect.yBottom;
     278      RestoreOS2TIB();
     279      return (MRESULT)ccount;
    251280    }
    252281
     
    268297    case WM_BUTTON3UP:
    269298    case WM_BUTTON3DBLCLK:
    270         win32wnd->MsgButton(pWinMsg);
    271         RestoreOS2TIB();
     299        if (win32wnd->IsWindowCreated())
     300        {
     301          win32wnd->MsgButton(pWinMsg);
     302          RestoreOS2TIB();
     303        }
    272304        return (MRESULT)TRUE;
    273305
     
    287319    {
    288320        //OS/2 Window coordinates -> Win32 Window coordinates
    289         win32wnd->MsgMouseMove(pWinMsg);
     321        if (win32wnd->IsWindowCreated())
     322          win32wnd->MsgMouseMove(pWinMsg);
    290323        RestoreOS2TIB();
    291324        return (MRESULT)TRUE;
     
    297330
    298331      // Only send this message if the window is enabled
    299       if (!WinIsWindowEnabled(hwnd))
     332      if (!win32wnd->IsWindowCreated())
     333        res = HT_NORMAL;
     334      else if (!WinIsWindowEnabled(hwnd))
    300335        res = HT_ERROR;
    301336      else if (win32wnd->getIgnoreHitTest())
     
    315350
    316351    case WM_PAINT:
    317         win32wnd->DispatchMsgA(pWinMsg);
     352        dprintf(("PMFRAME: WM_PAINT"));
     353        if (win32wnd->IsWindowCreated())
     354          win32wnd->MsgNCPaint();
    318355        goto RunDefWndProc;
    319356
     
    430467      UINT res = CVR_ALIGNLEFT | CVR_ALIGNTOP;
    431468
    432       //CB: only used if CS_SIZEDRAW isn't set
    433       //    PM moves children -> fast, no flickering (if redraw flags not set)
     469//CB: todo: use WM_NCCALCSIZE
    434470      if (win32wnd->getWindowClass())
    435471      {
     
    456492        USHORT flags = WinQueryWindowUShort(hwnd,QWS_FLAGS);
    457493
    458         //CB: emulate WM_ACTIVATE -> no flickering
    459         hwndTitle = WinWindowFromID(hwnd,FID_TITLEBAR);
    460         if (hwndTitle) WinSendMsg(hwndTitle,TBM_SETHILITE,mp1,MPVOID);
    461 
    462         WinSendMsg(WinWindowFromID(hwnd,FID_CLIENT),WM_ACTIVATE,mp1,mp2);
    463         WinSetWindowUShort(hwnd,QWS_FLAGS,mp1 ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
    464 
    465         //CB: show owner behind the dialog
    466         if (win32wnd->IsModalDialog())
     494        if (win32wnd->IsWindowCreated())
    467495        {
    468           Win32BaseWindow *topOwner = win32wnd->getOwner()->GetTopParent();
    469 
    470           if (topOwner) WinSetWindowPos(topOwner->getOS2FrameWindowHandle(),hwnd,0,0,0,0,SWP_ZORDER);
     496          WinSendMsg(WinWindowFromID(hwnd,FID_CLIENT),WM_ACTIVATE,mp1,mp2);
     497          WinSetWindowUShort(hwnd,QWS_FLAGS,mp1 ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
     498
     499          //CB: show owner behind the dialog
     500          if (win32wnd->IsModalDialog())
     501          {
     502            Win32BaseWindow *topOwner = win32wnd->getOwner()->GetTopParent();
     503
     504            if (topOwner) WinSetWindowPos(topOwner->getOS2FrameWindowHandle(),hwnd,0,0,0,0,SWP_ZORDER);
     505          }
     506        } else
     507        {
     508          WinSetWindowUShort(hwnd,QWS_FLAGS,mp1 ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
    471509        }
    472510
  • trunk/src/user32/new/win32dlg.cpp

    r2290 r2292  
    1 /* $Id: win32dlg.cpp,v 1.9 2000-01-01 14:57:27 cbratschi Exp $ */
     1/* $Id: win32dlg.cpp,v 1.10 2000-01-02 19:30:43 cbratschi Exp $ */
    22/*
    33 * Win32 Dialog Code for OS/2
     
    791791            {
    792792                /* always make combo box hide its listbox control */
    793                 if( WIDGETS_IsControl( wndFocus, COMBOBOX_CONTROL ) )
     793                if( CONTROLS_IsControl( wndFocus, COMBOBOX_CONTROL ) )
    794794                    wndFocus->SendMessageA(CB_SHOWDROPDOWN, FALSE, 0 );
    795795                else
    796                 if( WIDGETS_IsControl( wndFocus, EDIT_CONTROL ) &&
    797                     WIDGETS_IsControl( wndFocus->getParent(), COMBOBOX_CONTROL ))
     796                if( CONTROLS_IsControl( wndFocus, EDIT_CONTROL ) &&
     797                    CONTROLS_IsControl( wndFocus->getParent(), COMBOBOX_CONTROL ))
    798798                    wndFocus->SendMessageA(CB_SHOWDROPDOWN, FALSE, 0 );
    799799            }
  • trunk/src/user32/new/win32wbase.cpp

    r2290 r2292  
    1 /* $Id: win32wbase.cpp,v 1.18 2000-01-01 14:57:28 cbratschi Exp $ */
     1/* $Id: win32wbase.cpp,v 1.19 2000-01-02 19:30:44 cbratschi Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    7676    !(style & (WS_CHILD | WS_POPUP))
    7777
     78#define HAS_MENU(w) (!((w)->getStyle() & WS_CHILD) && ((w)->getWindowId() != 0))
     79
    7880/* bits in the dwKeyData */
    7981#define KEYDATA_ALT         0x2000
     
    8587//For quick lookup of current process id
    8688static ULONG currentProcessId = -1;
     89
     90static HBITMAP hbitmapClose = 0;
     91static HBITMAP hbitmapCloseD = 0;
     92static HBITMAP hbitmapMinimize = 0;
     93static HBITMAP hbitmapMinimizeD = 0;
     94static HBITMAP hbitmapMaximize = 0;
     95static HBITMAP hbitmapMaximizeD = 0;
     96static HBITMAP hbitmapRestore = 0;
     97static HBITMAP hbitmapRestoreD = 0;
     98
     99BYTE lpGrayMask[] = { 0xAA, 0xA0,
     100                      0x55, 0x50,
     101                      0xAA, 0xA0,
     102                      0x55, 0x50,
     103                      0xAA, 0xA0,
     104                      0x55, 0x50,
     105                      0xAA, 0xA0,
     106                      0x55, 0x50,
     107                      0xAA, 0xA0,
     108                      0x55, 0x50};
    87109
    88110//******************************************************************************
     
    102124  fIsSubclassedOS2Wnd = TRUE;
    103125  fFirstShow = FALSE;
     126  fCreated = TRUE;
    104127
    105128  SetLastError(0);
     
    456479
    457480  hwndLinkAfter = HWND_TOP;
    458   if(WIDGETS_IsControl(this, BUTTON_CONTROL) && ((dwStyle & 0x0f) == BS_GROUPBOX))
     481  if(CONTROLS_IsControl(this, BUTTON_CONTROL) && ((dwStyle & 0x0f) == BS_GROUPBOX))
    459482  {
    460483        hwndLinkAfter = HWND_BOTTOM;
     
    462485  }
    463486  else
    464   if(WIDGETS_IsControl(this, STATIC_CONTROL) && !(dwStyle & WS_GROUP)) {
     487  if(CONTROLS_IsControl(this, STATIC_CONTROL) && !(dwStyle & WS_GROUP)) {
    465488        dwStyle |= WS_CLIPSIBLINGS;
    466489  }
     
    512535        vertScrollInfo->flags  = ESB_ENABLE_BOTH;
    513536  }
    514 
     537#if 0 //CB: PM frame not yet created!
    515538  /* Send the WM_GETMINMAXINFO message and fix the size if needed */
    516539  if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
     
    522545        if (cs->cy < minTrack.y ) cs->cy = minTrack.y;
    523546  }
    524 
     547#endif
    525548  if(cs->style & WS_CHILD)
    526549  {
     
    583606
    584607  OS2Hwnd = OSLibWinCreateWindow((getParent()) ? getParent()->getOS2WindowHandle() : OSLIB_HWND_DESKTOP,
    585                                  dwOSWinStyle, dwOSFrameStyle, (char *)windowNameA,
     608                                 dwOSWinStyle,(char *)windowNameA,
    586609                                 (owner) ? owner->getOS2WindowHandle() : OSLIB_HWND_DESKTOP,
    587610                                 (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE,
     
    619642        return FALSE;
    620643  }
    621 #if 0
    622   if(OS2Hwnd != OS2HwndFrame) {
    623     if(OSLibWinSetWindowULong(OS2HwndFrame, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) {
    624             dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2HwndFrame));
    625             SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
    626             return FALSE;
    627     }
    628     if(OSLibWinSetWindowULong(OS2HwndFrame, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) {
    629             dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2HwndFrame));
    630             SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
    631             return FALSE;
    632     }
    633   }
    634 #endif
    635644
    636645  OSLibWinSetOwner(OS2Hwnd, OS2HwndFrame);
    637646
    638   FrameGetScrollBarHandles(this,dwStyle & WS_HSCROLL,dwStyle & WS_VSCROLL);
    639   subclassScrollBars(dwStyle & WS_HSCROLL,dwStyle & WS_VSCROLL);
     647  //FrameGetScrollBarHandles(this,dwStyle & WS_HSCROLL,dwStyle & WS_VSCROLL);
     648  //subclassScrollBars(dwStyle & WS_HSCROLL,dwStyle & WS_VSCROLL);
    640649
    641650  fakeWinBase.hwndThis     = OS2Hwnd;
     
    645654  if(windowClass->getIcon())
    646655        SetIcon(windowClass->getIcon());
    647 
    648656  /* Get class or window DC if needed */
    649657  if(windowClass->getStyle() & CS_OWNDC) {
     
    682690  // Subclass frame
    683691  pOldFrameProc = FrameSubclassFrameWindow(this);
    684   if (isChild()) FrameSetBorderSize(this,TRUE);
    685 
     692  //if (isChild()) FrameSetBorderSize(this,TRUE);
     693
     694  //preset rects
     695  rectWindow.left = cs->x;
     696  rectWindow.right = cs->x+cs->cx;
     697  rectWindow.top = cs->y;
     698  rectWindow.bottom = cs->y+cs->cy;
     699  rectClient = rectWindow;
     700  if (getParent()) MapWindowPoints(getParent()->getWindowHandle(),0,(PPOINT)&rectWindow,2);
    686701  /* Send the WM_CREATE message
    687702   * Perhaps we shouldn't allow width/height changes as well.
     
    690705  maxPos.x = rectWindow.left; maxPos.y = rectWindow.top;
    691706
    692   SetWindowPos(hwndLinkAfter,cs->x,cs->y,cs->cx,cs->cy,SWP_NOACTIVATE | SWP_NOREDRAW);
     707  //SetWindowPos(hwndLinkAfter,cs->x,cs->y,cs->cx,cs->cy,SWP_NOACTIVATE | SWP_NOREDRAW);
    693708
    694709  //Note: Solitaire crashes when receiving WM_SIZE messages before WM_CREATE
    695710  fNoSizeMsg = FALSE;
     711  fCreated = TRUE;
    696712
    697713  if(SendInternalMessageA(WM_NCCREATE, 0, (LPARAM)cs) )
    698714  {
    699         fCreated = TRUE;
    700 
     715        RECT rect;
     716
     717        //update rect
     718        rectWindow.left = cs->x;
     719        rectWindow.right = cs->x+cs->cx;
     720        rectWindow.top = cs->y;
     721        rectWindow.bottom = cs->y+cs->cy;
     722        rectClient = rectWindow;
     723        if (getParent()) MapWindowPoints(getParent()->getWindowHandle(),0,(PPOINT)&rectWindow,2);
    701724        SendNCCalcSize(FALSE, &rectWindow, NULL, NULL, 0, &rectClient );
    702 //        OffsetRect(&rectWindow, maxPos.x - rectWindow.left, maxPos.y - rectWindow.top);
     725        OffsetRect(&rectWindow, maxPos.x - rectWindow.left, maxPos.y - rectWindow.top);
     726        //set the window size and update the client
     727        rect = rectWindow;
     728        if (getParent()) MapWindowPoints(0,getParent()->getWindowHandle(),(PPOINT)&rect,2);
     729        SetWindowPos(hwndLinkAfter,rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,SWP_NOACTIVATE | SWP_NOREDRAW | SWP_FRAMECHANGED);
    703730        if( (SendInternalMessageA(WM_CREATE, 0, (LPARAM)cs )) != -1 )
    704731        {
     
    10761103ULONG Win32BaseWindow::MsgNCPaint()
    10771104{
    1078     return SendInternalMessageA(WM_PAINT, 0, 0);
     1105  HRGN hrgn;
     1106
     1107  hrgn = 0; //CB: todo: set to frame update region
     1108  return SendInternalMessageA(WM_NCPAINT,hrgn,0);
    10791109}
    10801110//******************************************************************************
     
    12271257  return rc;
    12281258}
    1229 /***********************************************************************
    1230  *           NC_HandleNCLButtonDown
    1231  *
    1232  * Handle a WM_NCLBUTTONDOWN message. Called from DefWindowProc().
    1233  */
     1259//******************************************************************************
     1260//******************************************************************************
     1261LONG Win32BaseWindow::HandleNCActivate(WPARAM wParam)
     1262{
     1263  WORD wStateChange;
     1264
     1265  if( wParam ) wStateChange = !(flags & WIN_NCACTIVATED);
     1266  else wStateChange = flags & WIN_NCACTIVATED;
     1267
     1268  if( wStateChange )
     1269  {
     1270    if (wParam) flags |= WIN_NCACTIVATED;
     1271    else flags &= ~WIN_NCACTIVATED;
     1272
     1273    if(!(dwStyle & WS_MINIMIZE))
     1274      DoNCPaint((HRGN)1,FALSE);
     1275  }
     1276
     1277  return TRUE;
     1278}
     1279//******************************************************************************
     1280//******************************************************************************
     1281VOID Win32BaseWindow::TrackMinMaxBox(WORD wParam)
     1282{
     1283  MSG msg;
     1284  HDC hdc;
     1285  BOOL pressed = TRUE;
     1286  UINT state;
     1287
     1288  if (wParam == HTMINBUTTON)
     1289  {
     1290    /* If the style is not present, do nothing */
     1291    if (!(dwStyle & WS_MINIMIZEBOX))
     1292      return;
     1293    /* Check if the sysmenu item for minimize is there  */
     1294#if 0 //CB: todo
     1295    state = GetMenuState(hSysMenu,SC_MINIMIZE,MF_BYCOMMAND);
     1296#endif
     1297  } else
     1298  {
     1299    /* If the style is not present, do nothing */
     1300    if (!(dwStyle & WS_MAXIMIZEBOX))
     1301      return;
     1302    /* Check if the sysmenu item for maximize is there  */
     1303#if 0 //CB: todo
     1304    state = GetMenuState(hSysMenu, SC_MAXIMIZE, MF_BYCOMMAND);
     1305#endif
     1306  }
     1307  SetCapture(Win32Hwnd);
     1308  hdc = GetWindowDC(Win32Hwnd);
     1309  if (wParam == HTMINBUTTON)
     1310    DrawMinButton(hdc,TRUE,FALSE);
     1311  else
     1312    DrawMaxButton(hdc,TRUE,FALSE);
     1313  do
     1314  {
     1315    BOOL oldstate = pressed;
     1316
     1317    GetMessageA(&msg,Win32Hwnd,0,0);
     1318    pressed = (HandleNCHitTest(msg.pt) == wParam);
     1319    if (pressed != oldstate)
     1320    {
     1321      if (wParam == HTMINBUTTON)
     1322        DrawMinButton(hdc,pressed,FALSE);
     1323      else
     1324        DrawMaxButton(hdc,pressed,FALSE);
     1325    }
     1326  } while (msg.message != WM_LBUTTONUP);
     1327  if (wParam == HTMINBUTTON)
     1328    DrawMinButton(hdc,FALSE,FALSE);
     1329  else
     1330    DrawMaxButton(hdc,FALSE,FALSE);
     1331  ReleaseCapture();
     1332  ReleaseDC(Win32Hwnd,hdc);
     1333  /* If the item minimize or maximize of the sysmenu are not there */
     1334  /* or if the style is not present, do nothing */
     1335  if ((!pressed) || (state == 0xFFFFFFFF))
     1336    return;
     1337  if (wParam == HTMINBUTTON)
     1338    SendInternalMessageA(WM_SYSCOMMAND,SC_MINIMIZE,*(LPARAM*)&msg.pt);
     1339  else
     1340    SendInternalMessageA(WM_SYSCOMMAND,IsZoomed(Win32Hwnd) ? SC_RESTORE:SC_MAXIMIZE,*(LPARAM*)&msg.pt);
     1341}
     1342//******************************************************************************
     1343//******************************************************************************
     1344VOID Win32BaseWindow::TrackCloseButton(WORD wParam)
     1345{
     1346  MSG msg;
     1347  HDC hdc;
     1348  BOOL pressed = TRUE;
     1349  UINT state;
     1350
     1351#if 0 //CB: todo
     1352  if (hSysMenu == 0)
     1353    return;
     1354  state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
     1355#endif 
     1356  /* If the item close of the sysmenu is disabled or not there do nothing */
     1357  if((state & MF_DISABLED) || (state & MF_GRAYED) || (state == 0xFFFFFFFF))
     1358    return;
     1359  hdc = GetWindowDC(Win32Hwnd);
     1360  SetCapture(Win32Hwnd);
     1361  DrawCloseButton(hdc,TRUE,FALSE);
     1362  do
     1363  {
     1364    BOOL oldstate = pressed;
     1365
     1366    GetMessageA(&msg,Win32Hwnd,0,0);
     1367    pressed = (HandleNCHitTest(msg.pt) == wParam);
     1368    if (pressed != oldstate)
     1369      DrawCloseButton(hdc, pressed, FALSE);
     1370  } while (msg.message != WM_LBUTTONUP);
     1371  DrawCloseButton(hdc, FALSE, FALSE);
     1372  ReleaseCapture();
     1373  ReleaseDC(Win32Hwnd, hdc );
     1374  if (!pressed) return;
     1375  SendInternalMessageA(WM_SYSCOMMAND,SC_CLOSE,*(LPARAM*)&msg.pt);
     1376}
     1377//******************************************************************************
     1378//******************************************************************************
    12341379LONG Win32BaseWindow::HandleNCLButtonDown(WPARAM wParam,LPARAM lParam)
    12351380{
     
    12371382  {
    12381383    case HTCAPTION:
    1239       SendInternalMessageA(WM_SYSCOMMAND,SC_MOVE+HTCAPTION,lParam);
     1384      SetActiveWindow();
     1385      if (GetActiveWindow() == Win32Hwnd)
     1386        SendInternalMessageA(WM_SYSCOMMAND,SC_MOVE+HTCAPTION,lParam);
    12401387      break;
    12411388
    12421389    case HTSYSMENU:
    1243       SendInternalMessageA(WM_SYSCOMMAND,SC_MOUSEMENU+HTSYSMENU,lParam);
     1390      if(dwStyle & WS_SYSMENU )
     1391      {
     1392        if( !(dwStyle & WS_MINIMIZE) )
     1393        {
     1394          HDC hDC = GetWindowDC(Win32Hwnd);
     1395          DrawSysButton(hDC,TRUE);
     1396          ReleaseDC(Win32Hwnd,hDC);
     1397        }
     1398        SendInternalMessageA(WM_SYSCOMMAND,SC_MOUSEMENU+HTSYSMENU,lParam);
     1399      }
    12441400      break;
    12451401
     
    12541410    case HTVSCROLL:
    12551411      SendInternalMessageA(WM_SYSCOMMAND,SC_VSCROLL+HTVSCROLL,lParam);
     1412      break;
     1413
     1414    case HTMINBUTTON:
     1415    case HTMAXBUTTON:
     1416      TrackMinMaxBox(wParam);   
     1417      break;
     1418
     1419    case HTCLOSE:
     1420      TrackCloseButton(wParam);
    12561421      break;
    12571422
     
    12941459  return 0;
    12951460}
     1461//******************************************************************************
     1462//******************************************************************************
     1463BOOL Win32BaseWindow::WindowNeedsWMBorder()
     1464{
     1465  if (!(dwStyle & WS_CHILD) &&
     1466      //Options.managed  && //CB: to check
     1467      !(dwExStyle & WS_EX_TOOLWINDOW) &&
     1468      ( ((dwStyle & WS_CAPTION) == WS_CAPTION) ||
     1469        (dwStyle & WS_THICKFRAME)))
     1470      return TRUE;
     1471  if (dwExStyle & WS_EX_TRAYWINDOW)
     1472    return TRUE;
     1473  return FALSE;
     1474}
     1475//******************************************************************************
     1476//******************************************************************************
     1477VOID Win32BaseWindow::AdjustRectOuter(LPRECT rect,BOOL menu)
     1478{
     1479  if(dwStyle & WS_ICONIC) return;
     1480
     1481  /* Decide if the window will be managed (see CreateWindowEx) */
     1482  if (!WindowNeedsWMBorder())
     1483  {
     1484    if (HAS_THICKFRAME(dwStyle,dwExStyle ))
     1485      InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
     1486    else
     1487      if (HAS_DLGFRAME( dwStyle, dwExStyle ))
     1488        InflateRect(rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
     1489      else
     1490        if (HAS_THINFRAME( dwStyle ))
     1491          InflateRect( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
     1492
     1493    if ((dwStyle & WS_CAPTION) == WS_CAPTION)
     1494    {
     1495      if (dwExStyle & WS_EX_TOOLWINDOW)
     1496        rect->top -= GetSystemMetrics(SM_CYSMCAPTION);
     1497      else
     1498        rect->top -= GetSystemMetrics(SM_CYCAPTION);
     1499    }
     1500  }
     1501
     1502  if (menu)
     1503    rect->top -= GetSystemMetrics(SM_CYMENU);
     1504}
     1505//******************************************************************************
     1506//******************************************************************************
     1507VOID Win32BaseWindow::AdjustRectInner(LPRECT rect)
     1508{
     1509  if(dwStyle & WS_ICONIC) return;
     1510
     1511  if (dwExStyle & WS_EX_CLIENTEDGE)
     1512    InflateRect (rect, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
     1513
     1514  if (dwExStyle & WS_EX_STATICEDGE)
     1515    InflateRect (rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
     1516
     1517  if (dwStyle & WS_VSCROLL) rect->right  += GetSystemMetrics(SM_CXVSCROLL);
     1518  if (dwStyle & WS_HSCROLL) rect->bottom += GetSystemMetrics(SM_CYHSCROLL);
     1519}
     1520//******************************************************************************
     1521//******************************************************************************
     1522LONG Win32BaseWindow::HandleNCCalcSize(RECT *winRect)
     1523{
     1524  RECT tmpRect = { 0, 0, 0, 0 };
     1525  LONG result = 0;
     1526  UINT style = (UINT) GetClassLongA(Win32Hwnd,GCL_STYLE);
     1527
     1528  if (style & CS_VREDRAW) result |= WVR_VREDRAW;
     1529  if (style & CS_HREDRAW) result |= WVR_HREDRAW;
     1530
     1531  if( !( dwStyle & WS_MINIMIZE ) )
     1532  {
     1533    AdjustRectOuter(&tmpRect,FALSE);
     1534
     1535    winRect->left   -= tmpRect.left;
     1536    winRect->top    -= tmpRect.top;
     1537    winRect->right  -= tmpRect.right;
     1538    winRect->bottom -= tmpRect.bottom;
     1539
     1540    if (HAS_MENU(this))
     1541    {
     1542#if 0 //CB: todo
     1543      winRect->top +=
     1544                MENU_GetMenuBarHeight(Win32Hwnd,
     1545                                       winRect->right - winRect->left,
     1546                                       -tmpRect.left, -tmpRect.top ) + 1;
     1547#endif
     1548    }
     1549
     1550    SetRect (&tmpRect, 0, 0, 0, 0);
     1551    AdjustRectInner(&tmpRect);
     1552    winRect->left   -= tmpRect.left;
     1553    winRect->top    -= tmpRect.top;
     1554    winRect->right  -= tmpRect.right;
     1555    winRect->bottom -= tmpRect.bottom;
     1556  }
     1557
     1558  return result;
     1559}
     1560//******************************************************************************
     1561//******************************************************************************
     1562LONG Win32BaseWindow::HandleNCHitTest(POINT pt)
     1563{
     1564  RECT rect = rectWindow;
     1565
     1566  if (!PtInRect(&rect,pt)) return HTNOWHERE;
     1567
     1568  if (dwStyle & WS_MINIMIZE) return HTCAPTION;
     1569
     1570  if (!(flags & WIN_MANAGED))
     1571  {
     1572    /* Check borders */
     1573    if (HAS_THICKFRAME(dwStyle,dwExStyle))
     1574    {
     1575      InflateRect( &rect, -GetSystemMetrics(SM_CXFRAME), -GetSystemMetrics(SM_CYFRAME) );
     1576      if (!PtInRect( &rect, pt ))
     1577      {
     1578        /* Check top sizing border */
     1579        if (pt.y < rect.top)
     1580        {
     1581          if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTTOPLEFT;
     1582          if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTTOPRIGHT;
     1583          return HTTOP;
     1584        }
     1585        /* Check bottom sizing border */
     1586        if (pt.y >= rect.bottom)
     1587        {
     1588          if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMLEFT;
     1589          if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMRIGHT;
     1590          return HTBOTTOM;
     1591        }
     1592        /* Check left sizing border */
     1593        if (pt.x < rect.left)
     1594        {
     1595          if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPLEFT;
     1596          if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMLEFT;
     1597          return HTLEFT;
     1598        }
     1599        /* Check right sizing border */
     1600        if (pt.x >= rect.right)
     1601        {
     1602          if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPRIGHT;
     1603          if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMRIGHT;
     1604          return HTRIGHT;
     1605        }
     1606      }
     1607    }
     1608    else  /* No thick frame */
     1609    {
     1610      if (HAS_DLGFRAME(dwStyle,dwExStyle))
     1611        InflateRect(&rect, -GetSystemMetrics(SM_CXDLGFRAME), -GetSystemMetrics(SM_CYDLGFRAME));
     1612      else if (HAS_THINFRAME(dwStyle ))
     1613        InflateRect(&rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
     1614      if (!PtInRect( &rect, pt )) return HTBORDER;
     1615    }
     1616
     1617    /* Check caption */
     1618
     1619    if ((dwStyle & WS_CAPTION) == WS_CAPTION)
     1620    {
     1621      if (dwExStyle & WS_EX_TOOLWINDOW)
     1622        rect.top += GetSystemMetrics(SM_CYSMCAPTION) - 1;
     1623      else
     1624        rect.top += GetSystemMetrics(SM_CYCAPTION) - 1;
     1625      if (!PtInRect( &rect, pt ))
     1626      {
     1627        /* Check system menu */
     1628        if(dwStyle & WS_SYSMENU)
     1629        {
     1630          /* Check if there is an user icon */
     1631          HICON hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICONSM);
     1632          if(!hIcon) hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICON);
     1633
     1634          /* If there is an icon associated with the window OR              */
     1635          /* If there is no hIcon specified and this is not a modal dialog, */
     1636          /* there is a system menu icon.                                   */
     1637          if((hIcon != 0) || (!(dwStyle & DS_MODALFRAME)))
     1638          rect.left += GetSystemMetrics(SM_CYCAPTION) - 1;
     1639        }
     1640        if (pt.x < rect.left) return HTSYSMENU;
     1641
     1642        /* Check close button */
     1643        if (dwStyle & WS_SYSMENU)
     1644        rect.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
     1645        if (pt.x > rect.right) return HTCLOSE;
     1646
     1647        /* Check maximize box */
     1648        /* In win95 there is automatically a Maximize button when there is a minimize one*/
     1649        if ((dwStyle & WS_MAXIMIZEBOX)|| (dwStyle & WS_MINIMIZEBOX))
     1650        rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
     1651        if (pt.x > rect.right) return HTMAXBUTTON;
     1652
     1653        /* Check minimize box */
     1654        /* In win95 there is automatically a Maximize button when there is a Maximize one*/
     1655        if ((dwStyle & WS_MINIMIZEBOX)||(dwStyle & WS_MAXIMIZEBOX))
     1656        rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
     1657
     1658        if (pt.x > rect.right) return HTMINBUTTON;
     1659        return HTCAPTION;
     1660      }
     1661    }
     1662  }
     1663
     1664  /* Check client area */
     1665
     1666  ScreenToClient(Win32Hwnd,&pt);
     1667  rect = rectClient;
     1668  if (PtInRect(&rect,pt)) return HTCLIENT;
     1669
     1670  /* Check vertical scroll bar */
     1671
     1672  if (dwStyle & WS_VSCROLL)
     1673  {
     1674    rect.right += GetSystemMetrics(SM_CXVSCROLL);
     1675    if (PtInRect( &rect, pt )) return HTVSCROLL;
     1676  }
     1677
     1678  /* Check horizontal scroll bar */
     1679
     1680  if (dwStyle & WS_HSCROLL)
     1681  {
     1682    rect.bottom += GetSystemMetrics(SM_CYHSCROLL);
     1683    if (PtInRect( &rect, pt ))
     1684    {
     1685      /* Check size box */
     1686      if ((dwStyle & WS_VSCROLL) &&
     1687          (pt.x >= rect.right - GetSystemMetrics(SM_CXVSCROLL)))
     1688        return HTSIZE;
     1689      return HTHSCROLL;
     1690    }
     1691  }
     1692
     1693  /* Check menu bar */
     1694
     1695  if (HAS_MENU(this))
     1696  {
     1697    if ((pt.y < 0) && (pt.x >= 0) && (pt.x < rect.right))
     1698      return HTMENU;
     1699  }
     1700
     1701  /* Should never get here */
     1702  return HTERROR;
     1703}
     1704
     1705//******************************************************************************
     1706//******************************************************************************
     1707VOID Win32BaseWindow::GetInsideRect(RECT *rect)
     1708{
     1709  rect->top    = rect->left = 0;
     1710  rect->right  = rectWindow.right - rectWindow.left;
     1711  rect->bottom = rectWindow.bottom - rectWindow.top;
     1712
     1713  if ((dwStyle & WS_ICONIC) || (flags & WIN_MANAGED)) return;
     1714
     1715  /* Remove frame from rectangle */
     1716  if (HAS_THICKFRAME(dwStyle,dwExStyle))
     1717  {
     1718    InflateRect( rect, -GetSystemMetrics(SM_CXSIZEFRAME), -GetSystemMetrics(SM_CYSIZEFRAME) );
     1719  }
     1720  else if (HAS_DLGFRAME(dwStyle,dwExStyle ))
     1721  {
     1722    InflateRect( rect, -GetSystemMetrics(SM_CXFIXEDFRAME), -GetSystemMetrics(SM_CYFIXEDFRAME));
     1723  }
     1724  else if (HAS_THINFRAME(dwStyle))
     1725  {
     1726    InflateRect( rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER) );
     1727  }
     1728
     1729  /* We have additional border information if the window
     1730   * is a child (but not an MDI child) */
     1731  if ( (dwStyle & WS_CHILD)  &&
     1732       ( (dwExStyle & WS_EX_MDICHILD) == 0 ) )
     1733  {
     1734    if (dwExStyle & WS_EX_CLIENTEDGE)
     1735      InflateRect (rect, -GetSystemMetrics(SM_CXEDGE), -GetSystemMetrics(SM_CYEDGE));
     1736
     1737    if (dwExStyle & WS_EX_STATICEDGE)
     1738      InflateRect (rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
     1739  }
     1740}
     1741//******************************************************************************
     1742//******************************************************************************
     1743VOID Win32BaseWindow::DrawFrame(HDC hdc,RECT *rect,BOOL dlgFrame,BOOL active)
     1744{
     1745  INT width, height;
     1746
     1747  if (dlgFrame)
     1748  {
     1749    width = GetSystemMetrics(SM_CXDLGFRAME) - GetSystemMetrics(SM_CXEDGE);
     1750    height = GetSystemMetrics(SM_CYDLGFRAME) - GetSystemMetrics(SM_CYEDGE);
     1751  } else
     1752  {
     1753    width = GetSystemMetrics(SM_CXFRAME) - GetSystemMetrics(SM_CXEDGE);
     1754    height = GetSystemMetrics(SM_CYFRAME) - GetSystemMetrics(SM_CYEDGE);
     1755  }
     1756
     1757  SelectObject( hdc, GetSysColorBrush(active ? COLOR_ACTIVEBORDER :
     1758                COLOR_INACTIVEBORDER) );
     1759
     1760  /* Draw frame */
     1761  PatBlt( hdc, rect->left, rect->top,
     1762            rect->right - rect->left, height, PATCOPY );
     1763  PatBlt( hdc, rect->left, rect->top,
     1764            width, rect->bottom - rect->top, PATCOPY );
     1765  PatBlt( hdc, rect->left, rect->bottom - 1,
     1766            rect->right - rect->left, -height, PATCOPY );
     1767  PatBlt( hdc, rect->right - 1, rect->top,
     1768            -width, rect->bottom - rect->top, PATCOPY );
     1769
     1770  InflateRect( rect, -width, -height );
     1771}
     1772//******************************************************************************
     1773//******************************************************************************
     1774BOOL Win32BaseWindow::DrawSysButton(HDC hdc,BOOL down)
     1775{
     1776  if(!(flags & WIN_MANAGED))
     1777  {
     1778    HICON  hIcon;
     1779    RECT rect;
     1780
     1781    GetInsideRect(&rect);
     1782
     1783    hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICONSM);
     1784    if(!hIcon) hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICON);
     1785
     1786    /* If there is no hIcon specified or this is not a modal dialog, */
     1787    /* get the default one.                                          */
     1788    if(hIcon == 0)
     1789      if (!(dwStyle & DS_MODALFRAME))
     1790        hIcon = LoadImageA(0, MAKEINTRESOURCEA(OIC_WINEICON), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
     1791
     1792    if (hIcon)
     1793      DrawIconEx (hdc, rect.left + 2, rect.top + 2, hIcon,
     1794                  GetSystemMetrics(SM_CXSMICON),
     1795                  GetSystemMetrics(SM_CYSMICON),
     1796                  0, 0, DI_NORMAL);
     1797
     1798    return (hIcon != 0);
     1799  }
     1800  return FALSE;
     1801}
     1802//******************************************************************************
     1803//******************************************************************************
     1804BOOL Win32BaseWindow::DrawGrayButton(HDC hdc,int x,int y)
     1805{
     1806  HBITMAP hMaskBmp;
     1807  HDC hdcMask = CreateCompatibleDC (0);
     1808  HBRUSH hOldBrush;
     1809  hMaskBmp = CreateBitmap (12, 10, 1, 1, lpGrayMask);
     1810
     1811  if(hMaskBmp == 0)
     1812    return FALSE;
     1813
     1814  SelectObject (hdcMask, hMaskBmp);
     1815
     1816  /* Draw the grayed bitmap using the mask */
     1817  hOldBrush = SelectObject (hdc, RGB(128, 128, 128));
     1818  BitBlt (hdc, x, y, 12, 10,
     1819          hdcMask, 0, 0, 0xB8074A);
     1820
     1821  /* Clean up */
     1822  SelectObject (hdc, hOldBrush);
     1823  DeleteObject(hMaskBmp);
     1824  DeleteDC (hdcMask);
     1825
     1826  return TRUE;
     1827}
     1828//******************************************************************************
     1829//******************************************************************************
     1830VOID Win32BaseWindow::DrawCloseButton(HDC hdc,BOOL down,BOOL bGrayed)
     1831{
     1832  RECT rect;
     1833  HDC hdcMem;
     1834
     1835  if( !(flags & WIN_MANAGED) )
     1836  {
     1837    BITMAP bmp;
     1838    HBITMAP hBmp, hOldBmp;
     1839
     1840    GetInsideRect(&rect);
     1841
     1842    hdcMem = CreateCompatibleDC( hdc );
     1843    hBmp = down ? hbitmapCloseD : hbitmapClose;
     1844    hOldBmp = SelectObject (hdcMem, hBmp);
     1845    GetObjectA (hBmp, sizeof(BITMAP), &bmp);
     1846
     1847    BitBlt (hdc, rect.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2,
     1848            rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
     1849            bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY);
     1850
     1851    if(bGrayed)
     1852      DrawGrayButton(hdc,rect.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2 + 2,
     1853                     rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
     1854
     1855    SelectObject (hdcMem, hOldBmp);
     1856    DeleteDC (hdcMem);
     1857  }
     1858}
     1859//******************************************************************************
     1860//******************************************************************************
     1861VOID Win32BaseWindow::DrawMaxButton(HDC hdc,BOOL down,BOOL bGrayed)
     1862{
     1863  RECT rect;
     1864  HDC hdcMem;
     1865
     1866  if( !(flags & WIN_MANAGED))
     1867  {
     1868    BITMAP  bmp;
     1869    HBITMAP  hBmp,hOldBmp;
     1870
     1871    GetInsideRect(&rect);
     1872    hdcMem = CreateCompatibleDC( hdc );
     1873    hBmp = IsZoomed(Win32Hwnd) ?
     1874            (down ? hbitmapRestoreD : hbitmapRestore ) :
     1875            (down ? hbitmapMaximizeD: hbitmapMaximize);
     1876    hOldBmp=SelectObject( hdcMem, hBmp );
     1877    GetObjectA (hBmp, sizeof(BITMAP), &bmp);
     1878
     1879    if (dwStyle & WS_SYSMENU)
     1880      rect.right -= GetSystemMetrics(SM_CYCAPTION) + 1;
     1881
     1882    BitBlt( hdc, rect.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2,
     1883          rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
     1884          bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY );
     1885
     1886    if(bGrayed)
     1887      DrawGrayButton(hdc, rect.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2 + 2,
     1888                      rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
     1889
     1890
     1891    SelectObject (hdcMem, hOldBmp);
     1892    DeleteDC( hdcMem );
     1893  }
     1894}
     1895//******************************************************************************
     1896//******************************************************************************
     1897VOID Win32BaseWindow::DrawMinButton(HDC hdc,BOOL down,BOOL bGrayed)
     1898{
     1899  RECT rect;
     1900  HDC hdcMem;
     1901
     1902  if( !(flags & WIN_MANAGED))
     1903
     1904  {
     1905    BITMAP  bmp;
     1906    HBITMAP  hBmp,hOldBmp;
     1907
     1908    GetInsideRect(&rect);
     1909
     1910    hdcMem = CreateCompatibleDC( hdc );
     1911    hBmp = down ? hbitmapMinimizeD : hbitmapMinimize;
     1912    hOldBmp= SelectObject( hdcMem, hBmp );
     1913    GetObjectA (hBmp, sizeof(BITMAP), &bmp);
     1914
     1915    if (dwStyle & WS_SYSMENU)
     1916      rect.right -= GetSystemMetrics(SM_CYCAPTION) + 1;
     1917
     1918    /* In win 95 there is always a Maximize box when there is a Minimize one */
     1919    if ((dwStyle & WS_MAXIMIZEBOX) || (dwStyle & WS_MINIMIZEBOX))
     1920      rect.right += -1 - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2;
     1921
     1922    BitBlt( hdc, rect.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2,
     1923          rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
     1924          bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY );
     1925
     1926    if(bGrayed)
     1927      DrawGrayButton(hdc, rect.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2 + 2,
     1928                      rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
     1929
     1930
     1931    SelectObject (hdcMem, hOldBmp);
     1932    DeleteDC( hdcMem );
     1933  }
     1934}
     1935//******************************************************************************
     1936//******************************************************************************
     1937VOID Win32BaseWindow::DrawCaption(HDC hdc,RECT *rect,BOOL active)
     1938{
     1939  RECT  r = *rect;
     1940  char    buffer[256];
     1941  HPEN  hPrevPen;
     1942  HMENU hSysMenu;
     1943
     1944  if (flags & WIN_MANAGED) return;
     1945
     1946  hPrevPen = SelectObject( hdc, GetSysColorPen(COLOR_3DFACE) );
     1947  MoveToEx( hdc, r.left, r.bottom - 1, NULL );
     1948  LineTo( hdc, r.right, r.bottom - 1 );
     1949  SelectObject( hdc, hPrevPen );
     1950  r.bottom--;
     1951
     1952  FillRect( hdc, &r, GetSysColorBrush(active ? COLOR_ACTIVECAPTION : COLOR_INACTIVECAPTION) );
     1953
     1954  if (!hbitmapClose)
     1955  {
     1956    if (!(hbitmapClose = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_CLOSE)))) return;
     1957    hbitmapCloseD    = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_CLOSED));
     1958    hbitmapMinimize  = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_REDUCE));
     1959    hbitmapMinimizeD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_REDUCED));
     1960    hbitmapMaximize  = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_ZOOM));
     1961    hbitmapMaximizeD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_ZOOMD));
     1962    hbitmapRestore   = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_RESTORE));
     1963    hbitmapRestoreD  = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_RESTORED));
     1964  }
     1965
     1966  if ((dwStyle & WS_SYSMENU) && !(dwExStyle & WS_EX_TOOLWINDOW))
     1967  {
     1968    if (DrawSysButton(hdc,FALSE))
     1969      r.left += GetSystemMetrics(SM_CYCAPTION) - 1;
     1970  }
     1971
     1972  if (dwStyle & WS_SYSMENU)
     1973  {
     1974    UINT state;
     1975#if 0 //CB: todo
     1976    /* Go get the sysmenu */
     1977    state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
     1978#endif
     1979    /* Draw a grayed close button if disabled and a normal one if SC_CLOSE is not there */
     1980    DrawCloseButton(hdc, FALSE,
     1981                    ((((state & MF_DISABLED) || (state & MF_GRAYED))) && (state != 0xFFFFFFFF)));
     1982    r.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
     1983
     1984    if ((dwStyle & WS_MAXIMIZEBOX) || (dwStyle & WS_MINIMIZEBOX))
     1985    {
     1986      /* In win95 the two buttons are always there */
     1987      /* But if the menu item is not in the menu they're disabled*/
     1988
     1989      DrawMaxButton(hdc, FALSE, (!(dwStyle & WS_MAXIMIZEBOX)));
     1990      r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
     1991
     1992      DrawMinButton(hdc, FALSE,  (!(dwStyle & WS_MINIMIZEBOX)));
     1993            r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
     1994    }
     1995  }
     1996
     1997  if (GetWindowTextA(buffer, sizeof(buffer) ))
     1998  {
     1999    NONCLIENTMETRICSA nclm;
     2000    HFONT hFont, hOldFont;
     2001    nclm.cbSize = sizeof(NONCLIENTMETRICSA);
     2002    SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
     2003    if (dwExStyle & WS_EX_TOOLWINDOW)
     2004      hFont = CreateFontIndirectA (&nclm.lfSmCaptionFont);
     2005    else
     2006      hFont = CreateFontIndirectA (&nclm.lfCaptionFont);
     2007    hOldFont = SelectObject (hdc, hFont);
     2008    if (active) SetTextColor( hdc, GetSysColor( COLOR_CAPTIONTEXT ) );
     2009    else SetTextColor( hdc, GetSysColor( COLOR_INACTIVECAPTIONTEXT ) );
     2010    SetBkMode( hdc, TRANSPARENT );
     2011    r.left += 2;
     2012    DrawTextA( hdc, buffer, -1, &r,
     2013             DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT );
     2014    DeleteObject (SelectObject (hdc, hOldFont));
     2015  }
     2016}
     2017//******************************************************************************
     2018//******************************************************************************
     2019VOID Win32BaseWindow::DoNCPaint(HRGN clip,BOOL suppress_menupaint)
     2020{
     2021  BOOL active  = flags & WIN_NCACTIVATED;
     2022  HDC hdc;
     2023  RECT rect,rectClip,rfuzz;
     2024
     2025  /* MSDN docs are pretty idiotic here, they say app CAN use clipRgn in
     2026     the call to GetDCEx implying that it is allowed not to use it either.
     2027     However, the suggested GetDCEx(    , DCX_WINDOW | DCX_INTERSECTRGN)
     2028     will cause clipRgn to be deleted after ReleaseDC().
     2029     Now, how is the "system" supposed to tell what happened?
     2030   */
     2031
     2032  if (!(hdc = GetDCEx( Win32Hwnd, (clip > 1) ? clip : 0, DCX_USESTYLE | DCX_WINDOW |
     2033                      ((clip > 1) ?(DCX_INTERSECTRGN /*| DCX_KEEPCLIPRGN*/) : 0) ))) return;
     2034
     2035
     2036  rect.top = rect.left = 0;
     2037  rect.right  = rectWindow.right - rectWindow.left;
     2038  rect.bottom = rectWindow.bottom - rectWindow.top;
     2039
     2040  if( clip > 1 )
     2041    GetRgnBox( clip, &rectClip );
     2042  else
     2043  {
     2044    clip = 0;
     2045    rectClip = rect;
     2046  }
     2047
     2048  SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
     2049
     2050  if(!(flags & WIN_MANAGED))
     2051  {
     2052    if (HAS_BIGFRAME( dwStyle, dwExStyle))
     2053    {
     2054      DrawEdge (hdc, &rect, EDGE_RAISED, BF_RECT | BF_ADJUST);
     2055    }
     2056    if (HAS_THICKFRAME( dwStyle, dwExStyle ))
     2057      DrawFrame(hdc, &rect, FALSE, active );
     2058    else if (HAS_DLGFRAME( dwStyle, dwExStyle ))
     2059      DrawFrame( hdc, &rect, TRUE, active );
     2060    else if (HAS_THINFRAME( dwStyle ))
     2061    {
     2062      SelectObject( hdc, GetStockObject(NULL_BRUSH) );
     2063      Rectangle( hdc, 0, 0, rect.right, rect.bottom );
     2064    }
     2065
     2066    if ((dwStyle & WS_CAPTION) == WS_CAPTION)
     2067    {
     2068      RECT  r = rect;
     2069      if (dwExStyle & WS_EX_TOOLWINDOW)
     2070      {
     2071        r.bottom = rect.top + GetSystemMetrics(SM_CYSMCAPTION);
     2072        rect.top += GetSystemMetrics(SM_CYSMCAPTION);
     2073      }
     2074      else
     2075      {
     2076        r.bottom = rect.top + GetSystemMetrics(SM_CYCAPTION);
     2077        rect.top += GetSystemMetrics(SM_CYCAPTION);
     2078      }
     2079      if( !clip || IntersectRect( &rfuzz, &r, &rectClip ) )
     2080        DrawCaption(hdc, &r, active);
     2081    }
     2082  }
     2083#if 0 //CB: todo
     2084  if (HAS_MENU(wndPtr))
     2085  {
     2086    RECT r = rect;
     2087    r.bottom = rect.top + GetSystemMetrics(SM_CYMENU);
     2088
     2089    rect.top += MENU_DrawMenuBar( hdc, &r, hwnd, suppress_menupaint ) + 1;
     2090  }
     2091#endif
     2092
     2093  if (dwExStyle & WS_EX_CLIENTEDGE)
     2094    DrawEdge (hdc, &rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
     2095
     2096  if (dwExStyle & WS_EX_STATICEDGE)
     2097    DrawEdge (hdc, &rect, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
     2098
     2099  /* Draw the scroll-bars */
     2100#if 0 //CB: todo
     2101  if (dwStyle & WS_VSCROLL)
     2102    SCROLL_DrawScrollBar( hwnd, hdc, SB_VERT, TRUE, TRUE );
     2103  if (wndPtr->dwStyle & WS_HSCROLL)
     2104    SCROLL_DrawScrollBar( hwnd, hdc, SB_HORZ, TRUE, TRUE );
     2105#endif
     2106  /* Draw the "size-box" */
     2107  if ((dwStyle & WS_VSCROLL) && (dwStyle & WS_HSCROLL))
     2108  {
     2109    RECT r = rect;
     2110    r.left = r.right - GetSystemMetrics(SM_CXVSCROLL) + 1;
     2111    r.top  = r.bottom - GetSystemMetrics(SM_CYHSCROLL) + 1;
     2112    FillRect( hdc, &r,  GetSysColorBrush(COLOR_SCROLLBAR) );
     2113  }
     2114
     2115  ReleaseDC(Win32Hwnd,hdc);
     2116}
     2117//******************************************************************************
     2118//******************************************************************************
     2119LONG Win32BaseWindow::HandleNCPaint(HRGN clip)
     2120{
     2121  if (!(dwStyle & WS_VISIBLE)) return 0;
     2122
     2123  if (dwStyle & WS_MINIMIZE) return 0;  //CB: to check
     2124
     2125  DoNCPaint(clip,FALSE);
     2126
     2127  return 0;
     2128}
    12962129/***********************************************************************
    12972130 *           NC_HandleNCLButtonDblClk
     
    16052438
    16062439    case WM_NCPAINT:
    1607         return 0;
     2440         return HandleNCPaint((HRGN)wParam);
    16082441
    16092442    case WM_NCACTIVATE:
     2443        return HandleNCActivate(wParam);
    16102444        return TRUE;
    16112445
     
    16172451
    16182452    case WM_NCCALCSIZE:
    1619         return NCHandleCalcSize(wParam, (NCCALCSIZE_PARAMS *)lParam);
     2453        return HandleNCCalcSize((RECT*)lParam);
    16202454
    16212455    case WM_CTLCOLORMSGBOX:
     
    16692503          HCURSOR hCursor;
    16702504
    1671           switch(lastHitTestVal)
     2505          switch(LOWORD(lParam))
    16722506          {
    16732507            case HTLEFT:
     
    18062640      point.y = (SHORT)HIWORD(lParam);
    18072641
    1808       return FrameHitTest(this,point.x,point.y);
     2642      return HandleNCHitTest(point);
    18092643    }
    18102644
  • trunk/src/user32/new/win32wbase.h

    r2290 r2292  
    1 /* $Id: win32wbase.h,v 1.13 2000-01-01 14:54:55 cbratschi Exp $ */
     1/* $Id: win32wbase.h,v 1.14 2000-01-02 19:30:45 cbratschi Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    131131         ULONG  getClientWidth()                { return rectClient.right - rectClient.left; };
    132132         BOOL   isChild();
    133          PRECT  getClientRect()                 { return &rectClient; };
     133         PRECT  getClientRectPtr()              { return &rectClient; };
     134         void   getClientRect(PRECT rect)
     135         {
     136                *rect = rectClient;
     137                rectClient.right  -= rectClient.left;
     138                rectClient.bottom -= rectClient.top;
     139                rectClient.left = rectClient.top = 0;
     140         }
    134141         void   setClientRect(PRECT rect)       { rectClient = *rect; };
    135142         PRECT  getWindowRect()                 { return &rectWindow; };
     
    179186         HWND   getOS2HwndModalDialog()       { return OS2HwndModalDialog; };
    180187         BOOL   CanReceiveSizeMsgs()          { return !fNoSizeMsg; };
     188         BOOL   IsWindowCreated()             { return fCreated; }
    181189         BOOL   IsWindowDestroyed()           { return fIsDestroyed; };
    182190         BOOL   IsWindowEnabled();
     
    252260       ULONG getBorderHeight() { return borderHeight; };
    253261
    254 static  void  NC_AdjustRectInner(LPRECT rect, DWORD style, DWORD exStyle);
    255 static  void  NC_AdjustRectOuter(LPRECT rect, DWORD style, BOOL menu, DWORD exStyle);
    256 static  BOOL  WindowNeedsWMBorder( DWORD style, DWORD exStyle );
    257 
    258262       PVOID getOldWndProc() { return pOldWndProc; }
    259263       VOID  setOldWndProc(PVOID aOldWndProc) { pOldWndProc = aOldWndProc; }
     
    327331        ULONG   nrUserWindowLong;
    328332
    329         RECT    rectWindow;
    330         RECT    rectClient;
     333        RECT    rectWindow; //relative to screen
     334        RECT    rectClient;  //relative to parent
    331335
    332336CREATESTRUCTA  *tmpcs; //temporary pointer to CREATESTRUCT used in CreateWindowEx
     
    346350        void  GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
    347351        LONG  HandleWindowPosChanging(WINDOWPOS *winpos);
     352        LONG  HandleNCActivate(WPARAM wParam);
     353        VOID  TrackMinMaxBox(WORD wParam);
     354        VOID  TrackCloseButton(WORD wParam);
    348355        LONG  HandleNCLButtonDown(WPARAM wParam,LPARAM lParam);
    349356        LONG  HandleNCLButtonUp(WPARAM wParam,LPARAM lParam);
    350357        LONG  HandleNCLButtonDblClk(WPARAM wParam,LPARAM lParam);
     358        BOOL  WindowNeedsWMBorder();
     359        VOID  AdjustRectOuter(LPRECT rect,BOOL menu);
     360        VOID  AdjustRectInner(LPRECT rect);
     361        LONG  HandleNCCalcSize(RECT *winRect);
     362        LONG  HandleNCHitTest(POINT pt);
     363        VOID  GetInsideRect(RECT *rect);
     364        VOID  DrawFrame(HDC hdc,RECT *rect,BOOL dlgFrame,BOOL active);
     365        BOOL  DrawSysButton(HDC hdc,BOOL down);
     366        BOOL  DrawGrayButton(HDC hdc,int x,int y);
     367        VOID  DrawCloseButton(HDC hdc,BOOL down,BOOL bGrayed);
     368        VOID  DrawMaxButton(HDC hdc,BOOL down,BOOL bGrayed);
     369        VOID  DrawMinButton(HDC hdc,BOOL down,BOOL bGrayed);
     370        VOID  DrawCaption(HDC hdc,RECT *rect,BOOL active);
     371        VOID  DoNCPaint(HRGN clip,BOOL suppress_menupaint);
     372        LONG  HandleNCPaint(HRGN clip);
    351373        LONG  HandleSysCommand(WPARAM wParam, POINT *pt32);
    352374
     
    355377                             RECT *oldClientRect, WINDOWPOS *winpos,
    356378                             RECT *newClientRect );
    357 
    358         LONG  NCHandleCalcSize(WPARAM wParam, NCCALCSIZE_PARAMS *ncsize);
    359379
    360380     LRESULT  SendInternalMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
  • trunk/src/user32/new/win32wbasepos.cpp

    r2290 r2292  
    1 /* $Id: win32wbasepos.cpp,v 1.1 2000-01-01 14:57:31 cbratschi Exp $ */
     1/* $Id: win32wbasepos.cpp,v 1.2 2000-01-02 19:30:45 cbratschi Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2 (nonclient/position methods)
     
    7272#define HAS_MENU()  (!(getStyle() & WS_CHILD) && (GetMenu() != 0))
    7373
    74 #if 0
    75 /***********************************************************************
    76  *           WINPOS_MinMaximize
    77  *
    78  * Fill in lpRect and return additional flags to be used with SetWindowPos().
    79  * This function assumes that 'cmd' is different from the current window
    80  * state.
    81  */
    82 UINT Win32BaseWindow::MinMaximize(UINT cmd, LPRECT lpRect )
    83 {
    84     UINT swpFlags = 0;
    85     POINT pt, size;
    86     LPINTERNALPOS lpPos;
    87 
    88     size.x = rectWindow.left; size.y = rectWindow.top;
    89     lpPos = WINPOS_InitInternalPos( wndPtr, size, &rectWindow );
    90 
    91     if (lpPos && !HOOK_CallHooks16(WH_CBT, HCBT_MINMAX, hwndSelf, cmd))
    92     {
    93     if( dwStyle & WS_MINIMIZE )
    94     {
    95         if( !SendInternalMessageA(WM_QUERYOPEN, 0, 0L ) )
    96         return (SWP_NOSIZE | SWP_NOMOVE);
    97         swpFlags |= SWP_NOCOPYBITS;
    98     }
    99     switch( cmd )
    100     {
    101         case SW_MINIMIZE:
    102          if( dwStyle & WS_MAXIMIZE)
    103          {
    104              flags |= WIN_RESTORE_MAX;
    105              dwStyle &= ~WS_MAXIMIZE;
    106                  }
    107                  else
    108              flags &= ~WIN_RESTORE_MAX;
    109              dwStyle |= WS_MINIMIZE;
    110 
    111 #if 0
    112          if( flags & WIN_NATIVE )
    113              if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, TRUE ) )
    114              swpFlags |= MINMAX_NOSWP;
    115 #endif
    116 
    117          lpPos->ptIconPos = WINPOS_FindIconPos( wndPtr, lpPos->ptIconPos );
    118 
    119          SetRect(lpRect, lpPos->ptIconPos.x, lpPos->ptIconPos.y,
    120              GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON) );
    121          swpFlags |= SWP_NOCOPYBITS;
    122          break;
    123 
    124         case SW_MAXIMIZE:
    125                 WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL );
    126 
    127          if( dwStyle & WS_MINIMIZE )
    128          {
    129              if( flags & WIN_NATIVE )
    130              if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, FALSE ) )
    131                  swpFlags |= MINMAX_NOSWP;
    132 
    133              WINPOS_ShowIconTitle( wndPtr, FALSE );
    134              dwStyle &= ~WS_MINIMIZE;
    135          }
    136                  dwStyle |= WS_MAXIMIZE;
    137 
    138          SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y,
    139                     size.x, size.y );
    140          break;
    141 
    142         case SW_RESTORE:
    143          if( dwStyle & WS_MINIMIZE )
    144          {
    145              if( flags & WIN_NATIVE )
    146              if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, FALSE ) )
    147                  swpFlags |= MINMAX_NOSWP;
    148 
    149              dwStyle &= ~WS_MINIMIZE;
    150              WINPOS_ShowIconTitle( wndPtr, FALSE );
    151 
    152              if( flags & WIN_RESTORE_MAX)
    153              {
    154              /* Restore to maximized position */
    155                          CONV_POINT16TO32( &lpPos->ptMaxPos, &pt );
    156                          WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL);
    157                          CONV_POINT32TO16( &pt, &lpPos->ptMaxPos );
    158              dwStyle |= WS_MAXIMIZE;
    159              SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y, size.x, size.y );
    160              break;
    161              }
    162          }
    163          else
    164              if( !(dwStyle & WS_MAXIMIZE) ) return (UINT16)(-1);
    165              else dwStyle &= ~WS_MAXIMIZE;
    166 
    167          /* Restore to normal position */
    168 
    169         *lpRect = lpPos->rectNormal;
    170          lpRect->right -= lpRect->left;
    171          lpRect->bottom -= lpRect->top;
    172 
    173          break;
    174     }
    175     } else swpFlags |= SWP_NOSIZE | SWP_NOMOVE;
    176     return swpFlags;
    177 }
    178 #endif
    17974/*******************************************************************
    18075 *           GetMinMaxInfo
     
    280175   return result;
    281176}
    282 //******************************************************************************
    283 //******************************************************************************
    284 LONG Win32BaseWindow::NCHandleCalcSize(WPARAM wParam, NCCALCSIZE_PARAMS *ncsize)
    285 {
    286   LONG    result = 0;
    287 
    288         if (getStyle() & CS_VREDRAW) result |= WVR_VREDRAW;
    289         if (getStyle() & CS_HREDRAW) result |= WVR_HREDRAW;
    290 
    291 //TODO: Wine calculates new size of client area even when window is iconic (client edges)
    292         if(!(getStyle() & (WS_MINIMIZE | WS_ICONIC)))
    293         {
    294             dprintf(("NCHandleCalcSize %x (%d,%d) (%d,%d)", getWindowHandle(), ncsize->rgrc[0].left, ncsize->rgrc[0].top, ncsize->rgrc[0].right, ncsize->rgrc[0].bottom));
    295             OSLibWinCalcFrameRect(getOS2FrameWindowHandle(), &ncsize->rgrc[0], TRUE); //frame -> client
    296             dprintf(("NCHandleCalcSize Adjusted client rect (%d,%d) (%d,%d)", ncsize->rgrc[0].left, ncsize->rgrc[0].top, ncsize->rgrc[0].right, ncsize->rgrc[0].bottom));
    297 
    298             OffsetRect(&ncsize->rgrc[0], -ncsize->rgrc[0].left, -ncsize->rgrc[0].top);
    299         }
    300 #if 0
    301 //TODO: Docs say app should return 0 when fCalcValidRects == 0; Wine doesn't do this
    302         if(wParam == 0) //fCalcValidRects
    303             return 0;
    304 #endif
    305         return result;
    306 }
    307 /***********************************************************************
    308  *           WIN_WindowNeedsWMBorder
    309  *
    310  * This method defines the rules for a window to have a WM border,
    311  * caption...  It is used for consitency purposes.
    312  */
    313 BOOL Win32BaseWindow::WindowNeedsWMBorder( DWORD style, DWORD exStyle )
    314 {
    315 //    if (!(style & WS_CHILD) && Options.managed  &&
    316     if (!(style & WS_CHILD)  &&
    317         (((style & WS_CAPTION) == WS_CAPTION) ||
    318          (style & WS_THICKFRAME)))
    319         return TRUE;
    320     return FALSE;
    321 }
    322 /******************************************************************************
    323  * NC_AdjustRectOuter95
    324  *
    325  * Computes the size of the "outside" parts of the window based on the
    326  * parameters of the client area.
    327  *
    328  + PARAMS
    329  *     LPRECT16  rect
    330  *     DWORD  style
    331  *     BOOL32  menu
    332  *     DWORD  exStyle
    333  *
    334  * NOTES
    335  *     "Outer" parts of a window means the whole window frame, caption and
    336  *     menu bar. It does not include "inner" parts of the frame like client
    337  *     edge, static edge or scroll bars.
    338  *
    339  * Revision history
    340  *     05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
    341  *        Original (NC_AdjustRect95) cut & paste from NC_AdjustRect
    342  *
    343  *     20-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
    344  *        Split NC_AdjustRect95 into NC_AdjustRectOuter95 and
    345  *        NC_AdjustRectInner95 and added handling of Win95 styles.
    346  *
    347  *     28-Jul-1999 Ove Kåven (ovek@arcticnet.no)
    348  *        Streamlined window style checks.
    349  *
    350  *****************************************************************************/
    351 void Win32BaseWindow::NC_AdjustRectOuter(LPRECT rect, DWORD style, BOOL menu, DWORD exStyle)
    352 {
    353     if(style & WS_ICONIC) return;
    354 
    355     /* Decide if the window will be managed (see CreateWindowEx) */
    356 //    if (!WindowNeedsWMBorder(style, exStyle))
    357 //    {
    358        if (HAS_THICKFRAME( style, exStyle ))
    359             InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
    360         else
    361         if (HAS_DLGFRAME( style, exStyle ))
    362             InflateRect(rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
    363         else
    364         if (HAS_THINFRAME( style ))
    365             InflateRect( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
    366 
    367         if ((style & WS_CAPTION) == WS_CAPTION)
    368         {
    369             if (exStyle & WS_EX_TOOLWINDOW)
    370                 rect->top -= GetSystemMetrics(SM_CYSMCAPTION);
    371             else
    372                 rect->top -= GetSystemMetrics(SM_CYCAPTION);
    373         }
    374 //    }
    375 
    376     if (menu)
    377         rect->top -= GetSystemMetrics(SM_CYMENU);
    378 }
    379 /******************************************************************************
    380  * NC_AdjustRectInner95
    381  *
    382  * Computes the size of the "inside" part of the window based on the
    383  * parameters of the client area.
    384  *
    385  + PARAMS
    386  *     LPRECT16 rect
    387  *     DWORD    style
    388  *     DWORD    exStyle
    389  *
    390  * NOTES
    391  *     "Inner" part of a window means the window frame inside of the flat
    392  *     window frame. It includes the client edge, the static edge and the
    393  *     scroll bars.
    394  *
    395  * Revision history
    396  *     05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
    397  *        Original (NC_AdjustRect95) cut & paste from NC_AdjustRect
    398  *
    399  *     20-Jun-1998 Eric Kohl (ekohl@abo.rhein-zeitung.de)
    400  *        Split NC_AdjustRect95 into NC_AdjustRectOuter95 and
    401  *        NC_AdjustRectInner95 and added handling of Win95 styles.
    402  *
    403  *****************************************************************************/
    404 void Win32BaseWindow::NC_AdjustRectInner(LPRECT rect, DWORD style, DWORD exStyle)
    405 {
    406     if(style & WS_ICONIC) return;
    407 
    408     if (exStyle & WS_EX_CLIENTEDGE)
    409         InflateRect(rect, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
    410 
    411     if (exStyle & WS_EX_STATICEDGE)
    412         InflateRect(rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
    413 
    414     if (style & WS_VSCROLL) rect->right  += GetSystemMetrics(SM_CXVSCROLL);
    415     if (style & WS_HSCROLL) rect->bottom += GetSystemMetrics(SM_CYHSCROLL);
    416 }
    417177/***********************************************************************
    418178 *           WINPOS_HandleWindowPosChanging16
  • trunk/src/user32/new/win32wmdichild.cpp

    r2290 r2292  
    1 /* $Id: win32wmdichild.cpp,v 1.6 2000-01-01 14:57:31 cbratschi Exp $ */
     1/* $Id: win32wmdichild.cpp,v 1.7 2000-01-02 19:30:45 cbratschi Exp $ */
    22/*
    33 * Win32 MDI Child Window Class for OS/2
     
    506506{
    507507    INT  nstagger;
    508     RECT rect = *client->getClientRect();
     508    RECT rect;
    509509    INT  spacing = GetSystemMetrics(SM_CYCAPTION) +
    510510                   GetSystemMetrics(SM_CYFRAME) - 1;
    511511
     512    client->getClientRect(&rect);
    512513    if( rect.bottom - rect.top - delta >= spacing )
    513514        rect.bottom -= delta;
     
    528529{
    529530    Win32MDIClientWindow *client = (Win32MDIClientWindow *)getParent();
    530     RECT rect = *client->getClientRect();
    531 
     531    RECT rect;
     532
     533    getClientRect(&rect);
    532534    if(client->getParent() == NULL) {
    533535        dprintf(("Win32MDIChildWindow::childGetMinMaxInfo:: client parent == NULL!!"));
  • trunk/src/user32/new/win32wmdiclient.cpp

    r2290 r2292  
    1 /* $Id: win32wmdiclient.cpp,v 1.8 2000-01-01 14:57:31 cbratschi Exp $ */
     1/* $Id: win32wmdiclient.cpp,v 1.9 2000-01-02 19:30:46 cbratschi Exp $ */
    22/*
    33 * Win32 MDI Client Window Class for OS/2
     
    101101        AppendMenuA( hWindowMenu, MF_SEPARATOR, 0, NULL );
    102102
    103         setClientRect(frameWnd->getClientRect());
     103        setClientRect(frameWnd->getClientRectPtr());
    104104
    105105        dprintf(("MDIClient created - hwnd = %04x, idFirst = %u\n", getWindowHandle(), idFirstChild ));
     
    694694{
    695695    INT  nstagger;
    696     RECT rect = *this->getClientRect();
     696    RECT rect;
    697697    INT  spacing = GetSystemMetrics(SM_CYCAPTION) +
    698698                     GetSystemMetrics(SM_CYFRAME) - 1;
    699699
     700    getClientRect(&rect);
    700701    if( rect.bottom - rect.top - delta >= spacing )
    701702        rect.bottom -= delta;
  • trunk/src/user32/new/window.cpp

    r2290 r2292  
    1 /* $Id: window.cpp,v 1.27 2000-01-01 14:57:34 cbratschi Exp $ */
     1/* $Id: window.cpp,v 1.28 2000-01-02 19:30:46 cbratschi Exp $ */
    22/*
    33 * Win32 window apis for OS/2
     
    768768 Win32BaseWindow *window;
    769769
     770    if (!pRect)
     771    {
     772      SetLastError(ERROR_INVALID_PARAMETER);
     773      return FALSE;
     774    }
    770775    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
    771776    if(!window) {
    772777        dprintf(("GetClientRect, window %x not found", hwnd));
    773778        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
    774         return 0;
    775     }
    776     *pRect = *window->getClientRect();
    777     OffsetRect(pRect, -pRect->left, -pRect->top);
     779        return FALSE;
     780    }
     781    window->getClientRect(pRect);
    778782    dprintf(("GetClientRect of %X returned (%d,%d) (%d,%d)\n", hwndWin32, pRect->left, pRect->top, pRect->right, pRect->bottom));
    779783    return TRUE;
     
    799803        WS_EX_STATICEDGE | WS_EX_TOOLWINDOW);
    800804    if (exStyle & WS_EX_DLGMODALFRAME) style &= ~WS_THICKFRAME;
    801 
     805#if 0  //CB: todo
    802806    Win32BaseWindow::NC_AdjustRectOuter( rect, style, menu, exStyle );
    803807    Win32BaseWindow::NC_AdjustRectInner( rect, style, exStyle );
    804 
     808#endif
    805809    dprintf(("AdjustWindowRectEx returned (%d,%d)(%d,%d)\n", rect->left, rect->top, rect->right, rect->bottom));
    806810    return TRUE;
  • trunk/src/user32/new/winproc.cpp

    r2290 r2292  
    1 /* $Id: winproc.cpp,v 1.1 2000-01-01 14:57:38 cbratschi Exp $ */
     1/* $Id: winproc.cpp,v 1.2 2000-01-02 19:30:47 cbratschi Exp $ */
    22/*
    33 * Window procedure callbacks
     
    4949
    5050/**********************************************************************
    51  *           WINPROC_GetPtr
     51 *           WINPROC_GetPtr
    5252 *
    5353 * Return a pointer to the win proc.
     
    5959
    6060    if(ptr == NULL) {
    61         return NULL;
     61        return NULL;
    6262    }
    6363
     
    7676
    7777/**********************************************************************
    78  *           WINPROC_AllocWinProc
     78 *           WINPROC_AllocWinProc
    7979 *
    8080 * Allocate a new window procedure.
     
    9191    /* Check if the function is already a win proc */
    9292
    93     if ((oldproc = WINPROC_GetPtr( func )))
     93    oldproc = WINPROC_GetPtr( func );
     94    if (oldproc)
    9495    {
    9596        *proc = *oldproc;
     
    119120
    120121/**********************************************************************
    121  *           WINPROC_GetProc
     122 *           WINPROC_GetProc
    122123 *
    123124 * Get a window procedure pointer that can be passed to the Windows program.
     
    135136
    136137/**********************************************************************
    137  *           WINPROC_SetProc
     138 *           WINPROC_SetProc
    138139 *
    139140 * Set the window procedure for a window or class. There are
    140141 * three tree classes of winproc callbacks:
    141142 *
    142  * 1) class  -> wp                      -       not subclassed
    143  *    class  -> wp -> wp -> wp -> wp    -       SetClassLong()
     143 * 1) class  -> wp                      -       not subclassed
     144 *    class  -> wp -> wp -> wp -> wp    -       SetClassLong()
    144145 *             /           /
    145  * 2) window -'           /             -       not subclassed
    146  *    window -> wp -> wp '              -       SetWindowLong()
    147  *
    148  * 3) timer  -> wp                      -       SetTimer()
    149  *
    150  * Initially, winproc of the window points to the current winproc 
    151  * thunk of its class. Subclassing prepends a new thunk to the 
    152  * window winproc chain at the head of the list. Thus, window thunk 
    153  * list includes class thunks and the latter are preserved when the 
     146 * 2) window -'           /             -       not subclassed
     147 *    window -> wp -> wp '              -       SetWindowLong()
     148 *
     149 * 3) timer  -> wp                      -       SetTimer()
     150 *
     151 * Initially, winproc of the window points to the current winproc
     152 * thunk of its class. Subclassing prepends a new thunk to the
     153 * window winproc chain at the head of the list. Thus, window thunk
     154 * list includes class thunks and the latter are preserved when the
    154155 * window is destroyed.
    155156 *
     
    162163
    163164    if(func == NULL) {
    164         *(WINDOWPROC **)pFirst = 0;
    165         return TRUE;
     165        *(WINDOWPROC **)pFirst = 0;
     166        return TRUE;
    166167    }
    167168
     
    177178            {
    178179                if ((*ppPrev)->user != user)
    179                 {
    180                     /* terminal thunk is being restored */
    181 
    182                     WINPROC_FreeProc( *pFirst, (*ppPrev)->user );
    183                     *(WINDOWPROC **)pFirst = *ppPrev;
    184                     return TRUE;
    185                 }
    186                 bRecycle = TRUE;
    187                 break;
    188             }
     180                {
     181                    /* terminal thunk is being restored */
     182
     183                    WINPROC_FreeProc( *pFirst, (*ppPrev)->user );
     184                    *(WINDOWPROC **)pFirst = *ppPrev;
     185                    return TRUE;
     186                }
     187                bRecycle = TRUE;
     188                break;
     189            }
    189190        }
    190191        else
     
    197198            }
    198199        }
    199            
     200
    200201        /* WPF_CLASS thunk terminates window thunk list */
    201202        if ((*ppPrev)->user != user) break;
     
    229230
    230231/**********************************************************************
    231  *           WINPROC_FreeProc
     232 *           WINPROC_FreeProc
    232233 *
    233234 * Free a list of win procs.
     
    246247
    247248/**********************************************************************
    248  *           WINPROC_GetProcType
     249 *           WINPROC_GetProcType
    249250 *
    250251 * Return the window procedure type.
     
    259260
    260261/**********************************************************************
    261  *           CallWindowProc32A    (USER32.18)
     262 *           CallWindowProc32A    (USER32.18)
    262263 *
    263264 * The CallWindowProc() function invokes the windows procedure _func_,
     
    280281 * CONFORMANCE
    281282 *
    282  *   ECMA-234, Win32 
    283  */
    284 LRESULT WINAPI CallWindowProcA( 
     283 *   ECMA-234, Win32
     284 */
     285LRESULT WINAPI CallWindowProcA(
    285286    WNDPROC func, /* window procedure */
    286287    HWND hwnd, /* target window */
     
    319320
    320321/**********************************************************************
    321  *           CallWindowProc32W    (USER32.19)
     322 *           CallWindowProc32W    (USER32.19)
    322323 */
    323324LRESULT WINAPI CallWindowProcW( WNDPROC func, HWND hwnd, UINT msg,
Note: See TracChangeset for help on using the changeset viewer.