bool wxStaticBox::Create( wxWindow* pParent, wxWindowID vId, const wxString& rsLabel, const wxPoint& rPos, const wxSize& rSize, long lStyle, const wxString& rsName ) { if(!CreateControl( pParent ,vId ,rPos ,rSize ,lStyle ,wxDefaultValidator ,rsName )) { return false; } wxPoint vPos(0,0); wxSize vSize(0,0); if (!OS2CreateControl( wxT("STATIC") ,SS_GROUPBOX ,vPos ,vSize ,rsLabel )) { return false; } // // To be transparent we should have the same colour as the parent as well // SetBackgroundColour(GetParent()->GetBackgroundColour()); LONG lColor = (LONG)wxBLACK->GetPixel(); ::WinSetPresParam( m_hWnd ,PP_FOREGROUNDCOLOR ,sizeof(LONG) ,(PVOID)&lColor ); lColor = (LONG)m_backgroundColour.GetPixel(); ::WinSetPresParam( m_hWnd ,PP_BACKGROUNDCOLOR ,sizeof(LONG) ,(PVOID)&lColor ); SetSize( rPos.x ,rPos.y ,rSize.x ,rSize.y ); return true; } // end of wxStaticBox::Create
bool wxChoice::Create( wxWindow* pParent , wxWindowID vId , const wxPoint& rPos , const wxSize& rSize , int n , const wxString asChoices[] , long lStyle , const wxValidator& rValidator , const wxString& rsName ) { long lSstyle; if (!CreateControl( pParent ,vId ,rPos ,rSize ,lStyle ,rValidator ,rsName )) return false; lSstyle = CBS_DROPDOWNLIST | WS_TABSTOP | WS_VISIBLE; if (lStyle & wxCLIP_SIBLINGS ) lSstyle |= WS_CLIPSIBLINGS; wxASSERT_MSG( !(lStyle & wxCB_DROPDOWN) && !(lStyle & wxCB_READONLY) && !(lStyle & wxCB_SIMPLE), wxT("this style flag is ignored by wxChoice, you " "probably want to use a wxComboBox") ); if (!OS2CreateControl( wxT("COMBOBOX") ,lSstyle )) return false; // // A choice/combobox normally has a white background (or other, depending // on global settings) rather than inheriting the parent's background colour. // SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); for (int i = 0; i < n; i++) { Append(asChoices[i]); } SetSize( rPos.x ,rPos.y ,rSize.x ,rSize.y ); return true; } // end of wxChoice::Create
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
// Single check box item bool wxToggleButton::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { if ( !CreateControl(parent, id, pos, size, style, validator, name) ) return false; if ( !OS2CreateControl(wxT("BUTTON"), label, pos, size, 0) ) return false; return true; }
bool wxControl::OS2CreateControl( const wxChar* zClassname, const wxString& rsLabel, const wxPoint& rPos, const wxSize& rSize, long lStyle ) { WXDWORD dwExstyle; WXDWORD dwStyle = OS2GetStyle( lStyle, &dwExstyle ); return OS2CreateControl( zClassname ,dwStyle ,rPos ,rSize ,rsLabel ,dwExstyle ); } // end of wxControl::OS2CreateControl
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 wxStaticLine::Create( wxWindow* pParent , wxWindowID vId , const wxPoint& rPos , const wxSize& rSize , long lStyle , const wxString& rsName ) { wxSize vSize = AdjustSize(rSize); if ( !CreateControl( pParent ,vId ,rPos ,vSize ,lStyle ,wxDefaultValidator ,rsName )) return FALSE; if (!OS2CreateControl( wxT("STATIC") ,SS_FGNDFRAME ,rPos ,rSize ,rsName )) return FALSE; wxColour vColour; vColour.Set(wxString(wxT("GREY"))); LONG lColor = (LONG)vColour.GetPixel(); ::WinSetPresParam( m_hWnd ,PP_FOREGROUNDCOLOR ,sizeof(LONG) ,(PVOID)&lColor ); return TRUE; } // end of wxStaticLine::Create
// // Create() function // bool wxNotebook::Create( wxWindow* pParent, wxWindowID vId, const wxPoint& rPos, const wxSize& rSize, long lStyle, const wxString& rsName ) { if ( (lStyle & wxBK_ALIGN_MASK) == wxBK_DEFAULT ) lStyle |= wxBK_TOP; // // Base init // if (!CreateControl( pParent ,vId ,rPos ,rSize ,lStyle ,wxDefaultValidator ,rsName )) return false; // // Notebook, so explicitly specify 0 as last parameter // if (!OS2CreateControl( wxT("NOTEBOOK") ,wxEmptyString ,rPos ,rSize ,lStyle | wxTAB_TRAVERSAL )) return false; SetBackgroundColour(wxColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE))); return true; } // end of wxNotebook::Create
bool wxComboBox::Create( wxWindow* pParent , wxWindowID vId , const wxString& rsValue , const wxPoint& rPos , const wxSize& rSize , int n , const wxString asChoices[] , long lStyle , const wxValidator& rValidator , const wxString& rsName ) { m_isShown = false; if (!CreateControl( pParent ,vId ,rPos ,rSize ,lStyle ,rValidator ,rsName )) return false; // // Get the right style // long lSstyle = 0L; lSstyle = WS_TABSTOP | WS_VISIBLE; if (lStyle & wxCLIP_SIBLINGS ) lSstyle |= WS_CLIPSIBLINGS; if (lStyle & wxCB_READONLY) lSstyle |= CBS_DROPDOWNLIST; else if (lStyle & wxCB_SIMPLE) lSstyle |= CBS_SIMPLE; // A list (shown always) and edit control else lSstyle |= CBS_DROPDOWN; if (!OS2CreateControl( _T("COMBOBOX") ,lSstyle )) return false; // // A choice/combobox normally has a white background (or other, depending // on global settings) rather than inheriting the parent's background colour. // SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); SetFont(*wxSMALL_FONT); int i; for (i = 0; i < n; i++) { Append(asChoices[i]); } SetSize( rPos.x ,rPos.y ,rSize.x ,rSize.y ); if (!rsValue.empty()) { SetValue(rsValue); } gfnWndprocEdit = (WXFARPROC)::WinSubclassWindow( (HWND)GetHwnd() ,(PFNWP)wxComboEditWndProc ); ::WinSetWindowULong(GetHwnd(), QWL_USER, (ULONG)this); Show(true); return true; } // end of wxComboBox::Create
bool wxChoice::Create( wxWindow* pParent , wxWindowID vId , const wxPoint& rPos , const wxSize& rSize , int n , const wxString asChoices[] , long lStyle , const wxValidator& rValidator , const wxString& rsName ) { long lSstyle; if (!CreateControl( pParent ,vId ,rPos ,rSize ,lStyle ,rValidator ,rsName )) return false; lSstyle = CBS_DROPDOWNLIST | WS_TABSTOP | WS_VISIBLE; // clipping siblings does not yet work // if (lStyle & wxCLIP_SIBLINGS ) // lSstyle |= WS_CLIPSIBLINGS; wxASSERT_MSG( !(lStyle & wxCB_DROPDOWN) && !(lStyle & wxCB_READONLY) && !(lStyle & wxCB_SIMPLE), wxT("this style flag is ignored by wxChoice, you " "probably want to use a wxComboBox") ); if (!OS2CreateControl( wxT("COMBOBOX") ,lSstyle )) return false; // // A choice/combobox normally has a white background (or other, depending // on global settings) rather than inheriting the parent's background colour. // SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); // initialize the controls contents for (int i = 0; i < n; i++) { Append(asChoices[i]); } SetSize( rPos.x ,rPos.y ,rSize.x ,rSize.y ); // Set height to use with sizers i.e. without the dropdown listbox wxFont vFont = GetFont(); int nEditHeight; wxGetCharSize( GetHWND(), NULL, &nEditHeight, &vFont ); nEditHeight = EDIT_HEIGHT_FROM_CHAR_HEIGHT(nEditHeight); SetInitialSize(wxSize(-1,nEditHeight+4)); // +2x2 for the border return true; } // end of wxChoice::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
bool wxComboBox::Create( wxWindow* pParent , wxWindowID vId , const wxString& rsValue , const wxPoint& rPos , const wxSize& rSize , int n , const wxString asChoices[] , long lStyle , const wxValidator& rValidator , const wxString& rsName ) { m_isShown = false; if (!CreateControl( pParent ,vId ,rPos ,rSize ,lStyle ,rValidator ,rsName )) return false; // // Get the right style // long lSstyle = 0L; lSstyle = WS_TABSTOP | WS_VISIBLE; // clipping siblings does not yet work // if (lStyle & wxCLIP_SIBLINGS ) // lSstyle |= WS_CLIPSIBLINGS; if (lStyle & wxCB_READONLY) lSstyle |= CBS_DROPDOWNLIST; else if (lStyle & wxCB_SIMPLE) lSstyle |= CBS_SIMPLE; // A list (shown always) and edit control else lSstyle |= CBS_DROPDOWN; if (!OS2CreateControl( wxT("COMBOBOX") ,lSstyle )) return false; // // A choice/combobox normally has a white background (or other, depending // on global settings) rather than inheriting the parent's background colour. // SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); for (int i = 0; i < n; i++) { Append(asChoices[i]); } SetSize( rPos.x ,rPos.y ,rSize.x ,rSize.y ); // Set height to use with sizers i.e. without the dropdown listbox wxFont vFont = GetFont(); int nEditHeight; wxGetCharSize( GetHWND(), NULL, &nEditHeight, &vFont ); nEditHeight = EDIT_HEIGHT_FROM_CHAR_HEIGHT(nEditHeight); SetInitialSize(wxSize(-1,nEditHeight+4)); // +2x2 for the border if (!rsValue.empty()) { SetValue(rsValue); } gfnWndprocEdit = (WXFARPROC)::WinSubclassWindow( (HWND)GetHwnd() ,(PFNWP)wxComboEditWndProc ); ::WinSetWindowULong(GetHwnd(), QWL_USER, (ULONG)this); Show(true); return true; } // end of wxComboBox::Create