changeset 503:f3ed8dda02f8

Added dw_filesystem_change_*() and testcase code from Mark in dwtest. Also, added _fix_button_owner() to dw_window_redraw() on OS/2.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 18 Jan 2004 06:33:25 +0000
parents 56ea525c1a24
children 7061da3532d7
files dw.def dw.h dwtest.c dww.def gtk/dw.c os2/dw.c win/dw.c
diffstat 7 files changed, 190 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/dw.def	Sat Jan 17 16:19:02 2004 +0000
+++ b/dw.def	Sun Jan 18 06:33:25 2004 +0000
@@ -141,6 +141,8 @@
   dw_filesystem_setup                    @240
   dw_filesystem_set_item                 @241
   dw_filesystem_set_file                 @242
+  dw_filesystem_change_item              @243
+  dw_filesystem_change_file              @244
 
   dw_screen_width                        @250
   dw_screen_height                       @251
--- a/dw.h	Sat Jan 17 16:19:02 2004 +0000
+++ b/dw.h	Sun Jan 18 06:33:25 2004 +0000
@@ -1007,6 +1007,8 @@
 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, unsigned long icon);
+void API dw_filesystem_change_item(HWND handle, int column, int row, void *data);
+void API dw_filesystem_change_file(HWND handle, int row, char *filename, unsigned long icon);
 void dw_taskbar_insert(HWND handle, unsigned long icon, char *bubbletext);
 void dw_taskbar_delete(HWND handle, unsigned long icon);
 int API dw_screen_width(void);
--- a/dwtest.c	Sat Jan 17 16:19:02 2004 +0000
+++ b/dwtest.c	Sun Jan 18 06:33:25 2004 +0000
@@ -27,22 +27,24 @@
 unsigned long flStyle = DW_FCF_SYSMENU | DW_FCF_TITLEBAR |
 	DW_FCF_SHELLPOSITION | DW_FCF_TASKLIST | DW_FCF_DLGBORDER;
 
+	void create_button( int);
+
 #ifdef __MAC__
 int main(int argc, char *argv[])
 {
     DWEnv env;
     HWND window;
-    
+
     dw_init(TRUE, argc, argv);
-    
+
     window = dw_window_new(HWND_DESKTOP, "Test Window", flStyle);
     dw_window_set_pos_size(window, 100, 100, 300, 200);
     dw_window_show(window);
-    
+
     dw_environment_query(&env);
-    dw_messagebox("Title", DW_MB_OK | DW_MB_INFORMATION, "Operating System: %s %d.%d\nBuild: %d.%d\n", 
+    dw_messagebox("Title", DW_MB_OK | DW_MB_INFORMATION, "Operating System: %s %d.%d\nBuild: %d.%d\n",
                 env.osName, env.MajorVersion, env.MinorVersion, env.MajorBuild, env.MinorBuild);
-            
+
     return 0;
 }
 #else
@@ -58,6 +60,7 @@
      notebookbox2,
      notebookbox3,
      notebookbox4,
+     notebookbox5,
      notebook,
      vscrollbar,
      hscrollbar,
@@ -73,7 +76,11 @@
      containerbox,
      textbox1, textbox2, textboxA,
      gap_box,
-     buttonbox;
+     buttonbox,
+     buttonboxperm,
+     filetoolbarbox;
+
+void *containerinfo;
 
 HPIXMAP text1pm,text2pm;
 unsigned long fileicon,foldericon,mle_point=-1;
@@ -326,7 +333,7 @@
 int DWSIGNAL browse_callback(HWND window, void *data)
 {
 	char *tmp;
-	tmp = dw_file_browse("test string", NULL, "c", DW_DIRECTORY_OPEN );
+	tmp = dw_file_browse("test string", NULL, "c", DW_FILE_OPEN );
 	if ( tmp )
 	{
 		if ( current_file )
@@ -341,6 +348,22 @@
 	return 0;
 }
 
+int DWSIGNAL button_callback(HWND window, void *data)
+{
+	return 0;
+}
+
+int DWSIGNAL redraw_button_box_callback(HWND window, void *data)
+{
+#if 0
+	dw_window_destroy( filetoolbarbox );
+	create_button(1);
+#else
+	dw_window_enable( window);
+#endif
+	return 0;
+}
+
 /* Callback to handle user selection of the scrollbar position */
 void DWSIGNAL scrollbar_valuechanged(HWND hwnd, int value, void *data)
 {
@@ -433,6 +456,7 @@
 	char buf[200];
 	char *str;
 	HWND statline = (HWND)data;
+	unsigned long size;
 
 	sprintf(buf,"DW_SIGNAL_ITEM_SELECT: Window: %x Item: %x Text: %s Itemdata: %x", (unsigned int)window, (unsigned int)item, text, (unsigned int)itemdata );
 	dw_window_set_text( statline, buf);
@@ -447,6 +471,12 @@
 	}
 	/* Make the last inserted point the cursor location */
 	dw_mle_set(container_mle, mle_point);
+/* set the details of item 0 to new data */
+fprintf(stderr,"In cb: container: %x containerinfo: %x icon: %x\n", container, containerinfo, fileicon);
+	dw_filesystem_change_file(container, 0, "new data", fileicon);
+	size = 999;
+fprintf(stderr,"In cb: container: %x containerinfo: %x icon: %x\n", container, containerinfo, fileicon);
+	dw_filesystem_change_item(container, 0, 0, &size);
 	return 0;
 }
 
@@ -634,7 +664,6 @@
 	unsigned long flags[3] = {  DW_CFA_ULONG | DW_CFA_RIGHT | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR,
 	DW_CFA_TIME | DW_CFA_CENTER | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR,
 	DW_CFA_DATE | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR };
-	void *containerinfo;
 	int z;
 	CTIME time;
 	CDATE date;
@@ -668,6 +697,7 @@
 		sprintf(buffer, "Filename %d",z+1);
 		if (z == 0 ) thisicon = foldericon;
 		else thisicon = fileicon;
+fprintf(stderr,"Initial: container: %x containerinfo: %x icon: %x\n", container, containerinfo, thisicon);
 		dw_filesystem_set_file(container, containerinfo, z, buffer, thisicon);
 		dw_filesystem_set_item(container, containerinfo, 0, z, &size);
 
@@ -706,6 +736,59 @@
 	return TRUE;
 }
 
