2009-06-28 09:19 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)

* harbour/contrib/hbxbp/xbp.ch
  * harbour/contrib/hbxbp/xbpdialog.prg
  * harbour/contrib/hbxbp/xbpmle.prg
  * harbour/contrib/hbxbp/xbpwindow.prg
    + Implemented fonts management.
         :setFontCompoundName( "10.Tohama italics" )
      Started XBP_PP_* implementation.
      NOTE: This implementation is based on QT's powerful mechanism
            of CSS inspired Cascading Style Sheets. It effectively
            means that look-and-feel of the requested parameters are
            guaranted to be rendered irrespective of the platform.
            This also means that a "true" inheritance is achieved 
            in the widgets. For example, if you set the color and 
            font of a top-level dialog, all children of it will also 
            inherit it. Xbase++ also documents this behavior but 
            also notify that some of the widgets do not respond to 
            this request, i.e., XbpPushButton(), XbpTabPage(), etc.
            But in Harbour-QT-Xbase++ it is possible, and, by 
            all means desirable.

            Anyway, I am more interested what the group think. It will 
            be heartening if some real-time Xbase++ users participate
            on the subject. I do not want to cook my own food.

  * harbour/contrib/hbxbp/tests/demoxbp.prg
    ! Demonstrated to use fonts and inheritance. Please play.
This commit is contained in:
Pritpal Bedi
2009-06-28 16:32:03 +00:00
parent 6c4f7ba5d1
commit b9ecc078ca
6 changed files with 200 additions and 61 deletions

View File

@@ -17,6 +17,34 @@
past entries belonging to author(s): Viktor Szakats.
*/
2009-06-28 09:19 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
* harbour/contrib/hbxbp/xbp.ch
* harbour/contrib/hbxbp/xbpdialog.prg
* harbour/contrib/hbxbp/xbpmle.prg
* harbour/contrib/hbxbp/xbpwindow.prg
+ Implemented fonts management.
:setFontCompoundName( "10.Tohama italics" )
Started XBP_PP_* implementation.
NOTE: This implementation is based on QT's powerful mechanism
of CSS inspired Cascading Style Sheets. It effectively
means that look-and-feel of the requested parameters are
guaranted to be rendered irrespective of the platform.
This also means that a "true" inheritance is achieved
in the widgets. For example, if you set the color and
font of a top-level dialog, all children of it will also
inherit it. Xbase++ also documents this behavior but
also notify that some of the widgets do not respond to
this request, i.e., XbpPushButton(), XbpTabPage(), etc.
But in Harbour-QT-Xbase++ it is possible, and, by
all means desirable.
Anyway, I am more interested what the group think. It will
be heartening if some real-time Xbase++ users participate
on the subject. I do not want to cook my own food.
* harbour/contrib/hbxbp/tests/demoxbp.prg
! Demonstrated to use fonts and inheritance. Please play.
2009-06-28 18:09 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbqt/qth/QFtp.qth
* contrib/hbqt/qth/QHttp.qth

View File

