home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 11.ddi / OWLSRC.PAK / MESSAGEB.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-02  |  2.1 KB  |  90 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows - (C) Copyright 1992, 1993 by Borland International
  3. //   source\owl\messageb.cpp
  4. //   Defines class TMessageBar.
  5. //----------------------------------------------------------------------------
  6. #include <owl\owlpch.h>
  7. #include <owl\messageb.h>
  8. #include <owl\textgadg.h>
  9.  
  10. TMessageBar::TMessageBar(TWindow*   parent,
  11.                          TFont*     font,
  12.                          TModule*   module)
  13.   : TGadgetWindow(parent, Horizontal, font, module)
  14. {
  15.   TTextGadget*  textGadget = new TTextGadget(TGadget::None);
  16.  
  17.   Attr.Id = IDW_STATUSBAR;
  18.   HighlightLine = TRUE;
  19.   HintText = 0;
  20.   textGadget->WideAsPossible = TRUE;
  21.   Insert(*textGadget);
  22. }
  23.  
  24. TMessageBar::~TMessageBar()
  25. {
  26.   delete HintText;
  27. }
  28.  
  29. void
  30. TMessageBar::PaintGadgets(TDC& dc, BOOL erase, TRect& rect)
  31. {
  32.   if (HighlightLine && rect.top == 0)
  33.     dc.TextRect(0, 0, rect.right, GetSystemMetrics(SM_CYBORDER),
  34.                 GetSysColor(COLOR_BTNHIGHLIGHT));
  35.  
  36.   if (HintText) {
  37.     TRect  clientRect = GetClientRect();
  38.     int    y = (clientRect.bottom - GetFontHeight()) / 2;
  39.  
  40.     if (HighlightLine)
  41.       clientRect.top += GetSystemMetrics(SM_CYBORDER);
  42.     dc.SelectObject(GetFont());
  43.     dc.SetBkColor(GetSysColor(COLOR_BTNFACE));
  44.     dc.ExtTextOut(5, y, ETO_OPAQUE, &clientRect, HintText, strlen(HintText));
  45.  
  46.   } else {
  47.     TGadgetWindow::PaintGadgets(dc, erase, rect);
  48.   }
  49. }
  50.  
  51. void
  52. TMessageBar::GetInnerRect(TRect& innerRect)
  53. {
  54.   TGadgetWindow::GetInnerRect(innerRect);
  55.  
  56.   if (HighlightLine)
  57.     innerRect.top += GetSystemMetrics(SM_CYBORDER);
  58. }
  59.  
  60. void
  61. TMessageBar::GetDesiredSize(TSize& size)
  62. {
  63.   TGadgetWindow::GetDesiredSize(size);
  64.  
  65.   if (HighlightLine)
  66.     size.cy++;
  67. }
  68.  
  69. void
  70. TMessageBar::SetText(const char* text)
  71. {
  72.   //
  73.   // forward the message to the text gadget
  74.   //
  75.   ((TTextGadget*)Gadgets)->SetText(text);
  76. }
  77.  
  78. //
  79. // sets or clears menu/command hint text over all the gadgets
  80. //
  81. void
  82. TMessageBar::SetHintText(const char* text)
  83. {
  84.   if (text != HintText) {
  85.     delete HintText;
  86.     HintText = text ? strnewdup(text) : 0;
  87.     Invalidate();
  88.   }
  89. }
  90.