2009-06-21 22:15 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)

* harbour/contrib/hbxbp/Makefile
  * harbour/contrib/hbxbp/xbplistbox.prg
  * harbour/contrib/hbxbp/xbpmenubar.prg
  * harbour/contrib/hbxbp/xbpmle.prg
  * harbour/contrib/hbxbp/xbppushbutton.prg
  * harbour/contrib/hbxbp/xbptabpage.prg
  * harbour/contrib/hbxbp/xbptoolbar.prg
  * harbour/contrib/hbxbp/xbptreeview.prg
  * harbour/contrib/hbxbp/xbpwindow.prg
    ! Implemented full blown XbpTreeView().
      Now it is near equal to Xbase++ one. Please test.

    + Started to implement Xbase++ concept of 
      Presentation Parameters the QT's recommended way through
      Style Sheets. In the first phase Xbase++ compatible 
      attributes will be implemented. Next phase will empower
      user to design application level Style Sheets.
      
  + harbour/contrib/hbxbp/xbpstyle.prg
    + Started to build a Style Sheet 

  * harbour/contrib/hbxbp/tests/demoxbp.prg
    + Demonstrated the extensions to XbpParts the way 
      GUI components will be managed as per look and feel.

      NOTE:  Style Sheet implementation is on the concept level yet
             and is subject to heavy changes per namespace, class
             hirarchy and allied matters. Also it is not Xbase++
             compatible. I am trying to implement Presentation
             Parameters through this mechanism and so far progress
             is quite satisfactory.
This commit is contained in:
Pritpal Bedi
2009-06-22 05:26:13 +00:00
parent be1a0ff9d9
commit 8da2158ce1
12 changed files with 602 additions and 139 deletions

View File

@@ -17,6 +17,39 @@
past entries belonging to author(s): Viktor Szakats.
*/
2009-06-21 22:15 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
* harbour/contrib/hbxbp/Makefile
* harbour/contrib/hbxbp/xbplistbox.prg
* harbour/contrib/hbxbp/xbpmenubar.prg
* harbour/contrib/hbxbp/xbpmle.prg
* harbour/contrib/hbxbp/xbppushbutton.prg
* harbour/contrib/hbxbp/xbptabpage.prg
* harbour/contrib/hbxbp/xbptoolbar.prg
* harbour/contrib/hbxbp/xbptreeview.prg
* harbour/contrib/hbxbp/xbpwindow.prg
! Implemented full blown XbpTreeView().
Now it is near equal to Xbase++ one. Please test.
+ Started to implement Xbase++ concept of
Presentation Parameters the QT's recommended way through
Style Sheets. In the first phase Xbase++ compatible
attributes will be implemented. Next phase will empower
user to design application level Style Sheets.
+ harbour/contrib/hbxbp/xbpstyle.prg
+ Started to build a Style Sheet
* harbour/contrib/hbxbp/tests/demoxbp.prg
+ Demonstrated the extensions to XbpParts the way
GUI components will be managed as per look and feel.
NOTE: Style Sheet implementation is on the concept level yet
and is subject to heavy changes per namespace, class
hirarchy and allied matters. Also it is not Xbase++
compatible. I am trying to implement Presentation
Parameters through this mechanism and so far progress
is quite satisfactory.
2009-06-21 22:11 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
* harbour/contrib/hbqt/hbqt_slots.cpp
* harbour/contrib/hbqt/hbqt_slots.h

View File

@@ -59,6 +59,7 @@ PRG_SOURCES=\
xbpspinbutton.prg \
xbpcombobox.prg \
xbptreeview.prg \
xbpstyle.prg \
PRG_HEADERS=\
xbp.ch \

View File

@@ -82,6 +82,7 @@ PROCEDURE BuildADialog()
/* Make background color of :drawingArea different */
//oDlg:drawingArea:setColorBG( GraMakeRGBColor( { 134,128,164 } ) )
//oDlg:drawingArea:setColorFG( GraMakeRGBColor( { 40,120,100 } ) )
/* Install menu system */
Build_MenuBar()
@@ -408,7 +409,9 @@ 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 } )
@@ -458,8 +461,10 @@ FUNCTION Build_ListBox( oWnd )
oListBox:ItemSelected := {|mp1, mp2, obj| mp1:=oListBox:getData(), ;
mp2:=oListBox:getItem(mp1), MsgBox( "itemSelected:"+mp2 ) }
/* DOES NOT Work in Harbour Xbase++ == OK */
oListBox:setColorBG( GraMakeRGBColor( {127,12,210} ) )
#if 0
oListBox:setColorBG( GraMakeRGBColor( {227,12,110} ) )
oListBox:setColorBG( GraMakeRGBColor( { 27,12, 45} ) )
#endif
RETURN nil
@@ -538,7 +543,7 @@ FUNCTION Build_MLE( oWnd )
// Create MLE, specify position using :create() and
// assign data code block accessing LOCAL variable
oMLE := XbpMLE():new()
oMLE:wordWrap := .F.
oMLE:wordWrap := .t.
oMLE:dataLink := {|x| IIf( x==NIL, cText, cText := x ) }
oMLE:create( oWnd, , {10,10}, {oWnd:currentSize()[1]-25,oWnd:currentSize()[2]-45} )
@@ -658,6 +663,7 @@ FUNCTION Build_TreeView( oWnd )
oTree:hasLines := .T.
oTree:hasButtons := .T.
oTree:create()
oTree:itemCollapsed := {|oItem,aRect,oSelf| MsgBox( oItem:caption ) }
FOR i := 1 TO 5
WorkAreaInfo( oTree, i )
@@ -680,6 +686,9 @@ PROCEDURE WorkAreaInfo( oTree, iIndex )
oStatus:create()
oArea:addItem( oStatus )
#ifdef __HARBOUR__
oArea:setImage( 'copy.png' )
#endif
// Create XbpTreeViewItem implicitly (2nd possibility)
oStruct := oArea:addItem( "STRUCTURE" )

