From 55d7b006156b8dc4acb5ff13a406d472136a8eba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Thu, 2 Jan 2014 12:53:40 +0000 Subject: [PATCH] [GB.FORM] * NEW: Add Spinner control icon. * NEW: Spinner.Label is a new property that tell if the spinner must display a label. * NEW: Spinner.Value is the percentage value to display as a label, between 0 and 1. [GB.GUI.AREA] * NEW: ProgressBar: Take the Enabled state into account when drawing the control. git-svn-id: svn://localhost/gambas/trunk@6053 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- comp/src/gb.form/.hidden/control/spinner.png | Bin 0 -> 594 bytes comp/src/gb.form/.info | 14 +++- comp/src/gb.form/.project | 2 +- comp/src/gb.form/.src/Spinner.class | 67 ++++++++++++++++-- comp/src/gb.form/.src/Test/FSpinner.class | 6 ++ comp/src/gb.form/.src/Test/FSpinner.form | 8 ++- comp/src/gb.gui.base/.src/ProgressBar.class | 23 +++--- .../src/gb.gui.base/.src/Test/FGridView.class | 1 - .../gb.gui.base/.src/Test/FProgressBar.form | 1 + 9 files changed, 103 insertions(+), 19 deletions(-) create mode 100644 comp/src/gb.form/.hidden/control/spinner.png diff --git a/comp/src/gb.form/.hidden/control/spinner.png b/comp/src/gb.form/.hidden/control/spinner.png new file mode 100644 index 0000000000000000000000000000000000000000..af2f08e534723f00146f6b3fffe7742ee1041968 GIT binary patch literal 594 zcmV-Y0P+!ibdV9|Iy2cI2XWv!uWVE`fE1ND;3c)+X*00a50mjJK|7+_ol z0DuP|0$L8fE4q)X(g47dGHU9cWyS(9nFqi}U^~NiC>AyfsE>f>9BtH!7-#^8R?Uq? zX{b%&<2SW3^(5Ar{A}~Z%zyj&DO69T_!WV8(YqK#9T+LoNrLJik-evkJqvJ{tXWze zBW=E+jHW<8C9^y&1lIatR;+PYY*$%_K-UpK%}QiK1y)NbR}lk-Ww03KUO}sU26}G+ zz_k%Y%lNHes$^ib#OycnZ@4%I4vQUV226o#$8ue$k=+BAd1dr-sM`g;2;>XUanyp5 zV7GuZpsl!JT3ONn#6fih{sjK$IRMVI*eqoXp96PlK3(8ZUsEmMSS@^%2cWI?>#Ozt zu;u{3i8dPOeOs9hRQJz{zqMw^jWXYn?+3f1CN(e<>R%RJk)B)H{J|PH_6N#HK-Pgx zYkZ?bI>1)}&17Jx4btpX{#Vw!PXZTbd?(#(sdP!}1Ha22LnGRvWN?Oc#N>fXFYp|X z)xLat1t%dA03SGVIW;Z-jx>sI9J`wVzDuO1RRE|-&3_&HKqM`UlY*P~*XnxCA@%J& g{_P%@byB|CKSVTq&^7Qz+yDRo07*qoM6N<$f>;9vn*aa+ literal 0 HcmV?d00001 diff --git a/comp/src/gb.form/.info b/comp/src/gb.form/.info index 999f55ae2..dafa41337 100644 --- a/comp/src/gb.form/.info +++ b/comp/src/gb.form/.info @@ -1869,7 +1869,7 @@ C _Properties C s -*,Border{Border.*}=None +*,Border{Border.*}=None,Label _DefaultSize C s @@ -1878,6 +1878,18 @@ Border p i +Label +p +b + +Value +p +f + +Enabled +p +b + _new m diff --git a/comp/src/gb.form/.project b/comp/src/gb.form/.project index 9b94dd700..7e63e9916 100644 --- a/comp/src/gb.form/.project +++ b/comp/src/gb.form/.project @@ -9,7 +9,7 @@ Component=gb.gui Component=gb.form Component=gb.settings Authors="BenoƮt Minisini" -Environment="GB_GUI=gb.qt" +Environment="GB_GUI=gb.gtk3" TabSize=2 Translate=1 Language=en diff --git a/comp/src/gb.form/.src/Spinner.class b/comp/src/gb.form/.src/Spinner.class index 35f7d53bb..63ec5b463 100644 --- a/comp/src/gb.form/.src/Spinner.class +++ b/comp/src/gb.form/.src/Spinner.class @@ -4,19 +4,25 @@ Export Inherits UserControl -Public Const _Properties As String = "*,Border{Border.*}=None" +Public Const _Properties As String = "*,Border{Border.*}=None,Label" Public Const _DefaultSize As String = "8,8" Property Border As Integer +Property Label As Boolean +Property Value As Float +Property Enabled As Boolean Private $hDrawingArea As DrawingArea Private $fStartTime As Float Private $hTimer As Timer Private $iBorder As Integer +Private $bLabel As Boolean +Private $fValue As Float Public Sub _new() $hDrawingArea = New DrawingArea(Me) As "DrawingArea" + Start End @@ -52,11 +58,9 @@ Public Sub DrawingArea_Draw() D = Frac(Timer - $fStartTime) * Pi(2) Endif - If Not Me.Enabled Then iFlag += Draw.Disabled - - X = Draw.W / 2 - Y = Draw.H / 2 - R = Min(Draw.W, Draw.H) / 2 * 7 / 8 + X = Paint.W / 2 + Y = Paint.H / 2 + R = Min(Paint.W, Paint.H) / 2 * 7 / 8 Paint.LineWidth = R / 8 Paint.LineCap = Paint.LineCapRound @@ -74,9 +78,14 @@ Public Sub DrawingArea_Draw() Next + If $bLabel Then + Paint.Background = Color.Foreground + Paint.DrawText(Format($fValue, "0%"), 0, 0, Paint.W, Paint.H, Align.Center) + Endif + DRAW_BORDER: - If $iBorder Then Style.PaintPanel(0, 0, Draw.W, Draw.H, $iBorder, iFlag) + If $iBorder Then Style.PaintPanel(0, 0, Paint.W, Paint.H, $iBorder, iFlag) End @@ -98,3 +107,47 @@ Private Sub Border_Write(Value As Integer) $hDrawingArea.Refresh End + +Private Function Label_Read() As Boolean + + Return $bLabel + +End + +Private Sub Label_Write(Value As Boolean) + + $bLabel = Value + $hDrawingArea.Refresh + +End + +Private Function Value_Read() As Float + + Return $fValue + +End + +Private Sub Value_Write(Value As Float) + + $fValue = Max(0, Min(1, Value)) + $hDrawingArea.Refresh + +End + +Private Function Enabled_Read() As Boolean + + Return Super.Enabled + +End + +Private Sub Enabled_Write(Value As Boolean) + + If Value = Me.Enabled Then Return + Super.Enabled = Value + If Value Then + Start + Else + Stop + Endif + +End diff --git a/comp/src/gb.form/.src/Test/FSpinner.class b/comp/src/gb.form/.src/Test/FSpinner.class index adb204b42..08a9031f4 100644 --- a/comp/src/gb.form/.src/Test/FSpinner.class +++ b/comp/src/gb.form/.src/Test/FSpinner.class @@ -6,3 +6,9 @@ Public Sub Form_Open() Spinner1.Start End + +Public Sub Timer1_Timer() + + Spinner1.Value += 0.005 + +End diff --git a/comp/src/gb.form/.src/Test/FSpinner.form b/comp/src/gb.form/.src/Test/FSpinner.form index 073758816..87fb87c0f 100644 --- a/comp/src/gb.form/.src/Test/FSpinner.form +++ b/comp/src/gb.form/.src/Test/FSpinner.form @@ -5,7 +5,13 @@ Background = &HFFFFFF& Arrangement = Arrange.Fill { Spinner1 Spinner - MoveScaled(5,6,18.2857,18.2857) + MoveScaled(17,19,18.2857,18.2857) Border = Border.Plain + Label = True + } + { Timer1 #Timer + #MoveScaled(46,8) + Enabled = True + Delay = 70 } } diff --git a/comp/src/gb.gui.base/.src/ProgressBar.class b/comp/src/gb.gui.base/.src/ProgressBar.class index 826ae6dc9..c0c2b45d6 100644 --- a/comp/src/gb.gui.base/.src/ProgressBar.class +++ b/comp/src/gb.gui.base/.src/ProgressBar.class @@ -53,28 +53,35 @@ Public Sub DrawingArea_Draw() Dim F As Integer = Style.FrameWidth Dim W As Float + Dim iCol As Integer - W = (Draw.W - F) * $fValue + W = (Paint.W - F) * $fValue - Paint.FillRect(F, F, Draw.W - F * 2, Draw.H - F * 2, Color.Merge(Color.Background, Color.LightForeground)) - Paint.FillRect(F, F, W - F, Draw.H - F * 2, Color.SelectedBackground) - Style.PaintPanel(0, 0, Draw.W, Draw.H, Border.Sunken) + iCol = Color.Merge(Color.Background, Color.LightForeground) + If Not Me.Enabled Then iCol = Color.Desaturate(iCol) + Paint.FillRect(F, F, Paint.W - F * 2, Paint.H - F * 2, iCol) + + iCol = Color.SelectedBackground + If Not Me.Enabled Then iCol = Color.Desaturate(iCol) + Paint.FillRect(F, F, W - F, Paint.H - F * 2, iCol) + + Style.PaintPanel(0, 0, Paint.W, Paint.H, Border.Sunken) 'Style.PaintPanel(F, F, W, Draw.H - F * 2, Border.Raised) If $bLabel Then Paint.Save - Paint.Rectangle(F, F, W - F, Draw.H - F * 2) + Paint.Rectangle(F, F, W - F, Paint.H - F * 2) Paint.Clip Paint.Background = Color.SelectedForeground - Paint.DrawText(Format($fValue, "0%"), 0, 0, Draw.W, Draw.H, Align.Center) + Paint.DrawText(Format($fValue, "0%"), 0, 0, Paint.W, Paint.H, Align.Center) Paint.Restore Paint.Save - Paint.Rectangle(F + W, F, Draw.W - F * 2 - W, Draw.H - F * 2) + Paint.Rectangle(F + W, F, Paint.W - F * 2 - W, Paint.H - F * 2) Paint.Clip Paint.Background = Color.Foreground - Paint.DrawText(Format($fValue, "0%"), 0, 0, Draw.W, Draw.H, Align.Center) + Paint.DrawText(Format($fValue, "0%"), 0, 0, Paint.W, Paint.H, Align.Center) Paint.Restore Endif diff --git a/comp/src/gb.gui.base/.src/Test/FGridView.class b/comp/src/gb.gui.base/.src/Test/FGridView.class index 91805a693..661267234 100644 --- a/comp/src/gb.gui.base/.src/Test/FGridView.class +++ b/comp/src/gb.gui.base/.src/Test/FGridView.class @@ -3,7 +3,6 @@ Public Sub Form_Open() - Dim hScrollBar As ScrollBar Dim I As Integer Print gvwInfo.W;; gvwInfo.H;; "/";; Me.W;; Me.H diff --git a/comp/src/gb.gui.base/.src/Test/FProgressBar.form b/comp/src/gb.gui.base/.src/Test/FProgressBar.form index e99d572b0..374faded2 100644 --- a/comp/src/gb.gui.base/.src/Test/FProgressBar.form +++ b/comp/src/gb.gui.base/.src/Test/FProgressBar.form @@ -4,6 +4,7 @@ MoveScaled(0,0,64,64) { ProgressBar1 ProgressBar MoveScaled(13,18,32,4) + Enabled = False } { Timer1 #Timer #MoveScaled(36,36)