VRuby; set color and background of a text label (VRStatic)

Hi,

how do I set the color and the background of a
VRStatic control?

I tried:

···


require 'vr/vruby’
require “vr/vrcontrol”

frm=VRLocalScreen.newform

def frm.construct
self.caption= "VisualuRuby Sample1"
addControl(VRStatic, “label1”,“This is Static”,200,50,200,40)
#@label1.setcolor(RGB(0xff,0xff,0xff))
p @label1.methods.grep(/olor/)
@label1.textColor=RGB(0xff,0xff,0xff)
end

frm.create
frm.show
VRLocalScreen.messageloop

and get:

sample.rb:11:in textColor=': Not in WM_PAINT event handling (StandardError) from sample.rb:11:inconstruct’
from c:/ruby/lib/ruby/site_ruby/1.8/vr/vruby.rb:508:in `create’
from sample.rb:14

Thanks for your help,
-A.

“Armin Roehrl” wrote:

Hi,

how do I set the color and the background of a
VRStatic control?

Hi Armin,

This uses vrctlcolor.rb which you should have in your vr/contrib folder.

(VRuby is for Windows only)

···

#----------------------------
require ‘vr/vruby’
require ‘vr/vrcontrol’
require ‘vr/vrhandler’ # (only using- vr/contrib/vrctlcolor)

class ARForm < VRForm
include VRCtlColor

def construct
self.caption= “Example - Colored VRStatic”
addControl(VRStatic, ‘lab1’, “Static Text\n… continued”, 100,50,200,80)

addCtlColor(@lab1)
@lab1.setTextColor(RGB(200,0,0))
@lab1.setBkColor(RGB(255,224,208))

end
end

VRLocalScreen.showForm(ARForm, 0, 0, 400, 400)
VRLocalScreen.messageloop
#----------------------------

daz

daz, thanks a lot!

My modified code below does not change the color
of the text.
If I uncomment the # in MyForm the color changes.
What can I do so that the color-change in a VRPanel works?

···

require ‘vr/vruby’
require ‘vr/vrhandler’
require ‘vr/vrdialog’
require ‘vr/vrcomctl’
require ‘vr/rscutil’
require 'vr/vrlayout

class Adresse < VRPanel
include VRMenuUseable
include VRGridLayoutManager
include WStyle
include WConst
include VRMessageParentRelayer
include VRStdControlContainer
include VRCtlColor

def construct
unit=10.0/9.0
self.setDimension(2,2)
addControl(VRStatic, “fn”, “Firma:”, 1, 1, 10, 10)
addControl(VRStatic, “firmenName”, “Müller GmbH”, 14, 1, 20, 10)
addCtlColor(@firmenName)
@firmenName.setTextColor(RGB(200,0,0))
@firmenName.setBkColor(RGB(255,224,208))
end
end

module MyForm
include VRMenuUseable
include VRGridLayoutManager
include WStyle
include WConst
include VRCtlColor

def construct
unit=10.0/9.0
setDimension(10,10)
addControl(Adresse, “panel”,“p”, 0.1+1.3unit ,0.2,4.75unit,3)
#addControl(VRStatic, “fn”, “Firma:”, 1, 1, 10, 10)
#addControl(VRStatic, “firmenName”, “Müller GmbH”, 5, 1, 20, 10)
#addCtlColor(@firmenName)
#@firmenName.setTextColor(RGB(200,0,0))
#@firmenName.setBkColor(RGB(255,224,208))
end

end

frm=VRLocalScreen.newform
frm.extend MyForm
frm.create.show
VRLocalScreen.messageloop
exit


Thank you,
-A

“Armin Roehrl” wrote:

Hi,

how do I set the color and the background of a
VRStatic control?

Hi Armin,

This uses vrctlcolor.rb which you should have in your vr/contrib folder.

(VRuby is for Windows only)

#----------------------------
require ‘vr/vruby’
require ‘vr/vrcontrol’
require ‘vr/vrhandler’ # (only using- vr/contrib/vrctlcolor)

class ARForm < VRForm
include VRCtlColor

def construct
self.caption= “Example - Colored VRStatic”
addControl(VRStatic, ‘lab1’, “Static Text\n… continued”, 100,50,200,80)

addCtlColor(@lab1)
@lab1.setTextColor(RGB(200,0,0))
@lab1.setBkColor(RGB(255,224,208))
end
end

VRLocalScreen.showForm(ARForm, 0, 0, 400, 400)
VRLocalScreen.messageloop
#----------------------------

daz