///////////////////////////////////////////////////////////////////////// // pstatbar.cpp Source for TProStatusBar class which diplays hint // the text of a TDecoratedFrame's status bar in a sunken // frame. // // Written by : George Cross, Borland C++ Developer Support // Date : June 14, 1996 // Compiler : Borland C++ 5.0, but is valid for 4.x and above ///////////////////////////////////////////////////////////////////////// #include #include "pstatbar.h" /////////////////////////////////////////////////////////////////////// // TProStatusBar constructor // // This constructor is strictly modelled after the constructor of // it's base class TStatusBar. // TProStatusBar::TProStatusBar (TWindow* parent, TGadget::TBorderStyle borderStyle, uint modeIndicators, TFont *font, TModule* module) : TStatusBar (parent, borderStyle, modeIndicators, font, module) { } //End TProStatusBar constructor /////////////////////////////////////////////////////////////////////// // PaintGadgets // // This is function where it all happens. This overrides the // member function of the same name in TMessageBar. // Please see the OWL source messageb.cpp to see what the base // function looked like. // void TProStatusBar::PaintGadgets(TDC& dc, bool erase, TRect& rect) { // //Draw the very outer border for the status bar. // if (HighlightLine && rect.top == 0) dc.TextRect(0, 0, rect.right, GetSystemMetrics(SM_CYBORDER), GetSysColor(COLOR_BTNHIGHLIGHT)); // //If there is text to display as a hint message as the user //selects a menu item or drags the mouse over the buttons on the //button bar. . . // if (HintText) { //Calculate the area in which we will TRect clientRect; //display the text. GetInnerRect(clientRect); //GetInnerRect is a member of TMessageBar //int y = (clientRect.bottom - GetFontHeight()) / 2; //was in base class's fn // //These lines below were present in the base class's function // // if (HighlightLine) // clientRect.top += GetSystemMetrics(SM_CYBORDER); // //Below we draw the recessed border for the rectangle in //which we wish to display the text for the hint message // dc.SelectObject(GetFont()); dc.SetBkColor(GetSysColor(COLOR_BTNFACE)); dc.SelectObject (TPen (TColor (GetSysColor(COLOR_WINDOW)))); dc.SelectObject (TBrush (TColor (GetSysColor (COLOR_BTNFACE)))); dc.Rectangle (clientRect); dc.SelectObject (TPen (TColor (GetSysColor (COLOR_BTNSHADOW)))); dc.MoveTo (clientRect.left, clientRect.bottom); dc.LineTo (clientRect.left, clientRect.top); dc.LineTo (clientRect.right, clientRect.top); // //Now we display the text for the hint message // dc.TextOut (clientRect.left + 5, //Horizontal origin clientRect.top + 1, //Vertical origin HintText, //string to display -1); //display all characters of string // //These lines below were present in the base class's function // // dc.ExtTextOut(5, y, ETO_OPAQUE, &clientRect, HintText, // strlen(HintText)); } //Otherwise, if not HintText, else { //we just repaint all gadgets TGadgetWindow::PaintGadgets(dc, erase, rect); //NumLock, Overtype . . . } //End else } //End PaintGadgets () /////////////////////////////////////////////////////////////////////// // SetText // // This function overrides that of the base class TMessageBar. // ****BIG NOTE ***** // Simply by changing the function name to "SetHintText", you will // see that the Overtype, NumLock, ScrollLock . . .etc gadgets are // not hidden by the Hint Text covering the whole message bar area // // Try it ! It's cool ! // void TProStatusBar::SetText (const char* text) { //((TTextGadget*) Gadgets)->SetText (text); //Use this for OWL 2.x SetMessageText(IDG_MESSAGE, text); //Use this for OWL 5.x }