changeset 612:c5e5671dec8f

Modify Calendar widget Amke Mac port actually compile and run Add Clipboard support for GTK and Win Add *from_data() contructors allowing icons, bitmaps to be created from embedded data.
author mhessling@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 23 Mar 2008 04:54:30 +0000
parents bc800fc67343
children f7d318cffc3e
files dw.h gtk/dw.c mac/dw.c os2/dw.c win/dw.c
diffstat 5 files changed, 1026 insertions(+), 307 deletions(-) [+]
line wrap: on
line diff
--- a/dw.h	Thu Jun 14 07:24:56 2007 +0000
+++ b/dw.h	Sun Mar 23 04:54:30 2008 +0000
@@ -249,7 +249,6 @@
 typedef void *HEV;
 typedef void *HSHM;
 typedef void *HMOD;
-typedef void *HPIXMAP;
 typedef void *HTREEITEM;
 typedef MenuRef HMENUI;
 
@@ -260,6 +259,12 @@
 	void *data;
 } WindowData;
 
+typedef struct _hpixmap {
+	unsigned long width, height;
+	/* ?? *pixmap; */
+	HWND handle;
+} *HPIXMAP;
+
 #define DW_DT_LEFT               0
 #define DW_DT_QUERYEXTENT        0
 #define DW_DT_UNDERSCORE         0
@@ -292,7 +297,7 @@
 #define DW_FCF_NOBYTEALIGN       0
 #define DW_FCF_NOMOVEWITHOWNER   0
 #define DW_FCF_SYSMODAL          0
-#define DW_FCF_HIDEBUTTON        kWindowCollapseAttribute
+#define DW_FCF_HIDEBUTTON        kWindowCollapseBoxAttribute
 #define DW_FCF_HIDEMAX           0
 #define DW_FCF_AUTOICON          0
 #define DW_FCF_MAXIMIZE          0
@@ -317,7 +322,11 @@
 
 #define DW_LIT_NONE              -1
 
-#define DW_MLE_CASESENSITIVE     MLFSEARCH_CASESENSITIVE
+#ifdef MLFSEARCH_CASESENSITIVE
+# define DW_MLE_CASESENSITIVE    MLFSEARCH_CASESENSITIVE
+#else
+# define DW_MLE_CASESENSITIVE    0
+#endif
 
 #define DW_POINTER_DEFAULT       0
 #define DW_POINTER_ARROW         0
@@ -336,6 +345,90 @@
 #define DW_MB_INFORMATION        (1 << 12)
 #define DW_MB_QUESTION           (1 << 13)
 
+/* Virtual Key Codes */
+#define VK_LBUTTON               0
+#define VK_RBUTTON               0
+#define VK_CANCEL                0
+#define VK_MBUTTON               0
+#define VK_BACK                  0
+#define VK_TAB                   0
+#define VK_CLEAR                 0
+#define VK_RETURN                0
+#define VK_MENU                  0
+#define VK_PAUSE                 0
+#define VK_CAPITAL               0
+#define VK_ESCAPE                0
+#define VK_SPACE                 0
+#define VK_PRIOR                 0
+#define VK_NEXT                  0
+#define VK_END                   0
+#define VK_HOME                  0
+#define VK_LEFT                  0
+#define VK_UP                    0
+#define VK_RIGHT                 0
+#define VK_DOWN                  0
+#define VK_SELECT                0
+#define VK_PRINT                 0
+#define VK_EXECUTE               0
+#define VK_SNAPSHOT              0
+#define VK_INSERT                0
+#define VK_DELETE                0
+#define VK_HELP                  0
+#define VK_LWIN                  0
+#define VK_RWIN                  0
+#define VK_NUMPAD0               0
+#define VK_NUMPAD1               0
+#define VK_NUMPAD2               0
+#define VK_NUMPAD3               0
+#define VK_NUMPAD4               0
+#define VK_NUMPAD5               0
+#define VK_NUMPAD6               0
+#define VK_NUMPAD7               0
+#define VK_NUMPAD8               0
+#define VK_NUMPAD9               0
+#define VK_MULTIPLY              0
+#define VK_ADD                   0
+#define VK_SEPARATOR             0
+#define VK_SUBTRACT              0
+#define VK_DECIMAL               0
+#define VK_DIVIDE                0
+#define VK_F1                    0
+#define VK_F2                    0
+#define VK_F3                    0
+#define VK_F4                    0
+#define VK_F5                    0
+#define VK_F6                    0
+#define VK_F7                    0
+#define VK_F8                    0
+#define VK_F9                    0
+#define VK_F10                   0
+#define VK_F11                   0
+#define VK_F12                   0
+#define VK_F13                   0
+#define VK_F14                   0
+#define VK_F15                   0
+#define VK_F16                   0
+#define VK_F17                   0
+#define VK_F18                   0
+#define VK_F19                   0
+#define VK_F20                   0
+#define VK_F21                   0
+#define VK_F22                   0
+#define VK_F23                   0
+#define VK_F24                   0
+#define VK_NUMLOCK               0
+#define VK_SCROLL                0
+#define VK_LSHIFT                0
+#define VK_RSHIFT                0
+#define VK_LCONTROL              0
+#define VK_RCONTROL              0
+#define VK_LMENU                 0
+#define VK_RMENU                 0
+
+/* Key Modifiers */
+#define KC_CTRL                  (1)
+#define KC_SHIFT                 (1 << 1)
+#define KC_ALT                   (1 << 2)
 
 #endif
 
@@ -940,6 +1033,7 @@
 HWND API dw_bitmap_new(unsigned long id);
 HWND API dw_bitmapbutton_new(char *text, unsigned long id);
 HWND API dw_bitmapbutton_new_from_file(char *text, unsigned long id, char *filename);
+HWND API dw_bitmapbutton_new_from_data(char *text, unsigned long id, char *str, int len);
 HWND API dw_container_new(unsigned long id, int multi);
 HWND API dw_tree_new(unsigned long id);
 HWND API dw_text_new(char *text, unsigned long id);
@@ -980,6 +1074,7 @@
 void API dw_window_set_style(HWND handle, unsigned long style, unsigned long mask);
 void API dw_window_set_icon(HWND handle, unsigned long id);
 void API dw_window_set_bitmap(HWND handle, unsigned long id, char *filename);
+void API dw_window_set_bitmap_from_data(HWND handle, unsigned long id, char *data, int len);
 char * API dw_window_get_text(HWND handle);
 void API dw_window_set_text(HWND handle, char *text);
 int API dw_window_set_border(HWND handle, int border);
@@ -1024,6 +1119,7 @@
 int API dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator);
 unsigned long API dw_icon_load(unsigned long module, unsigned long id);
 unsigned long API dw_icon_load_from_file(char *filename);
+unsigned long API dw_icon_load_from_data(char *data, int len);
 void API dw_icon_free(unsigned long handle);
 void * API dw_container_alloc(HWND handle, int rowcount);
 void API dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data);
@@ -1102,6 +1198,7 @@
 void API dw_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc);
 HPIXMAP API dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth);
 HPIXMAP API dw_pixmap_new_from_file(HWND handle, char *filename);
+HPIXMAP API dw_pixmap_new_from_data(HWND handle, char *data, int len);
 HPIXMAP API dw_pixmap_grab(HWND handle, ULONG id);
 void API dw_pixmap_destroy(HPIXMAP pixmap);
 void API dw_beep(int freq, int dur);
@@ -1138,8 +1235,10 @@
 int API dw_html_raw(HWND hwnd, char *string);
 int API dw_html_url(HWND hwnd, char *url);
 HWND API dw_html_new(unsigned long id);
+char API *dw_clipboard_get_text();
+void API dw_clipboard_set_text( char *str, int len );
 HWND API dw_calendar_new(unsigned long id);
