[DEVELOPMENT ENVIRONMENT]

* NEW: Create a ProjectChooser control that can be shared between the 
  project open dialog and the patch wizard (for example).


git-svn-id: svn://localhost/gambas/trunk@5523 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2013-01-27 19:28:31 +00:00
parent 3ee9d91054
commit 1170daa9d7
6 changed files with 319 additions and 134 deletions

View file

@ -540,7 +540,7 @@ msgstr ""
#: FFontChooser.form:40 FForm.class:3091 FGotoLine.form:23 #: FFontChooser.form:40 FForm.class:3091 FGotoLine.form:23
#: FHelpBrowser.form:61 FIconEditor.class:1373 FList.form:121 FMain.class:209 #: FHelpBrowser.form:61 FIconEditor.class:1373 FList.form:121 FMain.class:209
#: FMakeInstall.class:350 FMenu.form:377 FNewConnection.form:255 #: FMakeInstall.class:350 FMenu.form:377 FNewConnection.form:255
#: FNewTable.form:86 FNewTranslation.form:21 FOpenProject.form:203 #: FNewTable.form:86 FNewTranslation.form:21 FOpenProject.form:158
#: FOption.class:674 FPasteSpecial.form:77 FPasteTable.form:107 #: FOption.class:674 FPasteSpecial.form:77 FPasteTable.form:107
#: FProjectProperty.form:687 FProjectVersion.class:201 #: FProjectProperty.form:687 FProjectVersion.class:201
#: FPropertyComponent.form:255 FProxy.form:57 FReportBorderChooser.form:48 #: FPropertyComponent.form:255 FProxy.form:57 FReportBorderChooser.form:48
@ -636,7 +636,7 @@ msgstr ""
#: FCreateFile.form:443 FFieldChooser.form:132 FFontChooser.form:34 #: FCreateFile.form:443 FFieldChooser.form:132 FFontChooser.form:34
#: FGotoLine.form:17 FInfo.form:172 FList.form:115 FMain.class:1798 #: FGotoLine.form:17 FInfo.form:172 FList.form:115 FMain.class:1798
#: FMakeInstall.class:299 FMenu.form:372 FNewConnection.form:249 #: FMakeInstall.class:299 FMenu.form:372 FNewConnection.form:249
#: FNewTable.form:80 FNewTranslation.form:15 FOpenProject.form:197 #: FNewTable.form:80 FNewTranslation.form:15 FOpenProject.form:152
#: FPasteSpecial.form:71 FProjectProperty.form:681 FPropertyComponent.form:249 #: FPasteSpecial.form:71 FProjectProperty.form:681 FPropertyComponent.form:249
#: FProxy.form:63 FReportBorderChooser.form:54 FReportBrushChooser.form:40 #: FProxy.form:63 FReportBorderChooser.form:54 FReportBrushChooser.form:40
#: FReportCoordChooser.form:32 FReportPaddingChooser.form:69 #: FReportCoordChooser.form:32 FReportPaddingChooser.form:69
@ -700,7 +700,7 @@ msgstr ""
msgid "Free" msgid "Free"
msgstr "" msgstr ""
#: FConflict.form:47 FOpenProject.form:46 #: FConflict.form:47 FOpenProject.form:40
msgid "Open" msgid "Open"
msgstr "" msgstr ""
@ -1270,7 +1270,7 @@ msgstr ""
msgid "The project title is the true name of the application." msgid "The project title is the true name of the application."
msgstr "" msgstr ""
#: FCreateProject.form:426 FOpenProject.form:192 #: FCreateProject.form:426 FOpenProject.form:147
msgid "Open in another window" msgid "Open in another window"
msgstr "" msgstr ""
@ -2756,15 +2756,15 @@ msgstr ""
msgid "Sort history" msgid "Sort history"
msgstr "" msgstr ""
#: FMain.class:594 FOpenProject.form:116 FWelcome.form:42 #: FMain.class:594 FOpenProject.form:71 FWelcome.form:42
msgid "Sort by date" msgid "Sort by date"
msgstr "" msgstr ""
#: FMain.class:594 FOpenProject.form:125 FWelcome.form:49 #: FMain.class:594 FOpenProject.form:80 FWelcome.form:49
msgid "Sort by name" msgid "Sort by name"
msgstr "" msgstr ""
#: FMain.class:594 FOpenProject.form:133 FWelcome.form:55 #: FMain.class:594 FOpenProject.form:88 FWelcome.form:55
msgid "Sort by path" msgid "Sort by path"
msgstr "" msgstr ""
@ -3115,10 +3115,14 @@ msgstr ""
msgid "You must select an old version." msgid "You must select an old version."
msgstr "" msgstr ""
#: FMakePatch.class:30 Patch.class:28 #: FMakePatch.class:29 Patch.class:36
msgid "Not a valid Gambas project" msgid "Not a valid Gambas project"
msgstr "" msgstr ""
#: FMakePatch.class:45
msgid "Patch written."
msgstr ""
#: FMenu.form:80 #: FMenu.form:80
msgid "Insert menu" msgid "Insert menu"
msgstr "" msgstr ""
@ -3243,15 +3247,15 @@ msgstr ""
msgid "New translation" msgid "New translation"
msgstr "" msgstr ""
#: FOpenProject.form:33 #: FOpenProject.form:27
msgid "Select a project" msgid "Select a project"
msgstr "" msgstr ""
#: FOpenProject.form:92 #: FOpenProject.form:47
msgid "Recent" msgid "Recent"
msgstr "" msgstr ""
#: FOpenProject.form:148 FWelcome.class:56 #: FOpenProject.form:103 FWelcome.class:56
msgid "Examples" msgid "Examples"
msgstr "" msgstr ""
@ -5984,11 +5988,11 @@ msgstr ""
msgid "'tar' has returned the following error code:" msgid "'tar' has returned the following error code:"
msgstr "" msgstr ""
#: Patch.class:42 #: Patch.class:50
msgid "Unsupported source file type" msgid "Unsupported source file type"
msgstr "" msgstr ""
#: Patch.class:187 #: Patch.class:196
msgid "Patch didn't apply:\n" msgid "Patch didn't apply:\n"
msgstr "" msgstr ""

