Module: WR::ModFDCommon

Included in:
ModControlHook, ModResourceHook, ModToplevelHook
Defined in:
lib/wrb/applications/frmdesigner/fdmodules.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.index_of_src(lns, lsrc) ⇒ Object



311
312
313
314
# File 'lib/wrb/applications/frmdesigner/fdmodules.rb', line 311

def index_of_src(lns, lsrc)
  lsrc_id = lsrc.__id__
  lns.index{|i| i.__id__==lsrc_id}
end

Instance Method Details

#__fd_delete_items_srcs(lns) ⇒ Object



345
346
347
348
349
350
351
352
# File 'lib/wrb/applications/frmdesigner/fdmodules.rb', line 345

def __fd_delete_items_srcs(lns)
  return unless @__fd_items_srcs
  @__fd_items_srcs.each{|i|
    col, len, lsrc = i
    lns.delete(lsrc)
  }
  @__fd_items_srcs.clear
end

#__fd_set_items_srcs(lns, curln, indent, ar) ⇒ Object



332
333
334
335
336
337
338
339
340
341
342
343
# File 'lib/wrb/applications/frmdesigner/fdmodules.rb', line 332

def __fd_set_items_srcs(lns, curln, indent, ar)
  if @__fd_items_srcs
    __fd_delete_items_srcs(lns)
  else
    extend ModFDItemsSrcLine
  end
  ar.each{|i|
    lns[curln+=1, 0] = (s=indent+i+"\n")
    @__fd_items_srcs << [indent.size, i.size, s]
  }
  curln
end

#__hittest(sx, sy) ⇒ Object

Argument is not pointer but 64bits integer



242
243
244
245
246
247
248
249
250
# File 'lib/wrb/applications/frmdesigner/fdmodules.rb', line 242

def __hittest(sx, sy) # Argument is not pointer but 64bits integer

  pt = API::POINT[*ScreenToClient(sx, sy)]
  cwnd = API.ChildWindowFromPoint(self._hwnd, (pt.y<<32) + pt.x)
  r = APP.hwnd2ref(cwnd)
  if r!=self && r.respond_to?(:controls)
    r = r.__hittest(sx, sy)
  end
  return r
end

#parse_template4out(ctrl, cmd, tp, defval = nil) ⇒ Object



264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
# File 'lib/wrb/applications/frmdesigner/fdmodules.rb', line 264

def parse_template4out(ctrl, cmd, tp, defval=nil)
  atr = ctrl.__send__(cmd.intern)
  return '' if atr == defval
  if (c=ctrl.class) < WinControl # ; dpp self, cmd, atr

    if (f=c::FDConfig["#{cmd}_out".intern])
      return f.call(ctrl, atr)
    elsif (f=c::FDConfig["#{cmd}_get".intern]) 
      return f.call(ctrl, atr)
    end
  end
  if atr.is_a?(Font)
    ar = [atr.facename, atr.height, atr.attrstr]
    ar.delete("")
    return sprintf("%p", ar)
  elsif tp && tp.size>1 && atr.respond_to?(:to_a)
    atr = atr.to_a
  end
  if !atr.is_a?(Array)
    case tp
    when 'h'
      sprintf("%#x", atr)
    when 'n'
      atr.respond_to?(:name) ? "_#{atr.name}" : atr.to_s
    when 'a'
      atr ? sprintf("%p", atr.to_a) : ''
    else
      sprintf("%p", atr)
    end
  else #; dpp ctrl, cmd, tp, atr

    tp = tp.split(',')[0]
    return sprintf("%p", atr) if tp=='a'
    r = []
    tp.size.times{|i|
      c = tp[i]
      case c
      when 'h'
        r << sprintf("%#x", atr[i])
      when 'n'
        r << (atr[i].respond_to?(:name) ? "_#{atr[i].name}" : atr[i].to_s)
      else
        r << sprintf("%p", atr[i])
      end
    }
    "[#{r.join(", ")}]"
  end
end

#style2symbolsObject



317
318
319
320
321
322
323
324
325
326
327
328
329
330
# File 'lib/wrb/applications/frmdesigner/fdmodules.rb', line 317

def style2symbols
  r = []
  st = self.style
  altmask = self.class::FDConfig[:altanate_mask] || []
  self.class::WinStyles.each{|k, v|
    m = altmask.find{|i| i&v>0 || (i&1>0 && v==0)}
    if m 
      next r << k if v==(st&m)
    else
      r << k if v==(v&st)
    end
  }
  r
end