-void API dw_calendar_set_date( HWND window, int year, int month, int day );
-void API dw_calendar_get_date( HWND window, int *year, int *month, int *day );
+void API dw_calendar_set_date( HWND window, unsigned int year, unsigned int month, unsigned int day );
+void API dw_calendar_get_date( HWND window, unsigned int *year, unsigned int *month, unsigned int *day );
 
 #endif
--- a/gtk/dw.c	Thu Jun 14 07:24:56 2007 +0000
+++ b/gtk/dw.c	Sun Mar 23 04:54:30 2008 +0000
@@ -68,6 +68,16 @@
 	{ 0, 0xffff, 0xffff, 0xffff },	/* 15 bright white */
 };
 
+#define NUM_EXTS 5
+char *image_exts[NUM_EXTS] =
+{
+   ".xpm",
+   ".png",
+   ".bmp",
+   ".jpg",
+   ".ico",
+};
+
 #define DW_THREAD_LIMIT 50
 
 #ifndef max
@@ -82,6 +92,8 @@
 GdkColor _foreground[DW_THREAD_LIMIT];
 GdkColor _background[DW_THREAD_LIMIT];
 int _transparent[DW_THREAD_LIMIT];
+GtkClipboard *_clipboard_object[DW_THREAD_LIMIT];
+gchar *_clipboard_contents[DW_THREAD_LIMIT];
 
 GtkWidget *last_window = NULL, *popup = NULL;
 
@@ -1858,6 +1870,8 @@
 			_background[z].pixel = 1;
 			_background[z].red = _background[z].green = _background[z].blue = 0;
 			_transparent[z] = 1;
+			_clipboard_contents[z] = NULL;
+			_clipboard_object[z] = NULL;
 			return;
 		}
 	}
@@ -1871,7 +1885,15 @@
 	for(z=0;z<DW_THREAD_LIMIT;z++)
 	{
 		if(_dw_thread_list[z] == (DWTID)tid)
+		{
 			_dw_thread_list[z] = (DWTID)-1;
+			if ( _clipboard_contents[z] != NULL )
+			{
+				g_free( _clipboard_contents[z] );
+				_clipboard_contents[z] = NULL;;
+			}
+			_clipboard_object[z] = NULL;;
+		}
 	}
 }
 