View File

@@ -93,6 +93,7 @@ CLASS XbpListBox INHERIT XbpWindow, XbpDataRef
METHOD handleEvent()
METHOD exeBlock()
METHOD setStyle()
METHOD setItemsHeight( nPixel ) VIRTUAL
METHOD getItemHeight() VIRTUAL
@@ -189,6 +190,7 @@ METHOD XbpListBox:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
::show()
ENDIF
::setStyle()
::oParent:AddChild( SELF )
RETURN Self
@@ -238,3 +240,48 @@ METHOD XbpListBox:destroy()
RETURN NIL
/*----------------------------------------------------------------------*/
METHOD XbpListBox:setStyle()
LOCAL s, txt_:={}
aadd( txt_, ' ' )
aadd( txt_, ' QListView { ' )
aadd( txt_, ' alternate-background-color: yellow; ' )
aadd( txt_, ' } ' )
aadd( txt_, ' ' )
aadd( txt_, ' QListView { ' )
aadd( txt_, ' show-decoration-selected: 1; /* make the selection span the entire width of the view */ ' )
aadd( txt_, ' } ' )
aadd( txt_, ' ' )
aadd( txt_, ' QListView::item:alternate { ' )
aadd( txt_, ' background: #EEEEEE; ' )
aadd( txt_, ' } ' )
aadd( txt_, ' ' )
aadd( txt_, ' QListView::item:selected { ' )
aadd( txt_, ' border: 1px solid #6a6ea9; ' )
aadd( txt_, ' } ' )
aadd( txt_, ' ' )
aadd( txt_, ' QListView::item:selected:!active { ' )
aadd( txt_, ' background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, ' )
aadd( txt_, ' stop: 0 #ABAFE5, stop: 1 #8588B2); ' )
aadd( txt_, ' } ' )
aadd( txt_, ' ' )
aadd( txt_, ' QListView::item:selected:active { ' )
aadd( txt_, ' background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, ' )
aadd( txt_, ' stop: 0 #6a6ea9, stop: 1 #888dd9); ' )
aadd( txt_, ' } ' )
aadd( txt_, ' ' )
aadd( txt_, ' QListView::item:hover { ' )
aadd( txt_, ' background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, ' )
aadd( txt_, ' stop: 0 #FAFBFE, stop: 1 #DCDEF1); ' )
aadd( txt_, '} ' )
aadd( txt_, ' ' )
s := ""
aeval( txt_, {|e| s += e + chr( 13 )+chr( 10 ) } )
::oWidget:setStyleSheet( s )
RETURN self
/*----------------------------------------------------------------------*/

View File

