diff --git a/PropertyWindow.cpp b/PropertyWindow.cpp index 6afce7a..023bb5a 100644 --- a/PropertyWindow.cpp +++ b/PropertyWindow.cpp @@ -112,19 +112,14 @@ LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) // Get and display the text for the list item. int mul = 0; SendMessage(lpdis->hwndItem, CB_GETLBTEXT, lpdis->itemID, (LPARAM) achTemp); - if(lpdis->itemID == 0) + + if(lpdis->itemID >= 0) { - mul = selectedInstance->listicon; + mul = children[lpdis->itemID]->listicon; } - else if(lpdis->itemID == 1 && parent != NULL) - { - mul = parent->listicon; - } - else if(parent != NULL) - { - mul = children[lpdis->itemID-2]->listicon; - } - else mul = children[lpdis->itemID-1]->listicon; + //else mul = children[lpdis->itemID-1]->listicon; + + //mul = children[lpdis->itemID]->listicon; hr = StringCchLength(achTemp, 256, &cch); if (FAILED(hr)) @@ -181,32 +176,8 @@ LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) int ItemIndex = SendMessage((HWND) lParam, (UINT) CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0); CHAR ListItem[256]; SendMessage((HWND) lParam, (UINT) CB_GETLBTEXT, (WPARAM) ItemIndex, (LPARAM) ListItem); - if(ItemIndex != 0) - { - propWind->ClearProperties(); - while(g_selectedInstances.size() != 0) - g_selectedInstances.erase(g_selectedInstances.begin()); - if(parent != NULL) - { - std::cout << ItemIndex << std::endl; - if(ItemIndex == 1) - { - g_selectedInstances.push_back(parent); - propWind->SetProperties(parent); - } - else - { - g_selectedInstances.push_back(children.at(ItemIndex+2)); - propWind->SetProperties(children.at(ItemIndex+2)); - } - - } - else - { - g_selectedInstances.push_back(children.at(ItemIndex-1)); - propWind->SetProperties(children.at(ItemIndex-1)); - } - } + propWind->ClearProperties(); + propWind->UpdateSelected(children.at(ItemIndex)); } } break; @@ -222,7 +193,7 @@ LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) LPNMPROPGRID lpnmp = (LPNMPROPGRID)pnm; LPPROPGRIDITEM item = PropGrid_GetItemData(pnm->hwndFrom,lpnmp->iIndex); selectedInstance->PropUpdate(item); - //propWind->SetProperties(selectedInstance); + //propWind->UpdateSelected(selectedInstance); } } break; @@ -236,28 +207,35 @@ LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) return 0; } -void PropertyWindow::refreshExplorer() +void PropertyWindow::refreshExplorer(Instance* selectedInstance) { SendMessage(_explorerComboBox,CB_RESETCONTENT,0,0); parent = NULL; - for (unsigned int i=0;iname.c_str()); - if(g_selectedInstances[i]->getParent() != NULL) - { - std::string title = ".. ("; - title += g_selectedInstances[i]->getParent()->name; - title += ")"; - SendMessage(_explorerComboBox,CB_ADDSTRING, 0,(LPARAM)title.c_str()); - parent = g_selectedInstances[i]->getParent(); - } - children = g_selectedInstances[i]->getChildren(); - for(size_t z = 0; z < children.size(); z++) - { - SendMessage(_explorerComboBox,CB_ADDSTRING, 0,(LPARAM)children.at(z)->name.c_str()); - } - SendMessage(_explorerComboBox,CB_SETCURSEL,0,(LPARAM)0); + children.clear(); + g_selectedInstances.clear(); + //for (unsigned int i=0;iname.c_str()); + if(selectedInstance->getParent() != NULL) + { + std::string title = ".. ("; + title += selectedInstance->getParent()->name; + title += ")"; + SendMessage(_explorerComboBox,CB_ADDSTRING, 0,(LPARAM)title.c_str()); + parent = selectedInstance->getParent(); + children.push_back(selectedInstance->getParent()); } + //children = g_selectedInstances[i]->getChildren(); + + std::vector selectedChildren = selectedInstance->getChildren(); + for(size_t z = 0; z < selectedChildren.size(); z++) + { + children.push_back(selectedChildren.at(z)); + SendMessage(_explorerComboBox,CB_ADDSTRING, 0,(LPARAM)selectedChildren.at(z)->name.c_str()); + } + g_selectedInstances.push_back(selectedInstance); + SendMessage(_explorerComboBox,CB_SETCURSEL,0,(LPARAM)0); + //} } bool PropertyWindow::onCreate(int x, int y, int sx, int sy, HMODULE hThisInstance) { @@ -341,7 +319,7 @@ bool PropertyWindow::onCreate(int x, int y, int sx, int sy, HMODULE hThisInstanc SetWindowLongPtr(_hwndProp,GWL_USERDATA,(LONG)this); - refreshExplorer(); + //refreshExplorer(); _resize(); return true; @@ -364,7 +342,7 @@ void PropertyWindow::_resize() SetWindowPos(_explorerComboBox, NULL, 0, 0, rect.right, 400, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); } -void PropertyWindow::SetProperties(Instance * instance) +void PropertyWindow::UpdateSelected(Instance * instance) { PropGrid_ResetContent(_propGrid); prop = instance->getProperties(); @@ -380,7 +358,7 @@ void PropertyWindow::SetProperties(Instance * instance) PropGrid_ExpandAllCatalogs(_propGrid); //SetWindowLongPtr(_propGrid,GWL_USERDATA,(LONG)this); - refreshExplorer(); + refreshExplorer(instance); _resize(); } diff --git a/PropertyWindow.h b/PropertyWindow.h index 3479589..568a0f8 100644 --- a/PropertyWindow.h +++ b/PropertyWindow.h @@ -4,10 +4,10 @@ class PropertyWindow { public: PropertyWindow(int x, int y, int sx, int sy, HMODULE hThisInstance); bool onCreate(int x, int y, int sx, int sy, HMODULE hThisInstance); - void SetProperties(Instance *); + void UpdateSelected(Instance *); void ClearProperties(); void onResize(); - void refreshExplorer(); + void refreshExplorer(Instance* selectedInstance); HWND _hwndProp; private: HWND _propGrid; diff --git a/main.cpp b/main.cpp index f260bec..1fd4dfe 100644 --- a/main.cpp +++ b/main.cpp @@ -276,7 +276,7 @@ void GUDButtonListener::onButton1MouseClick(BaseButtonInstance* button) } g_selectedInstances = newinst; if(g_selectedInstances.size() > 0) - usableApp->_propWindow->SetProperties(newinst.at(0)); + usableApp->_propWindow->UpdateSelected(newinst.at(0)); } } } @@ -1380,11 +1380,11 @@ void Demo::onMouseLeftPressed(HWND hwnd,int x,int y) } } if(!found) - {while(g_selectedInstances.size() > 0) - g_selectedInstances.erase(g_selectedInstances.begin()); - g_selectedInstances.push_back(test); + { + g_selectedInstances.clear(); + g_selectedInstances.push_back(test); } - _propWindow->SetProperties(test); + _propWindow->UpdateSelected(test); //message = "Dragging = true."; //messageTime = System::time(); //dragging = true; @@ -1394,10 +1394,9 @@ void Demo::onMouseLeftPressed(HWND hwnd,int x,int y) } if(!objFound) { - while(g_selectedInstances.size() > 0) - g_selectedInstances.erase(g_selectedInstances.begin()); + g_selectedInstances.clear(); g_selectedInstances.push_back(dataModel); - _propWindow->SetProperties(dataModel); + _propWindow->UpdateSelected(dataModel); } }