void wxFrame::InternalSetMenuBar() { ERRORID vError; wxString sError; // // Set the parent and owner of the menubar to be the frame // if (!::WinSetParent(m_hMenu, m_hFrame, FALSE)) { vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); wxLogError(wxT("Error setting parent for submenu. Error: %s\n"), sError.c_str()); } if (!::WinSetOwner(m_hMenu, m_hFrame)) { vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); wxLogError(wxT("Error setting parent for submenu. Error: %s\n"), sError.c_str()); } ::WinSendMsg(m_hFrame, WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0); } // end of wxFrame::InternalSetMenuBar
void wxFrame::PositionStatusBar() { SWP vSwp; ERRORID vError; wxString sError; // // Native status bar positions itself // if (m_frameStatusBar) { int nWidth; int nY; int nStatbarWidth; int nStatbarHeight; RECTL vRect; RECTL vFRect; ::WinQueryWindowRect(m_hFrame, &vRect); nY = vRect.yTop; ::WinMapWindowPoints(m_hFrame, HWND_DESKTOP, (PPOINTL)&vRect, 2); vFRect = vRect; ::WinCalcFrameRect(m_hFrame, &vRect, TRUE); nWidth = vRect.xRight - vRect.xLeft; nY = nY - (vRect.yBottom - vFRect.yBottom); m_frameStatusBar->GetSize( &nStatbarWidth ,&nStatbarHeight ); nY= nY - nStatbarHeight; // // Since we wish the status bar to be directly under the client area, // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS. // m_frameStatusBar->SetSize( vRect.xLeft - vFRect.xLeft ,nY ,nWidth ,nStatbarHeight ); if (!::WinQueryWindowPos(m_frameStatusBar->GetHWND(), &vSwp)) { vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); wxLogError(wxT("Error setting parent for StatusBar. Error: %s\n"), sError.c_str()); return; } } } // end of wxFrame::PositionStatusBar
bool wxApp::OnInitGui() { ERRORID vError; wxString sError; if (!wxAppBase::OnInitGui()) return false; m_hMq = ::WinCreateMsgQueue(vHabmain, 0); if (!m_hMq) { vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); wxLogDebug(sError); return false; } return true; } // end of wxApp::OnInitGui
bool wxBrush::RealizeResource() { BOOL bOk; ERRORID vError; wxString sError; if (M_BRUSHDATA && M_BRUSHDATA->m_hBrush == 0L) { SIZEL vSize = {0, 0}; DEVOPENSTRUC vDop = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L}; HDC hDC = ::DevOpenDC( vHabmain ,OD_MEMORY ,"*" ,5L ,(PDEVOPENDATA)&vDop ,NULLHANDLE ); M_BRUSHDATA->m_hBrush = (WXHPEN)::GpiCreatePS( vHabmain ,hDC ,&vSize ,PU_PELS | GPIT_MICRO | GPIA_ASSOC ); } if (M_BRUSHDATA) { // // Set the color table to RGB mode // if (!::GpiCreateLogColorTable( (HPS)M_BRUSHDATA->m_hBrush ,0L ,LCOLF_RGB ,0L ,0L ,NULL )) { vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); wxLogError(_T("Unable to set current color table to RGB mode. Error: %s\n"), sError.c_str()); return FALSE; } if (M_BRUSHDATA->m_nStyle==wxTRANSPARENT) { return TRUE; } COLORREF vPmColour = 0L; vPmColour = M_BRUSHDATA->m_vColour.GetPixel() ; M_BRUSHDATA->m_vBundle.usSet = LCID_DEFAULT; switch (M_BRUSHDATA->m_nStyle) { case wxTRANSPARENT: M_BRUSHDATA->m_hBrush = NULL; // Must always select a suitable background brush break; // - could choose white always for a quick solution case wxBDIAGONAL_HATCH: M_BRUSHDATA->m_vBundle.usSymbol = PATSYM_DIAG3; break; case wxCROSSDIAG_HATCH: M_BRUSHDATA->m_vBundle.usSymbol = PATSYM_DIAGHATCH; break; case wxFDIAGONAL_HATCH: M_BRUSHDATA->m_vBundle.usSymbol = PATSYM_DIAG1; break; case wxCROSS_HATCH: M_BRUSHDATA->m_vBundle.usSymbol = PATSYM_HATCH; break; case wxHORIZONTAL_HATCH: M_BRUSHDATA->m_vBundle.usSymbol = PATSYM_HORIZ; break; case wxVERTICAL_HATCH: M_BRUSHDATA->m_vBundle.usSymbol = PATSYM_VERT; break; case wxSTIPPLE: if (M_BRUSHDATA->m_vStipple.Ok()) { ::GpiSetBitmapId( M_BRUSHDATA->m_hBrush ,(USHORT)M_BRUSHDATA->m_vStipple.GetHBITMAP() ,(USHORT)M_BRUSHDATA->m_vStipple.GetId() ); ::GpiSetPatternSet( M_BRUSHDATA->m_hBrush ,(USHORT)M_BRUSHDATA->m_vStipple.GetId() ); } else M_BRUSHDATA->m_vBundle.usSymbol = PATSYM_SOLID; break ; case wxSOLID: default: M_BRUSHDATA->m_vBundle.usSymbol = PATSYM_SOLID; break; } #ifdef WXDEBUG_CREATE if (M_BRUSHDATA->m_hBrush==NULL) wxError("Cannot create brush","Internal error") ; #endif M_BRUSHDATA->m_vBundle.lColor = vPmColour; M_BRUSHDATA->m_vBundle.lBackColor = RGB_WHITE; M_BRUSHDATA->m_vBundle.usMixMode = FM_OVERPAINT; M_BRUSHDATA->m_vBundle.usBackMixMode = BM_OVERPAINT; bOk = ::GpiSetAttrs( M_BRUSHDATA->m_hBrush ,PRIM_AREA ,ABB_COLOR | ABB_BACK_COLOR | ABB_MIX_MODE | ABB_BACK_MIX_MODE | ABB_SET | ABB_SYMBOL ,ABB_REF_POINT ,&M_BRUSHDATA->m_vBundle ); if (!bOk) { vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); wxLogError(_T("Can't set Gpi attributes for an AREABUNDLE. Error: %s\n"), sError.c_str()); } return bOk; } return FALSE; } // end of wxBrush::RealizeResource
bool wxPen::RealizeResource() { BOOL bOk; ERRORID vError; wxString sError; if (M_PENDATA && M_PENDATA->m_hPen == 0L) { SIZEL vSize = {0, 0}; DEVOPENSTRUC vDop = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L}; HDC hDC = ::DevOpenDC( vHabmain ,OD_MEMORY ,"*" ,5L ,(PDEVOPENDATA)&vDop ,NULLHANDLE ); M_PENDATA->m_hPen = (WXHPEN)::GpiCreatePS( vHabmain ,hDC ,&vSize ,PU_PELS | GPIT_MICRO | GPIA_ASSOC ); } if (M_PENDATA) { // // Set the color table to RGB mode // if (!::GpiCreateLogColorTable( (HPS)M_PENDATA->m_hPen ,0L ,LCOLF_RGB ,0L ,0L ,NULL )) { vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); wxLogError(_T("Unable to set current color table to RGB mode. Error: %s\n"), sError.c_str()); return false; } if (M_PENDATA->m_nStyle == wxTRANSPARENT) { return true; } COLORREF vPmColour = 0L; USHORT uLineType = (USHORT)wx2os2PenStyle(M_PENDATA->m_nStyle); vPmColour = M_PENDATA->m_vColour.GetPixel(); USHORT uJoin = 0L; switch(M_PENDATA->m_nJoin) { case wxJOIN_BEVEL: uJoin = LINEJOIN_BEVEL; break; case wxJOIN_MITER: uJoin = LINEJOIN_MITRE; break; case wxJOIN_ROUND: uJoin = LINEJOIN_ROUND; break; } USHORT uCap = 0L; switch(M_PENDATA->m_nCap) { case wxCAP_PROJECTING: uCap = LINEEND_SQUARE; break; case wxCAP_BUTT: uCap = LINEEND_FLAT; break; case wxCAP_ROUND: uCap = LINEEND_ROUND; break; } m_vLineBundle.lColor = (LONG)vPmColour; m_vLineBundle.usMixMode = FM_OVERPAINT; if (M_PENDATA->m_nWidth < 1) M_PENDATA->m_nWidth = 1; m_vLineBundle.fxWidth = M_PENDATA->m_nWidth; m_vLineBundle.lGeomWidth = M_PENDATA->m_nWidth; m_vLineBundle.usType = uLineType; m_vLineBundle.usEnd = uCap; m_vLineBundle.usJoin = uJoin; bOk = ::GpiSetAttrs( M_PENDATA->m_hPen ,PRIM_LINE ,LBB_COLOR | LBB_MIX_MODE | LBB_WIDTH | LBB_GEOM_WIDTH | LBB_TYPE | LBB_END | LBB_JOIN ,0L ,&m_vLineBundle ); if (!bOk) { vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); wxLogError(_T("Can't set Gpi attributes for a LINEBUNDLE. Error: %s\n"), sError.c_str()); return false; } ULONG flAttrMask = 0L; ULONG flDefMask = 0L; switch(M_PENDATA->m_nStyle) { case wxSTIPPLE: ::GpiSetBitmapId( M_PENDATA->m_hPen ,(USHORT)M_PENDATA->m_vStipple.GetHBITMAP() ,(USHORT)M_PENDATA->m_vStipple.GetId() ); ::GpiSetPatternSet( M_PENDATA->m_hPen ,(USHORT)M_PENDATA->m_vStipple.GetId() ); flAttrMask = ABB_COLOR | ABB_BACK_COLOR | ABB_MIX_MODE | ABB_BACK_MIX_MODE | ABB_SET | ABB_SYMBOL; flDefMask = ABB_REF_POINT; break; case wxBDIAGONAL_HATCH: m_vAreaBundle.usSymbol = PATSYM_DIAG3; m_vAreaBundle.usSet = LCID_DEFAULT; flAttrMask = ABB_COLOR | ABB_BACK_COLOR | ABB_MIX_MODE | ABB_BACK_MIX_MODE | ABB_SYMBOL; flDefMask = ABB_SET | ABB_REF_POINT; break; case wxCROSSDIAG_HATCH: m_vAreaBundle.usSymbol = PATSYM_DIAGHATCH; m_vAreaBundle.usSet = LCID_DEFAULT; flAttrMask = ABB_COLOR | ABB_BACK_COLOR | ABB_MIX_MODE | ABB_BACK_MIX_MODE | ABB_SYMBOL; flDefMask = ABB_SET | ABB_REF_POINT; break; case wxFDIAGONAL_HATCH: m_vAreaBundle.usSymbol = PATSYM_DIAG1; m_vAreaBundle.usSet = LCID_DEFAULT; flAttrMask = ABB_COLOR | ABB_BACK_COLOR | ABB_MIX_MODE | ABB_BACK_MIX_MODE | ABB_SYMBOL; flDefMask = ABB_SET | ABB_REF_POINT; break; case wxCROSS_HATCH: m_vAreaBundle.usSymbol = PATSYM_HATCH; m_vAreaBundle.usSet = LCID_DEFAULT; flAttrMask = ABB_COLOR | ABB_BACK_COLOR | ABB_MIX_MODE | ABB_BACK_MIX_MODE | ABB_SYMBOL; flDefMask = ABB_SET | ABB_REF_POINT; break; case wxHORIZONTAL_HATCH: m_vAreaBundle.usSymbol = PATSYM_HORIZ; m_vAreaBundle.usSet = LCID_DEFAULT; flAttrMask = ABB_COLOR | ABB_BACK_COLOR | ABB_MIX_MODE | ABB_BACK_MIX_MODE | ABB_SYMBOL; flDefMask = ABB_SET | ABB_REF_POINT; break; case wxVERTICAL_HATCH: m_vAreaBundle.usSymbol = PATSYM_VERT; m_vAreaBundle.usSet = LCID_DEFAULT; flAttrMask = ABB_COLOR | ABB_BACK_COLOR | ABB_MIX_MODE | ABB_BACK_MIX_MODE | ABB_SYMBOL; flDefMask = ABB_SET | ABB_REF_POINT; break; default: m_vAreaBundle.usSymbol = PATSYM_SOLID; m_vAreaBundle.usSet = LCID_DEFAULT; flAttrMask = ABB_COLOR | ABB_BACK_COLOR | ABB_MIX_MODE | ABB_BACK_MIX_MODE | ABB_SYMBOL; flDefMask = ABB_SET | ABB_REF_POINT; break; } m_vAreaBundle.lColor = vPmColour; m_vAreaBundle.lBackColor = RGB_WHITE; m_vAreaBundle.usMixMode = FM_OVERPAINT; m_vAreaBundle.usBackMixMode = BM_OVERPAINT; bOk = ::GpiSetAttrs( M_PENDATA->m_hPen ,PRIM_AREA ,flAttrMask ,flDefMask ,&m_vAreaBundle ); if (!bOk) { vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); wxLogError(_T("Can't set Gpi attributes for an AREABUNDLE. Error: %s\n"), sError.c_str()); } return (bool)bOk; } return false; } // end of wxPen::RealizeResource
void wxFillLogFont( LOGFONT* pFattrs, // OS2 GPI FATTRS PFACENAMEDESC pFaceName, HPS* phPS, bool* pbInternalPS, long* pflId, wxString& sFaceName, wxFont* pFont ) { LONG lNumFonts = 0L; // For system font count ERRORID vError; // For logging API errors LONG lTemp = 0L; bool bInternalPS = false; // if we have to create one PFONTMETRICS pFM = NULL; // // Initial house cleaning to free data buffers and ensure we have a // functional PS to work with // if (!*phPS) { *phPS = ::WinGetPS(HWND_DESKTOP); bInternalPS = true; } // // Determine the number of fonts. // if((lNumFonts = ::GpiQueryFonts( *phPS ,QF_PUBLIC | QF_PRIVATE ,NULL ,&lTemp ,(LONG) sizeof(FONTMETRICS) ,NULL )) < 0L) { ERRORID vError; wxString sError; vError = ::WinGetLastError(wxGetInstance()); sError = wxPMErrorToStr(vError); return; } // // Allocate space for the font metrics. // pFM = new FONTMETRICS[lNumFonts + 1]; // // Retrieve the font metrics. // lTemp = lNumFonts; lTemp = ::GpiQueryFonts( *phPS ,QF_PUBLIC ,NULL ,&lTemp ,(LONG) sizeof(FONTMETRICS) ,pFM ); pFont->SetFM( pFM ,(int)lNumFonts ); // // Initialize FATTR and FACENAMEDESC // pFattrs->usRecordLength = sizeof(FATTRS); pFattrs->fsFontUse = FATTR_FONTUSE_OUTLINE; // only outline fonts allowed pFattrs->fsType = 0; pFattrs->lMaxBaselineExt = pFattrs->lAveCharWidth = 0; pFattrs->idRegistry = 0; pFattrs->lMatch = 0; pFaceName->usSize = sizeof(FACENAMEDESC); pFaceName->usWeightClass = FWEIGHT_DONT_CARE; pFaceName->usWidthClass = FWIDTH_DONT_CARE; pFaceName->usReserved = 0; pFaceName->flOptions = 0; // // This does the actual selection of fonts // wxOS2SelectMatchingFontByName( pFattrs ,pFaceName ,pFM ,(int)lNumFonts ,pFont ); // // We should now have the correct FATTRS set with the selected // font, so now we need to generate an ID // long lNumLids = ::GpiQueryNumberSetIds(*phPS); if(lNumLids ) { long alTypes[255]; STR8 azNames[255]; long alIds[255]; memset(alIds, 0, sizeof(long) * 255); if(!::GpiQuerySetIds( *phPS ,lNumLids ,alTypes ,azNames ,alIds )) { if (bInternalPS) ::WinReleasePS(*phPS); return; } if (*pflId == 0L) *pflId = 1L; for(unsigned long LCNum = 0; LCNum < (unsigned long)lNumLids; LCNum++) if(alIds[LCNum] == *pflId) ++*pflId; if(*pflId > 254) // wow, no id available! { if (bInternalPS) ::WinReleasePS(*phPS); return; } } else *pflId = 1L; // // Release and delete the current font // ::GpiSetCharSet(*phPS, LCID_DEFAULT);/* release the font before deleting */ ::GpiDeleteSetId(*phPS, 1L); /* delete the logical font */ // // Now build a facestring // char zFacename[128]; strcpy(zFacename, pFattrs->szFacename); if(::GpiQueryFaceString( *phPS ,zFacename ,pFaceName ,FACESIZE ,pFattrs->szFacename ) == GPI_ERROR) { vError = ::WinGetLastError(vHabmain); } sFaceName = (wxChar*)zFacename; *pbInternalPS = bInternalPS; // // That's it, we now have everything we need to actually create the font // } // end of wxFillLogFont
// // Same as AddPage() but does it at given position // bool wxNotebook::InsertPage ( size_t nPage, wxNotebookPage* pPage, const wxString& rsStrText, bool bSelect, int nImageId ) { ULONG ulApiPage; wxASSERT( pPage != NULL ); wxCHECK( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), false ); // // Under OS/2 we can only insert FIRST, LAST, NEXT or PREV. Requires // two different calls to the API. Page 1 uses the BKA_FIRST. Subsequent // pages use the previous page ID coupled with a BKA_NEXT call. Unlike // Windows, OS/2 uses an internal Page ID to ID the pages. // // OS/2 also has a nice auto-size feature that automatically sizes the // the attached window so we don't have to worry about the size of the // window on the page. // if (nPage == 0) { ulApiPage = LONGFROMMR(::WinSendMsg( GetHWND() ,BKM_INSERTPAGE ,(MPARAM)0 ,MPFROM2SHORT(BKA_AUTOPAGESIZE | BKA_MAJOR, BKA_FIRST) )); if (ulApiPage == 0L) { ERRORID vError; wxString sError; vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); return false; } m_alPageId.Insert((long)ulApiPage, nPage); } else { ulApiPage = LONGFROMMR(::WinSendMsg( GetHWND() ,BKM_INSERTPAGE ,MPFROMLONG((ULONG)m_alPageId[nPage - 1]) ,MPFROM2SHORT(BKA_AUTOPAGESIZE | BKA_MAJOR, BKA_NEXT) )); if (ulApiPage == 0L) { ERRORID vError; wxString sError; vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); return false; } m_alPageId.Insert((long)ulApiPage, nPage); } // // Associate a window handle with the page // if (pPage) { if (!::WinSendMsg( GetHWND() ,BKM_SETPAGEWINDOWHWND ,MPFROMLONG((ULONG)m_alPageId[nPage]) ,MPFROMHWND(pPage->GetHWND()) )) return false; } // // If the inserted page is before the selected one, we must update the // index of the selected page // if (nPage <= (size_t)m_nSelection) { // // One extra page added // m_nSelection++; } if (pPage) { // // Save the pointer to the page // m_pages.Insert( pPage ,nPage ); } // // Now set TAB dimenstions // wxWindowDC vDC(this); wxCoord nTextX; wxCoord nTextY; vDC.GetTextExtent(rsStrText, &nTextX, &nTextY); nTextY *= 2; nTextX = (wxCoord)(nTextX * 1.3); if (nTextX > m_nTabSize) { m_nTabSize = nTextX; ::WinSendMsg( GetHWND() ,BKM_SETDIMENSIONS ,MPFROM2SHORT((USHORT)m_nTabSize, (USHORT)nTextY) ,(MPARAM)BKA_MAJORTAB ); } // // Now set any TAB text // if (!rsStrText.empty()) { if (!SetPageText( nPage ,rsStrText )) return false; } // // Now set any TAB bitmap image // if (nImageId != -1) { if (!SetPageImage( nPage ,nImageId )) return false; } if (pPage) { // // Don't show pages by default (we'll need to adjust their size first) // HWND hWnd = GetWinHwnd(pPage); WinSetWindowULong( hWnd ,QWL_STYLE ,WinQueryWindowULong( hWnd ,QWL_STYLE ) & ~WS_VISIBLE ); // // This updates internal flag too - otherwise it will get out of sync // pPage->Show(false); } // // Some page should be selected: either this one or the first one if there is // still no selection // int nSelNew = -1; if (bSelect) nSelNew = nPage; else if ( m_nSelection == -1 ) nSelNew = 0; if (nSelNew != -1) SetSelection(nSelNew); InvalidateBestSize(); return true; } // end of wxNotebook::InsertPage
void wxIcon::CopyFromBitmap( const wxBitmap& rBmp ) { wxMask* pMask = rBmp.GetMask(); HBITMAP hBmp = NULLHANDLE; HBITMAP hBmpMask = NULLHANDLE; HBITMAP hOldBitmap = NULLHANDLE; ERRORID vError; wxString sError; LONG lHits; if (!pMask) { // // We must have a mask for an icon, so even if it's probably incorrect, // do create it (grey is the "standard" transparent colour) // pMask = new wxMask( rBmp ,*wxLIGHT_GREY ); } BITMAPINFOHEADER2 vHeader; SIZEL vSize = {0, 0}; DEVOPENSTRUC vDop = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L}; HDC hDCSrc = ::DevOpenDC(vHabmain, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&vDop, NULLHANDLE); HDC hDCDst = ::DevOpenDC(vHabmain, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&vDop, NULLHANDLE); HPS hPSSrc = ::GpiCreatePS(vHabmain, hDCSrc, &vSize, PU_PELS | GPIA_ASSOC); HPS hPSDst = ::GpiCreatePS(vHabmain, hDCDst, &vSize, PU_PELS | GPIA_ASSOC); POINTL vPoint[4] = { {0, 0}, {rBmp.GetWidth(), rBmp.GetHeight()}, {0, 0}, {rBmp.GetWidth(), rBmp.GetHeight()} }; POINTL vPointMask[4] = { {0, 0}, {rBmp.GetWidth(), rBmp.GetHeight() * 2}, {0, 0}, {rBmp.GetWidth(), rBmp.GetHeight()} }; POINTERINFO vIconInfo; memset(&vIconInfo, '\0', sizeof(POINTERINFO)); vIconInfo.fPointer = FALSE; // we want an icon, not a pointer memset(&vHeader, '\0', 16); vHeader.cbFix = 16; vHeader.cx = (ULONG)rBmp.GetWidth(); vHeader.cy = (ULONG)rBmp.GetHeight(); vHeader.cPlanes = 1L; vHeader.cBitCount = 24; hBmp = ::GpiCreateBitmap( hPSDst ,&vHeader ,0L ,NULL ,NULL ); if ((hOldBitmap = ::GpiSetBitmap(hPSDst, hBmp)) == HBM_ERROR) { vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); } if ((hOldBitmap = ::GpiSetBitmap(hPSSrc, (HBITMAP)rBmp.GetHBITMAP())) == HBM_ERROR) { vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); } if ((lHits = ::GpiBitBlt( hPSDst ,hPSSrc ,4L ,vPoint ,ROP_SRCCOPY ,BBO_IGNORE )) == GPI_ERROR) { vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); } if ((hOldBitmap = ::GpiSetBitmap(hPSDst, NULLHANDLE)) == HBM_ERROR) { vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); } if ((hOldBitmap = ::GpiSetBitmap(hPSSrc, NULLHANDLE)) == HBM_ERROR) { vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); } vIconInfo.hbmColor = hBmp; vHeader.cy = (ULONG)rBmp.GetHeight() * 2; hBmpMask = ::GpiCreateBitmap( hPSDst ,&vHeader ,0L ,NULL ,NULL ); if ((hOldBitmap = ::GpiSetBitmap(hPSDst, hBmpMask)) == HBM_ERROR) { vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); } if ((hOldBitmap = ::GpiSetBitmap(hPSSrc, (HBITMAP)pMask->GetMaskBitmap())) == HBM_ERROR) { vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); } if ((lHits = ::GpiBitBlt( hPSDst ,hPSSrc ,4L ,vPointMask ,ROP_SRCCOPY ,BBO_IGNORE )) == GPI_ERROR) { vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); } if ((hOldBitmap = ::GpiSetBitmap(hPSSrc, NULLHANDLE)) == HBM_ERROR) { vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); } if ((hOldBitmap = ::GpiSetBitmap(hPSDst, NULLHANDLE)) == HBM_ERROR) { vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); } vIconInfo.hbmPointer = hBmpMask; HICON hIcon = ::WinCreatePointerIndirect( HWND_DESKTOP ,&vIconInfo ); if (!hIcon) { wxLogLastError(wxT("WinCreatePointerIndirect")); vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); } else { SetHICON((WXHICON)hIcon); SetSize( rBmp.GetWidth() ,rBmp.GetHeight() ); } if (!rBmp.GetMask()) { // // We created the mask, now delete it // delete pMask; } ::GpiSetBitmap(hPSSrc, NULL); ::GpiSetBitmap(hPSDst, NULL); ::GpiDestroyPS(hPSSrc); ::GpiDestroyPS(hPSDst); ::DevCloseDC(hDCSrc); ::DevCloseDC(hDCDst); } // end of wxIcon::CopyFromBitmap
WXHMENU wxMenuBar::Create() { 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_menuBarFrame != NULL) hFrame = GetWinHwnd(m_menuBarFrame); else hFrame = HWND_DESKTOP; // // Create an empty menu and then fill it with insertions // if ((m_hMenu = ::WinCreateWindow( hFrame ,WC_MENU ,NULL ,MS_ACTIONBAR | WS_SYNCPAINT | WS_VISIBLE ,0L ,0L ,0L ,0L ,hFrame ,HWND_TOP ,FID_MENU ,NULL ,NULL )) == 0) { wxLogLastError(wxT("WinLoadMenu")); } else { size_t nCount = GetMenuCount(), i; wxMenuList::iterator it; #if defined(__INTEL_COMPILER) && 1 // VDM auto patch # pragma ivdep # pragma swp # pragma unroll #endif #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ for (i = 0, it = m_menus.begin(); i < nCount; i++, it++) { APIRET rc; ERRORID vError; wxString sError; HWND hSubMenu; // // Set the parent and owner of the submenues to be the menubar, not the desktop // hSubMenu = (*it)->m_vMenuData.hwndSubMenu; if (!::WinSetParent((*it)->m_vMenuData.hwndSubMenu, m_hMenu, FALSE)) { vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); wxLogError(wxT("Error setting parent for submenu. Error: %s\n"), sError.c_str()); return NULLHANDLE; } if (!::WinSetOwner((*it)->m_vMenuData.hwndSubMenu, m_hMenu)) { vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); wxLogError(wxT("Error setting parent for submenu. Error: %s\n"), sError.c_str()); return NULLHANDLE; } (*it)->m_vMenuData.iPosition = (SHORT)i; rc = (APIRET)::WinSendMsg(m_hMenu, MM_INSERTITEM, (MPARAM)&(*it)->m_vMenuData, (MPARAM)m_titles[i].wx_str()); if (rc == (APIRET)MIT_MEMERROR || rc == (APIRET)MIT_ERROR) { vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); wxLogError(wxT("Error inserting or appending a menuitem. Error: %s\n"), sError.c_str()); return NULLHANDLE; } } } return m_hMenu; } // end of wxMenuBar::Create
// // Append a new item or submenu to the menu // bool wxMenu::DoInsertOrAppend( wxMenuItem* pItem, size_t nPos ) { wxMenu* pSubmenu = pItem->GetSubMenu(); MENUITEM& rItem = (pSubmenu != NULL)?pSubmenu->m_vMenuData: pItem->m_vMenuData; ERRORID vError; wxString sError; #if wxUSE_ACCEL UpdateAccel(pItem); #endif // wxUSE_ACCEL // // If "Break" has just been called, insert a menu break before this item // (and don't forget to reset the flag) // if (m_bDoBreak) { rItem.afStyle |= MIS_BREAK; m_bDoBreak = false; } // // Id is the numeric id for normal menu items and HMENU for submenus as // required by ::MM_INSERTITEM message API // if (pSubmenu != NULL) { wxASSERT_MSG(pSubmenu->GetHMenu(), wxT("invalid submenu")); pSubmenu->SetParent(this); rItem.iPosition = 0; // submenus have a 0 position rItem.id = (USHORT)pSubmenu->GetHMenu(); rItem.afStyle |= MIS_SUBMENU | MIS_TEXT; } else { rItem.id = (USHORT)pItem->GetId(); } char *pData = NULL; #if wxUSE_OWNER_DRAWN if (pItem->IsOwnerDrawn()) { // // Want to get {Measure|Draw}Item messages? // item draws itself, passing pointer to data doesn't work in OS/2 // Will eventually need to set the image handle somewhere into vItem.hItem // rItem.afStyle |= MIS_OWNERDRAW; pData = NULL; rItem.hItem = (HBITMAP)pItem->GetBitmap().GetHBITMAP(); pItem->m_vMenuData.afStyle = rItem.afStyle; pItem->m_vMenuData.hItem = rItem.hItem; } else #endif if (pItem->IsSeparator()) { rItem.afStyle = MIS_SEPARATOR; } else { if (pItem->GetId() == idMenuTitle) { // Item is an unselectable title to be passed via pData rItem.afStyle = MIS_STATIC; } else { // // Menu is just a normal string (passed in data parameter) // rItem.afStyle |= MIS_TEXT; } pData = (char*) pItem->GetItemLabel().wx_str(); } if (nPos == (size_t)-1) { rItem.iPosition = MIT_END; } else { rItem.iPosition = (SHORT)nPos; } APIRET rc; rc = (APIRET)::WinSendMsg( GetHmenu() ,MM_INSERTITEM ,(MPARAM)&rItem ,(MPARAM)pData ); #if wxUSE_OWNER_DRAWN if (pItem->IsOwnerDrawn()) { MENUITEM vMenuItem; ::WinSendMsg( GetHmenu() ,MM_QUERYITEM ,MPFROM2SHORT( (USHORT)pItem->GetId() ,(USHORT)(FALSE) ) ,&vMenuItem ); } #endif if (rc == (APIRET)MIT_MEMERROR || rc == (APIRET)MIT_ERROR) { vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); wxLogError(wxT("Error inserting or appending a menuitem. Error: %s\n"), sError.c_str()); wxLogLastError(wxT("Insert or AppendMenu")); return false; } // // If we're already attached to the menubar, we must update it // if (IsAttached() && GetMenuBar()->IsAttached()) { GetMenuBar()->Refresh(); } return true; } // end of wxMenu::DoInsertOrAppend
bool wxApp::RegisterWindowClasses( HAB vHab ) { ERRORID vError = 0L; wxString sError; if (!::WinRegisterClass( vHab ,(PSZ)wxFrameClassName ,wxFrameWndProc ,CS_SIZEREDRAW | CS_SYNCPAINT ,sizeof(ULONG) )) { vError = ::WinGetLastError(vHab); sError = wxPMErrorToStr(vError); wxLogLastError(sError.c_str()); return false; } if (!::WinRegisterClass( vHab ,(PSZ)wxFrameClassNameNoRedraw ,wxWndProc ,0 ,sizeof(ULONG) )) { vError = ::WinGetLastError(vHab); sError = wxPMErrorToStr(vError); wxLogLastError(sError.c_str()); return false; } if (!::WinRegisterClass( vHab ,(PSZ)wxMDIFrameClassName ,wxWndProc ,CS_SIZEREDRAW | CS_MOVENOTIFY | CS_SYNCPAINT ,sizeof(ULONG) )) { vError = ::WinGetLastError(vHab); sError = wxPMErrorToStr(vError); wxLogLastError(sError.c_str()); return false; } if (!::WinRegisterClass( vHab ,(PSZ)wxMDIFrameClassNameNoRedraw ,wxWndProc ,0 ,sizeof(ULONG) )) { vError = ::WinGetLastError(vHab); sError = wxPMErrorToStr(vError); wxLogLastError(sError.c_str()); return false; } if (!::WinRegisterClass( vHab ,(PSZ)wxMDIChildFrameClassName ,wxWndProc ,CS_MOVENOTIFY | CS_SIZEREDRAW | CS_SYNCPAINT | CS_HITTEST ,sizeof(ULONG) )) { vError = ::WinGetLastError(vHab); sError = wxPMErrorToStr(vError); wxLogLastError(sError.c_str()); return false; } if (!::WinRegisterClass( vHab ,(PSZ)wxMDIChildFrameClassNameNoRedraw ,wxWndProc ,CS_HITTEST ,sizeof(ULONG) )) { vError = ::WinGetLastError(vHab); sError = wxPMErrorToStr(vError); wxLogLastError(sError.c_str()); return false; } if (!::WinRegisterClass( vHab ,(PSZ)wxPanelClassName ,wxWndProc ,CS_MOVENOTIFY | CS_SIZEREDRAW | CS_HITTEST | CS_SAVEBITS | CS_SYNCPAINT ,sizeof(ULONG) )) { vError = ::WinGetLastError(vHab); sError = wxPMErrorToStr(vError); wxLogLastError(sError.c_str()); return false; } if (!::WinRegisterClass( vHab ,(PSZ)wxCanvasClassName ,wxWndProc ,CS_SIZEREDRAW | CS_HITTEST | CS_SYNCPAINT ,sizeof(ULONG) )) { vError = ::WinGetLastError(vHab); sError = wxPMErrorToStr(vError); wxLogLastError(sError.c_str()); return false; } if (!::WinRegisterClass( vHab ,(PSZ)wxCanvasClassNameNR ,wxWndProc ,CS_HITTEST | CS_SYNCPAINT ,sizeof(ULONG) )) { vError = ::WinGetLastError(vHab); sError = wxPMErrorToStr(vError); wxLogLastError(sError.c_str()); return false; } return true; } // end of wxApp::RegisterWindowClasses
bool wxStaticBitmap::Create( wxWindow* pParent, wxWindowID nId, const wxGDIImage& rBitmap, const wxPoint& rPos, const wxSize& WXUNUSED(rSize), long lStyle, const wxString& rName ) { ERRORID vError; wxString sError; Init(); SetName(rName); if (pParent) pParent->AddChild(this); if (nId == -1) m_windowId = (int)NewControlId(); else m_windowId = nId; m_windowStyle = lStyle; int nX= rPos.x; int nY = rPos.y; char zId[16]; m_windowStyle = lStyle; m_bIsIcon = rBitmap.IsKindOf(CLASSINFO(wxIcon)); // // For now we only support an ICON // int nWinstyle = SS_ICON; m_hWnd = (WXHWND)::WinCreateWindow( pParent->GetHWND() ,(PSZ)wxCanvasClassName ,zId ,nWinstyle | WS_VISIBLE ,0,0,0,0 ,pParent->GetHWND() ,HWND_TOP ,m_windowId ,NULL ,NULL ); if (!m_hWnd) { vError = ::WinGetLastError(wxGetInstance()); sError = wxPMErrorToStr(vError); return false; } wxCHECK_MSG( m_hWnd, false, wxT("Failed to create static bitmap") ); m_pImage = ConvertImage(rBitmap); ::WinSendMsg( m_hWnd, SM_SETHANDLE, MPFROMHWND(rBitmap.GetHandle()), (MPARAM)0); // Subclass again for purposes of dialog editing mode SubclassWin(m_hWnd); SetSize(nX, nY, m_pImage->GetWidth(), m_pImage->GetHeight()); return true; } // end of wxStaticBitmap::Create