@@ -154,6 +154,7 @@ CLASS xbpMenuBar INHERIT xbpWindow
METHOD ExeBlock()
METHOD ExeHovered()
METHOD PlaceItem()
METHOD setStyle()
ENDCLASS
@@ -195,6 +196,8 @@ METHOD xbpMenuBar:create( oParent, aPresParams, lVisible )
::oParent:oMenu := Self
endif
::setStyle()
::oParent:addChild( self )
RETURN Self
@@ -614,6 +617,39 @@ METHOD xbpMenuBar:onMenuKey( xParam )
RETURN Self
/*----------------------------------------------------------------------*/
METHOD xbpMenuBar:setStyle()
LOCAL txt_:={}
LOCAL s
aadd( txt_, 'QMenuBar { ' )
aadd( txt_, ' background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, ' )
aadd( txt_, ' stop:0 lightgray, stop:1 darkgray); ' )
aadd( txt_, '} ' )
aadd( txt_, ' ' )
aadd( txt_, 'QMenuBar::item { ' )
aadd( txt_, ' spacing: 3px; /* spacing between menu bar items */ ' )
aadd( txt_, ' padding: 1px 4px; ' )
aadd( txt_, ' background: transparent; ' )
aadd( txt_, ' border-radius: 4px; ' )
aadd( txt_, '} ' )
aadd( txt_, ' ' )
aadd( txt_, 'QMenuBar::item:selected { /* when selected using mouse or keyboard */ ' )
aadd( txt_, ' background: #a8a8a8; ' )
aadd( txt_, '} ' )
aadd( txt_, ' ' )
aadd( txt_, 'QMenuBar::item:pressed { ' )
aadd( txt_, ' background: #888888; ' )
aadd( txt_, '} ' )
s := ""
aeval( txt_, {|e| s += e + chr( 13 )+chr( 10 ) } )
::oWidget:setStyleSheet( s )
RETURN Self
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
@@ -634,6 +670,7 @@ CLASS xbpMenu INHERIT xbpMenuBar
METHOD getTitle()
METHOD setTitle()
METHOD popup()
METHOD setStyle()
ENDCLASS
@@ -666,6 +703,7 @@ METHOD xbpMenu:create( oParent, aPresParams, lVisible )
::oWidget := QMenu():new( ::pParent )
::oParent:oWidget:addMenu( ::pWidget )
::setStyle()
::oParent:addChild( self )
RETURN Self
@@ -693,3 +731,86 @@ METHOD xbpMenu:popUp( oXbp, aPos, nDefaultItem, nControl )
RETURN 0
/*----------------------------------------------------------------------*/
METHOD xbpMenu:setStyle()
LOCAL s, txt_:={}
aadd( txt_, ' QMenu { ' )
aadd( txt_, ' background-color: white; ' )
aadd( txt_, ' margin: 2px; /* some spacing around the menu */ ' )
aadd( txt_, ' } ' )
aadd( txt_, ' ' )
aadd( txt_, ' QMenu::item { ' )
aadd( txt_, ' padding: 2px 25px 2px 20px; ' )
aadd( txt_, ' border: 1px solid transparent; /* reserve space for selection border */ ' )
aadd( txt_, ' } ' )
aadd( txt_, ' ' )
aadd( txt_, ' QMenu::item:selected { ' )
aadd( txt_, ' border-color: darkblue; ' )
aadd( txt_, ' background: rgba(100, 100, 100, 150); ' )
aadd( txt_, ' } ' )
aadd( txt_, ' ' )
aadd( txt_, ' QMenu::icon:checked { /* appearance of a "checked" icon */ ' )
aadd( txt_, ' background: gray; ' )
aadd( txt_, ' border: 1px inset gray; ' )
aadd( txt_, ' position: absolute; ' )
aadd( txt_, ' top: 1px; ' )
aadd( txt_, ' right: 1px; ' )
aadd( txt_, ' bottom: 1px; ' )
aadd( txt_, ' left: 1px; ' )
aadd( txt_, ' } ' )
aadd( txt_, ' ' )
aadd( txt_, ' QMenu::separator { ' )
aadd( txt_, ' height: 2px; ' )
aadd( txt_, ' background: lightblue; ' )
aadd( txt_, ' margin-left: 10px; ' )
aadd( txt_, ' margin-right: 5px; ' )
aadd( txt_, ' } ' )
aadd( txt_, ' ' )
aadd( txt_, ' QMenu::indicator { ' )
aadd( txt_, ' width: 13px; ' )
aadd( txt_, ' height: 13px; ' )
aadd( txt_, ' } ' )
aadd( txt_, ' ' )
aadd( txt_, ' /* non-exclusive indicator = check box style indicator (see QActionGroup::setExclusive) */' )
aadd( txt_, ' QMenu::indicator:non-exclusive:unchecked { ' )
aadd( txt_, ' image: url(:/images/checkbox_unchecked.png); ' )
aadd( txt_, ' } ' )
aadd( txt_, ' ' )
aadd( txt_, ' QMenu::indicator:non-exclusive:unchecked:selected { ' )
aadd( txt_, ' image: url(:/images/checkbox_unchecked_hover.png); ' )
aadd( txt_, ' } ' )
aadd( txt_, ' ' )
aadd( txt_, ' QMenu::indicator:non-exclusive:checked { ' )
aadd( txt_, ' image: url(:/images/checkbox_checked.png); ' )
aadd( txt_, ' } ' )
aadd( txt_, ' ' )
aadd( txt_, ' QMenu::indicator:non-exclusive:checked:selected { ' )
aadd( txt_, ' image: url(:/images/checkbox_checked_hover.png); ' )
aadd( txt_, ' } ' )
aadd( txt_, ' ' )
aadd( txt_, ' /* exclusive indicator = radio button style indicator (see QActionGroup::setExclusive) */ ' )
aadd( txt_, ' QMenu::indicator:exclusive:unchecked { ' )
aadd( txt_, ' image: url(:/images/radiobutton_unchecked.png); ' )
aadd( txt_, ' } ' )
aadd( txt_, ' ' )
aadd( txt_, ' QMenu::indicator:exclusive:unchecked:selected { ' )
aadd( txt_, ' image: url(:/images/radiobutton_unchecked_hover.png); ' )
aadd( txt_, ' } ' )
aadd( txt_, ' ' )
aadd( txt_, ' QMenu::indicator:exclusive:checked { ' )
aadd( txt_, ' image: url(:/images/radiobutton_checked.png); ' )
aadd( txt_, ' } ' )
aadd( txt_, ' ' )
aadd( txt_, ' QMenu::indicator:exclusive:checked:selected { ' )
aadd( txt_, ' image: url(:/images/radiobutton_checked_hover.png); ' )
aadd( txt_, ' } ' )
s := ""
aeval( txt_, {|e| s += e + chr( 13 )+chr( 10 ) } )
::oWidget:setStyleSheet( s )
RETURN self
/*----------------------------------------------------------------------*/

