Ejemplo n.º 1
0
void InitializeOptions(void) {
	WNDCLASSEX wincl;
	HWND hwnd;

	wincl.hInstance = g_hInstance;
	wincl.lpszClassName = OPTION_WIN_CLASS;
	wincl.lpfnWndProc = OptionsWndProc;
	wincl.style = CS_DBLCLKS;
	wincl.cbSize = sizeof(WNDCLASSEX);

	wincl.hIcon = GetApplicationIcon();
	wincl.hIconSm = GetApplicationIcon();
	wincl.hCursor = LoadCursor(NULL, IDC_ARROW);
	wincl.lpszMenuName = NULL;
	wincl.cbClsExtra = 0;
	wincl.cbWndExtra = 0;
	wincl.hbrBackground = g_hBrush;

	if(!RegisterClassEx(&wincl)) {
		MessageError(T("Can't register windows class '") OPTION_WIN_CLASS T("'!"));
		ExitProcess(0);
	}

	hwnd = CreateWindowEx(0, OPTION_WIN_CLASS, T("Computer Guard Options"),
			WS_CAPTION | WS_SYSMENU | WS_BORDER, CW_USEDEFAULT,
			CW_USEDEFAULT, 420, 250,
			NULL, NULL, g_hInstance, NULL);

	UpdateWindow(hwnd);
	g_hwOptions = hwnd;
}
Ejemplo n.º 2
0
void InitializeTray(void) {
	g_nidIcon.cbSize = sizeof(NOTIFYICONDATA);
	/*g_nidIcon.dwInfoFlags = NIIF_INFO;*/
	g_nidIcon.hIcon = GetApplicationIcon();
	g_nidIcon.hWnd = g_hwOptions;
	g_nidIcon.uCallbackMessage = WM_TRAY;
	g_nidIcon.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
	g_nidIcon.uID = TRAY_ICON_ID;
	lstrcpy(g_nidIcon.szInfoTitle, APP_NAME);
	Shell_NotifyIcon(NIM_ADD, &g_nidIcon);
}
Ejemplo n.º 3
0
void g3d_create_path_deformation_form(void){
  g3d_create_form(&PATH_DEFORM_FORM,320,320,FL_UP_BOX);
  g3d_create_retract_frame();
  g3d_create_gvis_checkb();
  g3d_create_frame(&SPACE1,FL_NO_FRAME,100,30.0,"",(void**)&PATH_DEFORM_FORM,1);
  g3d_create_nbretract_input();
  g3d_create_ndraw_counter();
  g3d_create_dof1_counter();
  g3d_create_dof2_counter();
  g3d_create_node_frame();
  g3d_create_vis_graph_frame();

  fl_end_form();
  fl_set_form_icon(PATH_DEFORM_FORM, GetApplicationIcon(), 0);
  fl_set_form_atclose(PATH_DEFORM_FORM, CB_pathDeformForm_OnClose, NULL);
}
Ejemplo n.º 4
0
void CQuickLaunch::LoadLaunchItems(HKEY hKey, list<LaunchItem*>* pLaunchItems)
{
	DWORD dwCount = 0;
	RegistryGetDWORD(hKey, NULL, L"Count", &dwCount);

	for (DWORD i = 0; i < dwCount; ++i)
	{
		WCHAR wzPath[10],wzCount[5];
		DWORD dwSize = 0;
		_itow(i, wzCount, 10);

		StringCchCopy(wzPath, ARRAYSIZE(wzPath), wzCount);
		StringCchCat(wzPath, ARRAYSIZE(wzPath), L"_Path");

		LaunchItem* pRecord = new LaunchItem();
		
		bool bDelete = true;

		if (ERROR_SUCCESS == RegistryGetString(hKey, NULL, wzPath, pRecord->wzPath, ARRAYSIZE(pRecord->wzPath)))
		{
			pRecord->hIcon = GetApplicationIcon(pRecord->wzPath, false, NULL, NULL, NULL);
			
			// TODO: Load default icon
			if (!pRecord->hIcon)
			{
				pRecord->hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_ICON1));
			}
			bDelete = false;
		}
		if (bDelete)
		{
			delete pRecord;
		}
		else
		{
			pLaunchItems->push_back(pRecord);
		}
	}
}
Ejemplo n.º 5
0
BOOL CALLBACK CQuickLaunch::QuickLaunchProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) 
{
	static HWND hwndList;
	static HKEY g_hKey = NULL;
	static list<LaunchItem*> launchItems;

	TEXTMETRIC tm;

	static CDlgAnchor g_dlgAnchor;

    switch (message) 
    { 
		case WM_SIZE :
		{
			g_dlgAnchor.OnSize();
		}
		break;
		case WM_MEASUREITEM :
			{
				LPMEASUREITEMSTRUCT lpmis;
				lpmis = (MEASUREITEMSTRUCT FAR*) lParam;
				if (GetTextMetricsW(GetDC(hwndDlg), &tm))
				{
					lpmis->itemHeight = (UINT)(tm.tmHeight * 2.5);
				}
				else
				{
					lpmis->itemHeight = 50;
				}
			}
			break;
		case WM_DRAWITEM :
			{
				WCHAR tchBuffer[256] = {0};
				int y = 0;
				LPDRAWITEMSTRUCT lpdis = (DRAWITEMSTRUCT FAR*) lParam;

				LaunchItem* pRecord = (LaunchItem*)lpdis->itemData;
				GetTextMetrics(lpdis->hDC, &tm);

				HBRUSH hBrush = NULL;
				SetBkMode(lpdis->hDC, TRANSPARENT);
				if ((lpdis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)))
				{
					if ((lpdis->itemState & ODS_SELECTED))
					{
						hBrush = GetSysColorBrush(COLOR_HIGHLIGHT);
						SetTextColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
					}
					else
					{
						hBrush = GetSysColorBrush(COLOR_WINDOW);
						SetTextColor(lpdis->hDC, GetSysColor(COLOR_WINDOWTEXT));
					}
				}
				if (hBrush)
				{
					int desiredHeight = (lpdis->rcItem.bottom - lpdis->rcItem.top) - 2;

					RECT rect;
					memcpy(&rect, &(lpdis->rcItem), sizeof(RECT));
					rect.top += 1;
					rect.bottom -= 1;
					rect.left += 1;
					rect.right -= 1;
					rect.left += desiredHeight;

					FillRect(lpdis->hDC, &rect, hBrush);

					rect.left += 5;
					rect.right -= 5;
					rect.bottom -= 5;
					rect.top += 5;

					WCHAR wzFullPath[MAX_PATH];
					WCHAR wzName[MAX_PATH];
					StringCchCopy(wzFullPath, ARRAYSIZE(wzFullPath), pRecord->wzPath);
					StringCchCopy(wzName, ARRAYSIZE(wzName), pRecord->wzPath);

					WCHAR* wzFile = wcsrchr(wzName, L'\\');

					if (!wzFile)
					{
						wzFile = wzName;
					}
					else
					{
						wzFile++;
					}
					WCHAR* wzExt = wcsrchr(wzFile, L'.');
					if (wzExt)
					{
						wzExt[0] = 0;
					}

					WCHAR* wzDir = wcsrchr(wzFullPath, L'\\');
					if (wzDir)
					{
						wzDir[0] = 0;
					}

					// todo - trim of .lnk
					DrawText(lpdis->hDC, wzFile, wcslen(wzFile), &rect, DT_TOP);
					
					LOGFONT lf;
					ZeroMemory(&lf, sizeof(lf));
					lf.lfHeight = -((rect.bottom - rect.top) / 4);
					lf.lfWeight = FW_BOLD;
					lf.lfCharSet = DEFAULT_CHARSET;
					HFONT hFont = CreateFontIndirect(&lf);
					HGDIOBJ hOldFont = SelectObject(lpdis->hDC, hFont);
					DrawText(lpdis->hDC, wzFullPath, wcslen(wzFullPath), &rect, DT_BOTTOM);
					SelectObject(lpdis->hDC, hOldFont);

					if (pRecord->hIcon)
					{
						DrawIcon(lpdis->hDC, 0, rect.top, pRecord->hIcon);
					}
				}
			}
			break;
        case WM_INITDIALOG:
        {
			g_dlgAnchor.Init(hwndDlg);
			g_dlgAnchor.Add(IDC_LIST_SPEEDDIAL, ANCHOR_ALL);
			g_dlgAnchor.Add(IDC_BUTTON_ADD, ANCHOR_RIGHT | ANCHOR_BOTTOM);
			g_dlgAnchor.Add(IDC_BUTTON_REMOVE, ANCHOR_RIGHT | ANCHOR_TOP);
			g_dlgAnchor.Add(IDC_BUTTON_MOVEDOWN, ANCHOR_RIGHT | ANCHOR_TOP);
			g_dlgAnchor.Add(IDC_BUTTON_MOVEUP, ANCHOR_RIGHT | ANCHOR_TOP);

			hwndList = GetDlgItem(hwndDlg, IDC_LIST_SPEEDDIAL);

            SHINITDLGINFO shidi;
            // Create a Done button and size it.
            shidi.dwMask = SHIDIM_FLAGS;
            shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN | SHIDIF_SIZEDLGFULLSCREEN;
            shidi.hDlg = hwndDlg;
            SHInitDialog(&shidi);

            SHMENUBARINFO mbi;
            memset(&mbi, 0, sizeof(SHMENUBARINFO));
            mbi.cbSize = sizeof(SHMENUBARINFO);
            mbi.hwndParent = hwndDlg;
            mbi.nToolBarId = IDR_Flipper_SET_MENUBAR;
			mbi.hInstRes = CQuickLaunch::g_hInstance;
            mbi.nBmpId = 0;
            mbi.cBmpImages = 0;    

            SHCreateMenuBar(&mbi);

			RECT rect;
			GetWindowRect(hwndList, &rect);
			
			LV_COLUMN lvC;
			lvC.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
			lvC.fmt = LVCFMT_LEFT;  // left-align column
			lvC.cx = rect.right - rect.left - 2;
			lvC.pszText = L"Name";

			HKEY hKey = (HKEY)lParam;
			g_hKey = hKey;

			CQuickLaunch::LoadLaunchItems(hKey, &launchItems);

			list<LaunchItem*>::iterator iter = launchItems.begin();

			while (iter != launchItems.end())
			{
				LaunchItem* pRecord = *iter;
				int index = ListBox_InsertString(hwndList, -1, pRecord->wzPath);
				ListBox_SetItemData(hwndList, index, pRecord);
				iter++;
			}
			SetFocus(hwndList);

            return 0;
        }
        break;
        case WM_COMMAND: 
			{
				if (HIWORD(wParam) == LBN_SELCHANGE)
				{
					int index = ListBox_GetCurSel(hwndList);
					int count = ListBox_GetCount(hwndList);

					bool bMoveUp = (index > 0);
					bool bMoveDown = (index < (count - 1));

					if (index < 0)
					{
						bMoveUp = bMoveDown = false;
					}

					EnableWindow(GetDlgItem(hwndDlg, IDC_BUTTON_REMOVE), index >= 0);
					EnableWindow(GetDlgItem(hwndDlg, IDC_BUTTON_MOVEUP), bMoveUp);
					EnableWindow(GetDlgItem(hwndDlg, IDC_BUTTON_MOVEDOWN), bMoveDown);
				}
				else if (HIWORD(wParam) == BN_CLICKED)
				{
					switch (LOWORD(wParam)) 
					{
						case IDC_BUTTON_ADD :
						{
							LaunchItem* pRecord = new LaunchItem();
							SetCursor(LoadCursor(NULL, IDC_WAIT));

							CApplicationSelector* appSelector = new CApplicationSelector();
							// TODO
							if (appSelector->ShowDialog(CQuickLaunch::g_hInstance, hwndDlg, pRecord->wzPath, false))
							{
								pRecord->hIcon = GetApplicationIcon(pRecord->wzPath, false, NULL, NULL, NULL);
								int index = ListBox_InsertString(hwndList, -1, pRecord->wzPath);
								ListBox_SetItemData(hwndList, index, pRecord);
								ListBox_SetCurSel(hwndList, index);
								PostMessage(hwndDlg, WM_COMMAND, MAKELONG(0, LBN_SELCHANGE), 0);
							}
							else
							{
								delete pRecord;
							}
							delete appSelector;
							SetCursor(NULL);
						}
						break;
						case IDC_BUTTON_REMOVE :
						{
							int index = ListBox_GetCurSel(hwndList);

							if (index >= 0)
							{
								LaunchItem* pRecord = (LaunchItem*)ListBox_GetItemData(hwndList, index);
								ListBox_DeleteString(hwndList, index);
								delete pRecord;
							}
							int count = ListBox_GetCount(hwndList);
							ListBox_SetCurSel(hwndList, min(count-1, index));
							PostMessage(hwndDlg, WM_COMMAND, MAKELONG(0, LBN_SELCHANGE), 0);
						}
						break;
						case IDC_BUTTON_MOVEUP :
						{
							int index = ListBox_GetCurSel(hwndList);
							if (index > 0)
							{
								LaunchItem* pRecord = (LaunchItem*)ListBox_GetItemData(hwndList, index);
								ListBox_DeleteString(hwndList, index);
								ListBox_InsertString(hwndList, index-1, pRecord->wzPath);
								ListBox_SetItemData(hwndList, index-1, pRecord);
								ListBox_SetCurSel(hwndList, index-1);
								PostMessage(hwndDlg, WM_COMMAND, MAKELONG(0, LBN_SELCHANGE), 0);
							}
						}
						break;
						case IDC_BUTTON_MOVEDOWN :
						{
							int index = ListBox_GetCurSel(hwndList);
							int count = ListBox_GetCount(hwndList);
							if (index < count - 1)
							{
								LaunchItem* pRecord = (LaunchItem*)ListBox_GetItemData(hwndList, index);
								ListBox_DeleteString(hwndList, index);
								ListBox_InsertString(hwndList, index+1, pRecord->wzPath);
								ListBox_SetItemData(hwndList, index+1, pRecord);
								ListBox_SetCurSel(hwndList, index+1);
								PostMessage(hwndDlg, WM_COMMAND, MAKELONG(0, LBN_SELCHANGE), 0);
							}
						}
						break;
					}
				}
				switch (LOWORD(wParam))
				{
					case IDM_Flipper_SET_ACCEPT :
					case IDOK:
						{
							int index = 0;

							list<LaunchItem*> launchItems;
							int count = ListBox_GetCount(hwndList);

							for (int i = 0; i < count; ++i)
							{
								WCHAR wzPath[10], wzCount[5];
								DWORD dwSize = 0;
								_itow(i, wzCount, 10);

								StringCchCopy(wzPath, ARRAYSIZE(wzPath), wzCount);
								StringCchCat(wzPath, ARRAYSIZE(wzPath), L"_Path");

								LaunchItem* pRecord = (LaunchItem*)ListBox_GetItemData(hwndList, i);
								launchItems.push_back(pRecord);
							}

							CQuickLaunch::SaveLaunchItems(g_hKey, &launchItems);

							EndDialog(hwndDlg, IDOK);
						}
						break;
					case IDM_Flipper_SET_CANCEL:
						{
							EndDialog(hwndDlg, IDOK);
						}
						break;
				}
            }
            break;
        case WM_DESTROY:
            {
				CQuickLaunch::DestroyLaunchItems(&launchItems);
                Sleep(0);
            }
            break;
    } 
    return FALSE; 
}
Ejemplo n.º 6
0
node* CQuickLaunch::BuildLaunchList(int* piNodeLen, int thumbWidth, int thumbHeight)
{
	if (g_iThumbHeight != thumbHeight || g_iThumbWidth != thumbWidth)
	{
		DestroyPhoneNodes(NULL);
	}
	if (!g_pHeadNode)
	{
		node* pHead = NULL;
		node* pPrev = NULL;

		list<LaunchItem*> pPhoneList = g_launchList;
		list<LaunchItem*>::iterator iter = pPhoneList.begin();

		int iPhoneNodeListCount = 0;

		while (iter != pPhoneList.end())
		{
			LaunchItem* pRecord = *iter;
			node* pCurr = new node();
			if (!pHead)
			{
				pHead = pCurr;
				pCurr = pHead;
			}
			else
			{
				pPrev->next = pCurr;
			}
			pRecord->hIcon = GetApplicationIcon(pRecord->wzPath, false, NULL, NULL, NULL);
			pCurr->prev = pPrev;
			pCurr->hIcon = pRecord->hIcon;
			pCurr->iIndex = iPhoneNodeListCount;
			pCurr->bCenter = true;
			pCurr->hBmp = NULL;

			Sleep(5);

			WCHAR* wzName = wcsrchr(pRecord->wzPath, L'\\');
			if (!wzName)
			{
				wzName = pRecord->wzPath;
			}
			else
			{
				wzName++;
			}

			StringCchCopy(pCurr->wzText, ARRAYSIZE(pCurr->wzText), wzName);
			WCHAR* wzExt = wcsrchr(pCurr->wzText, '.');
			if (wzExt)
			{
				wzExt[0] = 0;
			}

			StringCchCopy(pCurr->wzDetails, ARRAYSIZE(pCurr->wzDetails), L"Select to Launch");
			/*
			StringCchCopy(pCurr->wzDetails, ARRAYSIZE(pCurr->wzDetails), pRecord->wzPath);
			wzName = wcsrchr(pCurr->wzDetails, L'\\');
			if (wzName)
			{
				wzName[0] = 0;
			}
			*/

			pCurr->pData = pRecord;

			pPrev = pCurr;
			iter++;
			iPhoneNodeListCount++;
		}
		g_iNodeLen = iPhoneNodeListCount;
		g_pHeadNode = pHead;
	}
	g_iThumbHeight = thumbHeight;
	g_iThumbWidth = thumbWidth;

	*piNodeLen = g_iNodeLen;
	return g_pHeadNode;
}
Ejemplo n.º 7
0
// Application entry point
int main( int argc, char *argv[] )
{
    QT_REQUIRE_VERSION( argc, argv, "4.7.0" );

#ifndef QT_DEBUG
    qInstallMsgHandler( MessageHandler );
#endif

    MainApplication app( argc, argv );
    XercesExt::XercesInit init;

    try
    {
        // We prevent Qt from constantly creating and deleting threads.
        // Using a negative number forces the threads to stay around;
        // that way, we always have a steady number of threads ready to do work.
        QThreadPool::globalInstance()->setExpiryTimeout( -1 );

        // Specify the plugin folders
        // (language codecs and image loaders)
        app.addLibraryPath( "codecs" );
        app.addLibraryPath( "iconengines" );
        app.addLibraryPath( "imageformats" );

        // Set application information for
        // easier use of QSettings classes
        QCoreApplication::setOrganizationName( "sigil-ebook" );
        QCoreApplication::setOrganizationDomain("sigil-ebook.com");
        QCoreApplication::setApplicationName( "sigil" );
        QCoreApplication::setApplicationVersion(SIGIL_VERSION);

        // Setup the translator and load the translation for the selected language
        QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8"));
        QTranslator translator;

        SettingsStore settings;
        const QString qm_name = QString("sigil_%1").arg(settings.uiLanguage());

        // Run though all locations and stop once we find and are able to load
        // an appropriate translation.
        foreach (QString path, UILanguage::GetPossibleTranslationPaths()) {
            if (QDir(path).exists()) {
                if (translator.load(qm_name, path)) {
                    break;
                }
            }
        }
        app.installTranslator(&translator);

        // We set the window icon explicitly on Linux.
        // On Windows this is handled by the RC file,
        // and on Mac by the ICNS file.
    #ifdef Q_WS_X11
        app.setWindowIcon( GetApplicationIcon() );
    #endif

        // On Unix systems, we make sure that the temp folder we
        // create is accessible by all users. On Windows, there's
        // a temp folder per user.
    #ifndef Q_WS_WIN
        CreateTempFolderWithCorrectPermissions();
    #endif

        // Needs to be created on the heap so that
        // the reply has time to return.
        UpdateChecker *checker = new UpdateChecker( &app );
        checker->CheckForUpdate();

        // Install an event filter for the application
        // so we can catch OS X's file open events
        AppEventFilter *filter = new AppEventFilter( &app );
        app.installEventFilter( filter );

        const QStringList &arguments = QCoreApplication::arguments();

        if (arguments.contains("-t")) {
            std::cout  << TempFolder::GetPathToSigilScratchpad().toStdString() << std::endl;
            return 1;
        //} else if (arguments.count() == 3) {
            // Used for an undocumented, unsupported *-to-epub
            // console conversion. USE AT YOUR OWN PERIL!
            return QuickConvert( arguments );
        } else {
            // Normal startup
            MainWindow *widget = GetMainWindow( arguments );
            widget->show();
            return app.exec();
        }
    }
    catch ( ExceptionBase &exception )
    {
        Utility::DisplayExceptionErrorDialog( Utility::GetExceptionInfo( exception ) );
        return 1;
    }
}