1: ================================================================================
  2: 
  3: Smalltalk.KSU defineClass: #WhatTime
  4:     superclass: #{UI.ApplicationModel}
  5:     indexedType: #none
  6:     private: false
  7:     instanceVariableNames: 'outputMode showDate showWeekday showSeconds '
  8:     classInstanceVariableNames: ''
  9:     imports: ''
 10:     category: 'KSU-Template'
 11: 
 12: ================================================================================
 13: 
 14: KSU.WhatTime method for 'initialize-release'
 15: 
 16: initialize
 17: 
 18:     super initialize.
 19:     outputMode := nil.
 20:     showDate := nil.
 21:     showWeekday := nil.
 22:     showSeconds := nil.
 23:     ^self
 24: 
 25: ------------------------------------------------------------
 26: 
 27: KSU.WhatTime method for 'aspects'
 28: 
 29: outputMode
 30: 
 31:     outputMode ifNil: [outputMode := 'トランスクリプト' asValue].
 32:     ^outputMode
 33: 
 34: ------------------------------------------------------------
 35: 
 36: KSU.WhatTime method for 'aspects'
 37: 
 38: showDate
 39: 
 40:     showDate ifNil: [showDate := false asValue].
 41:     ^showDate
 42: 
 43: ------------------------------------------------------------
 44: 
 45: KSU.WhatTime method for 'aspects'
 46: 
 47: showSeconds
 48: 
 49:     showSeconds ifNil: [showSeconds := false asValue].
 50:     ^showSeconds
 51: 
 52: ------------------------------------------------------------
 53: 
 54: KSU.WhatTime method for 'aspects'
 55: 
 56: showWeekday
 57: 
 58:     showWeekday ifNil: [showWeekday := false asValue].
 59:     ^showWeekday
 60: 
 61: ------------------------------------------------------------
 62: 
 63: KSU.WhatTime method for 'actions'
 64: 
 65: tellTime
 66:     "KSU.WhatTime new tellTime."
 67: 
 68:     | aTime aDate aStream aString |
 69:     aTime := Time now.
 70:     aDate := Date today.
 71:     aStream := String new writeStream.
 72:     self showDate value
 73:         ifTrue: 
 74:             [aStream
 75:                 nextPutAll: aDate year printString;
 76:                 nextPutAll: '年';
 77:                 nextPutAll: aDate monthIndex printString;
 78:                 nextPutAll: '月';
 79:                 nextPutAll: aDate dayOfMonth printString;
 80:                 nextPutAll: '日'].
 81:     self showWeekday value
 82:         ifTrue: 
 83:             [aStream
 84:                 nextPutAll: '(';
 85:                 nextPutAll: (#('月' '火' '水' '木' '金' '土' '日') at: aDate weekdayIndex);
 86:                 nextPutAll: ')'].
 87:     aStream
 88:         nextPutAll: aTime hours printString;
 89:         nextPutAll: '時';
 90:         nextPutAll: aTime minutes printString;
 91:         nextPutAll: '分'.
 92:     self showSeconds value
 93:         ifTrue: 
 94:             [aStream
 95:                 nextPutAll: aTime seconds printString;
 96:                 nextPutAll: '秒'].
 97:     aString := aStream contents.
 98:     aStream close.
 99:     self outputMode value = 'トランスクリプト'
100:         ifTrue: 
101:             [Transcript
102:                 cr;
103:                 show: aString]
104:         ifFalse: [Dialog warn: aString]
105: 
106: ================================================================================
107: 
108: KSU.WhatTime class
109:     instanceVariableNames: ''
110: 
111: ================================================================================
112: 
113: KSU.WhatTime class method for 'examples'
114: 
115: example1
116:     "KSU.WhatTime example1."
117: 
118:     | anApplication |
119:     anApplication := KSU.WhatTime new.
120:     anApplication open.
121:     ^anApplication
122: 
123: ------------------------------------------------------------
124: 
125: KSU.WhatTime class method for 'resources'
126: 
127: menuBar
128:     "Tools.MenuEditor new openOnClass: self andSelector: #menuBar"
129: 
130:     <resource: #menu>
131:     ^#(#{UI.Menu} #(
132:             #(#{UI.MenuItem} 
133:                 #rawLabel: 'ファイル' 
134:                 #submenu: #(#{UI.Menu} #(
135:                         #(#{UI.MenuItem} 
136:                             #rawLabel: '終了' 
137:                             #value: #closeRequest ) ) #(1 ) nil ) ) ) #(1 ) nil ) decodeAsLiteralArray
138: 
139: ------------------------------------------------------------
140: 
141: KSU.WhatTime class method for 'interface specs'
142: 
143: windowSpec
144:     "Tools.UIPainter new openOnClass: self andSelector: #windowSpec"
145: 
146:     <resource: #canvas>
147:     ^#(#{UI.FullSpec} 
148:         #window: 
149:         #(#{UI.WindowSpec} 
150:             #label: 'ボタンたち' 
151:             #min: #(#{Core.Point} 400 220 ) 
152:             #max: #(#{Core.Point} 0 0 ) 
153:             #bounds: #(#{Graphics.Rectangle} 1079 689 1479 909 ) 
154:             #flags: 4 
155:             #menu: #menuBar ) 
156:         #component: 
157:         #(#{UI.SpecCollection} 
158:             #collection: #(
159:                 #(#{UI.ActionButtonSpec} 
160:                     #layout: #(#{Graphics.Rectangle} 120 25 280 56 ) 
161:                     #name: #tellTime 
162:                     #model: #tellTime 
163:                     #label: 'いま何時かしら?' 
164:                     #isDefault: true 
165:                     #defaultable: true ) 
166:                 #(#{UI.CheckBoxSpec} 
167:                     #layout: #(#{Core.Point} 96 81 ) 
168:                     #name: #showDate 
169:                     #model: #showDate 
170:                     #label: '日付' ) 
171:                 #(#{UI.CheckBoxSpec} 
172:                     #layout: #(#{Core.Point} 96 113 ) 
173:                     #name: #showWeekday 
174:                     #model: #showWeekday 
175:                     #label: '曜日' ) 
176:                 #(#{UI.CheckBoxSpec} 
177:                     #layout: #(#{Core.Point} 96 145 ) 
178:                     #name: #showSeconds 
179:                     #model: #showSeconds 
180:                     #label: '秒' ) 
181:                 #(#{UI.RadioButtonSpec} 
182:                     #layout: #(#{Core.Point} 216 97 ) 
183:                     #name: #dialog 
184:                     #model: #outputMode 
185:                     #label: 'ダイアログ' 
186:                     #select: 'ダイアログ' ) 
187:                 #(#{UI.RadioButtonSpec} 
188:                     #layout: #(#{Core.Point} 216 129 ) 
189:                     #name: #transcript 
190:                     #model: #outputMode 
191:                     #label: 'トランスクリプト' 
192:                     #select: 'トランスクリプト' ) ) ) )
193: 
194: ================================================================================

This document was generated by KSU.TextDoclet on 2012/11/10 at 11:02:02.