View File

@@ -91,6 +91,7 @@ CLASS XbpMLE INHERIT XbpWindow, XbpDataRef
METHOD destroy()
METHOD exeBlock()
METHOD handleEvent()
METHOD setStyle()
METHOD clear() VIRTUAL
METHOD copyMarked() VIRTUAL
@@ -185,6 +186,7 @@ METHOD XbpMLE:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
eval( ::datalink )
ENDIF
::setStyle()
::oParent:addChild( Self )
RETURN Self
@@ -204,56 +206,6 @@ METHOD XbpMLE:handleEvent( nEvent, mp1, mp2 )
RETURN HBXBP_EVENT_UNHANDLED
/*----------------------------------------------------------------------*/
#if 0
DO CASE
CASE nMessage == HB_GTE_COMMAND
DO CASE
CASE aNM[ NMH_code ] == EN_CHANGE
::changed := .t.
CASE aNM[ NMH_code ] == EN_UPDATE
CASE aNM[ NMH_code ] == EN_MAXTEXT
CASE aNM[ NMH_code ] == EN_KILLFOCUS
IF hb_isBlock( ::sl_killInputFocus )
eval( ::sl_killInputFocus, NIL, NIL, Self )
ENDIF
CASE aNM[ NMH_code ] == EN_SETFOCUS
IF hb_isBlock( ::sl_setInputFocus )
eval( ::sl_setInputFocus, NIL, NIL, Self )
ENDIF
CASE aNM[ NMH_code ] == EN_HSCROLL
IF hb_isBlock( ::sl_hScroll )
eval( ::sl_hScroll, NIL, NIL, Self )
ENDIF
CASE aNM[ NMH_code ] == EN_VSCROLL
IF hb_isBlock( ::sl_vScroll )
eval( ::sl_vScroll, NIL, NIL, Self )
ENDIF
ENDCASE
CASE nMessage == HB_GTE_CTLCOLOR
IF hb_isNumeric( ::clr_FG )
WVG_SetTextColor( aNM[ 1 ], ::clr_FG )
ENDIF
IF hb_isNumeric( ::hBrushBG )
WVG_SetBkMode( aNM[ 1 ], 1 )
RETURN ( ::hBrushBG )
ELSE
RETURN WVG_GetCurrentBrush( aNM[ 1 ] )
ENDIF
ENDCASE
#endif
/*----------------------------------------------------------------------*/
METHOD XbpMLE:destroy()
@@ -263,3 +215,32 @@ METHOD XbpMLE:destroy()
RETURN NIL
/*----------------------------------------------------------------------*/
METHOD XbpMLE:setStyle()
LOCAL s, txt_:={}
aadd( txt_, ' ' )
aadd( txt_, ' QTextEdit { ' )
aadd( txt_, ' background-color: white; ' )
aadd( txt_, ' background-image: url(new.png); ' )
aadd( txt_, ' background-attachment: scroll; ' )
aadd( txt_, ' } ' )
#if 0
aadd( txt_, 'If the background-image is to be fixed with the viewport: ' )
aadd( txt_, ' ' )
aadd( txt_, ' QTextEdit { ' )
aadd( txt_, ' background-color: yellow; ' )
aadd( txt_, ' background-image: url(new.png); ' )
aadd( txt_, ' background-attachment: fixed; ' )
aadd( txt_, ' } ' )
#endif
aadd( txt_, ' ' )
s := ""
aeval( txt_, {|e| s += e + chr( 13 )+chr( 10 ) } )
::oWidget:setStyleSheet( s )
RETURN self
/*----------------------------------------------------------------------*/

View File

@@ -100,10 +100,8 @@ CLASS XbpPushButton INHERIT XbpWindow
METHOD handleEvent( nEvent, aInfo )
METHOD exeBlock()
//METHOD setColorFG() INLINE NIL
//METHOD setColorBG() INLINE NIL
ENDCLASS
/*----------------------------------------------------------------------*/
METHOD XbpPushButton:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )

View File

