Beispiel #1
0
void DrawDisabledButton(TDC& dc, const TRect& rc)
{
  // create a monochrome memory DC
  //
  TMemoryDC ddc;
  TBitmap bmp(ddc, rc.Width(), rc.Height());
  ddc.SelectObject(bmp);

  // build a mask
  //
  ddc.PatBlt(0, 0, rc.Width(), rc.Height(), WHITENESS);
  dc.SetBkColor(TColor::Sys3dFace);
  ddc.BitBlt(0, 0, rc.Width(), rc.Height(), dc, rc.left, rc.top, SRCCOPY);
  dc.SetBkColor(TColor::Sys3dHilight);
  ddc.BitBlt(0, 0, rc.Width(), rc.Height(), dc, rc.left, rc.top, SRCPAINT);

  // Copy the image from the toolbar into the memory DC
  // and draw it (grayed) back into the toolbar.
  //
  dc.FillRect(rc, TBrush(TColor::Sys3dFace));
  dc.SetBkColor(RGB(0, 0, 0));
  dc.SetTextColor(RGB(255, 255, 255));
  TBrush brShadow(TColor::Sys3dShadow);
  TBrush brHilight(TColor::Sys3dHilight);
  dc.SelectObject(brHilight);
  dc.BitBlt(rc.left+1, rc.top+1, rc.Width(), rc.Height(), ddc, 0, 0, 0x00E20746L);
  dc.SelectObject(brShadow);
  dc.BitBlt(rc.left, rc.top, rc.Width(), rc.Height(), ddc, 0, 0, 0x00E20746L);

  // reset DCs
  //
  dc.RestoreBrush();
  dc.RestoreBrush();
  ddc.RestoreBitmap();
}
Beispiel #2
0
void TEnhancedListBox :: DrawItem  ( DRAWITEMSTRUCT far & drawInfo )
	{
	char 	table [100] ;			/* buffer de travail      */
	TDC	drawDC(drawInfo.hDC);		/* zones de dessin        */
	TRect	itemRect(drawInfo.rcItem.left,drawInfo.rcItem.top,drawInfo.rcItem.right,drawInfo.rcItem.bottom);
	TRect   BaseRect = itemRect ;
	char *	pchar ;
	bool	useinvert = ( drawInfo. itemState & ODS_SELECTED ) ;

	if  ( drawInfo. itemID >= Nb_display )
		return ;

	if  ( ! boolpopup )			/* redimensionnement ?    */
		{
		TRect	deplace ;

		boolpopup = TRUE ;

		Parent -> GetWindowRect ( deplace ) ;	/* basee sur le parent */
		deplace. right -= deplace. left ;
		deplace. left = -1 ;
		deplace. bottom -= deplace. top ;
		deplace. top = -1 ;
		deplace. right += GetSystemMetrics ( SM_CXVSCROLL ) ; /* cache scroller */
		MoveWindow ( deplace, TRUE ) ;
		 }

	TListBox :: GetString ( table, drawInfo. itemID  ) ;

	drawDC. FillRect ( itemRect, TBrush ( TColor ( ::GetSysColor ( useinvert ? COLOR_HIGHLIGHT : COLOR_WINDOW ) ) ) ) ;

	if  ( useinvert )
		{
		SetTextColor ( drawDC, GetSysColor ( COLOR_HIGHLIGHTTEXT ) ) ;
		SetBkColor   ( drawDC, GetSysColor ( COLOR_HIGHLIGHT ) ) ;
		 }
	else
		{
		SetTextColor ( drawDC, GetSysColor ( COLOR_WINDOWTEXT ) ) ;
		SetBkColor   ( drawDC, GetSysColor ( COLOR_WINDOW ) ) ;
		 }

	itemRect. left += 3 ;		       	/* écriture formatée      */
	drawDC. DrawText ( table , -1, itemRect, DT_VCENTER ) ;
	itemRect. left += x1 ;
	pchar = memo [ base_display + drawInfo. itemID ] ;
	while  ( * pchar  &&  * pchar  !=  ' '  &&  * pchar  !=  '\t' )
		pchar ++ ;
	while  ( * pchar  ==  ' '  ||  * pchar  ==  '\t' )
		pchar ++ ;
	if  ( * pchar )
		drawDC. DrawText( pchar , -1, itemRect, DT_VCENTER ) ;
	 }
