From f23208caccf81b0b34c5c11b466c6bd64fdf0f9d Mon Sep 17 00:00:00 2001 From: David Webster Date: Tue, 7 Mar 2000 21:28:30 +0000 Subject: [PATCH] more minimal stuff git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6511 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/os2/app.cpp | 108 +++++++++--------- src/os2/frame.cpp | 195 ++++++++++++++++++++++---------- src/os2/makefile.va | 10 +- src/os2/menu.cpp | 100 +++++++++-------- src/os2/window.cpp | 264 ++++++++++++++++---------------------------- 5 files changed, 350 insertions(+), 327 deletions(-) diff --git a/src/os2/app.cpp b/src/os2/app.cpp index e895010722..2f333e5b1b 100644 --- a/src/os2/app.cpp +++ b/src/os2/app.cpp @@ -92,11 +92,11 @@ HICON wxDEFAULT_MDIPARENTFRAME_ICON = (HICON) NULL; HBRUSH wxDisableButtonBrush = (HBRUSH) 0; -MRESULT wxWndProc( HWND - ,ULONG - ,MPARAM - ,MPARAM - ); +MRESULT EXPENTRY wxWndProc( HWND + ,ULONG + ,MPARAM + ,MPARAM + ); // =========================================================================== // implementation @@ -201,12 +201,12 @@ bool wxApp::RegisterWindowClasses( ERRORID vError = 0L; wxString sError; - if ((rc = ::WinRegisterClass( vHab - ,wxFrameClassName - ,(PFNWP)wxWndProc - ,CS_SIZEREDRAW | CS_SYNCPAINT | CS_FRAME - ,0 - )) != 0) + if (!::WinRegisterClass( vHab + ,wxFrameClassName + ,(PFNWP)wxWndProc + ,CS_SIZEREDRAW | CS_SYNCPAINT + ,0 + )) { vError = ::WinGetLastError(vHab); sError = wxPMErrorToStr(vError); @@ -214,12 +214,12 @@ bool wxApp::RegisterWindowClasses( return FALSE; } - if ((rc = ::WinRegisterClass( vHab - ,wxFrameClassNameNoRedraw - ,(PFNWP)wxWndProc - ,CS_FRAME - ,0 - )) != 0) + if (!::WinRegisterClass( vHab + ,wxFrameClassNameNoRedraw + ,(PFNWP)wxWndProc + ,0 + ,0 + )) { vError = ::WinGetLastError(vHab); sError = wxPMErrorToStr(vError); @@ -227,12 +227,12 @@ bool wxApp::RegisterWindowClasses( return FALSE; } - if ((rc = ::WinRegisterClass( vHab - ,wxMDIFrameClassName - ,(PFNWP)wxWndProc - ,CS_SIZEREDRAW | CS_SYNCPAINT | CS_FRAME - ,0 - )) != 0) + if (!::WinRegisterClass( vHab + ,wxMDIFrameClassName + ,(PFNWP)wxWndProc + ,CS_SIZEREDRAW | CS_SYNCPAINT + ,0 + )) { vError = ::WinGetLastError(vHab); sError = wxPMErrorToStr(vError); @@ -240,12 +240,12 @@ bool wxApp::RegisterWindowClasses( return FALSE; } - if ((rc = ::WinRegisterClass( vHab - ,wxMDIFrameClassNameNoRedraw - ,(PFNWP)wxWndProc - ,CS_FRAME - ,0 - )) != 0) + if (!::WinRegisterClass( vHab + ,wxMDIFrameClassNameNoRedraw + ,(PFNWP)wxWndProc + ,0 + ,0 + )) { vError = ::WinGetLastError(vHab); sError = wxPMErrorToStr(vError); @@ -253,12 +253,12 @@ bool wxApp::RegisterWindowClasses( return FALSE; } - if ((rc = ::WinRegisterClass( vHab - ,wxMDIChildFrameClassName - ,(PFNWP)wxWndProc - ,CS_MOVENOTIFY | CS_SIZEREDRAW | CS_SYNCPAINT | CS_HITTEST | CS_FRAME - ,0 - )) != 0) + if (!::WinRegisterClass( vHab + ,wxMDIChildFrameClassName + ,(PFNWP)wxWndProc + ,CS_MOVENOTIFY | CS_SIZEREDRAW | CS_SYNCPAINT | CS_HITTEST + ,0 + )) { vError = ::WinGetLastError(vHab); sError = wxPMErrorToStr(vError); @@ -266,12 +266,12 @@ bool wxApp::RegisterWindowClasses( return FALSE; } - if ((rc = ::WinRegisterClass( vHab - ,wxMDIChildFrameClassNameNoRedraw - ,(PFNWP)wxWndProc - ,CS_HITTEST | CS_FRAME - ,0 - )) != 0) + if (!::WinRegisterClass( vHab + ,wxMDIChildFrameClassNameNoRedraw + ,(PFNWP)wxWndProc + ,CS_HITTEST + ,0 + )) { vError = ::WinGetLastError(vHab); sError = wxPMErrorToStr(vError); @@ -279,12 +279,12 @@ bool wxApp::RegisterWindowClasses( return FALSE; } - if ((rc = ::WinRegisterClass( vHab - ,wxPanelClassName - ,(PFNWP)wxWndProc - ,CS_MOVENOTIFY | CS_SIZEREDRAW | CS_HITTEST | CS_SAVEBITS | CS_SYNCPAINT - ,0 - )) != 0) + if (!::WinRegisterClass( vHab + ,wxPanelClassName + ,(PFNWP)wxWndProc + ,CS_MOVENOTIFY | CS_SIZEREDRAW | CS_HITTEST | CS_SAVEBITS | CS_SYNCPAINT + ,0 + )) { vError = ::WinGetLastError(vHab); sError = wxPMErrorToStr(vError); @@ -292,12 +292,12 @@ bool wxApp::RegisterWindowClasses( return FALSE; } - if ((rc = ::WinRegisterClass( vHab - ,wxCanvasClassName - ,(PFNWP)wxWndProc - ,CS_MOVENOTIFY | CS_SIZEREDRAW | CS_HITTEST | CS_SAVEBITS | CS_SYNCPAINT - ,0 - )) != 0) + if (!::WinRegisterClass( vHab + ,wxCanvasClassName + ,(PFNWP)wxWndProc + ,CS_MOVENOTIFY | CS_SIZEREDRAW | CS_HITTEST | CS_SAVEBITS | CS_SYNCPAINT + ,0 + )) { vError = ::WinGetLastError(vHab); sError = wxPMErrorToStr(vError); @@ -506,7 +506,7 @@ bool wxApp::OnInitGui() ERRORID vError; wxString sError; - m_hMq = WinCreateMsgQueue(vHabmain, 0); + m_hMq = ::WinCreateMsgQueue(vHabmain, 0); if (!m_hMq) { vError = ::WinGetLastError(vHabmain); diff --git a/src/os2/frame.cpp b/src/os2/frame.cpp index becb832a40..0adff13a4b 100644 --- a/src/os2/frame.cpp +++ b/src/os2/frame.cpp @@ -125,12 +125,6 @@ bool wxFrame::Create( m_bIconized = FALSE; - // - // We pass NULL as parent to MSWCreate because frames with parents behave - // very strangely under Win95 shell. - // Alteration by JACS: keep normal Windows behaviour (float on top of parent) - // with this ulStyle. - // if ((m_windowStyle & wxFRAME_FLOAT_ON_PARENT) == 0) pParent = NULL; @@ -446,11 +440,16 @@ void wxFrame::SetIcon( if (m_icon.Ok()) { - WinSendMsg( GetHwnd() - ,WM_SETICON - ,(MPARAM)((HICON)m_icon.GetHICON()) - ,NULL - ); + ::WinSendMsg( GetHwnd() + ,WM_SETICON + ,(MPARAM)((HICON)m_icon.GetHICON()) + ,NULL + ); + ::WinSendMsg( GetHwnd() + ,WM_UPDATEFRAME + ,(MPARAM)FCF_ICON + ,(MPARAM)0 + ); } } // end of wxFrame::SetIcon @@ -555,12 +554,7 @@ void wxFrame::SetMenuBar( void wxFrame::InternalSetMenuBar() { - - ::WinPostMsg( GetHwnd() - ,WM_UPDATEFRAME - ,(MPARAM)FCF_MENU - ,NULL - ); + WinSendMsg((HWND)GetHwnd(), WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0); } // end of wxFrame::InternalSetMenuBar // @@ -727,83 +721,166 @@ bool wxFrame::OS2Create( , long ulStyle ) { - ULONG ulPmFlags = 0L; + ULONG ulCreateFlags = 0L; + ULONG ulStyleFlags = 0L; ULONG ulExtraFlags = 0L; - ULONG ulTempFlags = FCF_STANDARD; + FRAMECDATA vFrameCtlData; + HWND hParent = NULLHANDLE; + HWND hClient = NULLHANDLE; + HWND hTitlebar = NULLHANDLE; + HWND hHScroll = NULLHANDLE; + HWND hVScroll = NULLHANDLE; + SWP vSwp; + SWP vSwpTitlebar; + SWP vSwpVScroll; + SWP vSwpHScroll; m_hDefaultIcon = (WXHICON) (wxSTD_FRAME_ICON ? wxSTD_FRAME_ICON : wxDEFAULT_FRAME_ICON); + memset(&vSwp, '\0', sizeof(SWP)); + memset(&vSwpTitlebar, '\0', sizeof(SWP)); + memset(&vSwpVScroll, '\0', sizeof(SWP)); + memset(&vSwpHScroll, '\0', sizeof(SWP)); + if (pParent) + hParent = GetWinHwnd(pParent); + else + hParent = HWND_DESKTOP; if (ulStyle == wxDEFAULT_FRAME_STYLE) - ulPmFlags = FCF_STANDARD; + ulCreateFlags = FCF_SIZEBORDER | FCF_TITLEBAR | FCF_SYSMENU | + FCF_MINMAX | FCF_VERTSCROLL | FCF_HORZSCROLL | FCF_TASKLIST; else { if ((ulStyle & wxCAPTION) == wxCAPTION) - ulPmFlags = FCF_TASKLIST; + ulCreateFlags = FCF_TASKLIST; else - ulPmFlags = FCF_NOMOVEWITHOWNER; + ulCreateFlags = FCF_NOMOVEWITHOWNER; if (ulStyle & wxMINIMIZE_BOX) - ulPmFlags |= FCF_MINBUTTON; + ulCreateFlags |= FCF_MINBUTTON; if (ulStyle & wxMAXIMIZE_BOX) - ulPmFlags |= FCF_MAXBUTTON; + ulCreateFlags |= FCF_MAXBUTTON; if (ulStyle & wxTHICK_FRAME) - ulPmFlags |= FCF_DLGBORDER; + ulCreateFlags |= FCF_DLGBORDER; if (ulStyle & wxSYSTEM_MENU) - ulPmFlags |= FCF_SYSMENU; - if ((ulStyle & wxMINIMIZE) || (ulStyle & wxICONIZE)) - ulPmFlags |= WS_MINIMIZED; - if (ulStyle & wxMAXIMIZE) - ulPmFlags |= WS_MAXIMIZED; + ulCreateFlags |= FCF_SYSMENU; if (ulStyle & wxCAPTION) - ulPmFlags |= FCF_TASKLIST; + ulCreateFlags |= FCF_TASKLIST; if (ulStyle & wxCLIP_CHILDREN) { // Invalid for frame windows under PM } - // - // Keep this in wxFrame because it saves recoding this function - // in wxTinyFrame - // -#if wxUSE_ITSY_BITSY if (ulStyle & wxTINY_CAPTION_VERT) - ulExtraFlags |= kVertCaption; + ulCreateFlags |= FCF_TASKLIST; if (ulStyle & wxTINY_CAPTION_HORIZ) - ulExtraFlags |= kHorzCaption; -#else - if (ulStyle & wxTINY_CAPTION_VERT) - ulPmFlags |= FCF_TASKLIST; - if (ulStyle & wxTINY_CAPTION_HORIZ) - ulPmFlags |= FCF_TASKLIST; -#endif + ulCreateFlags |= FCF_TASKLIST; + if ((ulStyle & wxTHICK_FRAME) == 0) - ulPmFlags |= FCF_BORDER; + ulCreateFlags |= FCF_BORDER; if (ulStyle & wxFRAME_TOOL_WINDOW) ulExtraFlags = kFrameToolWindow; if (ulStyle & wxSTAY_ON_TOP) - ulPmFlags |= FCF_SYSMODAL; + ulCreateFlags |= FCF_SYSMODAL; } + if ((ulStyle & wxMINIMIZE) || (ulStyle & wxICONIZE)) + ulStyleFlags |= WS_MINIMIZED; + if (ulStyle & wxMAXIMIZE) + ulStyleFlags |= WS_MAXIMIZED; + // // Clear the visible flag, we always call show // - ulPmFlags &= (unsigned long)~WS_VISIBLE; + ulStyleFlags &= (unsigned long)~WS_VISIBLE; m_bIconized = FALSE; - if ( !wxWindow::OS2Create( nId - ,pParent - ,zWclass - ,pWxWin - ,zTitle - ,nX - ,nY - ,nWidth - ,nHeight - ,ulPmFlags - ,NULL - ,ulExtraFlags)) + + // + // Set the frame control block + // + vFrameCtlData.cb = sizeof(vFrameCtlData); + vFrameCtlData.flCreateFlags = ulCreateFlags; + vFrameCtlData.hmodResources = 0L; + vFrameCtlData.idResources = 0; + + // + // Create the frame window + // + if (!wxWindow::OS2Create( hParent + ,WC_FRAME + ,zTitle + ,ulStyleFlags + ,(long)nX + ,(long)nY + ,(long)nWidth + ,(long)nHeight + ,NULLHANDLE + ,HWND_TOP + ,(long)nId + ,(void*)&vFrameCtlData + ,NULL + )) { return FALSE; } + + // + // Create the client window. We must call the API from here rather than + // the static base class create because we need a separate handle + // + if ((hClient = ::WinCreateWindow( GetHwnd() // Frame is parent + ,zWclass // Custom client class + ,NULL // Window title + ,0 // No styles + ,0, 0, 0, 0 // Window position + ,NULLHANDLE // Owner + ,HWND_TOP // Sibling + ,FID_CLIENT // standard client ID + ,NULL // Creation data + ,NULL // Window Pres Params + )) == 0L) + { + return FALSE; + } + + // + // Now size everything. If adding a menu the client will need to be resized. + // + if (!::WinSetWindowPos( GetHwnd() + ,HWND_TOP + ,nX + ,nY + ,nWidth + ,nHeight + ,SWP_SIZE | SWP_MOVE | SWP_ACTIVATE + )) + return FALSE; + + WinQueryWindowPos(GetHwnd(), &vSwp); + + if (ulCreateFlags & FCF_TITLEBAR) + { + hTitlebar = WinWindowFromID(GetHwnd(), FID_TITLEBAR); + WinQueryWindowPos(hTitlebar, &vSwpTitlebar); + } + if (ulCreateFlags & FCF_HORZSCROLL) + { + hHScroll = WinWindowFromID(GetHwnd(), FID_HORZSCROLL); + WinQueryWindowPos(hHScroll, &vSwpHScroll); + } + if (ulCreateFlags & FCF_VERTSCROLL) + { + hVScroll = WinWindowFromID(GetHwnd(), FID_VERTSCROLL); + WinQueryWindowPos(hVScroll, &vSwpVScroll); + } + if (!::WinSetWindowPos( hClient + ,HWND_TOP + ,SV_CXSIZEBORDER + ,(SV_CYSIZEBORDER - 1) + vSwpHScroll.cy + ,vSwp.cx - ((SV_CXSIZEBORDER * 2) + vSwpVScroll.cx) + ,vSwp.cy - ((SV_CYSIZEBORDER * 2) + 1 + vSwpTitlebar.cy + vSwpHScroll.cy) + ,SWP_SIZE | SWP_MOVE + )) + return FALSE; return TRUE; } // end of wxFrame::OS2Create diff --git a/src/os2/makefile.va b/src/os2/makefile.va index 1785ccae96..ce471c95f4 100644 --- a/src/os2/makefile.va +++ b/src/os2/makefile.va @@ -945,16 +945,16 @@ $(WXDIR)\lib\wx.lib: \ !else # Update the import library -$(WXDIR)\lib\wx210.lib: $(OBJECTS) - implib $(WXDIR)\lib\wx210.lib $(WXDIR)\lib\wx210.def +$(WXDIR)\lib\wx214.lib: $(OBJECTS) + implib $(WXDIR)\lib\wx214.lib $(WXDIR)\lib\wx214.def # Update the dynamic link library -$(WXDIR)\lib\wx200.dll: $(OBJECTS) $(WXDIR)\lib\wx210.lib +$(WXDIR)\lib\wx214.dll: $(OBJECTS) $(WXDIR)\lib\wx214.lib icc @<< /B" $(LINKFLAGS)" /Fe$@ $(LIBS) $(OBJECTS) - $(WXDIR)\lib\wx210.def + $(WXDIR)\lib\wx214.def << !endif @@ -1040,7 +1040,7 @@ clean_tiff: clean: $(PERIPH_CLEAN_TARGET) clean_png clean_zlib clean_jpeg clean_xpm clean_tiff del $(LIBTARGET) !if "$(WXMAKINGDLL)" == "1" - erase /N ..\..\lib\wx200.lib + erase /N ..\..\lib\wx214.lib !endif erase /N $(GENDIR)\$D\*.obj erase /N $(COMMDIR)\$D\*.obj diff --git a/src/os2/menu.cpp b/src/os2/menu.cpp index 023870332c..8ff449298f 100644 --- a/src/os2/menu.cpp +++ b/src/os2/menu.cpp @@ -71,20 +71,22 @@ void wxMenu::Init() m_bDoBreak = FALSE; // - // Create the menu + // Create the menu (to be used as a submenu or a popup) // - m_hMenu = ::WinCreateWindow( HWND_DESKTOP // parent - ,WC_MENU // type - ,"Menu" // a generic name - ,0L // no style flag - ,0L,0L,0L,0L // no position - ,NULLHANDLE // no owner - ,NULLHANDLE // no insertion position - ,0L // no ID needed for dynamic creation - ,NULL // no control data - ,NULL // no presentation params - ); - if (!m_hMenu) + if ((m_hMenu = ::WinCreateWindow( HWND_DESKTOP + ,(const wxChar*)WC_MENU + ,"Menu" + ,0L + ,0L + ,0L + ,0L + ,0L + ,NULLHANDLE + ,HWND_TOP + ,0L + ,NULL + ,NULL + )) != 0) { wxLogLastError("WinLoadMenu"); } @@ -92,7 +94,7 @@ void wxMenu::Init() // // If we have a title, insert it in the beginning of the menu // - if (!!m_title) + if (!m_title.IsEmpty()) { Append( idMenuTitle ,m_title @@ -230,13 +232,13 @@ bool wxMenu::DoInsertOrAppend( // wxMenu* pSubmenu = pItem->GetSubMenu(); - MENUITEM vItem; - if (pSubmenu != NULL ) + if (pSubmenu != NULL) { wxASSERT_MSG(pSubmenu->GetHMenu(), wxT("invalid submenu")); pSubmenu->SetParent(this); + m_vMenuData.iPosition = 0; // submenus have a 0 position m_vMenuData.id = (USHORT)pSubmenu->GetHMenu(); m_vMenuData.afStyle |= MIS_SUBMENU; } @@ -253,6 +255,7 @@ bool wxMenu::DoInsertOrAppend( // // Want to get {Measure|Draw}Item messages? // item draws itself, pass pointer to it in data parameter + // Will eventually need to set the image handle somewhere into m_vMenuData.hItem // m_vMenuData.afStyle |= MIS_OWNERDRAW; pData = (BYTE*)pItem; @@ -270,34 +273,35 @@ bool wxMenu::DoInsertOrAppend( BOOL bOk; // - // -1 means this is a sub menu not a menuitem + // -1 means this is a sub menu not a menuitem. We must create a window for it. + // Submenus are also attached to a menubar so its parent and owner should be the handle of the menubar. // if (nPos == (size_t)-1) { - HWND hSubMenu = ::WinCreateWindow( HWND_DESKTOP // parent - ,WC_MENU // type - ,"Menu" // a generic name - ,0L // no style flag - ,0L,0L,0L,0L // no position - ,NULLHANDLE // no owner - ,NULLHANDLE // no insertion position - ,0L // no ID needed for dynamic creation - ,NULL // no control data - ,NULL // no presentation params + HWND hSubMenu = ::WinCreateWindow( GetWinHwnd(m_menuBar) // parent + ,WC_MENU // type + ,"Menu" // a generic name + ,0L // no style flag + ,0L,0L,0L,0L // no position + ,GetWinHwnd(m_menuBar) // no owner + ,HWND_TOP // always on top + ,0L // no ID needed for dynamic creation + ,NULL // no control data + ,NULL // no presentation params ); m_vMenuData.iPosition = 0; m_vMenuData.hwndSubMenu = hSubMenu; m_vMenuData.hItem = NULLHANDLE; - bOk = (bool)::WinSendMsg(GetHmenu(), MM_INSERTITEM, (MPARAM)&vItem, (MPARAM)NULL); + bOk = (bool)::WinSendMsg(GetHmenu(), MM_INSERTITEM, (MPARAM)&m_vMenuData, (MPARAM)pItem->GetText().c_str()); } else { m_vMenuData.iPosition = nPos; m_vMenuData.hwndSubMenu = NULLHANDLE; m_vMenuData.hItem = NULLHANDLE; - bOk = (bool)::WinSendMsg(GetHmenu(), MM_INSERTITEM, (MPARAM)&vItem, (MPARAM)pData); + bOk = (bool)::WinSendMsg(GetHmenu(), MM_INSERTITEM, (MPARAM)&m_vMenuData, (MPARAM)pItem->GetText().c_str()); } if (!bOk) @@ -609,33 +613,43 @@ void wxMenuBar::Refresh() { wxCHECK_RET( IsAttached(), wxT("can't refresh unatteched menubar") ); -// DrawMenuBar(GetHwndOf(m_menuBarFrame)); -} + WinSendMsg(GetWinHwnd(m_pMenuBarFrame), WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0); +} // end of wxMenuBar::Refresh WXHMENU wxMenuBar::Create() { MENUITEM vItem; + HWND hFrame; if (m_hMenu != 0 ) return m_hMenu; wxCHECK_MSG(!m_hMenu, TRUE, wxT("menubar already created")); + // + // Menubars should be associated with a frame otherwise they are popups + // + if (m_pMenuBarFrame != NULL) + hFrame = GetWinHwnd(m_pMenuBarFrame); + else + hFrame = HWND_DESKTOP; // // Create an empty menu and then fill it with insertions // - m_hMenu = ::WinCreateWindow( HWND_DESKTOP // parent - ,WC_MENU // type - ,"Menu" // a generic name - ,0L // no style flag - ,0L,0L,0L,0L // no position - ,NULLHANDLE // no owner - ,NULLHANDLE // no insertion position - ,0L // no ID needed for dynamic creation - ,NULL // no control data - ,NULL // no presentation params - ); - if (!m_hMenu) + if (!wxWindow::OS2Create( hFrame + ,WC_MENU + ,"Menu" + ,MS_ACTIONBAR | WS_SYNCPAINT | WS_VISIBLE + ,0L + ,0L + ,0L + ,0L + ,hFrame + ,HWND_TOP + ,FID_MENU + ,(PVOID)NULL + ,(PVOID)NULL + )) { wxLogLastError("CreateMenu"); } diff --git a/src/os2/window.cpp b/src/os2/window.cpp index 5120d55fa2..01de71dd15 100644 --- a/src/os2/window.cpp +++ b/src/os2/window.cpp @@ -111,11 +111,11 @@ wxList* wxWinHandleList = NULL; // // the window proc for all our windows; most gui's have something similar // -MRESULT wxWndProc( HWND hWnd - ,ULONG message - ,MPARAM mp1 - ,MPARAM mp2 - ); +MRESULT EXPENTRY wxWndProc( HWND hWnd + ,ULONG message + ,MPARAM mp1 + ,MPARAM mp2 + ); #ifdef __WXDEBUG__ const char *wxGetMessageName(int message); @@ -326,6 +326,8 @@ bool wxWindow::Create( , const wxString& rName ) { + HWND hParent = NULLHANDLE; + wxCHECK_MSG(pParent, FALSE, wxT("can't create wxWindow without parent")); if ( !CreateBase( pParent @@ -338,53 +340,47 @@ bool wxWindow::Create( )) return(FALSE); - pParent->AddChild(this); + if (pParent) + { + pParent->AddChild(this); + hParent = GetWinHwnd(pParent); + } + else + hParent = HWND_DESKTOP; + + ULONG ulCreateFlags = 0L; - ULONG ulFlags = 0L; // - // Frame windows and their derivatives only + // Most wxSTYLES are really PM Class specific styles and will be + // set in those class create procs. PM's basic windows styles are + // very limited. // - if (lStyle & wxBORDER) - ulFlags |= FCF_BORDER; - if (lStyle & wxTHICK_FRAME ) - ulFlags |= FCF_SIZEBORDER; - - // - // Some generic window styles - // - ulFlags |= WS_VISIBLE; if (lStyle & wxCLIP_CHILDREN ) - ulFlags |= WS_CLIPCHILDREN; + ulCreateFlags |= WS_CLIPCHILDREN; + // + // Empty stuff for now since PM has no custome 3D effects + // Doesn't mean someone cannot make some up though + // bool bWant3D; WXDWORD dwExStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &bWant3D); // - // OS/2 PM doesn't have "extended" styles but if the library specifies - // them and we are creating a frame window then at least give it a border + // Generic OS/2 Windows are created with no owner, no Z Order, no Control data, + // and no presentation parameters // - if ( bWant3D || - (m_windowStyle & wxSIMPLE_BORDER) || - (m_windowStyle & wxRAISED_BORDER ) || - (m_windowStyle & wxSUNKEN_BORDER) || - (m_windowStyle & wxDOUBLE_BORDER) - ) - { - ulFlags |= FCF_BORDER; - } - OS2Create( m_windowId - ,pParent - ,wxCanvasClassName - ,this - ,NULL + OS2Create( hParent + ,(PSZ)wxCanvasClassName + ,rName.c_str() + ,ulCreateFlags ,rPos.x ,rPos.y ,WidthDefault(rSize.x) ,HeightDefault(rSize.y) - ,ulFlags - ,NULL - ,dwExStyle + ,NULLHANDLE + ,NULLHANDLE + ,m_windowId ); return(TRUE); } // end of wxWindow::Create @@ -1773,7 +1769,7 @@ wxWindow* wxWndHook = NULL; // // Main window proc // -MRESULT wxWndProc( +MRESULT EXPENTRY wxWndProc( HWND hWnd , ULONG ulMsg , MPARAM wParam @@ -2313,26 +2309,28 @@ void wxWindow::OS2DetachWindowMenu() } // end of wxWindow::OS2DetachWindowMenu bool wxWindow::OS2Create( - int vId -, wxWindow* pParent -, const wxChar* zWclass -, wxWindow* pWxWin + WXHWND hParent +, PSZ zClass , const wxChar* zTitle -, int nX -, int nY -, int nWidth -, int nHeight , WXDWORD dwStyle -, const wxChar* zDialogTemplate -, WXDWORD dwExtendedStyle // Port compatability only +, long lX +, long lY +, long lWidth +, long lHeight +, WXHWND hOwner +, WXHWND hZOrder +, unsigned long ulId +, void* pCtlData +, void* pPresParams ) { ERRORID vError; wxString sError; - int nX1 = CW_USEDEFAULT; - int nY1 = 0; - int nWidth1 = CW_USEDEFAULT; - int nHeight1 = 100; + long lX1 = (long)CW_USEDEFAULT; + long lY1 = 0L; + long lWidth1 = (long)CW_USEDEFAULT; + long lHeight1 = 100L; + int nControlId = 0; // // Find parent's size, if it exists, to set up a possible default @@ -2341,126 +2339,60 @@ bool wxWindow::OS2Create( RECTL vParentRect; HWND hWndClient; - HWND hParent = (HWND)NULL; - - if (pParent) - { - hParent = (HWND)pParent->GetHWND(); - hWndClient = ::WinWindowFromID(hParent, FID_CLIENT); - ::WinQueryWindowRect(hWndClient, &vParentRect); - - nWidth1 = vParentRect.xRight - vParentRect.xLeft; - nHeight1 = vParentRect.yTop - vParentRect.yBottom; - } - else - hParent = HWND_DESKTOP; - - if (nX > -1) - nX1 = nX; - if (nY > -1) - nY1 = nY; - if (nWidth > -1) - nWidth1 = nWidth; - if (nHeight > -1) - nHeight1 = nHeight; + if (lX > -1L) + lX1 = lX; + if (lY > -1L) + lY1 = lY; + if (lWidth > -1L) + lWidth1 = lWidth; + if (lHeight > -1L) + lHeight1 = lHeight; wxWndHook = this; - if (zDialogTemplate) + // + // check to see if the new window is a standard control + // + if ((ULONG)zClass == (ULONG)WC_BUTTON || + (ULONG)zClass == (ULONG)WC_COMBOBOX || + (ULONG)zClass == (ULONG)WC_CONTAINER || + (ULONG)zClass == (ULONG)WC_ENTRYFIELD || + (ULONG)zClass == (ULONG)WC_LISTBOX || + (ULONG)zClass == (ULONG)WC_MENU || + (ULONG)zClass == (ULONG)WC_NOTEBOOK || + (ULONG)zClass == (ULONG)WC_SCROLLBAR || + (ULONG)zClass == (ULONG)WC_SPINBUTTON || + (ULONG)zClass == (ULONG)WC_STATIC || + (ULONG)zClass == (ULONG)WC_TITLEBAR || + (ULONG)zClass == (ULONG)WC_VALUESET + ) { - // - // We can use extended styles for custom default user config params - // These can be processed in the dialog proc's WM_INITDLG - // Dialog template is defined by vId and should be loaded from the - // resource file in the current .exe - // - PDLGTEMPLATE pDlgt; - - ::DosGetResource(0L, RT_DIALOG, vId, (PPVOID)&pDlgt); - m_hWnd = (WXHWND)::WinCreateDlg( hParent - ,NULLHANDLE - ,(PFNWP)wxDlgProc - ,pDlgt - ,(PVOID)&dwExtendedStyle - ); - if (m_hWnd == 0) - { - vError = ::WinGetLastError(vHabmain); - sError = wxPMErrorToStr(vError); - wxLogError("Can't find dummy dialog template!\n" - "Check resource include path for finding wx.rc.\n" - "Error: %s\n", sError); - return FALSE; - } - - // - // Move the dialog to its initial position without forcing repainting - // - if (!::WinSetWindowPos( m_hWnd - ,HWND_TOP - ,nX1 - ,nY1 - ,nWidth1 - ,nHeight1 - ,SWP_MOVE | SWP_SIZE | SWP_NOREDRAW - )); - { - vError = ::WinGetLastError(vHabmain); - sError = wxPMErrorToStr(vError); - wxLogError("MoveWindow, error: %s\n", sError); - } + nControlId = ulId; } - else + + // + // We will either have a registered class via string name or a standard PM Class via a long + // + m_hWnd = (WXHWND)::WinCreateWindow( (HWND)hParent + ,zClass + ,(PSZ)zTitle ? zTitle : wxT("") + ,(ULONG)dwStyle + ,(LONG)lX1 + ,(LONG)lY1 + ,(LONG)lWidth + ,(LONG)lHeight + ,NULLHANDLE + ,HWND_TOP + ,(ULONG)ulId + ,pCtlData + ,pPresParams + ); + if (!m_hWnd) { - int nControlId = 0; - WXDWORD dwClass = dwStyle | 0xffff0000; - - // - // check to see if the new window is a standard control - // - if (dwClass & (ULONG)WC_BUTTON || - dwClass & (ULONG)WC_COMBOBOX || - dwClass & (ULONG)WC_CONTAINER || - dwClass & (ULONG)WC_ENTRYFIELD || - dwClass & (ULONG)WC_LISTBOX || - dwClass & (ULONG)WC_MENU || - dwClass & (ULONG)WC_NOTEBOOK || - dwClass & (ULONG)WC_SCROLLBAR || - dwClass & (ULONG)WC_SPINBUTTON || - dwClass & (ULONG)WC_STATIC || - dwClass & (ULONG)WC_TITLEBAR || - dwClass & (ULONG)WC_VALUESET - ) - nControlId = vId; - - wxString sClassName(zWclass); - - if (GetWindowStyleFlag() & wxNO_FULL_REPAINT_ON_RESIZE ) - { - sClassName += wxT("NR"); - } - - m_hWnd = (WXHWND)::WinCreateWindow( hParent - ,(PSZ)sClassName.c_str() - ,zTitle ? zTitle : wxT("") - ,dwStyle - ,nX1 - ,nY1 - ,nWidth - ,nHeight - ,NULLHANDLE - ,HWND_TOP - ,vId - ,NULL - ,NULL - ); - if (!m_hWnd) - { - vError = ::WinGetLastError(vHabmain); - sError = wxPMErrorToStr(vError); - wxLogError("Can't create window of class %s!. Error: %s\n", zWclass, sError); - return FALSE; - } + vError = ::WinGetLastError(vHabmain); + sError = wxPMErrorToStr(vError); + wxLogError("Can't create window of class %s!. Error: %s\n", zClass, sError); + return FALSE; } wxWndHook = NULL;