1*b1cdbd2cSJim Jagielski<?xml version="1.0" encoding="UTF-8"?>
2*b1cdbd2cSJim Jagielski<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3*b1cdbd2cSJim Jagielski<!--***********************************************************
4*b1cdbd2cSJim Jagielski *
5*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one
6*b1cdbd2cSJim Jagielski * or more contributor license agreements.  See the NOTICE file
7*b1cdbd2cSJim Jagielski * distributed with this work for additional information
8*b1cdbd2cSJim Jagielski * regarding copyright ownership.  The ASF licenses this file
9*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the
10*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance
11*b1cdbd2cSJim Jagielski * with the License.  You may obtain a copy of the License at
12*b1cdbd2cSJim Jagielski *
13*b1cdbd2cSJim Jagielski *   http://www.apache.org/licenses/LICENSE-2.0
14*b1cdbd2cSJim Jagielski *
15*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing,
16*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an
17*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18*b1cdbd2cSJim Jagielski * KIND, either express or implied.  See the License for the
19*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations
20*b1cdbd2cSJim Jagielski * under the License.
21*b1cdbd2cSJim Jagielski *
22*b1cdbd2cSJim Jagielski ***********************************************************-->
23*b1cdbd2cSJim Jagielski<script:module xmlns:script="http://openoffice.org/2000/script" script:name="DlgControl" script:language="StarBasic">Option Explicit
24*b1cdbd2cSJim Jagielski
25*b1cdbd2cSJim JagielskiDim CalBitmap As Object
26*b1cdbd2cSJim JagielskiPublic bSelectByMouseMove as Boolean
27*b1cdbd2cSJim JagielskiPublic fHeightCorrFactor as Double
28*b1cdbd2cSJim JagielskiPublic fWidthCorrFactor as Double
29*b1cdbd2cSJim Jagielski
30*b1cdbd2cSJim Jagielski
31*b1cdbd2cSJim Jagielski
32*b1cdbd2cSJim JagielskiSub Main()
33*b1cdbd2cSJim Jagielski	Call CalAutopilotTable()
34*b1cdbd2cSJim JagielskiEnd Sub
35*b1cdbd2cSJim Jagielski
36*b1cdbd2cSJim Jagielski
37*b1cdbd2cSJim JagielskiSub CalcmdDeleteSelect()
38*b1cdbd2cSJim JagielskiDim MsgBoxResult as Integer
39*b1cdbd2cSJim JagielskiDim bDoEnable as Boolean
40*b1cdbd2cSJim JagielskiDim iSel as Integer
41*b1cdbd2cSJim JagielskiDim MaxIndex as Integer
42*b1cdbd2cSJim Jagielski	If Ubound(DlgCalModel.lstOwnData.SelectedItems()) &gt; -1 Then
43*b1cdbd2cSJim Jagielski		MsgBoxResult = MsgBox(cCalSubcmdDeleteSelect_DeleteSelEntry$, 4+32, cCalSubcmdDeleteSelect_DeleteSelEntryTitle$)
44*b1cdbd2cSJim Jagielski		If MsgBoxResult = 6 Then
45*b1cdbd2cSJim Jagielski			iSel = DlgCalModel.lstOwnData.SelectedItems(0)
46*b1cdbd2cSJim Jagielski			DlgCalModel.lstOwnData.StringItemList() = RemoveSelected(DlgCalModel.lstOwnData)
47*b1cdbd2cSJim Jagielski			&apos; Flag to store the new data
48*b1cdbd2cSJim Jagielski			bCalOwnDataChanged = True
49*b1cdbd2cSJim Jagielski			bDoEnable = Ubound(DlgCalModel.lstOwnData.StringItemList()) &gt; -1
50*b1cdbd2cSJim Jagielski			DlgCalModel.cmdDelete.Enabled = bDoEnable
51*b1cdbd2cSJim Jagielski			If bDoEnable Then
52*b1cdbd2cSJim Jagielski				MaxIndex = Ubound(DlgCalModel.lstOwnData.StringItemList())
53*b1cdbd2cSJim Jagielski				If iSel &gt; MaxIndex Then
54*b1cdbd2cSJim Jagielski					iSel = MaxIndex
55*b1cdbd2cSJim Jagielski				End If
56*b1cdbd2cSJim Jagielski				DlgCalendar.GetControl(&quot;lstOwnData&quot;).SelectItemPos(iSel, True)
57*b1cdbd2cSJim Jagielski				CalUpdateNewEventFrame()
58*b1cdbd2cSJim Jagielski			Else
59*b1cdbd2cSJim Jagielski				Call CalClearInputMask()
60*b1cdbd2cSJim Jagielski			End If
61*b1cdbd2cSJim Jagielski		End If
62*b1cdbd2cSJim Jagielski	End If
63*b1cdbd2cSJim JagielskiEnd Sub
64*b1cdbd2cSJim Jagielski
65*b1cdbd2cSJim Jagielski
66*b1cdbd2cSJim JagielskiSub CalSaveOwnEventControls()
67*b1cdbd2cSJim Jagielski	With DlgCalModel
68*b1cdbd2cSJim Jagielski		.txtOwnEventDay.Tag = .txtOwnEventDay.Value
69*b1cdbd2cSJim Jagielski		.txtOwnEventMonth.Tag = .txtOwnEventMonth.Text
70*b1cdbd2cSJim Jagielski	End With
71*b1cdbd2cSJim JagielskiEnd Sub
72*b1cdbd2cSJim Jagielski
73*b1cdbd2cSJim Jagielski
74*b1cdbd2cSJim JagielskiSub CalMouseMoved(aEvent as object)
75*b1cdbd2cSJim JagielskiDim ListIndex as Integer
76*b1cdbd2cSJim Jagielski	Select Case sCurLangLocale
77*b1cdbd2cSJim Jagielski		Case  cLANGUAGE_GERMAN
78*b1cdbd2cSJim Jagielski			If bSelectByMouseMove Then
79*b1cdbd2cSJim Jagielski&apos;				oStatusLine.SetText(&quot;Position: &quot; &amp; aEvent.X &amp; &quot; ; &quot; &amp; aEvent.Y)
80*b1cdbd2cSJim Jagielski				ListIndex = CalGetGermanLandAtMousePos(CInt(aEvent.X/fWidthCorrFactor), CInt(aEvent.Y/fHeightCorrFactor))
81*b1cdbd2cSJim Jagielski				DlgCalendar.GetControl(&quot;lstHolidays&quot;).SelectItemPos(ListIndex, True)
82*b1cdbd2cSJim Jagielski			End If
83*b1cdbd2cSJim Jagielski	End Select
84*b1cdbd2cSJim JagielskiEnd Sub
85*b1cdbd2cSJim Jagielski
86*b1cdbd2cSJim Jagielski
87*b1cdbd2cSJim JagielskiSub SelectState(aEvent as Object)
88*b1cdbd2cSJim JagielskiDim ListIndex as Integer
89*b1cdbd2cSJim Jagielski	Select Case sCurLangLocale
90*b1cdbd2cSJim Jagielski		Case  cLANGUAGE_GERMAN
91*b1cdbd2cSJim Jagielski			If aEvent.ClickCount &gt;= 1 Then
92*b1cdbd2cSJim Jagielski				ListIndex = CalGetGermanLandAtMousePos(CInt(aEvent.X/fWidthCorrFactor), CInt(aEvent.Y/fHeightCorrFactor))
93*b1cdbd2cSJim Jagielski			DlgCalendar.GetControl(&quot;lstHolidays&quot;).SelectItemPos(ListIndex, True)
94*b1cdbd2cSJim Jagielski			bSelectByMouseMove = False
95*b1cdbd2cSJim Jagielski		End If
96*b1cdbd2cSJim Jagielski	End Select
97*b1cdbd2cSJim JagielskiEnd Sub
98*b1cdbd2cSJim Jagielski
99*b1cdbd2cSJim Jagielski
100*b1cdbd2cSJim JagielskiSub MouseLeavesImage
101*b1cdbd2cSJim Jagielski	bSelectbyMouseMove = True
102*b1cdbd2cSJim JagielskiEnd Sub
103*b1cdbd2cSJim Jagielski
104*b1cdbd2cSJim Jagielski
105*b1cdbd2cSJim JagielskiSub CalClearInputMask()
106*b1cdbd2cSJim JagielskiDim NullList() as String
107*b1cdbd2cSJim Jagielski	With DlgCalModel
108*b1cdbd2cSJim Jagielski		.txtEvent.Text = &quot;&quot;
109*b1cdbd2cSJim Jagielski		.txtOwnEventDay.SetPropertyToDefault(&quot;Value&quot;)
110*b1cdbd2cSJim Jagielski		.cmdInsert.Enabled = False
111*b1cdbd2cSJim Jagielski	End With
112*b1cdbd2cSJim Jagielski	If Ubound(DlgCalModel.lstOwnData.StringItemList()) &gt; -1 Then
113*b1cdbd2cSJim Jagielski		If Ubound(DlgCalModel.lstOwnData.SelectedItems()) = -1 Then
114*b1cdbd2cSJim Jagielski			DlgCalendar.GetControl(&quot;lstOwnData&quot;).SelectItemPos(0,True)
115*b1cdbd2cSJim Jagielski			CalUpdateNewEventFrame()
116*b1cdbd2cSJim Jagielski		End If
117*b1cdbd2cSJim Jagielski	End If
118*b1cdbd2cSJim JagielskiEnd Sub
119*b1cdbd2cSJim Jagielski
120*b1cdbd2cSJim Jagielski
121*b1cdbd2cSJim JagielskiSub CalmdSwitchOwnDataOrGeneral()
122*b1cdbd2cSJim Jagielski	If DlgCalModel.Step = 1 Then
123*b1cdbd2cSJim Jagielski		DlgCalModel.Step = 2
124*b1cdbd2cSJim Jagielski		DlgCalModel.cmdOwnData.Label = cCalSubcmdSwitchOwnDataOrGeneral_Back$
125*b1cdbd2cSJim Jagielski		DlgCalModel.cmdInsert.Enabled = DlgCalModel.txtEvent.Text &lt;&gt; &quot;&quot;
126*b1cdbd2cSJim Jagielski&apos;		ToggleYearBox()
127*b1cdbd2cSJim Jagielski	Else
128*b1cdbd2cSJim Jagielski		dim bla as boolean
129*b1cdbd2cSJim Jagielski		DlgCalModel.Step = 1
130*b1cdbd2cSJim Jagielski		DlgCalendar.GetControl(&quot;lblHolidays&quot;).Visible = sCurLangLocale  = cLANGUAGE_GERMAN
131*b1cdbd2cSJim Jagielski		DlgCalendar.GetControl(&quot;lstHolidays&quot;).Visible = sCurLangLocale  = cLANGUAGE_GERMAN
132*b1cdbd2cSJim Jagielski		DlgCalModel.cmdOwnData.Label = cCalSubcmdSwitchOwnDataOrGeneral_OwnData$
133*b1cdbd2cSJim Jagielski	End If
134*b1cdbd2cSJim JagielskiEnd Sub
135*b1cdbd2cSJim Jagielski
136*b1cdbd2cSJim Jagielski
137*b1cdbd2cSJim JagielskiSub ToggleInsertButton()
138*b1cdbd2cSJim Jagielski	DlgCalModel.cmdInsert.Enabled = LTrim(DlgCalModel.txtEvent.Text) &lt;&gt; &quot;&quot;
139*b1cdbd2cSJim JagielskiEnd Sub
140*b1cdbd2cSJim Jagielski
141*b1cdbd2cSJim Jagielski
142*b1cdbd2cSJim JagielskiSub CalUpdateNewEventFrame()
143*b1cdbd2cSJim JagielskiDim bDoEnable as Boolean
144*b1cdbd2cSJim JagielskiDim sSelectedItem
145*b1cdbd2cSJim JagielskiDim ListIndex as Integer
146*b1cdbd2cSJim JagielskiDim MaxSelIndex as Integer
147*b1cdbd2cSJim JagielskiDim CurEvMonth as Integer
148*b1cdbd2cSJim JagielskiDim CurEvDay as Integer
149*b1cdbd2cSJim JagielskiDim DateStr as String
150*b1cdbd2cSJim Jagielski	bDoEnable = False
151*b1cdbd2cSJim Jagielski	With DlgCalModel
152*b1cdbd2cSJim Jagielski		MaxSelIndex = Ubound(DlgCalModel.lstOwnData.SelectedItems())
153*b1cdbd2cSJim Jagielski		If MaxSelIndex &gt; -1 Then
154*b1cdbd2cSJim Jagielski			ListIndex = .lstOwnData.SelectedItems(MaxSelIndex)
155*b1cdbd2cSJim Jagielski			.txtEvent.Text = CalGetNameofEvent(ListIndex)
156*b1cdbd2cSJim Jagielski			If GetSelectedDateUnits(CurEvDay, CurEvMonth, ListIndex) &lt;&gt; SBDATEUNDEFINED Then
157*b1cdbd2cSJim Jagielski				.txtOwnEventDay.Value = CurEvDay
158*b1cdbd2cSJim Jagielski				DlgCalendar.GetControl(&quot;lstOwnEventMonth&quot;).SelectItemPos(CurEvMonth-1, True)
159*b1cdbd2cSJim Jagielski				.cmdDelete.Enabled = True
160*b1cdbd2cSJim Jagielski				.cmdInsert.Enabled = True
161*b1cdbd2cSJim Jagielski			Else
162*b1cdbd2cSJim Jagielski				Call CalClearInputMask()
163*b1cdbd2cSJim Jagielski				.cmdDelete.Enabled = True
164*b1cdbd2cSJim Jagielski			End If
165*b1cdbd2cSJim Jagielski		End If
166*b1cdbd2cSJim Jagielski	End With
167*b1cdbd2cSJim JagielskiEnd Sub
168*b1cdbd2cSJim Jagielski</script:module>
169