FoX: how to set font for an FXTable item

Y

Yuri Leikind

Hello all,

Is there a way to set font for a single FXTableItem ? FXTableItem does not
have an appropriate method, there is only a way to set font for the whole
FXTable, globally.
 
J

Jim Moy

Yuri said:
Is there a way to set font for a single FXTableItem ? FXTableItem does not
have an appropriate method, there is only a way to set font for the whole
FXTable, globally.

Call FXTableItem.setItem on your subclass of FXTableItem, then twiddle
to your heart's content in drawContent.

Jim
 
Y

Yuri Leikind

Call FXTableItem.setItem on your subclass of FXTableItem, then twiddle
to your heart's content in drawContent.


Perhaps you meant calling FXTable.setItem on my subclass of FXTableItem?

Ok, I define my subclass of FXTableItem with drawContent :


class MyTableItem < Fox::FXTableItem
def drawContent(table, dc, x, y, w, h)

dc.setTextFont(MY_FONT)
dc.foreground = Fox::FXRGB(255, 240, 240)

super(table, dc, x, y, w, h)
end
end

and then, when creating the table:

table.setItem(i, j, MyTableItem.new("hello"))

But well, that doesn't work. Did I miss something?
 
J

Jim Moy

Yuri said:
Perhaps you meant calling FXTable.setItem on my subclass of FXTableItem?

Yes, my mistake, I mis-typed.
Ok, I define my subclass of FXTableItem with drawContent :
class MyTableItem < Fox::FXTableItem
def drawContent(table, dc, x, y, w, h)
dc.setTextFont(MY_FONT)
dc.foreground = Fox::FXRGB(255, 240, 240)
super(table, dc, x, y, w, h)
But well, that doesn't work. Did I miss something?

It looks like super() is overriding your font setting. Here's what I do:

def drawContent(table, dc, x, y, w, h)
FXDCWindow.new( table ) do |mydc|
mydc.textFont = ...
mydc.drawText(...)
end
end

Can't remember why the param dc wasn't usable and I had to do the mydc
thing, it's been a while since I was in that code...

Jim
 
Y

Yuri Leikind

Yes, my mistake, I mis-typed.


It looks like super() is overriding your font setting. Here's what I do:

def drawContent(table, dc, x, y, w, h)
FXDCWindow.new( table ) do |mydc|
mydc.textFont = ...
mydc.drawText(...)
end
end

Can't remember why the param dc wasn't usable and I had to do the mydc
thing, it's been a while since I was in that code...

Thank you for your help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,438
Messages
2,571,699
Members
48,796
Latest member
Greg L.
Top