Ejemplo n.º 1
0
//
/// Paints a close box on the tiny caption bar. You can override the default box if
/// you want to design your own close box.
//
void
TTinyCaption::PaintCloseBox(TDC& dc, TRect& boxRect, bool pressed)
{
    // Fill the box with light gray & draw bevel if possible
    //
    PaintButton(dc, boxRect, pressed);

    if (pressed)
        boxRect.Offset(1,1);

    // Do something different to differentiate from standard system menu--
    // draw a recessed black box glyph about half the button size, centered
    //
    int glyphWidth  = boxRect.Width() > 7 ?
                      boxRect.Width()-boxRect.Width()/2-1 : boxRect.Width()-3;
    int glyphHeight = boxRect.Height() > 7 ?
                      boxRect.Height()-boxRect.Height()/2-1 : boxRect.Height()-3;
    if (glyphWidth > 1 && glyphHeight > 1) {
        TRect glyphRect(0, 0, glyphWidth, glyphHeight);
        glyphRect.Offset(boxRect.left + (boxRect.Width()-glyphWidth-1)/2,
                         boxRect.top + (boxRect.Height()-glyphHeight-1)/2);

        dc.TextRect(glyphRect, TColor::Sys3dShadow);
        glyphRect.Offset(1,1);
        dc.TextRect(glyphRect, TColor::Sys3dHilight);
        glyphRect.BottomRight().Offset(-1,-1);
        dc.TextRect(glyphRect, TColor::SysBtnText);
    }
}
Ejemplo n.º 2
0
void
TabDisplay::OnPaint(Canvas &canvas)
{
  canvas.Clear(COLOR_BLACK);
  canvas.Select(*look.button.font);

  const unsigned CaptionStyle = DT_CENTER | DT_NOCLIP
      | DT_WORDBREAK;

  const bool is_focused = !HasCursorKeys() || HasFocus();
  for (unsigned i = 0; i < buttons.size(); i++) {
    const TabButton &button = *buttons[i];

    const bool is_down = dragging && i == down_index && !drag_off_button;
    const bool is_selected = i == tab_bar.GetCurrentPage();

    canvas.SetTextColor(look.list.GetTextColor(is_selected, is_focused,
                                               is_down));
    canvas.SetBackgroundColor(look.list.GetBackgroundColor(is_selected,
                                                           is_focused,
                                                           is_down));

    const PixelRect &rc = GetButtonSize(i);
    PaintButton(canvas, CaptionStyle, button.caption, rc, button.bitmap,
                is_down, is_selected);
  }
}
Ejemplo n.º 3
0
SOM_Scope MRESULT   SOMLINK VRIconButtonInstance_vrWM_CONTROL(VRIconButton *somSelf,
		HWND hWnd,
		ULONG msg,
		MPARAM mp1,
		MPARAM mp2)
{
    VRIconButtonData *somThis = VRIconButtonGetData(somSelf);
    VRIconButtonMethodDebug("VRIconButton","VRIconButtonInstance_vrWM_CONTROL");

    if ( SHORT2FROMMP( mp1 ) == BN_PAINT ) {
        PaintButton( somSelf, (PUSERBUTTON) mp2 );
    }

    return (MRESULT) 0;
}
Ejemplo n.º 4
0
//
/// Paints a maximize box on the tiny caption bar.
//
void
TTinyCaption::PaintMaxBox(TDC& dc, TRect& boxRect, bool pressed)
{
    // Fill the box with light gray & draw bevel if possible
    //
    PaintButton(dc, boxRect, pressed);

    if (pressed)
        boxRect.Offset(1,1);

    // Down triangle
    //
    int bh = boxRect.Height();
    int bw = boxRect.Width();

    if (IsZoomed()) {
        TPoint begPt = boxRect.BottomLeft().OffsetBy((bw+1)/4, -bh*3/8);
        TPoint endPt = begPt.OffsetBy((bw+1)/2, 0);
        while (begPt.x < endPt.x) {
            dc.MoveTo(begPt);
            dc.LineTo(endPt);
            begPt.Offset(1,1);
            endPt.Offset(-1,1);
        }
    }

    // Up triangle
    //
    {
        TPoint begPt = boxRect.TopLeft().OffsetBy((bw+1)/4, IsZoomed() ? bh*3/8 : bh*2/3);
        TPoint endPt = begPt.OffsetBy((bw+1)/2, 0);
        while (begPt.x < endPt.x) {
            dc.MoveTo(begPt);
            dc.LineTo(endPt);
            begPt.Offset(1, -1);
            endPt.Offset(-1, -1);
        }
    }
}
Ejemplo n.º 5
0
//
/// Paints a minimize box on the tiny caption bar.
//
void
TTinyCaption::PaintMinBox(TDC& dc, TRect& boxRect, bool pressed)
{
    // Fill the box with light gray & draw bevel if possible
    //
    PaintButton(dc, boxRect, pressed);

    if (pressed)
        boxRect.Offset(1,1);

    int bh = boxRect.Height();
    int bw = boxRect.Width();

    TPoint begPt = boxRect.TopLeft().OffsetBy((bw+1)/4, (bh+2)/3);
    TPoint endPt = begPt.OffsetBy((bw+1)/2,0);
    while (begPt.x < endPt.x) {
        dc.MoveTo(begPt);
        dc.LineTo(endPt);
        begPt.Offset(1,1);
        endPt.Offset(-1,1);
    }
}
Ejemplo n.º 6
0
SOM_Scope MRESULT   SOMLINK VRIconButtonInstance_vrWM_PAINT(VRIconButton *somSelf,
		HWND hWnd,
		ULONG msg,
		MPARAM mp1,
		MPARAM mp2)
{
    USERBUTTON btn = {0};
    RECTL rcl;
    VRIconButtonData *somThis = VRIconButtonGetData(somSelf);
    VRIconButtonMethodDebug("VRIconButton","VRIconButtonInstance_vrWM_PAINT");

    if ( VRQueryRunMode() == VR_DESIGN_MODE ) {
        /* Workaround for BN_PAINT apparently not getting sent to groupbox
         * children when in VX-REXX is in Design mode.
         */
        btn.hps = WinBeginPaint( hWnd, NULLHANDLE, &rcl );
        btn.hwnd = hWnd;
        PaintButton( somSelf, &btn );
        WinEndPaint( btn.hps );
        return (MRESULT) 0;
    }
    else
        return _vrCallDefProc( somSelf, hWnd, msg, mp1, mp2 );
}
Ejemplo n.º 7
0
// Paint the button
void QPictureButton::paintEvent(QPaintEvent*)
{
    PaintButton();
    PaintIcon();
    PaintText();
}
Ejemplo n.º 8
0
/**
 * name:	Button_WndProc
 * desc:	window procedure for the button class
 * param:	hwndBtn		- window handle to the button
 *			uMsg		- message to handle
 *			wParam		- message specific parameter
 *			lParam		- message specific parameter
 * return:	message specific
 **/