+
+void buttons_add(void)
+{
+	HWND buttonsbox,abutton1,abutton2;
+
+	/* create a box to pack into the notebook page */
+	buttonsbox = dw_box_new(BOXVERT, 2);
+	dw_box_pack_start( notebookbox5, buttonsbox, 25, 200, TRUE, TRUE, 0);
+	dw_window_set_color(buttonsbox, DW_CLR_RED, DW_CLR_RED);
+/*
+ * Create our file toolbar boxes...
+ */
+	buttonboxperm = dw_box_new( BOXVERT, 0 );
+	dw_box_pack_start( buttonsbox, buttonboxperm, 25, 0, FALSE, TRUE, 2 );
+	dw_window_set_color(buttonboxperm, DW_CLR_WHITE, DW_CLR_WHITE);
+	abutton1 = dw_bitmapbutton_new_from_file( "Top", 0, "junk" );
+	dw_box_pack_start( buttonboxperm, abutton1, 25, 25, FALSE, FALSE, 0 );
+	dw_signal_connect( abutton1, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(button_callback), NULL );
+	dw_box_pack_start( buttonboxperm, 0, 25, 5, FALSE, FALSE, 0 );
+	abutton2 = dw_bitmapbutton_new_from_file( "Bottom", 0, "junk" );
+	dw_box_pack_start( buttonsbox, abutton2, 25, 25, FALSE, FALSE, 0 );
+	dw_signal_connect( abutton2, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(button_callback), NULL );
+
+	create_button(0);
+}
+
+void create_button( int redraw)
+{
+	HWND abutton1;
+	filetoolbarbox = dw_box_new( BOXVERT, 0 );
+	dw_box_pack_start( buttonboxperm, filetoolbarbox, 0, 0, TRUE, TRUE, 0 );
+
+	abutton1 = dw_bitmapbutton_new_from_file( "Should be under Top button", 0, "junk" );
+	dw_box_pack_start( filetoolbarbox, abutton1, 25, 25, FALSE, FALSE, 0);
+	dw_signal_connect( abutton1, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(redraw_button_box_callback), NULL );
+	dw_box_pack_start( filetoolbarbox, 0, 25, 5, FALSE, FALSE, 0 );
+
+	abutton1 = dw_bitmapbutton_new_from_file( "Should be under Top button", 0, "junk" );
+	dw_box_pack_start( filetoolbarbox, abutton1, 25, 25, FALSE, FALSE, 0);
+	dw_signal_connect( abutton1, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(redraw_button_box_callback), NULL );
+	dw_box_pack_start( filetoolbarbox, 0, 25, 5, FALSE, FALSE, 0 );
+
+	abutton1 = dw_bitmapbutton_new_from_file( "Should be under Top button", 0, "junk" );
+	dw_box_pack_start( filetoolbarbox, abutton1, 25, 25, FALSE, FALSE, 0);
+	dw_signal_connect( abutton1, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(redraw_button_box_callback), NULL );
+	dw_box_pack_start( filetoolbarbox, 0, 25, 5, FALSE, FALSE, 0 );
+	if ( redraw )
+	{
+		dw_window_redraw( filetoolbarbox );
+		dw_window_redraw( mainwindow );
+	}
+}
+
 /*
  * Let's demonstrate the functionality of this library. :)
  */
