bb.donnay-software.com

Donnay Software Web Forums
It is currently Wed Dec 11, 2019 11:45 pm

All times are UTC - 7 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: CJpushButton FONT
PostPosted: Thu Jul 01, 2010 10:14 pm 
Offline

Joined: Thu Jan 28, 2010 1:22 am
Posts: 822
Location: Sijsele, Belgium
Hi,

I posted the FONT problem about a month ago to the codejock developer forum. There wasn't any response, their support could be better. :(

After testing a bit with the cjpushbutton, I realised that it should be possible to use the XAML possibilities to use a font, with the normal eXpress++ syntax. This is my workaround for the font problem.

Code:
   @ 10,10 CJPushButton oBut1 ;
       Size 130,80 ;
      BITMAP ABO_LEVERN ;    // bitmap from resources
       Caption "Testing font" ; 
       Font '12.Arial bold italic' ;
       TextImageRelation xtpImageAboveText ;
       Transparent ;
      IMAGEALIGNMENT xtpAlignCenter ;
      textalign xtpAlignCenter ;
       Appearance xtpAppearanceOffice2007 ;
       Style xtpButtonNormal ;
      ACTION {|o| ....  } PIXEL


If the command doesn't set the ENABLEMARKUP and there is a FONT defined, I added the following in the cjclass.prg.

Code:
...
cCaption := aGetListItem[cGETLIST_CAPTION]
::caption := cCaption
// start workaround font lockup chris andries 01/07/10
// if enablemarkup is not set, and there is a font, create a simple xaml command to use the font.
if !aOptions[8] .and. !empty(cFont)   
    cFont = upper(cFont)
   cPointSize := left(cFont,at('.',cFont)-1)
   IF 'BOLD' $ Upper(cFont)
      lBold := .T.
      cFont := StrTran(cFont,' BOLD','')
   ENDIF
   IF 'ITALIC' $ Upper(cFont)
      lItalic := .T.
      cFont := StrTran(cFont,' ITALIC','')
   ENDIF
      
   cFont := Alltrim(StrTran(CJ_Token(cFont,'.',2),'.',' '))
   cFont := StrTran(cFont,'  ',' ')

    cCaption := "<TextBlock FontFamily='"+cFont+"' FontSize='"+cPointSize+"'"
   cCaption += iif(lBold, " FontWeight='Bold'","")
   cCaption += iif(lItalic," FontStyle='Italic'","")
    cCaption += ">" + aGetListItem[cGETLIST_CAPTION]+"</TextBlock>"
   ::enableMarkup := .T.
   ::caption := cCaption
endif
// stop workaround
::setColor( aGetListItem )
...


This way a font can be used without a problem, and without any knowledge of the xaml possibilities.

_________________
Best regards,

Chris.
www.aboservice.be


Top
 Profile  
 
 Post subject: Re: CJpushButton FONT
PostPosted: Fri Jul 02, 2010 6:50 am 
Offline
Site Admin
User avatar

Joined: Wed Jan 27, 2010 6:58 pm
Posts: 4014
Location: Boise, Idaho USA
Thanks Chris. I will add this to the code.

_________________
The eXpress train is coming - and it has more cars.


Top
 Profile  
 
 Post subject: Re: CJpushButton FONT
PostPosted: Mon Jan 10, 2011 12:35 pm 
Offline

Joined: Thu Jan 28, 2010 1:22 am
Posts: 822
Location: Sijsele, Belgium
Hi Roger,

I modified the code to have multi-line captions on the cj_buttons. If there is a semo-colom ';' used in the caption, I create a multiline caption with xaml.

Here is the complete class.

Code:
CLASS CJ_PushButton FROM DC_XbpActiveXControl, CJ_Parts

EXPORTED:

INLINE METHOD Init( oParent, oOwner, aPos, aSize, aPres, lVisible, oGetList )
::clsid := 'CodeJock.PushButton' + CJ_Version()
::license := CJ_LicenseControls()
::DC_XbpActiveXControl:init( @oParent, @oOwner, aPos, aSize, aPres, lVisible, oGetList )
::CJ_Parts:init(.t.)

RETURN self

INLINE METHOD Create( oParent, oOwner, aPos, aSize, aPres, lVisible )

LOCAL aGetListItem, aOptions, cFont, cCaption, aColor, oIcon
Local aResFile , nHandle , i
Local lBold := .F. , lItalic := .F. , cFamilyName := "" , cPointsize := ""

::DC_XbpActiveXControl:create( @oParent, @oOwner, aPos, aSize, aPres, lVisible )

aGetListItem := ::getList:getListArray[::getListPointer]
aOptions := aGetListItem[xGETLIST_OPTIONS3]

cFont := aGetListItem[cGETLIST_FONT]
//IF !Empty(cFont)
//  ::setFont(CJ_Font(cFont,.f.))
//  ::setProperty('font',CJ_Font(cFont)) // << locks up app
// ENDIF


DEFAULT aOptions := {}
ASize(aOptions,24)

DEFAULT aOptions[1] := xtpAppearanceFlat, ;
        aOptions[2] := 2, ;
        aOptions[4] := .f., ;
        aOptions[5] := .f., ;
        aOptions[6] := .t., ;
        aOptions[7] := .f., ;
        aOptions[8] := .f., ;
        aOptions[11] := 2, ;
        aOptions[12] := xtpAlignLeft, ;
        aOptions[14] := .t., ;
        aOptions[15] := .f., ;
        aOptions[16] := xtpButtonNormal, ;
        aOptions[17] := xtpAlignCenter, ;
        aOptions[18] := xtpImageBeforeText, ;
        aOptions[19] := .f., ;
        aOptions[20] := .f.

