13#include <owl/statusba.rh>
27 TModeStrings() : NumModes(0), ModeBuff(nullptr), ModeStrings(nullptr) {}
34 void Init(TModule* module,
uint16 resId, LPCTSTR defaultModes);
37 int Count()
const {
return NumModes; }
38 LPCTSTR operator [](
int i)
const {
return ModeStrings[i]; }
52TModeStrings::Init(
TModule* module,
uint16 resId, LPCTSTR defaultModes)
55 tstring modeResString(module->LoadString(resId));
56 ModeBuff =
strnewdup(modeResString.length() > 0 ?
57 modeResString.c_str() :
60 for (TCharIterator<tchar> i(ModeBuff); ; i++) {
63 if (*i.Current() ==
_T(
'|')) {
70 ModeStrings =
new pchar[NumModes];
72 for (
int j = 0; j < NumModes; j++) {
82static tchar DefOnModes[] =
_T(
"EXT|CAPS|NUM|SCRL|OVR|REC");
86 static TModeStrings ModeOnStrings;
90static int VkKeys[] = {
99static int GadgetIds[] = {
136 BorderStyle = borderStyle;
137 ModeIndicators = modeIndicators;
138 ModeIndicatorState = 0;
139 NumModeIndicators = 0;
141 GetModeOnStrings().Init(
GetModule(), IDS_MODES, DefOnModes);
148 HighlightLine =
false;
152 switch (BorderStyle) {
183 Margins.Left = Margins.Top = Margins.Right = Margins.Bottom = -1;
189 Gadgets->SetBorderStyle(BorderStyle);
197 for (
int i = 0; i < GetModeOnStrings().Count(); i++)
198 if (ModeIndicators & (1 << i)) {
200 if (owl::VkKeys[i] == 0) {
202 lstrlen(GetModeOnStrings()[i]),
203 GetModeOnStrings()[i], 0);
207 gadget =
new TModeGadget(VkKeys[i], GetModeOnStrings()[i],
233TStatusBar::InsertSizeGrip()
250TStatusBar::IsModeIndicator(TGadget* gadget)
252 int nonModeIndicators = NumGadgets - NumModeIndicators;
255 for (
int i = 0; i < nonModeIndicators; i++) {
276 origin.x -= cxBorder;
284 if (IsModeIndicator(next))
285 switch (Spacing.Units) {
287 origin.x += Spacing.Value;
295 origin.x += Spacing.Value * cxBorder;
311 sibling =
operator[](NumGadgets - NumModeIndicators - 1);
336TStatusBar::GetGadgetAndStrings(TModeIndicator mode,
TTextGadget*& gadget,
339 if ((ModeIndicators & mode) == 0) {
343 uint slot = NumGadgets - 1;
346 for (index = GetModeOnStrings().
Count() - 1; (1 << index) > mode; index--)
347 if (ModeIndicators & (1 << index))
350 strOn = GetModeOnStrings()[index];
352 for (gadget = (TTextGadget*)Gadgets; slot > 0; slot--)
379 if (GetGadgetAndStrings(mode, gadget, strOn)) {
384 ModeIndicatorState |= mode;
386 ModeIndicatorState &= ~mode;
406 retVal = HTBOTTOMRIGHT;
425 bool callresize =
false;
426 if (sizeType==SIZE_MAXIMIZED) {
438 else if (sizeType == SIZE_RESTORED) {
#define PRECONDITION(condition)
void SelectObject(const TBrush &brush)
Selects the given GDI brush object into this DC.
TFont derived from TGdiObject provides constructors for creating font objects from explicit informati...
TGadget is the base class for the following derived gadget classes:
TRect & GetBounds()
Returns the boundary rectangle for the gadget.
void SetMargins(const TMargins &margins)
Sets the margins of the gadget.
virtual void SetBounds(const TRect &rect)
Called by the gadget window to inform the gadget of a change in its bounding rectangle.
bool GetEnabled() const
Determines whether keyboard and mouse input have been enabled for the specified gadget.
TBorderStyle
Gadget border styles.
@ Embossed
Painted with an embossed border.
@ WndRecessed
Input field and other window are recessed.
@ Recessed
Recessed into the window.
@ None
No border painted at all.
@ WndRaised
Inner and outer edge of the window are raised.
@ ButtonUp
Button in up position.
@ Plain
Plain window frame.
@ Grooved
Grouping groove.
@ Raised
Raised above the gadget window.
@ WellSet
Well option set (auto grows + 1).
@ ButtonDn
Button in down position.
virtual void SetEnabled(bool enabled)
Enables or disables keyboard and mouse input for the gadget.
TGadget * NextGadget()
Returns the next gadget in the list of gadgets.
TMargins & GetMargins()
Gets the margin dimensions.
void SetBorderStyle(TBorderStyle bs)
Set the border style used by this gadget.
TGadget * operator[](uint index)
Returns gadget at a given index.
TPlacement
Enumerates the placement of a gadget.
TGadget * GadgetWithId(int id) const
Returns the gadget with a given ID, or 0 if none is found.
virtual void Insert(TGadget &gadget, TPlacement=After, TGadget *sibling=nullptr)
Inserts a Gadget.
int LayoutUnitsToPixels(int units)
Converts layout units to pixels.
auto Remove(TGadget &) -> TGadget *override
Removes a gadget from the gadget window.
virtual void LayoutSession()
LayoutSession is typically called when a change occurs in the size of the margins or gadgets,...
Derived from TWindow, TLayoutWindow provides functionality for defining the layout metrics for a wind...
virtual void Layout()
Causes the window to resize and position its children according to the specified metrics.
Derived from TGadgetWindow, TMessageBar implements a message bar with one text gadget as wide as the ...
TMessageBar(TWindow *parent=nullptr, TFont *font=nullptr, TModule *module=nullptr)
Constructs a TMessageBar object with the gadget window font.
void SetText(const tstring &text)
Forwards the message in the message bar to the text gadget for formatting.
virtual void SetHintText(LPCTSTR text)
Sets the hint text displayed on the messagebar.
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.
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
TPoint is a support class, derived from tagPOINT.
TRect is a mathematical class derived from tagRect.
TRect & Inflate(int dx, int dy)
Inflates a rectangle inflated by the given delta arguments.
bool Contains(const TPoint &point) const
Returns true if the given point lies within this rectangle; otherwise, it returns false.
Derived from TWindowDC, TScreenDC is a DC class that provides direct access to the screen bitmap.
TSizeGripGadget is a gadget that is used on the far right of a status bar to provide re-sizing grip f...
The tagSIZE struct is defined as.
Status bars have more options than a plain message bar: you can have multiple text gadgets,...
TModeIndicator
Enumerates the keyboard modes.
uint GetModeIndicators() const
Returns the bit flags for which indicator is on.
void EvOwlFrameSize(uint sizeType, const TSize &)
BGM SetModeIndicators is nearly useless; after construction, TStatusBar BGM pays almost no attention ...
void ToggleModeIndicator(TModeIndicator)
Toggles the ModeIndicator.
void Insert(TGadget &, TPlacement=After, TGadget *sibling=nullptr) override
By default, adds "gadget" after the existing text gadgets and before the mode indicator gadgets.
void PositionGadget(TGadget *previous, TGadget *next, TPoint &) override
Determines the position of the new gadget in relation to any previously existing gadgets and uses the...
TStatusBar(TWindow *parent=0, TGadget::TBorderStyle borderStyle=TGadget::Recessed, uint modeIndicators=0, TFont *font=0, TModule *module=0)
Constructs a TStatusBar object in the parent window and creates any new gadgets and mode indicator ga...
uint EvNCHitTest(const TPoint &point)
If the status bar has a size grip gadget and the mouse is over the gadget, simulates resizing of the ...
void SetModeIndicator(TModeIndicator, bool state)
Sets TModeIndicator to a given text gadget and set the status (on, by default) of the mode indicator.
void SetHintText(LPCTSTR text) override
Overriden method of TMessageBar to use our own text gadget Set (or clear if 0) menu/command item hint...
bool GetModeIndicator(TModeIndicator i) const
Returns the current status bar mode indicator.
Derived from TGadget, TTextGadget is a text gadget object.
@ Left
Aligns the text at the left edge of the bounding rectangle.
@ Center
Aligns the text horizontally at the center of the bounding rectangle.
TTextGadget(int id=0, TBorderStyle=Recessed, TAlign=Left, uint numChars=10, LPCTSTR text=0, TFont *font=0)
Constructs a TTextGadget object with the specified ID, border style, and alignment.
static const TUIMetric CyBorder
static const TUIMetric CxBorder
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
void SetFlag(uint mask)
Sets the specified TWindow wfXxxx constant flags (for example wfAlias, wfTransfer,...
TWindow * GetParentO() const
Return the OWL's parent for this window.
TModule * GetModule() const
Returns a pointer to the module object.
TPoint MapScreenToClient(const TPoint &p) const
Functional-style version of ScreenToClient.
uint EvNCHitTest(const TPoint &)
The default message handler for WM_NCHITTEST.
#define DEFINE_RESPONSE_TABLE1(cls, base)
Macro to define a response table for a class with one base.
#define IDG_STATUS_SCRL
The ID for a scroll lock gadget.
#define IDG_SIZEGRIP
The ID for a size grip gadget.
#define IDG_STATUS_OVR
The ID for an overwrite gadget.
#define IDG_STATUS_CAPS
The ID for a capslock gadget.
#define IDG_STATUS_EXT
The ID for an extended selection gadget.
#define IDG_STATUS_NUM
The ID for a numlock gadget.
#define IDG_STATUS_REC
The ID for a record gadget.
@ wfInsertAtEdge
(Decoration) Window to be inserted against frame's edge
Definition of classes TLayoutMetrics & TLayoutWindow.
char * strnewdup(const char *s, size_t minAllocSize=0)
Definition of mode-tracking text gadget class TModeGadget.
Object Windows Library (OWLNext Core).
ulong TStaticSync< T >::Count
General definitions used by all ObjectWindows programs.
#define TYPESAFE_DOWNCAST(object, toClass)
Definition of class TStatusBar.
Used by the TGadgetWindow and TGadget classes, TMargins contains the measurements of the margins for ...
Definition of TUIMetric, a UI metrics provider class.