34 typedef std::map<TWindow*, TFieldInfo, std::less<TWindow*> > TFieldDetails;
42 TOffsetEq(
size_t ofs) : Offset(ofs) {}
44 bool operator()(
const TFieldDetails::value_type& v)
45 {
return v.second.Offset == Offset;}
54 TIdEq(
int id) : Id(id) {}
56 bool operator()(
const TFieldDetails::value_type& v)
57 {
return v.first->GetId() == Id;}
63 struct TTransferIterInfo
65 TFieldDetails* Details;
78 void TransferChild(
TWindow& child,
const TTransferIterInfo& t)
87 TFieldDetails::const_iterator i = t.Details->find(&child);
89 const TFieldInfo& f = (*i).second;
91 if (size != f.Size)
TXWindow::Raise(&child, IDS_TRANSFERBUFFERSIZEMISMATCH);
94 void* field =
static_cast<char*
>(t.Buffer) + f.Offset;
95 uint transferred_size = child.Transfer(field, t.Direction);
96 if (transferred_size != size)
TXWindow::Raise(&child, IDS_TRANSFERBUFFERSIZEMISMATCH);
109 <<
_T(
" is trying to bind to more than one field.\n\n")
110 <<
_T(
"Ensure that every control is bound to a separate field in the transfer buffer, ")
111 _T(
"and that TTransferBufferWindow::Bind is not called more than once for the same control.\n");
124 <<
_T(
" is trying to bind to an already bound field.\n\n")
125 <<
_T(
"Ensure that every control is bound to a separate field in the transfer buffer, ")
126 _T(
"and that TTransferBufferWindow::Bind is not called more than once for the same control.\n");
137 s <<
_T(
"Transfer requested by unbound control #")
140 <<
_T(
"Use TTransferBufferWindow::Bind to bind the control to a field in the window's transfer buffer, ")
141 _T(
"or disable transfer for this control using TWindow::DisableTransfer.\n");
153 <<
_T(
" is meddling with the transfer of control #")
156 <<
_T(
"Validators are not allowed to take part in transfers in a TTransferBufferWindow. ")
157 _T(
"Turn off transfer meddling for the validator by calling TValidator::UnsetOption(voTransfer). ")
158 _T(
"You must use a custom control if you need to transfer numeric buffer fields.\n");
171 TFieldDetails FieldDetails;
190 if (!buffer && direction !=
tdSizeData)
return 0;
191 const auto info = TTransferIterInfo{&pimpl->FieldDetails, buffer, direction};
193 TransferChild(w, info);
201 TFieldDetails& f = pimpl->FieldDetails;
202 if (std::find_if(f.begin(), f.end(), TOffsetEq(offset)) != f.end())
204 if (std::find_if(f.begin(), f.end(), TIdEq(c.
GetId())) != f.end())
207 TFieldInfo info = {offset, size};
208 typedef std::pair<TFieldDetails::iterator, bool> TInsertResult;
209 TInsertResult r = f.insert(TFieldDetails::value_type(&c, info));
216 :
TXOwl(MakeMessageForTXPolygamousControl(c))
220 :
TXOwl(MakeMessageForTXFieldConflict(c))
224 :
TXOwl(MakeMessageForTXUnboundControl(c))
228 :
TXOwl(MakeMessageForTXMeddlingValidator(c))
#define PRECONDITION(condition)
A TEdit is an interface object that represents an edit control interface element.
TXFieldConflict(TWindow &c)
Thrown if a validator attempts to meddle with the transfer.
TXMeddlingValidator(TEdit &c)
TXPolygamousControl(TWindow &c)
Thrown if a transfer is attempted with an unbound control.
TXUnboundControl(TWindow &c)
Serves as the base class for safe transfer buffer windows.
void AssignField(TWindow &, size_t offset, size_t size)
Stores the field details and enables transfer for the given control.
TTransferBufferWindowBase()
Initializes the private implementation.
virtual ~TTransferBufferWindowBase()
Required for proper clean-up.
virtual uint Transfer(void *buffer, TTransferDirection direction)
TWindow override Dispatches to all the children.
virtual void TransferData(TTransferDirection direction)
TWindow override Initiates the transfer of the children data to or from the transfer buffer.
A streamable class, TValidator defines an abstract data validation object.
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
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...
auto GetChildren()
Returns a TWindow::TChildrenRange that can be iterated by standard means.
int GetId() const
Returns Attr.Id, the ID used to find the window in a specified parent's child list.
TWindow * GetParentO() const
Return the OWL's parent for this window.
void EnableTransfer()
Enables the transfer mechanism, which allows state data to be transferred between the window and a tr...
void * GetTransferBuffer() const
uint GetTransferBufferSize() const
static void Raise(TWindow *win=nullptr, uint resourceId=IDS_INVALIDWINDOW)
Creates the TXWindow exception and throws it.
TXOwl(const tstring &msg, uint resId=0)
An OWL exception with a given message for displaying and an unsigned Id that can be used for identifi...
@ voTransfer
Option to perform conversion & transfer.
TTransferDirection
The TTransferDirection enum describes the constants that the transfer function uses to determine how ...
@ wfTransfer
Participates in the Transfer mechanism.
@ tdSizeData
Return the size of data transferred by the class.
Object Windows Library (OWLNext Core).
tstring GetFullTypeName(T *w)
Helper; returns the type of a window as an tstring.
std::ostringstream tostringstream
#define TYPESAFE_DOWNCAST(object, toClass)