Beispiel #3
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
TFlatComboBox::EvPaint()
{
  TComboBox::EvPaint();

  if (IsFlat()){
    TWindowDC dc(GetHandle());
    TRect rect = GetClientRect();
    TFlatPainter::Paint(dc, rect);

    if(!IsSet(fpMouseIn) || !IsWindowEnabled()){
      // We draw the "untracked" situation
      rect.left = rect.right - TUIMetric::CxHThumb;// + 1;
#ifdef TEST
       dc.FrameRect(rect, TBrush(TColor::LtGreen));
#else
       dc.FrameRect(rect, TBrush(TColor::SysWindow));
#endif
    }
  }
}
Beispiel #4
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
    }
  }
}
Beispiel #5
0
void TEnhancedComboBox :: DrawItem  ( DRAWITEMSTRUCT far & drawInfo )
	{
	char 	table [100] ;			/* buffer de travail      */
	TDC	drawDC(drawInfo.hDC);		/* zones de dessin        */
	TRect	itemRect(drawInfo.rcItem.left,drawInfo.rcItem.top,drawInfo.rcItem.right,drawInfo.rcItem.bottom);
	TRect   BaseRect = itemRect ;
	char *	pchar ;
	bool	useinvert = ( drawInfo. itemState & ODS_SELECTED ) ;

	if  ( drawInfo. itemID  >=  Nb_display )
		return ;
	if  ( ! wpopup )
		new  TEnhancedBox ( drawInfo. hwndItem, this ) ;

	if  ( ! boolpopup )			/* redimensionnement ?    */
		{
		boolpopup = TRUE ;
		MovePopup ( drawInfo. hwndItem, x1+x2 ) ;
		 }
						/* récupération des infos */
	TComboBox::GetString ( table, drawInfo. itemID  ) ;

	drawDC. FillRect ( itemRect, TBrush ( TColor ( ::GetSysColor ( useinvert ? COLOR_HIGHLIGHT : COLOR_WINDOW ) ) ) ) ;

	if  ( useinvert )
		{
		SetTextColor ( drawDC, GetSysColor ( COLOR_HIGHLIGHTTEXT ) ) ;
		SetBkColor   ( drawDC, GetSysColor ( COLOR_HIGHLIGHT ) ) ;
		 }
	else
		{
		SetTextColor ( drawDC, GetSysColor ( COLOR_WINDOWTEXT ) ) ;
		SetBkColor   ( drawDC, GetSysColor ( COLOR_WINDOW ) ) ;
		 }

	itemRect. left += 3 ;		       	/* écriture formatée      */
	drawDC. DrawText ( table , -1, itemRect, DT_VCENTER ) ;
	itemRect. left += x1 ;
	pchar = memo [ base_display + drawInfo. itemID ] ;
	while  ( * pchar  &&  * pchar  !=  ' '  &&  * pchar  !=  '\t' )
		pchar ++ ;
	while  ( * pchar  ==  ' '  ||  * pchar  ==  '\t' )
		pchar ++ ;
	if  ( * pchar )
		drawDC. DrawText( pchar , -1, itemRect, DT_VCENTER ) ;
 }
Beispiel #6
0
//////////////////////////////////////////////////////////
// TMapDC
// ------
//  draw a LineDef
void TMapDC::DrawLineDefLen (SHORT x0, SHORT y0, SHORT x1, SHORT y1, int color)
{
	char Text[10];

	// How to display a Text using a XOR mode?
	//  1. Create a memory dc
	//  2. Calc the text size (GetTextExtent)
	//  3. Create a bitmap of this size
	//  4. Draw text in bitmap (TextOut) in the memory DC
	//  5. Draw bitmap (with text in it) on screen using XOR

	// Build the string of the line length
	sprintf (Text, "%d", ComputeDist (abs(x1 - x0), abs(y1 - y0)));

	// Get the text size
	TSize TextSize = GetTextExtent(Text, strlen(Text));

	// Calc. the text drawing rect
#ifdef WINDOWS_SCALING
	TRect TTextRect(TPoint ((x0 + x1) / 2, (y0 + y1) /2), TextSize));
#else
	TRect TTextRect(TPoint (SCREENX((x0 + x1) / 2), SCREENY((y0 + y1) /2)), TextSize);
#endif
	// Draw text in bitmap
	TMemoryDC MemDC;
	TBitmap TextBitmap (*this, TextSize.cx, TextSize.cy);
	MemDC.SelectObject (TextBitmap);
	MemDC.SetTextAlign (TA_LEFT);
	MemDC.SetBkMode (TRANSPARENT);
	MemDC.SetTextColor (GetColor16(BLUE));
	MemDC.SelectObject (TPen(GetColor16(color)));
	MemDC.SelectObject (TBrush(GetColor16(WHITE)));
	MemDC.Rectangle (TPoint(0, 0), TextSize);
	MemDC.TextOut (0, 0, Text);

	// Draw bitmap (with text in it) on screen using XOR
    // TTextRect.left -= TextSize.cx; // align to right
	BitBlt (TTextRect,
			MemDC,
			TPoint(0, 0),
			SRCINVERT);
}