comparison gtk/dw.c @ 671:c60a4f6cfae8

Implemented icon support on the Mac. In the process created a new HICN type. The existing implementation works well on OS/2 but it is kind of bad on the other platforms. I should revisit the Windows and GTK implementations. The typedef currently in use should be backwards compatible for now.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 27 Feb 2011 19:01:40 +0000
parents 9ab89d89e6b4
children 388f2a48aaae
comparison
equal deleted inserted replaced
670:0b920d0dc13e 671:c60a4f6cfae8
1 /* 1 /*
2 * Dynamic Windows: 2 * Dynamic Windows:
3 * A GTK like implementation of the PM GUI 3 * A GTK like implementation of the PM GUI
4 * GTK forwarder module for portabilty. 4 * GTK forwarder module for portabilty.
5 * 5 *
6 * (C) 2000-2004 Brian Smith <dbsoft@technologist.com> 6 * (C) 2000-2011 Brian Smith <brian@dbsoft.org>
7 * (C) 2003-2004 Mark Hessling <m.hessling@qut.edu.au> 7 * (C) 2003-2004 Mark Hessling <m.hessling@qut.edu.au>
8 * (C) 2002 Nickolay V. Shmyrev <shmyrev@yandex.ru> 8 * (C) 2002 Nickolay V. Shmyrev <shmyrev@yandex.ru>
9 */ 9 */
10 #include "config.h" 10 #include "config.h"
11 #include "dw.h" 11 #include "dw.h"
5501 * title: The text title of the entry. 5501 * title: The text title of the entry.
5502 * icon: Handle to coresponding icon. 5502 * icon: Handle to coresponding icon.
5503 * parent: Parent handle or 0 if root. 5503 * parent: Parent handle or 0 if root.
5504 * itemdata: Item specific data. 5504 * itemdata: Item specific data.
5505 */ 5505 */
5506 HTREEITEM dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, unsigned long icon, HTREEITEM parent, void *itemdata) 5506 HTREEITEM dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, HICN icon, HTREEITEM parent, void *itemdata)
5507 { 5507 {
5508 #if GTK_MAJOR_VERSION > 1 5508 #if GTK_MAJOR_VERSION > 1
5509 GtkWidget *tree; 5509 GtkWidget *tree;
5510 GtkTreeIter *iter; 5510 GtkTreeIter *iter;
5511 GtkTreeStore *store; 5511 GtkTreeStore *store;
5654 * title: The text title of the entry. 5654 * title: The text title of the entry.
5655 * icon: Handle to coresponding icon. 5655 * icon: Handle to coresponding icon.
5656 * parent: Parent handle or 0 if root. 5656 * parent: Parent handle or 0 if root.
5657 * itemdata: Item specific data. 5657 * itemdata: Item specific data.
5658 */ 5658 */
5659 HTREEITEM dw_tree_insert(HWND handle, char *title, unsigned long icon, HTREEITEM parent, void *itemdata) 5659 HTREEITEM dw_tree_insert(HWND handle, char *title, HICN icon, HTREEITEM parent, void *itemdata)
5660 { 5660 {
5661 #if GTK_MAJOR_VERSION > 1 5661 #if GTK_MAJOR_VERSION > 1
5662 GtkWidget *tree; 5662 GtkWidget *tree;
5663 GtkTreeIter *iter; 5663 GtkTreeIter *iter;
5664 GtkTreeStore *store; 5664 GtkTreeStore *store;
5799 * handle: Handle to the tree containing the item. 5799 * handle: Handle to the tree containing the item.
5800 * item: Handle of the item to be modified. 5800 * item: Handle of the item to be modified.
5801 * title: The text title of the entry. 5801 * title: The text title of the entry.
5802 * icon: Handle to coresponding icon. 5802 * icon: Handle to coresponding icon.
5803 */ 5803 */
5804 void dw_tree_item_change(HWND handle, HTREEITEM item, char *title, unsigned long icon) 5804 void dw_tree_item_change(HWND handle, HTREEITEM item, char *title, HICN icon)
5805 { 5805 {
5806 #if GTK_MAJOR_VERSION > 1 5806 #if GTK_MAJOR_VERSION > 1
5807 GtkWidget *tree; 5807 GtkWidget *tree;
5808 GtkTreeStore *store; 5808 GtkTreeStore *store;
5809 GdkPixbuf *pixbuf; 5809 GdkPixbuf *pixbuf;
6353 * module: Handle to module (DLL) in OS/2 and Windows. 6353 * module: Handle to module (DLL) in OS/2 and Windows.
6354 * id: A unsigned long id int the resources on OS/2 and 6354 * id: A unsigned long id int the resources on OS/2 and
6355 * Windows, on GTK this is converted to a pointer 6355 * Windows, on GTK this is converted to a pointer
6356 * to an embedded XPM. 6356 * to an embedded XPM.
6357 */ 6357 */
6358 unsigned long dw_icon_load(unsigned long module, unsigned long id) 6358 HICN dw_icon_load(unsigned long module, unsigned long id)
6359 { 6359 {
6360 return id; 6360 return id;
6361 } 6361 }
6362 6362
6363 /* 6363 /*
6365 * Parameters: 6365 * Parameters:
6366 * filename: Name of the file, omit extention to have 6366 * filename: Name of the file, omit extention to have
6367 * DW pick the appropriate file extension. 6367 * DW pick the appropriate file extension.
6368 * (ICO on OS/2 or Windows, XPM on Unix) 6368 * (ICO on OS/2 or Windows, XPM on Unix)
6369 */ 6369 */
6370 unsigned long API dw_icon_load_from_file(char *filename) 6370 HICN API dw_icon_load_from_file(char *filename)
6371 { 6371 {
6372 int found = -1, _locked_by_me = FALSE; 6372 int found = -1, _locked_by_me = FALSE;
6373 #if GTK_MAJOR_VERSION > 1 6373 #if GTK_MAJOR_VERSION > 1
6374 GdkPixbuf *pixbuf; 6374 GdkPixbuf *pixbuf;
6375 #elif defined(USE_IMLIB) 6375 #elif defined(USE_IMLIB)
6467 { 6467 {
6468 _PixmapArray[found].used = 0; 6468 _PixmapArray[found].used = 0;
6469 _PixmapArray[found].pixmap = _PixmapArray[found].mask = NULL; 6469 _PixmapArray[found].pixmap = _PixmapArray[found].mask = NULL;
6470 return 0; 6470 return 0;
6471 } 6471 }
6472 return ret | (1 << 31); 6472 return (HICN)ret | (1 << 31);
6473 } 6473 }
6474 6474
6475 /* 6475 /*
6476 * Obtains an icon from data. 6476 * Obtains an icon from data.
6477 * Parameters: 6477 * Parameters:
6478 * data: Source of data for image. 6478 * data: Source of data for image.
6479 * len: length of data 6479 * len: length of data
6480 */ 6480 */
6481 unsigned long API dw_icon_load_from_data(char *data, int len) 6481 HICN API dw_icon_load_from_data(char *data, int len)
6482 { 6482 {
6483 int found = -1, _locked_by_me = FALSE; 6483 int found = -1, _locked_by_me = FALSE;
6484 char *file; 6484 char *file;
6485 FILE *fp; 6485 FILE *fp;
6486 #if GTK_MAJOR_VERSION > 1 6486 #if GTK_MAJOR_VERSION > 1
6571 { 6571 {
6572 _PixmapArray[found].used = 0; 6572 _PixmapArray[found].used = 0;
6573 _PixmapArray[found].pixmap = _PixmapArray[found].mask = NULL; 6573 _PixmapArray[found].pixmap = _PixmapArray[found].mask = NULL;
6574 return 0; 6574 return 0;
6575 } 6575 }
6576 return ret | (1 << 31); 6576 return (HICN)ret | (1 << 31);
6577 } 6577 }
6578 6578
6579 /* 6579 /*
6580 * Frees a loaded resource in OS/2 and Windows. 6580 * Frees a loaded resource in OS/2 and Windows.
6581 * Parameters: 6581 * Parameters:
6582 * handle: Handle to icon returned by dw_icon_load(). 6582 * handle: Handle to icon returned by dw_icon_load().
6583 */ 6583 */
6584 void dw_icon_free(unsigned long handle) 6584 void dw_icon_free(HICN handle)
6585 { 6585 {
6586 /* If it is a private icon, find the item 6586 /* If it is a private icon, find the item
6587 * free the associated structures and set 6587 * free the associated structures and set
6588 * the entry to unused. 6588 * the entry to unused.
6589 */ 6589 */
6805 * pointer: Pointer to the allocated memory in dw_container_alloc(). 6805 * pointer: Pointer to the allocated memory in dw_container_alloc().
6806 * column: Zero based column of data being set. 6806 * column: Zero based column of data being set.
6807 * row: Zero based row of data being set. 6807 * row: Zero based row of data being set.
6808 * data: Pointer to the data to be added. 6808 * data: Pointer to the data to be added.
6809 */ 6809 */
6810 void API dw_filesystem_change_file(HWND handle, int row, char *filename, unsigned long icon) 6810 void API dw_filesystem_change_file(HWND handle, int row, char *filename, HICN icon)
6811 { 6811 {
6812 dw_filesystem_set_file(handle, NULL, row, filename, icon); 6812 dw_filesystem_set_file(handle, NULL, row, filename, icon);
6813 } 6813 }
6814 6814
6815 /* 6815 /*
6819 * pointer: Pointer to the allocated memory in dw_container_alloc(). 6819 * pointer: Pointer to the allocated memory in dw_container_alloc().
6820 * column: Zero based column of data being set. 6820 * column: Zero based column of data being set.
6821 * row: Zero based row of data being set. 6821 * row: Zero based row of data being set.
6822 * data: Pointer to the data to be added. 6822 * data: Pointer to the data to be added.
6823 */ 6823 */
6824 void dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, unsigned long icon) 6824 void dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, HICN icon)
6825 { 6825 {
6826 _dw_container_set_item(handle, pointer, 0, row, (void *)&icon, filename); 6826 _dw_container_set_item(handle, pointer, 0, row, (void *)&icon, filename);
6827 } 6827 }
6828 6828
6829 /* 6829 /*
7275 * Parameters: 7275 * Parameters:
7276 * handle: Window handle that will handle taskbar icon messages. 7276 * handle: Window handle that will handle taskbar icon messages.
7277 * icon: Icon handle to display in the taskbar. 7277 * icon: Icon handle to display in the taskbar.
7278 * bubbletext: Text to show when the mouse is above the icon. 7278 * bubbletext: Text to show when the mouse is above the icon.
7279 */ 7279 */
7280 void dw_taskbar_insert(HWND handle, unsigned long icon, char *bubbletext) 7280 void dw_taskbar_insert(HWND handle, HICN icon, char *bubbletext)
7281 { 7281 {
7282 /* TODO */ 7282 /* TODO */
7283 } 7283 }
7284 7284
7285 /* 7285 /*
7286 * Deletes an icon from the taskbar. 7286 * Deletes an icon from the taskbar.
7287 * Parameters: 7287 * Parameters:
7288 * handle: Window handle that was used with dw_taskbar_insert(). 7288 * handle: Window handle that was used with dw_taskbar_insert().
7289 * icon: Icon handle that was used with dw_taskbar_insert(). 7289 * icon: Icon handle that was used with dw_taskbar_insert().
7290 */ 7290 */
7291 void dw_taskbar_delete(HWND handle, unsigned long icon) 7291 void dw_taskbar_delete(HWND handle, HICN icon)
7292 { 7292 {
7293 /* TODO */ 7293 /* TODO */
7294 } 7294 }
7295 7295
7296 /* 7296 /*