Example #1
0
bool Desk_mousebutton_event(LPARAM button)
{
    char rc_key[80] = "blackbox.desktop.";

    const char (*modkey_strings)[6] = GetSystemMetrics(SM_SWAPBUTTON) ? &modkey_strings_l[0] : &modkey_strings_r[0];

    unsigned modkey = get_modkeys();
    for (int i = 0; i < (int)(sizeof(mk_mods)/sizeof(mk_mods[0])); i++){
        if (mk_mods[i] & modkey) strcat(rc_key, modkey_strings[i]);
    }

    if (button >= (int)(sizeof(button_strings)/sizeof(button_strings[0]))) return false;
    if (button >= 7){
        sprintf(strchr(rc_key, 0), "%s:", button_strings[button]); // WheelUp/WheelDown
    }
    else{
        sprintf(strchr(rc_key, 0), "%sClick:", button_strings[button]);
    }
    const char *broam = ReadString(extensionsrcPath(), rc_key, NULL);

    if (broam)
        post_command(broam);
    else
    if (1 == button && 0 == modkey)
        PostMessage(BBhwnd, BB_MENU, BB_MENU_ROOT, 0);
    else
    if ((2 == button && 0 == modkey) || (1 == button && MK_SHIFT == modkey))
        PostMessage(BBhwnd, BB_MENU, BB_MENU_TASKS, 0);
    else
        return false;

    return true;
}
Example #2
0
//===========================================================================
const char * Desk_extended_rootCommand(const char *p)
{
    const char rc_key [] = "blackbox.background.rootCommand:";
    const char *extrc = extensionsrcPath();
    if (p) WriteString(extrc, rc_key, p);
    else p = ReadString(extrc, rc_key, NULL);
    return p;
}
Example #3
0
static void load_nls(void)
{
	const char *lang_file =
		ReadString(extensionsrcPath(), "blackbox.options.language:", NULL);
	if (NULL == lang_file) return;

	char full_path[MAX_PATH];
	FILE *fp = fopen (make_bb_path(full_path, lang_file), "rb");
	if (NULL == fp) return;

	char line[4000], key[200], new_text[4000], *np;
	int nl;
	key[0] = 0;

	new_text[0] = 0;
	np = new_text;
	nl = 0;
	for (;;)
	{
		bool eof = false == read_next_line(fp, line, sizeof line);
		char *s = line, c = *s;
		if ('$' == c || eof)
		{
			if (key[0] && new_text[0])
			{
				struct nls *t = (struct nls *)c_alloc(sizeof *t + strlen(key));
				t->hash = calc_hash(t->key, key, &t->k);
				t->translation = new_str(new_text);
				cons_node(&pNLS, t);
			}
			if (eof) break;
			if (' ' == s[1]) s += 2;
			decode_escape(key, s);
			new_text[0] = 0;
			np = new_text;
			nl = 0;
			continue;
		}

		if ('#' == c || '!' == c) continue;

		if ('\0' != c)
		{
			while (nl--) *np++ = '\n';
			np += decode_escape(np, s);
			nl = 0;
		}

		nl ++;
	}
	fclose(fp);
	reverse_list(&pNLS);
}
Example #4
0
//================================================
void exec_folder_click(const struct _ITEMIDLIST * pidl)
{
	const TCHAR *p = ReadString(extensionsrcPath(), _T("blackbox.options.openFolderCommand:"), NULL);
	if (p)
	{
		TCHAR path[MAX_PATH]; TCHAR buffer[MAX_PATH*2];
		if (sh_get_displayname(NULL, pidl, SHGDN_FORPARSING, path))
		{
			post_command(replace_argument1(buffer, MAX_PATH*2, p, path));
			return;
		}
	}
	exec_pidl(pidl, _T("explore"), NULL);
}
Example #5
0
bool Desk_mousebutton_event(int button)
{
    char rc_key[100];
    unsigned modkey;
    int i;
    const char *broam;

    if (button < 1 || button > array_count(button_strings))
        return false;

    modkey = get_modkeys();
    if (button == 1 && 0 == modkey)
        return false;

    strcpy(rc_key, "blackbox.desktop.");
    for (i = 0; i < array_count(mk_mods); ++i)
        if (mk_mods[i] & modkey)
            strcat(rc_key, modkey_strings[i]);
    sprintf(strchr(rc_key, 0), "%sClick", button_strings[button-1]);

    broam = ReadString(extensionsrcPath(NULL), rc_key, NULL);
    // dbg_printf("%s - %s", rc_key, broam);

    if (broam) {
        post_command(broam);
        return true;
    }

    if (2 == button && 0 == modkey) {
        PostMessage(BBhwnd, BB_MENU, BB_MENU_ROOT, 0);
        return true;
    }
    if ((3 == button && 0 == modkey) || (2 == button && MK_SHIFT == modkey)) {
        PostMessage(BBhwnd, BB_MENU, BB_MENU_TASKS, 0);
        return true;
    }
    return false;

}
Example #6
0
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int gap = bevelWidth + borderWidth;

	switch (message)
	{
		case WM_PAINT:
		{
			OnPaint(hwnd);
		}
		break;

		// ==========

		case BB_RECONFIGURE:
		{
			if (myMenu){ DelMenu(myMenu); myMenu = NULL;}
			GetStyleSettings();
			InvalidateRect(hwndPlugin, NULL, true);
		}
		break;

		// for bbStylemaker
		case BB_REDRAWGUI:
		{
			GetStyleSettings();
			InvalidateRect(hwndPlugin, NULL, true);
		}
		break;

		case WM_DISPLAYCHANGE:
		{
			if(!inSlit)
			{
				// IntelliMove(tm)... <g>
				// (c) 2003 qwilk
				//should make this a function so it can be used on startup in case resolution changed since
				//the last time blackbox was used.
				int relx, rely;
				int oldscreenwidth = ScreenWidth;
				int oldscreenheight = ScreenHeight;
				ScreenWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);
				ScreenHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);
				if (xpos > oldscreenwidth / 2)
				{
					relx = oldscreenwidth - xpos;
					xpos = ScreenWidth - relx;
				}
				if (ypos > oldscreenheight / 2)
				{
					rely = oldscreenheight - ypos;
					ypos = ScreenHeight - rely;
				}
				MoveWindow(hwndPlugin, xpos, ypos, width, height, true);
			}
		}
		break;

		// ==========

		case BB_BROADCAST:
		{
			szTemp = (char*)lParam;

			if (!_stricmp(szTemp, "@BBShowPlugins") &&  pluginToggle && !inSlit)
			{
				// Show window and force update...
				ShowWindow( hwndPlugin, SW_SHOW);
				InvalidateRect( hwndPlugin, NULL, true);
			}
			else if (!_stricmp(szTemp, "@BBHidePlugins") && pluginToggle && !inSlit)
			{
				// Hide window...
				ShowWindow( hwndPlugin, SW_HIDE);
			}

			//===================

			if (strnicmp(szTemp, "@BBSeekbar", 10))
				return 0;
			szTemp += 10;

			if (!_stricmp(szTemp, "About"))
			{
				char tmp_str[MAX_LINE_LENGTH];
				SendMessage(hwndBlackbox, BB_HIDEMENU, 0, 0);
				sprintf(tmp_str, "%s", szVersion);
				MessageBox(hwndBlackbox, tmp_str, szAppName, MB_OK | MB_TOPMOST);
			}

			//===================

			else if (!_strnicmp(szTemp, "StyleType", 9))
			{
				styleType = atoi(szTemp + 10);
				GetStyleSettings();
				InvalidateRect(hwndPlugin, NULL, true);
			}
			else if (!_strnicmp(szTemp, "TrackStyle", 10))
			{
				trackStyleType = atoi(szTemp + 11);
				GetStyleSettings();
				InvalidateRect(hwndPlugin, NULL, true);
			}
			else if (!_strnicmp(szTemp, "KnobStyle", 9))
			{
				knobStyleType = atoi(szTemp + 10);
				GetStyleSettings();
				InvalidateRect(hwndPlugin, NULL, true);
			}

			else if (!_strnicmp(szTemp, "Appearance", 10))
			{
				appearance = atoi(szTemp + 11);
				track_needsupdate = true;
				knob_needsupdate = true;
				InvalidateRect(hwndPlugin, NULL, true);
				ShowMyMenu(false);
			}
			else if (!_strnicmp(szTemp, "PlayerType", 10))
			{
				playerType = atoi(szTemp + 11);

				// Stop the monitor...
				unsigned long exitcode;
				GetExitCodeThread(hThread_Time, &exitcode);
				TerminateThread(hThread_Time, exitcode);

				FreeLibrary(controlPlugin);
				if(!loadPlayerControl(hInstance, playerType)){
					MessageBox(hwndBlackbox, "Player control plugin not found", szAppName, MB_OK | MB_ICONERROR | MB_TOPMOST);
				}

				// Start the monitoring threads...
				hThread_Time = CreateThread(NULL, 0, TimeProc, NULL, 0, &dwThreadId_Time);

				knob_needsupdate = true;
				InvalidateRect(hwndPlugin, NULL, true);
				ShowMyMenu(false);
			}

			//===================

			else if (!_strnicmp(szTemp, "WidthSize", 9))
			{
				newWidth = atoi(szTemp + 10);
				if(ResizeMyWindow(newWidth, height)){
					track_needsupdate = true;
					knob_needsupdate = true;
					InvalidateRect(hwndPlugin, NULL, true);
				}
			}
			else if (!_strnicmp(szTemp, "HeightSize", 10))
			{
				newHeight = atoi(szTemp + 11);
				if(ResizeMyWindow(width, newHeight)){
					track_needsupdate = true;
					knob_needsupdate = true;
					InvalidateRect(hwndPlugin, NULL, true);
				}
			}

			//===================

			else if (!_stricmp(szTemp, "pluginToggle"))
			{
				pluginToggle = (pluginToggle ? false : true);
				SetWindowModes();
			}
			else if (!_stricmp(szTemp, "OnTop"))
			{
				alwaysOnTop = (alwaysOnTop ? false : true);
				if(!inSlit)SetWindowPos( hwndPlugin,
                                                         alwaysOnTop ? HWND_TOPMOST : HWND_NOTOPMOST,
                                                         0, 0, 0, 0,
                                                         SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE);

				ShowMyMenu(false);
			}

			else if (!_stricmp(szTemp, "InSlit"))
			{
				if(inSlit && hSlit){
					// We are in the slit, so lets unload and get out..
					SendMessage(hSlit, SLIT_REMOVE, NULL, (LPARAM)hwndPlugin);

					// Here you can move to where ever you want ;)
					SetWindowPos(hwndPlugin, NULL, xpos, ypos, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
					inSlit = false;
					SetWindowModes();
				}
				/* Make sure before you try and load into the slit that you have
				* the HWND of the slit ;)
				*/
				else if(hSlit){
					// (Back) into the slit..
					inSlit = true;
					SetWindowModes();
					SendMessage(hSlit, SLIT_ADD, NULL, (LPARAM)hwndPlugin);
				}
			}

			else if (!_stricmp(szTemp, "Transparent"))
			{
				transparency = (transparency ? false : true);
				SetWindowModes();
			}
			else if (!_strnicmp(szTemp, "AlphaValue", 10))
			{
				alpha = atoi(szTemp + 11);
				SetWindowModes();
			}
			else if (!_stricmp(szTemp, "SnapToEdge"))
			{
				snapWindow = (snapWindow ? false : true);
				ShowMyMenu(false);
			}
			else if (!_stricmp(szTemp, "ShowBorder"))
			{
				showBorder = (showBorder ? false : true);
				InvalidateRect(hwndPlugin, NULL, false);
				ShowMyMenu(false);
			}
			else if (!_stricmp(szTemp, "AllowTip"))
			{
				allowtip = (allowtip ? false : true);
				SetAllowTip(allowtip);
				ShowMyMenu(false);
			}

			else if (!_stricmp(szTemp, "Vertical"))
			{
				vertical = (vertical ? false : true);
				if(ResizeMyWindow(height, width)){
					track_needsupdate = true;
					knob_needsupdate = true;
					InvalidateRect(hwndPlugin, NULL, true);
				}
				ShowMyMenu(false);
			}
			else if (!_stricmp(szTemp, "Reversed"))
			{
				reversed = (reversed ? false : true);
				track_needsupdate = true;
				knob_needsupdate = true;
				InvalidateRect(hwndPlugin, NULL, true);
				ShowMyMenu(false);
			}

			//===================

			else if (!_stricmp(szTemp, "EditRC"))
			{
				BBExecute(GetDesktopWindow(), NULL,
				ReadString(extensionsrcPath(), "blackbox.editor:", "notepad.exe"),
                                          rcpath, NULL, SW_SHOWNORMAL, false);
			}
			else if (!_stricmp(szTemp, "ReloadSettings"))
			{
				ReadRCSettings();
				GetStyleSettings();

				if(inSlit && hSlit)
				{
					SetWindowModes();
					SendMessage(hSlit, SLIT_UPDATE, NULL, NULL);
				}
				else if(!inSlit || !hSlit)
					SendMessage(hSlit, SLIT_REMOVE, NULL, (LPARAM)hwndPlugin);

				else inSlit = false;
			}
			else if (!_stricmp(szTemp, "SaveSettings"))
			{
				WriteRCSettings();
			}
		}
		break;

		// ==========

		case WM_WINDOWPOSCHANGING:
		{
			// Is SnapWindowToEdge enabled?
			if (!inSlit && snapWindow)
			{
				// Snap window to screen edges (if the last bool is false it uses the current DesktopArea)
				if(IsWindowVisible(hwnd)) SnapWindowToEdge((WINDOWPOS*)lParam, 10, true);
			}
		}
		break;

		// ==========

		case WM_WINDOWPOSCHANGED:
		{
			if(!inSlit)
			{
				WINDOWPOS* windowpos = (WINDOWPOS*)lParam;
				if (0 == (windowpos->flags & SWP_NOMOVE))
				{
					xpos = windowpos->x;
					ypos = windowpos->y;
				}

				if(ResizeMyWindow(windowpos->cx, windowpos->cy) && 0 == (windowpos->flags & SWP_NOSIZE))
				{
					track_needsupdate = true;
					knob_needsupdate = true;
					InvalidateRect(hwndPlugin, NULL, true);
				}
			}
		}
		break;

		// ==========

		case WM_NCHITTEST:
		{
			if (!inSlit && GetKeyState(VK_MENU) & 0xF0)
			{
				return HTBOTTOMRIGHT;
			}
			else
			if (!inSlit && GetKeyState(VK_CONTROL) & 0xF0)
			{
				return HTCAPTION;
			}
		}
		return HTCLIENT;

		// ==========

		case WM_LBUTTONDOWN:
			SetFocus(hwnd);
			SetCapture(hwnd);

			InvalidateRect(hwndPlugin, NULL, false);
			dragging = true;
			SliderOnValueChange(lParam);
			break;
	
		case WM_MOUSEMOVE:
			if (!dragging) break;
			InvalidateRect(hwndPlugin, NULL, false);
			SliderOnValueChange(lParam);
			break;

		case WM_LBUTTONUP:
			ReleaseCapture();

		case WM_KILLFOCUS: 
			dragging = false;
			break;

		// ==========

		case WM_RBUTTONUP:
			ReleaseCapture();

		case WM_NCRBUTTONUP:
			ShowMyMenu(true);
			break;

		case WM_CLOSE:
			break;

		// bring window into foreground on sizing/moving-start
		case WM_NCLBUTTONDOWN:
			SetWindowPos(hwnd, HWND_TOP, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE);
			UpdateWindow(hwnd);
			// fall through
 		// ==========
		default:
			return DefWindowProc(hwnd,message,wParam,lParam);
	}
	return 0;
}
Example #7
0
void ContextItem::Measure(HDC hDC, SIZE *size)
{
	if (0==(m_type & MFT_OWNERDRAW))
	{
		MenuItem::Measure(hDC, size);
		return;
	}

	ContextMenu* Ctxt=(ContextMenu*)m_pMenu;

	MEASUREITEMSTRUCT mai;
	mai.CtlType     = ODT_MENU; // type of control
	mai.CtlID       = 0;        // combo box, list box, or button identifier
	mai.itemID      = m_id;     // menu item, variable-height list box, or combo box identifier
	mai.itemWidth   = 0;        // width of menu item, in pixels
	mai.itemHeight  = 0;        // height of single item in list box menu, in pixels
	mai.itemData    = m_data;   // application-defined 32-bit value

	Ctxt->wc->HandleMenuMsg(WM_MEASUREITEM, 0, (LPARAM)&mai);
	// the dumb measure method does not take an HDC,
	// and as such uses the system font as base instead of our's

	int w = mai.itemWidth * 3 / 2;
	int h = MenuInfo.nItemHeight;

	if (m_bmp) DeleteObject(m_bmp);

	// create a monochrome bitmap
	HDC buf = CreateCompatibleDC(NULL);
	m_bmp = CreateBitmap(w, h, 1, 1, NULL);
	HGDIOBJ other_bmp = SelectObject(buf, m_bmp);

	SetBkColor(buf, CRBACK);
	SetBkMode(buf, TRANSPARENT);
	SetTextColor(buf, CRTXT_WIN);

	HBRUSH hbr = CreateSolidBrush(CRBACK);
	RECT r = { 0, 0, w, h };
	FillRect(buf, &r, hbr);
	DeleteObject(hbr);

	// let the item draw with our font
	HGDIOBJ otherfont = SelectObject(buf, MenuInfo.hFrameFont);
	DrawItem(buf, w, h, false);
	SelectObject(buf, otherfont);

	// trick 17 (get the real width of the item)
	{
		int x, y;
		for (x = w; --x;)
			for (y = 0; y < h; y++)
				if (CRTXT_WIN == GetPixel(buf, x, y))
				{
					w = x+2;
					goto _break;
				}
		_break:;
	}

	SelectObject(buf, other_bmp);
	DeleteDC(buf);

	static int g_contextMenuAdjust[2];
	if (0 == MenuInfo.nAvgFontWidth)
	{
		MenuInfo.nAvgFontWidth = 1;
		const TCHAR *p = ReadString(extensionsrcPath(), _T("blackbox.contextmenu.itemAdjust:"),  _T("21/28"));
		g_contextMenuAdjust[0] =
		g_contextMenuAdjust[1] = _tstoi(p);
		if (NULL != (p = _tcschr(p, _T('/'))))
		g_contextMenuAdjust[1] = _tstoi(p+1);
	}

	m_icon_offset = m_id == 29 // 29 = SendTo-Items
		? g_contextMenuAdjust[1]
		: g_contextMenuAdjust[0]
		;

	m_bmp_width = w;
	size->cx = w - m_icon_offset;
	size->cy = MenuInfo.nItemHeight;
}