31#define OWL_CLIP_TAB_BOUNDING_RECT_ 0
32#define OWL_DRAW_TAB_BOUNDING_RECT_ 0
34#if OWL_CLIP_TAB_BOUNDING_RECT_
40#if OWL_DRAW_TAB_BOUNDING_RECT_
66 int x,
int y,
int w,
int h,
146 TabList.insert(TabList.begin() + index,
176 TabList.erase(TabList.begin() + index);
186 if (index < SelectedTab || SelectedTab ==
n)
188 CHECK(SelectedTab >= -1 && SelectedTab <
n);
189 if (index < FirstVisibleTab || FirstVisibleTab ==
n)
191 CHECK(FirstVisibleTab >= -1 && FirstVisibleTab <
n);
195 if ((SelectedTab >= 0) && (SelectedTab <
n))
225 return static_cast<int>(TabList.size());
249 if (index == SelectedTab)
return index;
254 if (SelectedTab >= 0 && SelectedTab <
GetCount())
264 if (SelectedTab >= 0 && SelectedTab <
GetCount())
316 LabelImageMargin =
v;
356 SelectedTabProtrusion =
v;
376 TabFont.reset(
new TFont(
font.GetObject()));
387 return SelectedTabFont ? *SelectedTabFont : *TabFont;
396 SelectedTabFont.reset(
new TFont(
font.GetObject()));
417 SelectedTabColor =
v;
462 if (index <
GetCount() && index >= 0) {
515 ShouldUseThemes =
false;
517 LabelMargin =
TSize(5, 3);
518 SelectedTabProtrusion = 0;
519 LabelImageMargin = 3;
520 FocusMargin =
TSize(2, 2);
530 SelectedTabFont.reset();
534 OwnedCelArray.reset();
539 ScrollButtons =
new TUpDown{
this, -1, 0, 0, 0, 0};
604 const TFont& TabFont;
605 const TFont& SelectedTabFont;
659 Dc.SetTextColor(TabTextColor);
675 tab.Rect.BottomRight())
689 TRect
r = Window.GetClientRect();
690 TRect
m(
r.TopLeft(), TSize(
r.Width(),
margin.cy));
696 TRect
r = Window.GetClientRect();
697 TRect
m(
r.TopLeft(), TSize(
r.Width(),
margin.cy));
698 Dc.SelectObject(
pen);
699 Dc.MoveTo(
m.BottomLeft());
700 Dc.LineTo(
m.BottomRight());
706 Dc.SelectObject(
brush);
713#if defined(OWL_GDIPLUS_H)
717 Gdiplus::Graphics
g(Dc);
721 g.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias);
726 Dc.SelectObject(
pen);
728 Dc.SetPixel(
pt[3],
pen.GetObject().lopnColor);
736 struct TFlatRenderer_
778 struct TWindowFaceRenderer_
781 TBrush SelectedTabBrush;
783 TWindowFaceRenderer_(
812 struct TStyle3dRenderer_
834 LightPen(TColor::Sys3dLight),
835 HilightPen(TColor::Sys3dHilight),
836 ShadowPen(TColor::Sys3dShadow),
837 DkShadowPen(TColor::Sys3dDkShadow)
846 TRect
r = Window.GetClientRect();
848 r.TopLeft().OffsetBy(0,
margin.cy),
863 Dc.SelectObject(LightPen);
864 Dc.MoveTo(
pt[0].x + 1,
pt[0].y);
865 Dc.LineTo(
pt[1].x + 1,
pt[1].y - 1);
867 Dc.SelectObject(HilightPen);
868 Dc.MoveTo(
pt[0].x,
pt[0].y);
869 Dc.LineTo(
pt[1].x,
pt[1].y);
871 Dc.SelectObject(ShadowPen);
872 Dc.MoveTo(
pt[1].x + 1,
pt[1].y - 1);
873 Dc.LineTo(
pt[2].x - 1,
pt[2].y - 1);
874 Dc.MoveTo(
pt[2].x - 1,
pt[2].y);
875 Dc.LineTo(
pt[3].x - 1,
pt[3].y);
877 Dc.SelectObject(DkShadowPen);
878 Dc.MoveTo(
pt[1].x + 1,
pt[1].y);
879 Dc.LineTo(
pt[2].x,
pt[2].y);
880 Dc.LineTo(
pt[3].x,
pt[3].y);
885 struct TThemeRenderer_
907 TRect
r = Window.GetClientRect();
908 TRect
m(
r.TopLeft(), TSize(
r.Width(),
margin.cy));
910 p.DrawBackground(Dc,
m);
918 TThemePart p(Window,
L"TAB", item, state);
940template <
class TPartRenderer>
941void TNoteTab::PaintTabs(TDC& dc,
const TRect&
paintRect)
987#if OWL_CLIP_TAB_BOUNDING_RECT_
1002 int ri = Dc.IntersectClipRect(
b);
1033 int dx = TabTapering;
1048 renderer.DrawTabFocusRect(
tab, FocusMargin, SelectedTabProtrusion);
1055#if OWL_DRAW_TAB_BOUNDING_RECT_
1060 const TNoteTabItem&
tab = TabList[
i];
1061 if (
tab.Rect.IsNull())
continue;
1067 TRect
b = GetBoundingRect(
tab.Rect);
1068 TPoint bp[] = {
b.TopLeft(),
b.BottomLeft(),
b.BottomRight(),
b.TopRight(),
b.TopLeft()};
1102 for (TNoteTabItemArray::const_iterator
i = TabList.begin();
i != TabList.end(); ++
i)
1118 else if (WindowFace)
1151 const auto& p = LastClientRectPainted;
1236 if (
tab < 0)
return;
1275#if OWL_CLIP_TAB_BOUNDING_RECT_
1284#if OWL_DRAW_TAB_BOUNDING_RECT_
1315 (TabFont->GetObject().lfItalic ||
selectedTabFont.GetObject().lfItalic) &&
1324 if (
tab.ImageIdx >= 0 && CelArray)
1327 tab.LabelSize.cx += size.cx + LabelImageMargin;
1328 tab.LabelSize.cy = std::max(
tab.LabelSize.cy, size.cy);
1348TNoteTab::CalculateTabRects(
int firstTab,
const TRect&
area)
const
1360 TPoint p =
area.TopLeft();
1363 const TNoteTabItem&
tab = TabList[
i];
1364 const TRect
r = CalculateTabRect(
tab, p,
i == SelectedTab);
1369 const TRect
b = GetBoundingRect(
r);
1379 p.Offset(
r.Width() + TabSpacing, 0);
1390TNoteTab::AssignTabRect(TNoteTabItem&
tab,
const TRect&
newRect)
1392 TRect&
r =
tab.Rect;
1410 if (
area.IsEmpty() ||
r.IsEmpty())
return false;
1411 return r.left >=
area.left &&
r.right <=
area.right;
1432 const auto allArea =
TRect{
c.TopLeft() + Margin,
c.BottomRight()};
1487 if (
tab.Rect.Contains(
pt))
1504 if (index == SelectedTab)
return false;
1544 rect.top = std::max(
1576 rect.left += Margin.cx;
1577 rect.top += Margin.cy;
1601 return TabList[index].Rect.IsNull() ?
false :
true;
1613 if (EffectiveTabsArea.
IsEmpty())
return false;
1615 TRect b = GetBoundingRect(TabList[index].Rect);
1627 FirstVisibleTab = index;
1683 if (ScrollLoc ==
loc)
1712 TransparentColor =
c;
Definition of a bitmap Cel array class.
#define PRECONDITION(condition)
#define CHECKX(condition, message)
The GDI Brush class is derived from TGdiObject.
TCelArray is a horizontal array of cels (a unit of animation) created by slicing a portion of or an e...
TSize CelSize() const
Return the size of the celarray.
Class wrapper for management of color values.
static const TColor Transparent
a non-painting color
static const TColor None
not-a-color
static const TColor SysWindowFrame
The symbolic system color value for the frame around each window.
static const TColor SysWindowText
The symbolic system color value for text in every window.
static const TColor Sys3dFace
The symbolic system color value for the face color of 3-dimensional display elements.
static const TColor SysWindow
The symbolic system color value for the background of each window.
static const TColor LtRed
Static TColor object with fixed Value set by RGB(255, 0, 0).
TControl unifies its derived control classes, such as TScrollBar, TControlGadget, and TButton.
void EvPaint()
Intercept WM_PAINT to redirect from TWindow to the underlying control if this Owl object is just a wr...
TDC is the root class for GDI DC wrappers.
bool FillSolidRect(const TRect &r, const TColor &color)
bool FillRgn(const TRegion ®ion, const TBrush &brush)
Fills the given region on this DC using the specified brush.
Encapsulates the system font used for a specific GUI element, e.g. icon, caption, menu,...
TFont derived from TGdiObject provides constructors for creating font objects from explicit informati...
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
TNotify is a thin wrapper around the NMHDR structure.
TPoint is a support class, derived from tagPOINT.
TPoint OffsetBy(int dx, int dy) const
Calculates an offset to this point using the given displacement arguments.
TRect is a mathematical class derived from tagRect.
bool IsNull() const
Returns true if left, right, top, and bottom are all 0; otherwise, returns false.
bool IsEmpty() const
Returns true if left >= right or top >= bottom; otherwise, returns false.
TRegion, derived from TGdiObject, represents GDI abstract shapes or regions.
Derived from TWindowDC, TScreenDC is a DC class that provides direct access to the screen bitmap.
The tagSIZE struct is defined as.
static TThemeModule & GetInstance()
Returns the module instance.
@ WndRecessed
Input field & other window recessed.
static const TUIMetric CyEdge
static const TUIMetric CyHScroll
static const TUIMetric CyFixedFrame
static const TUIMetric CySizeFrame
static const TUIMetric CxFixedFrame
static const TUIMetric CxEdge
static const TUIMetric CxHScroll
TUpDown encapsulates an up-down control, which is a window with a pair of arrow buttons that the user...
void SetRange(int lower, int upper)
Sets the minimum and maximum positions of the up-down control.
TResult SetPos(int pos)
Sets the current position of the underlying up-down control.
Type-safe encapsulation of a Windows class name, a union between ATOM and LPCTSTR.
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
HWND SetFocus()
Sets the keyboard focus to current window and activates the window that receives the focus by sending...
void SetBkgndColor(TColor color, bool shouldUpdate=true)
Sets the background color for the window.
TWindow()
Protected constructor for use by immediate virtually derived classes.
TWindow * GetParent() const
Retrieves the OWL object of the parent window. If none exists, returns 0.
auto GetBkgndColor() const -> TColor
Returns the overriding background color set for the window.
virtual void InvalidateRect(const TRect &rect, bool erase=true)
Invalidates a specified client area.
uint EvGetDlgCode(const MSG *msg)
The default message handler for WM_GETDLGCODE.
void EvKillFocus(HWND hWndGetFocus)
Handle WM_KILLFOCUS so that we can have a parent window hold onto our Handle and possibly restore foc...
bool ModifyStyle(uint32 offBits, uint32 onBits, uint swpFlags=0)
Modifies the style bits of the window.
bool MoveWindow(int x, int y, int w, int h, bool repaint=false)
Repositions the specified window.
TRect GetClientRect() const
Gets the coordinates of the window's client area (the area in a window you can use for drawing).
void UpdateWindow()
Updates the client area of the specified window by immediately sending a WM_PAINT message.
void EvSetFocus(HWND hWndLostFocus)
The default message handler for WM_SETFOCUS.
void SendNotification(int id, int notifyCode, HWND hCtl, TMsgId=WM_COMMAND)
Repacks a command message (msg) so that a child window (hCtl) can send a message to its parent regard...
bool IsWindowVisible() const
Returns true if the window is visible.
virtual bool ShowWindow(int cmdShow)
Displays this TWindow in a given state.
virtual void SetupWindow()
Performs setup following creation of an associated MS-Windows window.
static HWND GetFocus()
Gets a handle to the window that has the focus.
void EvSize(uint sizeType, const TSize &size)
Response method for an incoming WM_SIZE message.
HWND THandle
TWindow encapsulates an HWND.
virtual void Invalidate(bool erase=true)
Invalidates (mark for painting) the entire client area of a window.
HWND GetHandle() const
Returns the handle of the window.
Definition of classes for CommonControl encapsulation.
Definition of container classes used and made available by OWL.
Definition of class TControl.
#define DEFINE_RESPONSE_TABLE1(cls, base)
Macro to define a response table for a class with one base.
Utilities for GDI+ interoperability.
TAutoDelete
Flag for Handle ctors to control Handle deletion in dtor.
void EvLButtonDown(uint modKeys, const TPoint &point)
WM_LBUTTONDOWN handler - Checks whether the mouse was clicked on a tab item and selects it.
TRect Rect
Location of tab [client-area base coords].
uint EvGetDlgCode(const MSG *msg)
WM_GETDLGCODE handler - Informs dialog manager that arrow keys are to be used.
int Add(LPCTSTR txt, INT_PTR clientData=0, int imageIdx=-1, TAbsLocation imageLoc=alLeft, bool shouldSelect=true)
Adds a new tabitem to the notetab control.
void SetSelectedTabFont(const TFont &)
Sets the font used to render the text part of the selected tab label.
void SetSelectedTabColor(const TColor &)
Sets the fill color used to paint the selected tab.
auto GetWindowClassName() -> TWindowClassName override
Returns "OWL_Notetab" - the Window class name of the notetab control object.
void EvKeyDown(uint key, uint repeatCount, uint flags)
WM_KEYDOWN handler - handles arrow keys to allow user to navigate through tab items.
int TabFromPoint(const TPoint &pt) const
Returns the index of the tab item at the specified window coordinate.
void SetLabelMargin(const TSize &)
Sets the amount of padding around the tab label.
bool IsVisible(int index) const
Returns true if the tab item at the specified index is visible.
int GetSel() const
Returns the index of the selected tabitem.
bool EnsureVisible(int index)
If the tab specified by index is not visible, it is scrolled into view.
const TFont & GetSelectedTabFont() const
Returns the font used to render the text part of the selected tab label.
int Insert(LPCTSTR txt, int index, INT_PTR clientData=0, int imageIdx=-1, TAbsLocation imageLoc=alLeft, bool shouldSelect=true)
Inserts a new TTabItem at the specified index.
void SetSelectedTabProtrusion(int)
Sets the amount of extra height of the selected tab.
void EvSetFocus(THandle hWndLostFocus)
Handle WM_SETFOCUS: Draw focus to identify selected tab.
const TFont & GetTabFont() const
Returns the font used to render the text part of the tab labels.
HWND GetBuddy() const
Return handle of buddy window associated with the notetab control.
void SetFirstVisibleTab(int index)
Sets FirstVisibleTab to index if index is valid.
void SetTabFont(const TFont &)
Sets the font used to render the text part of the tab labels.
bool IsFullyVisible(int index) const
Returns true if the horizontal projection of the tab item at the specified index is contained within ...
void SetTabTapering(int)
Sets the amount of narrowing on each side of the tab towards the bottom.
void SetMargin(const TSize &)
Sets the amount of space to the left of the tabs and above the tabs.
bool GetItem(int index, TNoteTabItem &item) const
Retrieve information about the tab item at the specified index.
void SetEdgeColor(const TColor &)
Sets the pen color used to draw the edges of the tabs.
void SetFocusMargin(const TSize &)
Sets the margin around the focus rectangle for the selected tab.
void SetBuddy(HWND buddy)
Sets handle of the buddy window associated with this notetab control.
int SetSel(int index)
Selects the tabitem at the specified index.
void SetTabRects(int firstTab)
Lays out tab items (and scroll buttons) with the specified index at the leftmost.
void SetLabelImageMargin(int)
Sets the horizontal spacing between image and text in the label.
TNoteTab(TWindow *parent, int id, int x, int y, int w, int h, TWindow *buddy=0, bool dialogBuddy=true, TModule *module=0)
Constructor of NoteTab object.
TRect GetScrollerArea() const
Returns the desired location of the scrollers within the tab.
void EvHScroll(uint scrollCode, uint thumbPos, HWND hWndCtl)
Sets the first visible tab to the given thumb position.
bool Delete(int index)
Remove the tabitem at the specified 'index'.
void EvKillFocus(THandle hwndGetFocus)
Handle WM_KillFOCUS: Remove dotted focus rectangle from selected tab.
bool SetItem(int index, const TNoteTabItem &item)
Updates information about the tab item at the specified index.
void SetupWindow() override
Overriden virtual of TWindow - Initializes font used by control and resize accordingly.
bool NotifyAndSelect(int index)
Selects the tab at the given index and sends the appropriate notifications.
void SetTabColor(const TColor &)
Sets the fill color used to paint the tabs.
void EvPaint()
EV_WM_PAINT handler.
void SetCelArrayTransparentColor(const TColor &)
Sets the color assigned to denote transparency in the bitmaps used for the tabs (see SetCelArray).
int GetFirstVisibleTab() const
Returns FirstVisibleTab.
void InvalidateTab(int index)
Invalidates the rectangle occupied by the tab at the specified index.
void SetTabSize(int index)
Updates the internal information stored about the label of a particular tab item.
bool DeleteAll()
Removes all tab items in the notetab control. Always returns true.
void SetCelArray(TCelArray *array, TAutoDelete=AutoDelete)
Sets the bitmap array to be used for the tabs.
void SetScrollLocation(TAbsLocation pos)
Set the scroller location.
bool EvEraseBkgnd(HDC)
Disables automatic background erasure by returning false.
void SetTabSpacing(int)
Sets the horizontal distance between two tabs.
TRect GetScrollingTabsArea() const
Returns the rectangle of the area reserved for tabs when scrolling is active.
void EvSize(uint sizeType, const TSize &size)
WM_SIZE handler - Relay tab items.
void Paint(TDC &, bool erase, TRect &) override
TWindow::Paint override.
auto Transfer(void *buffer, TTransferDirection) -> uint override
Overrides TWindow virtual member function to handle transfers.
void InitCtrl()
Initialize internal variables used by NoteTab.
int GetCount() const
Return the number of tab items in the notetab control.
int GetMinimalHeight()
Returns the minimal control height for which tabs are not clipped.
TAbsLocation
General use absolute 2-D rectangular location enum.
@ alRight
Refers to right edge of frame.
@ alLeft
Refers to left edge of frame.
@ alNone
No location specified.
TTransferDirection
The TTransferDirection enum describes the constants that the transfer function uses to determine how ...
Object Windows Library (OWLNext Core)
TWindow * GetWindowPtr(HWND, const TApplication *)
Raw function to retrieve a TWindow pointer given an HWND from the a given app, or any app (app==0).
void InUse(const T &arg)
Handy utility to avoid compiler warnings about unused parameters.
auto GetCommCtrlVersion() -> DWORD
Returns the version number of the Common Control library (ComCtl32.dll).
Definition of class TNoteTab.
#define COUNTOF(s)
Array element count Important: Only use this with an argument of array type.
TNoteTabItem holds information about each tab in a notetab control.
Microsoft UxTheme Library Encapsulation.
Definition of the UI Helper Classes: TUIHandle, TUIBorder, TUIFace, TUIPart.
Definition of TUIMetric, a UI metrics provider class.
Definition of class TUpDown.