Page 1 of 2
SelFont
Posted: Tue Jan 02, 2007 6:15 pm
by Otto
I use oLbx:SelFont() to select a font for a listbox.
How can I store the selected font and size to an INI-file for a next time use?
Thanks in advance
Otto
Re: SelFont
Posted: Tue Jan 02, 2007 8:13 pm
by Enrico Maria Giordano
Have a look on how oFont:Choose() method is implemented.
EMG
Posted: Wed Jan 03, 2007 6:39 am
by Otto
Hello Enrico,
thank you for your answer.
How do I handle @nRGBColor?
Thanks in advance
Otto
Posted: Wed Jan 03, 2007 6:47 am
by Antonio Linares
Otto,
> How do I handle @nRGBColor?
It has to be supplied by reference to store the selected color. The font object does not hold the choosed color.
Posted: Wed Jan 03, 2007 7:56 am
by Otto
Thank you Antonio. Do you have a small code-example, too?
Thanks in advance
Otto
Posted: Wed Jan 03, 2007 10:19 am
by Enrico Maria Giordano
Search for all *.prg containing ChooseFont.
EMG
Posted: Wed Jan 03, 2007 11:14 am
by Otto
Hello Enrico,
thank you for your answer. But I can't find a way how to do.
1) DEFINE FONT oFontTest NAME "MS Sans Serif" SIZE -7.04,-16
and the color should be black.
2) I use oLbxX:SelFont() and would like to save the values
oLbxX:oFont:cFaceName () …
and also the chosen color. How to get the color?
Maybe you have a code example.
Regards
Otto
Posted: Wed Jan 03, 2007 12:09 pm
by Enrico Maria Giordano
Color is not in the font definition. You have to manage it externally.
EMG
Posted: Wed Jan 03, 2007 12:26 pm
by Otto
I understand - but how?
Thanks in advance
Otto
Posted: Wed Jan 03, 2007 12:33 pm
by Antonio Linares
Otto,
Please review samples\tgraph\test.prg
Once you have the selected color, you may do a oWnd:SetColor( ..., ... ) before painting
Posted: Wed Jan 03, 2007 1:18 pm
by Rossine
Hello Oto,
Try this:
Code: Select all
// Browsing arrays using TWBrowse
#include "FiveWin.ch"
//----------------------------------------------------------------------------//
function Main()
local oDlg, oBrw
local aSample := { { "First row one", "First row two" },;
{ "Second row one", "Second row two" },;
{ "Third row one", "Third row two" },;
{ "Fourth row one", "Fourth row two" } }
SET _3DLOOK ON
DEFINE DIALOG oDlg FROM 2, 2 TO 20, 60 TITLE "right click on the listbox"
@ 1, 2 LISTBOX oBrw ;
FIELDS "", "" ;
HEADERS "Reviewing two dimensions", "Array" ;
FIELDSIZES 150, 150 ;
OF oDlg ;
SIZE 150, 100 ;
ON DBLCLICK MsgInfo( "Array row: " + Str( oBrw:nAt ) + CRLF + ;
"Array col: " + Str( oBrw:nAtCol( nCol ) ) )
// bLine is a codeblock that returns an array
// if you need a 'traditional column based browse' have a look at TcBrowse
oBrw:nAt = 1
oBrw:bLine = { || { aSample[ oBrw:nAt ][ 1 ], aSample[ oBrw:nAt ][ 2 ] } }
oBrw:bGoTop = { || oBrw:nAt := 1 }
oBrw:bGoBottom = { || oBrw:nAt := Eval( oBrw:bLogicLen ) }
oBrw:bSkip = { | nWant, nOld | nOld := oBrw:nAt, oBrw:nAt += nWant,;
oBrw:nAt := Max( 1, Min( oBrw:nAt, Eval( oBrw:bLogicLen ) ) ),;
oBrw:nAt - nOld }
oBrw:bLogicLen = { || Len( aSample ) }
oBrw:cAlias = "Array" // Just put something
oBrw:brclicked := { |row,col| TROCA_FONT( oBrw ) }
@ 1, 30 BUTTON "&End" OF oDlg ACTION oDlg:End()
ACTIVATE DIALOG oDlg CENTERED
return nil
*******************
function TROCA_FONT( oBrw )
*******************
local oObj
oBrw:GetFont()
oBrw:SelFont()
oBrw:setcolor( oBrw:nClrText, choosecolor(oBrw:nClrPane) )
oBrw:refresh()
return NIL
Regards,
Rossine.
Posted: Wed Jan 03, 2007 5:06 pm
by Otto
Hello Antonio , hello Rossine,
thank you for your answer.
oWnd:SetColor( ..., ... ) does what I want but how can I extract color
as a return from oLbx:SelFont() .
Thanks in advance
Otto
Posted: Wed Jan 03, 2007 5:13 pm
by Enrico Maria Giordano
I still don't understand from what you want to extract the color. You have to define the font color separately.
EMG
Posted: Wed Jan 03, 2007 5:29 pm
by Otto
Hello Enrico,
adesso ti spiego ...
I do have a button where the user can change the font of the browser on the fly.
oLbxX:SelFont() does the job.
but then the new selection should become the new default setup.
Therefore I have to store all the values. If you start your program next time all your changes are still there.
Regards
Otto
Posted: Wed Jan 03, 2007 5:42 pm
by James Bott
Otto,
Here is the selFont() method from TWindow:
Code: Select all
METHOD SelFont() BLOCK { | Self, nClr | nClr := ::nClrText,;
::SetFont( If( ::oFont == nil,;
TFont():New( ,,,.t. ),;
::oFont:Choose( @nClr ) ) ),;
::oFont:nCount--,;
::nClrText := nClr, ::Refresh() }
TWBrowse inherts from TControl which inherits from TWindow, so this is the same method in TWBrowse.
You can see that ::nClrText is the font color. So oLbx:nClrText holds the RGB value of the font color.
James