[GB.FORM]

* NEW: Add text fields to enter the time in the calendar popup. Add an 
  apply button too.


git-svn-id: svn://localhost/gambas/trunk@5606 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2013-03-31 19:19:42 +00:00
parent dbaa1cf059
commit f3bfb12e5b
9 changed files with 206 additions and 89 deletions

View file

@ -26,11 +26,11 @@ msgstr ""
msgid "Unknown"
msgstr ""
#: DataSource.class:409
#: DataSource.class:405
msgid "Invalid value."
msgstr ""
#: DataSource.class:432
#: DataSource.class:428
msgid "You must fill all mandatory fields."
msgstr ""

View file

@ -286,13 +286,9 @@ Public Sub _Check() As Boolean
If Not $sTable Then Return True
hDB = _GetDB()
If Common.CheckDB(hDB) Then Return True
If Not $hConn Then
$hConn = New DataConnection(hDB)
Endif
If Not $hConn Then Return True
Return Common.CheckDB(hDB)
If Not $hConn Then $hConn = New DataConnection(hDB)
End

View file

@ -1,145 +1,145 @@
' Gambas class file
'EXPORT
INHERITS UserControl
Inherits UserControl
PUBLIC CONST _Properties AS String = "*,Mode=None,Field,TextField,ParentField,IconField"
PUBLIC CONST _DrawWith AS String = "TreeView"
Public Const _Properties As String = "*,Mode=None,Field,TextField,ParentField,IconField"
Public Const _DrawWith As String = "TreeView"
EVENT Activate
Event Activate
PROPERTY Field AS String
PROPERTY TextField AS String
PROPERTY ParentField AS String
PROPERTY IconField AS String
Property Field As String
Property TextField As String
Property ParentField As String
Property IconField As String
PROPERTY Mode AS Integer "<TreeView,None,Single,Multi,Extended>"
Property Mode As Integer "<TreeView,None,Single,Multi,Extended>"
'PROPERTY Connection AS Connection
'PROPERTY Table AS String
'PROPERTY Filter AS String
PROPERTY READ Current AS Variant[]
PROPERTY READ Count AS Integer
PROPERTY READ Index AS Integer
PROPERTY READ TreeView AS TreeView
Property Read Current As Variant[]
Property Read Count As Integer
Property Read Index As Integer
Property Read TreeView As TreeView
PRIVATE $hCtrl AS TreeView
PRIVATE $hTable AS DataTable
PRIVATE $sField AS String
PRIVATE $sText AS String
PRIVATE $sParent AS String
PRIVATE $sIcon AS String
Private $hCtrl As TreeView
Private $hTable As DataTable
Private $sField As String
Private $sText As String
Private $sParent As String
Private $sIcon As String
PUBLIC SUB _new()
Public Sub _new()
$hCtrl = NEW TreeView(ME)
$hCtrl = New TreeView(Me)
END
End
PUBLIC SUB Refresh()
Public Sub Refresh()
DIM hSrc AS DataSource
Dim hSrc As DataSource
IF Common.CheckDB() THEN RETURN
If Common.CheckDB() Then Return
hSrc = Common.GetSource(ME)
IF hSrc THEN
hSrc = Common.GetSource(Me)
If hSrc Then
$hTable = hSrc._GetTable()
ENDIF
Endif
$hCtrl.Clear
IF NOT $hTable THEN RETURN
If Not $hTable Then Return
' Remplir avec les éléments de niveau le plus haut
END
End
PRIVATE FUNCTION IconField_Read() AS String
Private Function IconField_Read() As String
RETURN $sIcon
Return $sIcon
END
End
PRIVATE SUB IconField_Write(Value AS String)
Private Sub IconField_Write(Value As String)
$sIcon = Value
END
End
PRIVATE FUNCTION Field_Read() AS String
Private Function Field_Read() As String
RETURN $sField
Return $sField
END
End
PRIVATE SUB Field_Write(Value AS String)
Private Sub Field_Write(Value As String)
$sField = Value
END
End
PRIVATE FUNCTION ParentField_Read() AS String
Private Function ParentField_Read() As String
RETURN $sParent
Return $sParent
END
End
PRIVATE SUB ParentField_Write(Value AS String)
Private Sub ParentField_Write(Value As String)
$sParent = Value
END
End
PRIVATE FUNCTION Mode_Read() AS Integer
Private Function Mode_Read() As Integer
RETURN $hCtrl.Mode
Return $hCtrl.Mode
END
End
PRIVATE SUB Mode_Write(Value AS Integer)
Private Sub Mode_Write(Value As Integer)
$hCtrl.Mode = Value
END
End
PRIVATE FUNCTION Current_Read() AS Variant[]
Private Function Current_Read() As Variant[]
'TRY RETURN $hTable.GetKeys(??)
END
End
PRIVATE FUNCTION Count_Read() AS Integer
Private Function Count_Read() As Integer
RETURN $hCtrl.Count
Return $hCtrl.Count
END
End
PRIVATE FUNCTION Index_Read() AS Integer
Private Function Index_Read() As Integer
END
End
PRIVATE FUNCTION TreeView_Read() AS TreeView
Private Function TreeView_Read() As TreeView
RETURN $hCtrl
Return $hCtrl
END
End
PRIVATE FUNCTION TextField_Read() AS String
Private Function TextField_Read() As String
RETURN $sText
Return $sText
END
End
PRIVATE SUB TextField_Write(Value AS String)
Private Sub TextField_Write(Value As String)
$sText = Value
END
End

View file

