1ccfcf0760
* NEW: The form editor has a new menu entry for transforming a control into another control. For example, a Label into a TextLabel, or a HBox into a VBox, and so on. The possible transformations are defined in the *.component file. * BUG: Compiler errors that are not related to the compiled code are now correctly displayed. * BUG: Locked forms are correctly loaded, and the form tab title now correctly shows the associated read-only state. * BUG: The automatic completion can deal with multiple local variable declarations on the same line now. [INTERPRETER] * BUG: Array.Insert() does not crash anymore if the inserted array is NULL. It raises an error now. [COMPILER] * BUG: The owner and group of all files generated by the compiler ('.startup', '.info', '.list', object files) are now set to the owner and group of the '.project' file. This way, any project can be safely compiled as root, without locking it for other users. git-svn-id: svn://localhost/gambas/trunk@1369 867c0c6c-44f3-4631-809d-bfa615b0a4ec
268 lines
4.4 KiB
Text
268 lines
4.4 KiB
Text
' Gambas class file
|
|
|
|
Static Private $hForm As FForm 'FForm
|
|
Static Private $cPict As New Collection
|
|
|
|
Private $bNoSelect As Boolean
|
|
|
|
Private Sub GetForm() As Boolean
|
|
|
|
$hForm = Null
|
|
Try $hForm = Project.ActiveForm
|
|
If Not $hForm Then
|
|
HideAll
|
|
Return True
|
|
Endif
|
|
|
|
End
|
|
|
|
|
|
Public Sub Form_Open()
|
|
|
|
ReadConfig
|
|
|
|
End
|
|
|
|
|
|
Public Sub Form_Show()
|
|
|
|
RefreshAll
|
|
|
|
End
|
|
|
|
|
|
Public Sub Form_Hide()
|
|
|
|
$hForm = Null
|
|
|
|
End
|
|
|
|
Static Public Sub GetControlIcon(sKind As String) As Picture
|
|
|
|
Dim sImg As String
|
|
Dim hPict As Picture
|
|
|
|
If sKind <> "Form" Then
|
|
sImg = ".control" &/ LCase(sKind)
|
|
Else
|
|
sImg = "img/32/form.png"
|
|
Endif
|
|
|
|
hPict = $cPict[sImg]
|
|
If Not hPict Then
|
|
hPict = Picture[sImg]
|
|
If Not hPict Then hPict = Picture["img/control/unknown.png"]
|
|
hPict = hPict.Image.Stretch(16, 16, True).Picture
|
|
$cPict[sImg] = hPict
|
|
Endif
|
|
|
|
Return hPict
|
|
|
|
End
|
|
|
|
|
|
|
|
Private Sub FillTree(hCtrl As CControl, Optional sParent As String)
|
|
|
|
Dim hChild As Control
|
|
Dim hTab As Object
|
|
Dim iTab As Integer
|
|
Dim sKey As String
|
|
Dim hPict As Picture
|
|
|
|
If Not hCtrl Then Return
|
|
|
|
If sParent Then
|
|
'sImg = "img/control/" & LCase(hCtrl.Kind) & ".png"
|
|
'sImg = ".control" &/ LCase(hCtrl.Kind)
|
|
hPict = GetControlIcon(hCtrl.Kind)
|
|
Else
|
|
hPict = Picture["img/16/form.png"]
|
|
'sImg = "img/32/form.png"
|
|
Endif
|
|
|
|
tvwControl.Add(hCtrl.Name, hCtrl.Name, hPict, sParent)
|
|
|
|
If Not hCtrl.IsContainer() Then Return
|
|
|
|
'IF hCtrl.Kind = "TabStrip" THEN
|
|
If hCtrl.IsMultiContainer() Then
|
|
|
|
hTab = hCtrl.Control
|
|
|
|
For iTab = 0 To hTab.Count - 1
|
|
sKey = hCtrl.Name & "." & iTab
|
|
tvwControl.Add(sKey, hTab[iTab].Text, GetControlIcon("TabStrip"), hCtrl.Name)
|
|
For Each hChild In hTab[iTab].Children
|
|
If Not hChild.Tag Then Continue
|
|
FillTree($hForm.Control[hChild.Tag], sKey)
|
|
Next
|
|
tvwControl[sKey].Expanded = True
|
|
Next
|
|
|
|
Else
|
|
|
|
For Each hChild In hCtrl.Control.Children
|
|
If Not hChild.Tag Then Continue
|
|
FillTree($hForm.Control[hChild.Tag], hCtrl.Name)
|
|
Next
|
|
|
|
Endif
|
|
|
|
tvwControl[hCtrl.Name].Expanded = True
|
|
|
|
End
|
|
|
|
Public Sub RefreshReadOnly()
|
|
|
|
If GetForm() Then Return
|
|
|
|
panControl.Visible = Not $hForm.ReadOnly
|
|
|
|
End
|
|
|
|
|
|
|
|
|
|
Public Sub RefreshAll(Optional sKey As String, Optional bForce As Boolean)
|
|
|
|
If Not Me.Visible Then Return
|
|
|
|
If GetForm() Then Return
|
|
|
|
'IF NOT Project.IsForm($hForm) THEN RETURN
|
|
|
|
If Not sKey Then
|
|
Try sKey = $hForm.Master.Name
|
|
Endif
|
|
|
|
If bForce Then $cPict.Clear
|
|
|
|
tvwControl.Clear
|
|
FillTree($hForm.Control[$hForm.Name])
|
|
tvwControl.Show
|
|
lblMessage.Hide
|
|
RefreshReadOnly
|
|
|
|
If sKey Then
|
|
Try tvwControl[sKey].Selected = True
|
|
Try tvwControl[sKey].EnsureVisible
|
|
Endif
|
|
|
|
$bNoSelect = False
|
|
|
|
End
|
|
|
|
Public Sub RefreshOne(sKey As String)
|
|
|
|
If Not Me.Visible Then Return
|
|
If GetForm() Then Return
|
|
|
|
tvwControl[sKey].Delete
|
|
FillTree($hForm.Control[sKey])
|
|
|
|
'TRY tvwControl[sKey].Selected = TRUE
|
|
'TRY tvwControl[sKey].EnsureVisible
|
|
|
|
End
|
|
|
|
|
|
Public Sub HideAll()
|
|
|
|
tvwControl.Hide
|
|
panControl.Hide
|
|
lblMessage.Show
|
|
|
|
End
|
|
|
|
|
|
|
|
|
|
Public Sub btnDown_Click()
|
|
|
|
Dim sKey As String
|
|
|
|
sKey = tvwControl.Key
|
|
Try $hForm.Control[tvwControl.Current.Text].MoveDown
|
|
If Error Then Return
|
|
RefreshAll(sKey)
|
|
|
|
End
|
|
|
|
Public Sub btnBottom_Click()
|
|
|
|
Dim sKey As String
|
|
|
|
sKey = tvwControl.Key
|
|
Try $hForm.Control[tvwControl.Current.Text].Raise
|
|
If Error Then Return
|
|
RefreshAll(sKey)
|
|
|
|
End
|
|
|
|
Public Sub btnTop_Click()
|
|
|
|
Dim sKey As String
|
|
|
|
sKey = tvwControl.Key
|
|
Try $hForm.Control[tvwControl.Current.Text].Lower
|
|
If Error Then Return
|
|
RefreshAll(sKey)
|
|
|
|
End
|
|
|
|
Public Sub btnUp_Click()
|
|
|
|
Dim sKey As String
|
|
|
|
sKey = tvwControl.Key
|
|
Try $hForm.Control[tvwControl.Current.Text].MoveUp
|
|
If Error Then Return
|
|
RefreshAll(sKey)
|
|
|
|
End
|
|
|
|
Public Sub Select(sName As String)
|
|
|
|
If tvwControl.Exist(sName) Then
|
|
Try tvwControl[sName].EnsureVisible
|
|
$bNoSelect = True
|
|
tvwControl[sName].Selected = True
|
|
$bNoSelect = False
|
|
Endif
|
|
|
|
End
|
|
|
|
|
|
Public Sub tvwControl_Select()
|
|
|
|
If Not $bNoSelect Then
|
|
If InStr(tvwControl.Current.Key, ".") Then
|
|
tvwControl.MoveParent
|
|
Try $hForm.SelectControl(tvwControl.Item.Text)
|
|
Else
|
|
Try $hForm.SelectControl(tvwControl.Current.Text)
|
|
Endif
|
|
Endif
|
|
|
|
End
|
|
|
|
Public Sub tvwControl_Collapse()
|
|
|
|
tvwControl.Item.Expanded = True
|
|
|
|
End
|
|
|
|
|
|
Public Sub ReadConfig()
|
|
|
|
tvwControl.Font.Grade = - Settings["/GlobalFont", 0]
|
|
RefreshAll
|
|
|
|
End
|
|
|
|
Public Sub tvwControl_Activate()
|
|
|
|
FMain.ActivatePropertyTab
|
|
|
|
End
|