Mercurial > dwindows
comparison ios/dw.m @ 2641:608598b9fed9
iOS: UISplitViewController may not be the right way to implement DWSplitBar.
Disable UISplitView code and instead temporarily implement it with normal
boxes. This gets HandyFTP functional on iOS.... however without the usual
splitbar functionality.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Fri, 13 Aug 2021 21:12:25 +0000 |
parents | cee87daaf150 |
children | 42bc7ddd6751 |
comparison
equal
deleted
inserted
replaced
2640:cee87daaf150 | 2641:608598b9fed9 |
---|---|
6946 * topleft: Handle to the window to be top or left. | 6946 * topleft: Handle to the window to be top or left. |
6947 * bottomright: Handle to the window to be bottom or right. | 6947 * bottomright: Handle to the window to be bottom or right. |
6948 * Returns: | 6948 * Returns: |
6949 * A handle to a splitbar window or NULL on failure. | 6949 * A handle to a splitbar window or NULL on failure. |
6950 */ | 6950 */ |
6951 DW_FUNCTION_DEFINITION(dw_splitbar_new, HWND, DW_UNUSED(int type), HWND topleft, HWND bottomright, unsigned long cid) | 6951 DW_FUNCTION_DEFINITION(dw_splitbar_new, HWND, int type, HWND topleft, HWND bottomright, unsigned long cid) |
6952 DW_FUNCTION_ADD_PARAM4(type, topleft, bottomright, cid) | 6952 DW_FUNCTION_ADD_PARAM4(type, topleft, bottomright, cid) |
6953 DW_FUNCTION_RETURN(dw_splitbar_new, HWND) | 6953 DW_FUNCTION_RETURN(dw_splitbar_new, HWND) |
6954 DW_FUNCTION_RESTORE_PARAM4(DW_UNUSED(type), int, topleft, HWND, bottomright, HWND, cid, unsigned long) | 6954 DW_FUNCTION_RESTORE_PARAM4(type, int, topleft, HWND, bottomright, HWND, cid, unsigned long) |
6955 { | 6955 { |
6956 DW_FUNCTION_INIT; | 6956 DW_FUNCTION_INIT; |
6957 #ifdef _DW_USE_SPLITBAR | |
6957 id tmpbox = dw_box_new(DW_VERT, 0); | 6958 id tmpbox = dw_box_new(DW_VERT, 0); |
6958 DWSplitBar *split = [[DWSplitBar alloc] init]; | 6959 DWSplitBar *split = [[DWSplitBar alloc] init]; |
6959 UIViewController *vc = [[[UIViewController alloc] init] retain]; | 6960 UIViewController *vc = [[[UIViewController alloc] init] retain]; |
6960 [split setDelegate:split]; | 6961 [split setDelegate:split]; |
6961 dw_box_pack_start(tmpbox, topleft, 0, 0, TRUE, TRUE, 0); | 6962 dw_box_pack_start(tmpbox, topleft, 0, 0, TRUE, TRUE, 0); |
6962 [vc setView:tmpbox]; | |
6963 if (@available(iOS 14.0, *)) { | 6963 if (@available(iOS 14.0, *)) { |
6964 [split setViewController:vc forColumn:UISplitViewControllerColumnPrimary]; | 6964 [split setViewController:vc forColumn:UISplitViewControllerColumnPrimary]; |
6965 } else { | 6965 } else { |
6966 [split addChildViewController:vc]; | 6966 [split addChildViewController:vc]; |
6967 } | 6967 } |
6968 [[vc view] addSubview:tmpbox]; | |
6968 [tmpbox autorelease]; | 6969 [tmpbox autorelease]; |
6969 tmpbox = dw_box_new(DW_VERT, 0); | 6970 tmpbox = dw_box_new(DW_VERT, 0); |
6970 dw_box_pack_start(tmpbox, bottomright, 0, 0, TRUE, TRUE, 0); | 6971 dw_box_pack_start(tmpbox, bottomright, 0, 0, TRUE, TRUE, 0); |
6971 vc = [[UIViewController alloc] init]; | 6972 vc = [[UIViewController alloc] init]; |
6972 [vc setView:tmpbox]; | |
6973 if (@available(iOS 14.0, *)) { | 6973 if (@available(iOS 14.0, *)) { |
6974 [split setViewController:vc forColumn:UISplitViewControllerColumnSecondary]; | 6974 [split setViewController:vc forColumn:UISplitViewControllerColumnSecondary]; |
6975 } else { | 6975 } else { |
6976 [split addChildViewController:vc]; | 6976 [split addChildViewController:vc]; |
6977 } | 6977 } |
6978 [[vc view] addSubview:tmpbox]; | |
6978 [tmpbox autorelease]; | 6979 [tmpbox autorelease]; |
6979 [vc autorelease]; | 6980 [vc autorelease]; |
6980 #if 0 /* TODO: All iOS splitbars are vertical */ | 6981 /* TODO: All iOS splitbars are vertical |
6981 [split setVertical:(type == DW_VERT ? YES : NO)]; | 6982 * [split setVertical:(type == DW_VERT ? YES : NO)]; |
6982 #endif | 6983 */ |
6983 /* Set the default percent to 50% split */ | 6984 /* Set the default percent to 50% split */ |
6984 [split setPercent:50.0]; | 6985 [split setPercent:50.0]; |
6985 [split setTag:cid]; | 6986 [split setTag:cid]; |
6987 #else | |
6988 id split = dw_box_new(type, 0); | |
6989 dw_box_pack_start(split, topleft, 0, 0, TRUE, TRUE, 0); | |
6990 dw_box_pack_start(split, bottomright, 0, 0, TRUE, TRUE, 0); | |
6991 [split setTag:cid]; | |
6992 #endif | |
6986 DW_FUNCTION_RETURN_THIS(split); | 6993 DW_FUNCTION_RETURN_THIS(split); |
6987 } | 6994 } |
6988 | 6995 |
6996 #ifdef _DW_USE_SPLITBAR | |
6989 /* | 6997 /* |
6990 * Sets the position of a splitbar (pecentage). | 6998 * Sets the position of a splitbar (pecentage). |
6991 * Parameters: | 6999 * Parameters: |
6992 * handle: The handle to the splitbar returned by dw_splitbar_new(). | 7000 * handle: The handle to the splitbar returned by dw_splitbar_new(). |
6993 * percent: The position of the splitbar. | 7001 * percent: The position of the splitbar. |
7000 DW_FUNCTION_INIT; | 7008 DW_FUNCTION_INIT; |
7001 DWSplitBar *split = handle; | 7009 DWSplitBar *split = handle; |
7002 CGSize size = [split preferredContentSize]; | 7010 CGSize size = [split preferredContentSize]; |
7003 float pos; | 7011 float pos; |
7004 /* Calculate the position based on the size */ | 7012 /* Calculate the position based on the size */ |
7005 #if 0 /* TODO: iOS split views are always vertical */ | 7013 /* TODO: iOS split views are always vertical |
7006 if(![split isVertical]) | 7014 if(![split isVertical]) |
7007 pos = size.height * (percent / 100.0); | 7015 pos = size.height * (percent / 100.0); |
7008 else | 7016 else */ |
7009 #endif | |
7010 pos = size.width * (percent / 100.0); | 7017 pos = size.width * (percent / 100.0); |
7011 if(pos > 0) | 7018 if(pos > 0) |
7012 { | 7019 { |
7013 if (@available(iOS 14.0, *)) { | 7020 if (@available(iOS 14.0, *)) { |
7014 [split setPreferredPrimaryColumnWidth:pos]; | 7021 [split setPreferredPrimaryColumnWidth:pos]; |
7044 } else { | 7051 } else { |
7045 /* TODO: If possible*/ | 7052 /* TODO: If possible*/ |
7046 } | 7053 } |
7047 return retval; | 7054 return retval; |
7048 } | 7055 } |
7056 #else | |
7057 /* | |
7058 * Sets the position of a splitbar (pecentage). | |
7059 * Parameters: | |
7060 * handle: The handle to the splitbar returned by dw_splitbar_new(). | |
7061 * percent: The position of the splitbar. | |
7062 */ | |
7063 void API dw_splitbar_set(HWND handle, float percent) | |
7064 { | |
7065 } | |
7066 | |
7067 /* | |
7068 * Gets the position of a splitbar (pecentage). | |
7069 * Parameters: | |
7070 * handle: The handle to the splitbar returned by dw_splitbar_new(). | |
7071 */ | |
7072 float API dw_splitbar_get(HWND handle) | |
7073 { | |
7074 return 50.0; | |
7075 } | |
7076 #endif | |
7049 | 7077 |
7050 /* Internal function to convert fontname to UIFont */ | 7078 /* Internal function to convert fontname to UIFont */ |
7051 UIFont *_dw_font_by_name(const char *fontname) | 7079 UIFont *_dw_font_by_name(const char *fontname) |
7052 { | 7080 { |
7053 UIFont *font = DWDefaultFont; | 7081 UIFont *font = DWDefaultFont; |