void CCreateBoundingWindow::OnCreate(HWND parent, int xPos, int yPos, int width, int height) { CSubWindow::OnCreate(parent, xPos, yPos, width, height); HINSTANCE hInst = GetModuleHandle(NULL); mBoundingCategoryComboBox = CreateControl(TEXT("combobox"), NULL, WS_CHILDWINDOW | WS_VISIBLE | LBS_STANDARD, 10, 10, 100, 400, IDC_BOUNDING_CATEGORY_COMBO, NULL); mCreateButton = CreateControl(TEXT("button"), TEXT("Create"), WS_CHILD | WS_VISIBLE, 120, 10, 60, 24, (IDC_CREATE_BOUNDING_BTN), NULL); mDeleteButton = CreateControl(TEXT("button"), TEXT("Delete"), WS_CHILD | WS_VISIBLE, 190, 10, 60, 24, (IDC_DELETE_BOUNDING_BTN), NULL); mBoundingsList = CreateControl(TEXT("listbox"), NULL, WS_CHILD | WS_VISIBLE | LBS_NOTIFY | WS_VSCROLL | WS_BORDER, 10, 40, 220, 100, IDC_BOUNDINGS_LISTBOX, NULL); mUpdateButton = CreateControl(TEXT("button"), TEXT("Update"), WS_CHILD | WS_VISIBLE, 10, 150, 100, 24, IDC_BOUNDING_UPDATE_BUTTON, NULL); const int labelWidth = 60; const int textFieldWidth = 90; const int intervalBetweenTextFields = 2; HWND label1 = CreateLabel(IDC_CREATE_BOUNDING_LABELS, TEXT("Center:"), 0, 180, labelWidth); HWND label2 = CreateLabel(IDC_CREATE_BOUNDING_LABELS + 1, TEXT("Rotation:"), 0, 210, labelWidth); HWND label3 = CreateLabel(IDC_CREATE_BOUNDING_LABELS + 2, TEXT("Mass:"), 0, 240, labelWidth); HWND label4 = CreateLabel(IDC_CREATE_BOUNDING_LABELS + 3, TEXT("Friction:"), 180, 240, labelWidth); for (u32 i = 0; i < 3; i++) { mCenterTextFields[i] = CreateControl(TEXT("edit"), NULL, WS_CHILDWINDOW | WS_VISIBLE | WS_BORDER, labelWidth + i * (textFieldWidth + intervalBetweenTextFields), 180, textFieldWidth, 20, (IDC_BOUNDING_CENTER_TEXTFIELD + i), NULL); mRotTextFields[i] = CreateControl(TEXT("edit"), NULL, WS_CHILDWINDOW | WS_VISIBLE | WS_BORDER, labelWidth + i * (textFieldWidth + intervalBetweenTextFields), 210, textFieldWidth, 20, (IDC_BOUNDING_ROTATION_TEXTFIELD + i), NULL); } mMassTextField = CreateControl(TEXT("edit"), NULL, WS_CHILDWINDOW | WS_VISIBLE | WS_BORDER, labelWidth, 240, textFieldWidth, 20, (IDC_BOUNDING_MASS_TEXTFIELD), NULL); mFrictionTextField = CreateControl(TEXT("edit"), NULL, WS_CHILDWINDOW | WS_VISIBLE | WS_BORDER, labelWidth + 180, 240, textFieldWidth, 20, (IDC_BOUNDING_FRICTION_TEXTFIELD), NULL); mBoundingWindows[BOX_BOUNDING] = new CBoxBoundingWindow(); mBoundingWindows[SPHERE_BOUNDING] = nullptr; mBoundingWindows[CYLINDER_BOUNDING] = new CCylinderBoundingWindow(); for (u32 i = 0; i < BOUNDING_CATEGORY_COUNT; i++) { if (mBoundingWindows[i]) { mBoundingWindows[i]->OnCreate(mParentHwnd, 0, 280, 300, 300); } } }
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
// for backward compatibility (2.29 had CreateItem) void __declspec(dllexport) CreateItem(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra) { CreateControl(hwndParent, string_size, variables, stacktop, extra); }
bool wxChoice::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, int n, const wxString choices[], long style, const wxValidator& validator, const wxString& name) { if ( !CreateControl(parent, id, pos, size, style, validator, name) ) return false; Widget parentWidget = (Widget) parent->GetClientWidget(); m_formWidget = (WXWidget) XtVaCreateManagedWidget(name.c_str(), xmRowColumnWidgetClass, parentWidget, XmNmarginHeight, 0, XmNmarginWidth, 0, XmNpacking, XmPACK_TIGHT, XmNorientation, XmHORIZONTAL, XmNresizeWidth, False, XmNresizeHeight, False, NULL); XtVaSetValues ((Widget) m_formWidget, XmNspacing, 0, NULL); /* * Create the popup menu */ m_menuWidget = (WXWidget) XmCreatePulldownMenu ((Widget) m_formWidget, wxMOTIF_STR("choiceMenu"), NULL, 0); if (n > 0) { int i; for (i = 0; i < n; i++) Append (choices[i]); } /* * Create button */ Arg args[10]; Cardinal argcnt = 0; XtSetArg (args[argcnt], XmNsubMenuId, (Widget) m_menuWidget); ++argcnt; XtSetArg (args[argcnt], XmNmarginWidth, 0); ++argcnt; XtSetArg (args[argcnt], XmNmarginHeight, 0); ++argcnt; XtSetArg (args[argcnt], XmNpacking, XmPACK_TIGHT); ++argcnt; m_buttonWidget = (WXWidget) XmCreateOptionMenu ((Widget) m_formWidget, wxMOTIF_STR("choiceButton"), args, argcnt); m_mainWidget = m_buttonWidget; XtManageChild ((Widget) m_buttonWidget); // New code from Roland Haenel ([email protected]) // Some time ago, I reported a problem with wxChoice-items under // Linux and Motif 2.0 (they caused sporadic GPFs). Now it seems // that I have found the code responsible for this behaviour. #if XmVersion >= 1002 #if XmVersion < 2000 // JACS, 24/1/99: this seems to cause a malloc crash later on, e.g. // in controls sample. // // Widget optionLabel = XmOptionLabelGadget ((Widget) m_buttonWidget); // XtUnmanageChild (optionLabel); #endif #endif wxSize bestSize = GetBestSize(); if( size.x > 0 ) bestSize.x = size.x; if( size.y > 0 ) bestSize.y = size.y; XtVaSetValues((Widget) m_formWidget, XmNresizePolicy, XmRESIZE_NONE, NULL); ChangeFont(false); ChangeBackgroundColour(); AttachWidget (parent, m_buttonWidget, m_formWidget, pos.x, pos.y, bestSize.x, bestSize.y); return true; }
bool wxChoice::CreateAndInit(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, int n, const wxString choices[], long style, const wxValidator& validator, const wxString& name) { if ( !(style & wxSP_VERTICAL) ) style |= wxSP_HORIZONTAL; if ( (style & wxBORDER_MASK) == wxBORDER_DEFAULT ) style |= wxBORDER_SIMPLE; style |= wxSP_ARROW_KEYS; SetWindowStyle(style); WXDWORD exStyle = 0; WXDWORD msStyle = MSWGetStyle(GetWindowStyle(), & exStyle) ; wxSize sizeText(size), sizeBtn(size); sizeBtn.x = GetBestSpinnerSize(IsVertical(style)).x; if ( sizeText.x == wxDefaultCoord ) { // DEFAULT_ITEM_WIDTH is the default width for the text control sizeText.x = DEFAULT_ITEM_WIDTH + MARGIN_BETWEEN + sizeBtn.x; } sizeText.x -= sizeBtn.x + MARGIN_BETWEEN; if ( sizeText.x <= 0 ) { wxLogDebug(_T("not enough space for wxSpinCtrl!")); } wxPoint posBtn(pos); posBtn.x += sizeText.x + MARGIN_BETWEEN; // we must create the list control before the spin button for the purpose // of the dialog navigation: if there is a static text just before the spin // control, activating it by Alt-letter should give focus to the text // control, not the spin and the dialog navigation code will give focus to // the next control (at Windows level), not the one after it // create the text window m_hwndBuddy = (WXHWND)::CreateWindowEx ( exStyle, // sunken border _T("LISTBOX"), // window class NULL, // no window title msStyle, // style (will be shown later) pos.x, pos.y, // position 0, 0, // size (will be set later) GetHwndOf(parent), // parent (HMENU)-1, // control id wxGetInstance(), // app instance NULL // unused client data ); if ( !m_hwndBuddy ) { wxLogLastError(wxT("CreateWindow(buddy text window)")); return false; } // initialize wxControl if ( !CreateControl(parent, id, posBtn, sizeBtn, style, validator, name) ) return false; // now create the real HWND WXDWORD spiner_style = WS_VISIBLE | UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_SETBUDDYINT | UDS_EXPANDABLE; if ( !IsVertical(style) ) spiner_style |= UDS_HORZ; if ( style & wxSP_WRAP ) spiner_style |= UDS_WRAP; if ( !MSWCreateControl(UPDOWN_CLASS, spiner_style, posBtn, sizeBtn, _T(""), 0) ) return false; // subclass the text ctrl to be able to intercept some events wxSetWindowUserData(GetBuddyHwnd(), this); m_wndProcBuddy = (WXFARPROC)wxSetWindowProc(GetBuddyHwnd(), wxBuddyChoiceWndProc); // set up fonts and colours (This is nomally done in MSWCreateControl) InheritAttributes(); if (!m_hasFont) SetFont(GetDefaultAttributes().font); // set the size of the text window - can do it only now, because we // couldn't call DoGetBestSize() before as font wasn't set if ( sizeText.y <= 0 ) { int cx, cy; wxGetCharSize(GetHWND(), &cx, &cy, GetFont()); sizeText.y = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy); } SetBestSize(size); (void)::ShowWindow(GetBuddyHwnd(), SW_SHOW); // associate the list window with the spin button (void)::SendMessage(GetHwnd(), UDM_SETBUDDY, (WPARAM)GetBuddyHwnd(), 0); // do it after finishing with m_hwndBuddy creation to avoid generating // initial wxEVT_COMMAND_TEXT_UPDATED message ms_allChoiceSpins.Add(this); // initialize the controls contents for ( int i = 0; i < n; i++ ) { Append(choices[i]); } return true; }
// 设置延迟加载属性 void CDuiNativeWnd::SetDelayCreate(bool bDelayCreate) { if( m_bDelayCreate == bDelayCreate ) return; CreateControl(); m_bDelayCreate = bDelayCreate; }
_DEZGEMDisp __fastcall TEZGEM::GetDefaultInterface() { CreateControl(); return m_OCXIntf; };
void TASInputDlg::CreateGCLayout() { if (m_has_layout) return; CreateBaseLayout(); m_buttons[6] = &m_x; m_buttons[7] = &m_y; m_buttons[8] = &m_z; m_buttons[9] = &m_l; m_buttons[10] = &m_r; m_buttons[11] = &m_start; m_controls[2] = &m_c_stick.x_cont; m_controls[3] = &m_c_stick.y_cont; m_controls[4] = &m_l_cont; m_controls[5] = &m_r_cont; wxBoxSizer* const top_box = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* const bottom_box = new wxBoxSizer(wxHORIZONTAL); m_main_stick = CreateStick(ID_MAIN_STICK, 255, 255, 128, 128, false, true); wxStaticBoxSizer* const main_box = CreateStickLayout(&m_main_stick, _("Main Stick")); m_c_stick = CreateStick(ID_C_STICK, 255, 255, 128, 128, false, true); wxStaticBoxSizer* const c_box = CreateStickLayout(&m_c_stick, _("C Stick")); wxStaticBoxSizer* const shoulder_box = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Shoulder Buttons")); m_l_cont = CreateControl(wxSL_VERTICAL, -1, 100, false, 255, 0); m_r_cont = CreateControl(wxSL_VERTICAL, -1, 100, false, 255, 0); shoulder_box->Add(m_l_cont.slider, 0, wxALIGN_CENTER_VERTICAL); shoulder_box->Add(m_l_cont.text, 0, wxALIGN_CENTER_VERTICAL); shoulder_box->Add(m_r_cont.slider, 0, wxALIGN_CENTER_VERTICAL); shoulder_box->Add(m_r_cont.text, 0, wxALIGN_CENTER_VERTICAL); for (Control* const control : m_controls) { if (control != nullptr) control->slider->Bind(wxEVT_RIGHT_UP, &TASInputDlg::OnRightClickSlider, this); } wxStaticBoxSizer* const m_buttons_box = new wxStaticBoxSizer(wxVERTICAL, this, _("Buttons")); wxGridSizer* const m_buttons_grid = new wxGridSizer(4); m_x = CreateButton("X"); m_y = CreateButton("Y"); m_l = CreateButton("L"); m_r = CreateButton("R"); m_z = CreateButton("Z"); m_start = CreateButton("Start"); for (unsigned int i = 4; i < ArraySize(m_buttons); ++i) if (m_buttons[i] != nullptr) m_buttons_grid->Add(m_buttons[i]->checkbox, false); m_buttons_grid->AddSpacer(5); m_buttons_box->Add(m_buttons_grid); m_buttons_box->Add(m_buttons_dpad); wxBoxSizer* const main_szr = new wxBoxSizer(wxVERTICAL); top_box->Add(main_box, 0, wxALL, 5); top_box->Add(c_box, 0, wxTOP | wxRIGHT, 5); bottom_box->Add(shoulder_box, 0, wxLEFT | wxRIGHT, 5); bottom_box->Add(m_buttons_box, 0, wxBOTTOM, 5); main_szr->Add(top_box); main_szr->Add(bottom_box); SetSizerAndFit(main_szr); ResetValues(); FinishLayout(); }
TConnectionPtr CAudioSystemEditor_wwise::CreateConnectionFromXMLNode(XmlNodeRef pNode, EACEControlType eATLControlType) { if (pNode) { const string sTag = pNode->getTag(); TImplControlType type = TagToType(sTag); if (type != AUDIO_IMPL_INVALID_TYPE) { string sName = pNode->getAttr("wwise_name"); string sLocalised = pNode->getAttr("wwise_localised"); bool bLocalised = (sLocalised.compareNoCase("true") == 0); // If control not found, create a placeholder. // We want to keep that connection even if it's not in the middleware. // The user could be using the engine without the wwise project IAudioSystemControl* pControl = GetControlByName(sName, bLocalised); if (pControl == nullptr) { pControl = CreateControl(SControlDef(sName, type)); if (pControl) { pControl->SetPlaceholder(true); pControl->SetLocalised(bLocalised); } } // If it's a switch we actually connect to one of the states within the switch if (type == eWCT_WWISE_SWITCH_GROUP || type == eWCT_WWISE_GAME_STATE_GROUP) { if (pNode->getChildCount() == 1) { pNode = pNode->getChild(0); if (pNode) { string sChildName = pNode->getAttr("wwise_name"); IAudioSystemControl* pChildControl = GetControlByName(sChildName, false, pControl); if (pChildControl == nullptr) { pChildControl = CreateControl(SControlDef(sChildName, type == eWCT_WWISE_SWITCH_GROUP ? eWCT_WWISE_SWITCH : eWCT_WWISE_GAME_STATE, false, pControl)); } pControl = pChildControl; } } else { CryWarning(VALIDATOR_MODULE_EDITOR, VALIDATOR_ERROR, "Audio Controls Editor (Wwise): Error reading connection to Wwise control %s", sName); } } if (pControl) { pControl->SetConnected(true); ++m_connectionsByID[pControl->GetId()]; if (type == eWCT_WWISE_RTPC) { switch (eATLControlType) { case EACEControlType::eACET_RTPC: { TRtpcConnectionPtr pConnection = std::make_shared<CRtpcConnection>(pControl->GetId()); float mult = 1.0f; float shift = 0.0f; if (pNode->haveAttr("atl_mult")) { const string sProperty = pNode->getAttr("atl_mult"); mult = (float)std::atof(sProperty.c_str()); } if (pNode->haveAttr("atl_shift")) { const string sProperty = pNode->getAttr("atl_shift"); shift = (float)std::atof(sProperty.c_str()); } pConnection->fMult = mult; pConnection->fShift = shift; return pConnection; } case EACEControlType::eACET_SWITCH_STATE: { TStateConnectionPtr pConnection = std::make_shared<CStateToRtpcConnection>(pControl->GetId()); float value = 0.0f; if (pNode->haveAttr("atl_mult")) { const string sProperty = pNode->getAttr("wwise_value"); value = (float)std::atof(sProperty.c_str()); } pConnection->fValue = value; return pConnection; } } } else { return std::make_shared<IAudioConnection>(pControl->GetId()); } } } } return nullptr; }
void TASInputDlg::CreateWiiLayout(int num) { if (m_has_layout) return; CreateBaseLayout(); m_buttons[6] = &m_one; m_buttons[7] = &m_two; m_buttons[8] = &m_plus; m_buttons[9] = &m_minus; m_buttons[10] = &m_home; m_controls[4] = &m_x_cont; m_controls[5] = &m_y_cont; m_controls[6] = &m_z_cont; m_main_stick = CreateStick(ID_MAIN_STICK, 1024, 768, 512, 384, true, false); m_main_stick_szr = CreateStickLayout(&m_main_stick, _("IR")); m_x_cont = CreateControl(wxSL_VERTICAL, -1, 100, false, 1023, 512); m_y_cont = CreateControl(wxSL_VERTICAL, -1, 100, false, 1023, 512); m_z_cont = CreateControl(wxSL_VERTICAL, -1, 100, false, 1023, 616); wxStaticBoxSizer* const axisBox = CreateAccelLayout(&m_x_cont, &m_y_cont, &m_z_cont, _("Orientation")); wxStaticBoxSizer* const m_buttons_box = new wxStaticBoxSizer(wxVERTICAL, this, _("Buttons")); wxGridSizer* const m_buttons_grid = new wxGridSizer(4); m_plus = CreateButton("+"); m_minus = CreateButton("-"); m_one = CreateButton("1"); m_two = CreateButton("2"); m_home = CreateButton("Home"); m_main_szr = new wxBoxSizer(wxVERTICAL); m_wiimote_szr = new wxBoxSizer(wxHORIZONTAL); m_ext_szr = new wxBoxSizer(wxHORIZONTAL); m_cc_szr = CreateCCLayout(); if (Core::IsRunning()) { m_ext = ((WiimoteEmu::Wiimote*)Wiimote::GetConfig()->controllers[num])->CurrentExtension(); } else { IniFile ini; ini.Load(File::GetUserPath(D_CONFIG_IDX) + "WiimoteNew.ini"); std::string extension; ini.GetIfExists("Wiimote" + std::to_string(num + 1), "Extension", &extension); if (extension == "Nunchuk") m_ext = 1; if (extension == "Classic") m_ext = 2; } m_buttons[11] = &m_c; m_buttons[12] = &m_z; m_controls[2] = &m_c_stick.x_cont; m_controls[3] = &m_c_stick.y_cont; m_controls[7] = &m_nx_cont; m_controls[8] = &m_ny_cont; m_controls[9] = &m_nz_cont; m_c_stick = CreateStick(ID_C_STICK, 255, 255, 128, 128, false, true); m_c_stick_szr = CreateStickLayout(&m_c_stick, _("Nunchuk stick")); m_nx_cont = CreateControl(wxSL_VERTICAL, -1, 100, false, 1023, 512); m_ny_cont = CreateControl(wxSL_VERTICAL, -1, 100, false, 1023, 512); m_nz_cont = CreateControl(wxSL_VERTICAL, -1, 100, false, 1023, 512); wxStaticBoxSizer* const nunchukaxisBox = CreateAccelLayout(&m_nx_cont, &m_ny_cont, &m_nz_cont, _("Nunchuk orientation")); m_c = CreateButton("C"); m_z = CreateButton("Z"); m_ext_szr->Add(m_c_stick_szr, 0, wxLEFT | wxBOTTOM | wxRIGHT, 5); m_ext_szr->Add(nunchukaxisBox); for (Control* const control : m_controls) { if (control != nullptr) control->slider->Bind(wxEVT_RIGHT_UP, &TASInputDlg::OnRightClickSlider, this); } for (unsigned int i = 4; i < ArraySize(m_buttons); ++i) if (m_buttons[i] != nullptr) m_buttons_grid->Add(m_buttons[i]->checkbox); m_buttons_grid->AddSpacer(5); m_buttons_box->Add(m_buttons_grid); m_buttons_box->Add(m_buttons_dpad); m_wiimote_szr->Add(m_main_stick_szr, 0, wxALL, 5); m_wiimote_szr->Add(axisBox, 0, wxTOP | wxRIGHT, 5); m_wiimote_szr->Add(m_buttons_box, 0, wxTOP | wxRIGHT, 5); m_main_szr->Add(m_wiimote_szr); m_main_szr->Add(m_ext_szr); m_main_szr->Add(m_cc_szr); HandleExtensionChange(); FinishLayout(); }
wxBoxSizer* TASInputDlg::CreateCCLayout() { wxBoxSizer* const szr = new wxBoxSizer(wxHORIZONTAL); for (size_t i = 0; i < ArraySize(m_cc_buttons); ++i) m_cc_buttons[i] = CreateButton(m_cc_button_names[i]); m_cc_l_stick = CreateStick(ID_CC_L_STICK, 63, 63, WiimoteEmu::Classic::LEFT_STICK_CENTER_X, WiimoteEmu::Classic::LEFT_STICK_CENTER_Y, false, true); m_cc_r_stick = CreateStick(ID_CC_R_STICK, 31, 31, WiimoteEmu::Classic::RIGHT_STICK_CENTER_X, WiimoteEmu::Classic::RIGHT_STICK_CENTER_Y, false, true); m_cc_controls[CC_L_STICK_X] = &m_cc_l_stick.x_cont; m_cc_controls[CC_L_STICK_Y] = &m_cc_l_stick.y_cont; m_cc_controls[CC_R_STICK_X] = &m_cc_r_stick.x_cont; m_cc_controls[CC_R_STICK_Y] = &m_cc_r_stick.y_cont; m_cc_controls[CC_L_TRIGGER] = &m_cc_l; m_cc_controls[CC_R_TRIGGER] = &m_cc_r; m_cc_l_stick_szr = CreateStickLayout(&m_cc_l_stick, _("Left stick")); m_cc_r_stick_szr = CreateStickLayout(&m_cc_r_stick, _("Right stick")); m_cc_l = CreateControl(wxSL_VERTICAL, -1, 100, false, 31, 0);; m_cc_r = CreateControl(wxSL_VERTICAL, -1, 100, false, 31, 0);; wxStaticBoxSizer* const shoulder_box = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Shoulder Buttons")); shoulder_box->Add(m_cc_l.slider, 0, wxALIGN_CENTER_VERTICAL); shoulder_box->Add(m_cc_l.text, 0, wxALIGN_CENTER_VERTICAL); shoulder_box->Add(m_cc_r.slider, 0, wxALIGN_CENTER_VERTICAL); shoulder_box->Add(m_cc_r.text, 0, wxALIGN_CENTER_VERTICAL); wxStaticBoxSizer* const cc_buttons_box = new wxStaticBoxSizer(wxVERTICAL, this, _("Buttons")); wxGridSizer* const cc_buttons_grid = new wxGridSizer(4); wxGridSizer* const cc_buttons_dpad = new wxGridSizer(3); cc_buttons_dpad->AddSpacer(20); cc_buttons_dpad->Add(m_cc_buttons[1].checkbox); cc_buttons_dpad->AddSpacer(20); cc_buttons_dpad->Add(m_cc_buttons[2].checkbox); cc_buttons_dpad->AddSpacer(20); cc_buttons_dpad->Add(m_cc_buttons[3].checkbox); cc_buttons_dpad->AddSpacer(20); cc_buttons_dpad->Add(m_cc_buttons[0].checkbox); cc_buttons_dpad->AddSpacer(20); for (auto button : m_cc_buttons) cc_buttons_grid->Add(button.checkbox); cc_buttons_grid->AddSpacer(5); cc_buttons_box->Add(cc_buttons_grid); cc_buttons_box->Add(cc_buttons_dpad); szr->Add(m_cc_l_stick_szr, 0, wxALL, 5); szr->Add(m_cc_r_stick_szr, 0, wxALL, 5); szr->Add(shoulder_box, 0, wxLEFT | wxRIGHT, 5); szr->Add(cc_buttons_box, 0, wxTOP | wxRIGHT, 5); for (Control* const control : m_cc_controls) { if (control != nullptr) control->slider->Bind(wxEVT_RIGHT_UP, &TASInputDlg::OnRightClickSlider, this); } return szr; }
bool CGUIDialogSettingsBase::OnMessage(CGUIMessage &message) { switch (message.GetMessage()) { case GUI_MSG_WINDOW_INIT: { m_delayedSetting.reset(); if (message.GetParam1() != WINDOW_INVALID) { // coming to this window first time (ie not returning back from some other window) // so we reset our section and control states m_iCategory = 0; ResetControlStates(); } if (AllowResettingSettings()) { m_resetSetting = new CSettingAction(SETTINGS_RESET_SETTING_ID); m_resetSetting->SetLabel(10041); m_resetSetting->SetHelp(10045); m_resetSetting->SetControl(CreateControl("button")); } m_dummyCategory = new CSettingCategory(SETTINGS_EMPTY_CATEGORY_ID); m_dummyCategory->SetLabel(10046); m_dummyCategory->SetHelp(10047); break; } case GUI_MSG_WINDOW_DEINIT: { // cancel any delayed changes if (m_delayedSetting != NULL) { m_delayedTimer.Stop(); CGUIMessage message(GUI_MSG_UPDATE_ITEM, GetID(), m_delayedSetting->GetID()); OnMessage(message); } CGUIDialog::OnMessage(message); FreeControls(); return true; } case GUI_MSG_FOCUSED: { CGUIDialog::OnMessage(message); int focusedControl = GetFocusedControlID(); // cancel any delayed changes if (m_delayedSetting != NULL && m_delayedSetting->GetID() != focusedControl) { m_delayedTimer.Stop(); CGUIMessage message(GUI_MSG_UPDATE_ITEM, GetID(), m_delayedSetting->GetID(), 1); // param1 = 1 for "reset the control if it's invalid" g_windowManager.SendThreadMessage(message, GetID()); } // update the value of the previous setting (in case it was invalid) else if (m_iSetting >= CONTROL_SETTINGS_START_CONTROL && m_iSetting < (int)(CONTROL_SETTINGS_START_CONTROL + m_settingControls.size())) { BaseSettingControlPtr control = GetSettingControl(m_iSetting); if (control != NULL && control->GetSetting() != NULL && !control->IsValid()) { CGUIMessage message(GUI_MSG_UPDATE_ITEM, GetID(), m_iSetting, 1); // param1 = 1 for "reset the control if it's invalid" g_windowManager.SendThreadMessage(message, GetID()); } } CVariant description; // check if we have changed the category and need to create new setting controls if (focusedControl >= CONTROL_SETTINGS_START_BUTTONS && focusedControl < (int)(CONTROL_SETTINGS_START_BUTTONS + m_categories.size())) { int categoryIndex = focusedControl - CONTROL_SETTINGS_START_BUTTONS; const CSettingCategory* category = m_categories.at(categoryIndex); if (categoryIndex != m_iCategory) { if (!category->CanAccess()) { // unable to go to this category - focus the previous one SET_CONTROL_FOCUS(CONTROL_SETTINGS_START_BUTTONS + m_iCategory, 0); return false; } m_iCategory = categoryIndex; CreateSettings(); } description = category->GetHelp(); } else if (focusedControl >= CONTROL_SETTINGS_START_CONTROL && focusedControl < (int)(CONTROL_SETTINGS_START_CONTROL + m_settingControls.size())) { m_iSetting = focusedControl; CSetting *setting = GetSettingControl(focusedControl)->GetSetting(); if (setting != NULL) description = setting->GetHelp(); } // set the description of the currently focused category/setting if (description.isInteger() || (description.isString() && !description.empty())) SetDescription(description); return true; } case GUI_MSG_CLICKED: { int iControl = message.GetSenderId(); if (iControl == CONTROL_SETTINGS_OKAY_BUTTON) { OnOkay(); Close(); return true; } if (iControl == CONTROL_SETTINGS_CANCEL_BUTTON) { OnCancel(); Close(); return true; } BaseSettingControlPtr control = GetSettingControl(iControl); if (control != NULL) OnClick(control); break; } case GUI_MSG_UPDATE_ITEM: { if (m_delayedSetting != NULL && m_delayedSetting->GetID() == message.GetControlId()) { // first get the delayed setting and reset its member variable // to avoid handling the delayed setting twice in case the OnClick() // performed later causes the window to be deinitialized (e.g. when // changing the language) BaseSettingControlPtr delayedSetting = m_delayedSetting; m_delayedSetting.reset(); // if updating the setting fails and param1 has been specifically set // we need to call OnSettingChanged() to restore a valid value in the // setting control if (!delayedSetting->OnClick() && message.GetParam1() != 0) OnSettingChanged(delayedSetting->GetSetting()); return true; } if (message.GetControlId() >= CONTROL_SETTINGS_START_CONTROL && message.GetControlId() < (int)(CONTROL_SETTINGS_START_CONTROL + m_settingControls.size())) { BaseSettingControlPtr settingControl = GetSettingControl(message.GetControlId()); if (settingControl.get() != NULL && settingControl->GetSetting() != NULL) { settingControl->Update(); return true; } } break; } case GUI_MSG_UPDATE: { if (IsActive() && HasID(message.GetSenderId())) { int focusedControl = GetFocusedControlID(); CreateSettings(); SET_CONTROL_FOCUS(focusedControl, 0); } break; } default: break; } return CGUIDialog::OnMessage(message); }
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]); } wxFont* pTextFont = new wxFont( 10 ,wxMODERN ,wxNORMAL ,wxNORMAL ); SetFont(*pTextFont); SetSize( rPos.x ,rPos.y ,rSize.x ,rSize.y ); delete pTextFont; return true; } // end of wxChoice::Create
bool wxSlider::Create(wxWindow *parent, wxWindowID id, int value, int minValue, int maxValue, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { wxCHECK_MSG( minValue < maxValue, false, wxT("Slider minimum must be strictly less than the maximum.") ); // our styles are redundant: wxSL_LEFT/RIGHT imply wxSL_VERTICAL and // wxSL_TOP/BOTTOM imply wxSL_HORIZONTAL, but for backwards compatibility // reasons we can't really change it, instead try to infer the orientation // from the flags given to us here switch ( style & (wxSL_LEFT | wxSL_RIGHT | wxSL_TOP | wxSL_BOTTOM) ) { case wxSL_LEFT: case wxSL_RIGHT: style |= wxSL_VERTICAL; break; case wxSL_TOP: case wxSL_BOTTOM: style |= wxSL_HORIZONTAL; break; case 0: // no specific direction, do we have at least the orientation? if ( !(style & (wxSL_HORIZONTAL | wxSL_VERTICAL)) ) { // no, choose default style |= wxSL_BOTTOM | wxSL_HORIZONTAL; } }; wxASSERT_MSG( !(style & wxSL_VERTICAL) || !(style & wxSL_HORIZONTAL), wxT("incompatible slider direction and orientation") ); // initialize everything if ( !CreateControl(parent, id, pos, size, style, validator, name) ) return false; // ensure that we have correct values for GetLabelsSize() m_rangeMin = minValue; m_rangeMax = maxValue; // create the labels first, so that our DoGetBestSize() could take them // into account // // note that we could simply create 3 wxStaticTexts here but it could // result in some observable side effects at wx level (e.g. the parent of // wxSlider would have 3 more children than expected) and so we prefer not // to do it like this if ( m_windowStyle & wxSL_LABELS ) { m_labels = new wxSubwindows(SliderLabel_Last); HWND hwndParent = GetHwndOf(parent); for ( size_t n = 0; n < SliderLabel_Last; n++ ) { wxWindowIDRef lblid = NewControlId(); HWND wnd = ::CreateWindow ( wxT("STATIC"), NULL, WS_CHILD | WS_VISIBLE | SS_CENTER, 0, 0, 0, 0, hwndParent, (HMENU)wxUIntToPtr(lblid.GetValue()), wxGetInstance(), NULL ); m_labels->Set(n, wnd, lblid); } m_labels->SetFont(GetFont()); } // now create the main control too if ( !MSWCreateControl(TRACKBAR_CLASS, wxEmptyString, pos, size) ) return false; // and initialize everything SetRange(minValue, maxValue); SetValue(value); SetPageSize( wxMax(1, (maxValue - minValue)/10) ); // we need to position the labels correctly if we have them and if // SetSize() hadn't been called before (when best size was determined by // MSWCreateControl()) as in this case they haven't been put in place yet if ( m_labels && size.x != wxDefaultCoord && size.y != wxDefaultCoord ) { SetSize(size); } return true; }
void CStatusCtrl::CreateControl(DWORD style, int x, int y, int width, int height) { int widths[] = {-1}; CreateControl(style, 1, widths); }
bool wxRadioButton::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; PreCreation(); Widget parentWidget = (Widget) parent->GetClientWidget(); Display* dpy = XtDisplay(parentWidget); wxString label1(GetLabelText(label)); wxXmString text( label1 ); Widget radioButtonWidget = XtVaCreateManagedWidget ("toggle", #if wxUSE_GADGETS xmToggleButtonGadgetClass, parentWidget, #else xmToggleButtonWidgetClass, parentWidget, #endif wxFont::GetFontTag(), m_font.GetFontTypeC(dpy), XmNlabelString, text(), XmNfillOnSelect, True, XmNindicatorType, XmONE_OF_MANY, // diamond-shape NULL); XtAddCallback (radioButtonWidget, XmNvalueChangedCallback, (XtCallbackProc)wxRadioButtonCallback, (XtPointer)this); m_mainWidget = (WXWidget) radioButtonWidget; XtManageChild (radioButtonWidget); PostCreation(); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); //copied from mac/radiobut.cpp (from here till "return true;") m_cycle = this ; if (HasFlag(wxRB_GROUP)) { AddInCycle( NULL ) ; } else { /* search backward for last group start */ wxRadioButton *chief = NULL; wxWindowList::compatibility_iterator node = parent->GetChildren().GetLast(); while (node) { wxWindow *child = node->GetData(); if (child->IsKindOf( CLASSINFO( wxRadioButton ) ) ) { chief = (wxRadioButton*) child; if (child->HasFlag(wxRB_GROUP)) break; } node = node->GetPrevious(); } AddInCycle( chief ) ; } return true; }
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)); for (int 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
void TASInputDlg::CreateWiiLayout(int num) { if (m_has_layout) return; const int space5 = FromDIP(5); CreateBaseLayout(); m_buttons[6] = &m_one; m_buttons[7] = &m_two; m_buttons[8] = &m_plus; m_buttons[9] = &m_minus; m_buttons[10] = &m_home; m_controls[4] = &m_x_cont; m_controls[5] = &m_y_cont; m_controls[6] = &m_z_cont; m_main_stick = CreateStick(ID_MAIN_STICK, 1024, 768, 512, 384, true, false); // i18n: IR stands for infrared and refers to the pointer functionality of Wii Remotes m_main_stick_szr = CreateStickLayout(&m_main_stick, _("IR")); m_x_cont = CreateControl(wxSL_VERTICAL, -1, 100, false, 1023, 512); m_y_cont = CreateControl(wxSL_VERTICAL, -1, 100, false, 1023, 512); m_z_cont = CreateControl(wxSL_VERTICAL, -1, 100, false, 1023, 616); wxStaticBoxSizer* const axisBox = CreateAccelLayout(&m_x_cont, &m_y_cont, &m_z_cont, _("Orientation")); m_plus = CreateButton("+"); m_plus.checkbox->SetClientData(&m_plus); m_minus = CreateButton("-"); m_minus.checkbox->SetClientData(&m_minus); m_one = CreateButton("1"); m_one.checkbox->SetClientData(&m_one); m_two = CreateButton("2"); m_two.checkbox->SetClientData(&m_two); m_home = CreateButton("HOME"); m_home.checkbox->SetClientData(&m_home); m_cc_szr = CreateCCLayout(); if (Core::IsRunning()) { m_ext = static_cast<WiimoteEmu::Wiimote*>(Wiimote::GetConfig()->GetController(num)) ->CurrentExtension(); } else { IniFile ini; ini.Load(File::GetUserPath(D_CONFIG_IDX) + "WiimoteNew.ini"); std::string extension; ini.GetIfExists("Wiimote" + std::to_string(num + 1), "Extension", &extension); if (extension == "Nunchuk") m_ext = 1; if (extension == "Classic") m_ext = 2; } m_buttons[11] = &m_c; m_buttons[12] = &m_z; m_controls[2] = &m_c_stick.x_cont; m_controls[3] = &m_c_stick.y_cont; m_controls[7] = &m_nx_cont; m_controls[8] = &m_ny_cont; m_controls[9] = &m_nz_cont; m_c_stick = CreateStick(ID_C_STICK, 255, 255, 128, 128, false, true); m_c_stick_szr = CreateStickLayout(&m_c_stick, _("Nunchuk stick")); m_nx_cont = CreateControl(wxSL_VERTICAL, -1, 100, false, 1023, 512); m_ny_cont = CreateControl(wxSL_VERTICAL, -1, 100, false, 1023, 512); m_nz_cont = CreateControl(wxSL_VERTICAL, -1, 100, false, 1023, 512); wxStaticBoxSizer* const nunchukaxisBox = CreateAccelLayout(&m_nx_cont, &m_ny_cont, &m_nz_cont, _("Nunchuk orientation")); m_c = CreateButton("C"); m_c.checkbox->SetClientData(&m_c); m_z = CreateButton("Z"); m_z.checkbox->SetClientData(&m_z); for (Control* const control : m_controls) { if (control != nullptr) control->slider->Bind(wxEVT_RIGHT_UP, &TASInputDlg::OnRightClickSlider, this); } m_ext_szr = new wxBoxSizer(wxHORIZONTAL); m_ext_szr->Add(m_c_stick_szr, 0, wxBOTTOM, space5); m_ext_szr->AddSpacer(space5); m_ext_szr->Add(nunchukaxisBox, 0, wxBOTTOM, space5); // Add non-DPad related buttons first. auto* const buttons_grid = new wxGridSizer(4); for (size_t i = 4; i < m_buttons.size(); ++i) { if (m_buttons[i] != nullptr) buttons_grid->Add(m_buttons[i]->checkbox); } buttons_grid->Add(space5, space5); auto* const buttons_box = new wxStaticBoxSizer(wxVERTICAL, this, _("Buttons")); buttons_box->Add(buttons_grid); buttons_box->Add(m_buttons_dpad, 0, wxTOP, space5); m_wiimote_szr = new wxBoxSizer(wxHORIZONTAL); m_wiimote_szr->AddSpacer(space5); m_wiimote_szr->Add(m_main_stick_szr); m_wiimote_szr->Add(axisBox, 0, wxLEFT, space5); m_wiimote_szr->Add(buttons_box, 0, wxLEFT, space5); m_wiimote_szr->AddSpacer(space5); // NOTE: Not all of these are visible at the same time. m_main_szr = new wxBoxSizer(wxVERTICAL); m_main_szr->Add(m_wiimote_szr, 0, wxTOP | wxBOTTOM, space5); m_main_szr->Add(m_ext_szr, 0, wxLEFT | wxRIGHT, space5); m_main_szr->Add(m_cc_szr, 0, wxLEFT | wxRIGHT, space5); SetSizer(m_main_szr); HandleExtensionChange(); FinishLayout(); }
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
wxBoxSizer* TASInputDlg::CreateCCLayout() { const std::array<wxString, 15> button_names{{_("Down"), _("Up"), _("Left"), _("Right"), "A", "B", "X", "Y", "+", "-", "L", "R", "ZR", "ZL", "HOME"}}; for (size_t i = 0; i < button_names.size(); ++i) { m_cc_buttons[i] = CreateButton(button_names[i]); m_cc_buttons[i].checkbox->SetClientData(&m_cc_buttons[i]); } m_cc_l_stick = CreateStick(ID_CC_L_STICK, 63, 63, WiimoteEmu::Classic::LEFT_STICK_CENTER_X, WiimoteEmu::Classic::LEFT_STICK_CENTER_Y, false, true); m_cc_r_stick = CreateStick(ID_CC_R_STICK, 31, 31, WiimoteEmu::Classic::RIGHT_STICK_CENTER_X, WiimoteEmu::Classic::RIGHT_STICK_CENTER_Y, false, true); m_cc_controls[CC_L_STICK_X] = &m_cc_l_stick.x_cont; m_cc_controls[CC_L_STICK_Y] = &m_cc_l_stick.y_cont; m_cc_controls[CC_R_STICK_X] = &m_cc_r_stick.x_cont; m_cc_controls[CC_R_STICK_Y] = &m_cc_r_stick.y_cont; m_cc_controls[CC_L_TRIGGER] = &m_cc_l; m_cc_controls[CC_R_TRIGGER] = &m_cc_r; m_cc_l_stick_szr = CreateStickLayout(&m_cc_l_stick, _("Left stick")); m_cc_r_stick_szr = CreateStickLayout(&m_cc_r_stick, _("Right stick")); m_cc_l = CreateControl(wxSL_VERTICAL, -1, 100, false, 31, 0); m_cc_r = CreateControl(wxSL_VERTICAL, -1, 100, false, 31, 0); const int space5 = FromDIP(5); const int space20 = FromDIP(20); auto* const shoulder_box = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Shoulder Buttons")); shoulder_box->Add(m_cc_l.slider, 0, wxALIGN_CENTER_VERTICAL); shoulder_box->Add(m_cc_l.text, 0, wxALIGN_CENTER_VERTICAL); shoulder_box->Add(m_cc_r.slider, 0, wxALIGN_CENTER_VERTICAL); shoulder_box->Add(m_cc_r.text, 0, wxALIGN_CENTER_VERTICAL); auto* const cc_buttons_dpad = new wxGridSizer(3); cc_buttons_dpad->Add(space20, space20); cc_buttons_dpad->Add(m_cc_buttons[1].checkbox); cc_buttons_dpad->Add(space20, space20); cc_buttons_dpad->Add(m_cc_buttons[2].checkbox); cc_buttons_dpad->Add(space20, space20); cc_buttons_dpad->Add(m_cc_buttons[3].checkbox); cc_buttons_dpad->Add(space20, space20); cc_buttons_dpad->Add(m_cc_buttons[0].checkbox); cc_buttons_dpad->Add(space20, space20); auto* const cc_buttons_grid = new wxGridSizer(4); for (auto& button : m_cc_buttons) if (!button.checkbox->GetContainingSizer()) cc_buttons_grid->Add(button.checkbox); cc_buttons_grid->Add(space5, space5); auto* const cc_buttons_box = new wxStaticBoxSizer(wxVERTICAL, this, _("Buttons")); cc_buttons_box->Add(cc_buttons_grid); cc_buttons_box->Add(cc_buttons_dpad, 0, wxTOP, space5); auto* const szr = new wxBoxSizer(wxHORIZONTAL); szr->AddSpacer(space5); szr->Add(m_cc_l_stick_szr, 0, wxTOP | wxBOTTOM, space5); szr->AddSpacer(space5); szr->Add(m_cc_r_stick_szr, 0, wxTOP | wxBOTTOM, space5); szr->AddSpacer(space5); szr->Add(shoulder_box, 0, wxTOP | wxBOTTOM, space5); szr->AddSpacer(space5); szr->Add(cc_buttons_box, 0, wxTOP | wxBOTTOM, space5); szr->AddSpacer(space5); for (Control* const control : m_cc_controls) { if (control != nullptr) control->slider->Bind(wxEVT_RIGHT_UP, &TASInputDlg::OnRightClickSlider, this); } return szr; }
bool wxCalendarCtrl::Create(wxWindow *parent, wxWindowID id, const wxDateTime& dt, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { if ( !wxMSWDateControls::CheckInitialization() ) return false; // we need the arrows for the navigation style |= wxWANTS_CHARS; // initialize the base class if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) ) return false; // create the native control: this is a bit tricky as we want to receive // double click events but the MONTHCAL_CLASS doesn't use CS_DBLCLKS style // and so we create our own copy of it which does static ClassRegistrar s_clsMonthCal; if ( !s_clsMonthCal.IsInitialized() ) { // get a copy of standard class and modify it WNDCLASS wc; if ( ::GetClassInfo(NULL, MONTHCAL_CLASS, &wc) ) { wc.lpszClassName = wxT("_wx_SysMonthCtl32"); wc.style |= CS_DBLCLKS; s_clsMonthCal.Register(wc); } else { wxLogLastError(wxT("GetClassInfoEx(SysMonthCal32)")); } } const wxChar * const clsname = s_clsMonthCal.IsRegistered() ? s_clsMonthCal.GetName().wx_str() : MONTHCAL_CLASS; if ( !MSWCreateControl(clsname, wxEmptyString, pos, size) ) return false; // initialize the control UpdateFirstDayOfWeek(); SetDate(dt.IsValid() ? dt : wxDateTime::Today()); if ( SetHolidayAttrs() ) UpdateMarks(); Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(wxCalendarCtrl::MSWOnClick)); Connect(wxEVT_LEFT_DCLICK, wxMouseEventHandler(wxCalendarCtrl::MSWOnDoubleClick)); return true; }
void TASInputDlg::CreateGCLayout() { if (m_has_layout) return; CreateBaseLayout(); m_buttons[6] = &m_x; m_buttons[7] = &m_y; m_buttons[8] = &m_z; m_buttons[9] = &m_l; m_buttons[10] = &m_r; m_buttons[11] = &m_start; m_controls[2] = &m_c_stick.x_cont; m_controls[3] = &m_c_stick.y_cont; m_controls[4] = &m_l_cont; m_controls[5] = &m_r_cont; m_main_stick = CreateStick(ID_MAIN_STICK, 255, 255, 128, 128, false, true); wxStaticBoxSizer* const main_box = CreateStickLayout(&m_main_stick, _("Main Stick")); m_c_stick = CreateStick(ID_C_STICK, 255, 255, 128, 128, false, true); wxStaticBoxSizer* const c_box = CreateStickLayout(&m_c_stick, _("C Stick")); auto* const shoulder_box = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Shoulder Buttons")); m_l_cont = CreateControl(wxSL_VERTICAL, -1, 100, false, 255, 0); m_r_cont = CreateControl(wxSL_VERTICAL, -1, 100, false, 255, 0); shoulder_box->Add(m_l_cont.slider, 0, wxALIGN_CENTER_VERTICAL); shoulder_box->Add(m_l_cont.text, 0, wxALIGN_CENTER_VERTICAL); shoulder_box->Add(m_r_cont.slider, 0, wxALIGN_CENTER_VERTICAL); shoulder_box->Add(m_r_cont.text, 0, wxALIGN_CENTER_VERTICAL); for (Control* const control : m_controls) { if (control != nullptr) control->slider->Bind(wxEVT_RIGHT_UP, &TASInputDlg::OnRightClickSlider, this); } m_x = CreateButton("X"); m_x.checkbox->SetClientData(&m_x); m_y = CreateButton("Y"); m_y.checkbox->SetClientData(&m_y); m_l = CreateButton("L"); m_l.checkbox->SetClientData(&m_l); m_r = CreateButton("R"); m_r.checkbox->SetClientData(&m_r); m_z = CreateButton("Z"); m_z.checkbox->SetClientData(&m_z); // i18n: The START/PAUSE button on GameCube controllers m_start = CreateButton(_("START")); m_start.checkbox->SetClientData(&m_start); const int space5 = FromDIP(5); // Add non-DPad related buttons first. auto* const buttons_grid = new wxGridSizer(4); for (size_t i = 4; i < m_buttons.size(); ++i) { if (m_buttons[i] != nullptr) buttons_grid->Add(m_buttons[i]->checkbox, false); } buttons_grid->Add(space5, space5); auto* const buttons_box = new wxStaticBoxSizer(wxVERTICAL, this, _("Buttons")); buttons_box->Add(buttons_grid); buttons_box->Add(m_buttons_dpad); auto* const top_box = new wxBoxSizer(wxHORIZONTAL); top_box->Add(main_box); top_box->Add(c_box, 0, wxLEFT, space5); auto* const bottom_box = new wxBoxSizer(wxHORIZONTAL); bottom_box->Add(shoulder_box); bottom_box->Add(buttons_box, 0, wxLEFT, space5); auto* const main_szr = new wxBoxSizer(wxVERTICAL); main_szr->AddSpacer(space5); main_szr->Add(top_box, 0, wxLEFT | wxRIGHT, space5); main_szr->AddSpacer(space5); main_szr->Add(bottom_box, 0, wxLEFT | wxRIGHT, space5); main_szr->AddSpacer(space5); SetSizerAndFit(main_szr); ResetValues(); FinishLayout(); }
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
// Create() function bool wxNotebook::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { if ( (style & wxBK_ALIGN_MASK) == wxBK_DEFAULT ) { #if defined(__POCKETPC__) style |= wxBK_BOTTOM | wxNB_FLAT; #else style |= wxBK_TOP; #endif } #ifdef __WXWINCE__ // Not sure why, but without this style, there is no border // around the notebook tabs. if (style & wxNB_FLAT) style |= wxBORDER_SUNKEN; #endif #if !wxUSE_UXTHEME // ComCtl32 notebook tabs simply don't work unless they're on top if we // have uxtheme, we can work around it later (after control creation), but // if we have been compiled without uxtheme support, we have to clear those // styles if ( HasTroubleWithNonTopTabs() ) { style &= ~(wxBK_BOTTOM | wxBK_LEFT | wxBK_RIGHT); } #endif //wxUSE_UXTHEME #if defined(__WINE__) && wxUSE_UNICODE LPCTSTR className = L"SysTabControl32"; #else LPCTSTR className = WC_TABCONTROL; #endif #if USE_NOTEBOOK_ANTIFLICKER // SysTabCtl32 class has natively CS_HREDRAW and CS_VREDRAW enabled and it // causes horrible flicker when resizing notebook, so get rid of it by // using a class without these styles (but otherwise identical to it) if ( !HasFlag(wxFULL_REPAINT_ON_RESIZE) ) { static ClassRegistrar s_clsNotebook; if ( !s_clsNotebook.IsInitialized() ) { // get a copy of standard class and modify it WNDCLASS wc; if ( ::GetClassInfo(NULL, WC_TABCONTROL, &wc) ) { gs_wndprocNotebook = reinterpret_cast<WXFARPROC>(wc.lpfnWndProc); wc.lpszClassName = wxT("_wx_SysTabCtl32"); wc.style &= ~(CS_HREDRAW | CS_VREDRAW); wc.hInstance = wxGetInstance(); wc.lpfnWndProc = wxNotebookWndProc; s_clsNotebook.Register(wc); } else { wxLogLastError(wxT("GetClassInfoEx(SysTabCtl32)")); } } // use our custom class if available but fall back to the standard // notebook if we failed to register it if ( s_clsNotebook.IsRegistered() ) { // it's ok to use c_str() here as the static s_clsNotebook object // has sufficiently long lifetime className = s_clsNotebook.GetName().c_str(); } } #endif // USE_NOTEBOOK_ANTIFLICKER if ( !CreateControl(parent, id, pos, size, style | wxTAB_TRAVERSAL, wxDefaultValidator, name) ) return false; if ( !MSWCreateControl(className, wxEmptyString, pos, size) ) return false; #if wxUSE_UXTHEME if ( HasFlag(wxNB_NOPAGETHEME) || wxSystemOptions::IsFalse(wxT("msw.notebook.themed-background")) ) { SetBackgroundColour(GetThemeBackgroundColour()); } else // use themed background by default { // create backing store UpdateBgBrush(); } // comctl32.dll 6.0 doesn't support non-top tabs with visual styles (the // control is simply not rendered correctly), so we disable themes // if possible, otherwise we simply clear the styles. if ( HasTroubleWithNonTopTabs() && (style & (wxBK_BOTTOM | wxBK_LEFT | wxBK_RIGHT)) ) { // check if we use themes at all -- if we don't, we're still okay if ( wxUxThemeEngine::GetIfActive() ) { wxUxThemeEngine::GetIfActive()->SetWindowTheme(GetHwnd(), L"", L""); // correct the background color for the new non-themed control SetBackgroundColour(GetThemeBackgroundColour()); } } #endif // wxUSE_UXTHEME // Undocumented hack to get flat notebook style // In fact, we should probably only do this in some // curcumstances, i.e. if we know we will have a border // at the bottom (the tab control doesn't draw it itself) #if defined(__POCKETPC__) || defined(__SMARTPHONE__) if (HasFlag(wxNB_FLAT)) { SendMessage(GetHwnd(), CCM_SETVERSION, COMCTL32_VERSION, 0); if (!m_hasBgCol) SetBackgroundColour(*wxWHITE); } #endif return true; }
ALERROR CDockPane::CreateControls (CString *retsError) // CreateControls // // Creates controls based on the pane descriptor. We assume that m_pContainer has // already been created and is empty. { int i; // If there is a <Controls> element then use that to figure out what to // create. CXMLElement *pControls = m_pPaneDesc->GetContentElementByTag(CONTROLS_TAG); if (pControls) { for (i = 0; i < pControls->GetContentElementCount(); i++) { CXMLElement *pControlDef = pControls->GetContentElement(i); // Figure out the type EControlTypes iType; if (strEquals(pControlDef->GetTag(), COUNTER_TAG)) iType = controlCounter; else if (strEquals(pControlDef->GetTag(), ITEM_DISPLAY_TAG)) iType = controlItemDisplay; else if (strEquals(pControlDef->GetTag(), TEXT_TAG)) iType = controlDesc; else if (strEquals(pControlDef->GetTag(), TEXT_INPUT_TAG)) iType = controlTextInput; else { *retsError = strPatternSubst(CONSTLIT("Unknown control element: <%s>."), pControlDef->GetTag()); return ERR_FAIL; } // Get the ID CString sID; if (!pControlDef->FindAttribute(ID_ATTRIB, &sID)) { *retsError = strPatternSubst(CONSTLIT("Missing ID attrib for control element: <%s>."), pControlDef->GetTag()); return ERR_FAIL; } // Create the control CreateControl(iType, sID); } } // Otherwise we create default controls else { // Create the text description control CreateControl(controlDesc, DEFAULT_DESC_ID); // Create counter or input fields if (m_pPaneDesc->GetAttributeBool(SHOW_COUNTER_ATTRIB)) CreateControl(controlCounter, DEFAULT_COUNTER_ID); else if (m_pPaneDesc->GetAttributeBool(SHOW_TEXT_INPUT_ATTRIB)) CreateControl(controlTextInput, DEFAULT_TEXT_INPUT_ID); } return NOERROR; }
bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, const wxString& value, 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; PreCreation(); m_tempCallbackStruct = NULL; m_modified = false; m_processedDefault = false; Widget parentWidget = (Widget) parent->GetClientWidget(); Bool wantHorizScroll = (m_windowStyle & wxHSCROLL) != 0 ? True : False; // If we don't have horizontal scrollbars, we want word wrap. // OpenMotif 2.1 crashes if wantWordWrap is True in Japanese // locale (and probably other multibyte locales). The check might be // more precise #if wxCHECK_LESSTIF() || wxCHECK_MOTIF_VERSION( 2, 2 ) Bool wantWordWrap = wantHorizScroll == True ? False : True; #else Bool wantWordWrap = False; #endif if (m_windowStyle & wxTE_MULTILINE) { Arg args[8]; int count = 0; XtSetArg (args[count], XmNscrollHorizontal, wantHorizScroll); ++count; if( m_font.IsOk() ) XtSetArg (args[count], (String) wxFont::GetFontTag(), m_font.GetFontType( XtDisplay(parentWidget) ) ); ++count; XtSetArg (args[count], XmNwordWrap, wantWordWrap); ++count; XtSetArg (args[count], XmNvalue, (const char*)value.mb_str()); ++count; XtSetArg (args[count], XmNeditable, style & wxTE_READONLY ? False : True); ++count; XtSetArg (args[count], XmNeditMode, XmMULTI_LINE_EDIT ); ++count; m_mainWidget = (WXWidget) XmCreateScrolledText(parentWidget, name.char_str(), args, count); XtManageChild ((Widget) m_mainWidget); } else { m_mainWidget = (WXWidget)XtVaCreateManagedWidget ( name.mb_str(), xmTextWidgetClass, parentWidget, wxFont::GetFontTag(), m_font.GetFontType( XtDisplay(parentWidget) ), XmNvalue, (const char*)value.mb_str(), XmNeditable, (style & wxTE_READONLY) ? False : True, NULL ); #if 0 // TODO: Is this relevant? What does it do? int noCols = 2; if (!value.empty() && (value.length() > (unsigned int) noCols)) noCols = value.length(); XtVaSetValues((Widget) m_mainWidget, XmNcolumns, noCols, NULL); #endif } // remove border if asked for if ( style & wxNO_BORDER ) { XtVaSetValues((Widget)m_mainWidget, XmNshadowThickness, 0, NULL); } // install callbacks XtAddCallback((Widget) m_mainWidget, XmNvalueChangedCallback, (XtCallbackProc)wxTextWindowChangedProc, (XtPointer)this); XtAddCallback((Widget) m_mainWidget, XmNmodifyVerifyCallback, (XtCallbackProc)wxTextWindowModifyProc, (XtPointer)this); XtAddCallback((Widget) m_mainWidget, XmNactivateCallback, (XtCallbackProc)wxTextWindowActivateProc, (XtPointer)this); XtAddCallback((Widget) m_mainWidget, XmNfocusCallback, (XtCallbackProc)wxTextWindowGainFocusProc, (XtPointer)this); XtAddCallback((Widget) m_mainWidget, XmNlosingFocusCallback, (XtCallbackProc)wxTextWindowLoseFocusProc, (XtPointer)this); PostCreation(); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); return true; }
int Create_Button_from_bmp_transHighlight(char* background_filename, char* highligted_transparent_button_filename, char* name, Sint16 x_location, Sint16 y_location, Uint16 button_width, Uint16 button_height, ButtonAction buttonFunctionPtr, control** control_toRet, char** error) { SDL_Surface* Button_Background; if (-1 == LoadBMP(background_filename, &Button_Background, error)) { *control_toRet = NULL; return -1; } SDL_Surface* Button_Highlighted; if (-1 == LoadBMP(background_filename, &Button_Highlighted, error)) { SDL_FreeSurface(Button_Background); Button_Background = NULL; *control_toRet = NULL; return -1; } SDL_Surface* TranparentHighlightedButton; if (-1 == LoadBMP(highligted_transparent_button_filename, &TranparentHighlightedButton, error)) { SDL_FreeSurface(Button_Background); Button_Background = NULL; SDL_FreeSurface(Button_Highlighted); Button_Highlighted = NULL; *control_toRet = NULL; return -1; } // Highlighting the Button Surface; if (-1 == HighlightButtonSurface(Button_Highlighted, TranparentHighlightedButton, error)) { SDL_FreeSurface(Button_Background); Button_Background = NULL; SDL_FreeSurface(Button_Highlighted); Button_Highlighted = NULL; SDL_FreeSurface(TranparentHighlightedButton); TranparentHighlightedButton = NULL; *control_toRet = NULL; return -1; } SDL_Rect* Button_Rect = malloc(sizeof(SDL_Rect)); if (Button_Rect == NULL) { SDL_FreeSurface(Button_Background); Button_Background = NULL; SDL_FreeSurface(Button_Highlighted); Button_Highlighted = NULL; SDL_FreeSurface(TranparentHighlightedButton); TranparentHighlightedButton = NULL; *control_toRet = NULL; *error = "ERROR: failed to allocate memory for SDL_Rect"; return -1; } Button_Rect->x = x_location; Button_Rect->y = y_location; Button_Rect->h = button_height; Button_Rect->w = button_width; if (-1 == CreateControl(Button_Background, Button_Highlighted, Button_Rect, name, buttonFunctionPtr, BUTTONTYPE, control_toRet, error)) { SDL_FreeSurface(Button_Background); Button_Background = NULL; SDL_FreeSurface(Button_Highlighted); Button_Highlighted = NULL; SDL_FreeSurface(TranparentHighlightedButton); TranparentHighlightedButton = NULL; free(Button_Rect); Button_Rect = NULL; return -1; } SDL_FreeSurface(TranparentHighlightedButton); TranparentHighlightedButton = NULL; return 0; }
_DZBUSxDisp __fastcall TZBUSx::GetDefaultInterface() { CreateControl(); return m_OCXIntf; };
bool wxDatePickerCtrl::Create(wxWindow *parent, wxWindowID id, const wxDateTime& dt, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { // although we already call InitCommonControls() in app.cpp which is // supposed to initialize all common controls, in comctl32.dll 4.72 (and // presumably earlier versions 4.70 and 4.71, date time picker not being // supported in < 4.70 anyhow) it does not do it and we have to initialize // it explicitly static bool s_initDone = false; // MT-ok: used from GUI thread only if ( !s_initDone ) { #ifndef __WXWINCE__ if ( wxApp::GetComCtl32Version() < 470 ) { wxLogError(_("This system doesn't support date picker control, please upgrade your version of comctl32.dll")); return false; } #endif #if wxUSE_DYNLIB_CLASS INITCOMMONCONTROLSEX icex; icex.dwSize = sizeof(icex); icex.dwICC = ICC_DATE_CLASSES; wxDynamicLibrary dllComCtl32( #ifdef __WXWINCE__ _T("commctrl.dll") #else _T("comctl32.dll") #endif , wxDL_VERBATIM); if ( dllComCtl32.IsLoaded() ) { typedef BOOL (WINAPI *ICCEx_t)(INITCOMMONCONTROLSEX *); wxDYNLIB_FUNCTION( ICCEx_t, InitCommonControlsEx, dllComCtl32 ); if ( pfnInitCommonControlsEx ) { (*pfnInitCommonControlsEx)(&icex); } s_initDone = true; } #endif } // use wxDP_SPIN if wxDP_DEFAULT (0) was given as style if ( !(style & wxDP_DROPDOWN) ) style |= wxDP_SPIN; // initialize the base class if ( !CreateControl(parent, id, pos, size, style, validator, name) ) return false; // create the native control if ( !MSWCreateControl(DATETIMEPICK_CLASS, wxEmptyString, pos, size) ) return false; if ( dt.IsValid() || (style & wxDP_ALLOWNONE) ) SetValue(dt); else SetValue(wxDateTime::Today()); return true; }
CWndControl* CWndWindow::CreateControl(int type, const QPoint& pos) { ControlData* controlData = new ControlData(); controlData->tiles = false; controlData->texture = ""; controlData->text = ""; controlData->rect = QRect(pos, QSize(30, 30)); controlData->flags = WBS_CHILD; switch (type) { case CREATECTRL_TEXT: controlData->define = "WIDC_TEXT"; controlData->type = WTYPE_TEXT; controlData->text = "Text"; controlData->texture = "WndEditTile00.tga"; controlData->tiles = true; controlData->rect.setSize(QSize(80, 40)); #if __VER >= 19 controlData->color = QColor(255, 255, 255); #endif break; case CREATECTRL_PICTURE: controlData->define = "WIDC_STATIC1"; controlData->type = WTYPE_STATIC; controlData->text = "Picture"; controlData->flags |= WBS_NOFRAME; controlData->flags |= WSS_PICTURE; controlData->rect.setSize(QSize(128, 128)); #if __VER >= 19 controlData->color = QColor(246, 204, 77); #endif break; case CREATECTRL_STATIC: controlData->define = "WIDC_STATIC"; controlData->type = WTYPE_STATIC; controlData->text = "Static"; controlData->flags |= WBS_NOFRAME; controlData->rect.setSize(QSize(40, 20)); #if __VER >= 19 controlData->color = QColor(246, 204, 77); #endif break; case CREATECTRL_TEXTEDIT: controlData->define = "WIDC_EDIT"; controlData->type = WTYPE_EDITCTRL; controlData->tiles = true; controlData->rect.setSize(QSize(120, 20)); #if __VER >= 19 controlData->color = QColor(255, 255, 255); #endif break; case CREATECTRL_GROUPBOX: controlData->define = "WIDC_GROUPBOX"; controlData->type = WTYPE_STATIC; controlData->text = "GroupBox"; controlData->flags |= WBS_NOFRAME; controlData->flags |= WSS_GROUPBOX; controlData->rect.setSize(QSize(128, 128)); #if __VER >= 19 controlData->color = QColor(246, 204, 77); #endif break; case CREATECTRL_BUTTON: controlData->define = "WIDC_BUTTON"; controlData->type = WTYPE_BUTTON; controlData->text = "Button"; controlData->flags |= WBS_NOFRAME; controlData->flags |= WBS_HIGHLIGHT; controlData->rect.setSize(QSize(80, 25)); #if __VER >= 19 controlData->color = QColor(0, 0, 0); #endif break; case CREATECTRL_CHECKBOX: controlData->define = "WIDC_CHECK"; controlData->type = WTYPE_BUTTON; controlData->text = "CheckBox"; controlData->flags |= WBS_NOFRAME; controlData->flags |= WBS_CHECK; controlData->rect.setSize(QSize(80, 15)); #if __VER >= 19 controlData->color = QColor(255, 249, 198); #endif break; case CREATECTRL_RADIO: controlData->define = "WIDC_RADIO"; controlData->type = WTYPE_BUTTON; controlData->text = "Radio"; controlData->flags |= WBS_NOFRAME; controlData->flags |= WBS_RADIO; controlData->rect.setSize(QSize(80, 15)); #if __VER >= 19 controlData->color = QColor(255, 249, 198); #endif break; case CREATECTRL_COMBOBOX: controlData->define = "WIDC_COMBOBOX"; controlData->type = WTYPE_COMBOBOX; controlData->rect.setSize(QSize(120, 20)); controlData->texture = "WndEditTile00.tga"; controlData->tiles = true; #if __VER >= 19 controlData->color = QColor(255, 255, 255); #endif break; case CREATECTRL_LISTBOX: controlData->define = "WIDC_LISTBOX"; controlData->type = WTYPE_LISTBOX; controlData->rect.setSize(QSize(100, 120)); controlData->texture = "WndEditTile00.tga"; controlData->tiles = true; controlData->flags |= WBS_VSCROLL; #if __VER >= 19 controlData->color = QColor(255, 255, 255); #endif break; case CREATECTRL_LISTCTRL: controlData->define = "WIDC_LISTCTRL"; controlData->type = WTYPE_LISTCTRL; controlData->rect.setSize(QSize(100, 120)); #if __VER >= 19 controlData->color = QColor(255, 255, 255); #endif break; case CREATECTRL_TREECTRL: controlData->define = "WIDC_TREECTRL"; controlData->type = WTYPE_TREECTRL; controlData->rect.setSize(QSize(100, 120)); controlData->texture = "WndEditTile00.tga"; controlData->tiles = true; controlData->flags |= WBS_VSCROLL; #if __VER >= 19 controlData->color = QColor(255, 255, 255); #endif break; case CREATECTRL_TABCTRL: controlData->define = "WIDC_TABCTRL"; controlData->type = WTYPE_TABCTRL; controlData->rect.setSize(QSize(119, 120)); controlData->flags |= WBS_NOFRAME; controlData->flags |= WBS_NODRAWFRAME; #if __VER >= 19 controlData->color = QColor(255, 255, 255); #endif break; case CREATECTRL_CUSTOM: controlData->define = "WIDC_CUSTOM"; controlData->type = WTYPE_CUSTOM; controlData->rect.setSize(QSize(64, 64)); controlData->flags |= WBS_NOFRAME; controlData->flags |= WBS_NODRAWFRAME; #if __VER >= 19 controlData->color = QColor(46, 112, 169); #endif break; } int id = 0; ControlData* ctrl = null; for (int i = 0; i < m_data->controls.GetSize(); i++) { ctrl = m_data->controls[i]; if (ctrl->define.startsWith(controlData->define)) { string define = ctrl->define; define = define.remove(controlData->define); define = define.trimmed(); if (define.isEmpty() && id == 0) id = 1; else { bool ok = false; const int temp = define.toInt(&ok); if (ok) { if (temp >= id) id = temp + 1; } } } } if (id > 0) controlData->define += string::number(id); controlData->ID = DataMng->GetControlID(controlData->define); controlData->textID = DataMng->GetNewText(controlData->text); controlData->tooltip = ""; controlData->tooltipID = DataMng->GetNewText(controlData->tooltip); controlData->disabled = false; controlData->group = false; controlData->visible = false; controlData->tabStop = false; m_data->controls.Append(controlData); return CreateControl(controlData); }