2009-12-03 Jeffrey Stedfast <fejj@novell.com>
[moon.git] / src / bitmapimage.h
blob783d1b511db0e361edf3fd409eca3aca8e1d0d21
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3 * bitmapimage.h
5 * Contact:
6 * Moonlight List (moonlight-list@lists.ximian.com)
8 * Copyright 2007-2008 Novell, Inc. (http://www.novell.com)
10 * See the LICENSE file included with the distribution for details.
14 #ifndef __BITMAPIMAGE_H__
15 #define __BITMAPIMAGE_H__
17 #include <gdk/gdkpixbuf.h>
19 #include "utils.h"
20 #include "dependencyobject.h"
21 #include "downloader.h"
22 #include "bitmapsource.h"
24 /* @Namespace=System.Windows.Media.Imaging */
25 class BitmapImage : public BitmapSource {
26 private:
27 Downloader *downloader;
28 GdkPixbufLoader *loader;
29 GError *gerror;
30 char *part_name;
31 Cancellable *get_res_aborter;
32 DownloaderAccessPolicy policy;
34 protected:
35 virtual ~BitmapImage ();
37 public:
38 /* @GenerateCBinding,GeneratePInvoke */
39 BitmapImage ();
40 virtual void Dispose ();
42 /* @PropertyType=Uri,AlwaysChange,GenerateAccessors,DefaultValue=Uri() */
43 const static int UriSourceProperty;
44 /* @PropertyType=double,DefaultValue=0.0,GenerateAccessors */
45 const static int ProgressProperty;
47 void SetUriSource (Uri* value);
48 Uri* GetUriSource ();
50 void SetProgress (double progress);
51 double GetProgress ();
53 void SetDownloadPolicy (DownloaderAccessPolicy dlpolicy)
55 policy = dlpolicy;
58 bool ValidateDownloadPolicy ();
60 void CleanupLoader ();
61 void CreateLoader (unsigned char *buffer);
62 /* @GenerateCBinding,GeneratePInvoke */
63 void PixbufWrite (gpointer buffer, gint32 offset, gint32 n);
64 /* @GenerateCBinding,GeneratePInvoke */
65 void PixmapComplete ();
67 virtual void OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error);
69 /* @DelegateType=EventHandler<DownloadProgressEventArgs> */
70 const static int DownloadProgressEvent;
71 /* @DelegateType=EventHandler<ExceptionRoutedEventArgs> */
72 const static int ImageFailedEvent;
73 /* @DelegateType=EventHandler<RoutedEventArgs> */
74 const static int ImageOpenedEvent;
76 void SetDownloader (Downloader *downloader, Uri *uri, const char *part_name);
77 void CleanupDownloader ();
78 void DownloaderProgressChanged ();
79 void DownloaderComplete ();
80 void DownloaderFailed ();
81 void UriSourceChanged ();
82 void Abort ();
84 static void uri_source_changed_callback (EventObject *user_data);
85 static void downloader_progress_changed (EventObject *sender, EventArgs *calldata, gpointer closure);
86 static void downloader_complete (EventObject *sender, EventArgs *calldata, gpointer closure);
87 static void downloader_failed (EventObject *sender, EventArgs *calldata, gpointer closure);
88 static void pixbuf_write (void *buffer, gint32 offset, gint32 n, gpointer data);
91 #endif /* __BITMAPIMAGE_H__ */