예제 #1
0
void TSplitter::GetTrackingRect(const TPoint& point, TRect& rect)
{
	GetLocalBounds(rect);

	if (fVertical)
	{
		rect.left = point.h - kSplitterWidth/2;
		rect.right = rect.left + kSplitterWidth;

		if (rect.left < 0)
			rect.Offset(-rect.left, 0);
		else if (rect.right > fBounds.GetWidth())
			rect.Offset(fBounds.GetWidth() - rect.right, 0);
	}
	else
	{
		rect.top = point.v - kSplitterWidth/2;
		rect.bottom = rect.top + kSplitterWidth;

		if (rect.top < 0)
			rect.Offset(0, -rect.top);
		else if (rect.bottom > fBounds.GetHeight())
			rect.Offset(0, fBounds.GetHeight() - rect.bottom);
	}
}
예제 #2
0
void TColumnResizer::GetTrackingRect(const TPoint& point, TRect& rect)
{
	TGridView* gridView = GetGridView();
	gridView->GetLocalBounds(rect);

	rect.left = point.h;
	rect.right = rect.left + 1;

	if (rect.left < 0)
		rect.Offset(-rect.left, 0);
	else if (rect.right > gridView->GetWidth())
		rect.Offset(gridView->GetWidth() - rect.right, 0);
}
예제 #3
0
void TWindow::LocalToTopLevel(TRect& rect) const
{
	const TWindow* window = this;
	
	const TPoint& scroll = GetScroll();
	rect.Offset(-scroll.h, -scroll.v);

	while (window->fParent)
	{
		rect.Offset(window->fBounds.left, window->fBounds.top);
		window = window->fParent;
	}
}
예제 #4
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);
    }
}
예제 #5
0
void TWindow::LocalToRoot(TRect& rect) const
{
	int x, y;
	Window childWindow;
	XTranslateCoordinates(sDisplay, fWindow, gApplication->GetRootWindow(),
										   0, 0, &x, &y, &childWindow);

	const TPoint& scroll = GetScroll();
	rect.Offset(x - scroll.h, y - scroll.v);
}
예제 #6
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);
        }
    }
}
예제 #7
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);
    }
}
예제 #8
0
//
// Intercept WM_PAINT to redirect from TWindow to the underlying control iff
// this Owl object is just a wrapper for a predefined class.
//
void
TFlatListBox::EvPaint()
{
  TListBox::EvPaint();

  if (IsFlat()){

    TWindowDC dc(GetHandle());

    TRect rect  = GetClientRect();
    TRect wrect = GetWindowRect();
    ::MapWindowPoints(HWND_DESKTOP, *this, LPPOINT(&wrect), 2);

    rect.bottom += 6;
    rect.right  += 6;
    wrect.Offset(3,3);

    bool haveScroll = wrect != rect;
    if(haveScroll){
       wrect.bottom -= 1;
       wrect.right  -= 1;
    }

    TFlatPainter::Paint(dc, wrect);

    if((!IsSet(fpMouseIn) || !IsWindowEnabled()) && haveScroll){
      // We draw the "untracked" situation
      wrect.left = wrect.right - TUIMetric::CxHThumb;

#ifdef TEST
       dc.FrameRect(wrect, TBrush(TColor::LtGreen));
#else
       dc.FrameRect(wrect, TBrush(TColor::SysWindow));
#endif
    }
  }
}
예제 #9
0
//
/// Paint Text
//
void
TButtonTextGadget::PaintText(TDC& dc, TRect& rect, const tstring& text)
{
  dc.SelectObject(GetFont());

  TColor textColor = TColor::SysBtnText;
  if(!GetEnabled())
    textColor = TColor::Sys3dHilight;
  else if((GetGadgetWindow()->GetFlatStyle()&TGadgetWindow::FlatHotText) && IsHaveMouse())
     textColor = TColor::LtBlue;

   TColor oldTxColor  = dc.SetTextColor(textColor);

  uint format =  DT_SINGLELINE|DT_NOCLIP|DT_END_ELLIPSIS;
  switch(Align){
    case aLeft:
      format |= DT_LEFT;
      break;
    case aRight:
      format |= DT_RIGHT;
      break;
    case aCenter:
      format |= DT_CENTER;
      break;
  }
  switch(LayoutStyle){
    case lTextLeft:
    case lTextRight:
      format |= DT_VCENTER;
      break;
    case lTextTop:
      format |= DT_VCENTER;//DT_BOTTOM;
      break;
    case lTextBottom:
      format |= DT_VCENTER;//DT_TOP;
      break;
  }

  // Create a UI Face object for this button & let it paint the button face
  //
  TPoint  dstPt(rect.TopLeft());

  if (GetButtonState() == Down && GetEnabled() &&
      GetGadgetWindow()->GetFlatStyle()&TGadgetWindow::FlatStandard)
  {
    if(IsHaveMouse())
    {
      if(IsPressed())
      {
        const int dx = (format & DT_CENTER) ? 2 : 1;
        const int dy = (format & DT_VCENTER) ? 2 : 1;
        rect.Offset(dx, dy);
      }
      TUIFace(rect, text, TColor::Sys3dFace,format).Paint(dc, dstPt,
                TUIFace::Normal, true, true);
    }
    else
    {
      TUIFace face(rect, text, TColor::Sys3dFace,format);
      if(GetGadgetWindow()->GadgetGetCaptured()==this)
        face.Paint(dc, dstPt, TUIFace::Normal, true);
      else
        face.Paint(dc, dstPt, TUIFace::Down, IsPressed(), false);
    }
  }
  else
  {
    TUIFace face(rect, text, TColor::Sys3dFace,format);
    if (!GetEnabled())
      face.Paint(dc, dstPt, TUIFace::Disabled, false, false);
    else if (GetButtonState() == Indeterminate)
      face.Paint(dc, dstPt, TUIFace::Indeterm, IsPressed(), false);
    else if (GetButtonState() == Down) // Down and not flat
      face.Paint(dc, dstPt, TUIFace::Down, IsPressed(), false);
    else
      face.Paint(dc, dstPt, TUIFace::Normal, IsPressed(), false);
  }

  dc.SetTextColor(oldTxColor);

  dc.RestoreFont();
}