2009-12-03 Jeffrey Stedfast <fejj@novell.com>
[moon.git] / src / resources.h
blob10ab1f3fb8ed2dcb76d87b1ae42da03e6a399ac0
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3 * resources.h: Resource dictionaries.
5 * Copyright 2007 Novell, Inc. (http://www.novell.com)
7 * See the LICENSE file included with the distribution for details.
8 *
9 */
11 #ifndef __MOON_RESOURCES_H__
12 #define __MOON_RESOURCES_H__
14 #include <glib.h>
16 #include "collection.h"
17 #include "value.h"
19 class ResourceDictionaryIterator : public CollectionIterator {
20 GHashTableIter iter;
21 gpointer key, value;
23 void Init ();
25 public:
26 ResourceDictionaryIterator (ResourceDictionary *resources);
28 virtual bool Next (MoonError *error);
29 virtual bool Reset ();
31 virtual Value *GetCurrent (MoonError *error);
33 /* @GenerateCBinding,GeneratePInvoke */
34 const char *GetCurrentKey (MoonError *error);
37 /* @Namespace=System.Windows */
38 class ResourceDictionary : public Collection {
39 friend class ResourceDictionaryIterator;
41 public:
42 /* @PropertyType=ResourceDictionaryCollection,AutoCreateValue,ManagedFieldAccess=Internal,ManagedSetterAccess=Internal,GenerateAccessors,ManagedPropertyType=PresentationFrameworkCollection<ResourceDictionary> */
43 const static int MergedDictionariesProperty;
45 /* @GenerateCBinding,GeneratePInvoke */
46 ResourceDictionary ();
48 /* just to provide an implementation. our CanAdd always returns true. */
49 virtual Type::Kind GetElementType () { return Type::INVALID;}
51 virtual CollectionIterator *GetIterator ();
53 bool Add (const char* key, Value *value);
55 /* @GenerateCBinding,GeneratePInvoke */
56 bool AddWithError (const char* key, Value *value, MoonError *error);
58 /* @GenerateCBinding,GeneratePInvoke */
59 bool Clear ();
61 /* @GenerateCBinding,GeneratePInvoke */
62 bool ContainsKey (const char *key);
64 /* @GenerateCBinding,GeneratePInvoke */
65 bool Remove (const char *key);
67 /* @GenerateCBinding,GeneratePInvoke */
68 bool Set (const char *key, Value *value);
70 /* @GenerateCBinding,GeneratePInvoke */
71 Value* Get (const char *key, bool *exists);
72 Value* GetFromMergedDictionaries (const char *key, bool *exists);
74 ResourceDictionaryCollection *GetMergedDictionaries ();
75 void SetMergedDictionaries (ResourceDictionaryCollection* value);
77 virtual void SetIsAttached (bool value);
78 virtual void UnregisterAllNamesRootedAt (NameScope *from_ns);
79 virtual void RegisterAllNamesRootedAt (NameScope *to_ns, MoonError *error);
81 protected:
82 virtual ~ResourceDictionary ();
84 virtual bool CanAdd (Value *value);
86 virtual bool AddedToCollection (Value *value, MoonError *error);
87 virtual void RemovedFromCollection (Value *value);
89 private:
90 GHashTable *hash;
91 bool from_resource_dictionary_api;
94 #endif /* __MOON_RESOURCES_H__ */