changeset 1744:535e8c19a13d

Added dw_filesystem_set_column_title() function to aid in localization.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 04 Jun 2012 22:18:56 +0000
parents a297b2bde127
children 7dd1659c2693
files dw.h dwtest.c gtk/dw.c gtk3/dw.c mac/dw.m os2/dw.c os2/dw.def os2/dw.lnk template/dw.c win/dw.c win/dw.def
diffstat 11 files changed, 118 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/dw.h	Sun Jun 03 19:44:04 2012 +0000
+++ b/dw.h	Mon Jun 04 22:18:56 2012 +0000
@@ -1607,6 +1607,7 @@
 void API dw_container_delete_row(HWND handle, char *text);
 void API dw_container_optimize(HWND handle);
 void API dw_container_set_stripe(HWND handle, unsigned long oddcolor, unsigned long evencolor);
+void API dw_filesystem_set_column_title(HWND handle, char *title);
 int API dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count);
 void API dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data);
 void API dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, HICN icon);
--- a/dwtest.c	Sun Jun 03 19:44:04 2012 +0000
+++ b/dwtest.c	Mon Jun 04 22:18:56 2012 +0000
@@ -1135,6 +1135,7 @@
     titles[2] = "Time";
     titles[3] = "Date";
 
+	dw_filesystem_set_column_title(container, "Test");
     dw_filesystem_setup(container, flags, titles, 4);
     dw_container_set_stripe(container, DW_CLR_DEFAULT, DW_CLR_DEFAULT);
     containerinfo = dw_container_alloc(container, 3);