@@ -67,7 +67,7 @@ PROCEDURE Main()
/*----------------------------------------------------------------------*/
PROCEDURE BuildADialog()
LOCAL oDlg, mp1, mp2, oXbp, nEvent, aSize, aTabs
LOCAL oDlg, mp1, mp2, oXbp, nEvent, aSize, aTabs, oDa
LOCAL nThread := ThreadID()
LOCAL cThread := hb_ntos( nThread )
@@ -77,6 +77,9 @@ PROCEDURE BuildADialog()
oDlg:close := {|| MsgBox( "You can also close me by pressing [ESC]" ), .T. }
oDlg:killDisplayFocus := {|| hb_OutDebug( "Loosing Display Focus" ) }
SetAppWindow( oDlg )
oDlg:show()
oDa := oDlg:drawingArea
/* Obtain desktop dimensions */
aSize := AppDesktop():currentSize()
@@ -85,11 +88,12 @@ PROCEDURE BuildADialog()
( aSize[ 2 ] - oDlg:currentSize()[ 2 ] ) / 2 } )
/* Callback to report the mouse moves */
// oDlg:drawingArea:motion := {|| hb_outDebug( "MouseMove: "+cThread ) }
// oDa:motion := {|| hb_outDebug( "MouseMove: "+cThread ) }
/* Make background color of :drawingArea different */
//oDlg:drawingArea:setColorBG( GraMakeRGBColor( { 134,128,164 } ) )
//oDlg:drawingArea:setColorFG( GraMakeRGBColor( { 40,120,100 } ) )
oDa:setColorBG( GraMakeRGBColor( { 134,128,200 } ) )
oDa:setFontCompoundName( "10.Tohama italics" )
oDa:setColorFG( GraMakeRGBColor( { 255,255,255 } ) )
/* Install menu system */
Build_MenuBar()
@@ -98,7 +102,7 @@ PROCEDURE BuildADialog()
Build_StatusBar( oDlg )
/* Install Toolbar */
Build_ToolBar( oDlg:drawingArea )
Build_ToolBar( oDa )
/* Install Tab Pages */
aTabs := Build_TabPages( oDlg )
@@ -116,10 +120,10 @@ PROCEDURE BuildADialog()
Build_ListBox( aTabs[ 1 ] )
/* Install Push Buttons */
Build_PushButton( oDlg:drawingArea )
Build_PushButton( oDa )
/* Install Single Line Edits */
Build_SLEs( oDlg:drawingArea )
Build_SLEs( oDa )
/* Install Multi-Line Edit */
Build_MLE( aTabs[ 2 ] )
@@ -131,7 +135,7 @@ PROCEDURE BuildADialog()
Build_SpinButtons( aTabs[ 3 ] )
/* Install Combo Box */
Build_ComboBox( oDlg:drawingArea )
Build_ComboBox( oDa )
/* Install TreeView */
Build_TreeView( aTabs[ 4 ] )
@@ -166,6 +170,7 @@ PROCEDURE AppSys()
FUNCTION Hb_OutDebug();RETURN nil
FUNCTION Hb_Symbol_Unused();RETURN nil
FUNCTION Hb_NtoS( n );RETURN ltrim( str( n ) )
FUNCTION Hb_ThreadStart();RETURN nil
#endif
/*----------------------------------------------------------------------*/
@@ -230,6 +235,8 @@ STATIC FUNCTION Build_MenuBar()
oSubMenu:setColorBG( GraMakeRGBColor( { 134,128,250 } ) )
oSubMenu:setColorFG( GraMakeRGBColor( { 255, 1, 1 } ) )
#ifdef __HARBOUR__
#if 0
oSubMenu := XbpMenu():new( oMenuBar ):create()
oSubMenu:title := "~Dialogs"
@@ -242,6 +249,7 @@ STATIC FUNCTION Build_MenuBar()
oMenuBar:addItem( { oSubMenu, NIL } )
#endif
#endif
Return nil
@@ -426,9 +434,6 @@ FUNCTION Build_TabPages( oDlg )
oTab1:caption := "ListView"
oTab1:create()
oTab1:TabActivate := {|| oTab2:minimize(), oTab3:minimize(), oTab4:minimize(), oTab1:maximize() }
#if 0
oTab1:setColorBG( GraMakeRGBColor( {198,198,198} ) )
#endif
// Second tab page is minimized
oTab2 := XbpTabPage():new( oDlg:drawingArea, , { 510, 20 }, { 360, nHeight } )
@@ -456,6 +461,8 @@ FUNCTION Build_TabPages( oDlg )
oTab4:TabActivate := ;
{|x,y,oTab| x := y, oTab1:minimize(), oTab2:minimize(), oTab3:minimize(), oTab4:maximize() }
oTab4:setColorBG( GraMakeRGBColor( {198,198,198} ) )
RETURN { oTab1, oTab2, oTab3, oTab4 }
/*----------------------------------------------------------------------*/
@@ -478,7 +485,7 @@ FUNCTION Build_ListBox( oWnd )
oListBox:ItemSelected := {|mp1, mp2, obj| mp1:=oListBox:getData(), ;
mp2:=oListBox:getItem( mp1 ), MsgBox( "itemSelected: "+mp2 ) }
#if 0
#if 1
oListBox:setColorBG( GraMakeRGBColor( {227,12,110} ) )
oListBox:setColorBG( GraMakeRGBColor( { 27,12, 45} ) )
#endif
@@ -510,14 +517,14 @@ FUNCTION Build_ScrollBar( oWnd )
oXbpH := XbpScrollbar():new()
oXbpH:type := XBPSCROLL_HORIZONTAL
oXbpH:range := { 1, 100 }
oXbpH:create( oWnd, , { 10,nHeight-50 }, { nWidth-40,nFat } )
oXbpH:range := { 1, 100 } //50
oXbpH:create( oWnd, , { 10,nHeight-30 }, { nWidth-40,nFat } )
oXbpH:scroll := {|| oXbpV:setData( oXbpH:getData() ) }
oXbpV := XbpScrollbar():new()
oXbpV:type := XBPSCROLL_VERTICAL
oXbpV:range := { 1, 100 }
oXbpV:create( oWnd, , { nWidth-30,10 }, { nFat,nHeight-60 } )
oXbpV:create( oWnd, , { nWidth-30,10 }, { nFat,nHeight-40 } )
oXbpV:scroll := {|| oXbpH:setData( oXbpV:getData() ) }
RETURN nil
@@ -538,6 +545,8 @@ FUNCTION Build_SLEs( oWnd )
//oXbp:setInputFocus := { |x,y,oSLE| oSLE:getData(), Qt_QDebug( "Var A =" + cVarA ) }
//oXbp:setInputFocus := { |x,y,oSLE| oSLE:getData() }
oXbp:setColorBG( GraMakeRGBColor( { 170,170,170 } ) )
oXbp := XbpSLE():new()
oXbp:autoTab := .T.
oXbp:bufferLength := 20
@@ -549,6 +558,8 @@ FUNCTION Build_SLEs( oWnd )
// when the input focus is lost
oXbp:killInputFocus := { |x,y,oSLE| oSLE:getData(), MsgBox( "Var B =" + cVarB ) }
oXbp:setColorBG( GraMakeRGBColor( { 190,190,190 } ) )
RETURN nil
/*----------------------------------------------------------------------*/
@@ -568,6 +579,10 @@ FUNCTION Build_MLE( oWnd )
// via :dataLink
oMLE:setData()
oMLE:setColorBG( GraMakeRGBColor( { 190,190,0 } ) )
oMLE:setColorFG( GraMakeRGBColor( { 0,0,0 } ) )
oMLE:setFontCompoundName( "14.Courier New bold normal" )
RETURN nil
/*----------------------------------------------------------------------*/

