SelFont

SelFont

Postby Otto » Tue Jan 02, 2007 6:15 pm

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: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Re: SelFont

Postby Enrico Maria Giordano » Tue Jan 02, 2007 8:13 pm

Have a look on how oFont:Choose() method is implemented.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Otto » Wed Jan 03, 2007 6:39 am

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

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

Postby Antonio Linares » Wed Jan 03, 2007 6:47 am

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
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Otto » Wed Jan 03, 2007 7:56 am

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

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

Postby Enrico Maria Giordano » Wed Jan 03, 2007 10:19 am

Search for all *.prg containing ChooseFont.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Otto » Wed Jan 03, 2007 11:14 am

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
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Postby Enrico Maria Giordano » Wed Jan 03, 2007 12:09 pm

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Otto » Wed Jan 03, 2007 12:26 pm

I understand - but how?
Thanks in advance
Otto
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Postby Antonio Linares » Wed Jan 03, 2007 12:33 pm

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
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Rossine » Wed Jan 03, 2007 1:18 pm

Hello Oto,

Try this:

Code: Select all  Expand view
// 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.
Rossine
 
Posts: 344
Joined: Tue Oct 11, 2005 11:33 am

Postby Otto » Wed Jan 03, 2007 5:06 pm

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
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Postby Enrico Maria Giordano » Wed Jan 03, 2007 5:13 pm

I still don't understand from what you want to extract the color. You have to define the font color separately.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Otto » Wed Jan 03, 2007 5:29 pm

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
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Postby James Bott » Wed Jan 03, 2007 5:42 pm

Otto,

Here is the selFont() method from TWindow:

Code: Select all  Expand view
   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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 91 guests