--- a/gtk/dw.c	Sun Jun 03 19:44:04 2012 +0000
+++ b/gtk/dw.c	Mon Jun 04 22:18:56 2012 +0000
@@ -6914,6 +6914,19 @@
 }
 
 /*
+ * Configures the main filesystem columnn title for localization.
+ * Parameters:
+ *          handle: Handle to the container to be configured.
+ *          title: The title to be displayed in the main column.
+ */
+void API dw_filesystem_set_column_title(HWND handle, char *title)
+{
+	char *newtitle = strdup(title ? title : "");
+	
+	dw_window_set_data(handle, "_dw_coltitle", newtitle);
+}
+
+/*
  * Sets up the filesystem columns, note: filesystem always has an icon/filename field.
  * Parameters:
  *          handle: Handle to the container to be configured.
@@ -6925,9 +6938,10 @@
 {
    char **newtitles = malloc(sizeof(char *) * (count + 1));
    unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 1));
+   char *coltitle = (char *)dw_window_get_data(handle, "_dw_coltitle");
    int res;
 
-   newtitles[0] = "Filename";
+   newtitles[0] = coltitle ? coltitle : "Filename";
 
    newflags[0] = DW_CFA_STRINGANDICON | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR;
 
@@ -6936,6 +6950,11 @@
 
    res = _dw_container_setup(handle, newflags, newtitles, count + 1, 1, 1);
 
+   if(coltitle)
+   {
+	  dw_window_set_data(handle, "_dw_coltitle", NULL);
+	  free(coltitle);
+   }
    if ( newtitles) free(newtitles);
    if ( newflags ) free(newflags);
    return res;
--- a/gtk3/dw.c	Sun Jun 03 19:44:04 2012 +0000
+++ b/gtk3/dw.c	Mon Jun 04 22:18:56 2012 +0000
@@ -5622,6 +5622,19 @@
 }
 
 /*
+ * Configures the main filesystem columnn title for localization.
+ * Parameters:
+ *          handle: Handle to the container to be configured.
+ *          title: The title to be displayed in the main column.
+ */
+void API dw_filesystem_set_column_title(HWND handle, char *title)
+{
+	char *newtitle = strdup(title ? title : "");
+	
+	dw_window_set_data(handle, "_dw_coltitle", newtitle);
+}
+
+/*
  * Sets up the filesystem columns, note: filesystem always has an icon/filename field.
  * Parameters:
  *          handle: Handle to the container to be configured.
@@ -5633,8 +5646,9 @@
 {
    char **newtitles = malloc(sizeof(char *) * (count + 1));
    unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 1));
-
-   newtitles[0] = "Filename";
+   char *coltitle = (char *)dw_window_get_data(handle, "_dw_coltitle");
+
+   newtitles[0] = coltitle ? coltitle : "Filename";
    newflags[0] = DW_CFA_STRINGANDICON | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR;
 
    memcpy(&newtitles[1], titles, sizeof(char *) * count);
@@ -5642,6 +5656,11 @@
 
    _dw_container_setup(handle, newflags, newtitles, count + 1, 1, 1);
 
+   if(coltitle)
+   {
+	  dw_window_set_data(handle, "_dw_coltitle", NULL);
+	  free(coltitle);
+   }
    if ( newtitles) free(newtitles);
    if ( newflags ) free(newflags);
    return DW_ERROR_NONE;
--- a/mac/dw.m	Sun Jun 03 19:44:04 2012 +0000
+++ b/mac/dw.m	Mon Jun 04 22:18:56 2012 +0000
@@ -6213,6 +6213,19 @@
 }
 
 /*
+ * Configures the main filesystem columnn title for localization.
+ * Parameters:
+ *          handle: Handle to the container to be configured.
+ *          title: The title to be displayed in the main column.
+ */
+void API dw_filesystem_set_column_title(HWND handle, char *title)
+{
+	char *newtitle = strdup(title ? title : "");
+	
+	dw_window_set_data(handle, "_dw_coltitle", newtitle);
+}
+
+/*
  * Sets up the filesystem columns, note: filesystem always has an icon/filename field.
  * Parameters:
  *          handle: Handle to the container to be configured.
@@ -6224,9 +6237,10 @@
 {
     char **newtitles = malloc(sizeof(char *) * (count + 1));
     unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 1));
+    char *coltitle = (char *)dw_window_get_data(handle, "_dw_coltitle");
     DWContainer *cont = handle;
 
-    newtitles[0] = "Filename";
+    newtitles[0] = coltitle ? coltitle : "Filename";
 
     newflags[0] = DW_CFA_STRINGANDICON | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR;
 
@@ -6236,6 +6250,11 @@
     dw_container_setup(handle, newflags, newtitles, count + 1, 0);
     [cont setFilesystem:YES];
 
+    if(coltitle)
+    {
+        dw_window_set_data(handle, "_dw_coltitle", NULL);
+        free(coltitle);
+    }
     free(newtitles);
     free(newflags);
     return DW_ERROR_NONE;
--- a/os2/dw.c	Sun Jun 03 19:44:04 2012 +0000
+++ b/os2/dw.c	Mon Jun 04 22:18:56 2012 +0000
@@ -8948,6 +8948,19 @@
 }
 
 /*
+ * Configures the main filesystem columnn title for localization.
+ * Parameters:
+ *          handle: Handle to the container to be configured.
+ *          title: The title to be displayed in the main column.
+ */
+void API dw_filesystem_set_column_title(HWND handle, char *title)
+{
+	char *newtitle = strdup(title ? title : "");
+	
+	dw_window_set_data(handle, "_dw_coltitle", newtitle);
+}
+
+/*
  * Sets up the filesystem columns, note: filesystem always has an icon/filename field.
  * Parameters:
  *          handle: Handle to the container to be configured.
@@ -8959,9 +8972,10 @@
 {
    char **newtitles = malloc(sizeof(char *) * (count + 2));
    unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 2));
-
-   newtitles[0] = "Icon";
-   newtitles[1] = "Filename";
+   char *coltitle = (char *)dw_window_get_data(handle, "_dw_coltitle");
+
+   newtitles[0] = "";
+   newtitles[1] = coltitle ? coltitle : "Filename";
 
    newflags[0] = DW_CFA_BITMAPORICON | DW_CFA_CENTER | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR;
    newflags[1] = DW_CFA_STRING | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR;
@@ -8971,6 +8985,11 @@
 
    dw_container_setup(handle, newflags, newtitles, count + 2, count ? 2 : 0);
 
+   if(coltitle)
+   {
+	  dw_window_set_data(handle, "_dw_coltitle", NULL);
+	  free(coltitle);
+   }
    free(newtitles);
    free(newflags);
    return DW_ERROR_NONE;
--- a/os2/dw.def	Sun Jun 03 19:44:04 2012 +0000
+++ b/os2/dw.def	Mon Jun 04 22:18:56 2012 +0000
@@ -160,6 +160,7 @@
   dw_filesystem_change_item              @243
   dw_filesystem_change_file              @244
   dw_filesystem_get_column_type          @245
+  dw_filesystem_set_column_title         @246
 
   dw_screen_width                        @250
   dw_screen_height                       @251
--- a/os2/dw.lnk	Sun Jun 03 19:44:04 2012 +0000
+++ b/os2/dw.lnk	Mon Jun 04 22:18:56 2012 +0000
@@ -155,6 +155,7 @@
 export dw_filesystem_change_item.243
 export dw_filesystem_change_file.244
 export dw_filesystem_get_column_type.245
+export dw_filesystem_set_column_title.246
 
 export dw_screen_width.250
 export dw_screen_height.251
--- a/template/dw.c	Sun Jun 03 19:44:04 2012 +0000
+++ b/template/dw.c	Mon Jun 04 22:18:56 2012 +0000
@@ -1615,6 +1615,16 @@
 }
 
 /*
+ * Configures the main filesystem columnn title for localization.
+ * Parameters:
+ *          handle: Handle to the container to be configured.
+ *          title: The title to be displayed in the main column.
+ */
+void API dw_filesystem_set_column_title(HWND handle, char *title)
+{
+}
+
+/*
  * Sets up the filesystem columns, note: filesystem always has an icon/filename field.
  * Parameters:
  *          handle: Handle to the container to be configured.
--- a/win/dw.c	Sun Jun 03 19:44:04 2012 +0000
+++ b/win/dw.c	Mon Jun 04 22:18:56 2012 +0000
@@ -9001,6 +9001,19 @@
 }
 
 /*
+ * Configures the main filesystem columnn title for localization.
+ * Parameters:
+ *          handle: Handle to the container to be configured.
+ *          title: The title to be displayed in the main column.
+ */
+void API dw_filesystem_set_column_title(HWND handle, char *title)
+{
+	char *newtitle = strdup(title ? title : "");
+	
+	dw_window_set_data(handle, "_dw_coltitle", newtitle);
+}
+
+/*
  * Sets up the filesystem columns, note: filesystem always has an icon/filename field.
  * Parameters:
  *          handle: Handle to the container to be configured.
@@ -9010,10 +9023,11 @@
  */
 int API dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count)
 {
+   char *coltitle = (char *)dw_window_get_data(handle, "_dw_coltitle");
    LV_COLUMN lvc;
 
    lvc.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
-   lvc.pszText = TEXT("Filename");
+   lvc.pszText = coltitle ? UTF8toWide(coltitle) : TEXT("Filename");
    lvc.cchTextMax = 8;
    lvc.fmt = 0;
    if(!count)
@@ -9023,6 +9037,11 @@
    lvc.iSubItem = count;
    SendMessage(handle, LVM_INSERTCOLUMN, (WPARAM)0, (LPARAM)&lvc);
    dw_container_setup(handle, flags, titles, count, -1);
+   if(coltitle)
+   {
+	  dw_window_set_data(handle, "_dw_coltitle", NULL);
+	  free(coltitle);
+   }
    return DW_ERROR_NONE;
 }
 
--- a/win/dw.def	Sun Jun 03 19:44:04 2012 +0000
+++ b/win/dw.def	Mon Jun 04 22:18:56 2012 +0000
@@ -159,6 +159,7 @@
   dw_filesystem_change_item              @243
   dw_filesystem_change_file              @244
   dw_filesystem_get_column_type          @245
+  dw_filesystem_set_column_title         @246
 
   dw_screen_width                        @250
   dw_screen_height                       @251