vruby 2004.08.07

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,193 @@
1
+ ###################################
2
+ #
3
+ # vrolednd.rb
4
+ # Programmed by nyasu <nyasu@osk.3web.ne.jp>
5
+ # Copyright 2002 Nishikawa,Yasuhiro
6
+ #
7
+ # More information at http://www.threeweb.ad.jp/~nyasu/software/vrproject.html
8
+ # (in Japanese)
9
+ #
10
+ ###################################
11
+
12
+ VR_DIR="vr/" unless defined?(::VR_DIR)
13
+ require VR_DIR+'sysmod'
14
+ require VR_DIR+'dragdropformat'
15
+
16
+ module OleDnDConstants
17
+ IDROPTARGET_NOTIFY_DRAGENTER=0
18
+ IDROPTARGET_NOTIFY_DRAGOVER=1
19
+ IDROPTARGET_NOTIFY_DRAGLEAVE=2
20
+ IDROPTARGET_NOTIFY_DROP=3
21
+
22
+ DROPEFFECT_NONE=0
23
+ DROPEFFECT_COPY=1
24
+ DROPEFFECT_MOVE=2
25
+ DROPEFFECT_LINK=4
26
+ end
27
+
28
+
29
+ module VROleDropTarget
30
+ =begin
31
+ == VROleDropTarget
32
+ A module for OLE drop target.
33
+ Include this module to make a window as an ole drop target.
34
+ === Instance Variables
35
+ --- vr_oledropmessage
36
+ Message ID to notify OLE drag-and-drop matter.
37
+ === Methods
38
+ --- start_oledroptarget(formats)
39
+ Starts the window as OLE drop target.
40
+ ((|formats|)) is an array of acceptable formats (CF_TEXT, and so on).
41
+
42
+ === Event handlers
43
+ --- self_oledragenter(format,keystate)
44
+ This notifies entering OLE drag on the window.
45
+ This method must return ((|Effects|)). The default effect is DROPEFFECT_COPY.
46
+ --- self_oledragover(keystate)
47
+ This notifies OLE dragging cursor is moving on the window.
48
+ This method must return ((|Effects|)) or ((|nil|)).
49
+ ((|nil|)) means "same as before". The default effect is ((|nil|)).
50
+ --- self_oledragleave
51
+ This notifies leaving OLE drag cursor.
52
+ --- self_oledrop(handle,format,keystate)
53
+ This notifies the item is dropped. Global heap handle of ((|handle|))
54
+ containing the contents of dropped object.
55
+ When the object is multi-formattedformat, it's in the first format that
56
+ appears in the argument array of start_oledroptarget() .
57
+ =end
58
+
59
+ include ClipboardFormat
60
+ include OleDnDConstants
61
+ include VRUserMessageUseable
62
+
63
+ IDROPTARGET_NOTIFY = "IIIIII" #*ppt,dwEffect,grfKeyState,cfFormat,hMem,*data
64
+
65
+ def vrinit
66
+ super
67
+ oledroptargetinit
68
+ end
69
+
70
+ def oledroptargetinit
71
+ @vr_oledropmessage = registerUserMessage(ReservedMsg::WM_VR_OLEDND,"vr_olednd",0)
72
+ addEvent @vr_oledropmessage
73
+ end
74
+
75
+ def start_oledroptarget(formats)
76
+ self.dndTargetStart( @vr_oledropmessage ,formats )
77
+ end
78
+
79
+ def self_vr_olednd(wparam,lparam)
80
+ notify = @screen.application.cstruct2array(lparam,IDROPTARGET_NOTIFY)
81
+ @vr_olednd_notify=notify
82
+ case wparam
83
+ when IDROPTARGET_NOTIFY_DRAGENTER
84
+ if notify[3]==0 then
85
+ @screen.application.pokeMemory(lparam+4,0,4) # effect none
86
+ return
87
+ end
88
+ r = selfmsg_dispatching("oledragenter",notify[3],notify[2]).to_i
89
+ @screen.application.pokeMemory(lparam+4,r,4) # effect r
90
+ when IDROPTARGET_NOTIFY_DRAGOVER
91
+ r = selfmsg_dispatching("oledragover",notify[2])
92
+ if r then
93
+ r = r.to_i
94
+ @screen.application.pokeMemory(lparam+4,r,4) # effect r
95
+ end
96
+ when IDROPTARGET_NOTIFY_DRAGLEAVE
97
+ selfmsg_dispatching("oledragleave")
98
+ when IDROPTARGET_NOTIFY_DROP
99
+ return if notify[3]==0
100
+ # selfmsg_dispatching("oledropraw",dataobj,notify[2])
101
+ selfmsg_dispatching("oledrop",notify[4],notify[3],notify[2])
102
+ end
103
+ @vr_olednd_notify=nil
104
+ end
105
+
106
+ def self_oledragenter(format,keystate)
107
+ DROPEFFECT_COPY
108
+ end
109
+
110
+ def self_oledragover(keystate)
111
+ nil
112
+ end
113
+
114
+ def self_oledragleave
115
+ end
116
+
117
+ def self_oledrop(handle,format,keystate)
118
+ end
119
+ end
120
+
121
+
122
+ module VROleDragSourceLow
123
+ =begin
124
+ == VROleDragSourceLow
125
+ A module for OLE drag source. (low level)
126
+
127
+ === Methods
128
+ --- start_oledragsource(formats,effect= DROPEFFECT_COPY|DROPEFFECT_MOVE)
129
+ Starts OLE Drag Drop. The dragged object is in the formats of ((|formats|)).
130
+ Acceptable effects is to be set for ((|effect|)).
131
+
132
+ === Event handlers
133
+ --- self_getoledragitem(format)
134
+ Fired when DropTarget requires the dragged data in the ((|format|))
135
+ This method must return the Global heap handle containing the dragged object.
136
+ If the handle is not available, return 0.
137
+ =end
138
+
139
+ include ClipboardFormat
140
+ include OleDnDConstants
141
+ include VRUserMessageUseable
142
+
143
+ def vrinit
144
+ super
145
+ oledragsourcelowinit
146
+ end
147
+
148
+ def oledragsourcelowinit
149
+ @vr_oledragmessage = registerUserMessage(ReservedMsg::WM_VR_OLEDND,"vr_oledrag",0)
150
+ addEvent @vr_oledragmessage
151
+ end
152
+
153
+ def set_dragobj_lparam(lparam,hMem)
154
+ @screen.application.pokeMemory(lparam,hMem,4)
155
+ end
156
+
157
+ def start_oledragsource(formats,effect=0x3)
158
+ dndSourceStart @vr_oledragmessage,formats,effect
159
+ end
160
+
161
+ def self_vr_oledrag(wparam,lparam)
162
+ handle = selfmsg_dispatching("getoledragitem",wparam).to_i
163
+ set_dragobj_lparam(lparam,handle)
164
+ end
165
+
166
+ def self_getoledragitem(format)
167
+ 0
168
+ end
169
+
170
+ end
171
+
172
+ module VROleDragSource
173
+ include VROleDragSourceLow
174
+
175
+ def start_oledrag(objs,effect=0x3)
176
+ @_vr_draghash={}
177
+ formats = []
178
+ objs.each do |o|
179
+ formats.push o.objectformat
180
+ @_vr_draghash[o.objectformat] = o
181
+ end
182
+ start_oledragsource(formats,effect)
183
+ end
184
+
185
+ def self_getoledragitem(format)
186
+ return 0 unless @_vr_draghash
187
+
188
+ ddobj = @_vr_draghash[format]
189
+
190
+ if ddobj then ddobj.handle else 0 end
191
+ end
192
+
193
+ end
@@ -0,0 +1,109 @@
1
+ ###################################
2
+ #
3
+ # vrowndraw.rb
4
+ # Programmed by nyasu <nyasu@osk.3web.ne.jp>
5
+ # Copyright 1999-2001 Nishikawa,Yasuhiro
6
+ #
7
+ # More information at http://www.threeweb.ad.jp/~nyasu/software/vrproject.html
8
+ # (in Japanese)
9
+ #
10
+ ###################################
11
+
12
+ VR_DIR="vr/" unless defined?(::VR_DIR)
13
+ require VR_DIR+'vrcontrol'
14
+
15
+ module WMsg
16
+ WM_DRAWITEM = 0x002B
17
+ end
18
+
19
+ module VROwnerDrawControlContainer
20
+ =begin
21
+ == VROwnerDrawControlContainer
22
+ This module provides a message handler for WM_DRAWITEM.
23
+ VRForm includes this module automatically loading "vrowndraw.rb".
24
+ =end
25
+
26
+ include VRMessageHandler
27
+
28
+ HANDLERNAME="ownerdraw"
29
+
30
+ def ownerdrawinit
31
+ addHandler(WMsg::WM_DRAWITEM,"vrwmdrawitem",
32
+ MSGTYPE::ARGINTSTRUCT,"UUUUUUUUUUUU")
33
+ addEvent WMsg::WM_DRAWITEM
34
+ addNoRelayMessages [WMsg::WM_DRAWITEM]
35
+ end
36
+
37
+ def vrinit
38
+ super
39
+ ownerdrawinit
40
+ end
41
+
42
+ def self_vrwmdrawitem(wParam,args)
43
+ id=LOWORD(wParam)
44
+ ct=@controls[id] # Activated Control
45
+
46
+ return unless ct # can't find?
47
+ r=0
48
+ ct.dopaint(args[6]) do
49
+ if ct.respond_to?(HANDLERNAME)
50
+ r=ct.__send__(HANDLERNAME,*args[2..11])
51
+ end
52
+ end
53
+ SKIP_DEFAULTHANDLER[r]
54
+ end
55
+ end
56
+
57
+ module VRContainersSet
58
+ include VROwnerDrawControlContainer
59
+ end
60
+
61
+
62
+
63
+ class VROwnerDrawButton < VRButton
64
+ =begin
65
+ == VROwnerDrawButton
66
+ Owner draw button.
67
+ This is just a button but the system doesn't draw button faces.
68
+ It's necessary to draw button face manually.
69
+
70
+ === Required methods
71
+ In these method, it doesn't need to call ((*dopaint*)).
72
+
73
+ --- drawpushed(left,top,right,bottom,state)
74
+ Draws the pushed button face.
75
+ --- drawreleased(left,top,right,bottom,state)
76
+ Draws the released button face.
77
+ --- drawfocused(left,top,right,bottom,state)
78
+ Draws the focused button face.
79
+ This method is fired after drawpushed or drawreleased.
80
+ =end
81
+
82
+ BS_OWNERDRAW = 0x0000000B
83
+ WINCLASSINFO = ["BUTTON", BS_OWNERDRAW]
84
+
85
+ def ownerdraw(iid,action,state,hwnd,hdc,left,top,right,bottom,data)
86
+ self.opaque=false
87
+ if (pushed = ((state & 1)>0) ) then
88
+ drawpushed(left,top,right,bottom,state)
89
+ @parent.controlmsg_dispatching(self,
90
+ "drawpushed",left,top,right,bottom,state)
91
+ else
92
+ drawreleased(left,top,right,bottom,state)
93
+ @parent.controlmsg_dispatching(self,
94
+ "drawreleased",left,top,right,bottom,state)
95
+ end
96
+
97
+ if (state & 0x10)>0 then
98
+ drawfocused(left,top,right,bottom,state)
99
+ @parent.controlmsg_dispatching(self,
100
+ "drawfocused",left,top,right,bottom,state)
101
+ end
102
+ end
103
+
104
+ def drawpushed(left,top,right,bottom,state) end
105
+ def drawreleased(left,top,right,bottom,state) end
106
+ def drawfocused(left,top,right,bottom,state) end
107
+ end
108
+
109
+
@@ -0,0 +1,335 @@
1
+ ###################################
2
+ #
3
+ # vrrichedit.rb
4
+ # Programmed by nyasu <nyasu@osk.3web.ne.jp>
5
+ # Copyright 2000-2001 Nishikawa,Yasuhiro
6
+ #
7
+ # More information at http://www.threeweb.ad.jp/~nyasu/software/vrproject.html
8
+ # (in Japanese)
9
+ #
10
+ ###################################
11
+
12
+ VR_DIR="vr/" unless defined?(::VR_DIR)
13
+ require VR_DIR+'vrcontrol'
14
+ require VR_DIR+'rscutil'
15
+ require 'Win32API'
16
+
17
+ module WMsg
18
+ EM_EXGETSEL = WM_USER+52
19
+ EM_EXLINEFROMCHAR= WM_USER+54
20
+ EM_EXSETSEL = WM_USER+55
21
+ EM_GETCHARFORMAT = WM_USER+58
22
+ EM_GETEVENTMASK = WM_USER+59
23
+ EM_GETPARAFORMAT = WM_USER+61
24
+ EM_SETBKGNDCOLOR = WM_USER+67
25
+ EM_SETCHARFORMAT = WM_USER+68
26
+ EM_SETEVENTMASK = WM_USER+69
27
+ EM_SETPARAFORMAT = WM_USER+71
28
+ EM_FINDTEXTEX = WM_USER+79
29
+ EM_SETLANGOPTIONS= WM_USER+120
30
+ end
31
+
32
+
33
+ class VRRichedit < VRText
34
+ =begin
35
+ == VRRichedit
36
+ This class represents RichEdit Control.
37
+ The parent class is VRText and this also has the same methods and event handlers.
38
+
39
+ === Overwritten Methods
40
+ These methods are overwritten to support over64k texts.
41
+ --- getSel
42
+ --- setSel(st,en,noscroll=0)
43
+ --- char2line(ptr)
44
+
45
+ === Methods
46
+ --- setTextFont(fontface,height=280,area=SCF_SELECTION)
47
+ Sets the text font. ((|area|)) parameter limits the changed area.
48
+ --- getTextFont(selarea=true)
49
+ Gets the text font and its size of the area.
50
+ If selarea is true, the area is the selected area and the other case,
51
+ it means the default font.
52
+ --- setTextColor(col,area=SCF_SELECTION)
53
+ Sets the color of the text in the area.
54
+ --- getTextColor(selarea=true)
55
+ Gets the text color in the area which is same as ((<getTextFont>)).
56
+ --- setBold(flag=true,area=SCF_SELECTION)
57
+ Sets or resets the text style into BOLD.
58
+ When ((|flag|)) is true, the text is set to bold style.
59
+ --- setItalic(flag=true,area=SCF_SELECTION)
60
+ Sets or resets the text style into ITALIC.
61
+ --- setUnderlined(flag=true,area=SCF_SELECTION)
62
+ Sets or resets the text style into UNDERLINED.
63
+ --- setStriked(flag=true,area=SCF_SELECTION)
64
+ Sets or resets the text style into STRIKE_OUT.
65
+ --- bold?(selarea=true)
66
+ Inspects whether the text style in the area is bold or not.
67
+ If ((|selarea|)) is true, the area is selected area.
68
+ --- italic?(selarea=true)
69
+ Inspects whether the text style in the area is italic or not.
70
+ --- underlined?(selarea=true)
71
+ Inspects whether the text style in the area is underlined or not.
72
+ --- striked?(selarea=true)
73
+ Inspects whether the text style in the area is striked out or not.
74
+ --- setAlignment(align)
75
+ Sets text alignment of current paragraph. ((|align|)) can be PFA_LEFT,
76
+ PFA_RIGHT or PFA_CENTER of VRRichedit constansts.
77
+ --- bkcolor=(color)
78
+ Sets the background color of the control.
79
+ --- selformat(area=SCF_SELECTION)
80
+ Gets the text format in ((|area|)). The return value is an instance of
81
+ FontStruct defined in rscutil.rb.
82
+ --- selformat=(format)
83
+ Set the text format in the selected area. ((|format|)) must be an instance
84
+ of FontStruct.
85
+ =end
86
+
87
+ CFM_BOLD = 0x00000001
88
+ CFM_ITALIC = 0x00000002
89
+ CFM_UNDERLINE = 0x00000004
90
+ CFM_STRIKEOUT = 0x00000008
91
+ CFM_PROTECTED = 0x00000010
92
+ CFM_LINK = 0x00000020
93
+ CFM_SIZE = 0x80000000
94
+ CFM_COLOR = 0x40000000
95
+ CFM_FACE = 0x20000000
96
+ CFM_OFFSET = 0x10000000
97
+ CFM_CHARSET = 0x08000000
98
+
99
+ CFE_BOLD = 0x0001
100
+ CFE_ITALIC = 0x0002
101
+ CFE_UNDERLINE = 0x0004
102
+ CFE_STRIKEOUT = 0x0008
103
+ CFE_PROTECTED = 0x0010
104
+ CFE_LINK = 0x0020
105
+ CFE_AUTOCOLOR = 0x40000000
106
+
107
+ SCF_SELECTION = 0x0001
108
+ SCF_WORD = 0x0002
109
+ SCF_DEFAULT = 0x0000
110
+ SCF_ALL = 0x0004 # not valid with SCF_SELECTION or SCF_WORD
111
+ SCF_USEUIRULES= 0x0008
112
+
113
+ PFA_LEFT = 0x0001
114
+ PFA_RIGHT = 0x0002
115
+ PFA_CENTER= 0x0003
116
+ PFM_STARTINDENT = 0x00000001
117
+ PFM_RIGHTINDENT = 0x00000002
118
+ PFM_OFFSET = 0x00000004
119
+ PFM_ALIGNMENT = 0x00000008
120
+ PFM_TABSTOPS = 0x00000010
121
+ PFM_NUMBERING = 0x00000020
122
+ PFM_OFFSETINDENT= 0x80000000
123
+
124
+ module EventMaskConsts
125
+ ENM_CHANGE = 0x00000001
126
+ ENM_UPDATE = 0x00000002
127
+ ENM_SCROLL = 0x00000004
128
+ end
129
+
130
+ class EventMask < Flags
131
+ CONSTMOD="VRRichedit::EventMaskConsts"
132
+ private
133
+ def integer_getter
134
+ @win.sendMessage WMsg::EM_GETEVENTMASK,0,0
135
+ end
136
+
137
+ def integer_setter(f)
138
+ @win.sendMessage WMsg::EM_SETEVENTMASK,0,f
139
+ end
140
+ end
141
+
142
+ CHARFORMATSIZE=60
143
+ MAX_TAB_STOPS=32
144
+ DEFAULTTABS=[4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76]
145
+
146
+ private
147
+ loadlib = Win32API.new("kernel32","LoadLibrary",["P"],"I")
148
+
149
+ libhandle = 0
150
+
151
+ =begin oop
152
+ #This causes GeneralProtectionViolation maybe for the late of RichEdit releasing.
153
+ freelib = Win32API.new("kernel32","FreeLibrary",["I"],"")
154
+ at_exit {
155
+ freelib.call(libhandle)
156
+ }
157
+ =end
158
+
159
+ def textlength
160
+ sendMessage WMsg::WM_GETTEXTLENGTH,0,0
161
+ end
162
+
163
+ # ooooops !
164
+ if (libhandle=loadlib.call("riched20"))!=0 then
165
+ RICHVERSION=2
166
+ def self.Controltype()
167
+ ["RICHEDIT20A",WStyle::ES_MULTILINE|WStyle::WS_VSCROLL,0x200]#EX_CLIENTEDGE
168
+ end
169
+ elsif (libhandle=loadlib.call("riched32"))!=0 then
170
+ RICHVERSION=1
171
+ def self.Controltype()
172
+ ["RICHEDIT",WStyle::ES_MULTILINE|WStyle::WS_VSCROLL,0x200] #EX_CLIENTEDGE
173
+ end
174
+ else
175
+ raise "no richedit control found"
176
+ end
177
+
178
+
179
+ public
180
+
181
+ def richeditinit
182
+ sendMessage WMsg::EM_SETLANGOPTIONS,0,0
183
+ eventmask.enm_change=true
184
+ end
185
+
186
+ def vrinit
187
+ super
188
+ richeditinit
189
+ end
190
+
191
+ def text
192
+ len=textlength+1
193
+ buffer = "\0"*len
194
+ sendMessage WMsg::WM_GETTEXT,len,buffer
195
+ buffer[0..-2].gsub(/\r\n/,$/)
196
+ end
197
+
198
+ # parameter order is not the same of the return value of getcharformat()
199
+ def setcharformat(area,effects,col=0,mask=0xf800003f,
200
+ font="System",height=280,off=0,pf=2,charset=128)
201
+ buffer = [CHARFORMATSIZE,mask,effects,
202
+ height,off,col,charset,pf].pack("LLLLLLCC")
203
+ buffer += font.to_s + "\0"
204
+ buffer += "\0"*(CHARFORMATSIZE-buffer.length)
205
+ sendMessage(WMsg::EM_SETCHARFORMAT,area,buffer)
206
+ end
207
+
208
+ def getcharformat(mask=0xf800003f,selectionarea=true)
209
+ buffer = [CHARFORMATSIZE,0,0,0,0,0].pack("LLLLLL")
210
+ buffer += "\0"* (CHARFORMATSIZE-buffer.length)
211
+ f = (selectionarea)? 1 : 0
212
+ sendMessage WMsg::EM_GETCHARFORMAT,f,buffer
213
+ return buffer.unpack("LLLLLLCC") << buffer[26..-2].delete("\0")
214
+ end
215
+
216
+ def setparaformat(mask=0x8000003f,numbering=false,startindent=0,rightindent=0,
217
+ offset=0,align=PFA_LEFT,tabstops=DEFAULTTABS)
218
+ size=4*7+4*MAX_TAB_STOPS
219
+ fNumber= if numbering then 1 else 0 end
220
+ tabcount = (tabstops.size>MAX_TAB_STOPS)? MAX_TAB_STOPS : tabstops.size
221
+
222
+ buffer = [
223
+ size,mask,fNumber,startindent,rightindent,offset,align,tabcount
224
+ ].pack("LLLLLLII")
225
+ buffer += tabstops.pack("L*")
226
+ sendMessage WMsg::EM_SETPARAFORMAT,0,buffer
227
+ end
228
+
229
+ ## ## ## ##
230
+ def getSel
231
+ charrange = [0,0].pack("LL")
232
+ sendMessage WMsg::EM_EXGETSEL,0,charrange
233
+ return charrange.unpack("LL")
234
+ end
235
+ def setSel(st,en,noscroll=0)
236
+ charrange = [st,en].pack("LL")
237
+ r=sendMessage WMsg::EM_EXSETSEL,0,charrange
238
+ if(noscroll!=0 && noscroll) then
239
+ scrolltocaret
240
+ end
241
+ return r
242
+ end
243
+ def char2line(pt)
244
+ sendMessage WMsg::EM_EXLINEFROMCHAR,0,pt
245
+ end
246
+
247
+ def setTextFont(fontface,height=280,area=SCF_SELECTION)
248
+ setcharformat(area,0,0,CFM_FACE|CFM_SIZE,fontface,height)
249
+ end
250
+ def getTextFont(selarea=true)
251
+ r=getcharformat(CFM_FACE|CFM_SIZE,selarea)
252
+ return r[3],r[8]
253
+ end
254
+
255
+ def setTextColor(col,area=SCF_SELECTION)
256
+ setcharformat(area,0,col,CFM_COLOR)
257
+ end
258
+ def getTextColor(selarea=true)
259
+ getcharformat(CFM_COLOR,selarea)[5]
260
+ end
261
+
262
+ def setBold(flag=true,area=SCF_SELECTION)
263
+ f = (flag)? CFE_BOLD : 0
264
+ setcharformat(area,f,0,CFM_BOLD)
265
+ end
266
+
267
+ def setItalic(flag=true,area=SCF_SELECTION)
268
+ f = (flag)? CFE_ITALIC : 0
269
+ setcharformat(area,f,0,CFM_ITALIC)
270
+ end
271
+
272
+ def setUnderlined(flag=true,area=SCF_SELECTION)
273
+ f = (flag)? CFE_UNDERLINE : 0
274
+ setcharformat(area,f,0,CFM_UNDERLINE)
275
+ end
276
+
277
+ def setStriked(flag=true,area=SCF_SELECTION)
278
+ f = (flag)? CFE_STRIKEOUT : 0
279
+ setcharformat(area,f,0,CFM_STRIKEOUT)
280
+ end
281
+
282
+ def bold?(selarea=true)
283
+ r=getcharformat(CFM_BOLD,selarea)[2]
284
+ if (r&CFE_BOLD)==0 then false else true end
285
+ end
286
+ def italic?(selarea=true)
287
+ r=getcharformat(CFM_ITALIC,selarea)[2]
288
+ if (r&CFE_ITALIC)==0 then false else true end
289
+ end
290
+ def underlined?(selarea=true)
291
+ r=getcharformat(CFM_UNDERLINE,selarea)[2]
292
+ if (r&CFE_UNDERLINE)==0 then false else true end
293
+ end
294
+ def striked?(selarea=true)
295
+ r=getcharformat(CFM_STRIKEOUT,selarea)[2]
296
+ if (r&CFE_STRIKEOUT)==0 then false else true end
297
+ end
298
+
299
+ def setAlignment(align)
300
+ setparaformat(PFM_ALIGNMENT,false,0,0,0,align)
301
+ end
302
+
303
+ def selformat=(f)
304
+ raise "format must be an instance of FontStruct" unless f.is_a?(FontStruct)
305
+ effects = f.style*2 + if f.weight>400 then 1 else 0 end
306
+ height = if f.height>0 then f.height else f.point*2 end
307
+ offset=0
308
+ setcharformat SCF_SELECTION,effects,f.color,0xf800003f,f.fontface,height,
309
+ offset,f.pitch_family,f.charset
310
+ f
311
+ end
312
+
313
+ def selformat(option=SCF_SELECTION)
314
+ r=getcharformat(option)
315
+ weight = if (r[2] & 1)>0 then 600 else 300 end
316
+ style = (r[2]/2) & 0xf #mask
317
+ width = r[3]/2 # tekitou....
318
+ point = r[3]/2
319
+ FontStruct.new2([r[8],r[3],style,weight,width,0,0,r[7],r[6]],point,r[5])
320
+ end
321
+
322
+ def bkcolor=(col)
323
+ if col then
324
+ sendMessage WMsg::EM_SETBKGNDCOLOR,0,col.to_i
325
+ else
326
+ sendMessage WMsg::EM_SETBKGNDCOLOR,1,0
327
+ end
328
+ end
329
+
330
+ def eventmask
331
+ EventMask.new(self)
332
+ end
333
+
334
+ end
335
+