Mercurial > dwindows
comparison os2/dw.c @ 539:8f80ed604a89
Some splitbar optimizations, removed unneeded code and optimized crucial
codepaths (window procedures) on OS/2 and Windows. I also figured out
what the splitbar problem is on OS/2, but the fix is not yet finished.
I have a somewhat working fix but it causes some other problems. So
I have not committed it yet.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 01 Apr 2004 07:25:38 +0000 |
parents | 5c1ee7f6e7ff |
children | 2b9b88c273bc |
comparison
equal
deleted
inserted
replaced
538:5c1ee7f6e7ff | 539:8f80ed604a89 |
---|---|
2782 } | 2782 } |
2783 } | 2783 } |
2784 | 2784 |
2785 void _handle_splitbar_resize(HWND hwnd, float percent, int type, int x, int y) | 2785 void _handle_splitbar_resize(HWND hwnd, float percent, int type, int x, int y) |
2786 { | 2786 { |
2787 float ratio = (float)percent/(float)100.0; | |
2788 HWND handle1 = (HWND)dw_window_get_data(hwnd, "_dw_topleft"); | |
2789 HWND handle2 = (HWND)dw_window_get_data(hwnd, "_dw_bottomright"); | |
2790 Box *tmp = WinQueryWindowPtr(handle1, QWP_USER); | |
2791 | |
2792 WinShowWindow(handle1, FALSE); | |
2793 WinShowWindow(handle2, FALSE); | |
2794 | |
2787 if(type == DW_HORZ) | 2795 if(type == DW_HORZ) |
2788 { | 2796 { |
2789 int newx = x; | 2797 int newx = (int)((float)x * ratio) - (SPLITBAR_WIDTH/2); |
2790 float ratio = (float)percent/(float)100.0; | |
2791 HWND handle1 = (HWND)dw_window_get_data(hwnd, "_dw_topleft"); | |
2792 HWND handle2 = (HWND)dw_window_get_data(hwnd, "_dw_bottomright"); | |
2793 Box *tmp = WinQueryWindowPtr(handle1, QWP_USER); | |
2794 | |
2795 WinShowWindow(handle1, FALSE); | |
2796 WinShowWindow(handle2, FALSE); | |
2797 | |
2798 newx = (int)((float)newx * ratio) - (SPLITBAR_WIDTH/2); | |
2799 | 2798 |
2800 WinSetWindowPos(handle1, NULLHANDLE, 0, 0, newx, y, SWP_MOVE | SWP_SIZE); | 2799 WinSetWindowPos(handle1, NULLHANDLE, 0, 0, newx, y, SWP_MOVE | SWP_SIZE); |
2801 _do_resize(tmp, newx - 1, y - 1); | 2800 _do_resize(tmp, newx - 1, y - 1); |
2802 | 2801 |
2803 dw_window_set_data(hwnd, "_dw_start", (void *)newx); | 2802 dw_window_set_data(hwnd, "_dw_start", (void *)newx); |
2806 | 2805 |
2807 newx = x - newx - SPLITBAR_WIDTH; | 2806 newx = x - newx - SPLITBAR_WIDTH; |
2808 | 2807 |
2809 WinSetWindowPos(handle2, NULLHANDLE, x - newx, 0, newx, y, SWP_MOVE | SWP_SIZE); | 2808 WinSetWindowPos(handle2, NULLHANDLE, x - newx, 0, newx, y, SWP_MOVE | SWP_SIZE); |
2810 _do_resize(tmp, newx - 1, y - 1); | 2809 _do_resize(tmp, newx - 1, y - 1); |
2811 | |
2812 WinShowWindow(handle1, TRUE); | |
2813 WinShowWindow(handle2, TRUE); | |
2814 } | 2810 } |
2815 else | 2811 else |
2816 { | 2812 { |
2817 int newy = y; | 2813 int newy = (int)((float)y * ratio) - (SPLITBAR_WIDTH/2); |
2818 float ratio = (float)percent/(float)100.0; | |
2819 HWND handle1 = (HWND)dw_window_get_data(hwnd, "_dw_topleft"); | |
2820 HWND handle2 = (HWND)dw_window_get_data(hwnd, "_dw_bottomright"); | |
2821 Box *tmp = WinQueryWindowPtr(handle1, QWP_USER); | |
2822 | |
2823 WinShowWindow(handle1, FALSE); | |
2824 WinShowWindow(handle2, FALSE); | |
2825 | |
2826 newy = (int)((float)newy * ratio) - (SPLITBAR_WIDTH/2); | |
2827 | 2814 |
2828 WinSetWindowPos(handle1, NULLHANDLE, 0, y - newy, x, newy, SWP_MOVE | SWP_SIZE); | 2815 WinSetWindowPos(handle1, NULLHANDLE, 0, y - newy, x, newy, SWP_MOVE | SWP_SIZE); |
2829 _do_resize(tmp, x - 1, newy - 1); | 2816 _do_resize(tmp, x - 1, newy - 1); |
2830 | 2817 |
2831 tmp = WinQueryWindowPtr(handle2, QWP_USER); | 2818 tmp = WinQueryWindowPtr(handle2, QWP_USER); |
2833 newy = y - newy - SPLITBAR_WIDTH; | 2820 newy = y - newy - SPLITBAR_WIDTH; |
2834 | 2821 |
2835 WinSetWindowPos(handle2, NULLHANDLE, 0, 0, x, newy, SWP_MOVE | SWP_SIZE); | 2822 WinSetWindowPos(handle2, NULLHANDLE, 0, 0, x, newy, SWP_MOVE | SWP_SIZE); |
2836 _do_resize(tmp, x - 1, newy - 1); | 2823 _do_resize(tmp, x - 1, newy - 1); |
2837 | 2824 |
2838 WinShowWindow(handle1, TRUE); | |
2839 WinShowWindow(handle2, TRUE); | |
2840 | |
2841 dw_window_set_data(hwnd, "_dw_start", (void *)newy); | 2825 dw_window_set_data(hwnd, "_dw_start", (void *)newy); |
2842 } | 2826 } |
2827 | |
2828 WinShowWindow(handle1, TRUE); | |
2829 WinShowWindow(handle2, TRUE); | |
2843 } | 2830 } |
2844 | 2831 |
2845 | 2832 |
2846 /* This handles any activity on the splitbars (sizers) */ | 2833 /* This handles any activity on the splitbars (sizers) */ |
2847 MRESULT EXPENTRY _splitwndproc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 2834 MRESULT EXPENTRY _splitwndproc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) |
2848 { | 2835 { |
2849 float *percent = (float *)dw_window_get_data(hwnd, "_dw_percent"); | |
2850 int type = (int)dw_window_get_data(hwnd, "_dw_type"); | |
2851 int start = (int)dw_window_get_data(hwnd, "_dw_start"); | |
2852 | |
2853 switch (msg) | 2836 switch (msg) |
2854 { | 2837 { |
2855 case WM_ACTIVATE: | 2838 case WM_ACTIVATE: |
2856 case WM_SETFOCUS: | 2839 case WM_SETFOCUS: |
2857 return (MRESULT)(FALSE); | 2840 return (MRESULT)(FALSE); |
2859 case WM_PAINT: | 2842 case WM_PAINT: |
2860 { | 2843 { |
2861 HPS hps; | 2844 HPS hps; |
2862 POINTL ptl[2]; | 2845 POINTL ptl[2]; |
2863 RECTL rcl; | 2846 RECTL rcl; |
2847 int type = (int)dw_window_get_data(hwnd, "_dw_type"); | |
2848 int start = (int)dw_window_get_data(hwnd, "_dw_start"); | |
2864 | 2849 |
2865 hps = WinBeginPaint(hwnd, 0, 0); | 2850 hps = WinBeginPaint(hwnd, 0, 0); |
2866 | 2851 |
2867 WinQueryWindowRect(hwnd, &rcl); | 2852 WinQueryWindowRect(hwnd, &rcl); |
2868 | 2853 |
2889 } | 2874 } |
2890 return MRFROMSHORT(FALSE); | 2875 return MRFROMSHORT(FALSE); |
2891 | 2876 |
2892 case WM_MOUSEMOVE: | 2877 case WM_MOUSEMOVE: |
2893 { | 2878 { |
2879 int type = (int)dw_window_get_data(hwnd, "_dw_type"); | |
2880 | |
2894 if(type == DW_HORZ) | 2881 if(type == DW_HORZ) |
2895 WinSetPointer(HWND_DESKTOP, | 2882 WinSetPointer(HWND_DESKTOP, |
2896 WinQuerySysPointer(HWND_DESKTOP, | 2883 WinQuerySysPointer(HWND_DESKTOP, |
2897 SPTR_SIZEWE, | 2884 SPTR_SIZEWE, |
2898 FALSE)); | 2885 FALSE)); |
2906 case WM_BUTTON1DOWN: | 2893 case WM_BUTTON1DOWN: |
2907 { | 2894 { |
2908 APIRET rc; | 2895 APIRET rc; |
2909 RECTL rclFrame; | 2896 RECTL rclFrame; |
2910 RECTL rclBounds; | 2897 RECTL rclBounds; |
2898 float *percent = (float *)dw_window_get_data(hwnd, "_dw_percent"); | |
2899 int type = (int)dw_window_get_data(hwnd, "_dw_type"); | |
2900 int start = (int)dw_window_get_data(hwnd, "_dw_start"); | |
2911 | 2901 |
2912 WinQueryWindowRect(hwnd, &rclFrame); | 2902 WinQueryWindowRect(hwnd, &rclFrame); |
2913 WinQueryWindowRect(hwnd, &rclBounds); | 2903 WinQueryWindowRect(hwnd, &rclBounds); |
2914 | 2904 |
2915 WinMapWindowPoints(hwnd, HWND_DESKTOP, | 2905 WinMapWindowPoints(hwnd, HWND_DESKTOP, |