@@ -715,6 +798,7 @@
 	ULONG notebookpage2;
 	ULONG notebookpage3;
 	ULONG notebookpage4;
+	ULONG notebookpage5;
 
 	dw_init(TRUE, argc, argv);
 
@@ -751,6 +835,12 @@
 	dw_notebook_page_set_text( notebook, notebookpage4, "container");
 	container_add();
 
+	notebookbox5 = dw_box_new( BOXVERT, 5 );
+	notebookpage5 = dw_notebook_page_new( notebook, 1, FALSE );
+	dw_notebook_pack( notebook, notebookpage5, notebookbox5 );
+	dw_notebook_page_set_text( notebook, notebookpage5, "buttons");
+	buttons_add();
+
 	dw_signal_connect(mainwindow, DW_SIGNAL_DELETE, DW_SIGNAL_FUNC(exit_callback), (void *)mainwindow);
 	timerid = dw_timer_connect(1000, DW_SIGNAL_FUNC(timer_callback), 0);
 	dw_window_set_icon(mainwindow, fileicon);
--- a/dww.def	Sat Jan 17 16:19:02 2004 +0000
+++ b/dww.def	Sun Jan 18 06:33:25 2004 +0000
@@ -138,6 +138,8 @@
   dw_filesystem_setup                    @240
   dw_filesystem_set_item                 @241
   dw_filesystem_set_file                 @242
+  dw_filesystem_change_item              @243
+  dw_filesystem_change_file              @244
 
   dw_screen_width                        @250
   dw_screen_height                       @251
--- a/gtk/dw.c	Sat Jan 17 16:19:02 2004 +0000
+++ b/gtk/dw.c	Sun Jan 18 06:33:25 2004 +0000
@@ -5081,6 +5081,34 @@
 }
 
 /*
+ * 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_container_change_item(handle, column + 2, 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_container_change_item(handle, 0, row, (void *)&icon);
+	dw_container_change_item(handle, 1, row, (void *)&filename);
+}
+
+/*
  * Sets an item in specified row and column to the given data.
  * Parameters:
  *          handle: Handle to the container window (widget).
--- a/os2/dw.c	Sat Jan 17 16:19:02 2004 +0000
+++ b/os2/dw.c	Sun Jan 18 06:33:25 2004 +0000
@@ -302,7 +302,7 @@
 		GpiDeleteBitmap(hbm);
 }
 
-/* This function removes and handlers on windows and frees
+/* This function removes any handlers on windows and frees
  * the user memory allocated to it.
  */
 void _free_window_memory(HWND handle)
@@ -3686,6 +3686,7 @@
 	HWND window = client ? client : handle;
 	Box *mybox = (Box *)WinQueryWindowPtr(window, QWP_USER);
 
+	_fix_button_owner(_toplevel_window(handle), 0);
 	if(window && mybox)
 	{
 		unsigned long width, height;
@@ -6602,6 +6603,34 @@
 }
 
 /*
+ * 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_container_change_item(handle, column + 2, 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_container_change_item(handle, 0, row, (void *)&icon);
+	dw_container_change_item(handle, 1, row, (void *)&filename);
+}
+
+/*
  * Sets an item in specified row and column to the given data.
  * Parameters:
  *          handle: Handle to the container window (widget).
--- a/win/dw.c	Sat Jan 17 16:19:02 2004 +0000
+++ b/win/dw.c	Sun Jan 18 06:33:25 2004 +0000
@@ -6695,6 +6695,34 @@
 }
 
 /*
+ * 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_container_change_item(handle, column + 2, 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_container_change_item(handle, 0, row, (void *)&icon);
+	dw_container_change_item(handle, 1, row, (void *)&filename);
+}
+
+/*
  * Sets the width of a column in the container.
  * Parameters:
  *          handle: Handle to window (widget) of container.