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.
Code: Select all
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