OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
occtrl.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectComponents
3// Copyright (c) 1994, 1996 by Borland International, All Rights Reserved
4/// \file
5/// Definition of TOcControl class - Proxy object representing a control in
6// an OCF container.
7//----------------------------------------------------------------------------
8
9#if !defined(OCF_OCCTRL_H)
10#define OCF_OCCTRL_H
11
12#include <owl/private/defs.h>
13#if defined(BI_HAS_PRAGMA_ONCE)
14# pragma once
15#endif
16
17#include <ocf/ocview.h>
18#include <ocf/ocpart.h>
19#include <ocf/automacr.h>
20
21
22
23
24// Check build target!
25//
26
27interface _ICLASS ITypeInfo;
28
29namespace ocf {
30
32class TAutoStack;
33
34//
35//
36//
38 public:
41
42 void Init(int index, ITypeInfo* typeInfo);
43 void Cleanup();
44
45 protected:
46 DISPID IDOfEvent;
49};
50
51//
52//
53//
55 public:
56 TEventList(ITypeInfo* typeInfo);
58 TEventEntry& operator[](int index);
59
60 owl::uint GetCount() const { return Count; }
61 const GUID& GetEventIID() const { return EventIID; }
62 protected:
66};
67
68
69//
70/// \class TOcControl
71// ~~~~~ ~~~~~~~~~~
72//
73/// Class representing an embedded control within a document
74///
75/// \todo Research this, as it is not true:
76/// change from protected IBControlSite to public IBControlSite -> c++ syntax
77/// in DECLARE_AUTOCLASS(TOcControl) exist conversion to IDispatch
78class _ICLASS TOcControl : public TOcPart, protected IBControlSite {
79 public:
80 TOcControl(TOcDocument& document, int id=0, TOcControlEvent* pEv=nullptr);
81 TOcControl(TOcDocument& document, LPCTSTR name);
82
83 // Overriden virtual of TOcPart
84 //
85 bool Init(TOcInitInfo * initInfo, owl::TRect pos);
86
87 // Define AddRef/Release/QI to avoid ambiguity
88 //
90
91 // Retrieve interface/object
92 //
93 IBControl* GetBControlI() {return BCtrlI;}
94 TOcView* GetActiveControlView();
95
96 ITypeInfo* GetEventTypeInfo();
97 IDispatch* GetCtlDispatch();
98
99 // Flag accessor functions
100 //
101 void SetDefault(bool def)
102 {if (def) Flags |= OcxDefault; else Flags &= ~OcxDefault;}
103 void SetCancel(bool cancel)
104 {if (cancel) Flags |= OcxCancel; else Flags &= ~OcxCancel;}
105 void SetUserName(owl::TString& name);
106 owl::uint GetId() const { return CtlId; }
107 void SetId(owl::uint id){ CtlId = id; }
108
109 // Support for caching/looking of control's events
110 //
111 bool FillEventList();
112 TEventList* GetEventList() const;
113
114 // Access to Extended property support
115 //
116 bool IsCancel() const {return (Flags & OcxCancel) != 0;}
117 bool IsDefault() const {return (Flags & OcxDefault)!= 0;}
118 long GetLeft() { return Pos.x; }
119 long GetTop() { return Pos.y; }
120 long GetWidth() { return Size.cx; }
121 long GetHeight() { return Size.cy; }
122 void SetLeft(long Value);
123 void SetWidth(long Value);
124 void SetTop(long Value);
125 void SetHeight(long Value);
126 owl::TString& GetUserName();
127 IDispatch* GetParent();
128
129 // Standard methods
130 //
131 HRESULT Refresh() { return GetBControlI()->Refresh(); }
132 HRESULT DoClick() { return GetBControlI()->DoClick(); }
133 HRESULT AboutBox() { return GetBControlI()->AboutBox();}
134
135 protected:
136 ~TOcControl();
137
138 // Overriden virtual of TOcPart
139 //
140 bool InitObj (TOcInitInfo * initInfo);
141
142 // Helper to create served object (IDispatch*) of a class
143 //
144 TUnknown* CreateAutoObject(const void* obj, TAutoClass& clsInfo);
145
146 // TUnknown virtual overrides
147 //
148 HRESULT QueryObject(const IID & iid, void * * iface);
149
157
158 // IBControlSite implementation for BOle to use
159 //
160 HRESULT _IFUNC Init(UINT, IBControl*, UINT);
161 HRESULT _IFUNC OnPropertyChanged(DISPID dispid);
162 HRESULT _IFUNC OnPropertyRequestEdit(DISPID dispid);
163 HRESULT _IFUNC OnControlFocus(BOOL fGotFocus);
164 HRESULT _IFUNC TransformCoords(owl::TPointL * lpptlHimetric,
165 owl::TPointF * lpptfContainer, DWORD flags);
166
167 // TOcPart virtual routed to correct base (don't want other Init to hide)
168 //
169 HRESULT _IFUNC Init(IBDataProvider * dp, IBPart * p, LPCOLESTR s, BOOL b)
170 {return TOcPart::Init(dp, p, s, b);}
171
172 // Initialize the event IDispatch [Assumes pEvents is initialized]
173 //
174 void SetEventDispatch();
175
177 //
178 // Standard extended properties
179 //
180 AUTOPROP(Visible, IsVisible, SetVisible, bool, public:)
181 AUTOPROP(Cancel, IsCancel, SetCancel, bool, public:)
182 AUTOPROP(Default, IsDefault, SetDefault, bool, public:)
183 //AUTOPROP(Name, GetUserName, SetUserName, owl::TString, public:)
184#pragma warn -inl
185 AUTOPROPBUG(Name, GetUserName, SetUserName, owl::TString, public:) // yura 05/26/98
186#pragma warn .inl
187
188 AUTOPROPRO(Parent, GetParent, IDispatch*, public:)
189 AUTOPROP(Left, GetLeft, SetLeft, long, public:)
190 AUTOPROP(Top, GetTop, SetTop, long, public:)
191 AUTOPROP(Width, GetWidth, SetWidth, long, public:)
192 AUTOPROP(Height, GetHeight, SetHeight, long, public:)
193
195};
196
197//
198/// \class TOcControlEvent
199// ~~~~~ ~~~~~~~~~~~~~~~
200/// OC Control Event class for standard control events
201//
203 public:
205
206 // Accessor to associated control object
207 //
208 TOcControl* GetControl() {return pCtrl;}
209
210 protected:
212
213 virtual void InitEventDispatch();
214 TUnknown* CreateAutoObject(const void* obj, TAutoClass& clsInfo);
215
216 // Standard events support
217 //
218 long Click();
219 long DblClick();
220 long MouseDown(short Button, short Shift, long X, long Y);
221 long MouseMove(short Button, short Shift, long X, long Y);
222 long MouseUp (short Button, short Shift, long X, long Y);
223 long KeyDown (short* KeyCode, short Shift);
224 long KeyUp (short* KeyCode, short Shift);
225 long ErrorEvent(short number, TAutoString Description,
226 SCODE SCode, TAutoString Source,
227 TAutoString HelpFile,
228 long helpContext, bool * CancelDisplay);
229
230 HRESULT ForwardClickEvent(owl::uint msg, DISPID id);
231 HRESULT ForwardKeyEvent (owl::uint msg, DISPID id, short *KeyCode, short Shift);
232 HRESULT ForwardMouseEvent(owl::uint msg, DISPID id, short Button, short Shift,
233 long X, long Y);
234 HRESULT CustomEvent(long *args);
235
236 protected:
239
241
242 // Automation symbol table declaring methods handling standard events
243 //
244 AUTOFUNC0R(Click, Click, long)
245 AUTOFUNC0R(DblClick, DblClick, long)
246 AUTOFUNC4(MouseDown, MouseDown, long, short, short, long, long, public:)
247 AUTOFUNC4(MouseUp, MouseUp, long, short, short, long, long, public:)
248 AUTOFUNC4(MouseMove, MouseMove, long, short, short, long, long, public:)
249 AUTOFUNC2(KeyDown, KeyDown, long, short*, short, public:)
250 AUTOFUNC2(KeyUp, KeyUp, long, short*, short, public:)
251#pragma warn -inl
252 AUTOFUNC7(ErrorEvent, ErrorEvent, long,
253 short /* number */,
254 TAutoString /* Description */,
255 long /* SCode */,
256 TAutoString /* Source */,
257 TAutoString /* HelpFile */,
258 long /* helpContext */,
259 bool* /* CancelDisplay */, public:)
260#pragma warn .inl
261 AUTOFUNCX(CustomEvent, CustomEvent, long, public:)
262
263 friend TOcControl;
264};
265
266
267//
268/// \class TOcxView
269// ~~~~~ ~~~~~~~~
270/// The TOcxView partner is a container (viewer) of a given (server/client)
271/// document.
272//
273class _ICLASS TOcxView : public TOcView {
274 public:
275 TOcxView(TOcDocument& doc, owl::TRegList* regList=0, IUnknown* outer=0);
276 ~TOcxView();
277
278 HRESULT QueryObject(const IID & iid, void * * iface);
279
280 // Ambient property support
281 //
282 void SetBackColor(long Color);
283 void SetForeColor(long Color);
284 void SetLocaleID(long LocaleId);
285 void SetMessageReflect(bool MsgRef);
286 void SetTextAlign(short Align);
287 void SetUserMode(bool Mode);
288 void SetUIDead(bool Dead);
289 void SetShowGrabHandles(bool Handles);
290 void SetSupportsMnemonics(bool Mnem);
291 void SetShowHatching(bool Hatch);
292 void SetDisplayAsDefault(bool Disp);
293 void SetDisplayName(owl::TString& Name);
294 void SetScaleUnits(owl::TString& ScaleUnits);
295 void SetFont(IDispatch *pFontDisp);
296
297 protected:
298 long GetBackColor();
299 long GetForeColor();
300 long GetLocaleID();
301 bool GetMessageReflect();
302 short GetTextAlign();
303 bool GetUserMode();
304 bool GetUIDead();
305 bool GetShowGrabHandles();
306 bool GetSupportsMnemonics();
307 bool GetShowHatching();
308 bool GetDisplayAsDefault();
309 owl::TString& GetDisplayName();
310 owl::TString& GetScaleUnits();
311 IDispatch* GetFont(); // returns IFontDispatch
312
313 void SetAmbBackColor(long Color);
314 void SetAmbForeColor(long Color);
315 void SetAmbLocaleID(long LocaleId);
316 void SetAmbMessageReflect(bool MsgRef);
317 void SetAmbTextAlign(short Align);
318 void SetAmbUserMode(bool Mode);
319 void SetAmbUIDead(bool Dead);
320 void SetAmbShowGrabHandles(bool Handles);
321 void SetAmbSupportsMnemonics(bool Mnem);
322 void SetAmbShowHatching(bool Hatch);
323 void SetAmbDisplayAsDefault(bool Disp);
324 void SetAmbDisplayName(owl::TString& Name);
325 void SetAmbScaleUnits(owl::TString& ScaleUnits);
326 void SetAmbFont(IDispatch *pFontDisp);
327
328 void AmbientChanged(DISPID dispid);
329 long GetAmbientValue(long AmbientMsg, long Default);
330
331 protected:
334
335 // Ambient properties
336 //
338 AUTOPROP(BackColor, GetBackColor, SetAmbBackColor, long, public:)
339 AUTOPROP(ForeColor, GetForeColor, SetAmbForeColor, long, public:)
340 AUTOPROP(LocaleID, GetLocaleID, SetAmbLocaleID, long, public:)
341 AUTOPROP(MessageReflect, GetMessageReflect, SetAmbMessageReflect, bool, public:)
342 AUTOPROP(TextAlign, GetTextAlign, SetAmbTextAlign, short, public:)
343 AUTOPROP(UserMode, GetUserMode, SetAmbUserMode, bool, public:)
344 AUTOPROP(UIDead, GetUIDead, SetAmbUIDead, bool, public:)
345 AUTOPROP(ShowGrabHandles, GetShowGrabHandles,SetAmbShowGrabHandles,bool, public:)
346 AUTOPROP(ShowHatching, GetShowHatching, SetAmbShowHatching, bool, public:)
347 //AUTOPROP(DisplayName, GetDisplayName, SetAmbDisplayName, owl::TString, public:)
348#pragma warn -inl
349 AUTOPROPBUG(DisplayName, GetDisplayName, SetAmbDisplayName, owl::TString, public:) // yura 05/26/98
350#pragma warn .inl
351 //AUTOPROP(ScaleUnits, GetScaleUnits, SetAmbScaleUnits, owl::TString, public:)
352#pragma warn -inl
353 AUTOPROPBUG(ScaleUnits, GetScaleUnits, SetAmbScaleUnits, owl::TString, public:) // yura 05/26/98
354#pragma warn .inl
355 AUTOPROP(Font, GetFont, SetAmbFont, IDispatch*, public:)
356 AUTOPROP(DisplayAsDefault, GetDisplayAsDefault, SetDisplayAsDefault, bool, public:)
357 AUTOPROP(SupportsMnemonics,GetSupportsMnemonics,SetAmbSupportsMnemonics, bool, public:)
358};
359
360
361//
362/// \struct TCtrlEvent
363//
364/// Base struct for all control event messages
365//
367 TCtrlEvent(TOcControl* ctl, DISPID id) : Ctrl(ctl), DispId(id) {}
368
369 TOcControl* Ctrl; // Proxy object representing control
370 DISPID DispId;
371};
372
374 TCtrlMouseEvent(TOcControl* ctl, DISPID id, short butt, short shft, long x, long y) :
375 TCtrlEvent(ctl, id), Button(butt), Shift(shft), X(x), Y(y)
376 {}
377
378 short Button;
379 short Shift;
380 long X;
381 long Y;
382};
383
384struct TCtrlKeyEvent : public TCtrlEvent {
385 TCtrlKeyEvent(TOcControl* ctl, DISPID id, short kcode, short shft) : TCtrlEvent(ctl, id),
386 KeyCode(kcode), Shift(shft)
387 {}
388
389 short KeyCode;
390 short Shift;
391};
392
394 TCtrlFocusEvent(TOcControl* ctl, bool gotFocus)
395 : TCtrlEvent(ctl, 0/*IId of Focus Event??*/),
396 GotFocus(gotFocus){}
397
399};
400
402 TCtrlPropertyEvent(TOcControl* ctl, DISPID dispid, bool acpt = true) :
403 TCtrlEvent(ctl, dispid), accept(acpt)
404 {}
405
406 bool accept;
407};
408
410#pragma warn -inl
411
413 SCODE scode, TAutoString src, TAutoString hlpfile,
414 long hlpCtx, bool xceldisplay) :
415 TCtrlEvent(ctl, DISPID_ERROREVENT),
416 Number(num), Description(desc), SCode(scode), Source(src),
417 HelpFile(hlpfile), HelpContext(hlpCtx),
418 CancelDisplay(xceldisplay)
419 {}
420#pragma warn .inl
421
422 short Number;
424 SCODE SCode;
429};
430
432 TCtrlCustomEvent(TOcControl* ctl, DISPID id, TAutoStack* args) : TCtrlEvent(ctl, id),
433 Args(args)
434 {}
436};
437
439
441 DWORD flgs) :
442 TCtrlEvent(ctl, 0/*IID for this event??*/),
443 lpptHimetric(him), lpptContainer(pcont), flags(flgs)
444 {}
445
448 DWORD flags;
449};
450
451
452//
453// Global functions to allow easy registration/unregistration of OCXes
454//
455_OCFFUNC(HRESULT) OcRegisterControl(LPTSTR ocxPath);
456_OCFFUNC(HRESULT) OcUnregisterControl(CLSID ClassId);
457
458} // OCF namespace
459
460#endif
461
Automation Symbol Table, Command, and Proxy Macro Definitions.
#define AUTOFUNC7(name, func, ret, t1, t2, t3, t4, t5, t6, t7, defs)
Definition automacr.h:665
#define DECLARE_AUTOCLASS(cls)
Definition automacr.h:222
#define AUTOPROPRO(name, get, type, defs)
Definition automacr.h:824
#define AUTOPROP(name, get, set, type, defs)
Definition automacr.h:818
#define AUTOFUNC0R(name, func, ret)
Definition automacr.h:573
#define AUTOFUNC2(name, func, ret, t1, t2, defs)
Definition automacr.h:605
#define AUTOPROPBUG(name, get, set, type, defs)
Definition automacr.h:821
#define AUTOFUNC4(name, func, ret, t1, t2, t3, t4, defs)
Definition automacr.h:631
#define AUTOFUNCX(name, func, ret, defs)
Definition automacr.h:1047
IBDataProvider – Supported by parts and/or sites which can be copied to the OLE2 clipboard.
Definition ocbocole.h:219
IBPart – Supported by server objects.
Definition ocbocole.h:241
Automation argument stack abstraction.
Definition autodefs.h:813
Based on reference counted TString with added automation functionality.
Definition autodefs.h:492
Definition occtrl.h:37
BSTR * NameAndParams
Definition occtrl.h:48
DISPID IDOfEvent
Definition occtrl.h:46
owl::uint ParamCount
Definition occtrl.h:47
owl::uint GetCount() const
Definition occtrl.h:60
const GUID & GetEventIID() const
Definition occtrl.h:61
owl::uint Count
Definition occtrl.h:64
TEventEntry * EventList
Definition occtrl.h:63
GUID EventIID
Definition occtrl.h:65
OC Control Event class for standard control events.
Definition occtrl.h:202
TOcControl * GetControl()
Definition occtrl.h:208
TOcControl * pCtrl
Definition occtrl.h:237
TServedObject * pIEvents
Definition occtrl.h:238
Class representing an embedded control within a document.
Definition occtrl.h:78
TOcControlEvent * pEvents
Definition occtrl.h:153
HRESULT AboutBox()
Definition occtrl.h:133
HRESULT Refresh()
Definition occtrl.h:131
owl::uint CtlId
Definition occtrl.h:155
TUNKNOWN_STANDARD_IUNKNOWN_METHODS
Definition occtrl.h:89
owl::uint GetId() const
Definition occtrl.h:106
HRESULT DoClick()
Definition occtrl.h:132
TServedObject * pIExtended
Definition occtrl.h:152
bool pEventsOwnership
Definition occtrl.h:154
TEventList * EventList
Definition occtrl.h:156
bool IsCancel() const
Definition occtrl.h:116
IBControl * BCtrlI
Definition occtrl.h:150
HRESULT _IFUNC Init(IBDataProvider *dp, IBPart *p, LPCOLESTR s, BOOL b)
Definition occtrl.h:169
void SetCancel(bool cancel)
Definition occtrl.h:103
long GetHeight()
Definition occtrl.h:121
void SetDefault(bool def)
Definition occtrl.h:101
long GetLeft()
Definition occtrl.h:118
owl::TString * pUserName
Definition occtrl.h:151
void SetId(owl::uint id)
Definition occtrl.h:107
long GetTop()
Definition occtrl.h:119
bool IsDefault() const
Definition occtrl.h:117
IBControl * GetBControlI()
Definition occtrl.h:93
long GetWidth()
Definition occtrl.h:120
OC Document class, holds parts & is a owner of views.
Definition ocdoc.h:43
OC part class represents an embeded or linked part in a document.
Definition ocpart.h:38
The TOcView partner is a container (viewer) of a given (server/client) document.
Definition ocview.h:136
The TOcxView partner is a container (viewer) of a given (server/client) document.
Definition occtrl.h:273
TServedObject * pIAmbients
Definition occtrl.h:332
owl::TString * pBlankString
Definition occtrl.h:333
OLE object exposed for automated access of internal object.
Definition autodefs.h:972
Standard implementation of a controlling IUnknown for an object, to be inherited with other COM inter...
Definition oleutil.h:264
TPointF is similar to TPoint, but uses floating variables rather than integers.
Definition geometry.h:181
TPointL is similar to TPoint, but uses long rather than int variables.
Definition geometry.h:132
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
A registration parameter table, composed of a list of TRegItems.
Definition registry.h:531
Reference to reference counted string object TUString Lightweight reference object consisting of a po...
Definition string.h:67
Object Component Framework (COM encapsulation)
Definition appdesc.h:22
MouseDown
Definition occtrl.cpp:181
TextAlign
Definition occtrl.cpp:127
MouseMove
Definition occtrl.cpp:191
Height
Definition occtrl.cpp:160
DisplayAsDefault
Definition occtrl.cpp:133
DisplayName
Definition occtrl.cpp:135
CustomEvent
Definition occtrl.cpp:210
Click
Definition occtrl.cpp:179
HRESULT OcRegisterControl(TCHAR *ocxPath)
Definition occtrl.cpp:1286
KeyUp
Definition occtrl.cpp:199
Cancel
Definition occtrl.cpp:154
UserMode
Definition occtrl.cpp:129
const GUID & iid
Definition appdesc.h:328
ShowGrabHandles
Definition occtrl.cpp:131
Parent
Definition occtrl.cpp:152
HRESULT OcUnregisterControl(CLSID ClassId)
Definition occtrl.cpp:1299
ForeColor
Definition occtrl.cpp:125
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
unsigned int uint
Definition number.h:25
#define _OCFFUNC(p)
Definition defs.h:47
#define _OCFCLASS
Definition defs.h:45
Definition of TOcPart class.
Definition of Compound Document TOcView Class.
#define _IFUNC
Definition oleutil.h:28
#define _ICLASS
Definition oleutil.h:25
TCtrlCustomEvent(TOcControl *ctl, DISPID id, TAutoStack *args)
Definition occtrl.h:432
TAutoStack * Args
Definition occtrl.h:435
TAutoString HelpFile
Definition occtrl.h:426
TAutoString Description
Definition occtrl.h:423
TAutoString Source
Definition occtrl.h:425
TCtrlErrorEvent(TOcControl *ctl, short num, TAutoString desc, SCODE scode, TAutoString src, TAutoString hlpfile, long hlpCtx, bool xceldisplay)
Definition occtrl.h:412
Base struct for all control event messages.
Definition occtrl.h:366
TOcControl * Ctrl
Definition occtrl.h:369
DISPID DispId
Definition occtrl.h:370
TCtrlEvent(TOcControl *ctl, DISPID id)
Definition occtrl.h:367
TCtrlFocusEvent(TOcControl *ctl, bool gotFocus)
Definition occtrl.h:394
TCtrlKeyEvent(TOcControl *ctl, DISPID id, short kcode, short shft)
Definition occtrl.h:385
TCtrlMouseEvent(TOcControl *ctl, DISPID id, short butt, short shft, long x, long y)
Definition occtrl.h:374
TCtrlPropertyEvent(TOcControl *ctl, DISPID dispid, bool acpt=true)
Definition occtrl.h:402
TCtrlTransformCoords(TOcControl *ctl, owl::TPointL *him, owl::TPointF *pcont, DWORD flgs)
Definition occtrl.h:440
owl::TPointF * lpptContainer
Definition occtrl.h:447
owl::TPointL * lpptHimetric
Definition occtrl.h:446