SelFont

User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

SelFont

Post 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
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post by Otto »

Hello Enrico,
thank you for your answer.
How do I handle @nRGBColor?

Thanks in advance
Otto
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post 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.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post by Otto »

Thank you Antonio. Do you have a small code-example, too?

Thanks in advance
Otto
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post 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
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Color is not in the font definition. You have to manage it externally.

EMG
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post by Otto »

I understand - but how?
Thanks in advance
Otto
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Otto,

Please review samples\tgraph\test.prg

Once you have the selected color, you may do a oWnd:SetColor( ..., ... ) before painting
regards, saludos

Antonio Linares
www.fivetechsoft.com
Rossine
Posts: 343
Joined: Tue Oct 11, 2005 11:33 am

Post 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.
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post 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
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post 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
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post 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
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post 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
Post Reply