@ -38,18 +38,22 @@ msgstr ""
msgid "Cannot create directory."
msgstr ""
#: FCalendar.form:40
#: FCalendar.form:46
msgid "Today"
msgstr ""
#: FCalendar.form:46
#: FCalendar.form:52
msgid "Previous month"
msgstr ""
#: FCalendar.form:79
#: FCalendar.form:85
msgid "Next month"
msgstr ""
#: FCalendar.form:142
msgid "Apply"
msgstr ""
#: FColorChooser.form:78
msgid "Follow color grid"
msgstr ""

View file

@ -105,6 +105,7 @@ Public Sub _new()
$hChooser = New DateChooser(hPanel) As "DateChooser"
$hChooser.Expand = True
$hChooser.Border = False
Me.Proxy = $hButtonBox

View file

@ -50,12 +50,13 @@ End
Public Sub _new()
dwgTime.W = Desktop.Scale * 16
panTime.W = Desktop.Scale * 16
FillMonth(False)
$dDate = Now
SetDate()
SetTime(Time($dDate))
$iDisabledColor = GetDisabledColor()
@ -144,7 +145,7 @@ End
Public Sub GetValue() As Date
If dwgTime.Visible Then
If panTime.Visible Then
Return Date($dDate) + $dTime
Else
Return Date($dDate)
@ -586,9 +587,11 @@ End
Private Sub SetTime(dTime As Date)
$dTime = Time(dTime)
$dTime = dTime
dwgTime.Refresh
dwgTime.SetFocus
txtHour.Text = Format(Hour($dTime), "00")
txtMinute.Text = Format(Minute($dTime), "00")
End
@ -639,7 +642,7 @@ End
Public Sub SetShowTime(bShowTime As Boolean)
If Not GetShowDate() And Not bShowTime Then Error.Raise("Bad argument")
dwgTime.Visible = bShowTime
panTime.Visible = bShowTime
sepTime.Visible = GetShowTime() And GetShowDate()
End
@ -706,3 +709,86 @@ Public Sub SetBorder(bBorder As Boolean)
End
Public Sub txtHour_GotFocus()
txtHour.SelectAll
End
Public Sub txtMinute_GotFocus()
txtMinute.SelectAll
End
Public Sub txtHour_MouseWheel()
Dim iHour As Integer = Hour($dTime)
If Mouse.Forward Then
iHour = Min(iHour + 1, 23)
Else
iHour = Max(iHour - 1, 0)
Endif
SetTime(Time(iHour, Minute($dTime), 0))
End
Public Sub txtMinute_MouseWheel()
Dim iMinute As Integer = Minute($dTime)
If Mouse.Forward Then
Inc iMinute
If iMinute > 59 Then iMinute = 0
Else
Dec iMinute
If iMinute < 0 Then iMinute = 59
Endif
SetTime(Time(Hour($dTime), iMinute, 0))
End
Public Sub txtHour_LostFocus()
Dim iHour As Integer
Dim iPos As Integer
Try iHour = CInt(Trim(txtHour.Text))
If Not Error And If iHour >= 0 And If iHour <= 23 Then
SetTime(Time(iHour, Minute($dTime), 0))
Endif
End
Public Sub txtMinute_LostFocus()
Dim iMinute As Integer
Try iMinute = CInt(Trim(txtMinute.Text))
If Not Error And If iMinute >= 0 And If iMinute <= 59 Then
SetTime(Time(Hour($dTime), iMinute, 0))
Endif
End
Public Sub txtHour_Activate()
txtMinute.SetFocus
End
Public Sub txtMinute_Activate()
dwgTime_DblClick
End
Public Sub btnOK_Click()
dwgTime_DblClick
End

View file

@ -71,13 +71,41 @@
MoveScaled(58,0,0,35)
Visible = False
}
{ dwgTime DrawingArea
MoveScaled(59,0,15,35)
{ panTime VBox
MoveScaled(58,0,17,35)
Visible = False
Background = Color.TextBackground
Foreground = Color.TextForeground
Tracking = True
Focus = True
{ HBox1 HBox
MoveScaled(0,0,17,4)
{ PictureBox1 PictureBox
MoveScaled(0,0,4,4)
Visible = False
Picture = Picture["icon:/small/clock"]
Alignment = Align.Center
}
{ txtHour TextBox
MoveScaled(4,0,4,4)
Expand = True
Alignment = Align.Right
}
{ txtMinute TextBox
MoveScaled(8,0,4,4)
Expand = True
Alignment = Align.Right
}
{ btnOK ToolButton
MoveScaled(13,0,4,4)
ToolTip = ("Apply")
Picture = Picture["icon:/small/ok"]
}
}
{ dwgTime DrawingArea
MoveScaled(1,14,14,20)
Background = Color.TextBackground
Foreground = Color.TextForeground
Tracking = True
Expand = True
Focus = True
}
}
}
}

View file

@ -78,6 +78,6 @@ End
Public Sub DateChooser1_Data({Date} As Date)
If WeekDay({Date}) = gb.Sunday Then DateChooser1.Data.Foreground = Color.Red
If Day({Date}) = 24 Then DateChooser1.Data.Font = Font["serif"]
If Day({Date}) = 24 Then DateChooser1.Data.Font = Font["serif,italic"]
End

View file

@ -37,6 +37,7 @@
}
{ DateBox2 DateBox
MoveScaled(23,26,24,4)
Mode = DateChooser.TimeOnly
}
}
{ Button2 Button
@ -78,6 +79,7 @@
Mode = DateChooser.DateTime
}
{ DateChooser1 DateChooser
MoveScaled(6,38,48,32)
MoveScaled(6,38,64,32)
Mode = DateChooser.DateTime
}
}