home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / bc45 / owlsrc.pak / MESSAGEB.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-24  |  2.2 KB  |  92 lines

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