2010-07-05 23:44:22 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 2010 Patrick Dubbert
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "VirtuaWinMeasure.h"
|
|
|
|
|
|
|
|
#include <tchar.h>
|
|
|
|
|
|
|
|
#include "VirtuaWinMessages.h"
|
|
|
|
#include "../../Library/Export.h"
|
|
|
|
|
|
|
|
HWND VirtuaWinMeasure::vwHandle = NULL;
|
|
|
|
std::map<std::wstring, VirtuaWinMeasure::MeasureType> VirtuaWinMeasure::StringToType;
|
|
|
|
|
|
|
|
VirtuaWinMeasure::VirtuaWinMeasure(HMODULE instance, UINT id) : VDMeasure(instance, id)
|
|
|
|
{
|
2011-03-29 19:21:57 +00:00
|
|
|
if (StringToType.size() == 0)
|
2010-07-05 23:44:22 +00:00
|
|
|
{
|
|
|
|
StringToType.insert(std::make_pair(std::wstring(L"VDMActive"), VDMActive));
|
|
|
|
StringToType.insert(std::make_pair(std::wstring(L"DesktopCount"), DesktopCountTotal));
|
|
|
|
StringToType.insert(std::make_pair(std::wstring(L"CurrentDesktop"), CurrentDesktop));
|
|
|
|
StringToType.insert(std::make_pair(std::wstring(L"SwitchDesktop"), SwitchDesktop));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
VirtuaWinMeasure::~VirtuaWinMeasure(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT VirtuaWinMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
|
|
|
|
{
|
|
|
|
std::wstring TypeString(ReadConfigString(section, _T("VDMeasureType"), _T("")));
|
|
|
|
std::map<std::wstring, MeasureType>::iterator i = StringToType.find(TypeString);
|
2011-03-29 19:21:57 +00:00
|
|
|
if (i != StringToType.end())
|
2010-07-05 23:44:22 +00:00
|
|
|
{
|
|
|
|
Type = i->second;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Type = Unknown;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(Type)
|
|
|
|
{
|
|
|
|
case VDMActive:
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case DesktopCountTotal:
|
|
|
|
{
|
|
|
|
LPCTSTR CountType = ReadConfigString(section, _T("VDDesktopCount"), _T(""));
|
2011-03-29 19:21:57 +00:00
|
|
|
if (_tcsicmp(CountType, _T("X")) == 0) Type = DesktopCountColumns;
|
|
|
|
else if (_tcsicmp(CountType, _T("Y")) == 0) Type = DesktopCountRows;
|
|
|
|
if (FindVirtuaWinWindow())
|
2010-07-05 23:44:22 +00:00
|
|
|
{
|
|
|
|
return (UINT) SendMessage(vwHandle, VW_DESKTOP_SIZE, 0, 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void VirtuaWinMeasure::Finalize()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT VirtuaWinMeasure::Update()
|
|
|
|
{
|
2011-03-29 19:21:57 +00:00
|
|
|
if (!FindVirtuaWinWindow())
|
2010-07-05 23:44:22 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(Type)
|
|
|
|
{
|
|
|
|
case VDMActive:
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case DesktopCountColumns:
|
|
|
|
return (UINT) SendMessage(vwHandle, VW_DESKX, 0, 0);
|
|
|
|
|
|
|
|
case DesktopCountRows:
|
|
|
|
return (UINT) SendMessage(vwHandle, VW_DESKY, 0, 0);
|
|
|
|
|
|
|
|
case DesktopCountTotal:
|
|
|
|
return (UINT) SendMessage(vwHandle, VW_DESKX, 0, 0) * (UINT) SendMessage(vwHandle, VW_DESKY, 0, 0);
|
|
|
|
|
|
|
|
case CurrentDesktop:
|
|
|
|
return (UINT) SendMessage(vwHandle, VW_CURDESK, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
LPCTSTR VirtuaWinMeasure::GetString(UINT flags)
|
|
|
|
{
|
|
|
|
static TCHAR Buffer[MAX_PATH];
|
|
|
|
Buffer[0] = _T('\0');
|
|
|
|
|
|
|
|
switch(Type)
|
|
|
|
{
|
|
|
|
case VDMActive:
|
|
|
|
case DesktopCountColumns:
|
|
|
|
case DesktopCountRows:
|
|
|
|
case DesktopCountTotal:
|
|
|
|
case CurrentDesktop:
|
|
|
|
swprintf_s(Buffer, MAX_PATH, L"%i", Update());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
void VirtuaWinMeasure::ExecuteBang(LPCTSTR args)
|
|
|
|
{
|
|
|
|
INT32 Desktop;
|
|
|
|
|
2011-03-29 19:21:57 +00:00
|
|
|
if (!FindVirtuaWinWindow()) return;
|
2010-07-05 23:44:22 +00:00
|
|
|
|
|
|
|
switch(Type)
|
|
|
|
{
|
|
|
|
case SwitchDesktop:
|
|
|
|
Desktop = _wtoi(args);
|
|
|
|
SendNotifyMessage(vwHandle, VW_CHANGEDESK, Desktop, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL VirtuaWinMeasure::FindVirtuaWinWindow()
|
|
|
|
{
|
2011-03-29 19:21:57 +00:00
|
|
|
if (IsWindow(vwHandle)) return TRUE;
|
2010-07-05 23:44:22 +00:00
|
|
|
vwHandle = FindWindow(_T("VirtuaWinMainClass"), _T("VirtuaWinMainClass"));
|
|
|
|
return vwHandle != NULL;
|
|
|
|
}
|