@@ -3696,6 +3718,7 @@
 /*
  * Create a new bitmap button window (widget) to be packed from a file.
  * Parameters:
+ *       label_text: Text to display on button. TBD when Windows works
  *       text: Bubble help text to be displayed.
  *       id: An ID to be used with dw_window_from_id() or 0L.
  *       filename: Name of the file, omit extention to have
@@ -3704,30 +3727,90 @@
  */
 HWND dw_bitmapbutton_new_from_file(char *text, unsigned long id, char *filename)
 {
-	GtkWidget *tmp;
-	GtkWidget *bitmap;
-    GtkTooltips *tooltips;
-	int _locked_by_me = FALSE;
-
-	DW_MUTEX_LOCK;
-	tmp = gtk_button_new();
-	bitmap = dw_bitmap_new(id);
-
-	if(bitmap)
-	{
-		dw_window_set_bitmap(bitmap, 0, filename);
-		gtk_container_add (GTK_CONTAINER(tmp), bitmap);
-	}
-	gtk_widget_show(tmp);
-	if(text)
-	{
-		tooltips = gtk_tooltips_new();
-		gtk_tooltips_set_tip(tooltips, tmp, text, NULL);
-		gtk_object_set_data(GTK_OBJECT(tmp), "tooltip", (gpointer)tooltips);
-	}
-	gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
-	DW_MUTEX_UNLOCK;
-	return tmp;
+   GtkWidget *bitmap;
+   GtkWidget *box;
+   GtkWidget *label;
+   GtkWidget *button;
+   GtkTooltips *tooltips;
+   char *label_text=NULL;
+   int _locked_by_me = FALSE;
+
+   DW_MUTEX_LOCK;
+
+    /* Create box for image and label */
+    box = gtk_hbox_new (FALSE, 0);
+    gtk_container_set_border_width (GTK_CONTAINER (box), 2);
+
+   /* Now on to the image stuff */
+   bitmap = dw_bitmap_new(id);
+   if ( bitmap )
+   {
+      dw_window_set_bitmap( bitmap, 0, filename );
+      /* Pack the image into the box */
+      gtk_box_pack_start( GTK_BOX(box), bitmap, TRUE, FALSE, 3 );
+      gtk_widget_show( bitmap );
+   }
+   if ( label_text )
+   {
+      /* Create a label for the button */
+      label = gtk_label_new( label_text );
+      /* Pack the label into the box */
+      gtk_box_pack_start( GTK_BOX(box), label, TRUE, FALSE, 3 );
+      gtk_widget_show( label );
+   }
+   /* Create a new button */
+   button = gtk_button_new();
+
+   /* Pack and show all our widgets */
+   gtk_widget_show( box );
+   gtk_container_add( GTK_CONTAINER(button), box );
+   gtk_widget_show( button );
+   if ( text )
+   {
+      tooltips = gtk_tooltips_new();
+      gtk_tooltips_set_tip( tooltips, button, text, NULL );
+      gtk_object_set_data( GTK_OBJECT(button), "tooltip", (gpointer)tooltips );
+   }
+   gtk_object_set_data( GTK_OBJECT(button), "_dw_id", (gpointer)id );
+   DW_MUTEX_UNLOCK;
+   return button;
+}
+
+/*
+ * Create a new bitmap button window (widget) to be packed from data.
+ * Parameters:
+ *       text: Bubble help text to be displayed.
+ *       id: An ID to be used with dw_window_from_id() or 0L.
+ *       data: Raw data of image.
+ *                 (BMP on OS/2 or Windows, XPM on Unix)
+ *       len:  Length of raw data
+ */
+HWND dw_bitmapbutton_new_from_data(char *text, unsigned long id, char *data, int len)
+{
+   GtkWidget *tmp;
+   GtkWidget *bitmap;
+   GtkTooltips *tooltips;
+   int _locked_by_me = FALSE;
+
+   DW_MUTEX_LOCK;
+   tmp = gtk_button_new();
+   bitmap = dw_bitmap_new(id);
+
+   if ( bitmap )
+   {
+      dw_window_set_bitmap_from_data(bitmap, 0, data, len);
+      gtk_container_add (GTK_CONTAINER(tmp), bitmap);
+   }
+   gtk_widget_show(tmp);
+   if(text)
+   {
+      tooltips = gtk_tooltips_new();
+      gtk_tooltips_set_tip(tooltips, tmp, text, NULL);
+      gtk_object_set_data(GTK_OBJECT(tmp), "tooltip", (gpointer)tooltips);
+   }
+   gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
+   DW_MUTEX_UNLOCK;
+   return tmp;
 }
 
 /*
@@ -3933,75 +4016,167 @@
  */
 void dw_window_set_bitmap(HWND handle, unsigned long id, char *filename)
 {
-	GdkBitmap *bitmap = NULL;
-	GdkPixmap *tmp;
-	int _locked_by_me = FALSE;
-
-	if(!id && !filename)
-		return;
-
-	DW_MUTEX_LOCK;
-	if(id)
-		tmp = _find_pixmap(&bitmap, id, handle, NULL, NULL);
-	else
-	{
-		char *file = alloca(strlen(filename) + 5);
-#if GTK_MAJOR_VERSION > 1
-		GdkPixbuf *pixbuf;
+   GdkBitmap *bitmap = NULL;
+   GdkPixmap *tmp;
+   int found_ext = 0;
+   int i;
+   int _locked_by_me = FALSE;
+
+   if(!id && !filename)
+      return;
+
+   DW_MUTEX_LOCK;
+   if(id)
+      tmp = _find_pixmap(&bitmap, id, handle, NULL, NULL);
+   else
+   {
+      char *file = alloca(strlen(filename) + 5);
+#if GTK_MAJOR_VERSION > 1
+      GdkPixbuf *pixbuf;
+#elif defined(USE_IMLIB)
+      GdkImlibImage *image;
+#endif
+
+      if (!file)
+      {
+         DW_MUTEX_UNLOCK;
+         return;
+      }
+
+      strcpy(file, filename);
+
+      /* check if we can read from this file (it exists and read permission) */
+      if ( access(file, 04 ) != 0 )
+      {
+         /* Try with .xpm extention */
+         for ( i = 0; i < NUM_EXTS; i++ )
+         {
+            strcpy( file, filename );
+            strcat( file, image_exts[i] );
+            if ( access( file, 04 ) == 0 )
+            {
+               found_ext = 1;
+               break;
+            }
+         }
+         if ( found_ext == 0 )
+         {
+            DW_MUTEX_UNLOCK;
+            return;
+         }
+      }
+#if GTK_MAJOR_VERSION > 1
+      pixbuf = gdk_pixbuf_new_from_file(file, NULL );
+      gdk_pixbuf_render_pixmap_and_mask(pixbuf, &tmp, &bitmap, 1);
+      g_object_unref(pixbuf);
 #elif defined(USE_IMLIB)
-		GdkImlibImage *image;
-#endif
-
-		if (!file)
-		{
-			DW_MUTEX_UNLOCK;
-			return;
-		}
-
-		strcpy(file, filename);
-
-		/* check if we can read from this file (it exists and read permission) */
-		if(access(file, 04) != 0)
-		{
-			/* Try with .xpm extention */
-			strcat(file, ".xpm");
-			if(access(file, 04) != 0)
-			{
-				DW_MUTEX_UNLOCK;
-				return;
-			}
-		}
-#if GTK_MAJOR_VERSION > 1
-		pixbuf = gdk_pixbuf_new_from_file(file, NULL);
-
-		gdk_pixbuf_render_pixmap_and_mask(pixbuf, &tmp, &bitmap, 1);
-		g_object_unref(pixbuf);
+      image = gdk_imlib_load_image(file);
+      gdk_imlib_render(image, image->rgb_width, image->rgb_height);
+      tmp = gdk_imlib_copy_image(image);
+      bitmap = gdk_imlib_copy_mask(image);
+      gdk_imlib_destroy_image(image);
+#else
+      tmp = gdk_pixmap_create_from_xpm(handle->window, &bitmap, &_colors[DW_CLR_PALEGRAY], file);
+#endif
+   }
+
+   if(tmp)
+   {
+#if GTK_MAJOR_VERSION > 1
+      gtk_image_set_from_pixmap(GTK_IMAGE(handle), tmp, bitmap);
+#else
+      gtk_pixmap_set(GTK_PIXMAP(handle), tmp, bitmap);
+#endif
+   }
+   DW_MUTEX_UNLOCK;
+}
+
+/*
+ * Sets the bitmap used for a given static window.
+ * Parameters:
+ *       handle: Handle to the window.
+ *       id: An ID to be used to specify the icon,
+ *           (pass 0 if you use the filename param)
+ *       data: the image data
+ *                 Bitmap on Windows and a pixmap on Unix, pass
+ *                 NULL if you use the id param)
+ *       len: length of data
+ */
+void dw_window_set_bitmap_from_data(HWND handle, unsigned long id, char *data, int len)
+{
+   GdkBitmap *bitmap = NULL;
+   GdkPixmap *tmp;
+   int _locked_by_me = FALSE;
+   char *file;
+   FILE *fp;
+
+   if (!id && !data)
+      return;
+
+   DW_MUTEX_LOCK;
+   if (id)
+      tmp = _find_pixmap(&bitmap, id, handle, NULL, NULL);
+   else
+   {
+#if GTK_MAJOR_VERSION > 1
+      GdkPixbuf *pixbuf;
 #elif defined(USE_IMLIB)
-		image = gdk_imlib_load_image(file);
-
-		gdk_imlib_render(image, image->rgb_width, image->rgb_height);
-		tmp = gdk_imlib_copy_image(image);
-		bitmap = gdk_imlib_copy_mask(image);
-		gdk_imlib_destroy_image(image);
+      GdkImlibImage *image;
+#endif
+      if (!data)
+      {
+         DW_MUTEX_UNLOCK;
+         return;
+      }
+      /*
+       * A real hack; create a temporary file and write the contents
+       * of the data to the file
+       */
+      file = tmpnam( NULL );
+      fp = fopen( file, "wb" );
+      if ( fp )
+      {
+         fwrite( data, len, 1, fp );
+         fclose( fp );
+      }
+      else
+      {
+         DW_MUTEX_UNLOCK;
+         return;
+      }
+#if GTK_MAJOR_VERSION > 1
+      pixbuf = gdk_pixbuf_new_from_file(file, NULL );
+      gdk_pixbuf_render_pixmap_and_mask(pixbuf, &tmp, &bitmap, 1);
+      g_object_unref(pixbuf);
+#elif defined(USE_IMLIB)
+      image = gdk_imlib_load_image(file);
+      gdk_imlib_render(image, image->rgb_width, image->rgb_height);
+      tmp = gdk_imlib_copy_image(image);
+      bitmap = gdk_imlib_copy_mask(image);
+      gdk_imlib_destroy_image(image);
 #else
-		tmp = gdk_pixmap_create_from_xpm(handle->window, &bitmap, &_colors[DW_CLR_PALEGRAY], file);
-#endif
-	}
-
-	if(tmp)
-#if GTK_MAJOR_VERSION > 1
-		gtk_image_set_from_pixmap(GTK_IMAGE(handle), tmp, bitmap);
+      tmp = gdk_pixmap_create_from_xpm_d(handle->window, &bitmap, &_colors[DW_CLR_PALEGRAY], mydata);
+#endif
+      /* remove our temporary file */
+      unlink (file );
+   }
+
+   if(tmp)
+   {
+#if GTK_MAJOR_VERSION > 1
+      gtk_image_set_from_pixmap(GTK_IMAGE(handle), tmp, bitmap);
 #else
-		gtk_pixmap_set(GTK_PIXMAP(handle), tmp, bitmap);
-#endif
-	DW_MUTEX_UNLOCK;
+      gtk_pixmap_set(GTK_PIXMAP(handle), tmp, bitmap);
+#endif
+   }
+   DW_MUTEX_UNLOCK;
 }
 
 /*
  * Sets the text used for a given window.
  * Parameters:
  *       handle: Handle to the window.
- *       text: The text associsated with a given window.                       f
+ *       text: The text associated with a given window.
  */
 void dw_window_set_text(HWND handle, char *text)
 {
@@ -5847,96 +6022,198 @@
  */
 unsigned long API dw_icon_load_from_file(char *filename)
 {
-	int found = -1, _locked_by_me = FALSE;
-#if GTK_MAJOR_VERSION > 1
-	GdkPixbuf *pixbuf;
+   int found = -1, _locked_by_me = FALSE;
+#if GTK_MAJOR_VERSION > 1
+   GdkPixbuf *pixbuf;
+#elif defined(USE_IMLIB)
+   GdkImlibImage *image;
+#endif
+   char *file = alloca(strlen(filename) + 5);
+   unsigned long z, ret = 0;
+
+   if (!file)
+      return 0;
+
+   strcpy(file, filename);
+
+   /* check if we can read from this file (it exists and read permission) */
+   if (access(file, 04) != 0)
+   {
+      /* Try with .xpm extention */
+      strcat(file, ".xpm");
+      if(access(file, 04) != 0)
+         return 0;
+   }
+
+   DW_MUTEX_LOCK;
+   /* Find a free entry in the array */
+   for (z=0;z<_PixmapCount;z++)
+   {
+      if (!_PixmapArray[z].used)
+      {
+         ret = found = z;
+         break;
+      }
+   }
+
+   /* If there are no free entries, expand the
+    * array.
+    */
+   if (found == -1)
+   {
+      DWPrivatePixmap *old = _PixmapArray;
+
+      ret = found = _PixmapCount;
+      _PixmapCount++;
+
+      _PixmapArray = malloc(sizeof(DWPrivatePixmap) * _PixmapCount);
+
+      if (found)
+         memcpy(_PixmapArray, old, sizeof(DWPrivatePixmap) * found);
+      if (old)
+         free(old);
+      _PixmapArray[found].used = 1;
+      _PixmapArray[found].pixmap = _PixmapArray[found].mask = NULL;
+   }
+
+#if GTK_MAJOR_VERSION > 1
+   pixbuf = gdk_pixbuf_new_from_file(file, NULL);
+   if (pixbuf)
+   {
+      _PixmapArray[found].pixbuf = pixbuf;
+      _PixmapArray[found].width = gdk_pixbuf_get_width(pixbuf);
+      _PixmapArray[found].height = gdk_pixbuf_get_height(pixbuf);
+
+      gdk_pixbuf_render_pixmap_and_mask(pixbuf, &_PixmapArray[found].pixmap, &_PixmapArray[found].mask, 1);
+   }
 #elif defined(USE_IMLIB)
-	GdkImlibImage *image;
-#endif
-	char *file = alloca(strlen(filename) + 5);
-	unsigned long z, ret = 0;
-
-	if (!file)
-		return 0;
-
-	strcpy(file, filename);
-
-	/* check if we can read from this file (it exists and read permission) */
-	if(access(file, 04) != 0)
-	{
-		/* Try with .xpm extention */
-		strcat(file, ".xpm");
-		if(access(file, 04) != 0)
-			return 0;
-	}
-
-	DW_MUTEX_LOCK;
-	/* Find a free entry in the array */
-	for(z=0;z<_PixmapCount;z++)
-	{
-		if(!_PixmapArray[z].used)
-		{
-			ret = found = z;
-			break;
-		}
-	}
-
-	/* If there are no free entries, expand the
-	 * array.
-	 */
-	if(found == -1)
-	{
-		DWPrivatePixmap *old = _PixmapArray;
-
-		ret = found = _PixmapCount;
-		_PixmapCount++;
-
-		_PixmapArray = malloc(sizeof(DWPrivatePixmap) * _PixmapCount);
-
-		if(found)
-			memcpy(_PixmapArray, old, sizeof(DWPrivatePixmap) * found);
-		if(old)
-			free(old);
-		_PixmapArray[found].used = 1;
-		_PixmapArray[found].pixmap = _PixmapArray[found].mask = NULL;
-	}
-
-#if GTK_MAJOR_VERSION > 1
-	pixbuf = gdk_pixbuf_new_from_file(file, NULL);
-
-	if(pixbuf)
-	{
-		_PixmapArray[found].pixbuf = pixbuf;
-		_PixmapArray[found].width = gdk_pixbuf_get_width(pixbuf);
-		_PixmapArray[found].height = gdk_pixbuf_get_height(pixbuf);
-
-		gdk_pixbuf_render_pixmap_and_mask(pixbuf, &_PixmapArray[found].pixmap, &_PixmapArray[found].mask, 1);
-	}
+   image = gdk_imlib_load_image(file);
+   if (image)
+   {
+      _PixmapArray[found].width = image->rgb_width;
+      _PixmapArray[found].height = image->rgb_height;
+
+      gdk_imlib_render(image, image->rgb_width, image->rgb_height);
+      _PixmapArray[found].pixmap = gdk_imlib_copy_image(image);
+      _PixmapArray[found].mask = gdk_imlib_copy_mask(image);
+      gdk_imlib_destroy_image(image);
+   }
+#else
+   if (last_window)
+      _PixmapArray[found].pixmap = gdk_pixmap_create_from_xpm(last_window->window, &_PixmapArray[found].mask, &_colors[DW_CLR_PALEGRAY], file);
+#endif
+   DW_MUTEX_UNLOCK;
+   if (!_PixmapArray[found].pixmap || !_PixmapArray[found].mask)
+   {
+      _PixmapArray[found].used = 0;
+      _PixmapArray[found].pixmap = _PixmapArray[found].mask = NULL;
+      return 0;
+   }
+   return ret | (1 << 31);
+}
+
+/*
+ * Obtains an icon from data.
+ * Parameters:
+ *       data: Source of data for image.
+ *       len:  length of data
+ */
+unsigned long API dw_icon_load_from_data(char *data, int len)
+{
+   int found = -1, _locked_by_me = FALSE;
+   char *file;
+   FILE *fp;
+#if GTK_MAJOR_VERSION > 1
+   GdkPixbuf *pixbuf;
 #elif defined(USE_IMLIB)
-	image = gdk_imlib_load_image(file);
-
-	if(image)
-	{
-		_PixmapArray[found].width = image->rgb_width;
-		_PixmapArray[found].height = image->rgb_height;
-
-		gdk_imlib_render(image, image->rgb_width, image->rgb_height);
-		_PixmapArray[found].pixmap = gdk_imlib_copy_image(image);
-		_PixmapArray[found].mask = gdk_imlib_copy_mask(image);
-		gdk_imlib_destroy_image(image);
-	}
+   GdkImlibImage *image;
+#endif
+   unsigned long z, ret = 0;
+
+   DW_MUTEX_LOCK;
+   /*
+    * A real hack; create a temporary file and write the contents
+    * of the data to the file
+    */
+   file = tmpnam( NULL );
+   fp = fopen( file, "wb" );
+   if ( fp )
+   {
+      fwrite( data, len, 1, fp );
+      fclose( fp );
+   }
+   else
+   {
+      DW_MUTEX_UNLOCK;
+      return 0;
+   }
+   /* Find a free entry in the array */
+   for (z=0;z<_PixmapCount;z++)
+   {
+      if(!_PixmapArray[z].used)
+      {
+         ret = found = z;
+         break;
+      }
+   }
+
+   /* If there are no free entries, expand the
+    * array.
+    */
+   if (found == -1)
+   {
+      DWPrivatePixmap *old = _PixmapArray;
+
+      ret = found = _PixmapCount;
+      _PixmapCount++;
+
+      _PixmapArray = malloc(sizeof(DWPrivatePixmap) * _PixmapCount);
+
+      if (found)
+         memcpy(_PixmapArray, old, sizeof(DWPrivatePixmap) * found);
+      if (old)
+         free(old);
+      _PixmapArray[found].used = 1;
+      _PixmapArray[found].pixmap = _PixmapArray[found].mask = NULL;
+   }
+
+#if GTK_MAJOR_VERSION > 1
+   pixbuf = gdk_pixbuf_new_from_file(file, NULL);
+   if (pixbuf)
+   {
+      _PixmapArray[found].pixbuf = pixbuf;
+      _PixmapArray[found].width = gdk_pixbuf_get_width(pixbuf);
+      _PixmapArray[found].height = gdk_pixbuf_get_height(pixbuf);
+
+      gdk_pixbuf_render_pixmap_and_mask(pixbuf, &_PixmapArray[found].pixmap, &_PixmapArray[found].mask, 1);
+   }
+#elif defined(USE_IMLIB)
+   image = gdk_imlib_load_image(file);
+
+   if (image)
+   {
+      _PixmapArray[found].width = image->rgb_width;
+      _PixmapArray[found].height = image->rgb_height;
+
+      gdk_imlib_render(image, image->rgb_width, image->rgb_height);
+      _PixmapArray[found].pixmap = gdk_imlib_copy_image(image);
+      _PixmapArray[found].mask = gdk_imlib_copy_mask(image);
+      gdk_imlib_destroy_image(image);
+   }
 #else
-	if (last_window)
-		_PixmapArray[found].pixmap = gdk_pixmap_create_from_xpm(last_window->window, &_PixmapArray[found].mask, &_colors[DW_CLR_PALEGRAY], file);
-#endif
-	DW_MUTEX_UNLOCK;
-	if(!_PixmapArray[found].pixmap || !_PixmapArray[found].mask)
-	{
-		_PixmapArray[found].used = 0;
-		_PixmapArray[found].pixmap = _PixmapArray[found].mask = NULL;
-		return 0;
-	}
-	return ret | (1 << 31);
+   if (last_window)
+      _PixmapArray[found].pixmap = gdk_pixmap_create_from_xpm_d(last_window->window, &_PixmapArray[found].mask, &_colors[DW_CLR_PALEGRAY], data);
+#endif
+   /* remove our temporary file */
+   unlink (file );
+   DW_MUTEX_UNLOCK;
+   if (!_PixmapArray[found].pixmap || !_PixmapArray[found].mask)
+   {
+      _PixmapArray[found].used = 0;
+      _PixmapArray[found].pixmap = _PixmapArray[found].mask = NULL;
+      return 0;
+   }
+   return ret | (1 << 31);
 }
 
 /*
@@ -7153,59 +7430,127 @@
  */
 HPIXMAP dw_pixmap_new_from_file(HWND handle, char *filename)
 {
-	int _locked_by_me = FALSE;
-	HPIXMAP pixmap;
+   int _locked_by_me = FALSE;
+   HPIXMAP pixmap;
 #ifndef USE_IMLIB
-	GdkBitmap *bitmap = NULL;
-#endif
-#if GTK_MAJOR_VERSION > 1
-	GdkPixbuf *pixbuf;
+   GdkBitmap *bitmap = NULL;
+#endif
+#if GTK_MAJOR_VERSION > 1
+   GdkPixbuf *pixbuf;
+#elif defined(USE_IMLIB)
+   GdkImlibImage *image;
+#endif
+   char *file = alloca(strlen(filename) + 5);
+
+   if (!file || !(pixmap = calloc(1,sizeof(struct _hpixmap))))
+      return NULL;
+
+   strcpy(file, filename);
+
+   /* check if we can read from this file (it exists and read permission) */
+   if(access(file, 04) != 0)
+   {
+      /* Try with .xpm extention */
+      strcat(file, ".xpm");
+      if(access(file, 04) != 0)
+      {
+         free(pixmap);
+         return NULL;
+      }
+   }
+
+   DW_MUTEX_LOCK;
+#if GTK_MAJOR_VERSION > 1
+   pixbuf = gdk_pixbuf_new_from_file(file, NULL);
+   pixmap->width = gdk_pixbuf_get_width(pixbuf);
+   pixmap->height = gdk_pixbuf_get_height(pixbuf);
+   gdk_pixbuf_render_pixmap_and_mask(pixbuf, &pixmap->pixmap, &bitmap, 1);
+   g_object_unref(pixbuf);
 #elif defined(USE_IMLIB)
-	GdkImlibImage *image;
-#endif
-	char *file = alloca(strlen(filename) + 5);
-
-	if (!file || !(pixmap = calloc(1,sizeof(struct _hpixmap))))
-		return NULL;
-
-	strcpy(file, filename);
-
-	/* check if we can read from this file (it exists and read permission) */
-	if(access(file, 04) != 0)
-	{
-		/* Try with .xpm extention */
-		strcat(file, ".xpm");
-		if(access(file, 04) != 0)
-		{
-			free(pixmap);
-			return NULL;
-		}
-	}
-
-	DW_MUTEX_LOCK;
-#if GTK_MAJOR_VERSION > 1
-	pixbuf = gdk_pixbuf_new_from_file(file, NULL);
-
-	pixmap->width = gdk_pixbuf_get_width(pixbuf);
-	pixmap->height = gdk_pixbuf_get_height(pixbuf);
-
-	gdk_pixbuf_render_pixmap_and_mask(pixbuf, &pixmap->pixmap, &bitmap, 1);
-	g_object_unref(pixbuf);
+   image = gdk_imlib_load_image(file);
+
+   pixmap->width = image->rgb_width;
+   pixmap->height = image->rgb_height;
+
+   gdk_imlib_render(image, pixmap->width, pixmap->height);
+   pixmap->pixmap = gdk_imlib_copy_image(image);
+   gdk_imlib_destroy_image(image);
+#else
+   pixmap->pixmap = gdk_pixmap_create_from_xpm(handle->window, &bitmap, &_colors[DW_CLR_PALEGRAY], file);
+#endif
+   pixmap->handle = handle;
+   DW_MUTEX_UNLOCK;
+   return pixmap;
+}
+
+/*
+ * Creates a pixmap from data
+ * Parameters:
+ *       handle: Window handle the pixmap is associated with.
+ *       data: Source of image data
+ *                 DW pick the appropriate file extension.
+ *                 (BMP on OS/2 or Windows, XPM on Unix)
+ * Returns:
+ *       A handle to a pixmap or NULL on failure.
+ */
+HPIXMAP dw_pixmap_new_from_data(HWND handle, char *data, int len)
+{
+   int _locked_by_me = FALSE;
+   char *file;
+   FILE *fp;
+   HPIXMAP pixmap;
+#ifndef USE_IMLIB
+   GdkBitmap *bitmap = NULL;
+#endif
+#if GTK_MAJOR_VERSION > 1
+   GdkPixbuf *pixbuf;
 #elif defined(USE_IMLIB)
-	image = gdk_imlib_load_image(file);
-
-	pixmap->width = image->rgb_width;
-	pixmap->height = image->rgb_height;
-
-	gdk_imlib_render(image, pixmap->width, pixmap->height);
-	pixmap->pixmap = gdk_imlib_copy_image(image);
-	gdk_imlib_destroy_image(image);
+   GdkImlibImage *image;
+#endif
+
+   if (!data || !(pixmap = calloc(1,sizeof(struct _hpixmap))))
+      return NULL;
+
+   DW_MUTEX_LOCK;
+   /*
+    * A real hack; create a temporary file and write the contents
+    * of the data to the file
+    */
+   file = tmpnam( NULL );
+   fp = fopen( file, "wb" );
+   if ( fp )
+   {
+      fwrite( data, len, 1, fp );
+      fclose( fp );
+   }
+   else
+   {
+      DW_MUTEX_UNLOCK;
+      return 0;
+   }
+#if GTK_MAJOR_VERSION > 1
+   pixbuf = gdk_pixbuf_new_from_file(file, NULL);
+   pixmap->width = gdk_pixbuf_get_width(pixbuf);
+   pixmap->height = gdk_pixbuf_get_height(pixbuf);
+   gdk_pixbuf_render_pixmap_and_mask(pixbuf, &pixmap->pixmap, &bitmap, 1);
+   g_object_unref(pixbuf);
+#elif defined(USE_IMLIB)
+   image = gdk_imlib_load_image(file);
+
+   pixmap->width = image->rgb_width;
+   pixmap->height = image->rgb_height;
+
+   gdk_imlib_render(image, pixmap->width, pixmap->height);
+   pixmap->pixmap = gdk_imlib_copy_image(image);
+   gdk_imlib_destroy_image(image);
 #else
-	pixmap->pixmap = gdk_pixmap_create_from_xpm(handle->window, &bitmap, &_colors[DW_CLR_PALEGRAY], file);
-#endif
-	pixmap->handle = handle;
-	DW_MUTEX_UNLOCK;
-	return pixmap;
+   pixmap->pixmap = gdk_pixmap_create_from_xpm_d(handle->window, &bitmap, &_colors[DW_CLR_PALEGRAY], data);
+#endif
+   /* remove our temporary file */
+   unlink (file );
+   pixmap->handle = handle;
+   DW_MUTEX_UNLOCK;
+   return pixmap;
 }
 
 /*
@@ -8231,27 +8576,33 @@
  */
 void dw_window_set_size(HWND handle, unsigned long width, unsigned long height)
 {
-	int _locked_by_me = FALSE;
-
-	if(!handle)
-		return;
-
-	DW_MUTEX_LOCK;
-	if(GTK_IS_WINDOW(handle))
-	{
-		_size_allocate(GTK_WINDOW(handle));
-		if(handle->window)
-			gdk_window_resize(handle->window, width - _dw_border_width, height - _dw_border_height);
-		gtk_window_set_default_size(GTK_WINDOW(handle), width - _dw_border_width, height - _dw_border_height);
-		if(!gtk_object_get_data(GTK_OBJECT(handle), "_dw_size"))
-		{
-			gtk_object_set_data(GTK_OBJECT(handle), "_dw_width", (gpointer)width - _dw_border_width);
-			gtk_object_set_data(GTK_OBJECT(handle), "_dw_height", (gpointer)height - _dw_border_height);
-		}
-	}
-	else
-		gtk_widget_set_usize(handle, width, height);
-	DW_MUTEX_UNLOCK;
+   int _locked_by_me = FALSE;
+   long default_width = width - _dw_border_width;
+   long default_height = height - _dw_border_height;
+
+   if(!handle)
+      return;
+
+   DW_MUTEX_LOCK;
+   if(GTK_IS_WINDOW(handle))
+   {
+      if ( width == 0 )
+         default_width = -1;
+      if ( height == 0 )
+         default_height = -1;
+      _size_allocate(GTK_WINDOW(handle));
+      if(handle->window)
+         gdk_window_resize(handle->window, default_width , default_height );
+      gtk_window_set_default_size(GTK_WINDOW(handle), default_width , default_height );
+      if(!gtk_object_get_data(GTK_OBJECT(handle), "_dw_size"))
+      {
+         gtk_object_set_data(GTK_OBJECT(handle), "_dw_width", (gpointer)default_width );
+         gtk_object_set_data(GTK_OBJECT(handle), "_dw_height", (gpointer)default_height );
+      }
+   }
+   else
+      gtk_widget_set_usize(handle, width, height);
+   DW_MUTEX_UNLOCK;
 }
 
 /*
@@ -8286,10 +8637,12 @@
 unsigned long dw_color_depth_get(void)
 {
 	int retval;
-	int _locked_by_me = FALSE;
-
-	DW_MUTEX_UNLOCK;
-	retval = gdk_visual_get_best_depth();
+	GdkVisual *vis;
+	int _locked_by_me = FALSE;
+
+	DW_MUTEX_UNLOCK;
+	vis = gdk_visual_get_system();
+	retval = vis->depth;
 	DW_MUTEX_UNLOCK;
 	return retval;
 }
@@ -8386,7 +8739,7 @@
 #if GTK_MAJOR_VERSION > 1
 	if((mdi = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_mdi")) && GTK_IS_MDI(mdi))
 	{
-		gint myx, myy;
+		gint myx=0, myy=0;
 
 		gtk_mdi_get_pos(GTK_MDI(mdi), handle, &myx, &myy);
 		*x = myx;
@@ -9392,9 +9745,11 @@
  */
 HWND dw_calendar_new(unsigned long id)
 {
-	GtkCalendar *tmp;
+	GtkWidget *tmp;
 	int _locked_by_me = FALSE;
 	GtkCalendarDisplayOptions flags;
+	time_t now;
+	struct tm *tmdata;
 
 	DW_MUTEX_LOCK;
 	tmp = gtk_calendar_new();
@@ -9402,9 +9757,11 @@
 	gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
 	/* select today */
 	flags = GTK_CALENDAR_WEEK_START_MONDAY|GTK_CALENDAR_SHOW_HEADING|GTK_CALENDAR_SHOW_DAY_NAMES;
-	gtk_calendar_display_options(tmp,flags);
-	gtk_calendar_select_month(tmp,11,2005);
-	gtk_calendar_select_day(tmp, 12);
+	gtk_calendar_display_options( GTK_CALENDAR(tmp), flags );
+	now = time( NULL );
+	tmdata = localtime( & now );
+	gtk_calendar_select_month( GTK_CALENDAR(tmp), tmdata->tm_mon, 1900+tmdata->tm_year );
+	gtk_calendar_select_day( GTK_CALENDAR(tmp), tmdata->tm_mday );
 
 	DW_MUTEX_UNLOCK;
 	return tmp;
@@ -9416,7 +9773,7 @@
  *       handle: The handle to the calendar returned by dw_calendar_new().
  *       year...
  */
-void dw_calendar_set_date(HWND handle, int year, int month, int day)
+void dw_calendar_set_date(HWND handle, unsigned int year, unsigned int month, unsigned int day)
 {
 	int _locked_by_me = FALSE;
 
@@ -9435,7 +9792,7 @@
  * Parameters:
  *       handle: The handle to the splitbar returned by dw_splitbar_new().
  */
-void dw_calendar_get_date(HWND handle, int *year, int *month, int *day)
+void dw_calendar_get_date(HWND handle, unsigned int *year, unsigned int *month, unsigned int *day)
 {
 	int _locked_by_me = FALSE;
 
@@ -9443,6 +9800,7 @@
 	if(GTK_IS_CALENDAR(handle))
 	{
 		gtk_calendar_get_date(GTK_CALENDAR(handle),year,month,day);
+		*month = *month + 1;
 	}
 	DW_MUTEX_UNLOCK;
 	return;
@@ -10122,6 +10480,50 @@
 }
 
 /*
+ * Gets the contents of the default clipboard as text.
+ * Parameters:
+ *       None.
+ * Returns:
+ *       Pointer to an allocated string of text or NULL if clipboard empty or contents could not
+ *       be converted to text.
+ */
+char *dw_clipboard_get_text()
+{
+   int _locked_by_me = FALSE, index = _find_thread_index(dw_thread_id());
+
+   DW_MUTEX_LOCK;
+   if ( _clipboard_object[index] == NULL )
+   {
+      _clipboard_object[index] = gtk_clipboard_get( GDK_SELECTION_CLIPBOARD );
+   }
+   if ( _clipboard_contents[index] != NULL )
+   {
+      g_free( _clipboard_contents[index] );
+   }
+   _clipboard_contents[index] = gtk_clipboard_wait_for_text( _clipboard_object[index] );
+   DW_MUTEX_UNLOCK;
+   return (char *)_clipboard_contents[index];
+}
+
+/*
+ * Sets the contents of the default clipboard to the supplied text.
+ * Parameters:
+ *       Text.
+ */
+void  dw_clipboard_set_text( char *str, int len )
+{
+   int _locked_by_me = FALSE, index = _find_thread_index(dw_thread_id());
+
+   DW_MUTEX_LOCK;
+   if ( _clipboard_object[index] == NULL )
+   {
+      _clipboard_object[index] = gtk_clipboard_get( GDK_SELECTION_CLIPBOARD );
+   }
+   gtk_clipboard_set_text( _clipboard_object[index], str, len );
+   DW_MUTEX_UNLOCK;
+}
+
+/*
  * Returns a pointer to a static buffer which containes the
  * current user directory.  Or the root directory (C:\ on
  * OS/2 and Windows).
@@ -10285,6 +10687,10 @@
 	gint cid;
 
 	DW_MUTEX_LOCK;
+/*
+ * If the window we are setting the signal on is a scrolled window we need to get
+ * the "real" widget type. thiswindow is the "real" widget type
+ */
 	if(GTK_IS_SCROLLED_WINDOW(thiswindow))
 	{
 		thiswindow = (HWND)gtk_object_get_user_data(GTK_OBJECT(window));
@@ -10304,12 +10710,17 @@
 	else if(GTK_IS_TREE_VIEW(thiswindow)  && strcmp(signame, DW_SIGNAL_ITEM_CONTEXT) == 0)
 	{
 		thisfunc = _findsigfunc("tree-context");
+
 		sigid = _set_signal_handler(thiswindow, window, sigfunc, data, thisfunc);
 		cid = gtk_signal_connect(GTK_OBJECT(thiswindow), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), (gpointer)sigid);
 		_set_signal_handler_id(thiswindow, sigid, cid);
+
+#if 0
 		sigid = _set_signal_handler(window, window, sigfunc, data, thisfunc);
 		cid = gtk_signal_connect(GTK_OBJECT(window), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), (gpointer)sigid);
 		_set_signal_handler_id(window, sigid, cid);
+#endif
+
 		DW_MUTEX_UNLOCK;
 		return;
 	}
--- a/mac/dw.c	Thu Jun 14 07:24:56 2007 +0000
+++ b/mac/dw.c	Sun Mar 23 04:54:30 2008 +0000
@@ -708,7 +708,7 @@
 	va_start(args, format);
 	vsprintf(outbuf, format, args);
 	va_end(args);
-        
+
 	GetStandardAlertDefaultParams(&param, kStdCFStringAlertVersionOne);
 	param.movable = TRUE;
 	param.helpButton = FALSE;
@@ -920,7 +920,7 @@
 {
 	WindowRef hwnd = 0;
 	ControlRef rootcontrol = 0;
-        
+
 	CreateNewWindow (kDocumentWindowClass, flStyle | kWindowStandardHandlerAttribute,
 					 &CreationRect, &hwnd);
 	CreateRootControl(hwnd, &rootcontrol);
@@ -937,7 +937,7 @@
 HWND API dw_box_new(int type, int pad)
 {
         ControlRef hwnd = NewControl(CreationWindow, NULL, "",
-                    true, kControlSupportsEmbedding | kControlHasSpecialBackground, 
+                    true, kControlSupportsEmbedding | kControlHasSpecialBackground,
                     0, 1, kControlUserPaneProc, (SInt32) 0);
         return (HWND)hwnd;
 }
@@ -1290,6 +1290,20 @@
 }
 
 /*
+ * Create a new bitmap button window (widget) to be packed from data.
+ * Parameters:
+ *       text: Bubble help text to be displayed.
+ *       id: An ID to be used with dw_window_from_id() or 0L.
+ *       data: Raw data of image.
+ *                 (BMP on OS/2 or Windows, XPM on Unix)
+ *       len:  Length of raw data
+ */
+HWND dw_bitmapbutton_new_from_data(char *text, unsigned long id, char *data, int len)
+{
+	return 0;
+}
+
+/*
  * Create a new spinbutton window (widget) to be packed.
  * Parameters:
  *       text: The text to be display by the static text widget.
@@ -1409,6 +1423,21 @@
 }
 
 /*
+ * Sets the bitmap used for a given static window.
+ * Parameters:
+ *       handle: Handle to the window.
+ *       id: An ID to be used to specify the icon,
+ *           (pass 0 if you use the filename param)
+ *       data: the image data
+ *                 Bitmap on Windows and a pixmap on Unix, pass
+ *                 NULL if you use the id param)
+ *       len: length of data
+ */
+void dw_window_set_bitmap_from_data(HWND handle, unsigned long id, char *data, int len)
+{
+}
+
+/*
  * Sets the text used for a given window.
  * Parameters:
  *       handle: Handle to the window.
@@ -1441,7 +1470,7 @@
 	else
 	{
 		Str255 str;
-        
+
 		GetControlTitle(handle, str);
 		cftext = CFStringCreateWithPascalString(NULL, str, CFStringGetSystemEncoding());
 	}
@@ -1680,6 +1709,17 @@
 }
 
 /*
+ * Appends the specified text items to the listbox's (or combobox) entry list.
+ * Parameters:
+ *          handle: Handle to the listbox to be appended to.
+ *          text: Text strings to append into listbox.
+ *          count: Number of text strings to append
+ */
+void API dw_listbox_list_append(HWND handle, char **text, int count)
+{
+}
+
+/*
  * Clears the listbox's (or combobox) list of all entries.
  * Parameters:
  *          handle: Handle to the listbox to be cleared.
@@ -2204,6 +2244,17 @@
 }
 
 /*
+ * Obtains an icon from data.
+ * Parameters:
+ *       data: Source of data for image.
+ *       len:  length of data
+ */
+unsigned long API dw_icon_load_from_data(char *data, int len)
+{
+	return 0;
+}
+
+/*
  * Frees a loaded resource in OS/2 and Windows.
  * Parameters:
  *          handle: Handle to icon returned by dw_icon_load().
@@ -2249,6 +2300,33 @@
 }
 
 /*
+ * Changes an existing item in specified row and column to the given data.
+ * Parameters:
+ *          handle: Handle to the container window (widget).
+ *          column: Zero based column of data being set.
+ *          row: Zero based row of data being set.
+ *          data: Pointer to the data to be added.
+ */
+void API dw_filesystem_change_item(HWND handle, int column, int row, void *data)
+{
+	dw_filesystem_set_item(handle, NULL, column, row, data);
+}
+
+/*
+ * Changes an item in specified row and column to the given data.
+ * Parameters:
+ *          handle: Handle to the container window (widget).
+ *          pointer: Pointer to the allocated memory in dw_container_alloc().
+ *          column: Zero based column of data being set.
+ *          row: Zero based row of data being set.
+ *          data: Pointer to the data to be added.
+ */
+void API dw_filesystem_change_file(HWND handle, int row, char *filename, unsigned long icon)
+{
+	dw_filesystem_set_file(handle, NULL, row, filename, icon);
+}
+
+/*
  * Sets an item in specified row and column to the given data.
  * Parameters:
  *          handle: Handle to the container window (widget).
@@ -2584,6 +2662,21 @@
 }
 
 /*
+ * Creates a pixmap from data
+ * Parameters:
+ *       handle: Window handle the pixmap is associated with.
+ *       data: Source of image data
+ *                 DW pick the appropriate file extension.
+ *                 (BMP on OS/2 or Windows, XPM on Unix)
+ * Returns:
+ *       A handle to a pixmap or NULL on failure.
+ */
+HPIXMAP API dw_pixmap_new_from_data(HWND handle, char *data, int len)
+{
+	return 0;
+}
+
+/*
  * Creates a pixmap from internal resource graphic specified by id.
  * Parameters:
  *       handle: Window handle the pixmap is associated with.
@@ -2933,6 +3026,39 @@
 }
 
 /*
+ * Creates a calendar window (widget) with given parameters.
+ * Parameters:
+ *       id: Unique identifier for calendar widget
+ * Returns:
+ *       A handle to a calendar window or NULL on failure.
+ */
+HWND dw_calendar_new(unsigned long id)
+{
+	return 0;
+}
+
+/*
+ * Sets the current date of a calendar
+ * Parameters:
+ *       handle: The handle to the calendar returned by dw_calendar_new().
+ *       year...
+ */
+void dw_calendar_set_date(HWND handle, unsigned int year, unsigned int month, unsigned int day)
+{
+	return;
+}
+
+/*
+ * Gets the position of a splitbar (pecentage).
+ * Parameters:
+ *       handle: The handle to the splitbar returned by dw_splitbar_new().
+ */
+void dw_calendar_get_date(HWND handle, unsigned int *year, unsigned int *month, unsigned int *day)
+{
+	return;
+}
+
+/*
  * Pack windows (widgets) into a box from the start (or top).
  * Parameters:
  *       box: Window handle of the box to be packed into.
@@ -3010,7 +3136,7 @@
  * Returns:
  *       NULL on error. A malloced buffer containing
  *       the file path on success.
- *       
+ *
  */
 char * API dw_file_browse(char *title, char *defpath, char *ext, int flags)
 {
--- a/os2/dw.c	Thu Jun 14 07:24:56 2007 +0000
+++ b/os2/dw.c	Sun Mar 23 04:54:30 2008 +0000
@@ -3,7 +3,7 @@
  *          A GTK like implementation of the PM GUI
  *
  * (C) 2000-2004 Brian Smith <dbsoft@technologist.com>
- * (C) 2003-2004 Mark Hessling <m.hessling@qut.edu.au>
+ * (C) 2003-2008 Mark Hessling <m.hessling@qut.edu.au>
  * (C) 2000 Achim Hasenmueller <achimha@innotek.de>
  * (C) 2000 Peter Nielsen <peter@pmview.com>
  * (C) 1998 Sergey I. Yevtushenko (some code borrowed from cell toolkit)
--- a/win/dw.c	Thu Jun 14 07:24:56 2007 +0000
+++ b/win/dw.c	Sun Mar 23 04:54:30 2008 +0000
@@ -63,6 +63,7 @@
 COLORREF _background[THREAD_LIMIT];
 HPEN _hPen[THREAD_LIMIT];
 HBRUSH _hBrush[THREAD_LIMIT];
+char *_clipboard_contents[THREAD_LIMIT];
 
 BYTE _red[] = { 	0x00, 0xbb, 0x00, 0xaa, 0x00, 0xbb, 0x00, 0xaa, 0x77,
 			  0xff, 0x00, 0xee, 0x00, 0xff, 0x00, 0xff, 0xaa, 0x00 };
@@ -3335,6 +3336,7 @@
 		_background[z] = DW_RGB_TRANSPARENT;
 		_hPen[z] = CreatePen(PS_SOLID, 1, _foreground[z]);
 		_hBrush[z] = CreateSolidBrush(_foreground[z]);
+		_clipboard_contents[z] = NULL;
 	}
 
 	if(!IS_WINNTOR95)
@@ -4666,52 +4668,52 @@
  *       id: An ID to be used with dw_window_from_id() or 0L.
  *       filename: Name of the file, omit extention to have
  *                 DW pick the appropriate file extension.
- *                 (BMP on OS/2 or Windows, XPM on Unix)
+ *                 (BMP or ICO on OS/2 or Windows, XPM on Unix)
  */
 HWND API dw_bitmapbutton_new_from_file(char *text, unsigned long id, char *filename)
 {
-	HWND tmp;
-	BubbleButton *bubble;
-	HBITMAP hbitmap = 0;
-	HANDLE icon = 0;
-	int windowtype = 0, len;
-
-	if(!(bubble = calloc(1, sizeof(BubbleButton))))
-		return 0;
-
-	windowtype = _dw_get_image_handle(filename, &icon, &hbitmap);
-
-	tmp = CreateWindow(BUTTONCLASSNAME,
-					   "",
-					   WS_CHILD | BS_PUSHBUTTON |
-					   windowtype | WS_CLIPCHILDREN |
-					   WS_VISIBLE,
-					   0,0,2000,1000,
-					   DW_HWND_OBJECT,
-					   (HMENU)id,
-					   DWInstance,
-					   NULL);
-
-	bubble->id = id;
-	strncpy(bubble->bubbletext, text, BUBBLE_HELP_MAX - 1);
-	bubble->bubbletext[BUBBLE_HELP_MAX - 1] = '\0';
-	bubble->pOldProc = (WNDPROC)SubclassWindow(tmp, _BtProc);
-
-	SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)bubble);
-
-	if(icon)
-	{
-		SendMessage(tmp, BM_SETIMAGE,
-					(WPARAM) IMAGE_ICON,
-					(LPARAM) icon);
-	}
-	else if(hbitmap)
-	{
-		SendMessage(tmp, BM_SETIMAGE,
-					(WPARAM) IMAGE_BITMAP,
-					(LPARAM) hbitmap);
-	}
-	return tmp;
+   HWND tmp;
+   BubbleButton *bubble;
+   HBITMAP hbitmap = 0;
+   HANDLE icon = 0;
+   int windowtype = 0, len;
+
+   if(!(bubble = calloc(1, sizeof(BubbleButton))))
+      return 0;
+
+   windowtype = _dw_get_image_handle(filename, &icon, &hbitmap);
+
+   tmp = CreateWindow(BUTTONCLASSNAME,
+                  "",
+                  WS_CHILD | BS_PUSHBUTTON |
+                  windowtype | WS_CLIPCHILDREN |
+                  WS_VISIBLE,
+                  0,0,2000,1000,
+                  DW_HWND_OBJECT,
+                  (HMENU)id,
+                  DWInstance,
+                  NULL);
+
+   bubble->id = id;
+   strncpy(bubble->bubbletext, text, BUBBLE_HELP_MAX - 1);
+   bubble->bubbletext[BUBBLE_HELP_MAX - 1] = '\0';
+   bubble->pOldProc = (WNDPROC)SubclassWindow(tmp, _BtProc);
+
+   SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)bubble);
+
+   if(icon)
+   {
+      SendMessage(tmp, BM_SETIMAGE,
+               (WPARAM) IMAGE_ICON,
+               (LPARAM) icon);
+   }
+   else if(hbitmap)
+   {
+      SendMessage(tmp, BM_SETIMAGE,
+               (WPARAM) IMAGE_BITMAP,
+               (LPARAM) hbitmap);
+   }
+   return tmp;
 }
 
 /*
@@ -8348,7 +8350,7 @@
  *       month:  The month to set the date to
  *       day:    The day to set the date to
  */
