Mercurial > dwindows
comparison os2/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 * | 4 * |
5 * (C) 2000-2004 Brian Smith <dbsoft@technologist.com> | 5 * (C) 2000-2011 Brian Smith <brian@dbsoft.org> |
6 * (C) 2003-2008 Mark Hessling <m.hessling@qut.edu.au> | 6 * (C) 2003-2008 Mark Hessling <m.hessling@qut.edu.au> |
7 * (C) 2000 Achim Hasenmueller <achimha@innotek.de> | 7 * (C) 2000 Achim Hasenmueller <achimha@innotek.de> |
8 * (C) 2000 Peter Nielsen <peter@pmview.com> | 8 * (C) 2000 Peter Nielsen <peter@pmview.com> |
9 * (C) 1998 Sergey I. Yevtushenko (some code borrowed from cell toolkit) | 9 * (C) 1998 Sergey I. Yevtushenko (some code borrowed from cell toolkit) |
10 * | 10 * |
6466 * title: The text title of the entry. | 6466 * title: The text title of the entry. |
6467 * icon: Handle to coresponding icon. | 6467 * icon: Handle to coresponding icon. |
6468 * parent: Parent handle or 0 if root. | 6468 * parent: Parent handle or 0 if root. |
6469 * itemdata: Item specific data. | 6469 * itemdata: Item specific data. |
6470 */ | 6470 */ |
6471 HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, unsigned long icon, HTREEITEM parent, void *itemdata) | 6471 HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, HICN icon, HTREEITEM parent, void *itemdata) |
6472 { | 6472 { |
6473 ULONG cbExtra; | 6473 ULONG cbExtra; |
6474 PCNRITEM pci; | 6474 PCNRITEM pci; |
6475 RECORDINSERT ri; | 6475 RECORDINSERT ri; |
6476 | 6476 |
6524 * title: The text title of the entry. | 6524 * title: The text title of the entry. |
6525 * icon: Handle to coresponding icon. | 6525 * icon: Handle to coresponding icon. |
6526 * parent: Parent handle or 0 if root. | 6526 * parent: Parent handle or 0 if root. |
6527 * itemdata: Item specific data. | 6527 * itemdata: Item specific data. |
6528 */ | 6528 */ |
6529 HTREEITEM API dw_tree_insert(HWND handle, char *title, unsigned long icon, HTREEITEM parent, void *itemdata) | 6529 HTREEITEM API dw_tree_insert(HWND handle, char *title, HICN icon, HTREEITEM parent, void *itemdata) |
6530 { | 6530 { |
6531 return dw_tree_insert_after(handle, (HTREEITEM)CMA_END, title, icon, parent, itemdata); | 6531 return dw_tree_insert_after(handle, (HTREEITEM)CMA_END, title, icon, parent, itemdata); |
6532 } | 6532 } |
6533 | 6533 |
6534 /* | 6534 /* |
6537 * handle: Handle to the tree containing the item. | 6537 * handle: Handle to the tree containing the item. |
6538 * item: Handle of the item to be modified. | 6538 * item: Handle of the item to be modified. |
6539 * title: The text title of the entry. | 6539 * title: The text title of the entry. |
6540 * icon: Handle to coresponding icon. | 6540 * icon: Handle to coresponding icon. |
6541 */ | 6541 */ |
6542 void API dw_tree_item_change(HWND handle, HTREEITEM item, char *title, unsigned long icon) | 6542 void API dw_tree_item_change(HWND handle, HTREEITEM item, char *title, HICN icon) |
6543 { | 6543 { |
6544 PCNRITEM pci = (PCNRITEM)item; | 6544 PCNRITEM pci = (PCNRITEM)item; |
6545 | 6545 |
6546 if(!pci) | 6546 if(!pci) |
6547 return; | 6547 return; |
6841 * module: Handle to module (DLL) in OS/2 and Windows. | 6841 * module: Handle to module (DLL) in OS/2 and Windows. |
6842 * id: A unsigned long id int the resources on OS/2 and | 6842 * id: A unsigned long id int the resources on OS/2 and |
6843 * Windows, on GTK this is converted to a pointer | 6843 * Windows, on GTK this is converted to a pointer |
6844 * to an embedded XPM. | 6844 * to an embedded XPM. |
6845 */ | 6845 */ |
6846 unsigned long API dw_icon_load(unsigned long module, unsigned long id) | 6846 HICN API dw_icon_load(unsigned long module, unsigned long id) |
6847 { | 6847 { |
6848 return WinLoadPointer(HWND_DESKTOP,module,id); | 6848 return WinLoadPointer(HWND_DESKTOP,module,id); |
6849 } | 6849 } |
6850 | 6850 |
6851 /* | 6851 /* |
6853 * Parameters: | 6853 * Parameters: |
6854 * filename: Name of the file, omit extention to have | 6854 * filename: Name of the file, omit extention to have |
6855 * DW pick the appropriate file extension. | 6855 * DW pick the appropriate file extension. |
6856 * (ICO on OS/2 or Windows, XPM on Unix) | 6856 * (ICO on OS/2 or Windows, XPM on Unix) |
6857 */ | 6857 */ |
6858 unsigned long API dw_icon_load_from_file(char *filename) | 6858 HICN API dw_icon_load_from_file(char *filename) |
6859 { | 6859 { |
6860 char *file = alloca(strlen(filename) + 5); | 6860 char *file = alloca(strlen(filename) + 5); |
6861 | 6861 |
6862 if(!file) | 6862 if(!file) |
6863 return 0; | 6863 return 0; |
6880 * Parameters: | 6880 * Parameters: |
6881 * filename: Name of the file, omit extention to have | 6881 * filename: Name of the file, omit extention to have |
6882 * DW pick the appropriate file extension. | 6882 * DW pick the appropriate file extension. |
6883 * (ICO on OS/2 or Windows, XPM on Unix) | 6883 * (ICO on OS/2 or Windows, XPM on Unix) |
6884 */ | 6884 */ |
6885 unsigned long API dw_icon_load_from_data(char *data, int len) | 6885 HICN API dw_icon_load_from_data(char *data, int len) |
6886 { | 6886 { |
6887 unsigned long icon=0; | 6887 HICN icon=0; |
6888 char *file; | 6888 char *file; |
6889 FILE *fp; | 6889 FILE *fp; |
6890 | 6890 |
6891 if ( !data ) | 6891 if ( !data ) |
6892 return 0; | 6892 return 0; |
6913 /* | 6913 /* |
6914 * Frees a loaded resource in OS/2 and Windows. | 6914 * Frees a loaded resource in OS/2 and Windows. |
6915 * Parameters: | 6915 * Parameters: |
6916 * handle: Handle to icon returned by dw_icon_load(). | 6916 * handle: Handle to icon returned by dw_icon_load(). |
6917 */ | 6917 */ |
6918 void API dw_icon_free(unsigned long handle) | 6918 void API dw_icon_free(HICN handle) |
6919 { | 6919 { |
6920 WinDestroyPointer(handle); | 6920 WinDestroyPointer(handle); |
6921 } | 6921 } |
6922 | 6922 |
6923 /* | 6923 /* |
7148 * pointer: Pointer to the allocated memory in dw_container_alloc(). | 7148 * pointer: Pointer to the allocated memory in dw_container_alloc(). |
7149 * column: Zero based column of data being set. | 7149 * column: Zero based column of data being set. |
7150 * row: Zero based row of data being set. | 7150 * row: Zero based row of data being set. |
7151 * data: Pointer to the data to be added. | 7151 * data: Pointer to the data to be added. |
7152 */ | 7152 */ |
7153 void API dw_filesystem_change_file(HWND handle, int row, char *filename, unsigned long icon) | 7153 void API dw_filesystem_change_file(HWND handle, int row, char *filename, HICN icon) |
7154 { | 7154 { |
7155 dw_container_change_item(handle, 0, row, (void *)&icon); | 7155 dw_container_change_item(handle, 0, row, (void *)&icon); |
7156 dw_container_change_item(handle, 1, row, (void *)&filename); | 7156 dw_container_change_item(handle, 1, row, (void *)&filename); |
7157 } | 7157 } |
7158 | 7158 |
7163 * pointer: Pointer to the allocated memory in dw_container_alloc(). | 7163 * pointer: Pointer to the allocated memory in dw_container_alloc(). |
7164 * column: Zero based column of data being set. | 7164 * column: Zero based column of data being set. |
7165 * row: Zero based row of data being set. | 7165 * row: Zero based row of data being set. |
7166 * data: Pointer to the data to be added. | 7166 * data: Pointer to the data to be added. |
7167 */ | 7167 */ |
7168 void API dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, unsigned long icon) | 7168 void API dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, HICN icon) |
7169 { | 7169 { |
7170 dw_container_set_item(handle, pointer, 0, row, (void *)&icon); | 7170 dw_container_set_item(handle, pointer, 0, row, (void *)&icon); |
7171 dw_container_set_item(handle, pointer, 1, row, (void *)&filename); | 7171 dw_container_set_item(handle, pointer, 1, row, (void *)&filename); |
7172 } | 7172 } |
7173 | 7173 |
7566 * Parameters: | 7566 * Parameters: |
7567 * handle: Window handle that will handle taskbar icon messages. | 7567 * handle: Window handle that will handle taskbar icon messages. |
7568 * icon: Icon handle to display in the taskbar. | 7568 * icon: Icon handle to display in the taskbar. |
7569 * bubbletext: Text to show when the mouse is above the icon. | 7569 * bubbletext: Text to show when the mouse is above the icon. |
7570 */ | 7570 */ |
7571 void API dw_taskbar_insert(HWND handle, unsigned long icon, char *bubbletext) | 7571 void API dw_taskbar_insert(HWND handle, HICN icon, char *bubbletext) |
7572 { | 7572 { |
7573 handle = handle; | 7573 handle = handle; |
7574 icon = icon; | 7574 icon = icon; |
7575 bubbletext = bubbletext; | 7575 bubbletext = bubbletext; |
7576 /* TODO */ | 7576 /* TODO */ |
7580 * Deletes an icon from the taskbar. | 7580 * Deletes an icon from the taskbar. |
7581 * Parameters: | 7581 * Parameters: |
7582 * handle: Window handle that was used with dw_taskbar_insert(). | 7582 * handle: Window handle that was used with dw_taskbar_insert(). |
7583 * icon: Icon handle that was used with dw_taskbar_insert(). | 7583 * icon: Icon handle that was used with dw_taskbar_insert(). |
7584 */ | 7584 */ |
7585 void API dw_taskbar_delete(HWND handle, unsigned long icon) | 7585 void API dw_taskbar_delete(HWND handle, HICN icon) |
7586 { | 7586 { |
7587 handle = handle; | 7587 handle = handle; |
7588 icon = icon; | 7588 icon = icon; |
7589 /* TODO */ | 7589 /* TODO */ |
7590 } | 7590 } |