InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IDVUINodeRef.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Dave Burnard
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2008 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //========================================================================================
23 
24 #ifndef __IDVUINODEREF__
25 #define __IDVUINODEREF__
26 
27 #include "IPMUnknown.h"
28 #include "DV_WidgetID.h"
29 
30 #include "DVAForwardDeclarations.h"
31 
32 #include "boost/cast.hpp"
33 
34 
39 class IDV_UI_NodeRef : public IPMUnknown
40 {
41 public:
42  enum {kDefaultIID = IID_IDV_UI_NODEREF};
43 
46  virtual dvaui::ui::UI_Node* Get_UI_Node() const = 0;
47 
50  virtual void Set_UI_Node(dvaui::ui::UI_Node*) = 0;
51 
52 
55  template<class Target>
56  inline static Target* Get_UI_Node_As(dvaui::ui::UI_Node* node)
57  {
58  return ((node) ? dynamic_cast<Target*>(node) : nil);
59  }
60 
61  template<class Target>
62  inline static Target* Get_UI_Node_As(IDV_UI_NodeRef* ref)
63  {
64  return ((ref && ref->Get_UI_Node()) ? dynamic_cast<Target*>(ref->Get_UI_Node()) : nil);
65  }
66 
67  template<class Target>
68  inline static Target* Get_UI_Node_As(const IPMUnknown* ref)
69  {
71  return ((nodeRef && nodeRef->Get_UI_Node()) ? dynamic_cast<Target*>(nodeRef->Get_UI_Node()) : nil );
72  }
73 
74  template<class Target>
75  inline Target* Get_UI_Node_As() const
76  {
77  return Get_UI_Node_As<Target*>(Get_UI_Node());
78  }
79 
80 };
81 
82 #endif