changeset 203:e0beea487e8f

Added the basics for scrollbar thumb size on OS/2, and dw_main_iteration() which runs a message loop until it handles one message and returns. So other languages can run message loops and call this function internally.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 01 Feb 2003 07:05:12 +0000
parents 9f87ad1572eb
children 098ed34d41fb
files dw.def dw.h dwtest.c dww.def os2/dw.c
diffstat 5 files changed, 56 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/dw.def	Mon Jan 20 20:31:52 2003 +0000
+++ b/dw.def	Sat Feb 01 07:05:12 2003 +0000
@@ -22,6 +22,7 @@
   dw_flush                               @21
   dw_free                                @22
   dw_main_sleep                          @23
+  dw_main_iteration                      @24
 
   dw_box_new                             @40
   dw_groupbox_new                        @41
--- a/dw.h	Mon Jan 20 20:31:52 2003 +0000
+++ b/dw.h	Sat Feb 01 07:05:12 2003 +0000
@@ -632,6 +632,7 @@
 #endif
 void API dw_main(void);
 void API dw_main_sleep(int seconds);
+void API dw_main_iteration(void);
 void API dw_free(void *ptr);
 int API dw_window_show(HWND handle);
 int API dw_window_hide(HWND handle);
@@ -680,7 +681,7 @@
 void API dw_slider_set_pos(HWND handle, unsigned int position);
 unsigned int API dw_scrollbar_query_pos(HWND handle);
 void API dw_scrollbar_set_pos(HWND handle, unsigned int position);
-void API dw_scrollbar_set_range(HWND handle, unsigned int range);
+void API dw_scrollbar_set_range(HWND handle, unsigned int range, unsigned int visible);
 void API dw_window_set_pos(HWND handle, unsigned long x, unsigned long y);
 void API dw_window_set_usize(HWND handle, unsigned long width, unsigned long height);
 void API dw_window_set_pos_size(HWND handle, unsigned long x, unsigned long y, unsigned long width, unsigned long height);
--- a/dwtest.c	Mon Jan 20 20:31:52 2003 +0000
+++ b/dwtest.c	Sat Feb 01 07:05:12 2003 +0000
@@ -167,7 +167,8 @@
 
 	scrollbar = dw_scrollbar_new(FALSE, 100, 0);
 	dw_box_pack_start( pagebox, scrollbar, 100, 20, TRUE, FALSE, 0);
-	dw_scrollbar_set_range(scrollbar, 0);
+	dw_scrollbar_set_range(scrollbar, 100, 50);
+	dw_scrollbar_set_pos(scrollbar, 10);
 
 	text1pm = dw_pixmap_new( textbox1, font_width*width1, font_height*rows, depth );
 	text2pm = dw_pixmap_new( textbox2, font_width*width2, font_height*rows, depth );
--- a/dww.def	Mon Jan 20 20:31:52 2003 +0000
+++ b/dww.def	Sat Feb 01 07:05:12 2003 +0000
@@ -19,6 +19,7 @@
   dw_flush                               @21
   dw_free                                @22
   dw_main_sleep                          @23
+  dw_main_iteration                      @24
                                          
   dw_box_new                             @40
   dw_groupbox_new                        @41
--- a/os2/dw.c	Mon Jan 20 20:31:52 2003 +0000
+++ b/os2/dw.c	Sat Feb 01 07:05:12 2003 +0000
@@ -1870,6 +1870,8 @@
 		msg = WM_BUTTON1DOWN;
 	if(msg == WM_BUTTON2UP || msg == WM_BUTTON3UP)
 		msg = WM_BUTTON1UP;
+	if(msg == WM_VSCROLL || msg == WM_HSCROLL)
+		msg = SLN_SLIDERTRACK;
 
 	/* Find any callbacks for this function */
 	while(tmp)
@@ -2240,19 +2242,35 @@
 						{
 							int (* API valuechangedfunc)(HWND, int, void *) = (int (* API)(HWND, int, void *))tmp->signalfunction;
 
-							if(tmp->window == hWnd || WinQueryWindow(tmp->window, QW_PARENT) == hWnd)
+							if(origmsg == SLN_SLIDERTRACK)
 							{
-								static int lastvalue = -1;
-								static HWND lasthwnd = NULLHANDLE;
-								int ulValue = (int)WinSendMsg(tmp->window, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), 0);
-								if(lastvalue != ulValue || lasthwnd != tmp->window)
+								/* Handle Slider control */
+								if(tmp->window == hWnd || WinQueryWindow(tmp->window, QW_PARENT) == hWnd)
 								{
-									dw_window_set_data(tmp->window, "_dw_slider_value", (void *)ulValue);
-									result = valuechangedfunc(tmp->window, ulValue, tmp->data);
-									lastvalue = ulValue;
-									lasthwnd = tmp->window;
+									static int lastvalue = -1;
+									static HWND lasthwnd = NULLHANDLE;
+									int ulValue = (int)WinSendMsg(tmp->window, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), 0);
+									if(lastvalue != ulValue || lasthwnd != tmp->window)
+									{
+										dw_window_set_data(tmp->window, "_dw_slider_value", (void *)ulValue);
+										result = valuechangedfunc(tmp->window, ulValue, tmp->data);
+										lastvalue = ulValue;
+										lasthwnd = tmp->window;
+									}
+									tmp = NULL;
 								}
-								tmp = NULL;
+							}
+							else
+							{
+								/* Handle scrollbar control */
+								if(tmp->window = hWnd)
+								{
+									int pos = (int) SHORT1FROMMP(mp2);
+
+									dw_window_set_data(hWnd, "_dw_scrollbar_value", (void *)pos);
+									result = valuechangedfunc(tmp->window, pos, tmp->data);
+									tmp = NULL;
+								}
 							}
 						}
 
@@ -3073,6 +3091,23 @@
 }
 
 /*
+ * Processes a single message iteration and returns.
+ */
+void API dw_main_iteration(void)
+{
+	QMSG qmsg;
+
+	_dwtid = dw_thread_id();
+
+	if(WinGetMsg(dwhab, &qmsg, 0, 0, 0))
+	{
+		if(qmsg.msg == WM_TIMER && qmsg.hwnd == NULLHANDLE)
+			_run_event(qmsg.hwnd, qmsg.msg, qmsg.mp1, qmsg.mp2);
+		WinDispatchMsg(dwhab, &qmsg);
+	}
+}
+
+/*
  * Free's memory allocated by dynamic windows.
  * Parameters:
  *           ptr: Pointer to dynamic windows allocated
@@ -5282,11 +5317,13 @@
  * Parameters:
  *          handle: Handle to the scrollbar to be set.
  *          range: Maximum range value.
- */
-void API dw_scrollbar_set_range(HWND handle, unsigned int range)
+ *          visible: Visible area relative to the range.
+ */
+void API dw_scrollbar_set_range(HWND handle, unsigned int range, unsigned int visible)
 {
 	unsigned int pos = (unsigned int)dw_window_get_data(handle, "_dw_scrollbar_value");
-	WinSendMsg(handle, SBM_SETSCROLLBAR, (MPARAM)pos, MPFROM2SHORT(0, (unsigned short)range));
+	WinSendMsg(handle, SBM_SETSCROLLBAR, (MPARAM)pos, MPFROM2SHORT(0, (unsigned short)range - visible));
+	WinSendMsg(handle, SBM_SETTHUMBSIZE, MPFROM2SHORT((unsigned short)visible, range), 0);
 }
 
 /*