// ::borderGap := aOptions[2]
IF Valtype(aOptions[3]) == 'O'
  ::buddyControl := aOptions[3]
ENDIF
::checked := aOptions[4]
::default := aOptions[5]
::drawFocusRect := aOptions[6]
::flatStyle := aOptions[7]
::enableMarkup := aOptions[8]
::imageGap := aOptions[11]
::imageAlignment := aOptions[12]
::rightToLeft := aOptions[15]
::style := aOptions[16]
::textAlignment := aOptions[17]
::textImageRelation := aOptions[18]
::transparent := aOptions[19]
::useVisualStyle := aOptions[20]
::setProperty("multiLine",aOptions[14])

IF Valtype(aOptions[21]) == 'B'
  ::click := {||PostAppEvent(DCGUI_EVENT_ACTION,aOptions[21],,self)}
ENDIF
IF Valtype(aOptions[22]) == 'B'
  ::dropDown := {||PostAppEvent(DCGUI_EVENT_ACTION,aOptions[22],,self)}
ENDIF
IF Valtype(aOptions[23]) == 'B'
  ::keyDown := {||PostAppEvent(DCGUI_EVENT_ACTION,aOptions[23],,self)}
ENDIF

cCaption := aGetListItem[cGETLIST_CAPTION]
::caption := cCaption

if !aOptions[8] .and. !empty(cFont)
    cFont = upper(cFont)
   cPointSize := left(cFont,at('.',cFont)-1)
   IF 'BOLD' $ Upper(cFont)
      lBold := .T.
      cFont := StrTran(cFont,' BOLD','')
   ENDIF
   IF 'ITALIC' $ Upper(cFont)
      lItalic := .T.
      cFont := StrTran(cFont,' ITALIC','')
   ENDIF
      
   cFont := Alltrim(StrTran(CJ_Token(cFont,'.',2),'.',' '))
   cFont := StrTran(cFont,'  ',' ')

    cCaption := "<TextBlock FontFamily='"+cFont+"' FontSize='"+cPointSize+"'"
   cCaption += iif(lBold, " FontWeight='Bold'","")
   cCaption += iif(lItalic," FontStyle='Italic'","")
   if ";" $ aGetListItem[cGETLIST_CAPTION]
      aGetListItem[cGETLIST_CAPTION] := strtran(aGetListItem[cGETLIST_CAPTION],";","<LineBreak/>")
   endif
    cCaption += ">" + aGetListItem[cGETLIST_CAPTION]+"</TextBlock>"
   ::enableMarkup := .T.
   ::caption := cCaption
endif
::setColor( aGetListItem )

IF !Empty(aOptions[10])
  ::picture := CJ_Picture(aOptions[10],xtpImageNormal)
ENDIF

IF !Empty(aOptions[9])
   if valtype(aOptions[9]) == "C"
      CJLoadIcon aOptions[9] ID 1 STATE xtpImageNormal PARENT ::globalSettings:icons
      oIcon := ::globalSettings:icons:getImage(1,32)
      ::picture := CJ_Picture(oIcon,xtpImageNormal)
   endif
   /*
   if valtype(aOptions[9]) == "N"
      aResFile := DC_BitmapResourceFile()
      FOR i := 1 TO Len(aResFile)
         nHandle := aResFile[i]
         CJLoadIconFromResource aOptions[9] HANDLE nHandle ID 1 STATE xtpImageNormal PARENT ::globalSettings:icons
         oIcon := ::globalSettings:icons:getImage(1,32)
         ::picture := CJ_Picture(oIcon,xtpImageNormal)
      next
   endif
   */
ENDIF

IF !Empty(aOptions[24])
   if valtype(aOptions[24]) == "C"
      CJLoadBitmap aOptions[24] ID 1 STATE xtpImageNormal PARENT ::globalSettings:icons
      oIcon := ::globalSettings:icons:getImage(1,32)
      ::picture := CJ_Picture(oIcon,xtpImageNormal)
   endif
   if valtype(aOptions[24]) == "N"
      aResFile := DC_BitmapResourceFile()
      FOR i := 1 TO Len(aResFile)
         nHandle := aResFile[i]
         CJLoadBitmapFromResource aOptions[24] HANDLE nHandle ID 1 STATE xtpImageNormal PARENT ::globalSettings:icons
         oIcon := ::globalSettings:icons:getImage(1,32)
         ::picture := CJ_Picture(oIcon,xtpImageNormal)
      next
   endif
ENDIF

::appearance := aOptions[1]

RETURN self

INLINE METHOD Destroy()

::CJ_Parts:destroy()
::DC_XbpActiveXControl:destroy()

ENDCLASS


_________________
Best regards,

Chris.
www.aboservice.be


Top
 Profile  
 
 Post subject: Re: CJpushButton FONT
PostPosted: Mon Jan 10, 2011 6:18 pm 
Offline
Site Admin
User avatar

Joined: Wed Jan 27, 2010 6:58 pm
Posts: 4014
Location: Boise, Idaho USA
I was just preparing to release build 255.

I will add your changes before I do. Thank you again.

_________________
The eXpress train is coming - and it has more cars.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: Bing [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group