Class: VRTooltip

Inherits:
SWin::Window
  • Object
show all
Defined in:
lib/vr/vrtooltip.rb

Defined Under Namespace

Classes: VRTooltipTool

Instance Method Summary collapse

Instance Method Details

#activate=(f) ⇒ Object



147
148
149
150
# File 'lib/vr/vrtooltip.rb', line 147

def activate=(f)
  i = if f then 1 else 0 end
  sendMessage WMsg::TTM_ACTIVATE,i,0
end

#addTool(cnt, text) ⇒ Object



193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/vr/vrtooltip.rb', line 193

def addTool(cnt,text)
  if classcheck("VRStatic",cnt) then
    sx=cnt.x; sy=cnt.y; ex=sx+cnt.w; ey=sy+cnt.h
    rect = [sx,sy,ex,ey]
    return addToolArea(rect,text)
  end
  if classcheck("VRToolbar::VRToolbarButton",cnt) then
    rect = [0,0,0,0].pack("LLLL")
    cnt.toolbar.sendMessage WMsg::TB_GETITEMRECT,cnt.index,rect
    return addToolArea(rect.unpack("LLLL"),text,cnt.toolbar)
  end

  ti = createTIPTOOLCore
  ti[1] |= WConst::TTF_IDISHWND 
  ti[3] = cnt.hWnd
  ti[9] =text
  addToolCore(ti)
  @_vr_tools[ ti[2,2] ] = VRTooltipTool.new(@parent.hWnd,cnt.hWnd,cnt)
end

#addToolArea(rect, text, wnd = @parent) ⇒ Object



213
214
215
216
217
218
219
220
221
# File 'lib/vr/vrtooltip.rb', line 213

def addToolArea(rect,text,wnd=@parent)
  sx,sy,ex,ey = *rect
  ti = createTIPTOOLCore wnd
  ti[3] = @parent.newControlID
  ti[4]=sx ; ti[5]=sy; ti[6]=ex ; ti[7]=ey
  ti[9] =text
  addToolCore(ti)
  @_vr_tools[ ti[2,2] ] = VRTooltipTool.new(@parent.hWnd,ti[3],rect)
end

#autopopTimeObject



161
162
163
# File 'lib/vr/vrtooltip.rb', line 161

def autopopTime
  sendMessage WMsg::TTM_GETDELAYTIME,2,0
end

#autopopTime=(msec) ⇒ Object



170
171
172
# File 'lib/vr/vrtooltip.rb', line 170

def autopopTime=(msec)
  sendMessage WMsg::TTM_SETDELAYTIME,2,MAKELPARAM(msec,0)
end

#bkColorObject



180
181
182
# File 'lib/vr/vrtooltip.rb', line 180

def bkColor
  sendMessage WMsg::TTM_GETTIPBKCOLOR,0,0
end

#bkColor=(c) ⇒ Object



183
184
185
# File 'lib/vr/vrtooltip.rb', line 183

def bkColor=(c)
  sendMessage WMsg::TTM_SETTIPBKCOLOR,c.to_i,0
end

#delTool(ttt) ⇒ Object



223
224
225
226
227
228
229
230
231
# File 'lib/vr/vrtooltip.rb', line 223

def delTool(ttt)
  raise "Requires VRTooltipTool (#{ttt.class})" unless ttt.is_a?(VRTooltipTool)
  ti=createTIPTOOLCore
  ti[2] = ttt.hwnd
  ti[3] = ttt.uid
  tts = ti.pack(WStruct::TOOLINFO)
  @_vr_tools.delete(ti[2,2])
  sendMessage WMsg::TTM_DELTOOL,0,tts
end

#enumToolObject



233
234
235
236
237
238
239
# File 'lib/vr/vrtooltip.rb', line 233

def enumTool
  r = sendMessage WMsg::TTM_GETTOOLCOUNT,0,0
  raise "Unknown error" if r!=@_vr_tools.size
  @_vr_tools.each do |key,val|
    yield val
  end
end

#getTextOf(ttt, maxlength = 1024) ⇒ Object

there is no way to determine the length



241
242
243
244
245
246
247
248
249
250
251
# File 'lib/vr/vrtooltip.rb', line 241

def getTextOf(ttt,maxlength=1024)  # there is no way to determine the length
  ti = createTIPTOOLCore
  buffer = "\0\0\0\0" * (maxlength/4+1) 
  ti[2] = ttt.hwnd
  ti[3] = ttt.uid
  ti[9] = buffer
  tis = ti.pack(WStruct::TOOLINFO)
  sendMessage WMsg::TTM_GETTEXT,0,tis
  buffer.gsub!(/\0.*/,'')
  buffer
end

#initialTimeObject



164
165
166
# File 'lib/vr/vrtooltip.rb', line 164

def initialTime
  sendMessage WMsg::TTM_GETDELAYTIME,3,0
end

#initialTime=(msec) ⇒ Object



173
174
175
# File 'lib/vr/vrtooltip.rb', line 173

def initialTime=(msec)
  sendMessage WMsg::TTM_SETDELAYTIME,3,MAKELPARAM(msec,0)
end

#maxtipwidthObject



157
158
159
# File 'lib/vr/vrtooltip.rb', line 157

def maxtipwidth
  sendMessage WMsg::TTM_GETMAXTIPWIDTH,0,0
end

#maxtipwidth=(w) ⇒ Object



152
153
154
155
# File 'lib/vr/vrtooltip.rb', line 152

def maxtipwidth=(w)
  s=[w].pack("L")
  sendMessage WMsg::TTM_SETMAXTIPWIDTH,0,s
end

#reshowTimeObject



167
168
169
# File 'lib/vr/vrtooltip.rb', line 167

def reshowTime
  sendMessage WMsg::TTM_GETDELAYTIME,1,0
end

#reshowTime=(msec) ⇒ Object



176
177
178
# File 'lib/vr/vrtooltip.rb', line 176

def reshowTime=(msec)
  sendMessage WMsg::TTM_SETDELAYTIME,1,MAKELPARAM(msec,0)
end

#setparam(parent, screen) ⇒ Object



143
144
145
# File 'lib/vr/vrtooltip.rb', line 143

def setparam(parent,screen)
  @parent,@screen = parent,screen unless defined? @screen
end

#setTextOf(ttt, text) ⇒ Object



253
254
255
256
257
258
# File 'lib/vr/vrtooltip.rb', line 253

def setTextOf(ttt,text)
  ti = getTOOLINFOCore(ttt.hwnd,ttt.uid)
  ti[9] = text
  tis = ti.pack(WStruct::TOOLINFO)
  sendMessage WMsg::TTM_SETTOOLINFO,0,tis
end

#textColorObject



186
187
188
# File 'lib/vr/vrtooltip.rb', line 186

def textColor
  sendMessage WMsg::TTM_GETTIPTEXTCOLOR,0,0
end

#textColor=(c) ⇒ Object



189
190
191
# File 'lib/vr/vrtooltip.rb', line 189

def textColor=(c)
  sendMessage WMsg::TTM_SETTIPTEXTCOLOR,c.to_i,0
end