DateChooser: ShowWeek is a new property that toggles the display of weeks.
[GB.FORM] * BUG: MenuButton: Fix background color. * NEW: DateChooser: ShowWeek is a new property that toggles the display of weeks.
This commit is contained in:
parent
77ba659c6c
commit
f3b746bf97
@ -9,7 +9,7 @@ Component=gb.form
|
||||
Component=gb.settings
|
||||
Component=gb.form.stock
|
||||
Authors="Benoît Minisini"
|
||||
Environment="GB_GUI=gb.qt5\n GB_STOCK_DEBUG=1\nLANG=zh_CN.UTF-8\nLC_ALL=zh_CN.UTF-8"
|
||||
Environment="GB_GUI=gb.gtk3\n GB_STOCK_DEBUG=1\n LANG=zh_CN.UTF-8\n LC_ALL=zh_CN.UTF-8\nGTK_DEBUG=interactive"
|
||||
TabSize=2
|
||||
Translate=1
|
||||
Language=en
|
||||
|
@ -432,7 +432,7 @@ Public Sub DrawingArea_Draw()
|
||||
If bMenu Then
|
||||
Paint.FillRect(1, 1, Me.W - 2, Me.H - 2, Color.SelectedBackground)
|
||||
Else
|
||||
Paint.FillRect(1, 1, Me.W - 2, Me.H - 2, Color.Background)
|
||||
Paint.FillRect(1, 1, Me.W - 2, Me.H - 2, Style.BackgroundOf(Me))
|
||||
If $bInsideArrow Or If $bMenuOnly Then
|
||||
Style.PaintButton(0, 0, Me.W, Me.H, False, iFlag, bFlat)
|
||||
Else
|
||||
|
@ -14,6 +14,7 @@ Property Read Data As _DateChooser_Data
|
||||
Property Border As Boolean
|
||||
Property MinValue As Date
|
||||
Property MaxValue As Date
|
||||
Property ShowWeek As Boolean
|
||||
|
||||
Public Const DateOnly As Integer = 0
|
||||
Public Const DateTime As Integer = 1
|
||||
@ -25,7 +26,7 @@ Event Activate
|
||||
Event Cancel
|
||||
Event Data({Date} As Date)
|
||||
|
||||
Public Const _Properties As String = "*,Border=True,Mode{DateChooser.*}=DateOnly"
|
||||
Public Const _Properties As String = "*,Border=True,Mode{DateChooser.*}=DateOnly,ShowWeek"
|
||||
Public Const _DefaultEvent As String = "Change"
|
||||
Public Const _DefaultSize As String = "40,28"
|
||||
Public Const _Group As String = "Chooser"
|
||||
@ -143,7 +144,6 @@ Private Function Colors_Read() As _DateChooser_Colors
|
||||
|
||||
End
|
||||
|
||||
|
||||
Public Sub SetFocus()
|
||||
|
||||
$hCal.SetFocus
|
||||
@ -197,7 +197,6 @@ Private Sub GetKey(dDate As Date) As String
|
||||
|
||||
End
|
||||
|
||||
|
||||
Public Sub _GetData(dDate As Date, Optional bCreate As Boolean) As _DateChooser_Data
|
||||
|
||||
Dim hData As _DateChooser_Data
|
||||
@ -263,3 +262,15 @@ Private Sub MaxValue_Write(Value As Date)
|
||||
$hCal.UpdateValue()
|
||||
|
||||
End
|
||||
|
||||
Private Function ShowWeek_Read() As Boolean
|
||||
|
||||
Return $hCal.GetShowWeek()
|
||||
|
||||
End
|
||||
|
||||
Private Sub ShowWeek_Write(Value As Boolean)
|
||||
|
||||
$hCal.SetShowWeek(Value)
|
||||
|
||||
End
|
||||
|
@ -12,6 +12,7 @@ Private $bShort As Boolean
|
||||
Private $iCurrentTime As Integer = -1
|
||||
Private $dCurrentDate As Date
|
||||
Private $iMonthWidth As Integer
|
||||
Private $bShowWeek As Boolean
|
||||
|
||||
'Private mnuMonth As Menu
|
||||
|
||||
@ -218,6 +219,23 @@ Public Sub GetValue() As Date
|
||||
|
||||
End
|
||||
|
||||
Private Sub CalcGrid(ByRef W As Integer, ByRef H As Integer, Optional ByRef XD As Integer, ByRef YD As Integer) As Boolean
|
||||
|
||||
H = dwgMonth.ClientH / 7
|
||||
W = dwgMonth.ClientW
|
||||
If $bShowWeek Then
|
||||
W -= H
|
||||
XD = H
|
||||
Else
|
||||
XD = 0
|
||||
Endif
|
||||
W = W \ 7
|
||||
|
||||
YD = dwgMonth.ClientH - H * 6
|
||||
|
||||
If W = 0 Or If H = 0 Then Return True
|
||||
|
||||
End
|
||||
|
||||
Public Sub dwgMonth_Draw()
|
||||
|
||||
@ -231,17 +249,13 @@ Public Sub dwgMonth_Draw()
|
||||
Dim bToday As Boolean
|
||||
Dim hDate As _DateChooser_Date
|
||||
Dim fSize As Float
|
||||
Dim iWeek As Integer
|
||||
|
||||
If CalcGrid(ByRef W, ByRef H, ByRef XD, ByRef YD) Then Return
|
||||
|
||||
iForeground = dwgMonth.Foreground 'Draw.Foreground
|
||||
iBackground = dwgMonth.Background 'Draw.Background
|
||||
|
||||
W = dwgMonth.ClientW / 7
|
||||
H = dwgMonth.ClientH / 7
|
||||
|
||||
If W = 0 Or H = 0 Then Return
|
||||
|
||||
XD = 0 '(Draw.W - W * 7) / 2
|
||||
YD = dwgMonth.ClientH - H * 6
|
||||
|
||||
Draw.FillStyle = Fill.Solid
|
||||
Draw.LineStyle = Line.None
|
||||
@ -270,9 +284,27 @@ Public Sub dwgMonth_Draw()
|
||||
|
||||
Draw.LineStyle = Line.Solid
|
||||
Draw.Foreground = Color.LightForeground
|
||||
Draw.Line(XD, YD - 1, XD + Draw.W - 1, YD - 1)
|
||||
Draw.Line(0, YD - 1, Draw.W - 1, YD - 1)
|
||||
Draw.LineStyle = Line.None
|
||||
|
||||
dDate = $dStart
|
||||
Paint.Font = GetParent().Font
|
||||
Paint.Font.Size = fSize
|
||||
|
||||
dDate = $dStart
|
||||
X = 0
|
||||
Y = YD
|
||||
For J = 0 To 5
|
||||
If Year(dDate) <> Year($dDate) Then
|
||||
iWeek = Week(DateAdd(dDate, gb.Day, 6))
|
||||
Else
|
||||
iWeek = Week(dDate)
|
||||
Endif
|
||||
Paint.DrawText(CStr(iWeek), X, Y, XD, H, Align.Center)
|
||||
Y += H
|
||||
dDate += 7
|
||||
Next
|
||||
|
||||
dDate = $dStart
|
||||
Y = YD
|
||||
For J = 0 To 5
|
||||
@ -436,17 +468,11 @@ Private Sub CalcCurrentDate() As Boolean
|
||||
|
||||
$dCurrentDate = Null
|
||||
|
||||
W = dwgMonth.ClientW / 7
|
||||
H = dwgMonth.ClientH / 7
|
||||
If CalcGrid(ByRef W, ByRef H, ByRef XD, ByRef YD) Then Return True
|
||||
|
||||
If W = 0 Or H = 0 Then Return True
|
||||
If Mouse.X < XD Or If Mouse.Y < YD Then Return True
|
||||
|
||||
XD = 0 '(Draw.W - W * 7) / 2
|
||||
YD = dwgMonth.ClientH - H * 6
|
||||
|
||||
If Mouse.Y < YD Then Return True
|
||||
|
||||
dDate = $dStart + Min(6, Mouse.X \ W) + ((Mouse.Y - YD) \ H) * 7
|
||||
dDate = $dStart + Min(6, (Mouse.X - XD) \ W) + ((Mouse.Y - YD) \ H) * 7
|
||||
If CheckDate(dDate) <> dDate Then Return True
|
||||
$dCurrentDate = dDate
|
||||
|
||||
@ -541,6 +567,8 @@ Public Sub Form_Resize()
|
||||
Endif
|
||||
|
||||
FillMonth(cmbMonth.Width < $iMonthWidth)
|
||||
|
||||
If $bShowWeek Then UpdateReloadSize
|
||||
|
||||
End
|
||||
|
||||
@ -845,6 +873,7 @@ Public Sub txtHour_MouseWheel()
|
||||
Endif
|
||||
|
||||
SetTime(Time(iHour, Minute($dTime), 0))
|
||||
If panDate.Visible Then btnOK_Click
|
||||
|
||||
End
|
||||
|
||||
@ -875,6 +904,7 @@ Public Sub txtMinute_MouseWheel()
|
||||
Endif
|
||||
|
||||
SetTime(Time(Hour($dTime), iMinute, 0))
|
||||
If panDate.Visible Then btnOK_Click
|
||||
|
||||
End
|
||||
|
||||
@ -945,3 +975,45 @@ Public Sub dwgMonth_MouseWheel()
|
||||
SetDate(Year(dDate), Month(dDate), Day(dDate))
|
||||
|
||||
End
|
||||
|
||||
Private Sub UpdateReloadSize()
|
||||
|
||||
Dim W As Integer
|
||||
Dim H As Integer
|
||||
Dim XD, YD As Integer
|
||||
|
||||
If Not $bShowWeek Then Return
|
||||
|
||||
If CalcGrid(ByRef W, ByRef H, ByRef XD, ByRef YD) Then
|
||||
btnReload.Hide
|
||||
Else
|
||||
btnReload.Move(0, 0, XD, YD)
|
||||
btnReload.Show
|
||||
Endif
|
||||
|
||||
End
|
||||
|
||||
Public Sub SetShowWeek(bWeek As Boolean)
|
||||
|
||||
If $bShowWeek = bWeek Then Return
|
||||
$bShowWeek = bWeek
|
||||
|
||||
If $bShowWeek Then
|
||||
btnReload.Reparent(dwgMonth)
|
||||
btnReload.Ignore = True
|
||||
UpdateReloadSize
|
||||
Else
|
||||
btnReload.Reparent(panToolbar)
|
||||
btnReload.Lower()
|
||||
btnReload.Ignore = False
|
||||
Endif
|
||||
|
||||
dwgMonth.Refresh
|
||||
|
||||
End
|
||||
|
||||
Public Sub GetShowWeek() As Boolean
|
||||
|
||||
Return $bShowWeek
|
||||
|
||||
End
|
||||
|
@ -3,24 +3,37 @@
|
||||
{ Form Form
|
||||
Move(0,0,824,336)
|
||||
#Scaled = False
|
||||
Arrangement = Arrange.Horizontal
|
||||
Spacing = True
|
||||
Margin = True
|
||||
{ DateBox1 DateBox
|
||||
Move(16,64,192,32)
|
||||
Mode = DateChooser.TimeOnly
|
||||
{ Panel1 Panel
|
||||
Move(16,8,320,304)
|
||||
{ DateBox2 DateBox
|
||||
Move(40,112,184,32)
|
||||
}
|
||||
{ DateBox3 DateBox
|
||||
Move(8,160,296,32)
|
||||
Mode = DateChooser.DateTime
|
||||
}
|
||||
{ Button1 Button
|
||||
Move(16,0,128,32)
|
||||
Text = ("Enable")
|
||||
}
|
||||
{ DateBox1 DateBox
|
||||
Move(0,56,192,32)
|
||||
Mode = DateChooser.TimeOnly
|
||||
}
|
||||
{ TextBox1 TextBox
|
||||
Move(40,216,192,32)
|
||||
Border = False
|
||||
}
|
||||
{ TextBox2 TextBox
|
||||
Move(40,256,192,32)
|
||||
}
|
||||
}
|
||||
{ DateChooser1 DateChooser
|
||||
Move(456,32,357,238)
|
||||
}
|
||||
{ DateBox2 DateBox
|
||||
Move(16,120,184,32)
|
||||
}
|
||||
{ Button1 Button
|
||||
Move(32,8,128,32)
|
||||
Text = ("Enable")
|
||||
}
|
||||
{ DateBox3 DateBox
|
||||
Move(16,168,296,32)
|
||||
Mode = DateChooser.DateTime
|
||||
Move(408,32,408,240)
|
||||
Expand = True
|
||||
ShowWeek = True
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user