diff --git a/comp/gb.term.form/.component b/comp/gb.term.form/.component index f2be9127b..2e143677b 100644 --- a/comp/gb.term.form/.component +++ b/comp/gb.term.form/.component @@ -1,6 +1,6 @@ [Component] Key=gb.term.form -Version=3.10.90 +Version=3.9.90 State=2 Authors=Fabien Bodard (gambas.fr@gmail.com) Needs=ImageIO diff --git a/comp/gb.term.form/.info b/comp/gb.term.form/.info index 72a812063..8c5d2cae0 100644 --- a/comp/gb.term.form/.info +++ b/comp/gb.term.form/.info @@ -647,6 +647,14 @@ _DefaultForeGround r i +_ClientHeight +r +i + +_ClientWidth +r +i + _AllowFocus v b @@ -842,6 +850,50 @@ Count r i +Text +r +s + +:Activate +: + + +:Change +: + + +EnsureVisible +m + + +_Render +m + + +_KeyPress +m + + +_MouseDown +m + + +_MouseUp +m + + +_MouseMove +m + + +_put +m + +(Value)s(Index)i +_get +m +s +(Index)i #TermPanel TermContainer C diff --git a/comp/gb.term.form/.project b/comp/gb.term.form/.project index cd777688d..61e74a01b 100644 --- a/comp/gb.term.form/.project +++ b/comp/gb.term.form/.project @@ -1,9 +1,9 @@ # Gambas Project File 3.0 -# Compiled with Gambas 3.10.90 -Startup=trfTest +# Compiled with Gambas 3.9.90 +Startup=FTest2 UseTerminal=1 RedirectStderr=1 -Version=3.10.90 +Version=3.9.90 VersionFile=1 Component=gb.image Component=gb.image.io diff --git a/comp/gb.term.form/.src/TermControl.class b/comp/gb.term.form/.src/TermControl.class index de2dd9fa0..f18eb4a49 100644 --- a/comp/gb.term.form/.src/TermControl.class +++ b/comp/gb.term.form/.src/TermControl.class @@ -34,6 +34,12 @@ Property Read HaveFocus As Boolean Property Read _DefaultBackground As Integer Property Read _DefaultForeGround As Integer +Property Read _ClientHeight As Integer +Property Read _ClientWidth As Integer + + + + Private $iColorMode As Integer Private $iBorder As Integer @@ -403,7 +409,7 @@ End Private Sub Foreground_Write(Value As Integer) - $iBackGround = Value + $iForeground = Value Me.Refresh End @@ -735,5 +741,14 @@ Private Function _DefaultForeGround_Read() As Integer End +Private Function _ClientHeight_Read() As Integer + Return $rectClient.Height +End + +Private Function _ClientWidth_Read() As Integer + + Return $rectClient.Width + +End diff --git a/comp/gb.term.form/.src/TermListBox.class b/comp/gb.term.form/.src/TermListBox.class index 4e5fbd45c..b983f0c1f 100644 --- a/comp/gb.term.form/.src/TermListBox.class +++ b/comp/gb.term.form/.src/TermListBox.class @@ -3,42 +3,174 @@ Export Inherits TermControl - Property List As String[] Property Index As Integer Property Read Count As Integer - +Property Read Text As String Private $iIndex As Integer Private $aList As New String[] - - +Private $iFirstVisible As Integer +Event Activate +Event Change +Class Rect Private Function List_Read() As String[] - - + Return $aList + End Private Sub List_Write(Value As String[]) - - + $aList = Value + End Private Function Index_Read() As Integer - - + Return $iIndex + End Private Sub Index_Write(Value As Integer) - - + $iIndex = Min($aList.Max, Max(0, Value)) + EnsureVisible + End Private Function Count_Read() As Integer - + Return $aList.Count + +End + +Public Sub _Render() + + Dim hAttr As New Attr + Dim iAttr, iAttr2 As Integer + Dim i, il, k, ilen As Integer + Dim s As String + Dim hRectC As Rect = Me._GetClientRect() + Dim hRect As Rect = Me._GetClientRect() +Dim iCursorPos As Integer + If Not Me._NeedRender Then Return + Super._Render + + hAttr.FillFrom(Me._Content[0][0].Attr) + + Swap hAttr.Background, hAttr.Foreground + iAttr = hAttr.GetInteger() + k = $iFirstVisible + For i = 0 To Me._Content.Max + If k > $aList.Max Then Break + s = $aList[k] + ilen = String.Len(s) + For il = 0 To IIf(k = $iIndex, hRect.width - 2, Min(hRect.width - 2, ilen)) + 'iAttr = Me._Content[i][il]. + If k = $iIndex Then Me._Content[i][il].Attr = iAttr + If il < ilen Then Me._Content[i][il].c = String.Code(String.Mid(s, il + 1, 1)) + Next + + Inc k + Next + + ilen = Me._Content[0].Max + 'Render the scrollbar + For i = 1 To Me._Content.Max - 2 + Me._Content[i][ilen].c = &H2591 + Next + Me._Content[0][ilen].c = &H25B2 + Me._Content[Me._Content.Max - 1][ilen].c = &H25BC + + hAttr.Foreground = TermColor.Black + iAttr = hAttr.GetInteger() + iCursorPos = ($iFirstVisible + hRect.height) / $aList.Count * (hRect.Height - 3) + Me._Content[iCursorPos][hRect.width - 1] = Char(String.Chr(&H2588), iAttr) + + + + Me._NeedRender = False +Fin: + +End + +Public Sub _KeyPress() + + Select Key.Code + Case Key.Up + Dec Me.Index + Raise Change + Case Key.Down + Inc Me.Index + Raise Change + Case Key.Return, Key.Enter + Raise Activate + + Default + + End Select + Super._KeyPress +End + +Public Sub _MouseDown() + + Super._MouseDown + Me.Index = $iFirstVisible + Mouse.Row + Raise Change + 'EnsureVisible +End + +Public Sub _MouseUp() + Super._MouseUp + Raise Activate + Raise Click + +End + +Public Sub _MouseMove() + Super._MouseMove + _MouseDown + +End + +Public Sub EnsureVisible() + + Dim hRect As Rect = Me._GetClientRect() + + If $iFirstVisible + (hRect.Height - 1) < $iIndex Then + $iFirstVisible = $iIndex - hRect.Height + 1 + Endif + If $iIndex < $iFirstVisible Then + $iFirstVisible = $iIndex + Endif + Me.Refresh + +End + + +Public Sub _put(Value As String, Index As Integer) + + $aList[Index] = Value + If IsVisible(Index) Then Me.Refresh +End + + +Public Function _get(Index As Integer) As String + + Return $aList[Index] + +End + + +Private Sub IsVisible(Index As Integer) As Boolean + + If Index >= $iFirstVisible And If Index < $iFirstVisible + Me._ClientHeight Then Return True + +End + +Private Function Text_Read() As String + + Return $aList[$iIndex] End diff --git a/comp/gb.term.form/.src/TermWindows.class b/comp/gb.term.form/.src/TermWindows.class index f8137f16e..f59524fbe 100644 --- a/comp/gb.term.form/.src/TermWindows.class +++ b/comp/gb.term.form/.src/TermWindows.class @@ -271,7 +271,7 @@ Static Public Sub File_Read() Endif i = 10 ipos2 = 10 - If String.InStr(S, "B") Then Stop +' If String.InStr(S, "B") Then Stop For Each ss In ["~", "A", "B", "C", "D", "H", "F", "P", "Q", "R", "S", "M", "Z"] i = InStr(s, ss, ipos) If i = 0 Then Continue diff --git a/comp/src/gb.term.form/.src/Test/FTest2.class b/comp/src/gb.term.form/.src/Test/FTest2.class new file mode 100644 index 000000000..ce6e8e0a6 --- /dev/null +++ b/comp/src/gb.term.form/.src/Test/FTest2.class @@ -0,0 +1,52 @@ +' Gambas class file + +Inherits TermForm +Private aList As New String[] +Private hTim As New Timer As "Tim" +Private hList As TermListBox +Private k As Integer + Private hLbl As TermLabel + +Public Sub _new() + Dim i As Integer +'aList = ["Chien", "Chat", "Eléphant", "Hiène", "Phoque", "Canard", "Hippoppo"] + Me.Spacing = 2 + + hList = New TermListBox(Me) As "ListBox1" + hLbl = New TermLabel(Me) + + For i = 1 To 200 + aList.Add("Item" & i) + Next + 'hList._Shadow = True + hList.List = aList + Me.Move(0, 0, 60, 20) + Me._Arrangement = Arrange.Vertical + hList.Move(1, 1, 3, 3) + 'Me._Arrangement = Arrange.Fill + hList.Expand = True + Me.Border = 1 + hList.Background = termColor.Blue + Me.Center + Me.Show + Me.Title = "Test 1" + hTim.Delay = 500 + hTim.Start + + hLbl.Background = TermColor.Green + hLbl.Foreground = TermColor.Black +End + + +Public Sub tim_Timer() + + hList[5] = k + Inc k +End + + +Public Sub ListBox1_Change() + + hLbl.Text = Last.Text + +End diff --git a/comp/gb.term.form/.src/Main.module b/comp/src/gb.term.form/.src/Test/Main.module similarity index 100% rename from comp/gb.term.form/.src/Main.module rename to comp/src/gb.term.form/.src/Test/Main.module diff --git a/comp/gb.term.form/.src/Main2.module b/comp/src/gb.term.form/.src/Test/Main2.module similarity index 100% rename from comp/gb.term.form/.src/Main2.module rename to comp/src/gb.term.form/.src/Test/Main2.module diff --git a/comp/gb.term.form/.src/Main3.module b/comp/src/gb.term.form/.src/Test/Main3.module similarity index 100% rename from comp/gb.term.form/.src/Main3.module rename to comp/src/gb.term.form/.src/Test/Main3.module diff --git a/comp/gb.term.form/.src/Module1.module b/comp/src/gb.term.form/.src/Test/Module1.module similarity index 100% rename from comp/gb.term.form/.src/Module1.module rename to comp/src/gb.term.form/.src/Test/Module1.module diff --git a/comp/gb.term.form/.src/trfTest.class b/comp/src/gb.term.form/.src/Test/trfTest.class similarity index 100% rename from comp/gb.term.form/.src/trfTest.class rename to comp/src/gb.term.form/.src/Test/trfTest.class diff --git a/comp/src/gb.term.form/.startup b/comp/src/gb.term.form/.startup new file mode 100644 index 000000000..c98521f14 --- /dev/null +++ b/comp/src/gb.term.form/.startup @@ -0,0 +1,10 @@ +FTest2 + +0 +0 +3.9.90 + +gb.image +gb.image.io +gb.term + diff --git a/gb.dbus/helper.c b/gb.dbus/helper.c index 8fa0eb65e..7d9c544d4 100644 --- a/gb.dbus/helper.c +++ b/gb.dbus/helper.c @@ -245,6 +245,7 @@ static char *array_from_dbus_type(const char *signature) if (type_contents != type) strcpy(type, type_contents); + GB.GetArrayClass(GB.FindClass(type)); strcat(type, "[]"); return type; } diff --git a/main/gbx/gbx_api.c b/main/gbx/gbx_api.c index fe7da0546..ce04db8d5 100644 --- a/main/gbx/gbx_api.c +++ b/main/gbx/gbx_api.c @@ -131,6 +131,7 @@ const void *const GAMBAS_Api[] = (void *)GB_ExistClassLocal, (void *)CLASS_find, (void *)GB_GetArrayType, + (void *)CLASS_get_array_class, (void *)GB_Is, (void *)GB_Ref, (void *)GB_Unref, diff --git a/main/share/gambas.h b/main/share/gambas.h index 47588d4cf..b7ec792c3 100644 --- a/main/share/gambas.h +++ b/main/share/gambas.h @@ -977,6 +977,7 @@ typedef bool (*ExistClassLocal)(const char *); GB_CLASS (*FindClassLocal)(const char *); GB_TYPE (*GetArrayType)(GB_CLASS); + GB_CLASS (*GetArrayClass)(GB_CLASS); bool (*Is)(void *, GB_CLASS); void (*Ref)(void *); void (*Unref)(void **);