@@ -0,0 +1,158 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Source file for the Xbp*Classes
*
* Copyright 2009 Pritpal Bedi <pritpal@vouchcac.com>
* http://www.harbour-project.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
*
* As a special exception, the Harbour Project gives permission for
* additional uses of the text contained in its release of Harbour.
*
* The exception is that, if you link the Harbour libraries with other
* files to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the Harbour library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the Harbour
* Project under the name Harbour. If you copy code from other
* Harbour Project or Free Software Foundation releases into a copy of
* Harbour, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for Harbour, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*
*/
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/*
* EkOnkar
* ( The LORD is ONE )
*
Class XbpStyle()
*
* Pritpal Bedi <pritpal@vouchcac.com>
* 21Jun2009
*/
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
#include "hbclass.ch"
#include "common.ch"
#include "xbp.ch"
#include "appevent.ch"
#include "hbqt.ch"
/*----------------------------------------------------------------------*/
CLASS XbpStyle
DATA style INIT ""
DATA qtWidget
DATA xbpPart
DATA colorFG
DATA colorBG
METHOD New() INLINE Self
METHOD Create()
METHOD Configure() VIRTUAL
METHOD Destroy() VIRTUAL
ENDCLASS
/*----------------------------------------------------------------------*/
METHOD XbpStyle:create()
LOCAL s := ''
#if 0
IF empty( ::xbpPart )
RETURN nil
ENDIF
#endif
s += ::qtWidget + '{ '
IF !empty( ::colorFG )
s += 'color: '
IF hb_isNumeric( ::colorFG )
s += hb_ntos( ::colorFG )
ELSE
s += ::colorFG
ENDIF
s += '; '
ENDIF
IF !empty( ::colorBG )
s += 'background-color: '
IF hb_isNumeric( ::colorBG )
s += hb_ntos( ::colorBG )
ELSE
s += ::colorBG
ENDIF
s += '; '
ENDIF
s += ' }'
::style := s
RETURN Self
/*----------------------------------------------------------------------*/
STATIC FUNCTION xbpToQT( cXbpPart )
LOCAL aQt := {}
LOCAL n, cQTWidget
cXbpPart := upper( cXbpPart )
aadd( aQt, { 'XBPDIALOG' , 'QWidget' } )
aadd( aQt, { 'XBPPUSHBUTTON' , ' ' } )
aadd( aQt, { 'XBPCHECKBOX' , ' ' } )
aadd( aQt, { 'XBPTREEVIEW' , ' ' } )
aadd( aQt, { 'XBPTREEVIEWITEM', ' ' } )
aadd( aQt, { 'XBPRADIOBUTTON' , ' ' } )
aadd( aQt, { 'XBPSCROLLBAR' , ' ' } )
aadd( aQt, { 'XBPSTATUSBAR' , ' ' } )
aadd( aQt, { 'XBPTABPAGE' , ' ' } )
aadd( aQt, { 'XBPSTATIC' , ' ' } )
IF ( n := ascan( aQt, {|e_| e_[ 1 ] == cXbpPart } ) ) > 0
cQTWidget := aQt[ n,2 ]
ENDIF
RETURN cQTWidget
/*----------------------------------------------------------------------*/

View File

@@ -99,9 +99,8 @@ CLASS XbpTabPage INHERIT XbpWindow
METHOD handleEvent()
METHOD exeBlock()
METHOD setColorBG()
METHOD setColorFG()
ENDCLASS
/*----------------------------------------------------------------------*/
METHOD XbpTabPage:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
@@ -212,27 +211,3 @@ METHOD XbpTabPage:destroy()
RETURN NIL
/*----------------------------------------------------------------------*/
/* TODO */
METHOD XbpTabPage:setColorBG( nRGB )
LOCAL oPalette
IF hb_isNumeric( nRGB )
oPalette := QPalette():new( QT_PTROF( QColor():new( nRGB ) ) )
//oPalette:pPtr := ::oWidget:palette()
//oPalette:setColor( QPalette_Button , QT_PTROF( QColor():new( nRGB ) ) )
//oPalette:setColor( QPalette_Background, QT_PTROF( QColor():new( nRGB ) ) )
//::oWidget:setBackGroundRole( QPalette_Dark )
::oWidget:setPalette( QT_PTROF( oPalette ) )
//::oParent:oTabWidget:setPalette( QT_PTROF( oPalette ) )
ENDIF
RETURN nil
/*----------------------------------------------------------------------*/
METHOD XbpTabPage:setColorFG()
RETURN nil
/*----------------------------------------------------------------------*/

View File

