diff --git a/harbour/ChangeLog b/harbour/ChangeLog index acb2294335..11b3b960d8 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,21 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-08-09 09:42 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * contrib/hbxbp/xbpbrowse.prg + ! Few more tweaks. + * contrib/hbxbp/xbptreeview.prg + - Commented out experimental CSS implementation. + + Made public Harbour extention ::setStyleSheet( cStyleSheet ) method. + Now it is possible to fine tune widget's appearnce the way user + can imagine. The supplied style sheet will be applied on top of + existing one. + % TODO: extend ::setStyleSheet() functionality the easiest way. + + * contrib/hbxbp/tests/demoxbp.prg + ! Demonstrated the use of ::setStyleSheet() with XbpTreeView() class. + Play with the tab. + 2009-08-09 18:32 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbxbp/tests/demoxbp.prg ! Fixed test.ico reference to avoid QT runtime error message diff --git a/harbour/contrib/hbxbp/tests/demoxbp.prg b/harbour/contrib/hbxbp/tests/demoxbp.prg index 499d58142e..f6178c56a5 100644 --- a/harbour/contrib/hbxbp/tests/demoxbp.prg +++ b/harbour/contrib/hbxbp/tests/demoxbp.prg @@ -846,18 +846,32 @@ STATIC FUNCTION RGB( r, g, b ) /*----------------------------------------------------------------------*/ FUNCTION Build_TreeView( oWnd ) - LOCAL i - LOCAL oTree := XbpTreeView():new( oWnd, , {10,10}, {oWnd:currentSize()[1]-25,oWnd:currentSize()[2]-45} ) + LOCAL i, oTree, oTree1 + LOCAL sz_:= oWnd:currentSize() + LOCAL nMid := sz_[ 1 ] / 2 + /* Style Sheet Rendering */ + oTree := XbpTreeView():new( oWnd, , {10,10}, {nMid-15,sz_[2]-45} ) oTree:hasLines := .T. oTree:hasButtons := .T. oTree:create() oTree:itemCollapsed := {|oItem,aRect,oSelf| MsgBox( oItem:caption ) } - + #ifdef __HARBOUR__ + oTree:setStyleSheet( GetTreeStyleSheet() ) + #endif FOR i := 1 TO 5 WorkAreaInfo( oTree, i ) NEXT + /* Traditional Rendering */ + oTree1 := XbpTreeView():new( oWnd, , {nMid+10,10}, {nMid-25,sz_[2]-45} ) + oTree1:hasLines := .T. + oTree1:hasButtons := .T. + oTree1:create() + FOR i := 1 TO 5 + WorkAreaInfo( oTree1, i ) + NEXT + RETURN nil ** Build the tree structure for a work area @@ -923,6 +937,102 @@ PROCEDURE FieldStruct( oItem, aField ) RETURN +FUNCTION GetTreeStyleSheet() + LOCAL s := "", txt_:={} + + aadd( txt_, 'QTreeView { ' ) + aadd( txt_, ' alternate-background-color: yellow; ' ) + aadd( txt_, ' } ' ) + aadd( txt_, ' ' ) + aadd( txt_, ' QTreeView { ' ) + aadd( txt_, ' show-decoration-selected: 1; ' ) + aadd( txt_, ' } ' ) + aadd( txt_, ' ' ) + aadd( txt_, ' QTreeView::item { ' ) + aadd( txt_, ' border: 1px solid #d9d9d9; ' ) + aadd( txt_, ' border-top-color: transparent; ' ) + aadd( txt_, ' border-bottom-color: transparent; ' ) + aadd( txt_, ' } ' ) + aadd( txt_, ' ' ) + aadd( txt_, ' QTreeView::item:hover { ' ) + aadd( txt_, ' background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #e7effd, stop: 1 #cbdaf1); ' ) + aadd( txt_, ' border: 1px solid #bfcde4; ' ) + aadd( txt_, ' } ' ) + aadd( txt_, ' ' ) + aadd( txt_, ' QTreeView::item:selected { ' ) + aadd( txt_, ' border: 1px solid #567dbc; ' ) + aadd( txt_, ' } ' ) + aadd( txt_, ' ' ) + aadd( txt_, ' QTreeView::item:selected:active{ ' ) + aadd( txt_, ' background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6ea1f1, stop: 1 #567dbc); ' ) + aadd( txt_, ' } ' ) + aadd( txt_, ' ' ) + aadd( txt_, ' QTreeView::item:selected:!active { ' ) + aadd( txt_, ' background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6b9be8, stop: 1 #577fbf); ' ) + aadd( txt_, ' } ' ) + aadd( txt_, ' ' ) + aadd( txt_, ' QTreeView::branch { ' ) + aadd( txt_, ' background: palette(base); ' ) + aadd( txt_, ' } ' ) + aadd( txt_, ' ' ) + aadd( txt_, ' QTreeView::branch:has-siblings:!adjoins-item { ' ) + aadd( txt_, ' background: cyan; ' ) + aadd( txt_, ' } ' ) + aadd( txt_, ' ' ) + aadd( txt_, ' QTreeView::branch:has-siblings:adjoins-item { ' ) + aadd( txt_, ' background: red; ' ) + aadd( txt_, ' } ' ) + aadd( txt_, ' ' ) + aadd( txt_, ' QTreeView::branch:!has-children:!has-siblings:adjoins-item { ' ) + aadd( txt_, ' background: blue; ' ) + aadd( txt_, ' } ' ) + aadd( txt_, ' ' ) + aadd( txt_, ' QTreeView::branch:closed:has-children:has-siblings { ' ) + aadd( txt_, ' background: pink; ' ) + aadd( txt_, ' } ' ) + aadd( txt_, ' ' ) + aadd( txt_, ' QTreeView::branch:has-children:!has-siblings:closed { ' ) + aadd( txt_, ' background: gray; ' ) + aadd( txt_, ' } ' ) + aadd( txt_, ' ' ) + aadd( txt_, ' QTreeView::branch:open:has-children:has-siblings { ' ) + aadd( txt_, ' background: magenta; ' ) + aadd( txt_, ' } ' ) + aadd( txt_, ' ' ) + aadd( txt_, ' QTreeView::branch:open:has-children:!has-siblings { ' ) + aadd( txt_, ' background: green; ' ) + aadd( txt_, ' } ' ) + aadd( txt_, ' ' ) + aadd( txt_, ' ' ) + aadd( txt_, 'vline.png branch-more.png branch-end.png branch-closed.png branch-open.png ' ) + aadd( txt_, ' QTreeView::branch:has-siblings:!adjoins-item { ' ) + aadd( txt_, ' border-image: url(vline.png) 0; ' ) + aadd( txt_, ' } ' ) + aadd( txt_, ' ' ) + aadd( txt_, ' QTreeView::branch:has-siblings:adjoins-item { ' ) + aadd( txt_, ' border-image: url(branch-more.png) 0; ' ) + aadd( txt_, ' } ' ) + aadd( txt_, ' ' ) + aadd( txt_, ' QTreeView::branch:!has-children:!has-siblings:adjoins-item { ' ) + aadd( txt_, ' border-image: url(branch-end.png) 0; ' ) + aadd( txt_, ' } ' ) + aadd( txt_, ' ' ) + aadd( txt_, ' QTreeView::branch:has-children:!has-siblings:closed, ' ) + aadd( txt_, ' QTreeView::branch:closed:has-children:has-siblings { ' ) + aadd( txt_, ' border-image: none; ' ) + aadd( txt_, ' image: url(branch-closed.png); ' ) + aadd( txt_, ' } ' ) + aadd( txt_, ' ' ) + aadd( txt_, ' QTreeView::branch:open:has-children:!has-siblings, ' ) + aadd( txt_, ' QTreeView::branch:open:has-children:has-siblings { ' ) + aadd( txt_, ' border-image: none; ' ) + aadd( txt_, ' image: url(branch-open.png); ' ) + aadd( txt_, ' } ' ) + + aeval( txt_, {|e| s += e + chr( 13 )+chr( 10 ) } ) + + RETURN s + /*----------------------------------------------------------------------*/ FUNCTION Build_Statics( oWnd ) diff --git a/harbour/contrib/hbxbp/xbpbrowse.prg b/harbour/contrib/hbxbp/xbpbrowse.prg index b37629a84c..8ed762628e 100644 --- a/harbour/contrib/hbxbp/xbpbrowse.prg +++ b/harbour/contrib/hbxbp/xbpbrowse.prg @@ -405,6 +405,7 @@ EXPORTED: METHOD vScroll SETGET DATA nCursorMode INIT XBPBRW_CURSOR_CELL METHOD cursorMode SETGET + DATA sizeCols INIT .T. DATA softTrack INIT .T. @@ -972,10 +973,13 @@ METHOD doConfigure() CLASS XbpBrowse xValue := Eval( oCol:block ) cType := ValType( xValue ) nWidth := IIF( cType $ "CMNDTL", Len( Transform( xValue, oCol:picture ) ), 0 ) + + #if 0 cColSep := oCol:colSep IF cColSep == NIL cColSep := ::cColSep ENDIF + cHeadSep := oCol:headSep IF !ISCHARACTER( cHeadSep ) .OR. cHeadSep == "" cHeadSep := ::cHeadSep @@ -991,6 +995,11 @@ METHOD doConfigure() CLASS XbpBrowse cFootSep := "" ENDIF ENDIF + #endif + cColSep := "" + cHeadSep := "" + cFootSep := "" + aCol := Array( _TBCI_SIZE ) aCol[ _TBCI_COLOBJECT ] := oCol aCol[ _TBCI_COLWIDTH ] := nWidth @@ -1070,15 +1079,15 @@ METHOD doConfigure() CLASS XbpBrowse nFootHeight := nHeight nHeight := 0 ENDIF - ::lHeadSep := lHeadSep + ::lHeadSep := .f. // lHeadSep ::nHeadHeight := nHeadHeight + ::lFootSep := .f. // lFootSep ::nFootHeight := nFootHeight - ::lFootSep := lFootSep /* update headings to maximum size and missing head/foot separators */ FOR EACH aCol IN ::aColData - aCol[ _TBCI_HEADING ] := Replicate( _TBR_CHR_LINEDELIMITER, nHeadHeight - hb_TokenCount( aCol[ _TBCI_HEADING ], _TBR_CHR_LINEDELIMITER ) ) + ; - aCol[ _TBCI_HEADING ] + aCol[ _TBCI_HEADING ] := Replicate( _TBR_CHR_LINEDELIMITER, nHeadHeight - ; + hb_TokenCount( aCol[ _TBCI_HEADING ], _TBR_CHR_LINEDELIMITER ) ) + aCol[ _TBCI_HEADING ] IF lHeadSep .AND. aCol[ _TBCI_HEADSEP ] == "" aCol[ _TBCI_HEADSEP ] := " " ENDIF @@ -1087,24 +1096,19 @@ METHOD doConfigure() CLASS XbpBrowse ENDIF NEXT - ::lHeadSep := .f. // lHeadSep - ::nHeadHeight := 0 // nHeadHeight - ::nFootHeight := 0 // nFootHeight - ::lFootSep := .f. // lFootSep - nRowCount := ::rowCount IF nRowCount == 0 _GENLIMITRTE() ENDIF /* create new record buffer */ - ASize( ::aCellStatus, nRowCount ) - ASize( ::aDispStatus, nRowCount ) - ASize( ::aCellValues, nRowCount ) + ASize( ::aCellStatus , nRowCount ) + ASize( ::aDispStatus , nRowCount ) + ASize( ::aCellValues , nRowCount ) ASize( ::aCellValuesA, nRowCount ) - ASize( ::aCellColors, nRowCount ) - AFill( ::aCellStatus, .F. ) - AFill( ::aDispStatus, .T. ) + ASize( ::aCellColors , nRowCount ) + AFill( ::aCellStatus , .F. ) + AFill( ::aDispStatus , .T. ) FOR EACH aVal, aValA, aCol IN ::aCellValues, ::aCellValuesA, ::aCellColors IF aVal == NIL aVal := Array( nColCount ) @@ -1168,11 +1172,11 @@ METHOD doConfigure() CLASS XbpBrowse // FOR i := 1 TO len( ::columns ) IF ::columns[ i ]:nColWidth != NIL - ::oWidget:setColumnWidth( i-1, ::columns[ i ]:nColWidth ) + //::oWidget:setColumnWidth( i-1, ::columns[ i ]:nColWidth ) ::oHorzHeaderView:resizeSection( i-1, ::columns[ i ]:nColWidth ) ELSE xVal := transform( eval( ::columns[ i ]:block ), ::columns[ i ]:picture ) - ::oWidget:setColumnWidth( i-1, oFontMetrics:width( xVal, -1 ) + 8 ) + //::oWidget:setColumnWidth( i-1, oFontMetrics:width( xVal, -1 ) + 8 ) ::oHorzHeaderView:resizeSection( i-1, oFontMetrics:width( xVal, -1 ) + 8 ) ENDIF NEXT diff --git a/harbour/contrib/hbxbp/xbptreeview.prg b/harbour/contrib/hbxbp/xbptreeview.prg index 10e09697c0..a05893e8d7 100644 --- a/harbour/contrib/hbxbp/xbptreeview.prg +++ b/harbour/contrib/hbxbp/xbptreeview.prg @@ -184,7 +184,7 @@ METHOD XbpTreeView:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) IF ::visible ::show() ENDIF - ::setStyle() +// ::setStyle() ::oParent:AddChild( SELF ) RETURN Self