View file

@ -0,0 +1,126 @@
' Gambas class file
Private $hProjectItem As ProjectItem
Private $sLast As String
Public Sub _new()
$hProjectItem = New ProjectItem(panProjectTitle)
$hProjectItem.Highlight = False
panProject.Reparent(dchProject.FileView.Parent)
End
Public Sub Form_Open()
$sLast = ""
dchProject.ShowFile = True
dchProject_Change
'tabProject_Click
End
Public Sub GetSettings() As Variant[]
Return [dchProject.Settings, splProject.Settings]
End
Public Sub SetSettings(Value As Variant[])
Try dchProject.Settings = Value[0]
Try splProject.Settings = Value[1]
End
Public Sub dchProject_Icon(Path As String)
If Exist(Path &/ ".project") Then
dchProject.Icon = Project.GetIcon(Path)
Endif
End
Private Sub GetProjectPath(sPath As String) As String
Do
If Exist(sPath &/ ".project") Then Return sPath
sPath = File.Dir(sPath)
If sPath = "/" Then Break
Loop
Catch
End
Public Sub dchProject_Change()
Dim sPath As String
Dim hProjectTree As CProjectTree
sPath = GetProjectPath(dchProject.Value)
If Not sPath Then
$sLast = ""
panProject.Hide
dchProject.FileView.Show
Return
Endif
If sPath = $sLast Then Return
$sLast = sPath
$hProjectItem.Path = sPath
hProjectTree = New CProjectTree(tvwProject, sPath)
panProject.Show
dchProject.FileView.Hide
splProject_Resize
End
Private Sub GetParent() As ProjectChooser
Return Me.Parent
End
Public Sub dchProject_Activate()
GetParent()._RaiseActivate
End
Public Sub splProject_Resize()
panProjectTitle.H = $hProjectItem.IdealHeight + panProjectTitle.Padding * 2
End
Public Sub GetPath() As String
Return GetProjectPath(dchProject.Value)
End
Public Sub SetPath(sPath As String)
dchProject.Value = sPath
End
Public Sub GetBorder() As Boolean
Return dchProject.Border
End
Public Sub SetBorder(Value As Boolean)
dchProject.Border = Value
End

View file