@@ -124,6 +124,7 @@ CLASS XbpToolBar INHERIT XbpWindow
METHOD sendToolbarMessage()
METHOD ExeBlock()
METHOD setStyle()
ENDCLASS
/*----------------------------------------------------------------------*/
@@ -179,6 +180,7 @@ METHOD XbpToolbar:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
::show()
ENDIF
::setStyle()
::oParent:AddChild( SELF )
RETURN Self
@@ -362,6 +364,29 @@ METHOD XbpToolbar:buttonDropDown( xParam )
RETURN Self
/*----------------------------------------------------------------------*/
METHOD XbpToolbar:setStyle()
LOCAL s, txt_:={}
aadd( txt_, ' ' )
aadd( txt_, ' QToolBar { ' )
aadd( txt_, ' background: cyan; ' )
aadd( txt_, ' spacing: 3px; /* spacing between items in the tool bar */ ' )
aadd( txt_, ' } ' )
aadd( txt_, ' ' )
aadd( txt_, ' QToolBar::handle { ' )
aadd( txt_, ' image: url(save.png); ' )
aadd( txt_, ' } ' )
aadd( txt_, ' ' )
s := ""
aeval( txt_, {|e| s += e + chr( 13 )+chr( 10 ) } )
::oWidget:setStyleSheet( s )
RETURN self
/*----------------------------------------------------------------------*/
/*
* XbpToolbarButton() Class compatible with XbpToolbarButton()

View File

@@ -91,19 +91,24 @@ CLASS XbpTreeView INHERIT XbpWindow, XbpDataRef
METHOD destroy()
METHOD handleEvent()
METHOD exeBlock()
METHOD setStyle()
METHOD itemFromPos( aPos )
DATA sl_itemCollapsed
DATA sl_itemExpanded
DATA sl_itemMarked
DATA sl_itemSelected
ACCESS itemCollapsed INLINE ::sl_itemCollapsed
ASSIGN itemCollapsed( bBlock ) INLINE ::sl_itemCollapsed := bBlock
METHOD itemCollapsed() SETGET
METHOD itemExpanded() SETGET
METHOD itemMarked() SETGET
DATA sl_itemExpanded
ACCESS itemExpanded INLINE ::sl_itemExpanded
ASSIGN itemExpanded( bBlock ) INLINE ::sl_itemExpanded := bBlock
DATA sl_itemMarked
ACCESS itemMarked INLINE ::sl_itemMarked
ASSIGN itemMarked( bBlock ) INLINE ::sl_itemMarked := bBlock
DATA oItemSelected
DATA sl_itemSelected
ACCESS itemSelected INLINE ::sl_itemSelected
ASSIGN itemSelected( bBlock ) INLINE ::sl_itemSelected := bBlock
@@ -142,6 +147,7 @@ METHOD XbpTreeView:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
::oWidget:setColumnCount( 1 )
::oWidget:setHeaderHidden( .t. )
#if 0
IF ::alwaysShowSelection
::style += TVS_SHOWSELALWAYS
@@ -154,29 +160,78 @@ METHOD XbpTreeView:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
ENDIF
#endif
::oRootItem := XbpTreeViewItem():New()
::oRootItem:hTree := ::oWidget
::oRootItem := XbpTreeViewItem():New()
::oRootItem:hTree := ::oWidget
::oRootItem:oXbpTree := self
oW := QTreeWidgetItem()
oW:pPtr := ::oWidget:invisibleRootItem()
::oRootItem:oItemWidget := oW
oW := QTreeWidgetItem()
oW:pPtr := ::oWidget:invisibleRootItem()
::oRootItem:oWidget := oW
//::connect( ::pWidget, "currentItemChanged(QTWItem)" , {|o,p1,p2| ::exeBlock( 1, p1, p2, o ) } )
//::connect( ::pWidget, "itemActivated(QTWItem)" , {|o,p1,p2| ::exeBlock( 2, p1, p2, o ) } )
//::connect( ::pWidget, "itemChanged(QTWItem)" , {|o,p1,p2| ::exeBlock( 3, p1, p2, o ) } )
::connect( ::pWidget, "itemClicked(QTWItem)" , {|o,p1,p2| ::exeBlock( 4, p1, p2, o ) } )
::connect( ::pWidget, "itemCollapsed(QTWItem)" , {|o,p1,p2| ::exeBlock( 5, p1, p2, o ) } )
::connect( ::pWidget, "itemDoubleClicked(QTWItem)" , {|o,p1,p2| ::exeBlock( 6, p1, p2, o ) } )
//::connect( ::pWidget, "itemEntered(QTWItem)" , {|o,p1,p2| ::exeBlock( 7, p1, p2, o ) } )
::connect( ::pWidget, "itemExpanded(QTWItem)" , {|o,p1,p2| ::exeBlock( 8, p1, p2, o ) } )
//::connect( ::pWidget, "itemPressed(QTWItem)" , {|o,p1,p2| ::exeBlock( 9, p1, p2, o ) } )
//::connect( ::pWidget, "itemSelectionChanged()" , {|o,p1,p2| ::exeBlock( 10, p1, p2, o ) } )
::setPosAndSize()
IF ::visible
::show()
ENDIF
::setStyle()
::oParent:AddChild( SELF )
RETURN Self
/*----------------------------------------------------------------------*/
METHOD XbpTreeView:ExeBlock( nMsg, p1, p2 )
LOCAL oItem, n
HB_SYMBOL_UNUSED( nMsg )
HB_SYMBOL_UNUSED( p1 )
HB_SYMBOL_UNUSED( p2 )
RETURN .t.
hb_outDebug( hb_ntos( nMsg ) )
IF hb_isPointer( p1 )
IF ( n := ascan( ::aItems, {|o| o:oWidget:pPtr == p1 } ) ) > 0
oItem := ::aItems[ n ]
ENDIF
ENDIF
DO CASE
CASE nMsg == 1 // "currentItemChanged(QTWItem)"
CASE nMsg == 2 // "itemActivated(QTWItem)"
CASE nMsg == 3 // "itemChanged(QTWItem)"
CASE nMsg == 4 // "itemClicked(QTWItem)"
IF hb_isBlock( ::sl_itemMarked )
eval( ::sl_itemMarked, oItem, {0,0,0,0}, self )
ENDIF
CASE nMsg == 5 // "itemCollapsed(QTWItem)"
IF hb_isBlock( ::sl_itemCollapsed )
eval( ::sl_itemCollapsed, oItem, {0,0,0,0}, self )
ENDIF
CASE nMsg == 6 // "itemDoubleClicked(QTWItem)"
IF hb_isBlock( ::sl_itemSelected )
eval( ::sl_itemSelected, oItem, {0,0,0,0}, self )
ENDIF
CASE nMsg == 7 // "itemEntered(QTWItem)"
CASE nMsg == 8 // "itemExpanded(QTWItem)"
IF hb_isBlock( ::sl_itemExpanded )
eval( ::sl_itemExpanded, oItem, {0,0,0,0}, self )
ENDIF
CASE nMsg == 9 // "itemPressed(QTWItem)"
CASE nMsg == 10 // "itemSelectionChanged()"
ENDCASE
RETURN .f.
/*----------------------------------------------------------------------*/
@@ -213,7 +268,7 @@ METHOD XbpTreeView:itemFromPos( aPos )
RETURN Self
/*----------------------------------------------------------------------*/
#if 0
METHOD XbpTreeView:itemCollapsed( xParam )
IF hb_isBlock( xParam ) .or. ( xParam == NIL )
@@ -241,7 +296,7 @@ METHOD XbpTreeView:itemMarked( xParam )
ENDIF
RETURN Self
#endif
/*----------------------------------------------------------------------*/
#if 0
METHOD XbpTreeView:itemSelected( xParam )
@@ -255,10 +310,11 @@ METHOD XbpTreeView:itemSelected( xParam )
/*----------------------------------------------------------------------*/
/* Class XbpTreeViewItem */
/*----------------------------------------------------------------------*/
CLASS XbpTreeViewItem
DATA oItemWidget
ACCESS pItemWidget INLINE IF( hb_isObject( ::oItemWidget ), ::oItemWidget:pPtr, NIL )
CLASS XbpTreeViewItem INHERIT XbpDataRef
DATA oWidget
ACCESS pWidget INLINE IF( hb_isObject( ::oWidget ), ::oWidget:pPtr, NIL )
DATA caption INIT ""
DATA dllName INIT NIL
@@ -266,53 +322,73 @@ CLASS XbpTreeViewItem
DATA image INIT -1
DATA markedImage INIT -1
DATA xValue // To be returned by get/set methods
DATA hTree
DATA hItem
DATA oParent
DATA oWnd
DATA oXbpTree
DATA aChilds INIT {}
METHOD new()
METHOD create()
METHOD configure()
METHOD destroy()
#if 0
METHOD expand( lExpand ) INLINE WVG_TreeView_Expand( ::hTree, ::hItem, ;
IF( hb_isLogical( lExpand ), lExpand, .t. ) )
#endif
METHOD isExpanded()
METHOD setCaption( cCaption )
METHOD expand( lExpand ) INLINE ::oWidget:setExpanded( lExpand )
METHOD isExpanded() INLINE ::oWidget:isExpanded()
METHOD setCaption( cCaption ) INLINE ::oWidget:setText( 0, cCaption )
METHOD setImage( xIcon )
METHOD setExpandedImage( nResIdoBitmap )
METHOD setImage( nResIdoBitmap )
METHOD setMarkedImage( nResIdoBitmap )
METHOD addItem()
METHOD delItem()
METHOD delItem( oItem )
METHOD getChildItems()
METHOD getParentItem()
METHOD insItem()
ENDCLASS
/*----------------------------------------------------------------------*/
METHOD XbpTreeViewItem:addItem( xItem )
METHOD XbpTreeViewItem:addItem( xItem, xNormalImage, xMarkedImage, xExpandedImage, cDllName, xValue )
Local oItem
HB_SYMBOL_UNUSED( cDllName )
IF valtype( xItem ) == 'C'
oItem := XbpTreeViewItem():New()
oItem:oParent := self
oItem:caption := xItem
oItem:oItemWidget := QTreeWidgetItem():new()
oItem:oItemWidget:setText( 0, oItem:caption )
::oItemWidget:addChild( oItem:oItemWidget:pPtr )
oItem:oWidget := QTreeWidgetItem():new()
oItem:oWidget:setText( 0, oItem:caption )
ELSE
xItem:oParent := self
::oItemWidget:addChild( xItem:oItemWidget:pPtr )
RETURN xItem
oItem := xItem
ENDIF
oItem:oParent := self
oItem:oXbpTree := oItem:oParent:oXbpTree
IF xNormalImage <> NIL
oItem:image := xNormalImage
ENDIF
IF xMarkedImage <> NIL
oItem:markedImage := xMarkedImage
ENDIF
IF xExpandedImage <> NIL
oItem:expandedImage := xExpandedImage
ENDIF
IF xValue <> NIL
oItem:xValue := xValue
ENDIF
::oWidget:addChild( oItem:oWidget:pPtr )
aadd( oItem:aChilds, oItem )
aadd( oItem:oXbpTree:aItems, oItem )
RETURN oItem
/*----------------------------------------------------------------------*/
@@ -325,8 +401,8 @@ METHOD XbpTreeViewItem:new()
METHOD XbpTreeViewItem:create()
::oItemWidget := QTreeWidgetItem():new()
::oItemWidget:setText( 0,::caption )
::oWidget := QTreeWidgetItem():new()
::oWidget:setText( 0,::caption )
RETURN Self
@@ -344,32 +420,19 @@ METHOD XbpTreeViewItem:destroy()
/*----------------------------------------------------------------------*/
METHOD XbpTreeViewItem:isExpanded()
RETURN NIL
/*----------------------------------------------------------------------*/
METHOD XbpTreeViewItem:setCaption( cCaption )
HB_SYMBOL_UNUSED( cCaption )
RETURN NIL
/*----------------------------------------------------------------------*/
METHOD XbpTreeViewItem:setExpandedImage( nResIdoBitmap )
HB_SYMBOL_UNUSED( nResIdoBitmap )
RETURN NIL
/*----------------------------------------------------------------------*/
METHOD XbpTreeViewItem:setImage( nResIdoBitmap )
METHOD XbpTreeViewItem:setImage( xIcon )
HB_SYMBOL_UNUSED( nResIdoBitmap )
::oWidget:setIcon( 0, xIcon )
RETURN NIL
RETURN self
/*----------------------------------------------------------------------*/
@@ -381,7 +444,14 @@ METHOD XbpTreeViewItem:setMarkedImage( nResIdoBitmap )
/*----------------------------------------------------------------------*/
METHOD XbpTreeViewItem:delItem()
METHOD XbpTreeViewItem:delItem( oItem )
LOCAL n
IF ( n := ascan( ::aChilds, oItem ) ) > 0
::oWidget:removeChild( ::aChilds[ n ]:oWidget:pPtr )
adel( ::aChilds, n )
asize( ::aChilds, len( ::aChilds )-1 )
ENDIF
RETURN NIL
@@ -404,4 +474,19 @@ METHOD XbpTreeViewItem:insItem()
RETURN NIL
/*----------------------------------------------------------------------*/
/* Another approach - in the making
*/
METHOD XbpTreeView:setStyle()
LOCAL oS
oS := XbpStyle():new()
oS:xbpPart := "XbpTreeView"
oS:qtWidget := "QTreeWidget"
oS:colorFG := "white"
oS:colorBG := "blue"
oS:create()
::oWidget:setStyleSheet( oS:style )
RETURN nil
/*----------------------------------------------------------------------*/

