Mercurial > dwindows
comparison mac/dw.m @ 844:5103d132c3cd
Implemented dw_scrollbox_get_range() and dw_scrollbox_get_pos() on the Mac.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 29 Mar 2011 23:25:20 +0000 |
parents | 2967934fb587 |
children | 1a7c8d210b18 |
comparison
equal
deleted
inserted
replaced
843:d51e958aad95 | 844:5103d132c3cd |
---|---|
2611 box->grouphwnd = groupbox; | 2611 box->grouphwnd = groupbox; |
2612 [groupbox setContentView:thisbox]; | 2612 [groupbox setContentView:thisbox]; |
2613 return groupbox; | 2613 return groupbox; |
2614 } | 2614 } |
2615 | 2615 |
2616 #ifndef INCOMPLETE | |
2617 /* | 2616 /* |
2618 * Create a new scrollable Box to be packed. | 2617 * Create a new scrollable Box to be packed. |
2619 * Parameters: | 2618 * Parameters: |
2620 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal). | 2619 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal). |
2621 * pad: Number of pixels to pad around the box. | 2620 * pad: Number of pixels to pad around the box. |
2622 * This works fine under GTK+, but is incomplete on other platforms | |
2623 */ | 2621 */ |
2624 HWND API dw_scrollbox_new( int type, int pad ) | 2622 HWND API dw_scrollbox_new( int type, int pad ) |
2625 { | 2623 { |
2626 DWScrollBox *scrollbox = [[DWScrollBox alloc] init]; | 2624 DWScrollBox *scrollbox = [[DWScrollBox alloc] init]; |
2627 DWBox *box = dw_box_new(type, pad); | 2625 DWBox *box = dw_box_new(type, pad); |
2642 * handle: Handle to the scrollbox to be queried. | 2640 * handle: Handle to the scrollbox to be queried. |
2643 * orient: The vertical or horizontal scrollbar. | 2641 * orient: The vertical or horizontal scrollbar. |
2644 */ | 2642 */ |
2645 int API dw_scrollbox_get_pos(HWND handle, int orient) | 2643 int API dw_scrollbox_get_pos(HWND handle, int orient) |
2646 { | 2644 { |
2647 int val = -1; | 2645 DWScrollBox *scrollbox = handle; |
2648 NSLog(@"dw_scrollbox_get_pos() unimplemented\n"); | 2646 NSView *view = [scrollbox documentView]; |
2649 return val; | 2647 NSSize contentsize = [scrollbox contentSize]; |
2648 NSScroller *scrollbar; | |
2649 int range = 0; | |
2650 int val = 0; | |
2651 if(orient == DW_VERT) | |
2652 { | |
2653 scrollbar = [scrollbox verticalScroller]; | |
2654 range = [view bounds].size.height - contentsize.height; | |
2655 } | |
2656 else | |
2657 { | |
2658 scrollbar = [scrollbox horizontalScroller]; | |
2659 range = [view bounds].size.width - contentsize.width; | |
2660 } | |
2661 if(range > 0) | |
2662 { | |
2663 val = [scrollbar floatValue] * range; | |
2664 } | |
2665 return val; | |
2650 } | 2666 } |
2651 | 2667 |
2652 /* | 2668 /* |
2653 * Gets the range for the scrollbar in the scrollbox. | 2669 * Gets the range for the scrollbar in the scrollbox. |
2654 * Parameters: | 2670 * Parameters: |
2655 * handle: Handle to the scrollbox to be queried. | 2671 * handle: Handle to the scrollbox to be queried. |
2656 * orient: The vertical or horizontal scrollbar. | 2672 * orient: The vertical or horizontal scrollbar. |
2657 */ | 2673 */ |
2658 int API dw_scrollbox_get_range(HWND handle, int orient) | 2674 int API dw_scrollbox_get_range(HWND handle, int orient) |
2659 { | 2675 { |
2660 int val = -1; | 2676 DWScrollBox *scrollbox = handle; |
2661 NSLog(@"dw_scrollbox_get_range() unimplemented\n"); | 2677 NSView *view = [scrollbox documentView]; |
2662 return val; | 2678 int range = 0; |
2663 } | 2679 if(orient == DW_VERT) |
2664 #endif | 2680 { |
2681 range = [view bounds].size.height; | |
2682 } | |
2683 else | |
2684 { | |
2685 range = [view bounds].size.width; | |
2686 } | |
2687 return range; | |
2688 } | |
2665 | 2689 |
2666 /* | 2690 /* |
2667 * Pack windows (widgets) into a box from the end (or bottom). | 2691 * Pack windows (widgets) into a box from the end (or bottom). |
2668 * Parameters: | 2692 * Parameters: |
2669 * box: Window handle of the box to be packed into. | 2693 * box: Window handle of the box to be packed into. |