OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
tabbed.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright © 1998 by Bidus Yura. All Rights Reserved.
4// OVERVIEW
5// ~~~~~~~~
6/// \file
7/// Class definition for TTabbedBase .
8//
9//
10//----------------------------------------------------------------------------
11
12#if !defined(OWL_TABBED_H) // Sentry, use file only if it's not already included.
13#define OWL_TABBED_H
14
15#include <owl/private/defs.h>
16#if defined(BI_HAS_PRAGMA_ONCE)
17# pragma once
18#endif
19
20#include <owl/layoutwi.h>
21#include <owl/notetab.h>
22
23#include <owl/tabbed.rh>
24
25
26#if !defined(RC_INVOKED)
27
28#include <owl/docview.h>
29
30namespace owl {
31
32#include <owl/preclass.h>
33
34class _OWLCLASS TNoteTab;
35
36////////////////////////////////////////////////////////////////////////////////
37/// \class TTabbedBase
38// ~~~~~ ~~~~~~~~~~~
39//
40/// TTabbedBase implements a tabbed window, designed to be
41/// mixed in with TWindow derived.
42//
43/// Example:
44// ~~~~~~~~
45/// \code
46///class TTabbedDialog : public TDialog, public TTabbedBase{
47/// public:
48/// TTabbedDialog(...);
49/// SetupWindow();
50/// };
51///TTabbedDialog::TTabbedDialog(...)
52///{
53/// Add(new TDialog(this, IDD_DLG1));
54/// Add(new TDialog(this, IDD_DLG2));
55/// Add(new TDialog(this, IDD_DLG3));
56/// GetTabControl()->SetSel(0);
57///}
58///TTabbedDialog::SetupWindow()
59///{
60/// TDialog::SetupWindow();
61/// SetupPages();
62///}
63/// \endcode
64//
65class _OWLCLASS TTabbedBase : virtual public TEventHandler
66{
67 public:
68 //
69 enum TTabPosition{ // only tpBottom currently
70 tpLeft = alLeft,
71 tpRight = alRight,
72 tpBottom = alBottom,
73 tpTop = alTop,
74 };
75
76 TTabbedBase(TWindow* self, int x, int y, int w, int h, TTabPosition=tpBottom, TNoteTab* tab = 0);
77 TTabbedBase(TWindow* self, TTabPosition=tpBottom, TNoteTab* tab = 0);
78
79 int Add(TWindow& wnd, LPCTSTR titles = 0);
80 int Add(TWindow& wnd, const tstring& titles) {return Add(wnd, titles.c_str());}
81
82 void SetupPages();
83 TNoteTab* GetTabControl() { return NoteTab; }
84 TWindow* GetPage(int index = -1);
85 void SelectPage(int index, bool shouldFocusPage = true);
86
87 protected:
88 void EvTabControlSelChange(TNotify& tcn);
89 bool EvTabControlSelChanging(TNotify& tcn);
90
91 virtual void AdjustPage(TWindow& page);
92
93
96
99 // add streaming???
100};
101
102////////////////////////////////////////////////////////////////////////////////
103/// \class TTabbedWindow
104// ~~~~~ ~~~~~~~~~~~~~
105/// Tabbed windows it is used in tabbed window.
106//
108 public:
109 TTabbedWindow(TWindow* parent=0, LPCTSTR title = 0, TModule* module = 0);
110 TTabbedWindow(TWindow* parent, const tstring& title, TModule* = 0);
111
112 // Need at least one page in order to add a page
113 int AddPage(TWindow& wnd, LPCTSTR titles = 0);
114 int AddPage(TWindow& wnd, const tstring& titles) {return AddPage(wnd, titles.c_str());}
115 bool DeletePage(TWindow& wnd);
116
117 //
118 /// Sets the height of the tab control to the given value, then updates the
119 /// layout of the window and invalidates the tab control. You can call
120 /// TNoteTab::GetMinimalHeight to get the shortest height that will show the
121 /// full vertical extent of the tabs.
122 //
123 void ResizeTabControl(int newHeight);
124
125 public:
126 auto Create() -> bool override;
127
128 private:
129 void Init();
130
132 // add streaming
133};
134
135
136////////////////////////////////////////////////////////////////////////////////
137/// \class TTabbedView
138// ~~~~~ ~~~~~~~~~~~
139//
141 public:
142 TTabbedView(TDocument& doc, TWindow* parent = 0);
143 ~TTabbedView() override;
144
145 static LPCTSTR StaticName(); // put in resource
146
147 // Override virtuals from TWindow
148 //
149 auto CanClose() -> bool override;
150
151 // Override virtuals from TView
152 //
153 auto GetViewName() -> LPCTSTR override;
154 auto GetWindow() -> TWindow* override;
155 auto SetDocTitle(LPCTSTR docname, int index) -> bool override;
156
157 private:
158 // Event handlers
159 //
160 bool VnIsWindow(HWND hWnd);
161
163};
164
165
166#include <owl/posclass.h>
167
168// inlines
169//
171{
172}
173
174//
176 return _T("Tabbed View");
177}
178
179//
180/// Only query document if this is the last view open to it.
181//
183 return TTabbedWindow::CanClose() && (Doc->NextView(this)
184 || Doc->NextView(nullptr) != this || Doc->CanClose());
185}
186
187//
189 return StaticName();
190}
191
192//
194 return static_cast<TWindow*>(this);
195}
196
197//
198inline bool TTabbedView::SetDocTitle(LPCTSTR docname, int index) {
199 return TTabbedWindow::SetDocTitle(docname, index);
200}
201
202} // OWL namespace
203
204#endif // !RC_INVOKED
205
206#endif // OWL_TABBED_H sentry.
207
An abstract base class, TDocument is the base class for all document objects and serves as an interfa...
Definition docview.h:187
TEventHandler is a base class from which you can derive classes that handle messages.
Definition eventhan.h:162
Derived from TWindow, TLayoutWindow provides functionality for defining the layout metrics for a wind...
Definition layoutwi.h:122
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
TNoteTab encapsulates a tab control with each tab item along the bottom of the window.
Definition notetab.h:70
TNotify is a thin wrapper around the NMHDR structure.
Definition commctrl.h:91
TTabbedBase implements a tabbed window, designed to be mixed in with TWindow derived.
Definition tabbed.h:66
int Add(TWindow &wnd, const tstring &titles)
Definition tabbed.h:80
DECLARE_RESPONSE_TABLE(TTabbedBase)
TNoteTab * GetTabControl()
Definition tabbed.h:83
TNoteTab * NoteTab
Definition tabbed.h:94
TTabPosition Position
Definition tabbed.h:95
auto CanClose() -> bool override
Only query document if this is the last view open to it.
Definition tabbed.h:182
auto GetViewName() -> LPCTSTR override
Definition tabbed.h:188
auto SetDocTitle(LPCTSTR docname, int index) -> bool override
Definition tabbed.h:198
~TTabbedView() override
Definition tabbed.h:170
static LPCTSTR StaticName()
Definition tabbed.h:175
auto GetWindow() -> TWindow *override
Definition tabbed.h:193
Tabbed windows it is used in tabbed window.
Definition tabbed.h:107
int AddPage(TWindow &wnd, const tstring &titles)
Definition tabbed.h:114
Abstract base class for view access from document.
Definition docview.h:397
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
virtual bool SetDocTitle(LPCTSTR docname, int index)
Default behavior for updating document title is to pass it to parent frame.
Definition window.cpp:778
virtual bool CanClose()
Use this function to determine if it is okay to close a window.
Definition window.cpp:2795
#define _T(x)
Definition cygwin.h:51
Definition of classes TDocument, TView, TWindowView, TStream, TInStream, TOutStream.
#define DECLARE_RESPONSE_TABLE(cls)
Definition eventhan.h:436
@ alTop
Refers to top edge of frame.
Definition geometry.h:64
@ alRight
Refers to right edge of frame.
Definition geometry.h:67
@ alBottom
Refers to bottom edge of frame.
Definition geometry.h:65
@ alLeft
Refers to left edge of frame.
Definition geometry.h:66
Definition of classes TLayoutMetrics & TLayoutWindow.
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
std::string tstring
Definition defs.h:79
Definition of class TNoteTab.
#define _OWLCLASS
Definition defs.h:338