1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * collection.h: different types of collections
5 * Copyright 2007 Novell, Inc. (http://www.novell.com)
7 * See the LICENSE file included with the distribution for details.
11 #ifndef __MOON_COLLECTION_H__
12 #define __MOON_COLLECTION_H__
16 #include "dependencyobject.h"
17 #include "eventargs.h"
20 class CollectionIterator
;
23 // Collection: provides a collection that we can monitor for
24 // changes. We expose this collection in a few classes to
25 // the managed world, and when a change happens we get a
26 // chance to reflect the changes
28 /* @Namespace=System.Windows */
29 /* @ManagedName=PresentationFrameworkCollection`1 */
30 /* @ManagedDependencyProperties=Manual */
31 /* @ManagedEvents=Manual */
32 class Collection
: public DependencyObject
{
34 /* @PropertyType=gint32,DefaultValue=0,GenerateAccessors */
35 const static int CountProperty
;
37 /* @GenerateCBinding,GeneratePInvoke */
38 virtual Type::Kind
GetElementType () = 0;
40 int Generation () { return generation
; }
41 GPtrArray
*Array () { return array
; }
43 /* @GenerateCBinding,GeneratePInvoke */
44 virtual CollectionIterator
*GetIterator ();
46 /* @GenerateCBinding,GeneratePInvoke */
47 virtual int GetCount ();
49 int Add (Value value
);
50 int Add (Value
*value
);
52 /* @GenerateCBinding,GeneratePInvoke */
53 virtual bool Clear ();
55 /* @GenerateCBinding,GeneratePInvoke */
56 bool Contains (Value
*value
);
57 /* @GenerateCBinding,GeneratePInvoke */
58 int IndexOf (Value
*value
);
60 bool Insert (int index
, Value value
);
61 bool Insert (int index
, Value
*value
);
63 bool Remove (Value value
);
64 /* @GenerateCBinding,GeneratePInvoke */
65 bool Remove (Value
*value
);
67 bool RemoveAt (int index
);
69 bool SetValueAt (int index
, Value
*value
);
70 Value
*GetValueAt (int index
);
72 /* @GenerateCBinding,GeneratePInvoke,Version=2.0 */
73 virtual int AddWithError (Value
*value
, MoonError
*error
);
74 /* @GenerateCBinding,GeneratePInvoke,Version=2.0 */
75 virtual bool InsertWithError (int index
, Value
*value
, MoonError
*error
);
76 /* @GenerateCBinding,GeneratePInvoke,Version=2.0 */
77 virtual Value
*GetValueAtWithError (int index
, MoonError
*error
);
78 /* @GenerateCBinding,GeneratePInvoke,Version=2.0 */
79 virtual bool SetValueAtWithError (int index
, Value
*value
, MoonError
*error
);
80 /* @GenerateCBinding,GeneratePInvoke,Version=2.0 */
81 virtual bool RemoveAtWithError (int index
, MoonError
*error
);
83 const static int ChangedEvent
;
84 const static int ItemChangedEvent
;
90 void EmitChanged (CollectionChangedAction action
, Value
*new_value
, Value
*old_value
, int index
);
91 void EmitItemChanged (DependencyObject
*object
, DependencyProperty
*property
, Value
*newValue
, Value
*oldValue
);
93 virtual bool CanAdd (Value
*value
);
94 virtual bool AddedToCollection (Value
*value
, MoonError
*error
) { return true; }
95 virtual void RemovedFromCollection (Value
*value
) {}
97 void SetCount (int count
);
99 virtual void CloneCore (Types
*types
, DependencyObject
* fromObj
);
102 virtual ~Collection ();
103 virtual void Dispose ();
107 /* @Namespace=None */
108 class DependencyObjectCollection
: public Collection
{
110 /* @GenerateCBinding,GeneratePInvoke */
111 DependencyObjectCollection ();
113 virtual Type::Kind
GetElementType () { return Type::DEPENDENCY_OBJECT
; }
115 virtual void SetSurface (Surface
*surface
);
117 virtual void OnSubPropertyChanged (DependencyProperty
*prop
, DependencyObject
*obj
, PropertyChangedEventArgs
*args
);
118 virtual void UnregisterAllNamesRootedAt (NameScope
*from_ns
);
119 virtual void RegisterAllNamesRootedAt (NameScope
*to_ns
, MoonError
*error
);
122 virtual bool AddedToCollection (Value
*value
, MoonError
*error
);
123 virtual void RemovedFromCollection (Value
*value
);
125 virtual ~DependencyObjectCollection ();
128 /* @Namespace=System.Windows.Media */
129 class DoubleCollection
: public Collection
{
131 /* @GenerateCBinding,GeneratePInvoke */
134 virtual Type::Kind
GetElementType () { return Type::DOUBLE
; }
136 static DoubleCollection
* FromStr (const char *str
);
139 virtual ~DoubleCollection ();
142 /* @Namespace=System.Windows.Media */
143 class PointCollection
: public Collection
{
145 /* @GenerateCBinding,GeneratePInvoke */
148 virtual Type::Kind
GetElementType () { return Type::POINT
; }
150 static PointCollection
* FromStr (const char *str
);
153 virtual ~PointCollection ();
156 class CollectionIterator
{
158 CollectionIterator (Collection
*c
);
159 ~CollectionIterator ();
161 /* @GenerateCBinding,GeneratePInvoke */
164 /* @GenerateCBinding,GeneratePInvoke */
167 /* @GenerateCBinding,GeneratePInvoke */
168 Value
* GetCurrent (int *error
);
170 /* @GenerateCBinding,GeneratePInvoke */
171 static void Destroy (CollectionIterator
*iterator
);
174 Collection
*collection
;
179 enum VisualTreeWalkerDirection
{
185 class VisualTreeWalker
{
187 VisualTreeWalker (UIElement
*item
, VisualTreeWalkerDirection direction
= Logical
, Types
*types
= NULL
);
189 ~VisualTreeWalker ();
195 DependencyObject
*content
;
196 Collection
*collection
;
199 VisualTreeWalkerDirection direction
;
202 class DeepTreeWalker
{
204 DeepTreeWalker (UIElement
*top
, Types
*types
= NULL
);
214 /* @Namespace=System.Windows */
215 class TriggerCollection
: public DependencyObjectCollection
{
217 virtual ~TriggerCollection ();
220 /* @GenerateCBinding,GeneratePInvoke,ManagedAccess=Internal */
221 TriggerCollection ();
223 virtual Type::Kind
GetElementType () { return Type::EVENTTRIGGER
; }
226 /* @Namespace=System.Windows */
227 class TriggerActionCollection
: public DependencyObjectCollection
{
229 virtual ~TriggerActionCollection ();
232 /* @GenerateCBinding,GeneratePInvoke */
233 TriggerActionCollection ();
235 /* this may seem wrong, but it's what the TriggerActionCollection mandates */
236 virtual Type::Kind
GetElementType () { return Type::BEGINSTORYBOARD
; }
239 /* @Namespace=System.Windows.Documents */
240 class InlineCollection
: public DependencyObjectCollection
{
242 virtual ~InlineCollection ();
245 /* @GenerateCBinding,GeneratePInvoke,ManagedAccess=Internal */
248 virtual Type::Kind
GetElementType () { return Type::INLINE
; }
250 bool Equals (InlineCollection
*inlines
);
253 /* @Namespace=System.Windows.Controls */
254 class UIElementCollection
: public DependencyObjectCollection
{
256 virtual ~UIElementCollection ();
261 /* @GenerateCBinding,GeneratePInvoke,ManagedAccess=Internal */
262 UIElementCollection ();
264 virtual Type::Kind
GetElementType () { return Type::UIELEMENT
; }
266 virtual bool Clear ();
268 void ResortByZIndex ();
271 /* @Namespace=System.Windows.Controls */
272 class ItemCollection
: public Collection
{
274 virtual ~ItemCollection ();
277 /* @GenerateCBinding,GeneratePInvoke,ManagedAccess=Internal */
280 virtual Type::Kind
GetElementType () { return Type::OBJECT
; }
283 /* @Namespace=System.Windows.Controls */
284 class MultiScaleSubImageCollection
: public DependencyObjectCollection
{
288 /* @GenerateCBinding,GeneratePInvoke,ManagedAccess=Internal */
289 MultiScaleSubImageCollection ();
291 virtual Type::Kind
GetElementType () { return Type::MULTISCALESUBIMAGE
; }
293 virtual bool Clear ();
295 void ResortByZIndex ();
298 virtual ~MultiScaleSubImageCollection ();
301 /* @Namespace=System.Windows.Controls */
302 class HitTestCollection
: public UIElementCollection
{
304 virtual bool AddedToCollection (Value
*value
, MoonError
*error
) { return true; }
305 virtual void RemovedFromCollection (Value
*value
) {}
306 virtual ~HitTestCollection () {}
308 /* @GenerateCBinding,GeneratePInvoke,ManagedAccess=Internal */
309 HitTestCollection ();
312 /* @Namespace=System.Windows */
313 class ResourceDictionaryCollection
: public DependencyObjectCollection
{
315 virtual ~ResourceDictionaryCollection ();
318 /* @GenerateCBinding,GeneratePInvoke */
319 ResourceDictionaryCollection ();
321 virtual Type::Kind
GetElementType () { return Type::RESOURCE_DICTIONARY
; }
326 Collection
*collection_new (Type::Kind kind
);
330 #endif /* __MOON_COLLECTION_H__ */