static LRESULT CALLBACK Button_WndProc(HWND hwndBtn, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    LPBTNCTRL bct = (LPBTNCTRL)GetWindowLongPtr(hwndBtn, 0);

    switch (uMsg) {
    case WM_NCCREATE:
    {
        LPCREATESTRUCT cs = (LPCREATESTRUCT)lParam;

        cs->style |= BS_OWNERDRAW;
        if (!(bct = (LPBTNCTRL)mir_alloc(sizeof(BTNCTRL))))
            return FALSE;
        memset(bct, 0, sizeof(BTNCTRL));
        bct->hwnd = hwndBtn;
        bct->stateId = PBS_NORMAL;
        bct->hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
        bct->dwStyle = cs->style;
        if (cs->style & MBS_DOWNARROW)
            bct->arrow = GetIconBtn(ICO_BTN_DOWNARROW);
        LoadTheme(bct);
        SetWindowLongPtr(hwndBtn, 0, (LONG_PTR)bct);
        if (cs->lpszName)
            SetWindowText(hwndBtn, cs->lpszName);
    }
    return TRUE;

    case WM_DESTROY:
        if (bct) {
            mir_cslock lck(csTips);
            if (hwndToolTips) {
                TOOLINFO ti;

                memset(&ti, 0, sizeof(ti));
                ti.cbSize = sizeof(ti);
                ti.uFlags = TTF_IDISHWND;
                ti.hwnd = bct->hwnd;
                ti.uId = (UINT_PTR)bct->hwnd;
                if (SendMessage(hwndToolTips, TTM_GETTOOLINFO, 0, (LPARAM)&ti)) {
                    SendMessage(hwndToolTips, TTM_DELTOOL, 0, (LPARAM)&ti);
                }
                if (SendMessage(hwndToolTips, TTM_GETTOOLCOUNT, 0, (LPARAM)&ti) == 0) {
                    DestroyWindow(hwndToolTips);
                    hwndToolTips = NULL;
                }
            }
            DestroyTheme(bct);
            mir_free(bct);
        }
        SetWindowLongPtr(hwndBtn, 0, 0);
        break;

    case WM_SETTEXT:
        bct->cHot = 0;
        if ((LPTSTR)lParam) {
            LPTSTR tmp = (LPTSTR)lParam;

            while (*tmp) {
                if (*tmp == '&' && *(tmp + 1)) {
                    bct->cHot = _totlower(*(tmp + 1));
                    break;
                }
                tmp++;
            }
            InvalidateRect(bct->hwnd, NULL, TRUE);
        }
        break;

    case WM_SYSKEYUP:
        if (bct->stateId != PBS_DISABLED && bct->cHot && bct->cHot == _totlower((TCHAR)wParam)) {
            if (bct->dwStyle & MBS_PUSHBUTTON) {
                if (bct->pbState) bct->pbState = 0;
                else bct->pbState = 1;
                InvalidateRect(bct->hwnd, NULL, TRUE);
            }
            else
                SetFocus(hwndBtn);
            SendMessage(GetParent(hwndBtn), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndBtn), BN_CLICKED), (LPARAM)hwndBtn);
            return 0;
        }
        break;

    case WM_THEMECHANGED:
        // themed changed, reload theme object
        LoadTheme(bct);
        InvalidateRect(bct->hwnd, NULL, TRUE); // repaint it
        break;

    case WM_SETFONT: // remember the font so we can use it later
        bct->hFont = (HFONT)wParam; // maybe we should redraw?
        break;

    case WM_NCPAINT:
    case WM_PAINT:
    {
        PAINTSTRUCT ps;
        HDC hdcPaint;
        HDC hdcMem;
        HBITMAP hbmMem;
        HDC hOld;
        RECT rcClient;

        if (hdcPaint = BeginPaint(hwndBtn, &ps)) {
            GetClientRect(bct->hwnd, &rcClient);
            hdcMem = CreateCompatibleDC(hdcPaint);
            hbmMem = CreateCompatibleBitmap(hdcPaint, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top);
            hOld = (HDC)SelectObject(hdcMem, hbmMem);

            // If its a push button, check to see if it should stay pressed
            if ((bct->dwStyle & MBS_PUSHBUTTON) && bct->pbState) bct->stateId = PBS_PRESSED;

            if ((bct->dwStyle & MBS_FLAT) && bct->hThemeToolbar || bct->hThemeButton)
                PaintThemeButton(bct, hdcMem, &rcClient);
            else
                PaintButton(bct, hdcMem, &rcClient);

            BitBlt(hdcPaint, 0, 0, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top, hdcMem, 0, 0, SRCCOPY);
            SelectObject(hdcMem, hOld);
            DeleteObject(hbmMem);
            DeleteDC(hdcMem);
            EndPaint(hwndBtn, &ps);
        }
    }
    return 0;

    case BM_SETIMAGE:
        if (wParam == IMAGE_ICON) {
            bct->hIcon = (HICON)lParam;
            bct->hBitmap = NULL;
            InvalidateRect(bct->hwnd, NULL, TRUE);
        }
        else if (wParam == IMAGE_BITMAP) {
            bct->hIcon = NULL;
            bct->hBitmap = (HBITMAP)lParam;
            InvalidateRect(bct->hwnd, NULL, TRUE);
        }
        else if (wParam == NULL && lParam == NULL) {
            bct->hIcon = NULL;
            bct->hBitmap = NULL;
            InvalidateRect(bct->hwnd, NULL, TRUE);
        }
        break;

    case BM_SETCHECK:
        if (!(bct->dwStyle & MBS_PUSHBUTTON)) break;
        if (wParam == BST_CHECKED) {
            bct->pbState = 1;
            bct->stateId = PBS_PRESSED;
        }
        else if (wParam == BST_UNCHECKED) {
            bct->pbState = 0;
            bct->stateId = PBS_NORMAL;
        }
        InvalidateRect(bct->hwnd, NULL, TRUE);
        break;

    case BM_GETCHECK:
        if (bct->dwStyle & MBS_PUSHBUTTON) return bct->pbState ? BST_CHECKED : BST_UNCHECKED;
        return 0;

    case BUTTONSETDEFAULT:
        bct->defbutton = (wParam != 0);
        InvalidateRect(bct->hwnd, NULL, TRUE);
        break;

    case BUTTONADDTOOLTIP:
        if (wParam) {
            mir_cslock lck(csTips);
            if (!hwndToolTips)
                hwndToolTips = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP, 0, 0, 0, 0, NULL, NULL, GetModuleHandle(NULL), NULL);

            if (lParam == MBBF_UNICODE) {
                TOOLINFOW ti;

                memset(&ti, 0, sizeof(TOOLINFOW));
                ti.cbSize = sizeof(TOOLINFOW);
                ti.uFlags = TTF_IDISHWND;
                ti.hwnd = bct->hwnd;
                ti.uId = (UINT_PTR)bct->hwnd;
                if (SendMessage(hwndToolTips, TTM_GETTOOLINFOW, 0, (LPARAM)&ti)) {
                    SendMessage(hwndToolTips, TTM_DELTOOLW, 0, (LPARAM)&ti);
                }
                ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
                ti.uId = (UINT_PTR)bct->hwnd;
                ti.lpszText = (LPWSTR)wParam;
                SendMessage(hwndToolTips, TTM_ADDTOOLW, 0, (LPARAM)&ti);
            }
            else {
                TOOLINFOA ti;

                memset(&ti, 0, sizeof(TOOLINFOA));
                ti.cbSize = sizeof(TOOLINFOA);
                ti.uFlags = TTF_IDISHWND;
                ti.hwnd = bct->hwnd;
                ti.uId = (UINT_PTR)bct->hwnd;
                if (SendMessage(hwndToolTips, TTM_GETTOOLINFOA, 0, (LPARAM)&ti)) {
                    SendMessage(hwndToolTips, TTM_DELTOOLA, 0, (LPARAM)&ti);
                }
                ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
                ti.uId = (UINT_PTR)bct->hwnd;
                ti.lpszText = (LPSTR)wParam;
                SendMessage(hwndToolTips, TTM_ADDTOOLA, 0, (LPARAM)&ti);
            }
        }
        break;

    case BUTTONTRANSLATE:
        TCHAR szButton[MAX_PATH];
        GetWindowText(bct->hwnd, szButton, _countof(szButton));
        SetWindowText(bct->hwnd, TranslateTS(szButton));
        break;

    case WM_SETFOCUS: // set keybord bFocus and redraw
        bct->bFocus = 1;
        InvalidateRect(bct->hwnd, NULL, TRUE);
        break;

    case WM_KILLFOCUS: // kill bFocus and redraw
        bct->bFocus = 0;
        InvalidateRect(bct->hwnd, NULL, TRUE);
        break;

    case WM_WINDOWPOSCHANGED:
        InvalidateRect(bct->hwnd, NULL, TRUE);
        break;

    case WM_ENABLE: // windows tells us to enable/disable
        bct->stateId = wParam ? PBS_NORMAL : PBS_DISABLED;
        InvalidateRect(bct->hwnd, NULL, TRUE);
        break;

    case WM_MOUSELEAVE: // faked by the WM_TIMER
        if (bct->stateId != PBS_DISABLED) { // don't change states if disabled
            bct->stateId = PBS_NORMAL;
            InvalidateRect(bct->hwnd, NULL, TRUE);
        }
        break;

    case WM_LBUTTONDOWN:
        if (bct->stateId != PBS_DISABLED) { // don't change states if disabled
            bct->stateId = PBS_PRESSED;
            InvalidateRect(bct->hwnd, NULL, TRUE);
        }
        break;

    case WM_LBUTTONUP:
        if (bct->stateId != PBS_DISABLED) { // don't change states if disabled
            BYTE bPressed = bct->stateId == PBS_PRESSED;

            if (bct->dwStyle & MBS_PUSHBUTTON) {
                if (bct->pbState) bct->pbState = 0;
                else bct->pbState = 1;
            }
            bct->stateId = PBS_HOT;

            // Tell your daddy you got clicked, if mouse is still over the button.
            if ((bct->dwStyle & MBS_PUSHBUTTON) || bPressed)
                SendMessage(GetParent(hwndBtn), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndBtn), BN_CLICKED), (LPARAM)hwndBtn);
            InvalidateRect(bct->hwnd, NULL, TRUE);
        }
        break;

    case WM_MOUSEMOVE:
        if (bct->stateId == PBS_NORMAL) {
            bct->stateId = PBS_HOT;
            InvalidateRect(bct->hwnd, NULL, TRUE);
        }
        // Call timer, used to start cheesy TrackMouseEvent faker
        SetTimer(hwndBtn, BUTTON_POLLID, BUTTON_POLLDELAY, NULL);
        break;

    case WM_TIMER: // use a timer to check if they have did a mouseout
        if (wParam == BUTTON_POLLID) {
            RECT rc;
            POINT pt;

            GetWindowRect(hwndBtn, &rc);
            GetCursorPos(&pt);
            if (!PtInRect(&rc, pt)) { // mouse must be gone, trigger mouse leave
                PostMessage(hwndBtn, WM_MOUSELEAVE, 0, 0L);
                KillTimer(hwndBtn, BUTTON_POLLID);
            }
        }
        break;
    case WM_ERASEBKGND:
        return 1;
    }
    return DefWindowProc(hwndBtn, uMsg, wParam, lParam);
}
Ejemplo n.º 9
0
void PageWin::OnPaint()
{
  sInt i,max,j;
  PageOp *po;
  PageDoc *pd;
  sRect r;
  sInt shadow;
  sU32 col;
  sChar *name;

 //  ToolWindow *tw;
//  ToolObject *to;
  static sChar *dragmodes[] = { "???","pick","rect","duplicate","width","select","move","scroll" };

  if(Flags&sGWF_CHILDFOCUS)
  {
    App->SetStat(0,dragmodes[DragKey]);
    OpWindowX = -1;
    OpWindowY = -1;
  }

  sPainter->Paint(sGui->FlatMat,Client,sGui->Palette[sGC_BACK]);
  if(Doc==0)
  {
    sPainter->PrintC(sGui->PropFont,Client,0,"Page");
  }
  else
  {
    pd = Doc;
    max = pd->Ops->GetCount();

    // paint body

    for(i=0;i<max;i++)
    {
      po = pd->Ops->Get(i);
      po->MakeRect(r,Client);
      name = po->Class->Name;
      if(po->Class->Flags & (POCF_STORE|POCF_LOAD|POCF_LABEL))
      {
        if(po->Data[1].Anim)
          name = po->Data[1].Anim;
      }
      PaintButton(r,name,po->Error ? 0xffff00000 : po->Class->Color,po->Selected,0);
      if(po->Edited)
        sPainter->Paint(sGui->FlatMat,r.x0+4,r.y0+4,8,4,0xff7f0000);
      if(po->Showed)
        sPainter->Paint(sGui->FlatMat,r.x0+4,r.y1-8,8,4,0xff007f00);
      if(po->Cache)
        sPainter->Paint(sGui->FlatMat,r.x0+4,r.y0+8,8,r.y1-r.y0-16,0xff00007f);
      if(po->Class->Flags & (POCF_LOAD|POCF_LABEL))
      {
        col = sGui->Palette[po->Selected?sGC_LOW2:sGC_HIGH2];
        for(j=4;j>=0;j--)
        {
          sPainter->Line(r.x0+j,r.y0,r.x0,r.y0+j,col);
          sPainter->Line(r.x1-j-1,r.y0,r.x1-1,r.y0+j,col);
          col = sGui->Palette[sGC_BACK];
        }
        sPainter->Line(r.x0,r.y0,r.x0,r.y0+5-2,col);
        sPainter->Line(r.x1-1,r.y0,r.x1-1,r.y0+5-2,col);
        col = sGui->Palette[po->Selected?sGC_LOW:sGC_HIGH]; j=4;
        sPainter->Line(r.x0+1,r.y0+j,r.x0+j,r.y0+1,col);
        sPainter->Line(r.x1-2,r.y0+j,r.x1-j-1,r.y0+1,col);
      }

      if(po->Class->Flags & (POCF_STORE|POCF_LABEL))
      {
        col = sGui->Palette[po->Selected?sGC_HIGH2:sGC_LOW2];
        for(j=4;j>=0;j--)
        {
          sPainter->Line(r.x0,r.y1-1-j,r.x0+j,r.y1-1,col);
          sPainter->Line(r.x1-1,r.y1-1-j,r.x1-j-1,r.y1-1,col);
          col = sGui->Palette[sGC_BACK];
        }
        sPainter->Line(r.x0,r.y1-1,r.x0,r.y1-5+2,col);
        sPainter->Line(r.x1-1,r.y1-1,r.x1-1,r.y1-5+2,col);
        col = sGui->Palette[po->Selected?sGC_HIGH:sGC_LOW]; j = 4;
        sPainter->Line(r.x0+1,r.y1-1-j,r.x0+j,r.y1-2,col);
        sPainter->Line(r.x1-2,r.y1-1-j,r.x1-j-1,r.y1-2,col);
      }
    }

    sPainter->Flush();
    sPainter->SetClipping(ClientClip);
    sPainter->EnableClipping(sTRUE);
    // paint shadow for dragging

    shadow = 0;
    if(DragMode==DM_MOVE||DragMode==DM_WIDTH)
      shadow = 1;
    if(DragMode==DM_DUPLICATE)
      shadow = 2;
    for(i=0;i<max;i++)
    {
      po = pd->Ops->Get(i);
      if(po->Selected && shadow)
      {
        po->MakeRect(r,Client);
        r.x0 += DragMoveX*PAGEX;
        r.y0 += DragMoveY*PAGEY;
        r.x1 += (DragMoveX+DragWidth)*PAGEX;
        r.y1 += DragMoveY*PAGEY;
        sGui->RectHL(r,shadow,sGui->Palette[sGC_DRAW],sGui->Palette[sGC_DRAW]);
      }
    }
  }

  if(DragMode==DM_RECT)
  {
    sGui->RectHL(DragRect,1,sGui->Palette[sGC_DRAW],sGui->Palette[sGC_DRAW]);
  }

  r.x0 = Client.x0 + CursorX*PAGEX;
  r.y0 = Client.y0 + CursorY*PAGEY;
  r.x1 = Client.x0 + (CursorX+CursorWidth)*PAGEX;
  r.y1 = Client.y0 + (CursorY+1)*PAGEY;
  sGui->RectHL(r,1,sGui->Palette[sGC_DRAW],sGui->Palette[sGC_DRAW]);
}