void CXTPPropertyGridInplaceList::Apply() { int nIndex = GetCurSel(); if (nIndex != LB_ERR && m_pItem) { CXTPPropertyGridItemConstraint* pConstraint = (CXTPPropertyGridItemConstraint*)GetItemDataPtr(nIndex); if (pConstraint && !pConstraint->m_bEnabled) return; CXTPPropertyGridItem* pItem = m_pItem; m_pItem = NULL; CXTPPropertyGridItemConstraints* pList = pItem->GetConstraints(); pList->SetCurrent(nIndex); CString str; GetText(nIndex, str); if (pItem->OnAfterEdit(str) && str != pItem->GetValue()) pItem->OnValueChanged(str); } if (m_hWnd && ::GetFocus() == m_hWnd) { GetOwner()->SetFocus(); } }
void PropertyPaneParticle::_UpdateProperty( int id ) { if(id < propDerivedStart) { __super::_UpdateProperty(id); return; } ManipulatorEffect& manEffect = ManipulatorSystem.GetEffect(); std::string strNewValue; switch (id) { case propParticle: { const auto names = manEffect.GetParticleTmpNames(); CXTPPropertyGridItemConstraints* pList = m_mapItem[propParticle]->GetConstraints(); pList->RemoveAll(); for (size_t i=0; i<names.size(); ++i) pList->AddConstraint(names[i].c_str()); strNewValue = manEffect.GetEffectParam("template"); } break; default: assert(0); } std::wstring wcsNewValue = Utility::EngineToUnicode(strNewValue); m_mapItem[id]->SetValue(wcsNewValue.c_str()); }
void CXTPPropertyGridItemFlags::SetValue(CString strValue) { int nValue = 0; strValue.MakeLower(); CXTPPropertyGridItemConstraints* pConstraints = GetConstraints(); for (int i = 0; i < pConstraints->GetCount(); i++) { if (HasFlag(strValue, pConstraints->GetAt(i))) nValue |= pConstraints->GetConstraintAt(i)->m_dwData; } SetFlags(nValue); }
void CXTPPropertyGridItemFlags::OnConstraintsChanged() { GetChilds()->Clear(); CXTPPropertyGridItemConstraints* pConstraints = GetConstraints(); int i; for (i = 0; i < pConstraints->GetCount(); i++) { AddChildItem(new CXTPPropertyGridItemFlag(pConstraints->GetAt(i), (int)pConstraints->GetConstraintAt(i)->m_dwData)); } UpdateChilds(); m_strDefaultValue = m_strValue = GetFlagsString(); CXTPPropertyGridItems* pItems = GetChilds(); for (i = 0; i < pItems->GetCount(); i++) { CXTPPropertyGridItemFlag* pItem = (CXTPPropertyGridItemFlag*)pItems->GetAt(i); pItem->SetDefaultValue(pItem->GetValue()); } }
CString CXTPPropertyGridItemFlags::GetFlagsString() { CString str; CXTPPropertyGridItemConstraints* pConstraints = GetConstraints(); int nValue = 0; for (int i = 0; i < pConstraints->GetCount(); i++) { CXTPPropertyGridItemConstraint* pConstraint = pConstraints->GetConstraintAt(i); if ((nValue & pConstraint->m_dwData) == pConstraint->m_dwData) continue; if ((m_nValue & pConstraint->m_dwData) == pConstraint->m_dwData) { str += (str.IsEmpty() ? _T("") : _T(";")) + pConstraint->m_strConstraint; nValue |= pConstraint->m_dwData; } } return _T("[") + str + _T("]"); }
void CXTPPropertyGridInplaceList::Create(CXTPPropertyGridItem* pItem, CRect rect) { ASSERT(pItem && pItem->GetGrid()); if (!pItem) return; CRect rcValue(rect); rcValue.left = pItem->GetGrid()->GetDividerPos() + 1; CWnd* pParent = (CWnd*)pItem->GetGrid(); m_pItem = pItem; DestroyWindow(); if (!m_hWnd) { CListBox::CreateEx(WS_EX_TOOLWINDOW | (pParent->GetExStyle() & WS_EX_LAYOUTRTL), _T("LISTBOX"), _T(""), LBS_NOTIFY | WS_CHILD | WS_VSCROLL | WS_BORDER | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS, CRect(0, 0, 0, 0), pParent, 0); SetOwner(pParent); if (m_bShowShadow && XTPSystemVersion()->IsWinXPOrGreater()) SetClassLongPtr(m_hWnd, GCL_STYLE, GetClassLongPtr(m_hWnd, GCL_STYLE) | 0x00020000); } SetFont(pParent->GetFont()); ResetContent(); CXTPPropertyGridItemConstraints* pList = pItem->GetConstraints(); int dx = rect.right - rcValue.left; CWindowDC dc(pParent); CXTPFontDC font(&dc, pParent->GetFont()); int nHeight = dc.GetTextExtent(_T(" "), 1).cy + 3; for (int i = 0; i < pList->GetCount(); i++) { CXTPPropertyGridItemConstraint* pConstraint = pList->GetConstraintAt(i); CString str = pConstraint->m_strConstraint; int nIndex = AddString(str); SetItemDataPtr(nIndex, pConstraint); CSize sz = pItem->OnMergeItemConstraint(&dc, pConstraint); dx = max(dx, sz.cx); nHeight = max(nHeight, sz.cy); if (pItem->GetValue() == str) SetCurSel(nIndex); } SetItemHeight(0, nHeight); rect.top = rect.bottom; rect.bottom += nHeight * __min(pItem->GetDropDownItemCount(), GetCount()) + 2; rect.left = rect.right - __min(dx, rect.Width() - XTP_PGI_EXPAND_BORDER); pParent->ClientToScreen(&rect); CRect rcWork = XTPMultiMonitor()->GetWorkArea(rect); if (rect.bottom > rcWork.bottom && rect.top > rcWork.CenterPoint().y) { rect.OffsetRect(0, - rect.Height() - rcValue.Height() - 1); } if (rect.left < rcWork.left) rect.OffsetRect(rcWork.left - rect.left, 0); if (rect.right > rcWork.right) rect.OffsetRect(rcWork.right - rect.right, 0); SetFocus(); SetWindowLongPtr(m_hWnd, GWLP_HWNDPARENT, 0); ModifyStyle(WS_CHILD, WS_POPUP); SetWindowLongPtr(m_hWnd, GWLP_HWNDPARENT, (LONG_PTR)pParent->m_hWnd); SetWindowPos(&CWnd::wndTopMost, rect.left, rect.top, rect.Width(), rect.Height(), SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOOWNERZORDER); CXTPMouseMonitor::SetupHook(this); }
VOID KSceneSettingDialogV2::InitGrid() { // Add "About..." menu item to system menu. #if 1 // get the size of the place holder, this will be used when creating the grid. CRect rc(0,0,100,100); { HWND hWnd = NULL; this->GetDlgItem(IDC_CUSTOM1, &hWnd); if (NULL != hWnd) { ::GetWindowRect(hWnd, &rc); ScreenToClient(&rc); ::ShowWindow(hWnd, SW_HIDE); } } // create the property grid. if ( m_Grid.Create( rc, this, IDC_SCENESETTING_GRID) ) { LOGFONT lf; GetFont()->GetLogFont( &lf ); // create document settings category. CXTPPropertyGridItem* pSettings = m_Grid.AddCategory(_T("Document Settings")); // add child items to category. CXTPPropertyGridItem* pItemSaveOnClose = pSettings->AddChildItem(new CXTPPropertyGridItemBool(_T("SaveOnClose"), TRUE)); pSettings->AddChildItem(new CXTPPropertyGridItemFont(_T("WindowFont"), lf)); pSettings->AddChildItem(new CXTPPropertyGridItemSize(_T("WindowSize"), CSize(100, 100))); pSettings->Expand(); pItemSaveOnClose->Select(); // create global settings category. CXTPPropertyGridItem* pGlobals = m_Grid.AddCategory(_T("Global Settings")); // add child items to category. CXTPPropertyGridItem* pItemGreeting = pGlobals->AddChildItem(new CXTPPropertyGridItem(_T("Greeting Text"), _T("Welcome to your application!"))); pGlobals->AddChildItem(new CXTPPropertyGridItemNumber(_T("ItemsInMRUList"), 4)); CXTPPropertyGridItem* pItemRate = pGlobals->AddChildItem(new CXTPPropertyGridItemNumber(_T("MaxRepeatRate"), 10)); pGlobals->AddChildItem(new CXTPPropertyGridItemColor(_T("ToolbarColor"), RGB(255, 192,128))); pItemGreeting->SetReadOnly(TRUE); pItemRate->SetDescription(_T("The rate in milliseconds that the text will repeat.")); // create version category. CXTPPropertyGridItem* pVersion = m_Grid.AddCategory(_T("Version")); // add child items to category. CXTPPropertyGridItem* pItemVersion = pVersion->AddChildItem(new CXTPPropertyGridItem(_T("AppVerion"), _T("1.0"))); CXTPPropertyGridItem* pItemLanguage = pVersion->AddChildItem(new CXTPPropertyGridItem(IDC_COMBO1, _T("English (United States)"))); pItemVersion->SetReadOnly(TRUE); pVersion->Expand(); CXTPPropertyGridItemConstraints* pList = pItemLanguage->GetConstraints(); pList->AddConstraint(_T("Neutral")); pList->AddConstraint(_T("Arabic")); pList->AddConstraint(_T("German")); pList->AddConstraint(_T("Chinese(Taiwan)")); pList->AddConstraint(_T("English (United Kingdom)")); pList->AddConstraint(_T("English (United States)")); pList->AddConstraint(_T("France")); pList->AddConstraint(_T("Russian")); pItemLanguage->SetFlags(xtpGridItemHasComboButton | xtpGridItemHasEdit); // create standard items category. CXTPPropertyGridItem* pStandard = m_Grid.AddCategory(_T("Standard Items")); pStandard->AddChildItem(new CXTPPropertyGridItem(_T("String item"))); pStandard->AddChildItem(new CXTPPropertyGridItemNumber(_T("Integer item"))); pStandard->AddChildItem(new CXTPPropertyGridItemDouble(_T("Double item"))); pStandard->AddChildItem(new CXTPPropertyGridItemColor(_T("Color item"))); pStandard->AddChildItem(new CXTPPropertyGridItemBool(_T("Bool item"))); pStandard->AddChildItem(new CXTPPropertyGridItemFont(_T("Font item"), lf)); COleDateTime dates(1981, 1, 26, 0, 0, 0 ); pStandard->AddChildItem(new CXTPPropertyGridItemDate(_T("Date item"), dates)); pStandard->AddChildItem(new CXTPPropertyGridItemSize(_T("Size item"))); CXTPPropertyGridItem* pItem = pStandard->AddChildItem(new CXTPPropertyGridItemEnum(_T("Enum item"), 2)); pItem->GetConstraints()->AddConstraint(_T("Windows 98"), 1); pItem->GetConstraints()->AddConstraint(_T("Windows 2000"), 2); pItem->GetConstraints()->AddConstraint(_T("Windows XP"), 3); pItem = pStandard->AddChildItem(new CXTPPropertyGridItemFlags(_T("Flag item"), 1 + 2)); pItem->GetConstraints()->AddConstraint(_T("All Windows"), 1 + 2 + 4); pItem->GetConstraints()->AddConstraint(_T("Windows 98"), 1); pItem->GetConstraints()->AddConstraint(_T("Windows 2000"), 2); pItem->GetConstraints()->AddConstraint(_T("Windows XP"), 4); // create custom items category. //CXTPPropertyGridItem* pCustom = m_Grid.AddCategory(_T("Custom Items")); //// add child items to category. //CXTPPropertyGridItem* pItemIcon = pCustom->AddChildItem(new CCustomItemIcon(_T("Icon"), m_hIcon)); //CXTPPropertyGridItem* pItemDock = pCustom->AddChildItem(new CCustomItemChilds(_T("DockPadding"), CRect(100, 20, 400, 50))); //pCustom->AddChildItem(new CCustomItemColor(_T("CustomCombolist"), RGB(0xFF, 0x80, 0x40))); //pItemIcon->SetDescription(_T("This sample shows how to override draw function")); //pItemDock->SetDescription(_T("This sample shows how to add item with childs")); //CXTPPropertyGridItem* pItemSpin = pCustom->AddChildItem(new CCustomItemSpin(_T("SpinButton"))); //pItemSpin->SetDescription(_T("This sample shows how to add new button type")); } //#ifdef _XTP_INCLUDE_CONTROLS // // Set control resizing. // SetResize(IDC_PROPERTY_GRID, SZ_TOP_LEFT, SZ_BOTTOM_RIGHT); // // SetResize(IDC_GBOX_APPEAR, SZ_TOP_RIGHT, SZ_TOP_RIGHT); // SetResize(IDC_CHK_TOOLBAR, SZ_TOP_RIGHT, SZ_TOP_RIGHT); // SetResize(IDC_CHK_HELP, SZ_TOP_RIGHT, SZ_TOP_RIGHT); // SetResize(IDC_CHK_DOUBLE, SZ_TOP_RIGHT, SZ_TOP_RIGHT); // SetResize(IDC_CHK_TABITEMS, SZ_TOP_RIGHT, SZ_TOP_RIGHT); // SetResize(IDC_COMBO_THEME, SZ_TOP_RIGHT, SZ_TOP_RIGHT); // SetResize(IDC_GBOX_SORT, SZ_TOP_RIGHT, SZ_TOP_RIGHT); // SetResize(IDC_SORT_CATEGORIES, SZ_TOP_RIGHT, SZ_TOP_RIGHT); // SetResize(IDC_SORT_ALPHABETICAL, SZ_TOP_RIGHT, SZ_TOP_RIGHT); // SetResize(IDC_SORT_NOSORT, SZ_TOP_RIGHT, SZ_TOP_RIGHT); // SetResize(IDC_GBOX_COLOR, SZ_TOP_RIGHT, SZ_TOP_RIGHT); // SetResize(IDC_CHK_CUSTOMCOLORS, SZ_TOP_RIGHT, SZ_TOP_RIGHT); // SetResize(IDC_BUTTON_SWITCHSTATE, SZ_TOP_RIGHT, SZ_TOP_RIGHT); // // // Load window placement // AutoLoadPlacement(_T("CPropertyGridDlg")); //#endif // // m_cmbTheme.AddString(_T("Default")); // m_cmbTheme.AddString(_T("NativeWinXP")); // m_cmbTheme.AddString(_T("Office2003")); // m_cmbTheme.AddString(_T("Cool")); // m_cmbTheme.AddString(_T("Simple")); // m_cmbTheme.AddString(_T("Delphi")); // m_cmbTheme.AddString(_T("Whidbey")); // m_cmbTheme.SetCurSel(0); #endif }