@ -0,0 +1,41 @@
# Gambas Form File 3.0
{ Form Form
MoveScaled(0,0,99,64)
Arrangement = Arrange.Fill
{ splProject HSplit
MoveScaled(1,1,93,61)
{ dchProject DirChooser
MoveScaled(1,2,62,58)
Expand = True
Border = False
ShowFile = True
ShowSplitter = False
}
{ Panel2 Panel
MoveScaled(64,2,28,56)
Visible = False
Arrangement = Arrange.Fill
{ panProject Panel
MoveScaled(1,1,26,53)
Arrangement = Arrange.Vertical
{ panProjectTitle Panel
MoveScaled(1,1,20,9)
Background = Color.TextBackground
Arrangement = Arrange.Fill
Padding = 2
}
{ Separator1 Separator
MoveScaled(1,11,12,0)
Background = Color.TextBackground
}
{ tvwProject TreeView
MoveScaled(2,13,22,37)
Expand = True
Mode = Select.None
Border = False
}
}
}
}
}

View file

@ -0,0 +1,66 @@
' Gambas class file
Export
Inherits UserControl
Public Const _Properties As String = "*,Border"
Public Const _DefaultEvent As String = "Activate"
Public Const _DefaultSize As String = "36,36"
Public Const _Group As String = "Chooser"
Event Activate
Property Settings As Variant[]
Property Path As String
Property Border As Boolean
Private $hForm As FProjectChooser
Public Sub _new()
$hForm = New FProjectChooser(Me)
End
Private Function Settings_Read() As Variant[]
Return $hForm.GetSettings()
End
Private Sub Settings_Write(Value As Variant[])
$hForm.SetSettings(Value)
End
Public Sub _RaiseActivate()
Raise Activate
End
Private Function Path_Read() As String
Return $hForm.GetPath()
End
Private Sub Path_Write(Value As String)
$hForm.SetPath(Value)
End
Private Function Border_Read() As Boolean
Return $hForm.GetBorder()
End
Private Sub Border_Write(Value As Boolean)
$hForm.SetBorder(Value)
End

View file