View File

@@ -106,11 +106,86 @@
#define XBPLISTBOX_MM_SINGLE 1
/* Generic Pres Parameters */
#define XBP_PP_FGCLR 2
#define XBP_PP_BGCLR 4
#define XBP_PP_HILITE_FGCLR 6
#define XBP_PP_HILITE_BGCLR 8
#define XBP_PP_DISABLED_FGCLR 10
#define XBP_PP_DISABLED_BGCLR 12
#define XBP_PP_BORDER_CLR 14
#define XBP_PP_COMPOUNDNAME 15
#define XBP_PP_FONT 16
#define XBP_PP_ACTIVE_CLR 19
#define XBP_PP_INACTIVE_CLR 21
#define XBP_PP_ACTIVETEXT_FGCLR 23
#define XBP_PP_ACTIVETEXT_BGCLR 25
#define XBP_PP_INACTIVETEXT_FGCLR 27
#define XBP_PP_INACTIVETEXT_BGCLR 29
#define XBP_PP_CAPTION 50
#define XBP_PP_ALIGNMENT 52
#define XBP_PP_ORIGIN 300
#define XBP_PP_MENU_FGCLR 32
#define XBP_PP_MENU_BGCLR 34
#define XBP_PP_MENU_HILITE_FGCLR 36
#define XBP_PP_MENU_HILITE_BGCLR 38
#define XBP_PP_MENU_DISABLED_FGCLR 40
#define XBP_PP_MENU_DISABLED_BGCLR 42
#define XBPSYSCLR_BUTTONTEXT ( -58 )
#define XBPSYSCLR_INFOBACKGROUND ( -57 )
#define XBPSYSCLR_INFOTEXT ( -56 )
#define XBPSYSCLR_3DHIGHLIGHT ( -55 )
#define XBPSYSCLR_3DLIGHT ( -54 )
#define XBPSYSCLR_3DFACE ( -53 )
#define XBPSYSCLR_3DSHADOW ( -52 )
#define XBPSYSCLR_3DDARKSHADOW ( -51 )
#define XBPSYSCLR_SHADOWHILITEBGND ( -50 )
#define XBPSYSCLR_SHADOWHILITEFGND ( -49 )
#define XBPSYSCLR_SHADOWTEXT ( -48 )
#define XBPSYSCLR_ENTRYFIELD ( -47 )
#define XBPSYSCLR_MENUDISABLEDTEXT ( -46 )
#define XBPSYSCLR_MENUHILITE ( -45 )
#define XBPSYSCLR_MENUHILITEBGND ( -44 )
#define XBPSYSCLR_PAGEBACKGROUND ( -43 )
#define XBPSYSCLR_FIELDBACKGROUND ( -42 )
#define XBPSYSCLR_BUTTONLIGHT ( -41 )
#define XBPSYSCLR_BUTTONMIDDLE ( -40 )
#define XBPSYSCLR_BUTTONDARK ( -39 )
#define XBPSYSCLR_BUTTONDEFAULT ( -38 )
#define XBPSYSCLR_TITLEBOTTOM ( -37 )
#define XBPSYSCLR_SHADOW ( -36 )
#define XBPSYSCLR_ICONTEXT ( -35 )
#define XBPSYSCLR_DIALOGBACKGROUND ( -34 )
#define XBPSYSCLR_HILITEFOREGROUND ( -33 )
#define XBPSYSCLR_HILITEBACKGROUND ( -32 )
#define XBPSYSCLR_INACTIVETITLETEXTBGND ( -31 )
#define XBPSYSCLR_ACTIVETITLETEXTBGND ( -30 )
#define XBPSYSCLR_INACTIVETITLETEXT ( -29 )
#define XBPSYSCLR_ACTIVETITLETEXT ( -28 )
#define XBPSYSCLR_OUTPUTTEXT ( -27 )
#define XBPSYSCLR_WINDOWSTATICTEXT ( -26 )
#define XBPSYSCLR_SCROLLBAR ( -25 )
#define XBPSYSCLR_BACKGROUND ( -24 )
#define XBPSYSCLR_ACTIVETITLE ( -23 )
#define XBPSYSCLR_INACTIVETITLE ( -22 )
#define XBPSYSCLR_MENU ( -21 )
#define XBPSYSCLR_WINDOW ( -20 )
#define XBPSYSCLR_WINDOWFRAME ( -19 )
#define XBPSYSCLR_MENUTEXT ( -18 )
#define XBPSYSCLR_WINDOWTEXT ( -17 )
#define XBPSYSCLR_TITLETEXT ( -16 )
#define XBPSYSCLR_ACTIVEBORDER ( -15 )
#define XBPSYSCLR_INACTIVEBORDER ( -14 )
#define XBPSYSCLR_APPWORKSPACE ( -13 )
#define XBPSYSCLR_HELPBACKGROUND ( -12 )
#define XBPSYSCLR_HELPTEXT ( -11 )
#define XBPSYSCLR_HELPHILITE ( -10 )
#define XBPSYSCLR_TRANSPARENT ( -255 )
#define XBPSLE_LEFT 1
#define XBPSLE_RIGHT 2

