OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
listboxview.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1993, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// Definition of class TListBoxView
7//----------------------------------------------------------------------------
8
9#if !defined(OWL_LISTBOXVIEW_H)
10#define OWL_LISTBOXVIEW_H
11
12#include <owl/private/defs.h>
13#if defined(BI_HAS_PRAGMA_ONCE)
14# pragma once
15#endif
16
17#include <owl/docmanag.h>
18#include <owl/listbox.h>
19#include <owl/listboxview.rh>
20
21
22namespace owl {
23
24#include <owl/preclass.h>
25
26/// \addtogroup docview
27/// @{
28/// \class TListBoxView
29// ~~~~~ ~~~~~~~~~
30/// Provides views for list boxes.
31class _OWLCLASS TListBoxView : public TListBox, public TView {
32 public:
33 TListBoxView(TDocument& doc, TWindow* parent = 0);
34
35 // Overridden virtuals from TView
36 //
37 auto GetViewName() -> LPCTSTR override;
38 auto GetWindow() -> TWindow* override;
39 auto SetDocTitle(LPCTSTR docname, int index) -> bool override;
40 using TView::SetDocTitle; ///< String-aware overload
41
42 // Overridden virtuals from TListBox
43 //
44 auto AddString(LPCTSTR) -> int override;
45 using TListBox::AddString; // Inject string-aware overload.
46
47 // Overridden virtuals from TWindow
48 //
49 auto CanClose() -> bool override;
50 auto Create() -> bool override;
51
52 static LPCTSTR StaticName(); ///< put in resource
53
54 protected:
55 long GetOrigin() const;
56 void SetOrigin(long origin);
57
58 int GetMaxWidth() const;
59 void SetMaxWidth(int maxwidth);
60
61 void SetExtent(const tstring& str);
62 bool LoadData(int top, int sel);
63
64 // Message response functions
65 //
66 void CmEditUndo();
67 void CmEditCut();
68 void CmEditCopy();
69 void CmEditPaste();
70 void CmEditDelete();
71 void CmEditClear();
72 void CmEditAdd();
73 void CmEditItem();
74 void CmSelChange();
75
76 uint EvGetDlgCode(const MSG*);
77
78 bool VnDocClosed(int omode);
79 bool VnCommit(bool force);
80 bool VnRevert(bool clear);
81 bool VnIsWindow(HWND hWnd);
82 bool VnIsDirty();
83
85 int DirtyFlag; ///< flag to indicate if the view is dirty
86
88 long Origin; ///< object's beginning position on the stream
89 int MaxWidth; ///< maximum horizontal extent (the number of pixels by which the view can be scrolled horizontally)
90
91 DECLARE_RESPONSE_TABLE(TListBoxView);
93};
94/// @}
95
97
98#include <owl/posclass.h>
99
100//----------------------------------------------------------------------------
101// Inline implementations
102//
103
104//
105/// Returns a constant string for the view name, ListView. This information is
106/// displayed in the user interface selection box.
107//
108inline LPCTSTR TListBoxView::StaticName() {
109 return _T("List View");
110}
111
112//
113/// Overrides TView's virtual GetViewName function and returns the descriptive name
114/// of the class (StaticName).
115//
117 return StaticName();
118}
119
120//
121/// Overrides TView's virtual GetWindow function and returns the list view object as
122/// a TWindow.
123//
125 return static_cast<TWindow*>(this);
126}
127
128//
129/// Overrides TView's virtual SetDocTitle function and stores the document title.
130/// This name is forwarded up the parent chain until a TFrameWindow object accepts
131/// the data and displays it in its caption.
132//
133inline bool TListBoxView::SetDocTitle(LPCTSTR docname, int index) {
134 return TListBox::SetDocTitle(docname, index);
135}
136
137//
138/// Return true if both the listbox and the document can close.
139///
140/// Checks to see if all child views can be closed before closing the current view.
141/// If any child returns 0, CanClose returns 0 and aborts the process. If all
142/// children return nonzero, it calls TDocManager::FlushDoc.
143//
145 return TListBox::CanClose() &&
146 (Doc->NextView(this) ||
147 Doc->NextView(nullptr) != this ||
148 Doc->CanClose());
149}
150
151//
152/// Returns the origin position on the persistent stream.
153//
154inline long TListBoxView::GetOrigin() const {
155 return Origin;
156}
157
158//
159/// Sets the position of the object
160//
161inline void TListBoxView::SetOrigin(long origin) {
162 Origin = origin;
163}
164
165//
166/// Returns the maximum width of the strings.
167//
168inline int TListBoxView::GetMaxWidth() const {
169 return MaxWidth;
170}
171
172//
173/// Sets the maximum width of the strings.
174//
175inline void TListBoxView::SetMaxWidth(int maxwidth) {
176 MaxWidth = maxwidth;
177}
178
179//
180/// Returns a nonzero value if the window's handle passed in hWnd is the same as
181/// that of the view's display window.
182//
183inline bool TListBoxView::VnIsWindow(HWND hWnd) {
184 return GetHandle() == hWnd;
185}
186
187//
188/// Returns a nonzero value if changes made to the data in the view have not been
189/// saved to the document; otherwise, returns 0.
190//
192 return DirtyFlag != 0;
193}
194
195
196} // OWL namespace
197
198
199#endif // OWL_LISTBOXVIEW_H
virtual int AddString(LPCTSTR str)
Adds str to the list box, returning its position in the list (0 is the first position).
Definition listbox.h:344
TListBox(TWindow *parent, int id, int x, int y, int w, int h, TModule *module=0)
Constructs a list box object with the supplied parent window (parent) library ID (module),...
Definition listbox.cpp:175
Provides views for list boxes.
Definition listboxview.h:31
bool LoadData(int top, int sel)
Reads the view from the stream and closes the file.
bool VnDocClosed(int omode)
Indicates that the document has been closed.
void CmEditClear()
Automatically responds to a menu selection with a menu ID of CM_EDITCLEAR by clearing the items in th...
void CmEditCopy()
Automatically responds to a menu selection with a menu ID of CM_EDITCOPY and copies the selected text...
void SetExtent(const tstring &str)
Sets the maximum horizontal extent for the list view window.
auto GetViewName() -> LPCTSTR override
Overrides TView's virtual GetViewName function and returns the descriptive name of the class (StaticN...
void CmEditAdd()
Automatically responds to CM_LISTADD message by getting the length of the input string and inserting ...
void CmEditItem()
Automatically responds to a CM_LISTEDIT message by getting the input text and inserting the text into...
auto SetDocTitle(LPCTSTR docname, int index) -> bool override
Overrides TView's virtual SetDocTitle function and stores the document title.
auto AddString(LPCTSTR) -> int override
< String-aware overload
bool VnIsDirty()
Returns a nonzero value if changes made to the data in the view have not been saved to the document; ...
void CmEditCut()
Automatically responds to a menu selection with a menu ID of CM_EDITCUT by calling CmEditCopy and CmE...
bool VnRevert(bool clear)
Indicates if changes made to the view should be erased, and if the data from the document should be r...
void CmSelChange()
Automatically responds to a LBN_SELCHANGE message (which indicates that the contents of the list view...
void CmEditPaste()
Automatically responds to a menu selection with a menu ID of CM_EDITPASTE by inserting text into the ...
int GetMaxWidth() const
Returns the maximum width of the strings.
TListBoxView(TDocument &doc, TWindow *parent=0)
Creates a TListBoxView object associated with the specified document and parent window.
void SetMaxWidth(int maxwidth)
Sets the maximum width of the strings.
void CmEditDelete()
Automatically responds to a menu selection with a menu ID of CM_EDITDELETE by deleting the currently ...
void CmEditUndo()
Handler to undo the last operation performed on the underlying ListBox.
bool VnCommit(bool force)
Commits changes made in the view to the document.
bool VnIsWindow(HWND hWnd)
Returns a nonzero value if the window's handle passed in hWnd is the same as that of the view's displ...
long GetOrigin() const
Returns the origin position on the persistent stream.
uint EvGetDlgCode(const MSG *)
Overrides TWindow's response to a WM_GETDLGCODE message (an input procedure associated with a control...
auto CanClose() -> bool override
Return true if both the listbox and the document can close.
auto GetWindow() -> TWindow *override
Overrides TView's virtual GetWindow function and returns the list view object as a TWindow.
static LPCTSTR StaticName()
put in resource
void SetOrigin(long origin)
Sets the position of the object.
auto Create() -> bool override
Overrides TWindow::Create and creates the view's window.
virtual bool SetDocTitle(LPCTSTR docname, int index)
Stores the document title.
Definition docview.h:1071
friend class TDocument
needs access to NextView
Definition docview.h:477
TView(TDocument &doc)
Constructs a TView object of the document associated with the view.
Definition view.cpp:34
virtual LPCTSTR GetViewName()=0
Pure virtual function that returns 0.
virtual TWindow * GetWindow()
Returns the TWindow instance associated with the view, or 0 if no view exists.
Definition docview.h:1049
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
HWND GetHandle() const
Returns the handle of the window.
Definition window.h:2020
#define _T(x)
Definition cygwin.h:51
Definition of class TDocManager.
#define DECLARE_STREAMABLE_OWL(cls, ver)
Definition objstrm.h:1529
#define DECLARE_STREAMABLE_INLINES(cls)
Definition objstrm.h:1538
Definition of class TListBox and TlistBoxData.
Object Windows Library (OWLNext Core).
Definition animctrl.h:22
std::string tstring
Definition defs.h:79
unsigned int uint
Definition number.h:25
#define protected_data
Definition defs.h:208
#define public_data
Definition defs.h:207
#define _OWLCLASS
Definition defs.h:338