OWLNext    7.0
Borland's Object Windows Library for the modern age
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
menugadg.cpp
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1992, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// Defines TMenuGadget
7///
8/// A TMenuGadget is a text gadget that when pressed, it acts as a popup menu.
9//----------------------------------------------------------------------------
10#include <owl/pch.h>
11#include <owl/menugadg.h>
12
13namespace owl {
14
16
17const int MaxMenuTextLen = 512;
18
19//
20/// Creates the pop-up menu and initializes the text gadget.
21//
22TMenuGadget::TMenuGadget(TMenu& menu, TWindow* window, int id,
24:
26 CmdTarget(window)
27{
28 SetShrinkWrap(true, true);
29 PopupMenu = new TPopupMenu(menu);
30
31 // initialize Text data member
32 //
36}
37
38//
39/// Deletes the allocated pop-up menu.
40//
42{
43 delete PopupMenu;
44}
45
46//
47/// Shows a pop-up menu on LButtonDown.
48//
49void
51{
54// GetInnerRect(rect);
55 TPoint p2(rect.TopLeft());
57 PopupMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, p2, 0, *CmdTarget);
58}
59
60//
61//
62//
63void
65{
66 // for flat style set borders minimum 1
67 if((GetGadgetWindow()->GetFlatStyle()&TGadgetWindow::FlatStandard) &&
68 GetBorderStyle()==None && Borders.Left == 0 && Borders.Top == 0 &&
69 Borders.Right==0 && Borders.Bottom==0)
70 Borders.Left = Borders.Top = Borders.Right = Borders.Bottom = 1;
71
73}
74
75//
76//
77//
78void
80{
81 if(GetGadgetWindow()->GetFlatStyle()&TGadgetWindow::FlatStandard){
82 TBorderStyle oldStyle = BorderStyle;
83 if(GetEnabled() && IsHaveMouse())
84 BorderStyle = Raised;
86 BorderStyle = oldStyle;
87 }
88 else
90}
91
92//
93//
94//
97{
98 if((GetGadgetWindow()->GetFlatStyle()&TGadgetWindow::FlatHotText) && IsHaveMouse())
99 return TColor::LtBlue;
100 return TColor::SysBtnText;
101}
102
103} // OWL namespace
104/* ========================================================================== */
105
Class wrapper for management of color values.
Definition color.h:245
static const TColor LtBlue
Static TColor object with fixed Value set by RGB(0, 0, 255).
Definition color.h:311
static const TColor SysBtnText
The symbolic system color value for the text on buttons.
Definition color.h:342
TDC is the root class for GDI DC wrappers.
Definition dc.h:64
TFont derived from TGdiObject provides constructors for creating font objects from explicit informati...
Definition gdiobjec.h:296
bool IsHaveMouse() const
Return true if mouse inside gadget.
Definition gadget.h:485
TRect & GetBounds()
Returns the boundary rectangle for the gadget.
Definition gadget.h:440
virtual void LButtonDown(uint modKeys, const TPoint &point)
Captures the mouse if TrackMouse is set.
Definition gadget.cpp:608
TGadgetWindow * GetGadgetWindow()
Return a pointer to the owning or parent window for the gadget.
Definition gadget.h:536
bool GetEnabled() const
Determines whether keyboard and mouse input have been enabled for the specified gadget.
Definition gadget.h:458
void SetShrinkWrap(bool shrinkWrapWidth, bool shrinkWrapHeight)
Simple set accessor to set whether shrinkwrapping is performed horizontally and/or vertically.
Definition gadget.cpp:165
TBorderStyle GetBorderStyle() const
Gets the style for the gadget's borders.
Definition gadget.h:432
TBorderStyle
Gadget border styles.
Definition gadget.h:127
@ None
No border painted at all.
Definition gadget.h:128
@ Raised
Raised above the gadget window.
Definition gadget.h:130
virtual void PaintBorder(TDC &dc)
Self sent by method Paint().
Definition gadget.cpp:432
@ FlatHotText
Adds hot text effect like.
Definition gadgetwi.h:196
@ FlatStandard
Flat style IE 3.0 - base style.
Definition gadgetwi.h:194
~TMenuGadget()
Deletes the allocated pop-up menu.
Definition menugadg.cpp:41
virtual void GetDesiredSize(TSize &size)
Definition menugadg.cpp:64
virtual void PaintBorder(TDC &dc)
Added support for Flat Style.
Definition menugadg.cpp:79
virtual void LButtonDown(uint modKeys, const TPoint &p)
Shows a pop-up menu on LButtonDown.
Definition menugadg.cpp:50
virtual TColor GetEnabledColor() const
Added support for Hot text.
Definition menugadg.cpp:96
TMenuGadget(TMenu &menu, TWindow *window, int id=0, TBorderStyle borderStyle=TGadget::ButtonUp, TCHAR *text=0, TFont *font=0)
Creates the pop-up menu and initializes the text gadget.
Definition menugadg.cpp:22
The TMenu class encapsulates window menus.
Definition menu.h:77
int GetMenuString(uint item, TCHAR *str, int count, uint flags) const
Returns the label (str) of the menu item (item).
Definition menu.h:438
TPoint is a support class, derived from tagPOINT.
Definition geometry.h:87
TPopupMenu creates an empty pop-up menu to add to an existing window or pop-up menu.
Definition menu.h:189
int TrackPopupMenu(uint flags, int x, int y, int rsvd, HWND wnd, const TRect *rect=nullptr)
Allows the application to create a pop-up menu at the specified location in the specified window.
Definition menu.h:561
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
The tagSIZE struct is defined as.
Definition geometry.h:234
Derived from TGadget, TTextGadget is a text gadget object.
Definition textgadg.h:37
void GetDesiredSize(TSize &size)
Respond to the virtual call to let this gadget's Window know how big this text gadget wants to be bas...
Definition textgadg.cpp:166
void SetText(LPCTSTR text)
Set the text for this gadget.
Definition textgadg.cpp:133
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
void ClientToScreen(TPoint &point) const
Converts the client coordinates specified in point to screen coordinates for the new window.
Definition window.h:2248
Definition TMenuGadget class.
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
OWL_DIAGINFO
Definition animctrl.cpp:14
const int MaxMenuTextLen
Definition menugadg.cpp:17
unsigned int uint
Definition number.h:25