Problem with Choose font

Problem with Choose font

Postby Silvio.Falconi » Thu Apr 20, 2023 7:38 am

When I recall Choosefont() I not see the font I select before
How I can to show the font I select before ?
I call with aFont := ChooseFont(,@nColorFont ) where nColorFont is the color
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7075
Joined: Thu Oct 18, 2012 7:17 pm

Re: Problem with Choose font

Postby cmsoft » Thu Apr 20, 2023 11:26 pm

Fijate si sirve asi:
Code: Select all  Expand view  RUN
#include "FiveWin.ch"
function Main()

   local oWnd, oFont, oBtn, oGet, nColor := 0

   DEFINE DIALOG oWnd TITLE "Elegir font"
   oFont:= oWnd:oFont

   @ 10,10 GET oGet VAR nColor PICTURE "999999999" RIGHT of oWnd PIXEL

   @ 30,10 BUTTON oBtn PROMPT "Elegir Font" ACTION ElegirFont(@oFont,@nColor) OF oWnd SIZE 30,10 PIXEL

   ACTIVATE DIALOG oWnd

return nil

//----------------------------------------------------------------------------//

function ElegirFont(oFont,nColor)

oFont := ChooseFont(oFont,@nColor)

return nil
User avatar
cmsoft
 
Posts: 1292
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: Problem with Choose font

Postby Silvio.Falconi » Fri Apr 21, 2023 9:43 am

I have different on my dialog I use BTNBMP control to show name of font and sizes

cFontName := oBrowse:aArraydata[nRecord][15]
nFontSize := oBrowse:aArraydata[nRecord][16]
lUnderline := oBrowse:aArraydata[nRecord][17]
lStrikeOut := oBrowse:aArraydata[nRecord][18]
lBold := oBrowse:aArraydata[nRecord][19]
lItalic := oBrowse:aArraydata[nRecord][20]
nColorFont := oBrowse:aArraydata[nRecord][21]


@ nRow,5 BTNBMP aGet[15] OF oDlg;
PROMPT cFontName RIGHT;
SIZE 250, 23 PIXEL FLAT NOROUND

@ nRow,215 BTNBMP aGet[16] OF oDlg;
PROMPT STR(nFontSize) LEFT;
SIZE 50, 23 PIXEL FLAT NOROUND



@ nRow, 255 BUTTONBMP oBtnSel[4] RESOURCE "REP_FONT" FLAT SIZE 20, 23 OF ooDlgPIXEL ;
ACTION (aFont := ChooseFont(@cFontName,@nColorFont ),;
cFontName:=aFont[LF_FACENAME],;
nFontSize:=IF( aFont[LF_HEIGHT ]!=NIL,FontHeightInPoints( aFont[LF_HEIGHT ]),0) ,;
lBold:= IIF(aFont[LF_WEIGHT]=700,.t.,.f.) ,;
lItalic:= aFont[LF_ITALIC],;
lUnderline:=aFont[LF_UNDERLINE],;
lStrikeout:=aFont[ LF_STRIKEOUT ],;
aGet[15]:settext(cFontName),;
aGet[16]:settext(str(nFontSize)),;
aGet[15]:refresh(),;
aGet[16]:refresh())


First run ok then On modify the choosefont not take the font I save before
I sent you a minitest
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7075
Joined: Thu Oct 18, 2012 7:17 pm

Re: Problem with Choose font

Postby Jimmy » Fri Apr 21, 2023 4:40 pm

hi Silvio,

as i understand the 1st Parameter is a Array or Object of used Font

Code: Select all  Expand view  RUN
  aFont := ChooseFont( { oFont:nInpHeight, oFont:nInpWidth, oFont:nEscapement,;
                          oFont:nOrientation, oFont:nWeight, oFont:lItalic,;
                          oFont:lUnderLine, oFont:lStrikeOut, oFont:nCharSet,;
                          oFont:nOutPrecision, oFont:nClipPrecision,;
                          oFont:nQuality, oFont:nPitchFamily, oFont:cFaceName },;
                          @nNewColor )

later we can use Array aFont to create New Font
Code: Select all  Expand view  RUN
  if !Empty( aFont[ LF_FACENAME ] )
      oNewFont = TFont():New( aFont[ LF_FACENAME ],, aFont[ LF_HEIGHT ], .f.,;
                           ! ( aFont[ LF_WEIGHT ] == FW_NORMAL ),;
                           aFont[ LF_ESCAPEMENT ], aFont[ LF_ORIENTATION ],;
                           aFont[ LF_WEIGHT ], aFont[ LF_ITALIC ],;
                           aFont[ LF_UNDERLINE ], aFont[ LF_STRIKEOUT ],;
                           aFont[ LF_CHARSET ], aFont[ LF_OUTPRECISION ],;
                           aFont[ LF_CLIPPRECISION ], aFont[ LF_QUALITY ],,;
                           aFont[ LF_PITCHANDFAMILY ] )

and set new Color
Code: Select all  Expand view  RUN
     o:SetFormat( oNewFont, nNewColor )
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Problem with Choose font

Postby Silvio.Falconi » Mon Apr 24, 2023 7:21 pm

Jimmy wrote:hi Silvio,

as i understand the 1st Parameter is a Array or Object of used Font

