Ejemplo n.º 1
0
void
TFlatPainter::Paint(TDC& dc, TRect& rect)
{
  TWindow* wnd = TYPESAFE_DOWNCAST(this, TWindow);
  if(!wnd)
    return;

  if(IsSet(fpMouseIn) && wnd->IsWindowEnabled()){
    // We draw the "tracked" situation
#ifdef TEST
    TBrush brush (TColor::LtRed);
#else
    TBrush brush (TColor::Sys3dFace);
#endif
    dc.FrameRect(rect, brush);
    rect.Inflate(-1, -1);
    dc.FrameRect(rect, brush);
    rect.Inflate(-1, -1);
    dc.FrameRect(rect, brush);
    rect.Inflate(1, 1);
    TUIBorder::DrawEdge(dc, rect, TUIBorder::SunkenOuter, TUIBorder::Rect);
  }
  else{
    // We draw the "untracked" situation
#ifdef TEST
    TBrush brush(TColor::LtBlue);
    TBrush brush2(TColor::LtGreen);
#else
    TBrush brush(TColor::Sys3dFace);
    TBrush brush2(TColor::SysWindow);
#endif

    dc.FrameRect(rect,brush);
    rect.Inflate(-1, -1);
    dc.FrameRect(rect,brush);
    rect.Inflate(-1, -1);
    dc.FrameRect(rect, brush2);
  }
}
Ejemplo n.º 2
0
/// Move and resize the window so that the window is the same size as the hyperlink
/// text. This stops the hyperlink cursor being active when it is not directly over
/// the text. If the text is left justified then the window is merely shrunk, but if
/// it is centred or right justified then the window will have to be moved as well.
//
// Suggested by Pål K. Tønder
void
TUrlLink::PositionWindow()
{
  // Get the current window position
  TRect rect;
  GetWindowRect(rect);

  TWindow* pParent = GetParentO();
  if(pParent){
    pParent->ScreenToClient(rect.TopLeft());
    pParent->ScreenToClient(rect.BottomRight());
  }

  // Get the size of the window text
  TTmpBuffer<tchar> buffer(MAX_PATH);
  GetText(buffer, MAX_PATH);

  TSize size = LinkFont->GetTextExtent(&buffer[0]);

  // Get the text justification via the window style
  uint32 style = GetStyle(); //TWindow

  // Recalc the window size and position based on the text justification
  if (style & SS_CENTERIMAGE)
    rect.Inflate(0, -(rect.Height() - size.cy)/2);
  else
    rect.bottom = rect.top + size.cy;

   if (style & SS_CENTER)
    rect.Inflate( -(rect.Width() - size.cx)/2, 0);
  else if (style & SS_RIGHT)
    rect.left  = rect.right - size.cx;
  else // SS_LEFT = 0, so we can't test for it explicitly
    rect.right = rect.left + size.cx;

  // Move the window
  SetWindowPos(NULL, rect.left, rect.top, rect.Width(), rect.Height(), SWP_NOZORDER);
}
Ejemplo n.º 3
0
//
/// Paints a blank button.
//
void
TTinyCaption::PaintButton(TDC& dc, TRect& r, bool pressed)
{
    TBrush winFrameBr(TColor::SysWindowFrame);
//  dc.OWLFastWindowFrame(winFrameBr, r, 1, 1);
    dc.FrameRect(r, winFrameBr);

    r.Inflate(-1,-1);
    dc.TextRect(r, TColor::Sys3dFace);
    if (r.Width() > 4 && r.Height() > 4) {
        if (pressed) {
            dc.TextRect(r.left, r.top, r.right, r.top+1, TColor::Sys3dShadow);
            dc.TextRect(r.left, r.top+1, r.left+1, r.bottom, TColor::Sys3dShadow);
        }
        else {
            dc.TextRect(r.left, r.top, r.right-1, r.top+1, TColor::Sys3dHilight);
            dc.TextRect(r.left, r.top+1, r.left+1, r.bottom-1, TColor::Sys3dHilight);
            dc.TextRect(r.right-1, r.top+1, r.right, r.bottom, TColor::Sys3dShadow);
            dc.TextRect(r.left+1, r.bottom-1, r.right-1, r.bottom, TColor::Sys3dShadow);
        }
    }
}