Mercurial > dwindows
comparison dwtest.c @ 2446:b9d373d1ccf5
Add support for checking the application data directory for the images.
Copy the images into the Mac application bundle so they can be found.
Add iOS #ifdefs so it has font and file locations that can be found.
Not entirely happy with the #ifdefs in the test program, may revisit.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Fri, 09 Apr 2021 19:10:30 +0000 |
parents | a773008c7c5d |
children | 8723c01fb87e |
comparison
equal
deleted
inserted
replaced
2445:a773008c7c5d | 2446:b9d373d1ccf5 |
---|---|
23 #define FILE_ICON_NAME "win\\file" | 23 #define FILE_ICON_NAME "win\\file" |
24 #elif defined(__MAC__) | 24 #elif defined(__MAC__) |
25 #define FIXEDFONT "9.Monaco" | 25 #define FIXEDFONT "9.Monaco" |
26 #define FOLDER_ICON_NAME "mac/folder" | 26 #define FOLDER_ICON_NAME "mac/folder" |
27 #define FILE_ICON_NAME "mac/file" | 27 #define FILE_ICON_NAME "mac/file" |
28 #elif defined(__IOS__) | |
29 #define FIXEDFONT "9.Monaco" | |
30 #define FOLDER_ICON_NAME "folder" | |
31 #define FILE_ICON_NAME "file" | |
28 #elif GTK_MAJOR_VERSION > 1 | 32 #elif GTK_MAJOR_VERSION > 1 |
29 #define FIXEDFONT "10.monospace" | 33 #define FIXEDFONT "10.monospace" |
30 #define FOLDER_ICON_NAME "gtk/folder" | 34 #define FOLDER_ICON_NAME "gtk/folder" |
31 #define FILE_ICON_NAME "gtk/file" | 35 #define FILE_ICON_NAME "gtk/file" |
32 #else | 36 #else |
1138 text1pm = dw_pixmap_new(textbox1, font_width*width1, font_height*rows, (int)depth); | 1142 text1pm = dw_pixmap_new(textbox1, font_width*width1, font_height*rows, (int)depth); |
1139 text2pm = dw_pixmap_new(textbox2, font_width*cols, font_height*rows, (int)depth); | 1143 text2pm = dw_pixmap_new(textbox2, font_width*cols, font_height*rows, (int)depth); |
1140 image = dw_pixmap_new_from_file(textbox2, "image/test"); | 1144 image = dw_pixmap_new_from_file(textbox2, "image/test"); |
1141 if(!image) | 1145 if(!image) |
1142 image = dw_pixmap_new_from_file(textbox2, "~/test"); | 1146 image = dw_pixmap_new_from_file(textbox2, "~/test"); |
1147 if(!image) | |
1148 { | |
1149 char *appdir = dw_app_dir(); | |
1150 char pathbuff[1025] = {0}; | |
1151 int pos = (int)strlen(appdir); | |
1152 | |
1153 strncpy(pathbuff, appdir, 1024); | |
1154 #if defined(__OS2__) || defined(__WIN32__) | |
1155 pathbuff[pos] = '\\'; | |
1156 #else | |
1157 pathbuff[pos] = '/'; | |
1158 #endif | |
1159 pos++; | |
1160 strncpy(&pathbuff[pos], "test", 1024-pos); | |
1161 image = dw_pixmap_new_from_file(textbox2, pathbuff); | |
1162 dw_debug("PathBuff: %s\n", pathbuff); | |
1163 } | |
1143 if(image) | 1164 if(image) |
1144 dw_pixmap_set_transparent_color(image, DW_CLR_WHITE); | 1165 dw_pixmap_set_transparent_color(image, DW_CLR_WHITE); |
1145 | 1166 |
1146 dw_messagebox(utf8string ? utf8string : "DWTest", DW_MB_OK|DW_MB_INFORMATION, "Width: %d Height: %d\n", font_width, font_height); | 1167 dw_messagebox(utf8string ? utf8string : "DWTest", DW_MB_OK|DW_MB_INFORMATION, "Width: %d Height: %d\n", font_width, font_height); |
1147 dw_draw_rect(0, text1pm, DW_DRAW_FILL | DW_DRAW_NOAA, 0, 0, font_width*width1, font_height*rows); | 1168 dw_draw_rect(0, text1pm, DW_DRAW_FILL | DW_DRAW_NOAA, 0, 0, font_width*width1, font_height*rows); |
2119 menu_add(); | 2140 menu_add(); |
2120 | 2141 |
2121 notebookbox = dw_box_new( DW_VERT, 5 ); | 2142 notebookbox = dw_box_new( DW_VERT, 5 ); |
2122 dw_box_pack_start( mainwindow, notebookbox, 0, 0, TRUE, TRUE, 0); | 2143 dw_box_pack_start( mainwindow, notebookbox, 0, 0, TRUE, TRUE, 0); |
2123 | 2144 |
2124 foldericon = dw_icon_load_from_file( FOLDER_ICON_NAME ); | 2145 foldericon = dw_icon_load_from_file(FOLDER_ICON_NAME); |
2125 fileicon = dw_icon_load_from_file( FILE_ICON_NAME ); | 2146 fileicon = dw_icon_load_from_file(FILE_ICON_NAME); |
2147 | |
2148 if(!foldericon && !fileicon) | |
2149 { | |
2150 char *appdir = dw_app_dir(); | |
2151 char pathbuff[1025] = {0}; | |
2152 int pos = (int)strlen(appdir); | |
2153 | |
2154 strncpy(pathbuff, appdir, 1024); | |
2155 #if defined(__OS2__) || defined(__WIN32__) | |
2156 pathbuff[pos] = '\\'; | |
2157 #else | |
2158 pathbuff[pos] = '/'; | |
2159 #endif | |
2160 pos++; | |
2161 strncpy(&pathbuff[pos], FOLDER_ICON_NAME, 1024-pos); | |
2162 foldericon = dw_icon_load_from_file(pathbuff); | |
2163 dw_debug("PathBuff: %s\n", pathbuff); | |
2164 strncpy(&pathbuff[pos], FILE_ICON_NAME, 1024-pos); | |
2165 fileicon = dw_icon_load_from_file(pathbuff); | |
2166 dw_debug("PathBuff: %s\n", pathbuff); | |
2167 } | |
2126 | 2168 |
2127 notebook = dw_notebook_new( 1, TRUE ); | 2169 notebook = dw_notebook_new( 1, TRUE ); |
2128 dw_box_pack_start( notebookbox, notebook, 100, 100, TRUE, TRUE, 0); | 2170 dw_box_pack_start( notebookbox, notebook, 100, 100, TRUE, TRUE, 0); |
2129 dw_signal_connect(notebook, DW_SIGNAL_SWITCH_PAGE, DW_SIGNAL_FUNC(switch_page_cb), NULL); | 2171 dw_signal_connect(notebook, DW_SIGNAL_SWITCH_PAGE, DW_SIGNAL_FUNC(switch_page_cb), NULL); |
2130 | 2172 |