Class: VRRichedit
- Inherits:
-
VRText
- Object
- SWin::Window
- VRWinComponent
- VRControl
- VRStdControl
- VREdit
- VRText
- VRRichedit
- Defined in:
- lib/vr/vrrichedit.rb
Defined Under Namespace
Modules: EventMaskConsts Classes: EventMask
Constant Summary collapse
- CFM_BOLD =
VRRichedit
This class represents RichEdit Control. The parent class is VRText and this also has the same methods and event handlers.
Overwritten Methods
These methods are overwritten to support over64k texts. — getSel — setSel(st,en,noscroll=0) — char2line(ptr)
Methods
— setTextFont(fontface,height=280,area=SCF_SELECTION)
Sets the text font. ((|area|)) parameter limits the changed area.
— getTextFont(selarea=true)
Gets the text font and its size of the area. If selarea is true, the area is the selected area and the other case, it means the default font.
— setTextColor(col,area=SCF_SELECTION)
Sets the color of the text in the area.
— getTextColor(selarea=true)
Gets the text color in the area which is same as ((<getTextFont>)).
— setBold(flag=true,area=SCF_SELECTION)
Sets or resets the text style into BOLD. When ((|flag|)) is true, the text is set to bold style.
— setItalic(flag=true,area=SCF_SELECTION)
Sets or resets the text style into ITALIC.
— setUnderlined(flag=true,area=SCF_SELECTION)
Sets or resets the text style into UNDERLINED.
— setStriked(flag=true,area=SCF_SELECTION)
Sets or resets the text style into STRIKE_OUT.
— bold?(selarea=true)
Inspects whether the text style in the area is bold or not. If ((|selarea|)) is true, the area is selected area.
— italic?(selarea=true)
Inspects whether the text style in the area is italic or not.
— underlined?(selarea=true)
Inspects whether the text style in the area is underlined or not.
— striked?(selarea=true)
Inspects whether the text style in the area is striked out or not.
— setAlignment(align)
Sets text alignment of current paragraph. ((|align|)) can be PFA_LEFT, PFA_RIGHT or PFA_CENTER of VRRichedit constansts.
— bkcolor=(color)
Sets the background color of the control.
— selformat(area=SCF_SELECTION)
Gets the text format in ((|area|)). The return value is an instance of FontStruct defined in rscutil.rb.
— selformat=(format)
Set the text format in the selected area. ((|format|)) must be an instance of FontStruct.
0x00000001
- CFM_ITALIC =
0x00000002
- CFM_UNDERLINE =
0x00000004
- CFM_STRIKEOUT =
0x00000008
- CFM_PROTECTED =
0x00000010
- CFM_LINK =
0x00000020
- CFM_SIZE =
0x80000000
- CFM_COLOR =
0x40000000
- CFM_FACE =
0x20000000
- CFM_OFFSET =
0x10000000
- CFM_CHARSET =
0x08000000
- CFE_BOLD =
0x0001
- CFE_ITALIC =
0x0002
- CFE_UNDERLINE =
0x0004
- CFE_STRIKEOUT =
0x0008
- CFE_PROTECTED =
0x0010
- CFE_LINK =
0x0020
- CFE_AUTOCOLOR =
0x40000000
- SCF_SELECTION =
0x0001
- SCF_WORD =
0x0002
- SCF_DEFAULT =
0x0000
- SCF_ALL =
not valid with SCF_SELECTION or SCF_WORD
0x0004
- SCF_USEUIRULES =
0x0008
- PFA_LEFT =
0x0001
- PFA_RIGHT =
0x0002
- PFA_CENTER =
0x0003
- PFM_STARTINDENT =
0x00000001
- PFM_RIGHTINDENT =
0x00000002
- PFM_OFFSET =
0x00000004
- PFM_ALIGNMENT =
0x00000008
- PFM_TABSTOPS =
0x00000010
- PFM_NUMBERING =
0x00000020
- PFM_OFFSETINDENT =
0x80000000
- CHARFORMATSIZE =
60
- MAX_TAB_STOPS =
32
- DEFAULTTABS =
[4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76]
Constants inherited from VRText
Constants inherited from VREdit
VREdit::VR_REGEXPNEWLINE, VREdit::WINCLASSINFO
Constants inherited from VRControl
Instance Attribute Summary
Attributes inherited from VRControl
Attributes inherited from VRWinComponent
Instance Method Summary collapse
- #bkcolor=(col) ⇒ Object
- #bold?(selarea = true) ⇒ Boolean
- #char2line(pt) ⇒ Object
- #eventmask ⇒ Object
- #getcharformat(mask = 0xf800003f, selectionarea = true) ⇒ Object
-
#getSel ⇒ Object
## ## ##.
- #getTextColor(selarea = true) ⇒ Object
- #getTextFont(selarea = true) ⇒ Object
- #italic?(selarea = true) ⇒ Boolean
- #richeditinit ⇒ Object
- #selformat(option = SCF_SELECTION) ⇒ Object
- #selformat=(f) ⇒ Object
- #setAlignment(align) ⇒ Object
- #setBold(flag = true, area = SCF_SELECTION) ⇒ Object
-
#setcharformat(area, effects, col = 0, mask = 0xf800003f, font = "System", height = 280, off = 0, pf = 2, charset = 128) ⇒ Object
parameter order is not the same of the return value of getcharformat().
- #setItalic(flag = true, area = SCF_SELECTION) ⇒ Object
- #setparaformat(mask = 0x8000003f, numbering = false, startindent = 0, rightindent = 0, offset = 0, align = PFA_LEFT, tabstops = DEFAULTTABS) ⇒ Object
- #setSel(st, en, noscroll = 0) ⇒ Object
- #setStriked(flag = true, area = SCF_SELECTION) ⇒ Object
- #setTextColor(col, area = SCF_SELECTION) ⇒ Object
- #setTextFont(fontface, height = 280, area = SCF_SELECTION) ⇒ Object
- #setUnderlined(flag = true, area = SCF_SELECTION) ⇒ Object
- #striked?(selarea = true) ⇒ Boolean
- #text ⇒ Object
- #underlined?(selarea = true) ⇒ Boolean
- #vrinit ⇒ Object
Methods inherited from VRText
#countLines, #getCurrentLine, #getLineLengthOf, #getLineTextOf, #line2char, #scrollTo, #scrolldown, #scrolldownPage, #scrolltocaret, #scrollup, #scrollupPage, #visibleStartLine
Methods inherited from VREdit
#clear, #copy, #cut, #limit, #limit=, #modified, #modified=, #paste, #readonly=, #replaceSel, #setCaret, #text=, #undo, #vrinitnew
Methods inherited from VRStdControl
#_vr_cmdhandlers, #addCommandHandler, #deleteCommandHandler
Methods inherited from VRControl
#add_parentcall, #call_parenthandler, #create, #setFont
Methods inherited from VRWinComponent
#_init, #create, #exwinstyle, #hide, #maximizebox, #maximizebox=, #minimizebox, #minimizebox=, #setscreen, #sizebox, #sizebox=, #tabstop, #tabstop=, #winstyle
Instance Method Details
#bkcolor=(col) ⇒ Object
322 323 324 325 326 327 328 |
# File 'lib/vr/vrrichedit.rb', line 322 def bkcolor=(col) if col then sendMessage WMsg::EM_SETBKGNDCOLOR,0,col.to_i else sendMessage WMsg::EM_SETBKGNDCOLOR,1,0 end end |
#bold?(selarea = true) ⇒ Boolean
282 283 284 285 |
# File 'lib/vr/vrrichedit.rb', line 282 def bold?(selarea=true) r=getcharformat(CFM_BOLD,selarea)[2] if (r&CFE_BOLD)==0 then false else true end end |
#char2line(pt) ⇒ Object
243 244 245 |
# File 'lib/vr/vrrichedit.rb', line 243 def char2line(pt) sendMessage WMsg::EM_EXLINEFROMCHAR,0,pt end |
#eventmask ⇒ Object
330 331 332 |
# File 'lib/vr/vrrichedit.rb', line 330 def eventmask EventMask.new(self) end |
#getcharformat(mask = 0xf800003f, selectionarea = true) ⇒ Object
208 209 210 211 212 213 214 |
# File 'lib/vr/vrrichedit.rb', line 208 def getcharformat(mask=0xf800003f,selectionarea=true) buffer = [CHARFORMATSIZE,0,0,0,0,0].pack("LLLLLL") buffer += "\0"* (CHARFORMATSIZE-buffer.length) f = (selectionarea)? 1 : 0 sendMessage WMsg::EM_GETCHARFORMAT,f,buffer return buffer.unpack("LLLLLLCC") << buffer[26..-2].delete("\0") end |
#getSel ⇒ Object
## ## ##
230 231 232 233 234 |
# File 'lib/vr/vrrichedit.rb', line 230 def getSel charrange = [0,0].pack("LL") sendMessage WMsg::EM_EXGETSEL,0,charrange return charrange.unpack("LL") end |
#getTextColor(selarea = true) ⇒ Object
258 259 260 |
# File 'lib/vr/vrrichedit.rb', line 258 def getTextColor(selarea=true) getcharformat(CFM_COLOR,selarea)[5] end |
#getTextFont(selarea = true) ⇒ Object
250 251 252 253 |
# File 'lib/vr/vrrichedit.rb', line 250 def getTextFont(selarea=true) r=getcharformat(CFM_FACE|CFM_SIZE,selarea) return r[3],r[8] end |
#italic?(selarea = true) ⇒ Boolean
286 287 288 289 |
# File 'lib/vr/vrrichedit.rb', line 286 def italic?(selarea=true) r=getcharformat(CFM_ITALIC,selarea)[2] if (r&CFE_ITALIC)==0 then false else true end end |
#richeditinit ⇒ Object
181 182 183 184 |
# File 'lib/vr/vrrichedit.rb', line 181 def richeditinit sendMessage WMsg::EM_SETLANGOPTIONS,0,0 eventmask.enm_change=true end |
#selformat(option = SCF_SELECTION) ⇒ Object
313 314 315 316 317 318 319 320 |
# File 'lib/vr/vrrichedit.rb', line 313 def selformat(option=SCF_SELECTION) r=getcharformat(option) weight = if (r[2] & 1)>0 then 600 else 300 end style = (r[2]/2) & 0xf #mask width = r[3]/2 # tekitou.... point = r[3]/2 FontStruct.new2([r[8],r[3],style,weight,width,0,0,r[7],r[6]],point,r[5]) end |
#selformat=(f) ⇒ Object
303 304 305 306 307 308 309 310 311 |
# File 'lib/vr/vrrichedit.rb', line 303 def selformat=(f) raise "format must be an instance of FontStruct" unless f.is_a?(FontStruct) effects = f.style*2 + if f.weight>400 then 1 else 0 end height = if f.height>0 then f.height else f.point*2 end offset=0 setcharformat SCF_SELECTION,effects,f.color,0xf800003f,f.fontface,height, offset,f.pitch_family,f.charset f end |
#setAlignment(align) ⇒ Object
299 300 301 |
# File 'lib/vr/vrrichedit.rb', line 299 def setAlignment(align) setparaformat(PFM_ALIGNMENT,false,0,0,0,align) end |
#setBold(flag = true, area = SCF_SELECTION) ⇒ Object
262 263 264 265 |
# File 'lib/vr/vrrichedit.rb', line 262 def setBold(flag=true,area=SCF_SELECTION) f = (flag)? CFE_BOLD : 0 setcharformat(area,f,0,CFM_BOLD) end |
#setcharformat(area, effects, col = 0, mask = 0xf800003f, font = "System", height = 280, off = 0, pf = 2, charset = 128) ⇒ Object
parameter order is not the same of the return value of getcharformat()
199 200 201 202 203 204 205 206 |
# File 'lib/vr/vrrichedit.rb', line 199 def setcharformat(area,effects,col=0,mask=0xf800003f, font="System",height=280,off=0,pf=2,charset=128) buffer = [CHARFORMATSIZE,mask,effects, height,off,col,charset,pf].pack("LLLLLLCC") buffer += font.to_s + "\0" buffer += "\0"*(CHARFORMATSIZE-buffer.length) sendMessage(WMsg::EM_SETCHARFORMAT,area,buffer) end |
#setItalic(flag = true, area = SCF_SELECTION) ⇒ Object
267 268 269 270 |
# File 'lib/vr/vrrichedit.rb', line 267 def setItalic(flag=true,area=SCF_SELECTION) f = (flag)? CFE_ITALIC : 0 setcharformat(area,f,0,CFM_ITALIC) end |
#setparaformat(mask = 0x8000003f, numbering = false, startindent = 0, rightindent = 0, offset = 0, align = PFA_LEFT, tabstops = DEFAULTTABS) ⇒ Object
216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/vr/vrrichedit.rb', line 216 def setparaformat(mask=0x8000003f,numbering=false,startindent=0,rightindent=0, offset=0,align=PFA_LEFT,tabstops=DEFAULTTABS) size=4*7+4*MAX_TAB_STOPS fNumber= if numbering then 1 else 0 end tabcount = (tabstops.size>MAX_TAB_STOPS)? MAX_TAB_STOPS : tabstops.size buffer = [ size,mask,fNumber,startindent,rightindent,offset,align,tabcount ].pack("LLLLLLII") buffer += tabstops.pack("L*") sendMessage WMsg::EM_SETPARAFORMAT,0,buffer end |
#setSel(st, en, noscroll = 0) ⇒ Object
235 236 237 238 239 240 241 242 |
# File 'lib/vr/vrrichedit.rb', line 235 def setSel(st,en,noscroll=0) charrange = [st,en].pack("LL") r=sendMessage WMsg::EM_EXSETSEL,0,charrange if(noscroll!=0 && noscroll) then scrolltocaret end return r end |
#setStriked(flag = true, area = SCF_SELECTION) ⇒ Object
277 278 279 280 |
# File 'lib/vr/vrrichedit.rb', line 277 def setStriked(flag=true,area=SCF_SELECTION) f = (flag)? CFE_STRIKEOUT : 0 setcharformat(area,f,0,CFM_STRIKEOUT) end |
#setTextColor(col, area = SCF_SELECTION) ⇒ Object
255 256 257 |
# File 'lib/vr/vrrichedit.rb', line 255 def setTextColor(col,area=SCF_SELECTION) setcharformat(area,0,col,CFM_COLOR) end |
#setTextFont(fontface, height = 280, area = SCF_SELECTION) ⇒ Object
247 248 249 |
# File 'lib/vr/vrrichedit.rb', line 247 def setTextFont(fontface,height=280,area=SCF_SELECTION) setcharformat(area,0,0,CFM_FACE|CFM_SIZE,fontface,height) end |
#setUnderlined(flag = true, area = SCF_SELECTION) ⇒ Object
272 273 274 275 |
# File 'lib/vr/vrrichedit.rb', line 272 def setUnderlined(flag=true,area=SCF_SELECTION) f = (flag)? CFE_UNDERLINE : 0 setcharformat(area,f,0,CFM_UNDERLINE) end |
#striked?(selarea = true) ⇒ Boolean
294 295 296 297 |
# File 'lib/vr/vrrichedit.rb', line 294 def striked?(selarea=true) r=getcharformat(CFM_STRIKEOUT,selarea)[2] if (r&CFE_STRIKEOUT)==0 then false else true end end |
#text ⇒ Object
191 192 193 194 195 196 |
# File 'lib/vr/vrrichedit.rb', line 191 def text len=textlength+1 buffer = "\0"*len sendMessage WMsg::WM_GETTEXT,len,buffer buffer[0..-2].gsub(/\r\n/,$/) end |
#underlined?(selarea = true) ⇒ Boolean
290 291 292 293 |
# File 'lib/vr/vrrichedit.rb', line 290 def underlined?(selarea=true) r=getcharformat(CFM_UNDERLINE,selarea)[2] if (r&CFE_UNDERLINE)==0 then false else true end end |
#vrinit ⇒ Object
186 187 188 189 |
# File 'lib/vr/vrrichedit.rb', line 186 def vrinit super richeditinit end |