-void API dw_calendar_set_date(HWND handle, int year, int month, int day)
+void API dw_calendar_set_date(HWND handle, unsigned int year, unsigned int month, unsigned int day)
 {
 	MONTHDAYSTATE mds[3];
 	SYSTEMTIME date;
@@ -8373,7 +8375,7 @@
  *       month:  Pointer to the month to get the date to
  *       day:    Pointer to the day to get the date to
  */
-void API dw_calendar_get_date(HWND handle, int *year, int *month, int *day)
+void API dw_calendar_get_date(HWND handle, unsigned int *year, unsigned int *month, unsigned int *day)
 {
 	SYSTEMTIME date;
 	if ( MonthCal_GetCurSel( handle, &date ) )
@@ -8519,6 +8521,87 @@
 }
 
 /*
+ * Gets the contents of the default clipboard as text.
+ * Parameters:
+ *       None.
+ * Returns:
+ *       Pointer to an allocated string of text or NULL if clipboard empty or contents could not
+ *       be converted to text.
+ */
+char *dw_clipboard_get_text()
+{
+   HANDLE handle;
+   int threadid = dw_thread_id();
+   long len;
+
+   if ( !OpenClipboard( NULL ) )
+      return NULL;
+
+   if ( ( handle = GetClipboardData( CF_TEXT) ) == NULL )
+   {
+      CloseClipboard();
+      return NULL;
+   }
+
+   len = strlen( (char *)handle );
+
+   if ( threadid < 0 || threadid >= THREAD_LIMIT )
+      threadid = 0;
+
+   if ( _clipboard_contents[threadid] != NULL )
+   {
+      GlobalFree( _clipboard_contents[threadid] );
+   }
+   _clipboard_contents[threadid] = (char *)GlobalAlloc(GMEM_FIXED, len + 1);
+   if ( !_clipboard_contents[threadid] )
+   {
+      CloseClipboard();
+      return NULL;
+   }
+
+   strcpy( (char *)_clipboard_contents[threadid], (char *)handle );
+   CloseClipboard();
+
+   return _clipboard_contents[threadid];
+}
+
+/*
+ * Sets the contents of the default clipboard to the supplied text.
+ * Parameters:
+ *       Text.
+ */
+void dw_clipboard_set_text( char *str, int len )
+{
+   HGLOBAL ptr1;
+   LPTSTR ptr2;
+
+   if ( !OpenClipboard( NULL ) )
+      return;
+
+   ptr1 = GlobalAlloc( GMEM_MOVEABLE|GMEM_DDESHARE, (len + 1) * sizeof(TCHAR) );
+
+   if ( !ptr1 )
+      return;
+
+   ptr2 = GlobalLock( ptr1 );
+
+   memcpy( (char *)ptr2, str, len + 1);
+   GlobalUnlock( ptr1 );
+   EmptyClipboard();
+
+   if ( !SetClipboardData( CF_TEXT, ptr1 ) )
+   {
+      GlobalFree( ptr1 );
+      return;
+   }
+
+   CloseClipboard();
+   GlobalFree( ptr1 );
+
+   return;
+}
+
+/*
  * Returns some information about the current operating environment.
  * Parameters:
  *       env: Pointer to a DWEnv struct.