Code: Select all  Expand view  RUN
  aFont := ChooseFont( { oFont:nInpHeight, oFont:nInpWidth, oFont:nEscapement,;
                          oFont:nOrientation, oFont:nWeight, oFont:lItalic,;
                          oFont:lUnderLine, oFont:lStrikeOut, oFont:nCharSet,;
                          oFont:nOutPrecision, oFont:nClipPrecision,;
                          oFont:nQuality, oFont:nPitchFamily, oFont:cFaceName },;
                          @nNewColor )

later we can use Array aFont to create New Font
Code: Select all  Expand view  RUN
  if !Empty( aFont[ LF_FACENAME ] )
      oNewFont = TFont():New( aFont[ LF_FACENAME ],, aFont[ LF_HEIGHT ], .f.,;
                           ! ( aFont[ LF_WEIGHT ] == FW_NORMAL ),;
                           aFont[ LF_ESCAPEMENT ], aFont[ LF_ORIENTATION ],;
                           aFont[ LF_WEIGHT ], aFont[ LF_ITALIC ],;
                           aFont[ LF_UNDERLINE ], aFont[ LF_STRIKEOUT ],;
                           aFont[ LF_CHARSET ], aFont[ LF_OUTPRECISION ],;
                           aFont[ LF_CLIPPRECISION ], aFont[ LF_QUALITY ],,;
                           aFont[ LF_PITCHANDFAMILY ] )

and set new Color
Code: Select all  Expand view  RUN
     o:SetFormat( oNewFont, nNewColor )



Please help because it not run ok

I have the data in a browse


Code: Select all  Expand view  RUN

    cFontName   := oBrowse:aArraydata[nRecord][15]
     nFontSize   := oBrowse:aArraydata[nRecord][16]
     lUnderline  := oBrowse:aArraydata[nRecord][17]
     lStrikeOut  := oBrowse:aArraydata[nRecord][18]
     lBold       := oBrowse:aArraydata[nRecord][19]
     lItalic     := oBrowse:aArraydata[nRecord][20]
     nColorFont  := oBrowse:aArraydata[nRecord][21]

 


only in the edit i create aFont array

aFont:= { , , ,, , lItalic,lUnderline, lStrikeOut, ,, ,, , cFontName }

then in the get control i do like this




Code: Select all  Expand view  RUN


 @ nRow,5  BTNBMP aGet[15] OF oRigaModulo;
                PROMPT cFontName  RIGHT;
                SIZE 250, 23  PIXEL FLAT NOROUND

 @ nRow,215  BTNBMP aGet[16] OF oRigaModulo;
                PROMPT STR(nFontSize) LEFT;
                SIZE 50, 23  PIXEL FLAT NOROUND

@ nRow, 255 BUTTONBMP oBtnSel[4]  RESOURCE "REP_FONT"  FLAT SIZE 20, 23  OF oRigaModulo PIXEL ;
         ACTION (aFont  := ChooseFont(aFont,@nColorFont ),;
                           cFontName:=aFont[LF_FACENAME],;
         nFontSize:=IF( aFont[LF_HEIGHT ]!=NIL,FontHeightInPoints( aFont[LF_HEIGHT ]),0) ,;
                           lBold:= IIF(aFont[LF_WEIGHT]=700,.t.,.f.) ,;
                           lItalic:= aFont[LF_ITALIC],;
                           lUnderline:=aFont[LF_UNDERLINE],;
                           lStrikeout:=aFont[ LF_STRIKEOUT ],;
                           aGet[15]:settext(cFontName),;
                           aGet[16]:settext(str(nFontSize)),;
                           aGet[15]:refresh(),;
                           aGet[16]:refresh())

 
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7075
Joined: Thu Oct 18, 2012 7:17 pm

Re: Problem with Choose font

Postby Jimmy » Wed Apr 26, 2023 11:03 pm

hi Silvio,
Silvio.Falconi wrote:I have the data in a browse
Code: Select all  Expand view  RUN

    cFontName   := oBrowse:aArraydata[nRecord][15]
     nFontSize   := oBrowse:aArraydata[nRecord][16]
     lUnderline  := oBrowse:aArraydata[nRecord][17]
     lStrikeOut  := oBrowse:aArraydata[nRecord][18]
     lBold       := oBrowse:aArraydata[nRecord][19]
     lItalic     := oBrowse:aArraydata[nRecord][20]
     nColorFont  := oBrowse:aArraydata[nRecord][21] 

only in the edit i create aFont array
Code: Select all  Expand view  RUN
aFont:= { , , ,, , lItalic,lUnderline, lStrikeOut, ,, ,, , cFontName }

then in the get control i do like this

as i understand 1st Element is "Start-Point" so aFont must be "full filled" before pass it
but your aFont seems not to include "all"
Code: Select all  Expand view  RUN
      aFont := { oFont:nInpHeight, oFont:nInpWidth, oFont:nEscapement,;
                              oFont:nOrientation, oFont:nWeight, oFont:lItalic,;
                              oFont:lUnderLine, oFont:lStrikeOut, oFont:nCharSet,;
                              oFont:nOutPrecision, oFont:nClipPrecision,;
                              oFont:nQuality, oFont:nPitchFamily, oFont:cFaceName }


i do have a oFont Object which also can be passed as 1st Parameter
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 41 guests