2011-04-15 00:59 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com)
* contrib/hbxbp/xbpfontdialog.prg
* contrib/hbxbp/xbpparthandler.prg
* contrib/hbxbp/xbpwindow.prg
! Fixed: XbpFont() as per Xbase++ documentation.
This commit is contained in:
@@ -16,6 +16,12 @@
|
||||
The license applies to all entries newer than 2009-04-28.
|
||||
*/
|
||||
|
||||
2011-04-15 00:59 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com)
|
||||
* contrib/hbxbp/xbpfontdialog.prg
|
||||
* contrib/hbxbp/xbpparthandler.prg
|
||||
* contrib/hbxbp/xbpwindow.prg
|
||||
! Fixed: XbpFont() as per Xbase++ documentation.
|
||||
|
||||
2011-04-14 18:23 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com)
|
||||
* contrib/hbqt/gtqtc/gtqtc.cpp
|
||||
* contrib/hbqt/gtqtc/gtqtc.h
|
||||
|
||||
@@ -414,24 +414,43 @@ METHOD XbpFont:new( oPS )
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD XbpFont:create( cFontName )
|
||||
LOCAL n, cFont, nPtSize
|
||||
LOCAL n, s, cFont, nPoint, cAttr := ""
|
||||
LOCAL aAttr := { "bolditalic", "italic", "bold" }
|
||||
|
||||
IF !empty( cFontName )
|
||||
IF ( n := at( '.', cFontName ) ) > 0
|
||||
cFont := '"' + substr( cFontName, n + 1 ) + '"'
|
||||
nPtSize := val( substr( cFontName, 1, n - 1 ) )
|
||||
IF ! empty( cFontName )
|
||||
cFont := cFontName
|
||||
s := lower( cFont )
|
||||
n := ascan( aAttr, {|e| at( e, cFont ) > 0 } )
|
||||
IF n > 0
|
||||
cAttr := aAttr[ n ]
|
||||
n := at( cAttr, s )
|
||||
cFont := substr( cFont, 1, n-1 )
|
||||
ENDIF
|
||||
IF ( n := at( ".", cFont ) ) > 0
|
||||
nPoint := val( substr( cFont, 1, n-1 ) )
|
||||
cFont := substr( cFont, n+1 )
|
||||
ELSE
|
||||
nPoint := 0
|
||||
ENDIF
|
||||
cFont := alltrim( cFont )
|
||||
|
||||
IF "italic" $ cAttr
|
||||
::italic := .t.
|
||||
ENDIF
|
||||
IF "bold" $ cAttr
|
||||
::bold := .t.
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
IF empty( cFont )
|
||||
cFont := ::familyName
|
||||
nPtSize := ::nominalPointSize
|
||||
cFont := ::familyName
|
||||
nPoint := ::nominalPointSize
|
||||
ENDIF
|
||||
IF empty( nPoint )
|
||||
nPoint := 12
|
||||
ENDIF
|
||||
|
||||
IF empty( nPtSize )
|
||||
nPtSize := 12
|
||||
ENDIF
|
||||
|
||||
::oWidget := QFont( cFont, nPtSize )
|
||||
::oWidget := QFont( cFont, nPoint )
|
||||
|
||||
::oWidget:setBold( ::bold )
|
||||
::oWidget:setItalic( ::italic )
|
||||
@@ -536,7 +555,7 @@ METHOD XbpFont:createFont()
|
||||
::aFontInfo[ 1 ] := ::familyName
|
||||
::aFontInfo[ 2 ] := ::height
|
||||
::aFontInfo[ 3 ] := ::width
|
||||
::aFontInfo[ 4 ] := IF( ::bold, 75, -1 )
|
||||
::aFontInfo[ 4 ] := iif( ::bold, 75, -1 )
|
||||
::aFontInfo[ 5 ] := ::italic
|
||||
::aFontInfo[ 6 ] := ::underscore
|
||||
::aFontInfo[ 7 ] := ::strikeout
|
||||
@@ -551,7 +570,7 @@ METHOD XbpFont:createFont()
|
||||
//aFont := Xbp_FontCreate( ::aFontInfo )
|
||||
|
||||
IF empty( aFont[ 1 ] )
|
||||
RETURN nil
|
||||
RETURN NIL
|
||||
ENDIF
|
||||
|
||||
::hFont := aFont[ 15 ]
|
||||
|
||||
@@ -110,7 +110,7 @@ CLASS XbpPartHandler
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD init( oParent, oOwner ) CLASS XbpPartHandler
|
||||
METHOD XbpPartHandler:init( oParent, oOwner )
|
||||
|
||||
::oParent := oParent
|
||||
::oOwner := oOwner
|
||||
@@ -120,7 +120,7 @@ METHOD init( oParent, oOwner ) CLASS XbpPartHandler
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD create( oParent, oOwner ) CLASS XbpPartHandler
|
||||
METHOD XbpPartHandler:create( oParent, oOwner )
|
||||
|
||||
DEFAULT oParent TO ::oParent
|
||||
DEFAULT oOwner TO ::oOwner
|
||||
@@ -128,7 +128,7 @@ METHOD create( oParent, oOwner ) CLASS XbpPartHandler
|
||||
::oParent := oParent
|
||||
::oOwner := oOwner
|
||||
|
||||
// DEFAULT ::oOwner TO ::oParent
|
||||
// DEFAULT ::oOwner TO ::oParent
|
||||
|
||||
IF hb_isObject( ::oOwner )
|
||||
::oOwner:addAsOwned( Self )
|
||||
@@ -138,7 +138,7 @@ METHOD create( oParent, oOwner ) CLASS XbpPartHandler
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD configure( oParent, oOwner ) CLASS XbpPartHandler
|
||||
METHOD XbpPartHandler:configure( oParent, oOwner )
|
||||
|
||||
DEFAULT oParent TO ::oParent
|
||||
DEFAULT oOwner TO ::oOwner
|
||||
@@ -150,7 +150,7 @@ METHOD configure( oParent, oOwner ) CLASS XbpPartHandler
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD destroy() CLASS XbpPartHandler
|
||||
METHOD XbpPartHandler:destroy()
|
||||
|
||||
::aChildren := NIL
|
||||
::nNameId := NIL
|
||||
@@ -163,7 +163,7 @@ METHOD destroy() CLASS XbpPartHandler
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD handleEvent( hEvent, mp1, mp2 ) CLASS XbpPartHandler
|
||||
METHOD XbpPartHandler:handleEvent( hEvent, mp1, mp2 )
|
||||
|
||||
HB_SYMBOL_UNUSED( hEvent )
|
||||
HB_SYMBOL_UNUSED( mp1 )
|
||||
@@ -173,7 +173,7 @@ METHOD handleEvent( hEvent, mp1, mp2 ) CLASS XbpPartHandler
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD status( nStatus ) CLASS XbpPartHandler
|
||||
METHOD XbpPartHandler:status( nStatus )
|
||||
LOCAL nOldStatus := ::nStatus
|
||||
|
||||
IF hb_isNumeric( nStatus )
|
||||
@@ -184,7 +184,7 @@ METHOD status( nStatus ) CLASS XbpPartHandler
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD addChild( oXbp ) CLASS XbpPartHandler
|
||||
METHOD XbpPartHandler:addChild( oXbp )
|
||||
|
||||
oXbp:nNameID := oXbp:nID
|
||||
aadd( ::aChildren, oXbp )
|
||||
@@ -196,7 +196,7 @@ METHOD addChild( oXbp ) CLASS XbpPartHandler
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD addAsChild() CLASS XbpPartHandler
|
||||
METHOD XbpPartHandler:addAsChild()
|
||||
|
||||
IF !empty( ::oParent )
|
||||
::oParent:addChild( Self )
|
||||
@@ -206,7 +206,7 @@ METHOD addAsChild() CLASS XbpPartHandler
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD addAsOwned( oXbp ) CLASS XbpPartHandler
|
||||
METHOD XbpPartHandler:addAsOwned( oXbp )
|
||||
|
||||
IF ! empty( oXbp )
|
||||
aadd( ::_aOwned, oXbp )
|
||||
@@ -216,7 +216,7 @@ METHOD addAsOwned( oXbp ) CLASS XbpPartHandler
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD childFromName( nNameId ) CLASS XbpPartHandler
|
||||
METHOD XbpPartHandler:childFromName( nNameId )
|
||||
LOCAL i
|
||||
|
||||
FOR i := 1 TO len( ::aChildren )
|
||||
@@ -229,13 +229,13 @@ METHOD childFromName( nNameId ) CLASS XbpPartHandler
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD childList() CLASS XbpPartHandler
|
||||
METHOD XbpPartHandler:childList()
|
||||
|
||||
RETURN ::aChildren
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD delChild( oXbp ) CLASS XbpPartHandler
|
||||
METHOD XbpPartHandler:delChild( oXbp )
|
||||
LOCAL n
|
||||
|
||||
n := ascan( ::aChildren, {|o| o == oXbp } )
|
||||
@@ -249,18 +249,21 @@ METHOD delChild( oXbp ) CLASS XbpPartHandler
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD delOwned( oXbp ) CLASS XbpPartHandler
|
||||
METHOD XbpPartHandler:delOwned( oXbp )
|
||||
LOCAL n
|
||||
|
||||
IF ( n := ascan( ::_aOwned, {|o| o == oXbp } ) ) > 0
|
||||
hb_adel( ::_aOwned, n, .t. )
|
||||
IF empty( ::_aOwned )
|
||||
::_aOwned := {}
|
||||
ENDIF
|
||||
endif
|
||||
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD setName( nNameId ) CLASS XbpPartHandler
|
||||
METHOD XbpPartHandler:setName( nNameId )
|
||||
LOCAL nOldNameId := ::nNameId
|
||||
|
||||
IF Valtype( nNameId ) == "N"
|
||||
@@ -271,7 +274,7 @@ METHOD setName( nNameId ) CLASS XbpPartHandler
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD setOwner( oOwner ) CLASS XbpPartHandler
|
||||
METHOD XbpPartHandler:setOwner( oOwner )
|
||||
LOCAL oOldXbp := ::oOwner
|
||||
|
||||
IF valtype( oOwner ) == "O"
|
||||
@@ -282,7 +285,7 @@ METHOD setOwner( oOwner ) CLASS XbpPartHandler
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD setParent( oParent ) CLASS XbpPartHandler
|
||||
METHOD XbpPartHandler:setParent( oParent )
|
||||
LOCAL oRect
|
||||
LOCAL oOldXbp := ::oParent
|
||||
|
||||
@@ -307,13 +310,13 @@ METHOD setParent( oParent ) CLASS XbpPartHandler
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD notifier() CLASS XbpPartHandler
|
||||
METHOD XbpPartHandler:notifier()
|
||||
|
||||
RETURN self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD moveOwned( nOffSetX, nOffSetY ) CLASS XbpPartHandler
|
||||
METHOD XbpPartHandler:moveOwned( nOffSetX, nOffSetY )
|
||||
LOCAL oXbp, oPos
|
||||
|
||||
FOR EACH oXbp IN ::_aOwned
|
||||
@@ -328,3 +331,4 @@ METHOD moveOwned( nOffSetX, nOffSetY ) CLASS XbpPartHandler
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
|
||||
@@ -167,6 +167,7 @@ CLASS XbpWindow INHERIT XbpPartHandler
|
||||
DATA aPP
|
||||
DATA qLayout
|
||||
DATA nLayout
|
||||
DATA oFont
|
||||
|
||||
METHOD init( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
|
||||
METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
|
||||
@@ -956,69 +957,23 @@ METHOD XbpWindow:setColorFG( nRGB )
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD XbpWindow:setFont( oFont )
|
||||
LOCAL cAttr := ""
|
||||
|
||||
// TODO:
|
||||
//::oWidget:setFont( oFont:oWidget ) /* Works but need to be refined */
|
||||
|
||||
IF oFont:bold .and. oFont:italic
|
||||
cAttr := "bolditalic"
|
||||
ELSEIF oFont:bold
|
||||
cAttr := "bold"
|
||||
ELSEIF oFont:italic
|
||||
cAttr := "italic"
|
||||
ENDIF
|
||||
|
||||
::setFontCompoundName( oFont:compoundName + " " + cAttr )
|
||||
::oFont := oFont
|
||||
::oWidget:setFont( ::oFont:oWidget )
|
||||
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD XbpWindow:setFontCompoundName( xFont )
|
||||
LOCAL cOldFont, s, n, nPoint, cFont, cFace, cCSS
|
||||
LOCAL aAttr := { "bolditalic", "italic", "bold" }
|
||||
LOCAL cAttr := "normal"
|
||||
LOCAL cWeight := "normal"
|
||||
LOCAL cOldFont := hbxbp_SetPresParam( ::aPresParams, XBP_PP_COMPOUNDNAME )
|
||||
LOCAL oFont
|
||||
|
||||
cOldFont := hbxbp_SetPresParam( ::aPresParams, XBP_PP_COMPOUNDNAME )
|
||||
oFont := Xbpfont():new( Self ):create( xFont )
|
||||
|
||||
IF hb_isNumeric( cFont )
|
||||
hbxbp_SetPresParam( ::aPresParams, XBP_PP_COMPOUNDNAME, xFont )
|
||||
|
||||
ELSE
|
||||
IF !empty( xFont )
|
||||
cFont := xFont
|
||||
s := lower( cFont )
|
||||
n := ascan( aAttr, {|e| at( e, cFont ) > 0 } )
|
||||
IF n > 0
|
||||
cAttr := aAttr[ n ]
|
||||
n := at( cAttr, s )
|
||||
cFont := substr( cFont, 1, n-1 )
|
||||
ENDIF
|
||||
IF ( n := at( ".", cFont ) ) > 0
|
||||
nPoint := val( substr( cFont,1,n-1 ) )
|
||||
cFont := substr( cFont,n+1 )
|
||||
ELSE
|
||||
nPoint := 0
|
||||
ENDIF
|
||||
cFace := alltrim( cFont )
|
||||
|
||||
hbxbp_SetPresParam( ::aPresParams, XBP_PP_COMPOUNDNAME, xFont )
|
||||
|
||||
IF cAttr == "bolditalic"
|
||||
cAttr := "italic"
|
||||
cWeight := "bold"
|
||||
ENDIF
|
||||
IF cAttr == "bold"
|
||||
cAttr := "normal"
|
||||
cWeight := "bold"
|
||||
ENDIF
|
||||
|
||||
cCSS := 'font-family: "'+ cFace + '"; font-style: ' + cAttr + '; font-size: ' + ;
|
||||
hb_ntos( nPoint ) + 'pt; font-weight: ' + cWeight + ';'
|
||||
::setStyleSheet( cCSS )
|
||||
ENDIF
|
||||
ENDIF
|
||||
::setFont( oFont )
|
||||
|
||||
RETURN cOldFont
|
||||
|
||||
|
||||
Reference in New Issue
Block a user