Beispiel #1
0
bool CWindowTreeDlg::RefreshTree()
{
    TreeView_DeleteAllItems(GetDlgItem(*this, IDC_WINDOWTREE));
    m_lastTreeItem = TVI_ROOT;
    EnumWindows(WindowEnumerator, (LPARAM)this);
    SelectTreeItem(m_SelectedWindow);
    return true;
}
Beispiel #2
0
/*
** Selects an item in the treeview.
**
*/
void CDialogManage::CTabSkins::SelectTreeItem(HWND tree, HTREEITEM item, LPCWSTR name)
{
	WCHAR buffer[MAX_PATH];
	TVITEM tvi = {0};
	tvi.mask = TVIF_TEXT;
	tvi.hItem = item;
	tvi.pszText = buffer;

	const WCHAR* pos = wcschr(name, L'\\');
	if (pos)
	{
		const int folderLen = (int)(pos - name);
		tvi.cchTextMax = folderLen + 1;		// Length of folder name plus 1 for NULL

		// Find and expand the folder
		do
		{
			TreeView_GetItem(tree, &tvi);
			if (wcsncmp(buffer, name, folderLen) == 0)
			{
				if ((item = TreeView_GetChild(tree, tvi.hItem)) != NULL)
				{
					TreeView_Expand(tree, tvi.hItem, TVE_EXPAND);
					++pos;	// Skip the slash
					SelectTreeItem(tree, item, pos);
				}

				break;
			}
		}
		while ((tvi.hItem = TreeView_GetNextSibling(tree, tvi.hItem)) != NULL);
	}
	else
	{
		tvi.cchTextMax = MAX_PATH;

		// Find and select the file
		do
		{
			TreeView_GetItem(tree, &tvi);
			if (wcscmp(buffer, name) == 0)
			{
				TreeView_Select(tree, tvi.hItem, TVGN_CARET);
				break;
			}
		}
		while ((tvi.hItem = TreeView_GetNextSibling(tree, tvi.hItem)) != NULL);
	}
}
Beispiel #3
0
INT_PTR CDialogManage::CTabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
{
	if (!m_HandleCommands)
	{
		// Values are being changed/reset, no need to apply changes
		return FALSE;
	}

	switch (LOWORD(wParam))
	{
	case IDC_MANAGESKINS_ACTIVESKINS_BUTTON:
		{
			HMENU menu = CreatePopupMenu();

			// Add active skins to menu
			std::map<std::wstring, CMeterWindow*>::const_iterator iter = Rainmeter->GetAllMeterWindows().begin();
			int index = 0;
			for ( ; iter != Rainmeter->GetAllMeterWindows().end(); ++iter)
			{
				std::wstring name = ((*iter).second)->GetFolderPath() + L'\\';
				name += ((*iter).second)->GetFileName();
				InsertMenu(menu, index, MF_BYPOSITION, ID_CONFIG_FIRST + index, name.c_str());
				++index;
			}

			if (index > 0)
			{
				RECT r;
				GetWindowRect((HWND)lParam, &r);

				// Show context menu
				TrackPopupMenu(
					menu,
					TPM_RIGHTBUTTON | TPM_LEFTALIGN,
					(*GetString(ID_STR_ISRTL) == L'1') ? r.right : r.left,
					--r.bottom,
					0,
					m_Window,
					NULL
				);
			}

			DestroyMenu(menu);
		}
		break;

	case IDC_MANAGESKINS_CREATEPACKAGE_BUTTON:
		{
			std::wstring file = Rainmeter->GetPath() + L"SkinInstaller.exe";
			RunFile(file.c_str(), L"/Packager");
		}
		break;

	case IDC_MANAGESKINS_LOAD_BUTTON:
		{
			if (!m_SkinWindow)
			{
				// Skin not active, load
				std::pair<int, int> indexes = Rainmeter->GetMeterWindowIndex(m_SkinFolderPath, m_SkinFileName);
				if (indexes.first != -1 && indexes.second != -1)
				{
					Rainmeter->ActivateSkin(indexes.first, indexes.second);

					// Fake selection change to update controls
					NMHDR nm;
					nm.code = TVN_SELCHANGED;
					nm.idFrom = IDC_MANAGESKINS_SKINS_TREEVIEW;
					nm.hwndFrom = GetDlgItem(m_Window, IDC_MANAGESKINS_SKINS_TREEVIEW);
					OnNotify(0, (LPARAM)&nm);
				}
			}
			else
			{
				m_HandleCommands = false;
				Rainmeter->DeactivateSkin(m_SkinWindow, -1);
			}
		}
		break;

	case IDC_MANAGESKINS_REFRESH_BUTTON:
		if (m_SkinWindow)
		{
			m_SkinWindow->Refresh(false);
		}
		break;

	case IDC_MANAGESKINS_EDIT_BUTTON:
		Rainmeter->EditSkinFile(m_SkinFolderPath, m_SkinFileName);
		break;

	case IDC_MANAGESKINS_X_TEXT:
		if (HIWORD(wParam) == EN_CHANGE)
		{
			WCHAR buffer[32];
			m_IgnoreUpdate = true;
			int x = (GetWindowText((HWND)lParam, buffer, 32) > 0) ? _wtoi(buffer) : 0;
			m_SkinWindow->MoveWindow(x, m_SkinWindow->GetY());

			if (x > m_SkinWindow->GetX())
			{
				_itow_s(m_SkinWindow->GetX(), buffer, 10);
				Edit_SetText((HWND)lParam, buffer);
			}
		}
		break;

	case IDC_MANAGESKINS_Y_TEXT:
		if (HIWORD(wParam) == EN_CHANGE)
		{
			WCHAR buffer[32];
			m_IgnoreUpdate = true;
			int y = (GetWindowText((HWND)lParam, buffer, 32) > 0) ? _wtoi(buffer) : 0;
			m_SkinWindow->MoveWindow(m_SkinWindow->GetX(), y);

			if (y > m_SkinWindow->GetY())
			{
				_itow_s(m_SkinWindow->GetY(), buffer, 10);
				Edit_SetText((HWND)lParam, buffer);
			}
		}
		break;

	case IDC_MANAGESKINS_LOADORDER_TEXT:
		if (HIWORD(wParam) == EN_CHANGE)
		{
			if (m_IgnoreUpdate)
			{
				// To avoid infinite loop after setting value below
				m_IgnoreUpdate = false;
			}
			else
			{
				// Convert text to number and set it to get rid of extra chars
				WCHAR buffer[32];
				int len = GetWindowText((HWND)lParam, buffer, 32);
				if ((len == 0) || (len == 1 && buffer[0] == L'-'))
				{
					// Ignore if empty or if - is only char
					break;
				}

				// Get selection
				DWORD sel = Edit_GetSel((HWND)lParam);

				// Reset value (to get rid of invalid chars)
				m_IgnoreUpdate = true;
				int value = _wtoi(buffer);

				_itow_s(value, buffer, 10);
				SetWindowText((HWND)lParam, buffer);

				// Reset selection
				Edit_SetSel((HWND)lParam, LOWORD(sel), HIWORD(sel));

				WritePrivateProfileString(m_SkinFolderPath.c_str(), L"LoadOrder", buffer, Rainmeter->GetIniFile().c_str());
				std::pair<int, int> indexes = Rainmeter->GetMeterWindowIndex(m_SkinWindow);
				if (indexes.first != -1)
				{
					Rainmeter->SetLoadOrder(indexes.first, value);

					std::multimap<int, CMeterWindow*> windows;
					Rainmeter->GetMeterWindowsByLoadOrder(windows);

					CSystem::PrepareHelperWindow();

					// Reorder window z-position to reflect load order
					std::multimap<int, CMeterWindow*>::const_iterator iter = windows.begin();
					for ( ; iter != windows.end(); ++iter)
					{
						CMeterWindow* mw = (*iter).second;
						mw->ChangeZPos(mw->GetWindowZPosition(), true);
					}
				}
			}
		}
		break;

	case IDC_MANAGESKINS_DISPLAYMONITOR_BUTTON:
		{
			HMENU menu = LoadMenu(Rainmeter->GetResourceInstance(), MAKEINTRESOURCE(IDR_SKIN_MENU));
			if (menu)
			{
				HMENU subMenu = GetSubMenu(menu, 0);	// Skin menu
				subMenu = GetSubMenu(subMenu, 4); // Settings menu
				subMenu = GetSubMenu(subMenu, 0); // Position menu
				subMenu = GetSubMenu(subMenu, 0); // Display monitor menu
				Rainmeter->CreateMonitorMenu(subMenu, m_SkinWindow);

				RECT r;
				GetWindowRect((HWND)lParam, &r);

				// Show context menu
				TrackPopupMenu(
					subMenu,
					TPM_RIGHTBUTTON | TPM_LEFTALIGN,
					(*GetString(ID_STR_ISRTL) == L'1') ? r.right : r.left,
					--r.bottom,
					0,
					m_Window,
					NULL
				);

				DestroyMenu(menu);
			}
		}
		break;

	case IDC_MANAGESKINS_DRAGGABLE_CHECKBOX:
		m_IgnoreUpdate = true;
		m_SkinWindow->SetWindowDraggable(!m_SkinWindow->GetWindowDraggable());
		break;

	case IDC_MANAGESKINS_CLICKTHROUGH_CHECKBOX:
		m_IgnoreUpdate = true;
		m_SkinWindow->SetClickThrough(!m_SkinWindow->GetClickThrough());
		break;

	case IDC_MANAGESKINS_KEEPONSCREEN_CHECKBOX:
		m_IgnoreUpdate = true;
		m_SkinWindow->SetKeepOnScreen(!m_SkinWindow->GetKeepOnScreen());
		break;

	case IDC_MANAGESKINS_SAVEPOSITION_CHECKBOX:
		m_IgnoreUpdate = true;
		m_SkinWindow->SetSavePosition(!m_SkinWindow->GetSavePosition());
		break;

	case IDC_MANAGESKINS_SNAPTOEDGES_CHECKBOX:
		m_IgnoreUpdate = true;
		m_SkinWindow->SetSnapEdges(!m_SkinWindow->GetSnapEdges());
		break;

	case IDC_MANAGESKINS_ZPOSITION_COMBOBOX:
		if (HIWORD(wParam) == CBN_SELCHANGE)
		{
			m_IgnoreUpdate = true;
			ZPOSITION zpos = (ZPOSITION)(ComboBox_GetCurSel((HWND)lParam) - 2);
			m_SkinWindow->SetWindowZPosition(zpos);
		}
		break;

	case IDC_MANAGESKINS_TRANSPARENCY_COMBOBOX:
		if (HIWORD(wParam) == CBN_SELCHANGE)
		{
			m_IgnoreUpdate = true;
			int sel = ComboBox_GetCurSel((HWND)lParam) + IDM_SKIN_TRANSPARENCY_0;
			SendMessage(m_SkinWindow->GetWindow(), WM_COMMAND, sel, 0);
		}
		break;

	case IDC_MANAGESKINS_ONHOVER_COMBOBOX:
		if (HIWORD(wParam) == CBN_SELCHANGE)
		{
			m_IgnoreUpdate = true;
			HIDEMODE hide = (HIDEMODE)ComboBox_GetCurSel((HWND)lParam);
			m_SkinWindow->SetWindowHide(hide);
		}
		break;

	case IDM_MANAGESKINSMENU_EXPAND:
		{
			HWND tree = GetDlgItem(m_Window, IDC_MANAGESKINS_SKINS_TREEVIEW);
			HTREEITEM item = TreeView_GetSelection(tree);
			TreeView_Expand(tree, item, TVE_TOGGLE);
		}
		break;

	case IDM_MANAGESKINSMENU_OPENFOLDER:
		{
			HWND tree = GetDlgItem(m_Window, IDC_MANAGESKINS_SKINS_TREEVIEW);
			Rainmeter->OpenSkinFolder(GetTreeSelectionPath(tree));
		}
		break;

	default:
		if (wParam >= ID_CONFIG_FIRST && wParam <= ID_CONFIG_LAST)
		{
			std::map<std::wstring, CMeterWindow*>::const_iterator iter = Rainmeter->GetAllMeterWindows().begin();
			int index = (int)wParam - ID_CONFIG_FIRST;
			int i = 0;
			for ( ; iter != Rainmeter->GetAllMeterWindows().end(); ++iter)
			{
				if (i == index)
				{
					std::wstring name = ((*iter).second)->GetFolderPath() + L'\\';
					name += ((*iter).second)->GetFileName();

					HWND item = GetDlgItem(m_Window, IDC_MANAGESKINS_SKINS_TREEVIEW);
					SelectTreeItem(item, TreeView_GetRoot(item), name.c_str());
					break;
				}

				++i;
			}
		}
		else if (wParam == IDM_SKIN_MONITOR_AUTOSELECT ||
			wParam == IDM_SKIN_MONITOR_PRIMARY ||
			wParam >= ID_MONITOR_FIRST && wParam <= ID_MONITOR_LAST)
		{
			if (m_SkinWindow)
			{
				SendMessage(m_SkinWindow->GetWindow(), WM_COMMAND, wParam, 0);
			}
			break;
		}

		return 1;
	}

	return 0;
}
Beispiel #4
0
MainWindow::MainWindow()
{
    sceneTree = new QTreeWidget();
    sceneTree->setColumnCount( 1 );
    // TODO: Change itemClicked to something that can handle multi-selection properly.
    connect( sceneTree, &QTreeWidget::itemClicked, [&](QTreeWidgetItem* item, int /* column */) { SelectTreeItem( item ); });
    connect( sceneTree, &QTreeWidget::itemChanged, [&](QTreeWidgetItem* item, int /* column */) { HierarchyItemRenamed( item ); });
    sceneTree->setSelectionMode( QAbstractItemView::SelectionMode::ExtendedSelection );

    sceneWidget = new SceneWidget();
    setWindowTitle( "Editor" );
    connect( sceneWidget, SIGNAL(GameObjectsAddedOrDeleted()), this, SLOT(HandleGameObjectsAddedOrDeleted()) );

    windowMenu.Init( this );
    setMenuBar( windowMenu.menuBar );

    QSplitter* splitter = new QSplitter();
    splitter->addWidget( sceneTree );
    splitter->addWidget( sceneWidget );
    setCentralWidget( splitter );

    UpdateHierarchy();
}
Beispiel #5
0
void CTravelTab::OnEditLoc() 
{
	int iSel = m_clcLocations.GetNextItem(-1, LVNI_SELECTED);
	if (iSel == -1)
		return;

	CSObject * pLoc = (CSObject *) m_clcLocations.GetItemData(iSel);
	if ( !pLoc )
		return;

	CAddDestination dlgAdd;
	dlgAdd.m_pCategoryList = &Main->m_pScripts->m_olAreas;

	dlgAdd.m_csDescription = pLoc->m_csDescription;
	dlgAdd.m_csCategory = pLoc->m_csCategory;
	dlgAdd.m_csSubsection = pLoc->m_csSubsection;

	CString csCoords, csMap;
	m_csCoords.GetWindowText(csCoords);
	m_ceMapPlane.GetWindowTextA(csMap);
	dlgAdd.m_csXCoord = csCoords.SpanExcluding(",");
	dlgAdd.m_csYCoord = csCoords.Mid(csCoords.Find(",") + 1);
	dlgAdd.m_csZCoord = dlgAdd.m_csYCoord.Mid(dlgAdd.m_csYCoord.Find(",") + 1);
	dlgAdd.m_csYCoord = dlgAdd.m_csYCoord.SpanExcluding(",");
	dlgAdd.m_csPlane = csMap;

	if (dlgAdd.DoModal() == IDOK)
	{
		OnRemoveLoc();
		CString csCategory = dlgAdd.m_csCategory;
		CString csSubsection = dlgAdd.m_csSubsection;
		CString csDescription = dlgAdd.m_csDescription;
		CString csX = dlgAdd.m_csXCoord;
		CString csY = dlgAdd.m_csYCoord;
		CString csZ = dlgAdd.m_csZCoord;
		CString csM = dlgAdd.m_csPlane;
		CString csPoint;
		csPoint.Format("%s,%s,%s", csX, csY, csZ);

		// Make sure an entry with this name doesn't already exist
		CCategory * pCategory = FindCategory(&Main->m_pScripts->m_olAreas, csCategory);
		CSObject * pObj = NULL;
		if (pCategory != NULL)
		{
			CSubsection * pSubsection = FindSubsection(pCategory, csSubsection);
			if (pSubsection != NULL)
			{
				POSITION pos = pSubsection->m_ItemList.GetHeadPosition();
				while ( pos )
				{
					CSObject * pObject = (CSObject *) pSubsection->m_ItemList.GetNext(pos);
					if ( pObject != NULL )
					{
						if ( pObject->m_csDescription == csDescription )
						{
							pObj = pObject;
							break;
						}
						continue;
					}
				}
			}
		}
		
		if (pObj != NULL)
		{
			AfxMessageBox("An entry with that name already exists.", MB_OK);
			return;
		}
		CSObject * pLoc = new CSObject;
		pLoc->m_bCustom = true;
		pLoc->m_csCategory = csCategory;
		pLoc->m_csSubsection = csSubsection;
		pLoc->m_csDescription = csDescription;
		pLoc->m_bType = TYPE_AREA;
		pLoc->m_csID = csPoint;
		pLoc->m_csDisplay = csM;

		Main->m_pScripts->m_aAreas.Add(pLoc);
		CString csKey;
		csKey.Format("%s\\%s\\%s\\%s",REGKEY_LOCATION, csCategory, csSubsection, csDescription);
		Main->PutRegistryString("Point", csPoint, hRegLocation, csKey);
		Main->PutRegistryString("Map", csM, hRegLocation, csKey);
		pCategory = FindCategory(&Main->m_pScripts->m_olAreas, pLoc->m_csCategory);
		pSubsection = FindSubsection(pCategory, pLoc->m_csSubsection);
		if ( pSubsection->m_ItemList.IsEmpty() )
			pSubsection->m_ItemList.AddHead( pLoc );
		else
			pSubsection->m_ItemList.AddTail( pLoc );

		FillCategoryTree();
		SelectTreeItem(csCategory, csSubsection);
	}
}
Beispiel #6
0
void CTravelTab::OnRemoveLoc() 
{
	CString csCategory;
	CString csSubsection;
	CString csDescription;

	HTREEITEM hCategory, hSubsection;
	hSubsection = this->m_ctcCategoryTree.GetSelectedItem();
	if (hSubsection != NULL)
	{
		hCategory = this->m_ctcCategoryTree.GetParentItem(hSubsection);
		if (hCategory == NULL)
			return;
	}

	csCategory = this->m_ctcCategoryTree.GetItemText(hCategory);
	csSubsection = this->m_ctcCategoryTree.GetItemText(hSubsection);
	int iItemSel = this->m_clcLocations.GetNextItem(-1, LVNI_SELECTED);
	if (iItemSel == -1)
		return;
	
	CCategory * pCategory = FindCategory(&Main->m_pScripts->m_olAreas, csCategory, false);
	CSubsection * pSubsection = FindSubsection(pCategory, csSubsection, false);

	CSObject * pLoc = (CSObject *)this->m_clcLocations.GetItemData(iItemSel);

	csDescription = pLoc->m_csDescription;

	POSITION pos = pSubsection->m_ItemList.Find(pLoc);
	if ( pos )
		pSubsection->m_ItemList.RemoveAt(pos);

	for ( int i = 0; i < Main->m_pScripts->m_aAreas.GetSize(); i++ )
	{
		CSObject * pTest = (CSObject *) Main->m_pScripts->m_aAreas.GetAt(i);
		if ( pTest == pLoc )
		{
			Main->m_pScripts->m_aAreas.RemoveAt(i);
			delete pLoc;
			break;
		}
	}
	CString csKey;
	csKey.Format("%s\\%s\\%s\\%s", REGKEY_LOCATION, csCategory, csSubsection, csDescription);
	Main->DeleteRegistryKey(csKey);

	if ( pSubsection->m_ItemList.IsEmpty() )
	{
		csKey.Format("%s\\%s\\%s", REGKEY_LOCATION, csCategory, csSubsection);
		Main->DeleteRegistryKey(csKey);
		POSITION pos = pCategory->m_SubsectionList.Find(pSubsection);
		if ( pos )
			pCategory->m_SubsectionList.RemoveAt(pos);
	}

	if ( pCategory->m_SubsectionList.IsEmpty() )
	{
		csKey.Format("%s\\%s", REGKEY_LOCATION, csCategory);
		Main->DeleteRegistryKey(csKey);
		POSITION pos = Main->m_pScripts->m_olAreas.Find(pCategory);
		if ( pos )
			Main->m_pScripts->m_olAreas.RemoveAt(pos);
	}

	FillCategoryTree();
	SelectTreeItem(csCategory, csSubsection);
}