Exemplo n.º 1
0
ST LRESULT CALLBACK Desk_WndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    static UINT msgs [] = { BB_DRAGTODESKTOP, 0 };
    static bool button_down;
    int n = 0;
    int nDelta;
    switch (uMsg)
    {
        //====================
        case WM_CREATE:
            hDesktopWnd = hwnd;
            MakeSticky(hwnd);
            MessageManager_AddMessages(hwnd, msgs);
            Desk_SetPosition();
            init_DeskDropTarget(hwnd);
            break;

        //====================
        case WM_DESTROY:
            exit_DeskDropTarget(hwnd);
            MessageManager_RemoveMessages(hwnd, msgs);
            RemoveSticky(hwnd);
            break;

        case WM_USER:
            Desk_Clear();
            Root.bmp = (HBITMAP)lParam;
        case WM_NCPAINT:
            Desk_SetPosition();
            break;

        //====================
        case WM_CLOSE:
            break;

        //====================
        case WM_MOUSEACTIVATE:
            return MA_NOACTIVATE;

        case WM_LBUTTONDOWN:
        case WM_RBUTTONDOWN:
        case WM_MBUTTONDOWN:
        case WM_XBUTTONDOWN:
            button_down = true;
            break;

        //====================
        case WM_LBUTTONUP: n = 0; goto post_click;
        case WM_RBUTTONUP: n = 1; goto post_click;
        case WM_MBUTTONUP: n = 2; goto post_click;
        case WM_XBUTTONUP:
            switch (HIWORD(wParam)) {
            case XBUTTON1: n = 3; goto post_click;
            case XBUTTON2: n = 4; goto post_click;
            case XBUTTON3: n = 5; goto post_click;
            } break;

        case WM_LBUTTONDBLCLK:
        case WM_RBUTTONDBLCLK:
        case WM_MBUTTONDBLCLK: n = 6;
            button_down = true;
            goto post_click;

        case WM_MOUSEWHEEL:
            nDelta = (short)HIWORD(wParam);
            if (nDelta > 0) n =  7; // Wheel UP
            if (nDelta < 0) n =  8; // Wheel Down
            button_down = true;
            goto post_click;

        post_click:
            if (button_down) PostMessage(BBhwnd, BB_DESKCLICK, 0, n);
            button_down = false;
//            PostMessage(BBhwnd, BB_DESKCLICK, 0, n);
            break;

        //====================
        case WM_PAINT:
        {
            PAINTSTRUCT ps;
            HDC hdc_scrn = BeginPaint(hwnd, &ps);
            if (Root.bmp)
            {
                HDC hdc_bmp = CreateCompatibleDC(hdc_scrn);
                HGDIOBJ other = SelectObject(hdc_bmp, Root.bmp);
                BitBltRect(hdc_scrn, hdc_bmp, &ps.rcPaint);
                SelectObject(hdc_bmp, other);
                DeleteDC(hdc_bmp);
            }
            else
            {
                PaintDesktop(hdc_scrn);
            }
            EndPaint(hwnd, &ps);
            break;
        }

        //====================
        case WM_ERASEBKGND:
            return TRUE;

        //====================
        case BB_DRAGTODESKTOP:
            return get_drop_command((const char *)lParam, wParam);

        //====================
        default:
            return DefWindowProc(hwnd, uMsg, wParam, lParam);

    }
    return 0;
}
Exemplo n.º 2
0
LRESULT slit_info::wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT *ret)
{
    static unsigned int msgs[] = { BB_REDRAWGUI, 0 };
    PluginInfo *p, **pp;

    if (ret)
        return *ret;

    switch(message)
    {
        //=============================================

        case WM_CREATE:
            SendMessage(GetBBWnd(), BB_REGISTERMESSAGE, (WPARAM)hwnd, (LPARAM)msgs);
            break;

        case WM_DESTROY:
            SendMessage(GetBBWnd(), BB_UNREGISTERMESSAGE, (WPARAM)hwnd, (LPARAM)msgs);
            if (this->bufbmp)
                DeleteObject(this->bufbmp), this->bufbmp = NULL;
            SetDesktopMargin(hwnd, 0, 0);
            for (pp = &this->m_pInfo; NULL != (p = *pp); *pp = p->next, m_free(p));
            break;

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

        case SLIT_ADD:
            //pdbg ((HWND) lParam, "add");
            for (pp = &this->m_pInfo; NULL != (p = *pp); pp = &p->next);
            *pp = p = (PluginInfo*)m_alloc(sizeof(struct PluginInfo));
            memset(p, 0, sizeof *p);
            /* if (!IsBadStringPtr((const char*)wParam, 80))
                ... */
            p->hwnd = (HWND)lParam;
            SetWindowLong(p->hwnd, GWL_STYLE,
                (GetWindowLong(p->hwnd, GWL_STYLE) & ~WS_POPUP) | WS_CHILD);
            SetParent(p->hwnd, hwnd);
            SetTimer(hwnd, 2, 20, NULL);
            break;

        case SLIT_REMOVE:
            //pdbg ((HWND) lParam, "remove");
            for (pp = &this->m_pInfo; NULL != (p = *pp) && p->hwnd != (HWND)lParam; pp = &p->next);
            if (p) {
                if (IsWindow(p->hwnd)) {
                    SetParent(p->hwnd, NULL);
                    SetWindowLong(p->hwnd, GWL_STYLE,
                        (GetWindowLong(p->hwnd, GWL_STYLE) & ~WS_CHILD) | WS_POPUP);
                }
                *pp = p->next;
                m_free(p);
            }
            SetTimer(hwnd, 2, 20, NULL);
            this->suspend_autohide = 0;
            break;

        case SLIT_UPDATE:
            //pdbg ((HWND) lParam, "update");
            SetTimer(hwnd, 2, 20, NULL);
            break;

        case WM_TIMER:
            if (2 == wParam) {
                KillTimer(hwnd, wParam);
                this->calculate_frame();
            }
            break;

        //=============================================
        // support bbStyleMaker under bbLean 1.16
        case WM_COPYDATA:
            return BBReceiveData(hwnd, lParam, NULL);

        case BB_SETSTYLESTRUCT:
            if (SN_SLIT == wParam)
                memcpy(&m_style, (void*)lParam, sizeof m_style);
            break;

        case BB_REDRAWGUI:
            if (wParam & BBRG_SLIT)
            {
                int m = margin;
                int p = padding;
                if (this->bufbmp)
                    DeleteObject(this->bufbmp), this->bufbmp = NULL;

                if (bblean_version >= 1170) {
                    getStyleSettings();
                } else {
                    // Workaround under bbLean 1.16
                    padding = m_style.marginWidth;
                    margin = m_style.marginWidth + m_style.borderWidth;
                }

                if (m != margin || p != padding)
                    this->calculate_frame();
                else
                    InvalidateRect(hwnd, NULL, FALSE);
            }
            break;

        case BB_RECONFIGURE:
            if (this->bufbmp)
                DeleteObject(this->bufbmp), this->bufbmp = NULL;
            getStyleSettings();
            this->getRCSettings();
            SetTimer(hwnd, 2, 20, NULL);
            break;

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

        case WM_PAINT:
        {
            PAINTSTRUCT ps;
            HDC hdc = BeginPaint(hwnd, &ps);
            HDC buf = CreateCompatibleDC(NULL);
            HGDIOBJ otherbmp;

            if (this->bufbmp
             && (this->bmp_width != this->width || this->bmp_height != this->height))
                DeleteObject(this->bufbmp), this->bufbmp = NULL;

            if (NULL == this->bufbmp) {
                this->bufbmp = CreateCompatibleBitmap(hdc,
                    this->bmp_width = this->width,
                    this->bmp_height = this->height
                    );
                otherbmp = SelectObject(buf, this->bufbmp);
                RECT r = { 0, 0, this->bmp_width, this->bmp_height };
                MakeStyleGradient(buf, &r, &m_style, m_style.bordered);
            } else {
                otherbmp = SelectObject(buf, this->bufbmp);
            }

            BitBltRect(hdc, buf, &ps.rcPaint);
            SelectObject(buf, otherbmp);
            DeleteDC(buf);
            EndPaint(hwnd, &ps);
            break;
        }

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

        // Right mouse button clicked?
        case WM_RBUTTONUP:
            this->show_menu (true);
            break;

        case WM_LBUTTONDBLCLK:
            BBP_set_autoHide(this, false == this->autoHide);
            this->show_menu (false);
            break;
    
        //=============================================
        default:
            return DefWindowProc(hwnd, message, wParam, lParam);
    }

    return 0;
}
Exemplo n.º 3
0
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    static int msgs[] = { BB_RECONFIGURE, BB_BROADCAST, 0};

    switch (message)
    {
        case WM_CREATE:
            /* Register to reveive these message */
            SendMessage(BBhwnd, BB_REGISTERMESSAGE, (WPARAM)hwnd, (LPARAM)msgs);
            /* Make the window appear on all workspaces */
            MakeSticky(hwnd);
            break;

        case WM_DESTROY:
            /* as above, in reverse */
            RemoveSticky(hwnd);
            SendMessage(BBhwnd, BB_UNREGISTERMESSAGE, (WPARAM)hwnd, (LPARAM)msgs);
            break;

        /* ---------------------------------------------------------- */
        /* Blackbox sends a "BB_RECONFIGURE" message on style changes etc. */

        case BB_RECONFIGURE:
            ReadRCSettings();
            GetStyleSettings();
            set_window_modes();
            break;

        /* ---------------------------------------------------------- */
        /* Painting directly on screen. Good enough for static plugins. */
#if 1
        case WM_PAINT:
        {
            PAINTSTRUCT ps;
            HDC hdc;
            RECT r;

            /* get screen DC */
            hdc = BeginPaint(hwnd, &ps);

            /* Setup the rectangle */
            r.left = r.top = 0;
            r.right = my.width;
            r.bottom =  my.height;

            /* and paint everything on it*/
            paint_window(hdc, &r);

            /* Done */
            EndPaint(hwnd, &ps);
            break;
        }

        /* ---------------------------------------------------------- */
        /* Painting with a cached double-buffer. If your plugin updates
           frequently, this avoids flicker */
#else
        case WM_PAINT:
        {
            PAINTSTRUCT ps;
            HDC hdc, hdc_buffer;
            HGDIOBJ otherbmp;
            RECT r;

            /* get screen DC */
            hdc = BeginPaint(hwnd, &ps);

            /* create a DC for the buffer */
            hdc_buffer = CreateCompatibleDC(hdc);

            if (NULL == my.bufbmp) /* No bitmap yet? */
            {
                /* Make a bitmap ... */
                my.bufbmp = CreateCompatibleBitmap(hdc, my.width, my.height);

                /* ... and select it into the DC, saving the previous default. */
                otherbmp = SelectObject(hdc_buffer, my.bufbmp);

                /* Setup the rectangle */
                r.left = r.top = 0;
                r.right = my.width;
                r.bottom =  my.height;

                /* and paint everything on it*/
                paint_window(hdc_buffer, &r);
            }
            else
            {
                /* Otherwise it has been painted already,
                   so just select it into the DC */
                otherbmp = SelectObject(hdc_buffer, my.bufbmp);
            }

            /* Copy the buffer on the screen, within the invalid rectangle: */
            BitBltRect(hdc, hdc_buffer, &ps.rcPaint);

            /* Put back the previous default bitmap */
            SelectObject(hdc_buffer, otherbmp);
            /* clean up */
            DeleteDC(hdc_buffer);

            /* Done. */
            EndPaint(hwnd, &ps);
            break;
        }
#endif
        /* ---------------------------------------------------------- */
        /* Manually moving/sizing has been started */

        case WM_ENTERSIZEMOVE:
            my.is_moving = true;
            break;

        case WM_EXITSIZEMOVE:
            if (my.is_moving)
            {
                if (my.is_inslit)
                {
                    /* moving in the slit is not really supported but who
                       knows ... */
                    SendMessage(g_hSlit, SLIT_UPDATE, 0, (LPARAM)hwnd);
                }
                else
                {
                    /* if not in slit, record new position */
                    WriteInt(rcpath, RC_KEY("xpos"), my.xpos);
                    WriteInt(rcpath, RC_KEY("ypos"), my.ypos);
                }

                if (my.is_sizing)
                {
                    /* record new size */
                    WriteInt(rcpath, RC_KEY("width"), my.width);
                    WriteInt(rcpath, RC_KEY("height"), my.height);
                }
            }
            my.is_moving = my.is_sizing = false;
            set_window_modes();
            break;

        /* --------------------------------------------------- */
        /* snap to edges on moving */

        case WM_WINDOWPOSCHANGING:
            if (my.is_moving)
            {
                WINDOWPOS* wp = (WINDOWPOS*)lParam;
                if (my.snapWindow && false == my.is_sizing)
                    SnapWindowToEdge(wp, 10, SNAP_FULLSCREEN);

                /* set a minimum size */
                if (wp->cx < 40)
                    wp->cx = 40;

                if (wp->cy < 20)
                    wp->cy = 20;
            }
            break;

        /* --------------------------------------------------- */
        /* record new position or size */

        case WM_WINDOWPOSCHANGED:
            if (my.is_moving)
            {
                WINDOWPOS* wp = (WINDOWPOS*)lParam;
                if (my.is_sizing)
                {
                    /* record sizes */
                    my.width = wp->cx;
                    my.height = wp->cy;

                    /* redraw window */
                    invalidate_window();
                }

                if (false == my.is_inslit)
                {
                    /* record position, if not in slit */
                    my.xpos = wp->x;
                    my.ypos = wp->y;
                }
            }
            break;

        /* ---------------------------------------------------------- */
        /* start moving or sizing accordingly to keys held down */

        case WM_LBUTTONDOWN:
            UpdateWindow(hwnd);
            if (GetAsyncKeyState(VK_MENU) & 0x8000)
            {
                /* start sizing, when alt-key is held down */
                PostMessage(hwnd, WM_SYSCOMMAND, 0xf008, 0);
                my.is_sizing = true;
            }
            else
            if (GetAsyncKeyState(VK_CONTROL) & 0x8000)
            {
                /* start moving, when control-key is held down */
                PostMessage(hwnd, WM_SYSCOMMAND, 0xf012, 0);
            }
            break;

        /* ---------------------------------------------------------- */
        /* normal mouse clicks */

        case WM_LBUTTONUP:
            /* code goes here ... */
            break;

        case WM_RBUTTONUP:
            /* Show the user menu on right-click (might test for control-key
               held down if wanted */
            /* if (wParam & MK_CONTROL) */
            ShowMyMenu(true);
            break;

        case WM_LBUTTONDBLCLK:
            /* Do something here ... */
            about_box();
            break;

        /* ---------------------------------------------------------- */
        /* Blackbox sends Broams to all windows... */

        case BB_BROADCAST:
        {
            const char *msg = (LPCSTR)lParam;
            struct msg_test msg_test;

            /* check general broams */
            if (!stricmp(msg, "@BBShowPlugins"))
            {
                if (my.is_hidden)
                {
                    my.is_hidden = false;
                    ShowWindow(hwnd, SW_SHOWNA);
                }
                break;
            }

            if (!stricmp(msg, "@BBHidePlugins"))
            {
                if (my.pluginToggle && false == my.is_inslit)
                {
                    my.is_hidden = true;
                    ShowWindow(hwnd, SW_HIDE);
                }
                break;
            }

            /* if the broam is not for us, return now */
            if (0 != memicmp(msg, BROAM_PREFIX, sizeof BROAM_PREFIX - 1))
                break;

            msg_test.msg = msg + sizeof BROAM_PREFIX - 1;

            if (scan_broam(&msg_test, "useSlit"))
            {
                eval_broam(&msg_test, M_BOL, &my.useSlit);
                break;
            }

            if (scan_broam(&msg_test, "alwaysOnTop"))
            {
                eval_broam(&msg_test, M_BOL, &my.alwaysOnTop);
                break;
            }

            if (scan_broam(&msg_test, "drawBorder"))
            {
                eval_broam(&msg_test, M_BOL, &my.drawBorder);
                break;
            }

            if (scan_broam(&msg_test, "snapWindow"))
            {
                eval_broam(&msg_test, M_BOL, &my.snapWindow);
                break;
            }

            if (scan_broam(&msg_test, "pluginToggle"))
            {
                eval_broam(&msg_test, M_BOL, &my.pluginToggle);
                break;
            }

            if (scan_broam(&msg_test, "alphaEnabled"))
            {
                eval_broam(&msg_test, M_BOL, &my.alphaEnabled);
                break;
            }

            if (scan_broam(&msg_test, "alphaValue"))
            {
                eval_broam(&msg_test, M_INT, &my.alphaValue);
                break;
            }

            if (scan_broam(&msg_test, "windowText"))
            {
                eval_broam(&msg_test, M_STR, &my.windowText);
                break;
            }

            if (scan_broam(&msg_test, "editRC"))
            {
                edit_rc(rcpath);
                break;
            }

            if (scan_broam(&msg_test, "About"))
            {
                about_box();
                break;
            }

            break;
        }

        /* ---------------------------------------------------------- */
        /* prevent the user from closing the plugin with alt-F4 */

        case WM_CLOSE:
            break;

        /* ---------------------------------------------------------- */
        /* let windows handle any other message */
        default:
            return DefWindowProc(hwnd,message,wParam,lParam);
    }
    return 0;
}
Exemplo n.º 4
0
/*----------------------------------------------------------------------------*/
void paint_window(HWND hwnd) {

    PAINTSTRUCT ps ;
    HFONT       hfnt0;
    HDC         hdc;
    int i,k,n,y,x;
    //int mm,yy;
    char bstr[256];

    RECT rw, r; SIZE sz;

#define MEMDC

#ifdef MEMDC
    HBITMAP     bm0,bm;
    HDC         fhdc ;
#endif

#ifdef MEMDC
    fhdc = BeginPaint (hwnd, &ps);

    hdc  = CreateCompatibleDC(fhdc);
    bm   = CreateCompatibleBitmap(fhdc,cwx+FRM,cwy+FRM);
    bm0  = (HBITMAP)SelectObject(hdc,bm);
#else
    hdc  = BeginPaint(hwnd,&ps);
#endif

    //goto pe;

    //fillpaint(&ps.rcPaint, Cbgd, hdc);

    GetClientRect(hwnd, &rw);

    paint_back(hdc, &rw, &r);
    BitBltRect(hdc, hdc_back, &ps.rcPaint);

    hfnt0 = (HFONT)SelectObject(hdc,hfnt_n);

    if (0!=synhilite)
    {
        memmove (My_Colors, darkcolors ? My_Colors_d : My_Colors_l, sizeof(My_Colors));
    }

    My_Colors[0] = (COLORREF)-1;
    My_Colors[1] = mStyle.MenuFrame.TextColor;
    My_Colors[3] = mStyle.MenuHilite.TextColor;
    if (mStyle.MenuHilite.parentRelative)
        My_Colors[2] = grey_value (My_Colors[3]) > 128 ? 0x333333 : 0xeeeeee;
    else
        My_Colors[2] = mixcolors(&mStyle.MenuHilite);

    if (edp) {
        i=ps.rcPaint.top;
        k=ps.rcPaint.bottom;
        n=ps.rcPaint.right;

        i=(i-zy0)/zy;
        k=(k-zy0+zy-1)/zy;
        n=(n-zx0+zx-1)/zx;

        if (i<0) i=0;
        if (k<0) k=0;
        if (k>i && n>0) printpage(hdc,n,i,k);

        BitBlt(hdc, 0, rw.bottom-FRM,  rw.right,  FRM, hdc_back, 0, rw.bottom-FRM, SRCCOPY);
        BitBlt(hdc, rw.right-FRM,  0,  FRM, rw.bottom, hdc_back, rw.right-FRM,  0, SRCCOPY);
    }

    SetTextColor (hdc, mStyle.MenuTitle.TextColor );
    SetBkMode    (hdc, TRANSPARENT);
    //SelectObject (hdc, hfnt_sb);
    SelectObject (hdc, fnt2);
    format_status(bstr,1);
    DrawText(hdc, bstr, strlen(bstr), &r,
        //mStyle.MenuTitle.justify|DT_VCENTER|DT_SINGLELINE
        DT_LEFT|DT_VCENTER|DT_SINGLELINE
        );

    if (edp==NULL) goto paint_end;

    if (infomsg[0]) {

        SetBkColor   (hdc, My_Colors[2]);
        SetTextColor (hdc, My_Colors[3]);
        SetBkMode    (hdc,OPAQUE);

        SelectObject (hdc, fnt1);

        sprintf(bstr," %s ",infomsg);
        n=strlen(bstr);

        GetTextExtentPoint32 (hdc, bstr, n, &sz);
        y=cwy-sz.cy;
        x=cwx-sz.cx;
        if (x<0) x = 0;
        TextOut(hdc, x, y, bstr, n);
    }

    {
        StyleItem *pSI = &MenuInfo.Scroller;
        get_vscr_rect(&rw);
        MakeGradient_s(hdc, rw, pSI, pSI->bordered ?  pSI->borderWidth : 0);
    }

#if 0
    if (lmax==0
       && yy>=imin(tlin-plin,pgy)
       && mm>(pgx<50?pgx:pgx*6/5)
        ) lmax=mm;
#endif


paint_end:
    SelectObject (hdc, hfnt0);

#ifdef MEMDC
    BitBltRect(fhdc, hdc, &ps.rcPaint);
    //BitBlt(fhdc,0,0,cwx+FRM,cwy+FRM,hdc,0,0,SRCCOPY);
    SelectObject (hdc, bm0);
    DeleteDC(hdc);
    DeleteObject (bm);
#endif
    EndPaint (hwnd, &ps) ;

    if (edp && 0==scroll_lock && caret==1)
        ShowCaret(hwnd), caret=3;
}
Exemplo n.º 5
0
//===========================================================================
void PaintToolbar(HDC hdc, RECT *rcPaint)
{
	RECT r; int i; const TCHAR *label = Toolbar_CurrentWindow; StyleItem *pSI;

#ifdef BBOPT_MEMCHECK
	// Display some statistics.
#pragma message("\n"__FILE__ "(397) : warning 0: MEMCHECK enabled.\n")
	/*
    if (NULL==Toolbar_hFont)
    {
        LOGFONT logFont;
        SystemParametersInfo(SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
        Toolbar_hFont = CreateFontIndirect(&logFont);
    }
	 */
	extern int g_menu_count;
	extern int g_menu_item_count;
	TCHAR temp[256];
	if (alloc_size && false == Toolbar_ShowingExternalLabel)
	{
		_stprintf(temp,_T("Menus %d  MenuItems %d  Memory %d"), g_menu_count, g_menu_item_count, alloc_size);
		label = temp;

	}
#endif

	int tbW = TBInfo.width;
	int tbH = TBInfo.height;
	HDC buf = CreateCompatibleDC(NULL);
	HGDIOBJ bufother = SelectObject(buf, CreateCompatibleBitmap(hdc, tbW, tbH));

	if (NULL==Toolbar_hFont) Toolbar_hFont = CreateStyleFont(&mStyle.Toolbar);
	HGDIOBJ other_font = SelectObject(buf, Toolbar_hFont);

	// Get width of clock...
	SIZE size;

	GetTextExtentPoint32(buf, Toolbar_CurrentTime, (int)_tcsnlen(Toolbar_CurrentTime,0x7FFFFFFFUL), &size);
	size.cx += 6;
	if (tbClockW < size.cx) tbClockW = size.cx + 6;

	GetTextExtentPoint32(buf, Toolbar_WorkspaceName, (int)_tcsnlen(Toolbar_WorkspaceName,0x7FFFFFFFUL), &size);
	int tbLabelW = size.cx + 6;

	// The widest sets the width!
	tbLabelW = tbClockW = (int)imax(tbH * 2, imax(tbLabelW, tbClockW));

	int margin = tbMargin;
	int border = mStyle.Toolbar.borderWidth;
	int border_margin = margin + border;
	int button_padding = (tbH - tbButtonWH) / 2 - border;

	int tbLabelX = border_margin;
	int tbClockX = tbW - tbClockW - border_margin;
	int two_buttons = 2*tbButtonWH + 3*button_padding;
	int tbWinLabelX = tbLabelX + tbLabelW + two_buttons;
	int tbWinLabelW = tbClockX - tbWinLabelX - two_buttons;
	if (tbWinLabelW < 0) tbWinLabelW = 0;

	Toolbar_Button[0].r.left = tbLabelX + tbLabelW + button_padding;
	Toolbar_Button[1].r.left = Toolbar_Button[0].r.left + tbButtonWH + button_padding;
	Toolbar_Button[2].r.left = tbClockX - 2*tbButtonWH - 2*button_padding;
	Toolbar_Button[3].r.left = Toolbar_Button[2].r.left + tbButtonWH + button_padding;

	Toolbar_Button[4].r.left = tbClockX;
	for (i = 0; i<5; i++)
	{
		Toolbar_Button[i].r.top    = (tbH - tbButtonWH) / 2;
		Toolbar_Button[i].r.bottom = Toolbar_Button[i].r.top + tbButtonWH;
		Toolbar_Button[i].r.right  = Toolbar_Button[i].r.left + tbButtonWH;
	}
	Toolbar_Button[4].r.right = tbClockX + tbClockW;

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

	// Paint toolbar Style
	_SetRect(&r, 0, 0, tbW, tbH); pSI = &mStyle.Toolbar;
	MakeStyleGradient(buf, &r, pSI, true);

	//====================
	// Paint unpressed workspace/task buttons...

	r.left = r.top = 0; r.right = r.bottom = tbButtonWH;
	{
		HPEN activePen   = CreatePen(PS_SOLID, 1, mStyle.ToolbarButtonPressed.picColor);
		HPEN inactivePen = CreatePen(PS_SOLID, 1, mStyle.ToolbarButton.picColor);
		HDC src = CreateCompatibleDC(NULL);
		HGDIOBJ srcother = SelectObject(src, CreateCompatibleBitmap(hdc, tbButtonWH, tbButtonWH));
		int yOffset = tbH / 2; int xOffset; int f1 = -1;
		for (i=0; i<4; i++)
		{
			int f2 = Toolbar_Button[i].pressed || (Toolbar_force_button_pressed && i&1);
			pSI = f2 ? &mStyle.ToolbarButtonPressed : &mStyle.ToolbarButton;

			if (pSI->parentRelative)
			{
				CreateBorder(buf, &r, pSI->borderColor, pSI->borderWidth);
			}
			else
			{
				if (f1 != f2)
					MakeStyleGradient(src, &r, pSI, pSI->bordered), f1 = f2;

				BitBlt(buf,
					   Toolbar_Button[i].r.left,
					   Toolbar_Button[i].r.top,
					   tbButtonWH, tbButtonWH, src, 0, 0, SRCCOPY
					   );
			}

			xOffset = Toolbar_Button[i].r.left + (tbButtonWH / 2);
			HGDIOBJ penother = SelectObject(buf, f2 ? activePen : inactivePen);
			arrow_bullet(buf, xOffset, yOffset, (i&1)*2-1);
			SelectObject(buf, penother);
		}

		DeleteObject(SelectObject(src, srcother));
		DeleteDC(src);
		DeleteObject(inactivePen);
		DeleteObject(activePen);
	}

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

	r.top = (tbH - tbLabelH)/2;
	r.bottom = r.top + tbLabelH;
	SetBkMode(buf, TRANSPARENT);
	int justify = mStyle.Toolbar.Justify | (DT_VCENTER|DT_SINGLELINE|DT_WORD_ELLIPSIS|DT_NOPREFIX);

	// Paint workspaces background...
	r.right = (r.left = tbLabelX) + tbLabelW; pSI = &mStyle.ToolbarLabel;
	MakeStyleGradient(buf, &r, pSI, pSI->bordered);
	_InflateRect(&r, -3, 0);
	BBDrawText(buf, Toolbar_WorkspaceName, -1, &r, justify, pSI);

	// Paint window label background...
	r.right = (r.left = tbWinLabelX) + tbWinLabelW; pSI = &mStyle.ToolbarWindowLabel;
	MakeStyleGradient(buf, &r, pSI, pSI->bordered);
	_InflateRect(&r, -3, 0);
	BBDrawText(buf, label, -1, &r, justify, pSI);

	// Paint clock background...
	r.right = (r.left = tbClockX) + tbClockW; pSI = &mStyle.ToolbarClock;
	MakeStyleGradient(buf, &r, pSI, pSI->bordered);
	_InflateRect(&r, -3, 0);
	BBDrawText(buf, Toolbar_CurrentTime, -1, &r, justify, pSI);

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

	BitBltRect(hdc, buf, rcPaint);

	SelectObject(buf, other_font);
	DeleteObject(SelectObject(buf, bufother));
	DeleteDC(buf);
}
Exemplo n.º 6
0
ST LRESULT CALLBACK Desk_WndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    static const UINT msgs [] = { BB_DRAGTODESKTOP, BB_REDRAWGUI, 0 };
    static bool button_down, dblclk;
    int n;

    switch (uMsg)
    {
        //====================
        case WM_CREATE:
            hDesktopWnd = hwnd;
            MakeSticky(hwnd);
            MessageManager_Register(hwnd, msgs, true);
            init_DeskDropTarget(hwnd);
            Desk_SetPosition();
            break;

        //====================
        case WM_DESTROY:
            exit_DeskDropTarget(hwnd);
            MessageManager_Register(hwnd, msgs, false);
            RemoveSticky(hwnd);
            break;

        case WM_NCPAINT:
            // dbg_printf("ncpaint: %x %x %x %x", hwnd, uMsg, wParam, lParam);
            // keep the window on bottom
            Desk_SetPosition();
            break;

        case WM_SETTINGCHANGE:
			if (SPI_SETDESKWALLPAPER == wParam)
			{
				CHAR oldWallPaper[(MAX_PATH + 1)];
				if (TRUE == SystemParametersInfo(SPI_GETDESKWALLPAPER, sizeof(oldWallPaper), &oldWallPaper, 0))
					Desk_read_background(oldWallPaper);
					//Desk_new_background(oldWallPaper);
					//Desk_read_background(oldWallPaper);
				Desk_SetPosition();

				//InvalidateRect(hwnd, NULL, FALSE);
			}
            break;


        //====================
        case WM_CLOSE:
            break;

        //====================
        case WM_MOUSEACTIVATE:
            return MA_NOACTIVATE;
        
        case WM_LBUTTONDOWN:
        case WM_RBUTTONDOWN:
        case WM_MBUTTONDOWN:
        case WM_XBUTTONDOWN:
            dblclk = false;
            button_down = true;
            if (uMsg == WM_LBUTTONDOWN) {
                n = 0;
                goto post_click_2;
            }
            break;

        case WM_MOUSEMOVE:
            break;

        case WM_LBUTTONDBLCLK:
        case WM_RBUTTONDBLCLK:
        case WM_MBUTTONDBLCLK:
            dblclk = true;
            button_down = true;
            break;

        case WM_LBUTTONUP: n = dblclk ? 7 : 1; goto post_click;
        case WM_RBUTTONUP: n = 2; goto post_click;
        case WM_MBUTTONUP: n = 3; goto post_click;
        case WM_XBUTTONUP:
            switch (HIWORD(wParam)) {
            case XBUTTON1: n = 4; goto post_click;
            case XBUTTON2: n = 5; goto post_click;
            case XBUTTON3: n = 6; goto post_click;
            } break;

        post_click:
            if (false == button_down)
                break;
            button_down = dblclk = false;

        post_click_2:
            wParam &= (MK_CONTROL|MK_SHIFT);
            if (0x8000 & GetAsyncKeyState(VK_MENU))
                wParam |= MK_ALT;

            PostMessage(BBhwnd, BB_DESKCLICK, wParam, n);
            break;

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

        case WM_PAINT:
        {
            PAINTSTRUCT ps;
            HDC hdc_scrn;
            HDC hdc_bmp;
            HGDIOBJ other;

            hdc_scrn = BeginPaint(hwnd, &ps);
            if (Root.bmp) {
                hdc_bmp = CreateCompatibleDC(hdc_scrn);
                other = SelectObject(hdc_bmp, Root.bmp);
                BitBltRect(hdc_scrn, hdc_bmp, &ps.rcPaint);
                SelectObject(hdc_bmp, other);
                DeleteDC(hdc_bmp);
            } else {
                PaintDesktop(hdc_scrn);
            }
            EndPaint(hwnd, &ps);
            break;
        }

        //====================
        case WM_ERASEBKGND:
            return TRUE;

        //====================
        case BB_DRAGTODESKTOP:
            return get_drop_command((const char *)lParam, wParam);

        case BB_REDRAWGUI:
            if (wParam & BBRG_DESK)
                Desk_new_background("style");
            break;

        //====================
        default:
            return DefWindowProc(hwnd, uMsg, wParam, lParam);
    }
    return 0;
}
Exemplo n.º 7
0
//===========================================================================
static void PaintToolbar(HDC hdc, RECT *rcPaint)
{
    RECT r;
    StyleItem *pSI;
    struct button *btn;

    HDC buf;
    HGDIOBJ bufother, other_font;
    int size;

    int margin, border, border_margin, button_padding, middle_padding, two_buttons;
    int tbW, tbH, tbLabelW, tbLabelX, tbClockX, tbWinLabelX, tbWinLabelW;
    int i, justify;

    tbW = TBInfo.width;
    tbH = TBInfo.height;
    buf = CreateCompatibleDC(NULL);
    bufother = SelectObject(buf, CreateCompatibleBitmap(hdc, tbW, tbH));

    if (NULL==Toolbar_hFont)
        Toolbar_hFont = CreateStyleFont(&mStyle.Toolbar);
    other_font = SelectObject(buf, Toolbar_hFont);

    size = 6 + get_text_extend(buf, Toolbar_CurrentTime);
    if (tbClockW < size)
        tbClockW = size + 2*tbLabelIndent;

    size = get_text_extend(buf, Toolbar_WorkspaceName);
    tbLabelW = size + 2*tbLabelIndent;

    // The widest sets the width!
    tbLabelW = tbClockW = imax(tbH * 2, imax(tbLabelW, tbClockW));

    margin = tbMargin;
    border = mStyle.Toolbar.borderWidth;
    border_margin = margin + border;
    button_padding = (tbH - tbButtonWH) / 2 - border;
    middle_padding = button_padding;
    if (0 == button_padding)
        middle_padding -= mStyle.ToolbarButton.borderWidth;

    tbLabelX = border_margin;
    tbClockX = tbW - tbClockW - border_margin;
    two_buttons = 2*tbButtonWH + 2*button_padding + middle_padding;
    tbWinLabelX = tbLabelX + tbLabelW + two_buttons;
    tbWinLabelW = tbClockX - tbWinLabelX - two_buttons;
    if (tbWinLabelW < 0) tbWinLabelW = 0;

    btn = Toolbar_Button;
    btn[0].r.left = tbLabelX + tbLabelW + button_padding;
    btn[1].r.left = btn[0].r.left + tbButtonWH + middle_padding;
    btn[2].r.left = tbClockX - 2*tbButtonWH - button_padding - middle_padding;
    btn[3].r.left = btn[2].r.left + tbButtonWH + middle_padding;
    btn[4].r.left = tbClockX;
    for (i = 0; i<5; i++) {
        btn[i].r.top    = (tbH - tbButtonWH) / 2;
        btn[i].r.bottom = btn[i].r.top + tbButtonWH;
        btn[i].r.right  = btn[i].r.left + tbButtonWH;
    }
    btn[4].r.right = tbClockX + tbClockW;

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

    // Paint toolbar Style
    r.left = r.top = 0;
    r.right = tbW;
    r.bottom = tbH;
    pSI = &mStyle.Toolbar;
    MakeStyleGradient(buf, &r, pSI, pSI->bordered);

    //====================
    // Paint unpressed workspace/task buttons...

    r.left = r.top = 0;
    r.right = r.bottom = tbButtonWH;
    {
        HDC src;
        HGDIOBJ srcother;
        int x, y, f2, f1 = -1;
        src = CreateCompatibleDC(NULL);
        srcother = SelectObject(src, CreateCompatibleBitmap(hdc, tbButtonWH, tbButtonWH));
        for (i = 0; i < 4; i++)
        {
            btn = Toolbar_Button + i;
            f2 = btn->pressed || (Toolbar_force_button_pressed && (i&1));
            x = btn->r.left, y = btn->r.top;
            pSI = f2 ? &mStyle.ToolbarButtonPressed : &mStyle.ToolbarButton;
            if (pSI->parentRelative) {
                RECT b;
                b.left = x, b.top = y, b.right = x+r.right, b.bottom = y+r.bottom;
                CreateBorder(buf, &b, pSI->borderColor, pSI->borderWidth);
            } else {
                if (f1 != f2) {
                    MakeStyleGradient(src, &r, pSI, pSI->bordered);
                    f1 = f2;
                }
                BitBlt(buf, x, y, tbButtonWH, tbButtonWH, src, 0, 0, SRCCOPY);
            }
            bbDrawPix(buf, &btn->r, pSI->picColor, (i&1) ? BS_TRIANGLE : -BS_TRIANGLE);
        }

        DeleteObject(SelectObject(src, srcother));
        DeleteDC(src);
    }

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

    r.top = (tbH - tbLabelH)/2;
    r.bottom = r.top + tbLabelH;
    SetBkMode(buf, TRANSPARENT);
    justify = mStyle.Toolbar.Justify | (DT_VCENTER|DT_SINGLELINE|DT_WORD_ELLIPSIS|DT_NOPREFIX);

    // Paint workspaces background...
    r.right = (r.left = tbLabelX) + tbLabelW;
    pSI = &mStyle.ToolbarLabel;
    MakeStyleGradient(buf, &r, pSI, pSI->bordered);
    r.left  += tbLabelIndent;
    r.right -= tbLabelIndent;
    bbDrawText(buf, Toolbar_WorkspaceName, &r, justify, pSI->TextColor);

    // Paint window label background...
    r.right = (r.left = tbWinLabelX) + tbWinLabelW;
    pSI = &mStyle.ToolbarWindowLabel;
    MakeStyleGradient(buf, &r, pSI, pSI->bordered);
    r.left  += tbLabelIndent;
    r.right -= tbLabelIndent;
    bbDrawText(buf, Toolbar_CurrentWindow, &r, justify, pSI->TextColor);

    // Paint clock background...
    r.right = (r.left = tbClockX) + tbClockW;
    pSI = &mStyle.ToolbarClock;
    MakeStyleGradient(buf, &r, pSI, pSI->bordered);
    r.left  += tbLabelIndent;
    r.right -= tbLabelIndent;
    bbDrawText(buf, Toolbar_CurrentTime, &r, justify, pSI->TextColor);

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

    BitBltRect(hdc, buf, rcPaint);

    SelectObject(buf, other_font);
    DeleteObject(SelectObject(buf, bufother));
    DeleteDC(buf);
}