├── wrapper.xojo_resources ├── .gitignore ├── .DS_Store ├── .wrapper.xojo_uistate ├── App Icon └── shuttle.png ├── Launch Images ├── .DS_Store ├── iPadLandscape.png ├── iPadPortrait.png ├── iPadPortrait2x.png ├── iPadLandscape2x.png ├── iPhone5Portrait.png ├── iPhone6Portrait.png ├── iPhonePortrait2x.png ├── iPhone6PlusPortrait.png └── iPhone6PlusLandscape.png ├── Wrapper.xojo_binary_code ├── wrapper.xojo_binary_project ├── iPadScreen.xojo_code ├── iPhoneScreen.xojo_code ├── Build Automation.xojo_code ├── App.xojo_code ├── README.md ├── MainView.xojo_code ├── ViewUITableView.xojo_code.obsolete_20150105_005525 ├── ViewBackgroundColor.xojo_code ├── View1.xojo_code.obsolete_20141213_222951 ├── SetNavigationBarColor.xojo_code ├── UITableView.xojo_code.obsolete_20150105_005525 └── Wrapper.xojo_code /wrapper.xojo_resources: -------------------------------------------------------------------------------- 1 | ICNS -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | wrapper.xojo_project 3 | -------------------------------------------------------------------------------- /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mitchboo/XojoiOSWrapper/HEAD/.DS_Store -------------------------------------------------------------------------------- /.wrapper.xojo_uistate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mitchboo/XojoiOSWrapper/HEAD/.wrapper.xojo_uistate -------------------------------------------------------------------------------- /App Icon/shuttle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mitchboo/XojoiOSWrapper/HEAD/App Icon/shuttle.png -------------------------------------------------------------------------------- /Launch Images/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mitchboo/XojoiOSWrapper/HEAD/Launch Images/.DS_Store -------------------------------------------------------------------------------- /Wrapper.xojo_binary_code: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mitchboo/XojoiOSWrapper/HEAD/Wrapper.xojo_binary_code -------------------------------------------------------------------------------- /wrapper.xojo_binary_project: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mitchboo/XojoiOSWrapper/HEAD/wrapper.xojo_binary_project -------------------------------------------------------------------------------- /Launch Images/iPadLandscape.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mitchboo/XojoiOSWrapper/HEAD/Launch Images/iPadLandscape.png -------------------------------------------------------------------------------- /Launch Images/iPadPortrait.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mitchboo/XojoiOSWrapper/HEAD/Launch Images/iPadPortrait.png -------------------------------------------------------------------------------- /Launch Images/iPadPortrait2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mitchboo/XojoiOSWrapper/HEAD/Launch Images/iPadPortrait2x.png -------------------------------------------------------------------------------- /Launch Images/iPadLandscape2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mitchboo/XojoiOSWrapper/HEAD/Launch Images/iPadLandscape2x.png -------------------------------------------------------------------------------- /Launch Images/iPhone5Portrait.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mitchboo/XojoiOSWrapper/HEAD/Launch Images/iPhone5Portrait.png -------------------------------------------------------------------------------- /Launch Images/iPhone6Portrait.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mitchboo/XojoiOSWrapper/HEAD/Launch Images/iPhone6Portrait.png -------------------------------------------------------------------------------- /Launch Images/iPhonePortrait2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mitchboo/XojoiOSWrapper/HEAD/Launch Images/iPhonePortrait2x.png -------------------------------------------------------------------------------- /Launch Images/iPhone6PlusPortrait.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mitchboo/XojoiOSWrapper/HEAD/Launch Images/iPhone6PlusPortrait.png -------------------------------------------------------------------------------- /Launch Images/iPhone6PlusLandscape.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mitchboo/XojoiOSWrapper/HEAD/Launch Images/iPhone6PlusLandscape.png -------------------------------------------------------------------------------- /iPadScreen.xojo_code: -------------------------------------------------------------------------------- 1 | #tag IOSScreen 2 | OrientationPortrait = True 3 | OrientationLandscapeLeft = True 4 | OrientationLandscapeRight = True 5 | OrientationPortraitUpsideDown = True 6 | Begin ScreenContent 7 | ItemName = 8 | Target = 163706629 9 | Icon = 0 10 | End ScreenContent 11 | #tag EndIOSScreen 12 | -------------------------------------------------------------------------------- /iPhoneScreen.xojo_code: -------------------------------------------------------------------------------- 1 | #tag IOSScreen 2 | OrientationPortrait = True 3 | OrientationLandscapeLeft = True 4 | OrientationLandscapeRight = True 5 | OrientationPortraitUpsideDown = True 6 | Begin ScreenContent 7 | ItemName = 8 | Target = 163706629 9 | Icon = 0 10 | End ScreenContent 11 | #tag EndIOSScreen 12 | -------------------------------------------------------------------------------- /Build Automation.xojo_code: -------------------------------------------------------------------------------- 1 | #tag BuildAutomation 2 | Begin BuildStepList Linux 3 | Begin BuildProjectStep Build 4 | End 5 | End 6 | Begin BuildStepList Mac OS X 7 | Begin BuildProjectStep Build 8 | End 9 | End 10 | Begin BuildStepList Windows 11 | Begin BuildProjectStep Build 12 | End 13 | End 14 | Begin BuildStepList iOS 15 | Begin BuildProjectStep Build 16 | End 17 | Begin SignProjectStep Sign 18 | End 19 | End 20 | #tag EndBuildAutomation 21 | -------------------------------------------------------------------------------- /App.xojo_code: -------------------------------------------------------------------------------- 1 | #tag Class 2 | Protected Class App 3 | Inherits IOSApplication 4 | #tag CompatibilityFlags = TargetIOS 5 | #tag Method, Flags = &h0 6 | Sub HideStatusBar(mView as iOSView) 7 | ' By Jason King 8 | 'Sub HideStatusBar(mView as iOSView) 9 | declare function object_getClass lib "/usr/lib/libobjc.A.dylib" (cls As Ptr) As Ptr 10 | declare function NSSelectorFromString lib FoundationLib (aSelectorName as CFStringRef) as Ptr 11 | declare function class_addMethod lib "/usr/lib/libobjc.A.dylib" (cls as Ptr, name as Ptr, imp as Ptr, types as CString) as Boolean 12 | 13 | dim viewControllerClass As Ptr = object_getClass(mView.ViewControllerHandle) 14 | if not class_addMethod(viewControllerClass, NSSelectorFromString("prefersStatusBarHidden"), _ 15 | AddressOf impl_prefersStatusBarHidden, "b@:") then break 16 | 'End Sub 17 | End Sub 18 | #tag EndMethod 19 | 20 | #tag Method, Flags = &h21 21 | Private Shared Function impl_prefersStatusBarHidden(pid as ptr, sel as ptr) As Boolean 22 | 'Works with hideStatusBar by Jason King 23 | 'Private Shared Function impl_prefersStatusBarHidden(pid as ptr, sel as ptr) As Boolean 24 | Return True 25 | 'End Function 26 | End Function 27 | #tag EndMethod 28 | 29 | 30 | #tag Note, Name = How to use HideStatusBar 31 | This method has been created by Jason King. 32 | 33 | To use HideStatusBar, add in the Open event of a view : 34 | HideStatusBar(self) 35 | 36 | As of now, it does remove the status bar for the whole application, but a method to reinstate it is not available. 37 | #tag EndNote 38 | 39 | 40 | #tag ViewBehavior 41 | #tag EndViewBehavior 42 | End Class 43 | #tag EndClass 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | XojoiOSWrapper 2 | ============== 3 | 4 | Module that brings legacy and additional functions to Xojo iOS 5 | 6 | Here is the first of no doubt a long series. This module contains the functions I needed to adapt older code, 7 | plus a couple declares (setfocus/clearfocus) needed to activate and remove the keyboard in code in the Textfield or TextArea. 8 | 9 | This repository contains the files as a xojo_project so they can be viewed online.The project now contains classes, each on a separate page : 10 | 11 | - ViewBackgroundColor : changes the view background color 12 | 13 | - SetNavigationBarColor 14 | 15 | But if all you need is the wrapper module, simply download and drag Wrapper.xojo_binary_code into your program. 16 | 17 | Methods available : 18 | Asc(), 19 | Backdrop() (for iOSButton), 20 | BackgroundColor (for TextField and TextArea, works with most controls), 21 | BackgroundImage (for most controls, including CC) 22 | BoolToText, 23 | CDbl(), 24 | Chr(), 25 | Clearfocus, 26 | EncodeBase64 27 | EncodeBase64 with memoryblock in, avoiding the sometimes impossible convertion to Text, 28 | DecodeBase64(), 29 | EncodeURLComponent(), 30 | Floor(), 31 | ForeColor, 32 | Auto.FindType 33 | hideTabBar(), 34 | Instr(), 35 | Left(), 36 | Len(), 37 | HTMLViewer.LoadPage(), 38 | MainScreenScale, 39 | MaxWidth(), 40 | MD5, 41 | Mid(), 42 | Msgbox(), 43 | NthField(), 44 | redColor, 45 | Right(), 46 | SetFocus, 47 | SetBackgroundRoundedRectangle() (for iOSButton), 48 | SetSeparatorColor() (for iOSTable), 49 | SetSeparatorStyle() (for iOSTable), 50 | ShellPath 51 | ShowURL, 52 | StringHeight(), 53 | StringWidth(), 54 | StripAccents(), 55 | TextAscent(), 56 | Tab (constant), 57 | CC.TrueWindow, CC.TrueView, 58 | Val(), 59 | 60 | Constants : 61 | EndOfLine 62 | 63 | Will grow with future contributions ... 64 | 65 | See http://dethomsoft.com/download.html for dtPLugins for iOS by Jean-Paul Devulder 66 | See https://github.com/kingj5/iOSKit for the iOSKit series of classes by Jason King 67 | See https://github.com/sbeardsl/xojoGestures for a module from Stephen J. Beardslee which brings gesture support. 68 | See https://github.com/UBogun/Xojo-AppleLib/ from Ulrich Bogun for extended modules and classes. 69 | -------------------------------------------------------------------------------- /MainView.xojo_code: -------------------------------------------------------------------------------- 1 | #tag IOSView 2 | Begin iosView MainView 3 | BackButtonTitle = "" 4 | Compatibility = "" 5 | Left = 0 6 | NavigationBarVisible= False 7 | TabTitle = "" 8 | Title = "" 9 | Top = 0 10 | Begin iOSTable Table1 11 | AccessibilityHint= "" 12 | AccessibilityLabel= "" 13 | AutoLayout = Table1, 2, , 2, False, +1.00, 1, 1, 0, 14 | AutoLayout = Table1, 3, , 3, False, +1.00, 1, 1, 50, 15 | AutoLayout = Table1, 1, , 1, False, +1.00, 1, 1, 0, 16 | AutoLayout = Table1, 8, , 0, False, +1.00, 1, 1, 320, 17 | Format = "0" 18 | Height = 320.0 19 | Left = 0 20 | LockedInPosition= False 21 | Scope = 0 22 | SectionCount = 0 23 | Top = 50 24 | Visible = True 25 | Width = 320.0 26 | End 27 | Begin iOSButton Button1 28 | AccessibilityHint= "" 29 | AccessibilityLabel= "" 30 | AutoLayout = Button1, 8, , 0, False, +1.00, 1, 1, 30, 31 | AutoLayout = Button1, 7, , 0, False, +1.00, 1, 1, 122, 32 | AutoLayout = Button1, 9, , 9, False, +1.00, 1, 1, 0, 33 | AutoLayout = Button1, 3, , 3, False, +1.00, 1, 1, 386, 34 | Caption = "Hide status bar" 35 | Enabled = True 36 | Height = 30.0 37 | Left = 99 38 | LockedInPosition= False 39 | Scope = 0 40 | TextColor = &c007AFF00 41 | TextFont = "" 42 | TextSize = 0 43 | Top = 386 44 | Visible = True 45 | Width = 122.0 46 | End 47 | End 48 | #tag EndIOSView 49 | 50 | #tag WindowCode 51 | #tag EndWindowCode 52 | 53 | #tag Events Table1 54 | #tag Event 55 | Sub Open() 56 | me.AddSection("") 57 | me.AddRow(0, "ViewBackgroundColor") 58 | me.AddRow(0, "SetNavigationBarColor") 59 | 60 | 61 | End Sub 62 | #tag EndEvent 63 | #tag Event 64 | Sub Action(section As Integer, row As Integer) 65 | Dim newView As iOSView 66 | 67 | select case row 68 | 69 | case 0 70 | newView = New ViewBackgroundColor 71 | case 1 72 | newView = new SetNavigationBarColor 73 | 74 | end select 75 | 76 | Self.PushTo(newView) 77 | End Sub 78 | #tag EndEvent 79 | #tag EndEvents 80 | #tag Events Button1 81 | #tag Event 82 | Sub Action() 83 | dim v as new mainview 84 | app.HideStatusBar(v) 85 | End Sub 86 | #tag EndEvent 87 | #tag EndEvents 88 | #tag ViewBehavior 89 | #tag ViewProperty 90 | Name="BackButtonTitle" 91 | Group="Behavior" 92 | Type="Text" 93 | EditorType="MultiLineEditor" 94 | #tag EndViewProperty 95 | #tag ViewProperty 96 | Name="Index" 97 | Visible=true 98 | Group="ID" 99 | InitialValue="-2147483648" 100 | Type="Integer" 101 | #tag EndViewProperty 102 | #tag ViewProperty 103 | Name="Left" 104 | Visible=true 105 | Group="Position" 106 | InitialValue="0" 107 | Type="Integer" 108 | #tag EndViewProperty 109 | #tag ViewProperty 110 | Name="Name" 111 | Visible=true 112 | Group="ID" 113 | Type="String" 114 | #tag EndViewProperty 115 | #tag ViewProperty 116 | Name="NavigationBarVisible" 117 | Group="Behavior" 118 | Type="Boolean" 119 | #tag EndViewProperty 120 | #tag ViewProperty 121 | Name="Super" 122 | Visible=true 123 | Group="ID" 124 | Type="String" 125 | #tag EndViewProperty 126 | #tag ViewProperty 127 | Name="TabTitle" 128 | Group="Behavior" 129 | Type="Text" 130 | #tag EndViewProperty 131 | #tag ViewProperty 132 | Name="Title" 133 | Group="Behavior" 134 | Type="Text" 135 | EditorType="MultiLineEditor" 136 | #tag EndViewProperty 137 | #tag ViewProperty 138 | Name="Top" 139 | Visible=true 140 | Group="Position" 141 | InitialValue="0" 142 | Type="Integer" 143 | #tag EndViewProperty 144 | #tag EndViewBehavior 145 | -------------------------------------------------------------------------------- /ViewUITableView.xojo_code.obsolete_20150105_005525: -------------------------------------------------------------------------------- 1 | #tag IOSView 2 | Begin iosView ViewUITableView 3 | BackButtonTitle = "" 4 | Compatibility = "" 5 | Left = 0 6 | NavigationBarVisible= False 7 | TabTitle = "" 8 | Title = "" 9 | Top = 0 10 | Begin iOSRectangle Rectangle1 11 | AccessibilityHint= "" 12 | AccessibilityLabel= "" 13 | AutoLayout = Rectangle1, 7, , 0, False, +1.00, 1, 1, 126, 14 | AutoLayout = Rectangle1, 3, , 3, False, +1.00, 1, 1, 35, 15 | AutoLayout = Rectangle1, 1, , 1, False, +1.00, 1, 1, 166, 16 | AutoLayout = Rectangle1, 8, , 0, False, +1.00, 1, 1, 392, 17 | BorderColor = &c00000000 18 | BorderWidth = 2.0 19 | CornerHeight = 0.0 20 | CornerWidth = 0.0 21 | FillColor = &cFFFF3D00 22 | Height = 392.0 23 | Left = 166 24 | LockedInPosition= False 25 | Scope = 0 26 | Top = 35 27 | Visible = True 28 | Width = 126.0 29 | End 30 | Begin uitableview Table1 31 | AccessibilityHint= "" 32 | AccessibilityLabel= "" 33 | Alpha = 0.0 34 | AutoLayout = Table1, 3, , 3, False, +1.00, 1, 1, 44, 35 | AutoLayout = Table1, 2, , 2, False, +1.00, 1, 1, -0, 36 | AutoLayout = Table1, 8, , 0, False, +1.00, 1, 1, 320, 37 | AutoLayout = Table1, 1, , 1, False, +1.00, 1, 1, 0, 38 | Format = "0" 39 | Height = 320.0 40 | Left = 0 41 | LockedInPosition= False 42 | RowHeight = 0.0 43 | Scope = 0 44 | SectionCount = 0 45 | Top = 44 46 | TransparentTable= False 47 | Visible = True 48 | Width = 320.0 49 | End 50 | Begin iOSButton Button1 51 | AccessibilityHint= "" 52 | AccessibilityLabel= "" 53 | AutoLayout = Button1, 7, , 0, False, +1.00, 1, 1, 100, 54 | AutoLayout = Button1, 4, BottomLayoutGuide, 3, False, +1.00, 1, 1, -*kStdControlGapV, 55 | AutoLayout = Button1, 9, , 9, False, +1.00, 1, 1, 0, 56 | AutoLayout = Button1, 8, , 0, False, +1.00, 1, 1, 30, 57 | Caption = "Untitled" 58 | Enabled = True 59 | Height = 30.0 60 | Left = 110 61 | LockedInPosition= False 62 | Scope = 0 63 | TextColor = &c007AFF00 64 | TextFont = "" 65 | TextSize = 0 66 | Top = 442 67 | Visible = True 68 | Width = 100.0 69 | End 70 | End 71 | #tag EndIOSView 72 | 73 | #tag WindowCode 74 | #tag Event 75 | Sub Open() 76 | Table1.AddSection"" 77 | Table1.AddRow 0, "Foo" 78 | Table1.AddRow 0, "Bar" 79 | table1.RowHeight = 12 80 | 81 | table1.AddRow 0, "Rowheight: "+table1.RowHeight.ToText 82 | // table1.backgroundview = NIL 83 | // table1.Alpha = 0.6 84 | table1.TransparentTable = true 85 | Table1.MakeVisibleCellsTransparent 86 | End Sub 87 | #tag EndEvent 88 | 89 | 90 | #tag Note, Name = Credit 91 | 92 | This has been created by Jason King. 93 | 94 | For use, you need to drag the UITableView class into your project, as well as the Wrapper module which contains needed additional declares. 95 | #tag EndNote 96 | 97 | 98 | #tag EndWindowCode 99 | 100 | #tag Events Button1 101 | #tag Event 102 | Sub Action() 103 | setSeparatorColor(Table1.Handle,redColor) 104 | 105 | End Sub 106 | #tag EndEvent 107 | #tag EndEvents 108 | #tag ViewBehavior 109 | #tag ViewProperty 110 | Name="BackButtonTitle" 111 | Group="Behavior" 112 | Type="Text" 113 | EditorType="MultiLineEditor" 114 | #tag EndViewProperty 115 | #tag ViewProperty 116 | Name="Index" 117 | Visible=true 118 | Group="ID" 119 | InitialValue="-2147483648" 120 | Type="Integer" 121 | #tag EndViewProperty 122 | #tag ViewProperty 123 | Name="Left" 124 | Visible=true 125 | Group="Position" 126 | InitialValue="0" 127 | Type="Integer" 128 | #tag EndViewProperty 129 | #tag ViewProperty 130 | Name="Name" 131 | Visible=true 132 | Group="ID" 133 | Type="String" 134 | #tag EndViewProperty 135 | #tag ViewProperty 136 | Name="NavigationBarVisible" 137 | Group="Behavior" 138 | Type="Boolean" 139 | #tag EndViewProperty 140 | #tag ViewProperty 141 | Name="Super" 142 | Visible=true 143 | Group="ID" 144 | Type="String" 145 | #tag EndViewProperty 146 | #tag ViewProperty 147 | Name="TabTitle" 148 | Group="Behavior" 149 | Type="Text" 150 | #tag EndViewProperty 151 | #tag ViewProperty 152 | Name="Title" 153 | Group="Behavior" 154 | Type="Text" 155 | EditorType="MultiLineEditor" 156 | #tag EndViewProperty 157 | #tag ViewProperty 158 | Name="Top" 159 | Visible=true 160 | Group="Position" 161 | InitialValue="0" 162 | Type="Integer" 163 | #tag EndViewProperty 164 | #tag EndViewBehavior 165 | -------------------------------------------------------------------------------- /ViewBackgroundColor.xojo_code: -------------------------------------------------------------------------------- 1 | #tag IOSView 2 | Begin iosView ViewBackgroundColor 3 | BackButtonTitle = "" 4 | Compatibility = "" 5 | Left = 0 6 | NavigationBarVisible= False 7 | TabTitle = "" 8 | Title = "" 9 | Top = 0 10 | Begin iOSTextArea TextArea1 11 | AccessibilityHint= "" 12 | AccessibilityLabel= "" 13 | AutoLayout = TextArea1, 8, , 0, False, +1.00, 1, 1, 283, 14 | AutoLayout = TextArea1, 3, , 3, False, +1.00, 1, 1, 76, 15 | AutoLayout = TextArea1, 2, , 2, False, +1.00, 1, 1, 0, 16 | AutoLayout = TextArea1, 1, , 1, False, +1.00, 1, 1, 0, 17 | Editable = True 18 | Height = 283.0 19 | KeyboardType = "0" 20 | Left = 0 21 | LockedInPosition= False 22 | Scope = 0 23 | Text = "This view where the background color has been changed is based upon code from Stéphane Pinel, posted by Richard Berglund in the forum.\n\nSee the Open event of this view.\n" 24 | TextAlignment = "0" 25 | TextColor = &c00000000 26 | TextFont = "" 27 | TextSize = 0 28 | Top = 76 29 | Visible = True 30 | Width = 320.0 31 | End 32 | Begin iOSButton Button1 33 | AccessibilityHint= "" 34 | AccessibilityLabel= "" 35 | AutoLayout = Button1, 4, TextArea1, 3, False, +1.00, 1, 1, -*kStdControlGapV, 36 | AutoLayout = Button1, 8, , 0, False, +1.00, 1, 1, 30, 37 | AutoLayout = Button1, 1, , 1, False, +1.00, 1, 1, 7, 38 | AutoLayout = Button1, 7, , 0, False, +1.00, 1, 1, 82, 39 | Caption = "< Back" 40 | Enabled = True 41 | Height = 30.0 42 | Left = 7 43 | LockedInPosition= False 44 | Scope = 0 45 | TextColor = &cFF800000 46 | TextFont = "Custom Helvetica Helvetica-Bold" 47 | TextSize = 18 48 | Top = 38 49 | Visible = True 50 | Width = 82.0 51 | End 52 | End 53 | #tag EndIOSView 54 | 55 | #tag WindowCode 56 | #tag Event 57 | Sub Open() 58 | app.HideStatusBar(self) 59 | ' ObjC Declare to get a ref to a class by its name 60 | Declare Function objc_getClass lib "/usr/lib/libobjc.dylib" (aClassName As CString) as Ptr 61 | ' Here is the corresponding Xojo call 62 | dim theUIColorClassRef As Ptr = objc_getClass("UIColor") 63 | 64 | ' UIKit Declare to create a color object 65 | Declare Function decl_GetColorWithRGBA lib "UIKit" selector "colorWithRed:green:blue:alpha:" (UIColorClassRef As Ptr, red As Single, green As Single, blue As Single, alpha As Single) As Ptr 66 | ' Here is the corresponding Xojo call, where we create a flashy green color 67 | dim myUIColorObject As ptr = decl_GetColorWithRGBA(theUIColorClassRef, (33.0/255.0), (209.0/255.0), (57.0/255.0), 1.0) 68 | 69 | ' UIKit Declare to get a reference to a View from its ViewController 70 | Declare Function decl_GetView lib "UIKit" selector "view" (aUIViewController As Ptr) As Ptr 71 | ' Here is the corresponding Xojo call (View.Self returns a ViewController) 72 | dim myViewPtr As Ptr = decl_GetView(self.Handle) 73 | 74 | ' UIKit Declare to set the backgound color of a View 75 | Declare Sub decl_SetBackgroundColor lib "UIKit" selector "setBackgroundColor:" (aUIView As Ptr, aUIColor As Ptr) 76 | ' Here is the corresponding Xojo call 77 | decl_SetBackgroundColor(myViewPtr, myUIColorObject) 78 | End Sub 79 | #tag EndEvent 80 | 81 | 82 | #tag EndWindowCode 83 | 84 | #tag Events Button1 85 | #tag Event 86 | Sub Action() 87 | close 88 | End Sub 89 | #tag EndEvent 90 | #tag EndEvents 91 | #tag ViewBehavior 92 | #tag ViewProperty 93 | Name="BackButtonTitle" 94 | Group="Behavior" 95 | Type="Text" 96 | EditorType="MultiLineEditor" 97 | #tag EndViewProperty 98 | #tag ViewProperty 99 | Name="Index" 100 | Visible=true 101 | Group="ID" 102 | InitialValue="-2147483648" 103 | Type="Integer" 104 | #tag EndViewProperty 105 | #tag ViewProperty 106 | Name="Left" 107 | Visible=true 108 | Group="Position" 109 | InitialValue="0" 110 | Type="Integer" 111 | #tag EndViewProperty 112 | #tag ViewProperty 113 | Name="Name" 114 | Visible=true 115 | Group="ID" 116 | Type="String" 117 | #tag EndViewProperty 118 | #tag ViewProperty 119 | Name="NavigationBarVisible" 120 | Group="Behavior" 121 | Type="Boolean" 122 | #tag EndViewProperty 123 | #tag ViewProperty 124 | Name="Super" 125 | Visible=true 126 | Group="ID" 127 | Type="String" 128 | #tag EndViewProperty 129 | #tag ViewProperty 130 | Name="TabTitle" 131 | Group="Behavior" 132 | Type="Text" 133 | #tag EndViewProperty 134 | #tag ViewProperty 135 | Name="Title" 136 | Group="Behavior" 137 | Type="Text" 138 | EditorType="MultiLineEditor" 139 | #tag EndViewProperty 140 | #tag ViewProperty 141 | Name="Top" 142 | Visible=true 143 | Group="Position" 144 | InitialValue="0" 145 | Type="Integer" 146 | #tag EndViewProperty 147 | #tag EndViewBehavior 148 | -------------------------------------------------------------------------------- /View1.xojo_code.obsolete_20141213_222951: -------------------------------------------------------------------------------- 1 | #tag IOSView 2 | Begin iosView View1 3 | BackButtonTitle = "" 4 | Compatibility = "" 5 | Left = 0 6 | NavigationBarVisible= True 7 | TabTitle = "" 8 | Title = "Color me" 9 | Top = 0 10 | Begin iOSTextArea TextArea1 11 | AutoLayout = TextArea1, 1, , 1, False, +1.00, 1, 1, 0, 12 | AutoLayout = TextArea1, 2, , 2, False, +1.00, 1, 1, 0, 13 | AutoLayout = TextArea1, 3, , 0, False, +1.00, 1, 1, 94, 14 | AutoLayout = TextArea1, 8, , 0, False, +1.00, 1, 1, 200, 15 | Editable = True 16 | Height = 200.0 17 | KeyboardType = "" 18 | Left = 0.0 19 | LockedInPosition= False 20 | Scope = 0 21 | Text = "For more information, see the note attached to this view\n" 22 | TextAlignment = "" 23 | TextColor = &c00000000 24 | TextFont = "" 25 | TextSize = 0 26 | Top = 94.0 27 | Visible = True 28 | Width = 320.0 29 | End 30 | Begin iOSButton Button1 31 | AutoLayout = Button1, 8, , 0, False, +1.00, 1, 1, 30, 32 | AutoLayout = Button1, 3, , 3, False, +1.00, 1, 1, 339, 33 | AutoLayout = Button1, 7, , 0, False, +1.00, 1, 1, 100, 34 | AutoLayout = Button1, 9, , 9, False, +1.00, 1, 1, 0, 35 | Caption = "Untitled" 36 | Enabled = True 37 | Height = 30.0 38 | Left = 110.0 39 | LockedInPosition= False 40 | Scope = 0 41 | TextColor = &c007AFF00 42 | TextFont = "" 43 | TextSize = 0 44 | Top = 339.0 45 | Visible = True 46 | Width = 100.0 47 | End 48 | End 49 | #tag EndIOSView 50 | 51 | #tag WindowCode 52 | #tag Note, Name = Change navigationBar color 53 | 54 | https://forum.xojo.com/18202-navigationbar-color 55 | 56 | Richard Berglund 5 hours ago Beta Testers 57 | Hi, 58 | 59 | With the help from Jim Mckay. Changing the color of the NavigationBar. 60 | 61 | Private Function UIColor(c as Color) As Ptr 62 | // returns a Ptr to a new Uicolor Created from a Xojo Color 63 | declare function colorFromRGBA lib UIKit selector "colorWithRed:green:blue:alpha:" (id as Ptr, red as Single, green as Single, blue as Single, alpha as Single) as Ptr 64 | dim r as single = c.red/255 65 | dim g as single = c.Green/255 66 | dim b as single = c.Blue/255 67 | dim a as single = (255 - c.Alpha) / 255 68 | 69 | return colorFromRGBA(NSClassFromString ("UIColor"), r, g, b, a) 70 | End Function 71 | 72 | declare function NSClassFromString lib "Foundation" (classname as CFStringRef) as ptr 73 | declare function keyWindow lib "UIKit" selector "keyWindow" (obj_ref as ptr) as ptr 74 | declare function sharedApplication lib "UIKit" selector "sharedApplication" (obj_ref as ptr) as ptr 75 | declare function rootViewController lib "UIKit" selector "rootViewController" (obj_ref as ptr) as ptr 76 | declare function navigationBar lib "UIKit" selector "navigationBar" (obj_ref as ptr) as ptr 77 | 78 | dim sApp as ptr=sharedApplication(NSClassFromString("UIApplication")) 79 | dim currentWindow as ptr=keyWindow(sApp) 80 | dim navController as ptr=rootViewController(currentWindow) 81 | dim navBar as ptr= navigationBar(navController) 82 | 83 | Declare Sub setBarTintColor lib UIKit selector "setBarTintColor:" (id as ptr, UIColor as Ptr) 84 | setBarTintColor navBar, UIColor(&cFF0000) 85 | 86 | declare Sub setTintColor lib UIKit selector "setTintColor:" (id as ptr, UIColor as Ptr) 87 | setTintColor navBar, UIColor(&cFF7700) 88 | 89 | declare sub setTranslucent lib UIKit selector "setTranslucent:" (id as ptr) 90 | setTranslucent navBar 91 | You can set it to translucent or solid by excluding setTranslucent. 92 | 93 | For changing the text color for the top text. I'm still trying to figure out. 94 | 95 | let titleDict: NSDictionary = [NSForegroundColorAttributeName: UIColor.whiteColor()] 96 | self.navigationController.navigationBar.titleTextAttributes = titleDict 97 | 98 | or 99 | [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}]; 100 | #tag EndNote 101 | 102 | 103 | #tag EndWindowCode 104 | 105 | #tag Events Button1 106 | #tag Event 107 | Sub Action() 108 | declare function NSClassFromString lib "Foundation" (classname as CFStringRef) as ptr 109 | declare function keyWindow lib "UIKit" selector "keyWindow" (obj_ref as ptr) as ptr 110 | declare function sharedApplication lib "UIKit" selector "sharedApplication" (obj_ref as ptr) as ptr 111 | declare function rootViewController lib "UIKit" selector "rootViewController" (obj_ref as ptr) as ptr 112 | declare function navigationBar lib "UIKit" selector "navigationBar" (obj_ref as ptr) as ptr 113 | 114 | dim sApp as ptr=sharedApplication(NSClassFromString("UIApplication")) 115 | dim currentWindow as ptr=keyWindow(sApp) 116 | dim navController as ptr=rootViewController(currentWindow) 117 | dim navBar as ptr= navigationBar(navController) 118 | 119 | Declare Sub setBarTintColor lib UIKit selector "setBarTintColor:" (id as ptr, UIColor as Ptr) 120 | setBarTintColor navBar, UIColor(&cFF0000) 121 | 122 | declare Sub setTintColor lib UIKit selector "setTintColor:" (id as ptr, UIColor as Ptr) 123 | setTintColor navBar, UIColor(&cFF7700) 124 | 125 | declare sub setTranslucent lib UIKit selector "setTranslucent:" (id as ptr) 126 | setTranslucent navBar 127 | End Sub 128 | #tag EndEvent 129 | #tag EndEvents 130 | -------------------------------------------------------------------------------- /SetNavigationBarColor.xojo_code: -------------------------------------------------------------------------------- 1 | #tag IOSView 2 | Begin iosView SetNavigationBarColor 3 | BackButtonTitle = "Back" 4 | Compatibility = "" 5 | Left = 0 6 | NavigationBarVisible= True 7 | TabTitle = "" 8 | Title = "Color me" 9 | Top = 0 10 | Begin iOSTextArea TextArea1 11 | AccessibilityHint= "" 12 | AccessibilityLabel= "" 13 | AutoLayout = TextArea1, 8, , 0, False, +1.00, 1, 1, 200, 14 | AutoLayout = TextArea1, 2, , 2, False, +1.00, 1, 1, 0, 15 | AutoLayout = TextArea1, 1, , 1, False, +1.00, 1, 1, 0, 16 | AutoLayout = TextArea1, 3, , 3, False, +1.00, 1, 1, 87, 17 | Editable = True 18 | Height = 200.0 19 | KeyboardType = "0" 20 | Left = 0 21 | LockedInPosition= False 22 | Scope = 0 23 | Text = "For more information, see the note attached to this view\n" 24 | TextAlignment = "0" 25 | TextColor = &c00000000 26 | TextFont = "" 27 | TextSize = 0 28 | Top = 87 29 | Visible = True 30 | Width = 320.0 31 | End 32 | Begin iOSButton Button1 33 | AccessibilityHint= "" 34 | AccessibilityLabel= "" 35 | AutoLayout = Button1, 8, , 0, False, +1.00, 1, 1, 30, 36 | AutoLayout = Button1, 9, , 9, False, +1.00, 1, 1, 0, 37 | AutoLayout = Button1, 7, , 0, False, +1.00, 1, 1, 100, 38 | AutoLayout = Button1, 3, , 3, False, +1.00, 1, 1, 306, 39 | Caption = "Color in Red" 40 | Enabled = True 41 | Height = 30.0 42 | Left = 110 43 | LockedInPosition= False 44 | Scope = 0 45 | TextColor = &c007AFF00 46 | TextFont = "" 47 | TextSize = 0 48 | Top = 306 49 | Visible = True 50 | Width = 100.0 51 | End 52 | Begin iOSButton Button2 53 | AccessibilityHint= "" 54 | AccessibilityLabel= "" 55 | AutoLayout = Button2, 8, , 0, False, +1.00, 1, 1, 30, 56 | AutoLayout = Button2, 9, , 9, False, +1.00, 1, 1, 0, 57 | AutoLayout = Button2, 7, , 0, False, +1.00, 1, 1, 130, 58 | AutoLayout = Button2, 3, Button1, 4, False, +1.00, 1, 1, *kStdControlGapV, 59 | Caption = "For tabbed view" 60 | Enabled = True 61 | Height = 30.0 62 | Left = 95 63 | LockedInPosition= False 64 | Scope = 0 65 | TextColor = &c007AFF00 66 | TextFont = "" 67 | TextSize = 0 68 | Top = 344 69 | Visible = False 70 | Width = 130.0 71 | End 72 | End 73 | #tag EndIOSView 74 | 75 | #tag WindowCode 76 | #tag Event 77 | Sub Open() 78 | 'app.ShowStatusBar(self) 79 | End Sub 80 | #tag EndEvent 81 | 82 | 83 | #tag Note, Name = Change navigationBar color 84 | 85 | https://forum.xojo.com/18202-navigationbar-color 86 | 87 | Richard Berglund 5 hours ago Beta Testers 88 | Hi, 89 | 90 | With the help from Jim Mckay. Changing the color of the NavigationBar. 91 | 92 | Private Function UIColor(c as Color) As Ptr 93 | // returns a Ptr to a new Uicolor Created from a Xojo Color 94 | declare function colorFromRGBA lib UIKit selector "colorWithRed:green:blue:alpha:" (id as Ptr, red as Single, green as Single, blue as Single, alpha as Single) as Ptr 95 | dim r as single = c.red/255 96 | dim g as single = c.Green/255 97 | dim b as single = c.Blue/255 98 | dim a as single = (255 - c.Alpha) / 255 99 | 100 | return colorFromRGBA(NSClassFromString ("UIColor"), r, g, b, a) 101 | End Function 102 | 103 | declare function NSClassFromString lib "Foundation" (classname as CFStringRef) as ptr 104 | declare function keyWindow lib "UIKit" selector "keyWindow" (obj_ref as ptr) as ptr 105 | declare function sharedApplication lib "UIKit" selector "sharedApplication" (obj_ref as ptr) as ptr 106 | declare function rootViewController lib "UIKit" selector "rootViewController" (obj_ref as ptr) as ptr 107 | declare function navigationBar lib "UIKit" selector "navigationBar" (obj_ref as ptr) as ptr 108 | 109 | dim sApp as ptr=sharedApplication(NSClassFromString("UIApplication")) 110 | dim currentWindow as ptr=keyWindow(sApp) 111 | dim navController as ptr=rootViewController(currentWindow) 112 | dim navBar as ptr= navigationBar(navController) 113 | 114 | Declare Sub setBarTintColor lib UIKit selector "setBarTintColor:" (id as ptr, UIColor as Ptr) 115 | setBarTintColor navBar, UIColor(&cFF0000) 116 | 117 | declare Sub setTintColor lib UIKit selector "setTintColor:" (id as ptr, UIColor as Ptr) 118 | setTintColor navBar, UIColor(&cFF7700) 119 | 120 | declare sub setTranslucent lib UIKit selector "setTranslucent:" (id as ptr) 121 | setTranslucent navBar 122 | You can set it to translucent or solid by excluding setTranslucent. 123 | 124 | For changing the text color for the top text. I'm still trying to figure out. 125 | 126 | let titleDict: NSDictionary = [NSForegroundColorAttributeName: UIColor.whiteColor()] 127 | self.navigationController.navigationBar.titleTextAttributes = titleDict 128 | 129 | or 130 | [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}]; 131 | #tag EndNote 132 | 133 | 134 | #tag EndWindowCode 135 | 136 | #tag Events Button1 137 | #tag Event 138 | Sub Action() 139 | declare function NSClassFromString lib "Foundation" (classname as CFStringRef) as ptr 140 | declare function keyWindow lib "UIKit" selector "keyWindow" (obj_ref as ptr) as ptr 141 | declare function sharedApplication lib "UIKit" selector "sharedApplication" (obj_ref as ptr) as ptr 142 | declare function rootViewController lib "UIKit" selector "rootViewController" (obj_ref as ptr) as ptr 143 | declare function navigationBar lib "UIKit" selector "navigationBar" (obj_ref as ptr) as ptr 144 | 145 | dim sApp as ptr=sharedApplication(NSClassFromString("UIApplication")) 146 | dim currentWindow as ptr=keyWindow(sApp) 147 | dim navController as ptr=rootViewController(currentWindow) 148 | dim navBar as ptr= navigationBar(navController) 149 | 150 | Declare Sub setBarTintColor lib UIKit selector "setBarTintColor:" (id as ptr, UIColor as Ptr) 151 | setBarTintColor navBar, UIColor(&cFF0000) 152 | 153 | declare Sub setTintColor lib UIKit selector "setTintColor:" (id as ptr, UIColor as Ptr) 154 | setTintColor navBar, UIColor(&cFF7700) 155 | 156 | declare sub setTranslucent lib UIKit selector "setTranslucent:" (id as ptr) 157 | setTranslucent navBar 158 | End Sub 159 | #tag EndEvent 160 | #tag EndEvents 161 | #tag Events Button2 162 | #tag Event 163 | Sub Action() 164 | // Use this code for view in a tabbed view setting 165 | 166 | declare function NSClassFromString lib "Foundation" (classname as CFStringRef) as ptr 167 | declare function keyWindow lib "UIKit" selector "keyWindow" (obj_ref as ptr) as ptr 168 | declare function sharedApplication lib "UIKit" selector "sharedApplication" (obj_ref as ptr) as ptr 169 | declare function rootViewController lib "UIKit" selector "rootViewController" (obj_ref as ptr) as ptr 170 | declare function navigationBar lib "UIKit" selector "navigationBar" (obj_ref as ptr) as ptr 171 | 172 | declare function navigationController lib "UIKit" selector "navigationController" (viewController as ptr) as ptr 173 | dim navigationControllerRef as ptr = navigationController(self.ViewControllerHandle) //self is the iOSView 174 | 175 | dim navigationBarRef as ptr = navigationBar(navigationControllerRef) 176 | 177 | dim sApp as ptr=sharedApplication(NSClassFromString("UIApplication")) 178 | dim currentWindow as ptr=keyWindow(sApp) 179 | dim navController as ptr=rootViewController(currentWindow) 180 | dim navBar as ptr= navigationBar(navigationControllerRef) 181 | 182 | 183 | 184 | Declare Sub setBarTintColor lib UIKit selector "setBarTintColor:" (id as ptr, UIColor as Ptr) 185 | setBarTintColor navBar, UIColor(&cFF0000) 186 | 187 | declare Sub setTintColor lib UIKit selector "setTintColor:" (id as ptr, UIColor as Ptr) 188 | setTintColor navBar, UIColor(&cFF7700) 189 | 190 | declare sub setTranslucent lib UIKit selector "setTranslucent:" (id as ptr) 191 | setTranslucent navBar 192 | 193 | 194 | End Sub 195 | #tag EndEvent 196 | #tag EndEvents 197 | #tag ViewBehavior 198 | #tag ViewProperty 199 | Name="BackButtonTitle" 200 | Group="Behavior" 201 | Type="Text" 202 | EditorType="MultiLineEditor" 203 | #tag EndViewProperty 204 | #tag ViewProperty 205 | Name="Index" 206 | Visible=true 207 | Group="ID" 208 | InitialValue="-2147483648" 209 | Type="Integer" 210 | #tag EndViewProperty 211 | #tag ViewProperty 212 | Name="Left" 213 | Visible=true 214 | Group="Position" 215 | InitialValue="0" 216 | Type="Integer" 217 | #tag EndViewProperty 218 | #tag ViewProperty 219 | Name="Name" 220 | Visible=true 221 | Group="ID" 222 | Type="String" 223 | #tag EndViewProperty 224 | #tag ViewProperty 225 | Name="NavigationBarVisible" 226 | Group="Behavior" 227 | Type="Boolean" 228 | #tag EndViewProperty 229 | #tag ViewProperty 230 | Name="Super" 231 | Visible=true 232 | Group="ID" 233 | Type="String" 234 | #tag EndViewProperty 235 | #tag ViewProperty 236 | Name="TabTitle" 237 | Group="Behavior" 238 | Type="Text" 239 | #tag EndViewProperty 240 | #tag ViewProperty 241 | Name="Title" 242 | Group="Behavior" 243 | Type="Text" 244 | EditorType="MultiLineEditor" 245 | #tag EndViewProperty 246 | #tag ViewProperty 247 | Name="Top" 248 | Visible=true 249 | Group="Position" 250 | InitialValue="0" 251 | Type="Integer" 252 | #tag EndViewProperty 253 | #tag EndViewBehavior 254 | -------------------------------------------------------------------------------- /UITableView.xojo_code.obsolete_20150105_005525: -------------------------------------------------------------------------------- 1 | #tag Class 2 | Protected Class UITableView 3 | Inherits iosTable 4 | #tag Method, Flags = &h21 5 | Private Function BackgroundView(id as ptr) As ptr 6 | Declare Function backgroundView lib UIKit Selector "backgroundView" (id as ptr) as ptr 7 | return backgroundView (id) 8 | 9 | End Function 10 | #tag EndMethod 11 | 12 | #tag Method, Flags = &h21 13 | Private Function cellForIndexPath(IndexPath as Ptr) As Ptr 14 | // Returns a Table cell 15 | 16 | declare Function cellForRowAtIndexPath lib UIKit selector "cellForRowAtIndexPath:" (id as ptr, indexpath as ptr)as ptr 17 | return cellForRowAtIndexPath (handle, IndexPath) 18 | End Function 19 | #tag EndMethod 20 | 21 | #tag Method, Flags = &h21 22 | Private Function ClearColor() As Ptr 23 | // Returns a Clear NSColor 24 | 25 | declare function clearColor lib UIKit selector "clearColor" (id as Ptr) as Ptr 26 | return clearColor(NSClassFromString ("UIColor")) 27 | 28 | 29 | End Function 30 | #tag EndMethod 31 | 32 | #tag Method, Flags = &h21 33 | Private Function ContentView(id as ptr) As ptr 34 | // Returns the contentview of an object 35 | 36 | Declare Function contentView_ lib UIKit selector "contentView" (id as ptr) as ptr 37 | return contentView_ (id) 38 | End Function 39 | #tag EndMethod 40 | 41 | #tag Method, Flags = &h21 42 | Private Function Count(id as ptr) As UInteger 43 | Declare Function count_ lib Foundation selector "count" (id as ptr) as UInteger 44 | return count_ (id) 45 | End Function 46 | #tag EndMethod 47 | 48 | #tag Method, Flags = &h21 49 | Private Function getBackgroundColor(id as ptr) As Ptr 50 | declare Function backgroundColor_ lib UIKit selector "backgroundColor" (id as ptr) as Ptr 51 | Return backgroundColor_ (id) 52 | End Function 53 | #tag EndMethod 54 | 55 | #tag Method, Flags = &h21 56 | Private Function IndexPath(row as integer, section as integer) As Ptr 57 | // Creates an indexpath 58 | 59 | // declare function initWithIndex lib UIKit selector "initWithIndex:" (id as ptr, index as uinteger) as ptr 60 | declare Function indexPathForRow lib UIKit selector "indexPathForRow:inSection:" (id as ptr, row as Integer, Section as Integer) as ptr 61 | 62 | return indexPathForRow (IndexPathClass, row, section) 63 | End Function 64 | #tag EndMethod 65 | 66 | #tag Method, Flags = &h21 67 | Private Function IndexPath(Index as UInteger) As Ptr 68 | // Creates an indexpath 69 | 70 | // declare function initWithIndex lib UIKit selector "initWithIndex:" (id as ptr, index as uinteger) as ptr 71 | declare function indexPathWithIndex lib UIKit selector "indexPathWithIndex:" (id as ptr, index as uinteger) as ptr 72 | 73 | return indexPathWithIndex (IndexPathClass, index) 74 | End Function 75 | #tag EndMethod 76 | 77 | #tag Method, Flags = &h0 78 | Function layer(id as ptr) As ptr 79 | Declare function layer_ lib UIKit selector "layer" (id as ptr) as ptr 80 | return layer_ (id) 81 | End Function 82 | #tag EndMethod 83 | 84 | #tag Method, Flags = &h0 85 | Sub MakeVisibleCellsTransparent() 86 | for q as UInteger = 0 to count(visibleCells) -1 87 | dim cell as ptr = objectAtIndex (visibleCells, q) 88 | setBackgroundColor cell, ClearColor 89 | next 90 | End Sub 91 | #tag EndMethod 92 | 93 | #tag ExternalMethod, Flags = &h21 94 | Private Declare Function NSAllocateObject Lib Foundation (aClass as Ptr, extraBytes as UInteger = 0, zone as ptr = NIL) As Ptr 95 | #tag EndExternalMethod 96 | 97 | #tag ExternalMethod, Flags = &h0 98 | Declare Function NSClassFromString Lib Foundation (aClassName as CFStringRef) As Ptr 99 | #tag EndExternalMethod 100 | 101 | #tag Method, Flags = &h21 102 | Private Function objectAtIndex(id as ptr, index as UInteger) As Ptr 103 | Declare Function objectAtIndex_ lib Foundation selector "objectAtIndex:" (id as ptr, index as uinteger) as Ptr 104 | return objectAtIndex_ (id, index) 105 | End Function 106 | #tag EndMethod 107 | 108 | #tag Method, Flags = &h21 109 | Private Sub setAlpha(id as ptr, alpha as single) 110 | declare Sub setAlpha lib UIKit selector "setAlpha:" (id as ptr, alpha as single) 111 | setAlpha id, alpha 112 | End Sub 113 | #tag EndMethod 114 | 115 | #tag Method, Flags = &h21 116 | Private Sub setBackgroundColor(id as ptr, UIColor as Ptr) 117 | declare Sub setBackgroundColor_ lib UIKit selector "setBackgroundColor:" (id as ptr, UIColor as Ptr) 118 | setBackgroundColor_ id, UIColor 119 | End Sub 120 | #tag EndMethod 121 | 122 | #tag Method, Flags = &h21 123 | Private Sub setOpacity(id as ptr, alpha as single) 124 | declare Sub setOpacity_ lib UIKit selector "setOpacity:" (id as ptr, alpha as single) 125 | setOpacity_ id, alpha 126 | End Sub 127 | #tag EndMethod 128 | 129 | #tag Method, Flags = &h21 130 | Private Sub setOpaque(id as ptr, value as boolean) 131 | declare Sub setOpaque_ lib UIKit selector "setOpaque:" (id as ptr, value as boolean) 132 | setOpaque_ id, value 133 | End Sub 134 | #tag EndMethod 135 | 136 | 137 | #tag ComputedProperty, Flags = &h0 138 | #tag Setter 139 | Set 140 | // for q as uinteger = 0 to me.RowCount(0) -1 141 | // dim index as ptr = indexpath(q, 0) 142 | // dim cell as ptr= cellForIndexPath(index) 143 | // dim contentview as ptr = ContentView (cell) 144 | // setAlpha contentview, value 145 | // dim background as ptr = BackgroundView (contentview) 146 | // next 147 | 148 | // for q as UInteger = 0 to count(visibleCells) -1 149 | // dim cell as ptr = objectAtIndex (visibleCells, q) 150 | // dim contentview as ptr = ContentView (cell) 151 | // setAlpha contentview,value 152 | // dim layer as ptr = layer(contentview) 153 | // setOpacity layer, value 154 | // next 155 | 156 | dim bg as Ptr = BackgroundView 157 | setAlpha BackgroundView, value 158 | setOpaque BackgroundView, false 159 | // setBackgroundColor handle, ClearNSColor 160 | End Set 161 | #tag EndSetter 162 | Alpha As single 163 | #tag EndComputedProperty 164 | 165 | #tag ComputedProperty, Flags = &h0 166 | #tag Getter 167 | Get 168 | return BackgroundView (handle) 169 | End Get 170 | #tag EndGetter 171 | #tag Setter 172 | Set 173 | Declare Sub setBackgroundView lib UIKit Selector "setBackgroundView:" (id as ptr, value as ptr) 174 | setBackgroundView handle, value 175 | 176 | End Set 177 | #tag EndSetter 178 | Attributes( hidden ) BackgroundView As Ptr 179 | #tag EndComputedProperty 180 | 181 | #tag ComputedProperty, Flags = &h21 182 | #tag Getter 183 | Get 184 | if mIndexPathClass = nil then mIndexPathClass = NSClassFromString("NSIndexPath") 185 | return mIndexPathClass 186 | End Get 187 | #tag EndGetter 188 | Private IndexPathClass As Ptr 189 | #tag EndComputedProperty 190 | 191 | #tag Property, Flags = &h21 192 | Private mIndexPathClass As Ptr 193 | #tag EndProperty 194 | 195 | #tag ComputedProperty, Flags = &h0 196 | #tag Getter 197 | Get 198 | Declare Function rowHeight lib UIKit Selector "rowHeight" (id as ptr) as single 199 | return rowHeight (handle) 200 | 201 | End Get 202 | #tag EndGetter 203 | #tag Setter 204 | Set 205 | Declare Sub setRowHeight lib UIKit Selector "setRowHeight:" (id as ptr, value as single) 206 | setrowHeight handle, value 207 | 208 | End Set 209 | #tag EndSetter 210 | RowHeight As Single 211 | #tag EndComputedProperty 212 | 213 | #tag ComputedProperty, Flags = &h0 214 | #tag Getter 215 | Get 216 | return getbackgroundColor (handle) = ClearColor 217 | End Get 218 | #tag EndGetter 219 | #tag Setter 220 | Set 221 | if value then setBackgroundColor handle, ClearColor 222 | End Set 223 | #tag EndSetter 224 | TransparentTable As Boolean 225 | #tag EndComputedProperty 226 | 227 | #tag ComputedProperty, Flags = &h21 228 | #tag Getter 229 | Get 230 | // Returns a NSArray of the visible cells 231 | 232 | Declare Function visibleCells lib UIKit selector "visibleCells" (id as ptr) as ptr 233 | return visibleCells (handle) 234 | End Get 235 | #tag EndGetter 236 | Private visibleCells As Ptr 237 | #tag EndComputedProperty 238 | 239 | 240 | #tag Constant, Name = Foundation, Type = Text, Dynamic = False, Default = \"foundation.framework", Scope = Private 241 | #tag EndConstant 242 | 243 | #tag Constant, Name = UIKit, Type = Text, Dynamic = False, Default = \"UIKit", Scope = Public 244 | #tag EndConstant 245 | 246 | 247 | #tag ViewBehavior 248 | #tag ViewProperty 249 | Name="AccessibilityHint" 250 | Group="Behavior" 251 | Type="Text" 252 | #tag EndViewProperty 253 | #tag ViewProperty 254 | Name="AccessibilityLabel" 255 | Group="Behavior" 256 | Type="Text" 257 | #tag EndViewProperty 258 | #tag ViewProperty 259 | Name="Alpha" 260 | Group="Behavior" 261 | Type="single" 262 | #tag EndViewProperty 263 | #tag ViewProperty 264 | Name="Format" 265 | Visible=true 266 | Group="Behavior" 267 | Type="iOSTable.Formats" 268 | EditorType="Enum" 269 | #tag EnumValues 270 | "0 - Plain" 271 | "1 - Grouped" 272 | #tag EndEnumValues 273 | #tag EndViewProperty 274 | #tag ViewProperty 275 | Name="Height" 276 | Visible=true 277 | Group="Position" 278 | Type="Double" 279 | #tag EndViewProperty 280 | #tag ViewProperty 281 | Name="Index" 282 | Visible=true 283 | Group="ID" 284 | InitialValue="-2147483648" 285 | Type="Integer" 286 | #tag EndViewProperty 287 | #tag ViewProperty 288 | Name="Left" 289 | Visible=true 290 | Group="Position" 291 | InitialValue="0" 292 | Type="Integer" 293 | #tag EndViewProperty 294 | #tag ViewProperty 295 | Name="Name" 296 | Visible=true 297 | Group="ID" 298 | Type="String" 299 | #tag EndViewProperty 300 | #tag ViewProperty 301 | Name="RowHeight" 302 | Group="Behavior" 303 | Type="Single" 304 | #tag EndViewProperty 305 | #tag ViewProperty 306 | Name="SectionCount" 307 | Group="Behavior" 308 | Type="Integer" 309 | #tag EndViewProperty 310 | #tag ViewProperty 311 | Name="Super" 312 | Visible=true 313 | Group="ID" 314 | Type="String" 315 | #tag EndViewProperty 316 | #tag ViewProperty 317 | Name="Top" 318 | Visible=true 319 | Group="Position" 320 | InitialValue="0" 321 | Type="Integer" 322 | #tag EndViewProperty 323 | #tag ViewProperty 324 | Name="TransparentTable" 325 | Group="Behavior" 326 | Type="Boolean" 327 | #tag EndViewProperty 328 | #tag ViewProperty 329 | Name="Visible" 330 | Visible=true 331 | Group="Behavior" 332 | Type="Boolean" 333 | #tag EndViewProperty 334 | #tag ViewProperty 335 | Name="Width" 336 | Visible=true 337 | Group="Position" 338 | Type="Double" 339 | #tag EndViewProperty 340 | #tag EndViewBehavior 341 | End Class 342 | #tag EndClass 343 | -------------------------------------------------------------------------------- /Wrapper.xojo_code: -------------------------------------------------------------------------------- 1 | #tag Module 2 | Protected Module Wrapper 3 | #tag Method, Flags = &h0 4 | Function asc(s as text) As Integer 5 | 6 | 7 | if s.Length > 1 then 8 | s = s.Left(1) 9 | end if 10 | 11 | For Each codePoint As UInt32 In s.Codepoints 12 | return codepoint 13 | Next 14 | 15 | 16 | End Function 17 | #tag EndMethod 18 | 19 | #tag Method, Flags = &h0 20 | Sub Backdrop(extends b As iOSButton, assigns backdrop as iOSImage) 21 | 'This method was posted by Jim McKay in the https://forum.xojo.com/18184-button-and-view-colours-ios/last thread 22 | 'on 12/12/2014 23 | 24 | declare sub setBackgroundImage lib "UIKit" selector "setBackgroundImage:forState:" (obj as ptr, value as ptr, state as integer) 25 | setBackgroundImage(b.Handle,backdrop.Handle,0) 26 | 27 | //For use : iOSButton.Backdrop = Pic 28 | 29 | End Sub 30 | #tag EndMethod 31 | 32 | #tag Method, Flags = &h0 33 | Sub BackGroundColor(extends UIView as iOSControl, assigns Clr as Color) 34 | 35 | Declare Function NSClassFromString Lib "Foundation" (className As CFStringRef) As Ptr 36 | Declare Function colorWithRGBA Lib "UIKit" Selector "colorWithRed:green:blue:alpha:" ( _ 37 | UIColorClassRef As Ptr, red As CGFloat, green As CGFloat, blue As CGFloat, alpha As CGFloat) As Ptr 38 | Declare Function view Lib "UIKit" Selector "view" (UIViewController As Ptr) As Ptr 39 | Declare Sub setBackgroundColor Lib "UIKit" Selector "setBackgroundColor:" (UIView As Ptr, UIColor As Ptr) 40 | 41 | Dim UIColorClassPtr As Ptr = NSClassFromString("UIColor") 42 | Dim colorPtr As ptr = colorWithRGBA(UIColorClassPtr, (Clr.Red / 255), (Clr.Green / 255), (Clr.Blue / 255), 1-(Clr.Alpha/255)) 43 | Dim viewPtr As Ptr = UIView.Handle 44 | setBackgroundColor(viewPtr, colorPtr) 45 | End Sub 46 | #tag EndMethod 47 | 48 | #tag Method, Flags = &h0 49 | Function boolToText(extends variable as boolean) As Text 50 | return If(variable, "True", "False") 51 | End Function 52 | #tag EndMethod 53 | 54 | #tag Method, Flags = &h0 55 | Function Cdbl(Number as Text) As Double 56 | return double.FromText(Number) 57 | 58 | End Function 59 | #tag EndMethod 60 | 61 | #tag Method, Flags = &h0 62 | Function chr(c as integer) As Text 63 | return Text.FromUnicodeCodepoint(c) 64 | End Function 65 | #tag EndMethod 66 | 67 | #tag Method, Flags = &h0 68 | Sub ClearFocus(extends c As iOSControl) 69 | declare sub resignFirstResponder lib "Foundation.Framework" selector "resignFirstResponder" (obj_id as Ptr) 70 | 71 | resignFirstResponder(c.handle) 72 | End Sub 73 | #tag EndMethod 74 | 75 | #tag Method, Flags = &h0 76 | Function decodeBase64(aText as text) As Text 77 | 'By Jason King 78 | 'Function decodeBase64(aText as text) As Text 79 | declare function initWithBase64EncodedString lib FoundationLib selector "initWithBase64EncodedString:options:" _ 80 | (obj_id as ptr, str as CFStringRef, options as Integer) as ptr 81 | declare function alloc lib FoundationLib selector "alloc" (clsRef as ptr) as ptr 82 | declare function NSClassFromString lib FoundationLib (clsName as CFStringRef) as ptr 83 | 84 | dim mData as ptr = initWithBase64EncodedString(alloc(NSClassFromString("NSData")), aText, 1) 85 | 86 | const NSUTF8StringEncoding = 4 87 | 88 | declare function initWithData lib FoundationLib selector "initWithData:encoding:" (obj_id as ptr, data as ptr, encoding as Integer) as CFStringRef 89 | Return initWithData(alloc(NSClassFromString("NSString")), mData, NSUTF8StringEncoding) 90 | 'End Function 91 | End Function 92 | #tag EndMethod 93 | 94 | #tag Method, Flags = &h0 95 | Function encodeBase64(extends mb as MemoryBlock) As Text 96 | 'From Phillip Zedalis 97 | 'Function EncodeBase64(Extends t As Text) As Text 98 | Declare Function dataWithBytes Lib "UIKit" Selector "dataWithBytes:length:" (class_id As Ptr, bytes As Ptr, length As UInt32) As Ptr 99 | Declare Function base64EncodedStringWithOptions Lib "UIKit" Selector "base64EncodedStringWithOptions:" (class_id As Ptr, options As UInt32) As CFStringRef 100 | 101 | // Create NSData pointer to be point of reference. 102 | Dim data As Ptr 103 | data = NSClassFromString("NSData") 104 | 105 | '// Create global ASCII TextEncoding 106 | 'Dim te As Xojo.Core.TextEncoding 107 | 'te = Xojo.Core.TextEncoding.FromIANAName("ISO-8859-1") 108 | ' 109 | '// Convert Text to MemoryBlock 110 | 'Dim tmb As Xojo.Core.MemoryBlock 111 | 'tmb = te.ConvertTextToData(t) 112 | 113 | // Create NSData object using MemoryBlock 114 | Dim dataRef as Ptr = dataWithBytes(data, mb.Data, mb.Size) 115 | 116 | // Create Text object to hold Base64 encoded string. 117 | Dim x As Text 118 | x = base64EncodedStringWithOptions(dataRef, 0) 119 | 120 | // Return Base64 encoded string 121 | Return x 122 | 'End Function 123 | End Function 124 | #tag EndMethod 125 | 126 | #tag Method, Flags = &h0 127 | Function EncodeBase64(Extends t As Text) As Text 128 | 'From Phillip Zedalis 129 | 'Function EncodeBase64(Extends t As Text) As Text 130 | Declare Function dataWithBytes Lib "UIKit" Selector "dataWithBytes:length:" (class_id As Ptr, bytes As Ptr, length As UInt32) As Ptr 131 | Declare Function base64EncodedStringWithOptions Lib "UIKit" Selector "base64EncodedStringWithOptions:" (class_id As Ptr, options As UInt32) As CFStringRef 132 | 133 | // Create NSData pointer to be point of reference. 134 | Dim data As Ptr 135 | data = NSClassFromString("NSData") 136 | 137 | // Create global ASCII TextEncoding 138 | Dim te As Xojo.Core.TextEncoding 139 | te = Xojo.Core.TextEncoding.FromIANAName("ISO-8859-1") 140 | 141 | // Convert Text to MemoryBlock 142 | Dim tmb As Xojo.Core.MemoryBlock 143 | tmb = te.ConvertTextToData(t) 144 | 145 | // Create NSData object using MemoryBlock 146 | Dim dataRef as Ptr = dataWithBytes(data, tmb.Data, tmb.Size) 147 | 148 | // Create Text object to hold Base64 encoded string. 149 | Dim x As Text 150 | x = base64EncodedStringWithOptions(dataRef, 0) 151 | 152 | // Return Base64 encoded string 153 | Return x 154 | 'End Function 155 | End Function 156 | #tag EndMethod 157 | 158 | #tag Method, Flags = &h0 159 | Function encodeBase64_2(aText as Text) As Text 160 | 'By Jason King 161 | 'Function encodeBase64(aText as Text) As Text 162 | declare function dataUsingEncoding lib FoundationLib selector "dataUsingEncoding:" (obj_id as ptr, encoding as Integer) as ptr 163 | declare function stringWithString lib FoundationLib selector "stringWithString:" (obj_id as ptr, str as CFStringRef) as ptr 164 | declare function NSClassFromString lib FoundationLib (clsName as CFStringRef) as ptr 165 | 166 | const NSUTF8StringEncoding = 4 167 | dim str as Ptr = stringWithString(NSClassFromString("NSString"), aText) 168 | dim mData as ptr = dataUsingEncoding(str,NSUTF8StringEncoding) 169 | 170 | declare function base64EncodedStringWithOptions lib FoundationLib selector "base64EncodedStringWithOptions:" _ 171 | (obj_id as ptr, options as Integer) as CFStringRef 172 | 173 | Return base64EncodedStringWithOptions(mData,1) 174 | 'End Function 175 | End Function 176 | #tag EndMethod 177 | 178 | #tag Method, Flags = &h0 179 | Function EncodeURLComponent(value as text) As text 180 | 181 | Declare Function CFURLCreateStringByAddingPercentEscapes lib "Foundation" (allocator as Ptr, origString as CFStringRef , charactersToLeaveUnescaped as CFStringRef , legalURLCharactersToBeEscaped as cfStringRef,encoding as uint32) as CFStringRef 182 | 183 | return CFURLCreateStringByAddingPercentEscapes(nil, value, nil, nil, &h08000100) 184 | 185 | End Function 186 | #tag EndMethod 187 | 188 | #tag Method, Flags = &h0 189 | Function FindType(extends au as Auto) As Text 190 | 'Function FindType(extends au as Auto) As Text 191 | dim oTypeInfo as xojo.Introspection.TypeInfo = Xojo.Introspection.GetType(au) 192 | 193 | return oTypeInfo.FullName 194 | 'End Function 195 | End Function 196 | #tag EndMethod 197 | 198 | #tag Method, Flags = &h0 199 | Function getAppVersion() As Text 200 | 'Function getAppVersion() As Text 201 | declare function NSClassFromString lib FoundationLib (clsName as CFStringRef) as ptr 202 | declare function mainBundle lib FoundationLib selector "mainBundle" (clsRef as ptr) as ptr 203 | declare function objectForInfoDictionaryKey lib FoundationLib selector "objectForInfoDictionaryKey:" _ 204 | (obj_id as ptr, key as CFStringRef) as CFStringRef 205 | 206 | Return objectForInfoDictionaryKey(mainBundle(NSClassFromString("NSBundle")), "CFBundleShortVersionString") 207 | 'End Function 208 | End Function 209 | #tag EndMethod 210 | 211 | #tag Method, Flags = &h0 212 | Function getGUID() As Text 213 | 214 | declare function NSClassFromString lib "Foundation" (clsName as cfstringref) as ptr 215 | dim UIDevicePtr as ptr = NSClassFromString("UIDevice") 216 | declare function currentDevice lib "UIKit" selector "currentDevice" (clsRef as ptr) as ptr 217 | dim currentDevicePtr as ptr = currentDevice(UIDevicePtr) 218 | 219 | declare function identifierForVendor lib "UIKit" selector "identifierForVendor" (obj_id as ptr) as ptr 220 | dim NSUUIDPtr as ptr = identifierForVendor(currentDevicePtr) 221 | 222 | declare function UUIDString lib "Foundation" selector "UUIDString" (obj_id as ptr) as cfstringref 223 | dim GUID as Text = UUIDString(NSUUIDPtr) 224 | 225 | return GUID 226 | 227 | End Function 228 | #tag EndMethod 229 | 230 | #tag Method, Flags = &h0 231 | Sub goTabPage(idx as integer, doReset as Boolean = False) 232 | 'This method has been posted in the forum by Antonio Rinaldi. 233 | 'It allows setting the active tab like if the user had tapped himself on the tab icon, without need for PushTo. 234 | 'Index is zero based, left to right 235 | 236 | 237 | 238 | 'Sub goTabPage(idx as integer,doReset as Boolean=False) 239 | if idx<0 then Return 240 | Declare Function NSClassFromString lib "Foundation"(cls as CFStringRef) as Ptr 241 | Declare function sharedApplication_ lib "UIKit" selector "sharedApplication"(cls_ptr as Ptr) as Ptr 242 | dim shAppPtr as Ptr=sharedApplication_(NSClassFromString("UIApplication")) 243 | 244 | Declare function keyWindow_ lib "UIkit" selector "keyWindow"(app_ptr as Ptr) as Ptr 245 | dim keyWinPtr as Ptr=keyWindow_(shAppPtr) 246 | 247 | Declare Function rootWiewController_ lib "UIKit" selector "rootViewController"(winPtr as Ptr) as Ptr 248 | dim rootWiewControllerPtr as Ptr=rootWiewController_(keyWinPtr) 249 | 250 | Declare Function isMemberOfClass_ lib "foundation" selector "isMemberOfClass:"(oPtr as Ptr,cPtr as Ptr) as Boolean 251 | dim a as ptr=NSClassFromString("UITabBarController") 252 | if isMemberOfClass_(rootWiewControllerPtr,NSClassFromString("UITabBarController")) then 253 | Declare sub setSelectedIndex lib "UIKIT" selector "setSelectedIndex:"(tbPtr as Ptr,page as UInteger) 254 | setSelectedIndex(rootWiewControllerPtr,idx) 255 | 256 | if doReset then 257 | Declare Function selectedViewController_ lib "UIKIT" selector "selectedViewController"(oPtr as ptr) as Ptr 258 | dim navPtr as Ptr=selectedViewController_(rootWiewControllerPtr) 259 | Declare Sub popToRoot lib "UIKIT" selector "popToRootViewControllerAnimated:"(oPtr as Ptr,animated as Boolean) 260 | popToRoot(navPtr,true) 261 | end if 262 | end if 263 | 'End Sub 264 | End Sub 265 | #tag EndMethod 266 | 267 | #tag Method, Flags = &h0 268 | Sub hideTabBar(v as iOSView, slf as iOSView) 269 | ' This method was posted by Paul Lefebvre at https://forum.xojo.com/18176-controlling-tab-bar-visibility/last 270 | ' on 12/12/2014 271 | 272 | 'To hide the tabbar for a view, call as such : 273 | 'Dim v As New View1 274 | 'hideTabBar(v, Self) 275 | 276 | // @property(nonatomic) BOOL hidesBottomBarWhenPushed 277 | 278 | Declare Sub setHidesBottomBarWhenPushed Lib "UIKit" _ 279 | Selector "setHidesBottomBarWhenPushed:" (id As Ptr, value As Boolean) 280 | 281 | setHidesBottomBarWhenPushed(v.Handle, True) 282 | 283 | Slf.PushTo(v) 284 | 285 | // To reinstate the tab bar, close the pushed view. 286 | End Sub 287 | #tag EndMethod 288 | 289 | #tag Method, Flags = &h0 290 | Function Instr(Texte as Text, Cherche as Text) As Integer 291 | Return Texte.IndexOf(Cherche) 292 | 293 | End Function 294 | #tag EndMethod 295 | 296 | #tag Method, Flags = &h0 297 | Function isFirstResponder(extends c As iOSControl) As Boolean 298 | declare function isFirstResponder lib "Foundation.Framework" selector "isFirstResponder" (obj_id as Ptr) as boolean 299 | 300 | Return isFirstResponder(c.handle) 301 | End Function 302 | #tag EndMethod 303 | 304 | #tag Method, Flags = &h0 305 | Function Left(T as text, count as integer) As Text 306 | if count > 0 then 307 | if count > t.length then 308 | count = t.length 309 | end if 310 | return t.Left(count) 311 | end if 312 | End Function 313 | #tag EndMethod 314 | 315 | #tag Method, Flags = &h0 316 | Function len(t as Text) As Integer 317 | return t.length 318 | End Function 319 | #tag EndMethod 320 | 321 | #tag Method, Flags = &h0 322 | Function LenB(Extends T as Text) As Integer 323 | 324 | const allowLossy as boolean = True 325 | Return TextEncoding.UTF8.ConvertTextToData(T, allowLossy).Size 326 | End Function 327 | #tag EndMethod 328 | 329 | #tag Method, Flags = &h0 330 | Function LenB(T as Text) As Integer 331 | 332 | const allowLossy as boolean = True 333 | Return TextEncoding.UTF8.ConvertTextToData(T, allowLossy).Size 334 | End Function 335 | #tag EndMethod 336 | 337 | #tag Method, Flags = &h0 338 | Function MainScreenScale() As Double 339 | //Jim McKay Retina detection 340 | 341 | 'Function MainScreenScale() As Double 342 | //declare function NSClassFromString lib "Foundation.Framework" (aClassName as CFStringRef) as Ptr 343 | declare function NSClassFromString lib "Foundation" (aClassName as CFStringRef) as Ptr 344 | soft declare function scale lib "UIKit" selector "scale" (classRef as Ptr) as single 345 | soft declare function mainScreen lib "UIKit" selector "mainScreen" (classRef as Ptr) as ptr 346 | 347 | 348 | return scale(mainScreen(NSClassFromString("UIScreen"))) 349 | 350 | 351 | 'End Function 352 | End Function 353 | #tag EndMethod 354 | 355 | #tag Method, Flags = &h0 356 | Sub MaxWidth() 357 | declare sub setAdjustsFontSizeToFitWidth lib "Foundation" selector "setAdjustsFontSizeToFitWidth:" (obj as ptr,value as Boolean) 358 | 'setAdjustsFontSizeToFitWidth(Label1.Handle,true) 359 | End Sub 360 | #tag EndMethod 361 | 362 | #tag Method, Flags = &h0 363 | Function MD5(extends t as Text) As Text 364 | 'Antonio Rinaldi 2/14/2015 365 | 'https://forum.xojo.com/20012-md5-on-text/0#p167800 366 | 367 | 'Function MD5(extends t as Text) As Text 368 | dim a As MemoryBlock = TextEncoding.UTF8.ConvertTextToData(t) 369 | dim b As MemoryBlock = Xojo.Crypto.MD5(a) 370 | dim v() as Text 371 | dim n as UInteger=b.Size-1 372 | for i as UInteger=0 to n 373 | v.Append b.UInt8Value(i).ToHex(2) 374 | next 375 | return text.Join(v,"") 376 | 'End Function 377 | End Function 378 | #tag EndMethod 379 | 380 | #tag Method, Flags = &h0 381 | Function Mid(T as Text, start as Integer, lengt as integer) As Text 382 | if lengt > 0 then 383 | if lengt > T.Length then lengt = t.Length 384 | return T.Mid(start-1, lengt) 385 | end if 386 | End Function 387 | #tag EndMethod 388 | 389 | #tag Method, Flags = &h0 390 | Sub Msgbox(s as text) 391 | dim m as new iOSMessageBox 392 | 393 | dim buttons() as text 394 | buttons.Append("OK") 395 | m.Buttons = buttons 396 | m.Message = s 397 | m.Show 398 | 399 | End Sub 400 | #tag EndMethod 401 | 402 | #tag ExternalMethod, Flags = &h0 403 | Declare Function NSClassFromString Lib Foundation (aClassName as CFStringRef) As Ptr 404 | #tag EndExternalMethod 405 | 406 | #tag Method, Flags = &h0 407 | Function NthField(txt as Text, delimiter as Text, index as integer) As Text 408 | Dim parts() as Text = txt.split(delimiter) 409 | Return parts(index-1) 410 | 411 | End Function 412 | #tag EndMethod 413 | 414 | #tag Method, Flags = &h0 415 | Function Pixel(extends g as iOSGraphics, x as integer, y as integer) As Color 416 | 'Jason King 417 | 'It works on both iOSGraphics and iOSImage. Just call img.Pixel(x,y) or g.Pixel(x,y) to get the color at the specified position. Enjoy! 418 | 419 | 420 | const UIKitLib = "UIKit.framework" 421 | const CoreGraphicsLib = "CoreGraphics.framework" 422 | const FoundationLib = "Foundation.framework" 423 | 424 | declare function CGBitmapContextCreateImage lib CoreGraphicsLib (context as ptr) as ptr 425 | dim cgimageref as ptr = CGBitmapContextCreateImage(g.Handle) 426 | 427 | declare function imageWithCGImage lib UIKitLib selector "imageWithCGImage:" (clsRef as ptr, img as ptr) as ptr 428 | declare function NSClassFromString lib FoundationLib (clsName as CFStringRef) as ptr 429 | dim newUIImage as ptr = imageWithCGImage(NSClassFromString("UIImage"), cgimageref) 430 | 431 | Return iOSImage.FromHandle(newUIImage).Pixel(x,y) 432 | 433 | End Function 434 | #tag EndMethod 435 | 436 | #tag Method, Flags = &h0 437 | Function Pixel(extends img as iosImage, x as integer, y as integer) As Color 438 | 'Jason King 439 | 'It works on both iOSGraphics and iOSImage. Just call img.Pixel(x,y) or g.Pixel(x,y) to get the color at the specified position. Enjoy! 440 | 441 | const CoreGraphicsLib = "CoreGraphics.framework" 442 | const UIKitLib = "UIKit.framework" 443 | const CoreFoundationLib = "CoreFoundation.framework" 444 | 445 | 446 | if x>img.Width or y>img.Height or x<0 or y<0 then 447 | dim e as new OutOfBoundsException 448 | e.Reason = "The pixel location must be within the bounds of the picture" 449 | Raise e 450 | end if 451 | 452 | declare function CGImage lib UIKitLib selector "CGImage" (obj_id as ptr) as ptr 453 | dim CGImageRef as ptr = CGImage(img.Handle) 454 | 455 | declare function CGImageGetDataProvider lib CoreGraphicsLib (cgimage as ptr) as ptr 456 | dim dataProvider as ptr = CGImageGetDataProvider(CGImageRef) 457 | 458 | declare function CGDataProviderCopyData lib CoreGraphicsLib (provider as ptr) as ptr 459 | dim pixelData as ptr = CGDataProviderCopyData(dataProvider) 460 | 461 | declare function CFDataGetBytePtr lib CoreFoundationLib (dataref as ptr) as Ptr 462 | dim dataMB as xojo.core.MemoryBlock = new xojo.Core.MemoryBlock(CFDataGetBytePtr(pixelData)) 463 | 464 | dim numberOfComponents as Integer = 4 //PNG is RGBA 465 | dim startPoint as Integer = ((img.Width*y)+x)*numberOfComponents 466 | 467 | dim r, g, b, a as UInt8 468 | b = dataMB.UInt8Value(startPoint) 469 | g = dataMB.UInt8Value(startPoint+1) 470 | r = dataMB.UInt8Value(startPoint+2) 471 | a = 255-dataMB.UInt8Value(startPoint+3) 472 | 473 | declare sub CFRelease lib CoreFoundationLib (obj_id as ptr) 474 | CFRelease(pixelData) 475 | 476 | Return Color.RGBA(r,g,b,a) 477 | End Function 478 | #tag EndMethod 479 | 480 | #tag Method, Flags = &h0 481 | Function redColor() As Ptr 482 | 'From 483 | 'Private Function RedColor() As Ptr 484 | // Returns a red NSColor 485 | 486 | declare function redColor lib UIKit selector "redColor" (id as Ptr) as Ptr 487 | return redColor(NSClassFromString ("UIColor")) 488 | End Function 489 | #tag EndMethod 490 | 491 | #tag Method, Flags = &h0 492 | Function Right(T as text, count as integer) As Text 493 | if count > 0 then 494 | if count > t.length then 495 | count = t.length 496 | end if 497 | return t.Right(count) 498 | end if 499 | End Function 500 | #tag EndMethod 501 | 502 | #tag Method, Flags = &h0 503 | Sub SaveToCameraRoll(extends img as iOSImage) 504 | 'Jason King 505 | 'Just saw this conversation - its entirely possible with declares. Just pop this short function into a module and call it like "img.SaveToCameraRoll" 506 | 507 | 'Sub SaveToCameraRoll(extends img as iOSImage) 508 | declare sub UIImageWriteToSavedPhotosAlbum lib "UIKit" (img as ptr, target as ptr, sel as ptr, info as ptr) 509 | UIImageWriteToSavedPhotosAlbum(img.Handle,nil,nil,nil) 510 | 'End Sub 511 | End Sub 512 | #tag EndMethod 513 | 514 | #tag Method, Flags = &h0 515 | Sub setBackgroundRoundedRectangle(extends b As iOSButton, back As color, border as color, radius as double) 516 | 'This method was posted by Jim McKay in the https://forum.xojo.com/18184-button-and-view-colours-ios/last thread 517 | 'on 12/12/2014 518 | 519 | declare sub setBackgroundImage lib "UIKit" selector "setBackgroundImage:forState:" (obj as ptr, value as ptr, state as integer) 520 | 521 | radius=min(radius,min(b.Width,b.Height)/2-.01) 522 | 523 | dim pth As new iOSPath 524 | pth.AddRoundRect(0,0,b.width,b.height,radius,radius) 525 | 526 | dim p as new iOSBitmap(b.Width,b.Height,1) 527 | p.Graphics.LineColor=border 528 | p.Graphics.FillColor=back 529 | p.Graphics.LineWidth=1 530 | p.Graphics.FillPath(pth) 531 | p.Graphics.DrawPath(pth) 532 | 533 | dim i As iOSImage=p.Image 534 | setBackgroundImage(b.Handle,i.Handle,0) 535 | 536 | End Sub 537 | #tag EndMethod 538 | 539 | #tag Method, Flags = &h0 540 | Sub SetFocus(extends c As iOSControl) 541 | declare sub becomeFirstResponder lib "Foundation.Framework" selector "becomeFirstResponder" (obj_id as Ptr) 542 | 543 | becomeFirstResponder(c.handle) 544 | End Sub 545 | #tag EndMethod 546 | 547 | #tag Method, Flags = &h0 548 | Sub setSeparatorColor(id as ptr, UIColor as Ptr) 549 | ' By Richard Berglund 550 | 551 | 'Private Sub setSeparatorColor(id as ptr, UIColor as Ptr) 552 | declare Sub setSeparatorColor lib UIKit selector "setSeparatorColor:" (id as ptr, UIColor as Ptr) 553 | setSeparatorColor id, UIColor 554 | 555 | 'End Sub 556 | End Sub 557 | #tag EndMethod 558 | 559 | #tag Method, Flags = &h0 560 | Sub SetSeparatorStyle(myIOSTable as iOSTable, Style as integer) 561 | ' From Antonio Rinaldi 562 | ' Style = 0 no line. 1 = ndefault 563 | declare sub setSeparatorStyle lib "UIKit" selector "setSeparatorStyle:"(o as ptr,mode as integer) 564 | 'setSeparatorStyle(myIOSTable.handle,0) 565 | setSeparatorStyle(myIOSTable.handle,Style) 566 | End Sub 567 | #tag EndMethod 568 | 569 | #tag Method, Flags = &h0 570 | Function ShowURL(url As Text) As Boolean 571 | // NSString* launchUrl = @"http://www.xojo.com/"; 572 | // [[UIApplication sharedApplication] openURL:[NSURL URLWithString: launchUrl]]; 573 | 574 | Declare Function NSClassFromString Lib "Foundation" (name As CFStringRef) As Ptr 575 | Declare Function sharedApplication Lib "UIKit" Selector "sharedApplication" (obj As Ptr) As Ptr 576 | Dim sharedApp As Ptr = sharedApplication(NSClassFromString("UIApplication")) 577 | 578 | // https://developer.apple.com/library/mac/documentation/UIKit/Reference/Foundation/Classes/NSURL_Class/#//apple_ref/occ/clm/NSURL/URLWithString: 579 | Declare Function URLWithString Lib "Foundation" Selector "URLWithString:" ( id As Ptr, URLString As CFStringRef ) As Ptr 580 | Dim nsURL As Ptr = URLWithString(NSClassFromString("NSURL"), url) 581 | 582 | // https://developer.apple.com/Library/ios/documentation/UIKit/Reference/UIApplication_Class/index.html#//apple_ref/occ/instm/UIApplication/openURL: 583 | Declare Function openURL Lib "UIKit" Selector "openURL:" (id As Ptr, nsurl As Ptr) As Boolean 584 | Return openURL(sharedApp, nsURL) 585 | 586 | End Function 587 | #tag EndMethod 588 | 589 | #tag Method, Flags = &h0 590 | Function split(s as text, delimiter as text) As text() 591 | return s.split(delimiter) 592 | 593 | End Function 594 | #tag EndMethod 595 | 596 | #tag Method, Flags = &h0 597 | Function Str(Value as Auto) As Text 598 | Dim info As Xojo.Introspection.TypeInfo 599 | info = Xojo.Introspection.GetType(Value) 600 | system.debuglog info.Name 601 | 602 | if info.Name = "Color" then 603 | dim c as color = Value 604 | return "&c"+c.Red.toHex(2) + _ 605 | c.Green.toHex(2) + _ 606 | c.Blue.toHex(2) + _ 607 | c.Alpha.toHex(2) 608 | elseif info.name = "Int32" or info.name = "Int64" or info.name = "UInt32" or info.name = "Int64" then 609 | dim v as Int64 = value 610 | Return v.ToText 611 | elseif info.name = "Single" or info.name = "Double"then 612 | dim v as double = value 613 | Return v.ToText 614 | elseif info.name = "Date" then 615 | dim d as date = value 616 | Return d.Totext 617 | elseif info.name = "Boolean" then 618 | dim b as Boolean= Value 619 | if b then 620 | Return "True" 621 | else 622 | Return "False" 623 | end if 624 | end if 625 | 626 | End Function 627 | #tag EndMethod 628 | 629 | #tag Method, Flags = &h0 630 | Function StripAccents(T as Text) As Text 631 | //From Eli Ott, in https://forum.xojo.com/29028-textencodings-to-remove-accented-characters 632 | Declare Function dataUsingEncoding Lib "Foundation" Selector "dataUsingEncoding:allowLossyConversion:" _ 633 | (NSString As CFStringRef, NSStringEncoding As UInteger, allowLossyConversion As Boolean) As Ptr 634 | Declare Function NSClassFromString Lib "Foundation" (className As CFStringRef) As Ptr 635 | Declare Function alloc Lib "Foundation" Selector "alloc" (NSClass As Ptr) As Ptr 636 | Declare Function initWithData Lib "Foundation" Selector "initWithData:encoding:" _ 637 | (NSClass As Ptr, NSData As Ptr, NSStringEncoding As UInteger) As CFStringRef 638 | 639 | Const NSASCIIStringEncoding = 1 640 | 641 | //Dim t As Text = "áéíóúàèìòùäëïöüãõÁÉÍÓÚÀÈÌÒÙÄËÏÖÜÃÕç" 642 | 643 | Dim data As Ptr = dataUsingEncoding(t, NSASCIIStringEncoding, True) 644 | Dim result As CFStringRef = initWithData(alloc(NSClassFromString("NSString")), data, NSASCIIStringEncoding) 645 | 646 | Return Result 647 | 648 | End Function 649 | #tag EndMethod 650 | 651 | #tag Method, Flags = &h0 652 | Function TextValue(extends a as Auto) As Text 653 | 'This method has been created by Brock Nash 654 | 'Function TextValue(extends a as Auto) As text 655 | Dim info As Xojo.Introspection.TypeInfo = Xojo.Introspection.GetType(a) 656 | 657 | #if TargetDesktop or TargetWeb then 658 | if info.Name = "string" then 659 | return CType(a, string).totext 660 | elseif info.name = "variant" then 661 | dim v as Variant = a 662 | return v.TextValue 663 | end 664 | #endif 665 | Select Case info.Name 666 | Case "Integer" 667 | return CType(a, Integer).totext 668 | Case "Int8" 669 | return CType(a, Int8).totext 670 | Case "UInt8" 671 | return CType(a, UInt8).totext 672 | Case "UInt16" 673 | return CType(a, UInt16).totext 674 | Case "UInt32" 675 | return CType(a, UInt32).totext 676 | Case "UInt64" 677 | return CType(a, UInt64).totext 678 | Case "Short" 679 | return CType(a, Short).totext 680 | Case "Byte" 681 | return CType(a, Byte).totext 682 | Case "Int32" 683 | return CType(a, Int32).totext 684 | Case "Int64" 685 | return CType(a, Int64).totext 686 | Case "text" 687 | dim t as text = a 688 | return t 689 | Case "Double" 690 | return CType(a, Double).totext 691 | Else 692 | return "" 693 | end 694 | 695 | 'End Function 696 | End Function 697 | #tag EndMethod 698 | 699 | #tag Method, Flags = &h0 700 | Function Transparent(Extends Img as iOSImage) As iOSImage 701 | dim pic as new iOSBitmap(img.width, img.height, 1, False) 702 | 703 | for x as integer = 0 to img.width 704 | for y as integer = 0 to img.height 705 | if img.Pixel(x,y) <> &c00000000 then 706 | pic.Graphics.AntiAlias = False 707 | pic.graphics.LineColor = img.pixel(x,y) 708 | pic.Graphics.LineWidth = 1 709 | pic.Graphics.DrawLine(x,y,x+1,y) 710 | end if 711 | next 712 | next 713 | 714 | return pic.Image 715 | End Function 716 | #tag EndMethod 717 | 718 | #tag Method, Flags = &h0 719 | Function TrueView(CC as iOSContainerControl) As iOSView 720 | Return iOSView(App.CurrentScreen.Content) 721 | End Function 722 | #tag EndMethod 723 | 724 | #tag Method, Flags = &h0 725 | Function TrueView(CC as iOSControl) As iOSView 726 | Return iOSView(App.CurrentScreen.Content) 727 | End Function 728 | #tag EndMethod 729 | 730 | #tag Method, Flags = &h0 731 | Function TrueWindow(CC as iOSContainerControl) As iOSView 732 | Return iOSView(App.CurrentScreen.Content) 733 | End Function 734 | #tag EndMethod 735 | 736 | #tag Method, Flags = &h0 737 | Function TrueWindow(CC as iOSControl) As iOSView 738 | Return iOSView(App.CurrentScreen.Content) 739 | End Function 740 | #tag EndMethod 741 | 742 | #tag Method, Flags = &h0 743 | Function UIColor(c as Color) As Ptr 744 | // returns a Ptr to a new Uicolor Created from a Xojo Color 745 | declare function colorFromRGBA lib UIKit selector "colorWithRed:green:blue:alpha:" (id as Ptr, red as Single, green as Single, blue as Single, alpha as Single) as Ptr 746 | dim r as single = c.red/255 747 | dim g as single = c.Green/255 748 | dim b as single = c.Blue/255 749 | dim a as single = (255 - c.Alpha) / 255 750 | 751 | return colorFromRGBA(NSClassFromString ("UIColor"), r, g, b, a) 752 | 753 | 754 | End Function 755 | #tag EndMethod 756 | 757 | #tag Method, Flags = &h0 758 | Function Val(T as Text) As Double 759 | Return Double.FromText(T) 760 | End Function 761 | #tag EndMethod 762 | 763 | 764 | #tag Note, Name = Posts in the forum and tips 765 | 766 | 12/12/2014 767 | 768 | jim mckay 1 minute ago Beta Testers, Xojo Pro 769 | Here's a method to add a round rect to an iOSButton 770 | 771 | Sub setColor(extends b As iOSButton, back As color, border as color, radius as double) 772 | declare sub setBackgroundImage lib "UIKit" selector "setBackgroundImage:forState:" (obj as ptr, value as ptr, state as integer) 773 | 774 | radius=min(radius,min(b.Width,b.Height)/2-.01) 775 | 776 | dim pth As new iOSPath 777 | pth.AddRoundRect(0,0,b.width,b.height,radius,radius) 778 | 779 | dim p as new iOSBitmap(b.Width,b.Height,1) 780 | p.Graphics.LineColor=border 781 | p.Graphics.FillColor=back 782 | p.Graphics.LineWidth=1 783 | p.Graphics.FillPath(pth) 784 | p.Graphics.DrawPath(pth) 785 | 786 | dim i As iOSImage=p.Image 787 | setBackgroundImage(b.Handle,i.Handle,0) 788 | End Sub 789 | 790 | ----------------------------------- 791 | 792 | https://forum.xojo.com/18176-controlling-tab-bar-visibility/0#p151660 793 | 794 | Paul Lefebvre 11 hours ago Xojo Inc United States (Maine) 795 | Seems like this might work: 796 | 797 | // @property(nonatomic) BOOL hidesBottomBarWhenPushed 798 | 799 | Dim v As New View3 800 | 801 | Declare Sub setHidesBottomBarWhenPushed Lib "UIKit" _ 802 | Selector "setHidesBottomBarWhenPushed:" (id As Ptr, value As Boolean) 803 | 804 | setHidesBottomBarWhenPushed(v.Handle, True) 805 | 806 | Self.PushTo(v) 807 | 808 | --- 809 | 810 | To reinstate the tab, use self.close. 811 | 812 | --------- 813 | #tag EndNote 814 | 815 | #tag Note, Name = Present view modal 816 | 817 | Jason King is not verified 5 hours ago 2015/2/6 818 | I don't know if this will help you any, but you can present the new view modally and it won't have a toolbar at all. You would then have to add your own cancel and done buttons (since it doesn't seem possible to use the Navigationbar for modal views) but it would eliminate the back arrow problem. To present a view modally: 819 | 820 | declare sub presentViewController_ lib UIKitLib selector "presentViewController:animated:completion:" (obj_id as ptr, viewControllerToPresent as ptr, flag as Boolean, completion as ptr) 821 | //newView is an instance of iOSView which is the new view you want to present modally, self is the iOSView you want to cover up (what you would normally call self.PushTo() from to display newView 822 | PresentViewController_(self.ViewControllerHandle, newView.ViewControllerHandle, True, nil) 823 | To dismiss that view: 824 | 825 | declare sub dismissModalViewController lib UIKitLib selector "dismissViewControllerAnimated:completion:" _ 826 | (obj_id as ptr, animated as Boolean, completion as ptr) 827 | //self is the parent iOSView, not the view you presented modally 828 | //you may want to keep a reference to the parent iOSView in the modally presented view so that you can dismiss the modal view from within itself (i.e. by a button) 829 | dismissModalViewController(self.ViewControllerHandle, True, Nil) 830 | 831 | #tag EndNote 832 | 833 | #tag Note, Name = Untitled 834 | 835 | 836 | #tag EndNote 837 | 838 | 839 | #tag ComputedProperty, Flags = &h0 840 | #tag Getter 841 | Get 842 | return &u0D+&u0A 843 | 844 | End Get 845 | #tag EndGetter 846 | EndOfLine As Text 847 | #tag EndComputedProperty 848 | 849 | 850 | #tag Constant, Name = Foundation, Type = Text, Dynamic = False, Default = \"foundation.framework", Scope = Public 851 | #tag EndConstant 852 | 853 | #tag Constant, Name = FoundationLib, Type = Text, Dynamic = False, Default = \"foundation.framework", Scope = Public 854 | #tag EndConstant 855 | 856 | #tag Constant, Name = UIKit, Type = Text, Dynamic = False, Default = \"UIKit", Scope = Public 857 | #tag EndConstant 858 | 859 | #tag Constant, Name = WrFoundationLib, Type = Text, Dynamic = False, Default = \"foundation.framework", Scope = Public 860 | #tag EndConstant 861 | 862 | 863 | #tag ViewBehavior 864 | #tag ViewProperty 865 | Name="EndOfLine" 866 | Group="Behavior" 867 | Type="Text" 868 | #tag EndViewProperty 869 | #tag ViewProperty 870 | Name="Index" 871 | Visible=true 872 | Group="ID" 873 | InitialValue="-2147483648" 874 | Type="Integer" 875 | #tag EndViewProperty 876 | #tag ViewProperty 877 | Name="Left" 878 | Visible=true 879 | Group="Position" 880 | InitialValue="0" 881 | Type="Integer" 882 | #tag EndViewProperty 883 | #tag ViewProperty 884 | Name="Name" 885 | Visible=true 886 | Group="ID" 887 | Type="String" 888 | #tag EndViewProperty 889 | #tag ViewProperty 890 | Name="Super" 891 | Visible=true 892 | Group="ID" 893 | Type="String" 894 | #tag EndViewProperty 895 | #tag ViewProperty 896 | Name="Top" 897 | Visible=true 898 | Group="Position" 899 | InitialValue="0" 900 | Type="Integer" 901 | #tag EndViewProperty 902 | #tag EndViewBehavior 903 | End Module 904 | #tag EndModule 905 | --------------------------------------------------------------------------------