View File

@@ -137,6 +137,8 @@ METHOD XbpDialog:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
::drawingArea := XbpDrawingArea():new( self, , {0,0}, ::aSize, , .t. ):create()
::oWidget:setCentralWidget( QT_PTROF( ::drawingArea:oWidget ) )
//::setQtProperty()
::setPosAndSize()
IF ::visible
::show()
@@ -288,6 +290,8 @@ METHOD XbpDrawingArea:create( oParent, oOwner, aPos, aSize, aPresParams, lVisibl
::oWidget:setMouseTracking( .T. )
::oWidget:setFocusPolicy( 2 )
//::setQtProperty() /* Using it for one-to-one style sheet management */
::oParent:addChild( SELF )
/* Connects All Event Handlers */

View File

@@ -221,9 +221,11 @@ METHOD XbpMLE:setStyle()
aadd( txt_, ' ' )
aadd( txt_, ' QTextEdit { ' )
aadd( txt_, ' background-color: white; ' )
aadd( txt_, ' background-image: url(new.png); ' )
aadd( txt_, ' background-attachment: scroll; ' )
//aadd( txt_, ' background-color: white; ' )
//aadd( txt_, ' background-image: url(new.png); ' )
//aadd( txt_, ' background-attachment: scroll; ' )
aadd( txt_, ' background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, ' )
aadd( txt_, ' stop:0 white, stop:1 darkgray); ' )
aadd( txt_, ' } ' )
#if 0
aadd( txt_, 'If the background-image is to be fixed with the viewport: ' )

View File

@@ -77,8 +77,16 @@
CLASS XbpWindow INHERIT XbpPartHandler
CLASSDATA nProperty INIT 0
DATA qtProperty INIT ""
/* Called in the initializer - Unique in the application */
METHOD getProperty() INLINE "PROP" + hb_ntos( ++::nProperty )
/* After object is physically created, set unique property to 1 */
METHOD setQtProperty() INLINE ::oWidget:setProperty( ::qtProperty, 1 )
DATA cargo INIT ""
DATA styleSheet INIT ""
METHOD setStyleSheet()
/* CONFIGURATION */
DATA animate INIT .F.
@@ -291,6 +299,8 @@ METHOD XbpWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
::XbpPartHandler:init( oParent, oOwner )
::qtProperty := ::getProperty()
RETURN Self
/*----------------------------------------------------------------------*/
@@ -722,6 +732,15 @@ METHOD XbpWindow:lockUpdate()
/*----------------------------------------------------------------------*/
METHOD XbpWindow:setStyleSheet( cNewSheet )
LOCAL cSheet := ::oWidget:styleSheet()
::oWidget:setStyleSheet( cSheet + " " + cNewSheet )
RETURN Self
/*----------------------------------------------------------------------*/
METHOD XbpWindow:setColorBG( nRGB )
#if 0
LOCAL cClass := __ObjGetClsName( self )
@@ -745,7 +764,7 @@ METHOD XbpWindow:setColorBG( nRGB )
LOCAL oColor := QColor():new( nRGB )
::oWidget:setStyleSheet( "background-color: "+ oColor:name +";" )
::setStyleSheet( "background-color: "+ oColor:name +";" )
RETURN Self
@@ -775,12 +794,48 @@ METHOD XbpWindow:setColorFG( nRGB )
LOCAL oColor := QColor():new( nRGB )
::oWidget:setStyleSheet( "color: "+ oColor:name +";" )
::setStyleSheet( "color: "+ oColor:name +";" )
RETURN Self
/*----------------------------------------------------------------------*/
METHOD XbpWindow:setFontCompoundName( xFont )
LOCAL cOldFont, s, n, nPoint, cFont, cAttr, cFace
LOCAL aAttr := { "normal","italic","bold" }
cOldFont := ::fnt_COMMPOUNDNAME
IF hb_isNumeric( cFont )
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 )
ELSE
cAttr := "normal"
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 )
::setStyleSheet( 'font-family: "'+ cFace +'"; font-style: '+ cAttr +'; font-size: '+ hb_ntos( nPoint )+'pt;' )
ENDIF
ENDIF
RETURN cOldFont
/*----------------------------------------------------------------------*/
METHOD XbpWindow:setModalState()
RETURN Self
@@ -902,46 +957,6 @@ METHOD XbpWindow:setFont()
/*----------------------------------------------------------------------*/
METHOD XbpWindow:setFontCompoundName( xFont )
LOCAL cOldFont, s, n, nPoint, cFont, cAttr, cFace
LOCAL aAttr := { "normal","italic","bold" }
cOldFont := ::fnt_COMMPOUNDNAME
IF hb_isNumeric( cFont )
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 )
ELSE
cAttr := "normal"
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 )
HB_SYMBOL_UNUSED( cFace )
HB_SYMBOL_UNUSED( cAttr )
HB_SYMBOL_UNUSED( nPoint )
ENDIF
ENDIF
RETURN cOldFont
/*----------------------------------------------------------------------*/
METHOD XbpWindow:setPresParam()
RETURN Self