View File

@@ -78,6 +78,7 @@
CLASS XbpWindow INHERIT XbpPartHandler
DATA cargo INIT ""
DATA styleSheet INIT ""
/* CONFIGURATION */
DATA animate INIT .F.
@@ -266,6 +267,8 @@ EXPORTED:
DATA aConnections INIT {}
DATA aEConnections INIT {}
METHOD setStyle() INLINE NIL
ENDCLASS
/*----------------------------------------------------------------------*/
@@ -453,6 +456,7 @@ METHOD XbpWindow:lockUpdate()
/*----------------------------------------------------------------------*/
METHOD XbpWindow:setColorBG( nRGB )
#if 0
LOCAL cClass := __ObjGetClsName( self )
IF hb_isNumeric( nRGB )
@@ -470,12 +474,18 @@ METHOD XbpWindow:setColorBG( nRGB )
::oWidget:setPalette( QT_PTROF( ::oPalette ) )
ENDIF
#endif
LOCAL oColor := QColor():new( nRGB )
::oWidget:setStyleSheet( "background-color: "+ oColor:name +";" )
RETURN Self
/*----------------------------------------------------------------------*/
METHOD XbpWindow:setColorFG( nRGB )
#if 0
LOCAL cClass := __ObjGetClsName( self )
IF hb_isNumeric( nRGB )
@@ -494,6 +504,11 @@ METHOD XbpWindow:setColorFG( nRGB )
::oWidget:setPalette( QT_PTROF( ::oPalette ) )
ENDIF
#endif
LOCAL oColor := QColor():new( nRGB )
::oWidget:setStyleSheet( "color: "+ oColor:name +";" )
RETURN Self
@@ -1220,3 +1235,18 @@ METHOD XbpObject:INIT()
RETURN Self
/*----------------------------------------------------------------------*/
#if 0 /* A Template */
METHOD xbpWindow:setStyle()
LOCAL s, txt_:={}
aadd( txt_, ' ' )
aadd( txt_, ' ' )
s := ""
aeval( txt_, {|e| s += e + chr( 13 )+chr( 10 ) } )
::oWidget:setStyleSheet( s )
RETURN self
#endif
/*----------------------------------------------------------------------*/