@ -1,31 +1,10 @@
' Gambas class file ' Gambas class file
'
' Copyright (C) Benoît Minisini
'
' This program is free software; you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation; either version 2 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program; if not, write to the Free Software
' Foundation, Inc., 51 Franklin St, Fifth Floor,
' Boston, MA 02110-1301 USA
'
Static Private $sPath As String Static Private $sPath As String
Static Private $sLast As String
Static Private $bAnother As Boolean Static Private $bAnother As Boolean
Static Public InAnotherWindow As Boolean Static Public InAnotherWindow As Boolean
Private $hProjectItem As ProjectItem
Private $iSort As Integer Private $iSort As Integer
Public Sub Run(Optional bAnother As Boolean) As String Public Sub Run(Optional bAnother As Boolean) As String
@ -43,9 +22,9 @@ End
Public Sub _new() Public Sub _new()
$hProjectItem = New ProjectItem(panProjectTitle) ' $hProjectItem = New ProjectItem(panProjectTitle)
$hProjectItem.Highlight = False ' $hProjectItem.Highlight = False
panProject.Reparent(dchProject.FileView.Parent) ' panProject.Reparent(dchProject.FileView.Parent)
End End
@ -56,7 +35,7 @@ Public Sub btnOK_Click()
Dim hProjectItem As ProjectItem Dim hProjectItem As ProjectItem
If tabProject.Index = 0 Then If tabProject.Index = 0 Then
sPath = GetProjectPath(dchProject.Value) sPath = pchProject.Path
Else If tabProject.Index = 1 Then Else If tabProject.Index = 1 Then
hProjectItem = lstRecent.Current hProjectItem = lstRecent.Current
Try sPath = hProjectItem.Path Try sPath = hProjectItem.Path
@ -87,13 +66,14 @@ Public Sub Form_Open()
Dim hCtrl As RadioButton Dim hCtrl As RadioButton
$sLast = "" '$sLast = ""
Settings.Read(Me) Settings.Read(Me)
Settings.Read(dchProject) Settings.Read(pchProject)
Settings.Read(splProject) ' Settings.Read(dchProject)
dchProject.ShowFile = True ' Settings.Read(splProject)
'dchProject.Value = Settings["/FOpenProject/Path"] ' dchProject.ShowFile = True
dchProject_Change ' 'dchProject.Value = Settings["/FOpenProject/Path"]
' dchProject_Change
tabProject_Click tabProject_Click
InAnotherWindow = False InAnotherWindow = False
@ -113,59 +93,60 @@ Public Sub Form_Close()
Settings["/FOpenProject/SortRecent"] = $iSort Settings["/FOpenProject/SortRecent"] = $iSort
Settings.Write(Me) Settings.Write(Me)
Settings.Write(splProject) ' Settings.Write(splProject)
Settings.Write(dchProject) ' Settings.Write(dchProject)
Settings.Write(pchProject)
End End
Public Sub dchProject_Icon(Path As String) ' Public Sub dchProject_Icon(Path As String)
'
If Exist(Path &/ ".project") Then ' If Exist(Path &/ ".project") Then
dchProject.Icon = Project.GetIcon(Path) ' dchProject.Icon = Project.GetIcon(Path)
Endif ' Endif
'
End ' End
'
Private Sub GetProjectPath(sPath As String) As String ' Private Sub GetProjectPath(sPath As String) As String
'
Do ' Do
If Exist(sPath &/ ".project") Then Return sPath ' If Exist(sPath &/ ".project") Then Return sPath
sPath = File.Dir(sPath) ' sPath = File.Dir(sPath)
If sPath = "/" Then Break ' If sPath = "/" Then Break
Loop ' Loop
'
Catch ' Catch
'
End ' End
'
'
Public Sub dchProject_Change() ' Public Sub dchProject_Change()
'
Dim sPath As String ' Dim sPath As String
Dim hProjectTree As CProjectTree ' Dim hProjectTree As CProjectTree
'
sPath = GetProjectPath(dchProject.Value) ' sPath = GetProjectPath(dchProject.Value)
'
If Not sPath Then ' If Not sPath Then
$sLast = "" ' $sLast = ""
panProject.Hide ' panProject.Hide
dchProject.FileView.Show ' dchProject.FileView.Show
Return ' Return
Endif ' Endif
'
If sPath = $sLast Then Return ' If sPath = $sLast Then Return
'
$sLast = sPath ' $sLast = sPath
'
$hProjectItem.Path = sPath ' $hProjectItem.Path = sPath
hProjectTree = New CProjectTree(tvwProject, sPath) ' hProjectTree = New CProjectTree(tvwProject, sPath)
'
panProject.Show ' panProject.Show
dchProject.FileView.Hide ' dchProject.FileView.Hide
'
splProject_Resize ' splProject_Resize
'
End ' End
' Public Sub fvwProject_Activate() ' Public Sub fvwProject_Activate()
' '
@ -408,11 +389,11 @@ Public Sub lstExample_Activate()
End End
Public Sub splProject_Resize() ' Public Sub splProject_Resize()
'
panProjectTitle.H = $hProjectItem.IdealHeight + panProjectTitle.Padding * 2 ' panProjectTitle.H = $hProjectItem.IdealHeight + panProjectTitle.Padding * 2
'
End ' End
Public Sub btnOther_Click() Public Sub btnOther_Click()

View file

@ -16,41 +16,8 @@
Index = 0 Index = 0
Text = ("Open") Text = ("Open")
Picture = Picture["icon:/small/open"] Picture = Picture["icon:/small/open"]
{ splProject HSplit { pchProject ProjectChooser
MoveScaled(1,1,93,61) MoveScaled(3,4,81,54)
Expand = True
{ dchProject DirChooser
MoveScaled(1,2,62,58)
Expand = True
Border = False
ShowFile = True
ShowSplitter = False
}
{ Panel2 Panel
MoveScaled(64,2,28,56)
Visible = False
Arrangement = Arrange.Fill
{ panProject Panel
MoveScaled(1,1,26,53)
Arrangement = Arrange.Vertical
{ panProjectTitle Panel
MoveScaled(1,1,20,9)
Background = Color.TextBackground
Arrangement = Arrange.Fill
Padding = 2
}
{ Separator1 Separator
MoveScaled(1,11,12,0)
Background = Color.TextBackground
}
{ tvwProject TreeView
MoveScaled(2,13,22,37)
Expand = True
Mode = Select.None
Border = False
}
}
}
} }
Index = 1 Index = 1
Text = ("Recent") Text = ("Recent")