diff --git a/comp/src/gb.form/.info b/comp/src/gb.form/.info index 2976af0fc..f9a61dc5c 100644 --- a/comp/src/gb.form/.info +++ b/comp/src/gb.form/.info @@ -1050,6 +1050,14 @@ _new m +TaskPreview_Read +m + +(Data)s +TaskPreview_Kill +m + + Refresh_Timer m @@ -1638,6 +1646,10 @@ Border p b +Font +p +Font + _new m diff --git a/comp/src/gb.form/.lang/.pot b/comp/src/gb.form/.lang/.pot index 34b5018c0..8a0e8611e 100644 --- a/comp/src/gb.form/.lang/.pot +++ b/comp/src/gb.form/.lang/.pot @@ -223,7 +223,7 @@ msgstr "" msgid "Close" msgstr "" -#: FEditBookmark.class:20 FileView.class:100 +#: FEditBookmark.class:20 FileView.class:103 msgid "Name" msgstr "" @@ -251,11 +251,11 @@ msgstr "" msgid "Directory" msgstr "" -#: FFileProperties.form:105 FileView.class:102 +#: FFileProperties.form:105 FileView.class:105 msgid "Size" msgstr "" -#: FFileProperties.form:117 FileView.class:104 +#: FFileProperties.form:117 FileView.class:107 msgid "Last modified" msgstr "" @@ -343,6 +343,14 @@ msgstr "" msgid "How quickly daft jumping zebras vex" msgstr "" +#: FMain.form:21 +msgid "ButtonBox1" +msgstr "" + +#: FMain.form:26 +msgid "MaskBox1" +msgstr "" + #: FMessage.form:39 msgid "Do not display this message again" msgstr "" @@ -363,7 +371,7 @@ msgstr "" msgid "&Previous" msgstr "" -#: FileView.class:816 +#: FileView.class:872 msgid "Cannot rename file." msgstr "" @@ -371,7 +379,7 @@ msgstr "" msgid "MenuButton1" msgstr "" -#: Form3.form:20 +#: Form3.form:19 msgid "1" msgstr "" diff --git a/comp/src/gb.form/.project b/comp/src/gb.form/.project index 4d81b61fc..a5b47e902 100644 --- a/comp/src/gb.form/.project +++ b/comp/src/gb.form/.project @@ -1,7 +1,7 @@ # Gambas Project File 3.0 # Compiled with Gambas 3.4.90 Title=More controls for graphical components -Startup=Form3 +Startup=Form1 Version=3.4.90 VersionFile=1 Component=gb.image diff --git a/comp/src/gb.form/.src/File/CTaskPreview.class b/comp/src/gb.form/.src/File/CTaskPreview.class new file mode 100644 index 000000000..3c3bbb510 --- /dev/null +++ b/comp/src/gb.form/.src/File/CTaskPreview.class @@ -0,0 +1,96 @@ +' Gambas class file + +Inherits Task + +Private $sDir As String +Private $iSize As Integer + +Public Sub _new(sDir As String, iSize As Integer) + + $sDir = sDir + $iSize = iSize + +End + +Private Sub PrintIcon(sFile As String, hImage As Image) + + Dim hIcon As Image + Dim sTemp As String + + hIcon = New Image(hImage.W + 4, hImage.H + 4, Color.Transparent) + Paint.Begin(hIcon) + Paint.AntiAlias = False + Paint.LineWidth = 2 + Paint.Rectangle(0, 0, hIcon.W, hIcon.H) + Paint.Background = Color.Gray + Paint.Stroke + Paint.End + hIcon.DrawImage(hImage, 2, 2) + + sTemp = File.SetExt(Temp$(), "png") + hIcon.Save(sTemp) + Print sFile; "\t"; sTemp + +End + +Public Sub Main() + + Dim sFile As String + Dim sExt As String + Dim sPath As String + Dim hImage As Image + Dim hIcon As Image + Dim sTemp As String + Dim hSvgImage As SvgImage + + For Each sFile In Dir($sDir).Sort(gb.Natural) + + sPath = $sDir &/ sFile + sExt = LCase(File.Ext(sFile)) + + If sExt = "jpg" Or If sExt = "jpeg" Or If sExt = "png" Or If sExt = "gif" Or If sExt = "bmp" Or If sExt = "xpm" Then + + If Stat(sPath).Size > 4194304 Then Continue + + Try hImage = Image.Load(sPath) + If Error Then Continue + + If Not (hImage.Width = $iSize And hImage.Height = $iSize) Then + If hImage.Width > hImage.Height Then + hImage = hImage.Stretch($iSize, ($iSize * hImage.Height) \ hImage.Width) + Else + hImage = hImage.Stretch(($iSize * hImage.Width) \ hImage.Height, $iSize) + Endif + Endif + + PrintIcon(sFile, hImage) + + Else If sExt = "svg" Or If sExt = "svgz" Then + + Try hSvgImage = SvgImage.Load(sPath) + If Error Then Continue + + If hSvgImage.Width > hSvgImage.Height Then + hSvgImage.Resize($iSize, $iSize * hSvgImage.Height / hSvgImage.Width) + Else + hSvgImage.Resize($iSize * hSvgImage.Width / hSvgImage.Height, $iSize) + Endif + + hImage = New Image(hSvgImage.Width, hSvgImage.Height, Color.Transparent) + Paint.Begin(hImage) + hSvgImage.Paint() + Paint.End + + PrintIcon(sFile, hImage) + + Endif + + Next + + Print "." + + Do + Sleep 3600 + Loop + +End diff --git a/comp/src/gb.form/.src/File/FileView.class b/comp/src/gb.form/.src/File/FileView.class index f88c88646..73e6dc83f 100644 --- a/comp/src/gb.form/.src/File/FileView.class +++ b/comp/src/gb.form/.src/File/FileView.class @@ -32,7 +32,7 @@ Property Read Count As Integer Property Background As Integer Property Foreground As Integer -Static Private $aImgExt As String[] = ["png", "jpeg", "jpg", "gif", "xpm"] +'Static Private $aImgExt As String[] = ["png", "jpeg", "jpg", "gif", "xpm"] Static Private $cExt As New Collection(gb.IgnoreCase) Private $sDir As String @@ -50,6 +50,9 @@ Private $bRefreshTriggered As Boolean Private $iIconSize As Integer = 32 Private $bDesktopIsLoaded As Boolean +Private $hPreview As CTaskPreview +'Private $cPreview As New Collection + Static Public Sub _init() $cExt["html"] = "html" @@ -139,8 +142,6 @@ End Private Sub GetIcon(sPath As String, iSize As Integer) As Picture - Dim hImage As Image - Dim hIcon As Image Dim sIcon As String Dim hPict As Picture @@ -150,37 +151,39 @@ Private Sub GetIcon(sPath As String, iSize As Integer) As Picture If IsDir(sPath) Then Return - If $bShowPreview And If $aImgExt.Exist(File.Ext(sPath)) < 0 Then - If Stat(sPath).Size <= 65536 Then - - Try hImage = Image.Load(sPath) - If Not Error Then - If Not (hImage.Width = iSize And hImage.Height = iSize) Then - If hImage.Width > hImage.Height Then - hImage = hImage.Stretch(iSize, (iSize * hImage.Height) \ hImage.Width) - Else - hImage = hImage.Stretch((iSize * hImage.Width) \ hImage.Height, iSize) - Endif - Endif - - hIcon = New Image(hImage.W + 4, hImage.H + 4, Color.Transparent) - Paint.Begin(hIcon) - Paint.AntiAlias = False - Paint.LineWidth = 2 - Paint.Rectangle(0, 0, hIcon.W, hIcon.H) - Paint.Background = Color.Merge(GetView().Background, Color.Gray) - Paint.Stroke - Paint.End - hIcon.DrawImage(hImage, 2, 2) - - Return hIcon.Picture - Else - Return Picture["icon:/" & iSize & "/image"] - Endif - - Endif - - Endif + 'If $bShowPreview And If $cPreview.Exist(sPath) Then Return $cPreview[sPath].Picture + + ' If $bShowPreview And If $aImgExt.Exist(File.Ext(sPath), gb.IgnoreCase) < 0 Then + ' If Stat(sPath).Size <= 65536 Then + ' + ' Try hImage = Image.Load(sPath) + ' If Not Error Then + ' If Not (hImage.Width = iSize And hImage.Height = iSize) Then + ' If hImage.Width > hImage.Height Then + ' hImage = hImage.Stretch(iSize, (iSize * hImage.Height) \ hImage.Width) + ' Else + ' hImage = hImage.Stretch((iSize * hImage.Width) \ hImage.Height, iSize) + ' Endif + ' Endif + ' + ' hIcon = New Image(hImage.W + 4, hImage.H + 4, Color.Transparent) + ' Paint.Begin(hIcon) + ' Paint.AntiAlias = False + ' Paint.LineWidth = 2 + ' Paint.Rectangle(0, 0, hIcon.W, hIcon.H) + ' Paint.Background = Color.Merge(GetView().Background, Color.Gray) + ' Paint.Stroke + ' Paint.End + ' hIcon.DrawImage(hImage, 2, 2) + ' + ' Return hIcon.Picture + ' Else + ' Return Picture["icon:/" & iSize & "/image"] + ' Endif + ' + ' Endif + ' + ' Endif If $bDesktopIsLoaded Then @@ -227,6 +230,16 @@ Private Sub GetSelection() As String[] End +Private Sub GetIconSize() As Integer + + If $hColumnView.Visible Then + Return 16 + Else + Return $iIconSize + Endif + +End + Private Sub RefreshView() Dim sFile As String @@ -252,15 +265,15 @@ Private Sub RefreshView() $hColumnView.Clear hPictFile = Picture["icon:/small/file"] hPictFolder = Picture["icon:/small/directory"] - iSize = 16 Else $hIconView.Clear $hIconView._Begin hPictFile = Picture["icon:/" & $iIconSize & "/file"] hPictFolder = Picture["icon:/" & $iIconSize & "/directory"] - iSize = $iIconSize Endif + iSize = GetIconSize() + sDir = $sDir If Not sDir Then sDir = User.Home @@ -318,6 +331,8 @@ Private Sub RefreshView() Try GetView()[sFile].Selected = True Next + If $bShowPreview Then RunPreview + Finally If Not $hColumnView.Visible Then $hIconView._End @@ -329,6 +344,47 @@ Catch End +Private Sub RunPreview() + + If $hPreview Then $hPreview.Stop + + $hPreview = New CTaskPreview($sDir, GetIconSize()) As "TaskPreview" + +End + +Public Sub TaskPreview_Read(Data As String) + + Dim iPos As Integer + Dim sPath As String + Dim sPreview As String + Dim sLine As String + + If Not $bShowPreview Then Return + + For Each sLine In Split(Data, "\n", "", True) + + If sLine = "." Then + Try $hPreview.Stop + Return + Endif + + iPos = InStr(sLine, "\t") + sPath = Left(sLine, iPos - 1) + sPreview = Mid$(sLine, iPos + 1) + + Try GetView()["1" & sPath].Picture = Image.Load(sPreview).Picture + + Next + +End + +Public Sub TaskPreview_Kill() + + If $hPreview = Last Then $hPreview = Null + +End + + Private Sub RefreshViewLater() If $bRefreshTriggered Then Return @@ -709,7 +765,7 @@ Private Sub IconSize_Write(Value As Integer) $iIconSize = Value RefreshView - $hIconView.GridSize = Min(32, Value \ 3) + $hIconView.GridSize = Min(40, (Value + 8) \ 3) End diff --git a/comp/src/gb.form/.src/MenuButton.class b/comp/src/gb.form/.src/MenuButton.class index f1eec60f5..d1279c074 100644 --- a/comp/src/gb.form/.src/MenuButton.class +++ b/comp/src/gb.form/.src/MenuButton.class @@ -25,6 +25,7 @@ Property MenuOnly As Boolean Property Value As Boolean Property AutoResize As Boolean Property Border As Boolean +Property Font As Font Private $hDrawingArea As DrawingArea Private $hPicture As Picture @@ -436,3 +437,16 @@ Private Sub MenuOnly_Write(Value As Boolean) $bMenuOnly = Value End + +Private Function Font_Read() As Font + + Return Super.Font + +End + +Private Sub Font_Write(Value As Font) + + Super.Font = Value + UpdateSize + +End diff --git a/comp/src/gb.form/.src/Test/FMain.form b/comp/src/gb.form/.src/Test/FMain.form index 67063381e..411f8c030 100644 --- a/comp/src/gb.form/.src/Test/FMain.form +++ b/comp/src/gb.form/.src/Test/FMain.form @@ -3,7 +3,6 @@ { Form Form Move(0,0,476,336) #Scaled = False - Arrangement = Arrange.Fill Spacing = True Margin = True { DateChooser1 DateChooser @@ -12,4 +11,12 @@ Foreground = &HFF0000& Border = False } + { ButtonBox1 ButtonBox + Move(84,56,168,28) + Text = ("ButtonBox1") + } + { MaskBox1 MaskBox + Move(273,28,168,28) + Text = ("MaskBox1") + } } diff --git a/comp/src/gb.form/.src/Test/Form3.form b/comp/src/gb.form/.src/Test/Form3.form index ed621f3d4..6da5fccdc 100644 --- a/comp/src/gb.form/.src/Test/Form3.form +++ b/comp/src/gb.form/.src/Test/Form3.form @@ -7,7 +7,6 @@ Margin = True { HBox1 HBox MoveScaled(1,1,51,4) - Visible = False { txtZoom TextBox MoveScaled(0,0,24,4) Text = ("1") diff --git a/comp/src/gb.form/map/icon.map b/comp/src/gb.form/map/icon.map index cc8e05641..216cf695d 100644 --- a/comp/src/gb.form/map/icon.map +++ b/comp/src/gb.form/map/icon.map @@ -119,6 +119,7 @@ save actions/document-save save-as actions/document-save-as science categories/applications-science screen devices/video-display +script mimetypes/text-x-script security status/security-medium select actions/select-rectangular select-all actions/edit-select-all