#ifndef __GENERICDATAVIEW_H__ #define __GENERICDATAVIEW_H__ #include "WindowsSupport/WindowsSupport.pkg" #include "DeviceInterface/DeviceInterface.pkg" #include "GenericDataViewPresenter.h" #include #include class GenericDataView :public ViewBase { public: // Constructors GenericDataView(IUIManager& uiManager, GenericDataViewPresenter& presenter, IGenericAccess& model, const IGenericAccessPage* page); protected: // Member window procedure virtual LRESULT WndProcWindow(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); private: // Structures struct ExpandStateInfo { unsigned int collectionEntryCount; std::wstring collectionKeyAsString; bool expanded; }; struct ParentCollectionInfo { ParentCollectionInfo(const IGenericAccessGroupCollectionEntry* acollection, const std::wstring& achildKey, const IGenericAccessGroupEntry* achildEntry) :collection(acollection), childKey(achildKey), childEntry(achildEntry) { } const IGenericAccessGroupCollectionEntry* collection; std::wstring childKey; const IGenericAccessGroupEntry* childEntry; }; struct GridRowInfo { const IGenericAccessGroupEntry* entry; IGenericAccessGroup::GroupEntryType entryType; bool expandState; unsigned int childEntryCount; unsigned int nestingLevel; unsigned int lastCollectionModifiedToken; std::wstring collectionEntryKey; std::list preservedExpandState; std::list parentCollectionInfo; }; struct CachedState { bool supportsLocking; bool lockedState; bool supportsHighlighting; bool highlightState; }; // Constants static const long long DataListControlID = 100; static const unsigned int NameColumnID = 1; static const unsigned int ValueColumnID = 2; private: // Event handlers LRESULT msgWM_CREATE(HWND hwnd, WPARAM wParam, LPARAM lParam); LRESULT msgWM_DESTROY(HWND hwnd, WPARAM wParam, LPARAM lParam); LRESULT msgWM_TIMER(HWND hwnd, WPARAM wParam, LPARAM lParam); LRESULT msgWM_SIZE(HWND hwnd, WPARAM wParam, LPARAM lParam); LRESULT msgWM_PAINT(HWND hwnd, WPARAM wParam, LPARAM lParam); LRESULT msgWM_COMMAND(HWND hwnd, WPARAM wParam, LPARAM lParam); LRESULT msgWM_SETFOCUS(HWND hwnd, WPARAM wParam, LPARAM lParam); LRESULT msgWM_KILLFOCUS(HWND hwnd, WPARAM wParam, LPARAM lParam); // Data update methods void PopulateDataGrid(const IGenericAccessGroupEntry* entry, unsigned int& currentRow, unsigned int indentLevel, bool addChildrenOnly, bool usePreservedExpandState, bool preservedExpandState, unsigned int preservedExpandStateCollectionEntryCount, std::list& preservedExpandStateBuffer, const std::list& parentCollectionInfo, const std::wstring& collectionEntryKey = L"", bool useNameOverride = false, const std::wstring& nameOverride = L""); void DepopulateDataGrid(unsigned int targetRowNo, bool removeChildrenOnly, std::list& preservedExpandStateBuffer); void DepopulateDataGrid(unsigned int recursionDepth, unsigned int& targetRowNo, unsigned int& rowsToRemove, bool removeChildrenOnly, std::list& preservedExpandStateBuffer); void UpdateDataGrid(unsigned int& currentRow, bool parentLockSucceeded); std::wstring BuildGroupSummaryText(const IGenericAccessGroup* currentNode); // Collection locking methods bool LockTargetRowEntry(unsigned int rowNo); void UnlockTargetRowEntry(unsigned int rowNo); private: const IGenericAccessPage* _page; GenericDataViewPresenter& _presenter; IGenericAccess& _model; std::map> _cachedStateMap; std::vector _rowInfo; HWND _hwndDataList; HFONT _valueFont; }; #endif