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
modegad.cpp
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1995, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// Defines TModeGadget.
7///
8/// A mode gadget is a gadget that displays the mode of a key.
9/// The key code is defined as VK_XXXX in Windows.
10//----------------------------------------------------------------------------
11#include <owl/pch.h>
12#include <owl/modegad.h>
13
14namespace owl {
15
17
18//
19/// Initializes the text gadget with the text key's text.
20//
23:
24 TTextGadget(id, border, align, 10, text, font), VkKey(vkKey)
25{
26 SetShrinkWrap(true, true);
27}
28
29//
30/// String-aware overload
31//
33 int vkKey,
34 const tstring& text,
35 int id,
38 TFont* font
39 )
40 : TTextGadget(id, border, align, 10, text, font),
41 VkKey(vkKey)
42{
43 SetShrinkWrap(true, true);
44}
45
46//
47/// Override from TGadget to update the state of the key.
48//
49bool
51{
53 int state = ::GetKeyState(VkKey);
54
55 // Toggle keys
56 //
57 if (VkKey == VK_SCROLL || VkKey == VK_INSERT ||
58 VkKey == VK_NUMLOCK || VkKey == VK_CAPITAL) {
59 if (state & 1)
60 SetEnabled(true);
61 else
62 SetEnabled(false);
63 }
64 else {
65 // This is a regular key, highlite only when pressed
66 //
67 if (state & (1 << (sizeof(int) * 8 - 1)))
68 SetEnabled(true);
69 else
70 SetEnabled(false);
71 }
72 return false;
73}
74
75
76} // OWL namespace
77/* ========================================================================== */
78
TFont derived from TGdiObject provides constructors for creating font objects from explicit informati...
Definition gdiobjec.h:296
virtual bool IdleAction(long idleCount)
Called during idle time to allow the gadget to perform any idle actions.
Definition gadget.cpp:120
void SetShrinkWrap(bool shrinkWrapWidth, bool shrinkWrapHeight)
Simple set accessor to set whether shrinkwrapping is performed horizontally and/or vertically.
Definition gadget.cpp:165
TBorderStyle
Gadget border styles.
Definition gadget.h:127
virtual void SetEnabled(bool enabled)
Enables or disables keyboard and mouse input for the gadget.
Definition gadget.cpp:194
TModeGadget(int vkKey, LPCTSTR text, int id=0, TBorderStyle=Recessed, TAlign=Center, TFont *font=0)
Initializes the text gadget with the text key's text.
Definition modegad.cpp:21
bool IdleAction(long count)
Override from TGadget to update the state of the key.
Definition modegad.cpp:50
Derived from TGadget, TTextGadget is a text gadget object.
Definition textgadg.h:37
TAlign
Enumerates the text-alignment attributes.
Definition textgadg.h:42
Definition of mode-tracking text gadget class TModeGadget.
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
OWL_DIAGINFO
Definition animctrl.cpp:14
std::string tstring
Definition defs.h:79