bool wxRadioButton::Create( wxWindow* pParent, wxWindowID vId, const wxString& rsLabel, const wxPoint& rPos, const wxSize& rSize, long lStyle, const wxValidator& rValidator, const wxString& rsName ) { if ( !CreateControl( pParent ,vId ,rPos ,rSize ,lStyle ,rValidator ,rsName)) return false; long lSstyle = WS_TABSTOP; if (HasFlag(wxRB_GROUP)) lSstyle |= WS_GROUP; // // wxRB_SINGLE is a temporary workaround for the following problem: if you // have 2 radiobuttons in the same group but which are not consecutive in // the dialog, Windows can enter an infinite loop! The simplest way to // reproduce it is to create radio button, then a panel and then another // radio button: then checking the last button hangs the app. // // Ideally, we'd detect (and avoid) such situation automatically but for // now, as I don't know how to do it, just allow the user to create // BS_RADIOBUTTON buttons for such situations. // lSstyle |= HasFlag(wxRB_SINGLE) ? BS_RADIOBUTTON : BS_AUTORADIOBUTTON; if (HasFlag(wxCLIP_SIBLINGS)) lSstyle |= WS_CLIPSIBLINGS; if (!OS2CreateControl( wxT("BUTTON") ,lSstyle ,rPos ,rSize ,rsLabel ,0 )) return false; wxAssociateWinWithHandle(m_hWnd, this); if (HasFlag(wxRB_GROUP)) SetValue(true); SetFont(*wxSMALL_FONT); SetSize( rPos.x, rPos.y, rSize.x, rSize.y ); return true; } // end of wxRadioButton::Create
bool wxCheckBox::Create( wxWindow* pParent , wxWindowID vId , const wxString& rsLabel , const wxPoint& rPos , const wxSize& rSize , long lStyle , const wxValidator& rValidator , const wxString& rsName ) { LONG lColor; bool bOk; if (!CreateControl( pParent ,vId ,rPos ,rSize ,lStyle ,rValidator ,rsName )) return FALSE; long osStyle = BS_AUTOCHECKBOX | WS_TABSTOP | WS_VISIBLE; bOk = OS2CreateControl( wxT("BUTTON") ,osStyle ,rPos ,rSize ,rsLabel ,0 ); m_backgroundColour = pParent->GetBackgroundColour(); lColor = (LONG)m_backgroundColour.GetPixel(); ::WinSetPresParam( m_hWnd ,PP_BACKGROUNDCOLOR ,sizeof(LONG) ,(PVOID)&lColor ); wxAssociateWinWithHandle(m_hWnd, this); return bOk; } // end of wxCheckBox::Create
bool wxSpinButton::Create( wxWindow* pParent , wxWindowID vId , const wxPoint& rPos , const wxSize& rSize , long lStyle , const wxString& rsName ) { int nX = rPos.x; int nY = rPos.y; int nWidth = rSize.x; int nHeight = rSize.y; SWP vSwp; m_min = 0; m_max = 100; if (vId == -1) m_windowId = NewControlId(); else m_windowId = vId; if (pParent) { m_backgroundColour = pParent->GetBackgroundColour(); m_foregroundColour = pParent->GetForegroundColour(); } SetName(rsName); SetParent(pParent); m_windowStyle = lStyle; // // Get the right size for the control // if (nWidth <= 0 || nHeight <= 0 ) { wxSize vSize = DoGetBestSize(); if (nWidth <= 0 ) nWidth = vSize.x; if (nHeight <= 0 ) nHeight = vSize.y; } if (nX < 0 ) nX = 0; if (nY < 0 ) nY = 0; long lSstyle = 0L; lSstyle = WS_VISIBLE | WS_TABSTOP | SPBS_MASTER | // We use only single field spin buttons SPBS_NUMERICONLY; // We default to numeric data if (m_windowStyle & wxCLIP_SIBLINGS ) lSstyle |= WS_CLIPSIBLINGS; m_hWnd = (WXHWND)::WinCreateWindow( GetWinHwnd(pParent) ,WC_SPINBUTTON ,(PSZ)NULL ,lSstyle ,0L, 0L, 0L, 0L ,GetWinHwnd(pParent) ,HWND_TOP ,(HMENU)vId ,NULL ,NULL ); if (m_hWnd == 0) { return FALSE; } SetRange(m_min, m_max); if(pParent) pParent->AddChild((wxSpinButton *)this); ::WinQueryWindowPos(m_hWnd, &vSwp); SetXComp(vSwp.x); SetYComp(vSwp.y-5); // compensate for the associated TextControl border SetFont(*wxSMALL_FONT); // // For OS/2 we want to hide the text portion so we can substitute an // independent text ctrl in its place. // Therefore we must override any user given width with our best guess. // SetSize( nX - GetXComp() ,nY - GetYComp() ,nWidth ,nHeight ); wxAssociateWinWithHandle( m_hWnd ,(wxWindowOS2*)this ); #if 0 // FIXME: // Apparently, this does not work, as it crashes in setvalue/setrange calls // What's it supposed to do anyway? ::WinSetWindowULong(GetHwnd(), QWL_USER, (LONG)this); fnWndProcSpinCtrl = (WXFARPROC)::WinSubclassWindow(m_hWnd, (PFNWP)wxSpinCtrlWndProc); #endif return TRUE; } // end of wxSpinButton::Create
bool wxSpinCtrl::Create( wxWindow* pParent, wxWindowID vId, const wxString& WXUNUSED(rsValue), const wxPoint& rPos, const wxSize& rSize, long lStyle, int nMin, int nMax, int nInitial, const wxString& rsName ) { if (vId == wxID_ANY) m_windowId = NewControlId(); else m_windowId = vId; m_backgroundColour = pParent->GetBackgroundColour(); m_foregroundColour = pParent->GetForegroundColour(); SetName(rsName); SetParent(pParent); m_windowStyle = lStyle; int lSstyle = 0L; lSstyle = WS_VISIBLE | WS_TABSTOP | SPBS_MASTER | // We use only single field spin buttons SPBS_NUMERICONLY; // We default to numeric data if (m_windowStyle & wxCLIP_SIBLINGS ) lSstyle |= WS_CLIPSIBLINGS; SPBCDATA vCtrlData; vCtrlData.cbSize = sizeof(SPBCDATA); vCtrlData.ulTextLimit = 10L; vCtrlData.lLowerLimit = 0L; vCtrlData.lUpperLimit = 100L; vCtrlData.idMasterSpb = vId; vCtrlData.pHWXCtlData = NULL; m_hWnd = (WXHWND)::WinCreateWindow( GetWinHwnd(pParent) ,WC_SPINBUTTON ,(PSZ)NULL ,lSstyle ,0L, 0L, 0L, 0L ,GetWinHwnd(pParent) ,HWND_TOP ,(HMENU)vId ,(PVOID)&vCtrlData ,NULL ); if (m_hWnd == 0) { return false; } m_hWndBuddy = m_hWnd; // One in the same for OS/2 if(pParent) pParent->AddChild((wxSpinButton *)this); SetFont(*wxSMALL_FONT); SetXComp(0); SetYComp(0); SetSize( rPos.x, rPos.y, rSize.x, rSize.y ); SetRange(nMin, nMax); SetValue(nInitial); // // For OS/2 we'll just set our handle into our long data // wxAssociateWinWithHandle( m_hWnd ,(wxWindowOS2*)this ); ::WinSetWindowULong(GetHwnd(), QWL_USER, (LONG)this); fnWndProcSpinCtrl = (WXFARPROC)::WinSubclassWindow(m_hWnd, (PFNWP)wxSpinCtrlWndProc); m_svAllSpins.Add(this); return true; } // end of wxSpinCtrl::Create
bool wxMDIChildFrame::Create(wxMDIParentFrame *parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { SetName(name); if ( id != wxID_ANY ) m_windowId = id; else m_windowId = (int)NewControlId(); if ( parent ) { parent->AddChild(this); } int x = pos.x; int y = pos.y; int width = size.x; int height = size.y; MDICREATESTRUCT mcs; mcs.szClass = style & wxFULL_REPAINT_ON_RESIZE ? wxMDIChildFrameClassName : wxMDIChildFrameClassNameNoRedraw; mcs.szTitle = title; mcs.hOwner = wxGetInstance(); if (x != wxDefaultCoord) mcs.x = x; else mcs.x = CW_USEDEFAULT; if (y != wxDefaultCoord) mcs.y = y; else mcs.y = CW_USEDEFAULT; if (width != wxDefaultCoord) mcs.cx = width; else mcs.cx = CW_USEDEFAULT; if (height != wxDefaultCoord) mcs.cy = height; else mcs.cy = CW_USEDEFAULT; DWORD msflags = WS_OVERLAPPED | WS_CLIPCHILDREN; if (style & wxMINIMIZE_BOX) msflags |= WS_MINIMIZEBOX; if (style & wxMAXIMIZE_BOX) msflags |= WS_MAXIMIZEBOX; if (style & wxTHICK_FRAME) msflags |= WS_THICKFRAME; if (style & wxSYSTEM_MENU) msflags |= WS_SYSMENU; if ((style & wxMINIMIZE) || (style & wxICONIZE)) msflags |= WS_MINIMIZE; if (style & wxMAXIMIZE) msflags |= WS_MAXIMIZE; if (style & wxCAPTION) msflags |= WS_CAPTION; mcs.style = msflags; mcs.lParam = 0; wxWindowCreationHook hook(this); m_hWnd = (WXHWND)::SendMessage(GetWinHwnd(parent->GetClientWindow()), WM_MDICREATE, 0, (LONG)(LPSTR)&mcs); wxAssociateWinWithHandle((HWND) GetHWND(), this); return true; }
bool wxGauge::Create( wxWindowOS2* pParent, wxWindowID vId, int nRange, const wxPoint& rPos, const wxSize& rSize, long lStyle, const wxValidator& rValidator, const wxString& rsName ) { int nX = rPos.x; int nY = rPos.y; int nWidth = rSize.x; int nHeight = rSize.y; long lMsStyle = 0L; SWP vSwp; SetName(rsName); #if wxUSE_VALIDATORS SetValidator(rValidator); #endif if (pParent) pParent->AddChild(this); m_backgroundColour.Set(wxString(wxT("LIGHT GREY"))); m_foregroundColour.Set(wxString(wxT("NAVY"))); m_nRangeMax = nRange; m_nGaugePos = 0; m_windowStyle = lStyle; if (vId == wxID_ANY) m_windowId = (int)NewControlId(); else m_windowId = vId; if (m_windowStyle & wxCLIP_SIBLINGS ) lMsStyle |= WS_CLIPSIBLINGS; // // OS/2 will use an edit control for this, since there is not a native gauge // Other choices include using an armless slider but they are more difficult // to control and manipulate // lMsStyle = WS_VISIBLE | ES_MARGIN | ES_LEFT | ES_READONLY; if (m_windowStyle & wxCLIP_SIBLINGS) lMsStyle |= WS_CLIPSIBLINGS; m_hWnd = (WXHWND)::WinCreateWindow( (HWND)GetHwndOf(pParent) // Parent window handle ,WC_ENTRYFIELD // Window class ,(PSZ)NULL // Initial Text ,(ULONG)lMsStyle // Style flags ,0L, 0L, 0L, 0L // Origin -- 0 size ,(HWND)GetHwndOf(pParent) // owner window handle (same as parent ,HWND_TOP // initial z position ,(HMENU)m_windowId // Window identifier ,NULL // Slider control data ,NULL // no Presentation parameters ); wxAssociateWinWithHandle( m_hWnd ,(wxWindowOS2*)this ); ::WinSetWindowULong(GetHwnd(), QWL_USER, (LONG)this); fnWndProcGauge = (WXFARPROC)::WinSubclassWindow(m_hWnd, (PFNWP)wxGaugeWndProc); ::WinQueryWindowPos(m_hWnd, &vSwp); SetXComp(vSwp.x); SetYComp(vSwp.y); wxFont* pTextFont = new wxFont( 10 ,wxMODERN ,wxNORMAL ,wxNORMAL ); SetFont(*pTextFont); if (nWidth == -1L) nWidth = 50L; if (nHeight == -1L) nHeight = 28L; SetSize( nX ,nY ,nWidth ,nHeight ); m_nWidth = nWidth; // Save for GetBestSize m_nHeight = nHeight; ::WinShowWindow((HWND)GetHWND(), TRUE); delete pTextFont; return true; } // end of wxGauge::Create
bool wxRadioBox::Create( wxWindow* pParent, wxWindowID vId, const wxString& rsTitle, const wxPoint& rPos, const wxSize& rSize, int nNum, const wxString asChoices[], int nMajorDim, long lStyle, const wxValidator& rVal, const wxString& rsName ) { wxColour vColour(*wxBLACK); LONG lColor; HWND hWndParent = GetHwndOf(pParent); m_backgroundColour = pParent->GetBackgroundColour(); m_nSelectedButton = -1; m_nNoItems = 0; // // Common initialization // if (!CreateControl( pParent ,vId ,rPos ,rSize ,lStyle ,rVal ,rsName )) return false; if (!OS2CreateControl( wxT("STATIC") ,SS_GROUPBOX ,rPos ,rSize ,rsTitle )) return false; wxAssociateWinWithHandle(m_hWnd, this); // // Now we can set m_nNoItems and let SetMajorDim set m_numCols/m_numRows // m_nNoItems = (unsigned int)nNum; SetMajorDim(nMajorDim == 0 ? nNum : nMajorDim, lStyle); m_ahRadioButtons = new WXHWND[nNum]; m_pnRadioWidth = new int[nNum]; m_pnRadioHeight = new int[nNum]; for (int i = 0; i < nNum; i++) { m_pnRadioWidth[i] = m_pnRadioHeight[i] = -1; long lStyleBtn = BS_AUTORADIOBUTTON | WS_VISIBLE; int nNewId = NewControlId(); if (i == 0) lStyleBtn |= WS_GROUP | WS_TABSTOP; wxString sLabel = ::wxPMTextToLabel(asChoices[i]); HWND hWndBtn = (WXHWND)::WinCreateWindow ( hWndParent, WC_BUTTON, sLabel.c_str(), lStyleBtn, 0, 0, 0, 0, hWndParent, HWND_BOTTOM, (HMENU)nNewId, NULL, NULL ); if (!hWndBtn) { return false; } lColor = (LONG)vColour.GetPixel(); ::WinSetPresParam( hWndBtn ,PP_FOREGROUNDCOLOR ,sizeof(LONG) ,(PVOID)&lColor ); lColor = (LONG)m_backgroundColour.GetPixel(); ::WinSetPresParam( hWndBtn ,PP_BACKGROUNDCOLOR ,sizeof(LONG) ,(PVOID)&lColor ); m_ahRadioButtons[i] = (WXHWND)hWndBtn; SubclassRadioButton((WXHWND)hWndBtn); wxAssociateWinWithHandle(hWndBtn, this); wxOS2SetFont( hWndBtn ,*wxSMALL_FONT ); ::WinSetWindowULong(hWndBtn, QWL_USER, (ULONG)this); m_aSubControls.Add(nNewId); } // // Create a dummy control to end the group. // (void)::WinCreateWindow ( hWndParent, WC_BUTTON, "", WS_GROUP, 0, 0, 0, 0, hWndParent, HWND_TOP, (HMENU)NewControlId(), NULL, NULL ); fnWndProcRadioBox = (WXFARPROC)::WinSubclassWindow( GetHwnd() ,(PFNWP)wxRadioBoxWndProc ); ::WinSetWindowULong(GetHwnd(), QWL_USER, (ULONG)this); lColor = (LONG)vColour.GetPixel(); ::WinSetPresParam( m_hWnd ,PP_FOREGROUNDCOLOR ,sizeof(LONG) ,(PVOID)&lColor ); lColor = (LONG)m_backgroundColour.GetPixel(); ::WinSetPresParam( m_hWnd ,PP_BACKGROUNDCOLOR ,sizeof(LONG) ,(PVOID)&lColor ); SetXComp(0); SetYComp(0); SetSelection(0); SetSize( rPos.x ,rPos.y ,rSize.x ,rSize.y ); return true; } // end of wxRadioBox::Create