18#if defined(__BORLANDC__)
65 bool trackMenuSelection,
70 Init(parent, title, clientWnd, trackMenuSelection, module);
79 Init(parent, title.c_str(), client, trackMenuSelection, module);
94 TrackMenuSelection = trackMenuSelection;
96 SettingClient =
false;
104 ClientWnd =
new TWindow(
this,
_T(
"\007"));
106 if (ClientWnd->GetWindowAttr().Style & WS_BORDER) {
127 delete BarCreatorFunct;
128 delete BarInserterFunct;
135 *BarCreatorFunct = funct;
141 *BarInserterFunct = funct;
157 ClientSize.cx = clientRect.right;
158 ClientSize.cy = clientRect.bottom;
194 clientWnd =
new TWindow(
this,
_T(
"\007"));
209 if (metrics.
X.
RelWin == oldWnd)
211 if (metrics.
Y.
RelWin == oldWnd)
219 child = child->
Next();
220 }
while (child != first);
227 SettingClient =
true;
229 SettingClient =
false;
253 if (child == ClientWnd && !SettingClient)
273 if (child != ClientWnd && child->
GetHandle() &&
278 child = child->
Next();
279 }
while (child != firstChild);
295 if (
id ==
static_cast<uint>(-1))
324 for (i =
static_cast<int>(
::_tcslen(buf)) - 1; i >= 0; i--)
325 if (buf[i] ==
_T(
'.'))
330#if defined(BI_DBCS_SUPPORT)
333 if (i >= 3 && buf[i-3] ==
'(' && buf[i-2] ==
'&' && buf[i] ==
')')
340 if (buf[i] ==
_T(
'&')) {
357 if (len == 0 && MergeModule !=
nullptr)
358 len = MergeModule->LoadString(
id, resStr, 256);
360 WARNX(OwlWin, len == 0, 0,
361 _T(
"TDecoratedFrame::GetHintText LoadString(")
365 if (len && (pLF =
_tcschr(resStr,
_T(
'\n'))) !=
nullptr)
374 if (numBytes == 0 && MergeModule !=
nullptr)
375 numBytes = MergeModule->LoadString(
id, buf, size);
377 WARNX(OwlWin, numBytes == 0, 0,
378 _T(
"TDecoratedFrame::GetHintText LoadString(")
407 if (TrackMenuSelection) {
408 if (flags == 0xFFFF && hMenu ==
nullptr) {
415 else if (flags & MF_POPUP) {
438 MenuItemId =
TMenu(hMenu).GetMenuItemID(menuItemId);
441 else if (flags & (MF_SEPARATOR | MF_MENUBREAK | MF_MENUBARBREAK)
451 MenuItemId = menuItemId;
481 if (source == MSGF_MENU && MenuItemId) {
501const uint32 locMask = 0x0F00;
502const int locShift = 8;
511 w.GetWindowAttr().Style = (w.GetWindowAttr().Style & ~locMask) | (
uint32(loc) << locShift);
522 TRACEX(OwlCmd, 1,
_T(
"TDecoratedFrame:EvCommand - id(") <<
id <<
_T(
"), ctl(") <<\
523 static_cast<void*
>(hWndCtl) <<
_T(
"), code(") << notifyCode <<
_T(
")"));
527 if (hWndCtl ==
nullptr) {
552 TLocation location = GetLocation_(*decoration);
556 struct TSiblingSearch
563 : Decoration(d), Sibling(
nullptr), Location(loc)
566 TSiblingSearch search(decoration, location);
570 const auto i = std::find_if(c.begin(), c.end(), [&](
TWindow& w)
571 { return ((&w != search.Decoration) && (GetLocation_(w) == search.Location)); });
572 search.Sibling = (i != c.end()) ? &(*i) :
nullptr;
577 if (&w == search.Decoration)
580 if (GetLocation_(w) == search.Location && w.IsWindowVisible())
588 search.Sibling = ClientWnd;
596 InsertAtTop(*decoration, search.Sibling);
600 InsertAtBottom(*decoration, search.Sibling);
604 InsertAtLeft(*decoration, search.Sibling);
608 InsertAtRight(*decoration, search.Sibling);
623 decoration->
ShowWindow(visible ? SW_HIDE : SW_SHOWNA);
645 if (hint.length() > 0)
668TDecoratedFrame::InsertAtTop(
TWindow& decoration,
TWindow* insertAbove)
678 insertBelow = metrics.
Y.
RelWin;
693 bool overlap = (decoration.
GetWindowAttr().Style & WS_BORDER);
710TDecoratedFrame::InsertAtBottom(
TWindow& decoration,
TWindow* insertBelow)
712 TLayoutMetrics metrics;
720 if (insertBelow == ClientWnd) {
721 insertAbove = metrics.Height.RelWin;
732 insertAbove = metrics.Y.RelWin;
744 bool overlap = (decoration.GetWindowAttr().Style & WS_BORDER);
761TDecoratedFrame::InsertAtLeft(
TWindow& decoration,
TWindow* insertLeftOf)
763 TLayoutMetrics metrics;
771 insertRightOf = metrics.X.RelWin;
785 bool overlap = (decoration.GetWindowAttr().Style & WS_BORDER);
801 if (
ToBool(ClientWnd->GetWindowAttr().Style & WS_BORDER) == overlap) {
802 metrics.Y.SameAs(ClientWnd,
lmTop);
803 metrics.Height.SameAs(ClientWnd,
lmBottom);
821TDecoratedFrame::InsertAtRight(
TWindow& decoration,
TWindow* insertRightOf)
823 TLayoutMetrics metrics;
831 if (insertRightOf == ClientWnd) {
832 insertLeftOf = metrics.Width.RelWin;
844 insertLeftOf = metrics.X.RelWin;
856 bool overlap = (decoration.GetWindowAttr().Style & WS_BORDER);
872 if (
ToBool(ClientWnd->GetWindowAttr().Style & WS_BORDER) == overlap) {
873 metrics.Y.SameAs(ClientWnd,
lmTop);
874 metrics.Height.SameAs(ClientWnd,
lmBottom);
903 SetLocation_(decoration, location);
926 InsertAtTop(decoration, ClientWnd);
929 InsertAtBottom(decoration, ClientWnd);
932 InsertAtLeft(decoration, ClientWnd);
935 InsertAtRight(decoration, ClientWnd);
956 const auto i = find_if(c.begin(), c.end(), [](
TWindow& w) { return w.ChildWithId(IDW_TOOLBAR); });
957 if (i == c.end())
return nullptr;
1018#if OWL_PERSISTENT_STREAMS
1035TDecoratedFrame::Streamer::Write(opstream& os)
const
Class definition for TBarDescr.
#define WARNX(group, condition, level, message)
#define TRACEX(group, level, message)
Descriptor of Bar Implementation.
Base class for an extensible interface for auto enabling/disabling of commands (menu items,...
uint GetId() const
Retrieves the id of the command.
virtual void Enable(bool enable=true)
Enables or disables the command sender.
virtual void SetCheck(int check)=0
Changes the check state of the command sender to either unchecked, checked, or indeterminate.
virtual void SetText(LPCTSTR text)=0
Changes the text associated with a command sender; for example, text associated with a menu item or t...
@ Unchecked
Command is not enabled.
@ Checked
Command is enabled.
TControlBar(TWindow *parent=0, TTileDirection direction=Horizontal, TFont *font=0, TModule *module=0)
Constructs a TControlBar interface object with the specified direction (either horizontal or vertical...
TDecoratedFrame automatically positions its client window (you must supply a client window) so that i...
void SetBarInserter(const TBarInsertFunctor &funct)
void EvMenuSelect(uint menuItemId, uint flags, HMENU hMenu)
Responds to user menu selection.
TBarInsertFunctor * GetBarInserter()
void RemoveChild(TWindow *) override
Makes sure that both bases get a chance to see the child removed.
void EvEnterIdle(uint source, HWND hWndDlg)
Responds to a window message that tells an application's main window that a dialog box or a menu is e...
void SetBarCreator(const TGadgetWndFunctor &funct)
TDecoratedFrame(TWindow *parent, LPCTSTR title, TWindow *clientWnd, bool trackMenuSelection=false, TModule *module=0)
Constructs a TDecoratedFrame object with the specified parent window (parent), window caption (title)...
virtual TGadgetWindow * GetControlBar()
Search for child with ID = IDW_TOOLBAR, and if found check that it is GadgetWindow and return it;.
TGadgetWndFunctor * GetBarCreator()
auto MergeBar(const TBarDescr &) -> bool override
Merges the given bar descriptor with this frame's own bar descriptor and displays the resulting contr...
auto SetClientWindow(TWindow *) -> TWindow *override
Overrides TFrameWindows virtual function.
auto EvCommand(uint id, HWND hWndCtl, uint notifyCode) -> TResult override
Automates hiding and showing of decorations.
void Init(TWindow *parent, LPCTSTR title, TWindow *client, bool trackMenuSelection, TModule *)
Initialization shared by the constructors.
virtual bool CreateBar()
SetupWindow() call this function to create control bar, if it is MainWindow and if BarDescriptor exis...
void EvSize(uint sizeType, const TSize &size)
Forward our size event to the layout window base, and not the frame base.
~TDecoratedFrame() override
void EvCommandEnable(TCommandEnabler &) override
Handles checking and unchecking of menu items that are associated with decorations.
auto PreProcessMsg(MSG &) -> bool override
Override TFrameWindow member function to give decorations an opportunity to do pre-processing (e....
TLocation
Enumeration describing the possible locations of a Gadgetwindow [Used mainly for location of Toolbar ...
@ Bottom
Refers to bottom edge of frame.
@ None
No location specified.
@ Top
Refers to top edge of frame.
@ Left
Refers to left edge of frame.
@ Right
Refers to right edge of frame.
virtual tstring GetHintText(uint id, THintText hintType) const
Retrieves the text specified by the resource id.
void CleanupWindow() override
void SetupWindow() override
Override SetupWindow in order to layout & position decorations Calls TLayoutWindow::Layout to size an...
virtual void Insert(TWindow &decoration, TLocation location=Top)
Insert a decoration window into position at one of the four edges.
Derived from TWindow, TFrameWindow controls such window-specific behavior as keyboard navigation and ...
void Init(TWindow *clientWnd, bool shrinkToClient)
Normal initialization of a default constructed TFrameWindow.
virtual TWindow * GetClientWindow()
Returns a pointer to the client window.
void EvCommandEnable(TCommandEnabler &) override
Handle WM_COMMAND_ENABLE to provide command enable distribution and default support for windows witho...
virtual bool RestoreBar()
Do nothing in TFrameWindow. Overriden in TDecoratedFrame.
void CleanupWindow() override
Cleans up any associated icons.
auto PreProcessMsg(MSG &) -> bool override
Overrides TWindow's virtual function.
void BroadcastResizeToChildren(uint sizeType, const TSize &size)
Tell child windows frame has minimized/maximized/restored (They may want to change enabled state or r...
auto EvCommand(uint id, HWND hWndCtl, uint notifyCode) -> TResult override
Handle WM_COMMAND to provide extra processing for commands: Extra processing for commands: starts wit...
virtual TWindow * SetClientWindow(TWindow *clientWnd)
Sets the client window to the specified window.
const TBarDescr * GetBarDescr() const
Returns a pointer to the control bar descriptor.
TFrameWindow()
< String-aware overload
void SetupWindow() override
Calls TWindow::SetUpWindow to create windows in a child list.
void RemoveChild(TWindow *) override
If someone removes our client with a RemoveChild() call, update our client and restore focus ptrs.
Derived from TWindow, TGadgetWindow maintains a list of tiled gadgets for a window and lets you dynam...
auto Create() -> bool override
Overrides TWindow member function and chooses the initial size of the gadget if shrink-wrapping was r...
When specifying the layout metrics for a window, four layout constraints are needed.
TEdgeConstraint Y
Y contains the Y (top, center, bottom) edge constraint of the window.
TEdgeOrWidthConstraint Width
Contains the width size constraint, center edge constraint, or right edge (lmRight) constraint of the...
TEdgeOrHeightConstraint Height
Contains the height size constraint, center edge constraint, or bottom edge constraint of the window.
TEdgeConstraint X
X contains the X (left, center, right) edge constraint of the window.
Derived from TWindow, TLayoutWindow provides functionality for defining the layout metrics for a wind...
TLayoutWindow(TWindow *parent, LPCTSTR title=0, TModule *module=0)
Creates a TLayoutWindow object with specified parent, window caption, and library ID.
void EvSize(uint sizeType, const TSize &size)
Responds to a change in size by calling Layout() to resize the window.
virtual void Layout()
Causes the window to resize and position its children according to the specified metrics.
bool GetChildLayoutMetrics(const TWindow &child, TLayoutMetrics &metrics)
Gets the layout metrics of the child window.
void SetChildLayoutMetrics(TWindow &child, const TLayoutMetrics &metrics)
Sets the metrics for the window and removes any existing ones.
void RemoveChild(TWindow *) override
Overrides TWindow virtual to allow cleanup of child metrics.
bool RemoveChildLayoutMetrics(const TWindow &child)
Removes child (layout) metrics for a given child (if found) and updates other children as necessary.
Derived from TGadgetWindow, TMessageBar implements a message bar with one text gadget as wide as the ...
void ClearHintText()
Clears the hint text, thus restoring the underlying content on the messagebar.
virtual void SetHintText(LPCTSTR text)
Sets the hint text displayed on the messagebar.
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
TRect is a mathematical class derived from tagRect.
The tagSIZE struct is defined as.
static int GetMenuString(HMENU, UINT, TCHAR *, int, UINT)
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
void EvEnterIdle(uint source, HWND hWndDlg)
The default message handler for WM_ENTERIDLE.
virtual void SetParent(TWindow *newParent)
Sets the parent for the specified window by setting Parent to the specified new Parent window object.
TWindow()
Protected constructor for use by immediate virtually derived classes.
TWindow(TWindow *parent, LPCTSTR title=nullptr, TModule *module=nullptr)
Adds this to the child list of parent if nonzero, and calls EnableAutoCreate so that this will be cre...
virtual bool PreProcessMsg(MSG &msg)
Called from TApplication::ProcessAppMsg() to give the window an opportunity to perform preprocessing ...
auto GetChildren()
Returns a TWindow::TChildrenRange that can be iterated by standard means.
virtual void Destroy(int retVal=0)
Destroys an MS-Windows element associated with the TWindow.
virtual bool Create()
Creates the window interface element to be associated with this ObjectWindows interface element.
long GetWindowLong(int index) const
Retrieves information about the window depending on the value stored in index.
void Init(TWindow *parent, LPCTSTR title, TModule *module)
Normal initialization of a default constructed TWindow.
TModule * GetModule() const
Returns a pointer to the module object.
TWindowAttr & GetWindowAttr()
Returns the TWindowAttr structure, which contains the window's creation attributes.
HMENU GetMenu() const
Returns the handle to the menu of the indicated window.
bool ModifyStyle(uint32 offBits, uint32 onBits, uint swpFlags=0)
Modifies the style bits of the window.
LPCTSTR GetCaption() const
Returns the Title member of TWindow.
TWindow * Next()
Returns a pointer to the next sibling window in the window's sibling list.
bool IsWindowVisible() const
Returns true if the window is visible.
virtual bool ShowWindow(int cmdShow)
Displays this TWindow in a given state.
bool IsFlagSet(uint mask)
Returns the state of the bit flag in Attr.Flags whose mask is supplied.
void GetClientRect(TRect &rect) const
Gets the coordinates of the window's client area and then copies them into the object referred to by ...
TWindow * GetFirstChild()
Returns a pointer to the first child window, which is the first window created in the interface objec...
HWND GetHandle() const
Returns the handle of the window.
auto ChildWithId(int id) const -> const TWindow *
ipstream, a specialized input stream derivative of pstream, is the base class for reading (extracting...
Definition of class TControlBar.
Definition of class TDecoratedFrame, a TFrameWindow that can manage decorations around the client win...
#define TBarInsert_FUNCTOR(func)
#define TGadgetWnd_FUNCTOR(func)
#define DEFINE_RESPONSE_TABLE2(cls, base1, base2)
Macro to define a response table for a class with two bases.
C++ Functor template implementation.
#define lmParent
Use to represent the parent in layout metrics.
@ lmTop
The top edge of the window.
@ lmBottom
The bottom edge of the window.
@ lmRight
The right edge of the window.
@ lmLeft
The left edge of the window.
void ReadBaseObject(Base *base, ipstream &in)
void ReadVirtualBase(Base *base, ipstream &in)
void WriteVirtualBase(Base *base, opstream &out)
void WriteBaseObject(Base *base, opstream &out)
@ htStatus
Text displayed on status bar.
@ htTooltip
Shorter text displayed in a tooltip.
TAbsLocation
General use absolute 2-D rectangular location enum.
@ alTop
Refers to top edge of frame.
int LoadString(uint id, TCHAR *buf, int maxChars) const
Loads a string resource identified by id into the buffer pointed to by buff.
@ wfMainWindow
This frame window is the main window.
@ wfInsertAtEdge
(Decoration) Window to be inserted against frame's edge
Definition of class TMessageBar.
Object Windows Library (OWLNext Core).
IMPLEMENT_STREAMABLE3(TDecoratedFrame, TFrameWindow, TLayoutWindow, TWindow)
TFunctor3< bool, TDecoratedFrame &, TGadgetWindow &, TAbsLocation > TBarInsertFunctor
LRESULT TResult
Result type.
bool EvBarInserter(TDecoratedFrame &frame, TGadgetWindow &destWindow, TAbsLocation loc)
const unsigned int IDW_FIRSTMDICHILD
child window IDs, 32 max to 32032
TFunctor1< TGadgetWindow *, TWindow * > TGadgetWndFunctor
DIAG_DECLARE_GROUP(OwlThread)
#define COUNTOF(s)
Array element count Important: Only use this with an argument of array type.
#define TYPESAFE_DOWNCAST(object, toClass)
void SameAs(TWindow *otherWin, TEdge edge)
Sets the edge of your window indicated by edge equivalent to the corresponding edge of the window in ...
void Set(TEdge edge, TRelationship rel, TWindow *otherWin, TEdge otherEdge, int value=0)
For setting arbitrary edge constraints.
void SameAs(TWindow *otherWin, TEdge edge)
void SameAs(TWindow *otherWin, TEdge edge)
TWindow * RelWin
RelWin is a pointer to the sibling windows or lmParent if the child is a proportion of the parent's d...
int Id
Contains the identifier of the child window.
uint32 Style
Contains the values that define the style, shape, and size of your window.