# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1301441120 0 # Node ID 5103d132c3cdfd4f27fc2e823efe7807f35c3d28 # Parent d51e958aad95bcb480dbd2de485cd67ac9469449 Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac. diff -r d51e958aad95 -r 5103d132c3cd mac/dw.m --- a/mac/dw.m Tue Mar 29 23:04:32 2011 +0000 +++ b/mac/dw.m Tue Mar 29 23:25:20 2011 +0000 @@ -2613,13 +2613,11 @@ return groupbox; } -#ifndef INCOMPLETE /* * Create a new scrollable Box to be packed. * Parameters: * type: Either DW_VERT (vertical) or DW_HORZ (horizontal). * pad: Number of pixels to pad around the box. - * This works fine under GTK+, but is incomplete on other platforms */ HWND API dw_scrollbox_new( int type, int pad ) { @@ -2644,9 +2642,27 @@ */ int API dw_scrollbox_get_pos(HWND handle, int orient) { - int val = -1; - NSLog(@"dw_scrollbox_get_pos() unimplemented\n"); - return val; + DWScrollBox *scrollbox = handle; + NSView *view = [scrollbox documentView]; + NSSize contentsize = [scrollbox contentSize]; + NSScroller *scrollbar; + int range = 0; + int val = 0; + if(orient == DW_VERT) + { + scrollbar = [scrollbox verticalScroller]; + range = [view bounds].size.height - contentsize.height; + } + else + { + scrollbar = [scrollbox horizontalScroller]; + range = [view bounds].size.width - contentsize.width; + } + if(range > 0) + { + val = [scrollbar floatValue] * range; + } + return val; } /* @@ -2657,11 +2673,19 @@ */ int API dw_scrollbox_get_range(HWND handle, int orient) { - int val = -1; - NSLog(@"dw_scrollbox_get_range() unimplemented\n"); - return val; -} -#endif + DWScrollBox *scrollbox = handle; + NSView *view = [scrollbox documentView]; + int range = 0; + if(orient == DW_VERT) + { + range = [view bounds].size.height; + } + else + { + range = [view bounds].size.width; + } + return range; +} /* * Pack windows (widgets) into a box from the end (or bottom).