From b109875df73bf9e126e283fa759be8e2c53efbdf Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Mon, 29 Jun 2009 02:46:22 +0000 Subject: [PATCH] 2009-06-28 19:40 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * harbour/contrib/hbxbp/xbp.ch * harbour/contrib/hbxbp/xbp3state.prg * harbour/contrib/hbxbp/xbpcheckbox.prg * harbour/contrib/hbxbp/xbpcombobox.prg * harbour/contrib/hbxbp/xbpdialog.prg * harbour/contrib/hbxbp/xbpmenubar.prg * harbour/contrib/hbxbp/xbpmle.prg * harbour/contrib/hbxbp/xbpradiobutton.prg * harbour/contrib/hbxbp/xbpscrollbar.prg * harbour/contrib/hbxbp/xbpsle.prg * harbour/contrib/hbxbp/xbpspinbutton.prg * harbour/contrib/hbxbp/xbpstatusbar.prg * harbour/contrib/hbxbp/xbptabpage.prg * harbour/contrib/hbxbp/xbptreeview.prg * harbour/contrib/hbxbp/xbpwindow.prg + Added :setPointer() method to change the cursor shape for a widget. ! Advanced implementation of Presentation Parameters. Now the base structure is almost like Xbase++ one. About to generate a Style Sheet based on PresParametrs array. ! Code tweaked more organized. * harbour/contrib/hbxbp/tests/demoxbp.prg + Demonstrated the use of Cursor Shapes. --- harbour/ChangeLog | 25 ++ harbour/contrib/hbxbp/tests/demoxbp.prg | 41 ++- harbour/contrib/hbxbp/xbp.ch | 34 ++- harbour/contrib/hbxbp/xbp3state.prg | 2 +- harbour/contrib/hbxbp/xbpcheckbox.prg | 4 +- harbour/contrib/hbxbp/xbpcombobox.prg | 2 +- harbour/contrib/hbxbp/xbpdialog.prg | 28 +- harbour/contrib/hbxbp/xbpmenubar.prg | 4 + harbour/contrib/hbxbp/xbpmle.prg | 2 +- harbour/contrib/hbxbp/xbpradiobutton.prg | 2 +- harbour/contrib/hbxbp/xbpscrollbar.prg | 2 +- harbour/contrib/hbxbp/xbpsle.prg | 2 +- harbour/contrib/hbxbp/xbpspinbutton.prg | 2 +- harbour/contrib/hbxbp/xbpstatusbar.prg | 19 +- harbour/contrib/hbxbp/xbptabpage.prg | 2 +- harbour/contrib/hbxbp/xbptreeview.prg | 2 +- harbour/contrib/hbxbp/xbpwindow.prg | 326 +++++++++++++++++++---- 17 files changed, 411 insertions(+), 88 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 521e48e55f..42bb4560ac 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,31 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-06-28 19:40 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * harbour/contrib/hbxbp/xbp.ch + * harbour/contrib/hbxbp/xbp3state.prg + * harbour/contrib/hbxbp/xbpcheckbox.prg + * harbour/contrib/hbxbp/xbpcombobox.prg + * harbour/contrib/hbxbp/xbpdialog.prg + * harbour/contrib/hbxbp/xbpmenubar.prg + * harbour/contrib/hbxbp/xbpmle.prg + * harbour/contrib/hbxbp/xbpradiobutton.prg + * harbour/contrib/hbxbp/xbpscrollbar.prg + * harbour/contrib/hbxbp/xbpsle.prg + * harbour/contrib/hbxbp/xbpspinbutton.prg + * harbour/contrib/hbxbp/xbpstatusbar.prg + * harbour/contrib/hbxbp/xbptabpage.prg + * harbour/contrib/hbxbp/xbptreeview.prg + * harbour/contrib/hbxbp/xbpwindow.prg + + Added :setPointer() method to change the cursor shape for a widget. + ! Advanced implementation of Presentation Parameters. Now the + base structure is almost like Xbase++ one. About to + generate a Style Sheet based on PresParametrs array. + ! Code tweaked more organized. + + * harbour/contrib/hbxbp/tests/demoxbp.prg + + Demonstrated the use of Cursor Shapes. + 2009-06-28 19:19 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * harbour/contrib/hbqt/generator/qt45.qtp * harbour/contrib/hbqt/Makefile_gen diff --git a/harbour/contrib/hbxbp/tests/demoxbp.prg b/harbour/contrib/hbxbp/tests/demoxbp.prg index 5534707ccc..76e694113d 100644 --- a/harbour/contrib/hbxbp/tests/demoxbp.prg +++ b/harbour/contrib/hbxbp/tests/demoxbp.prg @@ -70,12 +70,13 @@ PROCEDURE BuildADialog() LOCAL oDlg, mp1, mp2, oXbp, nEvent, aSize, aTabs, oDa LOCAL nThread := ThreadID() LOCAL cThread := hb_ntos( nThread ) + LOCAL aPP /* Create Application Window */ oDlg := GuiStdDialog( "Harbour - Xbase++ - QT Dialog [ "+ hb_ntos( nThread )+" ]" ) oDlg:close := {|| MsgBox( "You can also close me by pressing [ESC]" ), .T. } - oDlg:killDisplayFocus := {|| hb_OutDebug( "Loosing Display Focus" ) } + // oDlg:killDisplayFocus := {|| hb_OutDebug( "Loosing Display Focus" ) } SetAppWindow( oDlg ) oDlg:show() @@ -99,7 +100,7 @@ PROCEDURE BuildADialog() Build_MenuBar() /* Install Statusbar */ - Build_StatusBar( oDlg ) + Build_StatusBar( oDa ) /* Install Toolbar */ Build_ToolBar( oDa ) @@ -140,6 +141,9 @@ PROCEDURE BuildADialog() /* Install TreeView */ Build_TreeView( aTabs[ 4 ] ) +//aPP := aTabs[4]:setPresParam() +//hb_outDebug( valtype( aPP ) +' '+ str( len( aPP ) ) ) + /* Present the dialog on the screen */ oDlg:Show() @@ -167,7 +171,7 @@ PROCEDURE AppSys() /*----------------------------------------------------------------------*/ #ifdef __XPP__ -FUNCTION Hb_OutDebug();RETURN nil +FUNCTION Hb_OutDebug( cStr );RETURN nil FUNCTION Hb_Symbol_Unused();RETURN nil FUNCTION Hb_NtoS( n );RETURN ltrim( str( n ) ) FUNCTION Hb_ThreadStart();RETURN nil @@ -235,7 +239,6 @@ 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() @@ -360,7 +363,6 @@ FUNCTION Build_CheckBox( oWnd ) {| mp1, mp2, oChk| MsgBox( "Checkbox B", ; IIf( oChk:getData(), "selected", ; "not selected" ) ) } - RETURN nil /*----------------------------------------------------------------------*/ @@ -435,6 +437,8 @@ FUNCTION Build_TabPages( oDlg ) oTab1:create() oTab1:TabActivate := {|| oTab2:minimize(), oTab3:minimize(), oTab4:minimize(), oTab1:maximize() } + oTab1:setPointer( , XBPSTATIC_SYSICON_WAIT, XBPWINDOW_POINTERTYPE_SYSPOINTER ) + // Second tab page is minimized oTab2 := XbpTabPage():new( oDlg:drawingArea, , { 510, 20 }, { 360, nHeight } ) oTab2:caption := "XbpMLE" @@ -484,11 +488,10 @@ FUNCTION Build_ListBox( oWnd ) // Code block for list box selection: oListBox:ItemSelected := {|mp1, mp2, obj| mp1:=oListBox:getData(), ; mp2:=oListBox:getItem( mp1 ), MsgBox( "itemSelected: "+mp2 ) } - - #if 1 - oListBox:setColorBG( GraMakeRGBColor( {227,12,110} ) ) + oListBox:setColorFG( GraMakeRGBColor( {227,12,110} ) ) oListBox:setColorBG( GraMakeRGBColor( { 27,12, 45} ) ) - #endif + + oListBox:setPointer( , XBPSTATIC_SYSICON_MOVE, XBPWINDOW_POINTERTYPE_SYSPOINTER ) RETURN nil @@ -504,6 +507,8 @@ FUNCTION Build_StatusBar( oWnd ) oPanel:caption := "Harbour-QT-Xbase++ is Ready" oPanel:autosize := XBPSTATUSBAR_AUTOSIZE_SPRING + oSBar:setPointer( , XBPSTATIC_SYSICON_SIZEWE, XBPWINDOW_POINTERTYPE_SYSPOINTER ) + RETURN nil /*----------------------------------------------------------------------*/ @@ -768,3 +773,21 @@ PROCEDURE FieldStruct( oItem, aField ) /*----------------------------------------------------------------------*/ +STATIC FUNCTION PP_Debug( oXbp ) + LOCAL aPP := oXbp:setPresParam() + LOCAL s := '' + + aeval( aPP, {|e_| s += ( hb_ntos( e_[ 1 ] ) +' '+ valtype( e_[ 2 ] ) +' '+ ; + IF( valtype( e_[ 2 ] )=='N', hb_ntos( e_[ 2 ] ), ' ' ) + '; '+ chr( 13 )+chr( 10 ) ) } ) + + #ifdef __XPP__ + MsgBox( s ) + #else + hb_outDebug( s ) + #endif + + RETURN nil + +/*----------------------------------------------------------------------*/ + + diff --git a/harbour/contrib/hbxbp/xbp.ch b/harbour/contrib/hbxbp/xbp.ch index f5fe9f7d95..4e67536c52 100644 --- a/harbour/contrib/hbxbp/xbp.ch +++ b/harbour/contrib/hbxbp/xbp.ch @@ -185,7 +185,9 @@ #define XBPSYSCLR_TRANSPARENT ( -255 ) - +#define XBP_DISP_MODELESS 1 +#define XBP_DISP_APPMODAL 2 +#define XBP_DISP_SYSMODAL 3 #define XBPSLE_LEFT 1 #define XBPSLE_RIGHT 2 @@ -232,7 +234,35 @@ #define XBP_MK_CONTROL 8 #define XBP_MK_MBUTTON 16 +#define XBPWINDOW_POINTERTYPE_POINTER 1 +#define XBPWINDOW_POINTERTYPE_SYSPOINTER 2 +#define XBPWINDOW_POINTERTYPE_ICON 3 + +#define XBPSTATIC_SYSICON_DEFAULT 0 +#define XBPSTATIC_SYSICON_ARROW 1 +#define XBPSTATIC_SYSICON_TEXT 2 +#define XBPSTATIC_SYSICON_WAIT 3 +#define XBPSTATIC_SYSICON_SIZE 4 +#define XBPSTATIC_SYSICON_MOVE 5 +#define XBPSTATIC_SYSICON_SIZENWSE 6 +#define XBPSTATIC_SYSICON_SIZENESW 7 +#define XBPSTATIC_SYSICON_SIZEWE 8 +#define XBPSTATIC_SYSICON_SIZENS 9 +#define XBPSTATIC_SYSICON_APPICON 10 +#define XBPSTATIC_SYSICON_ICONINFORMATION 11 +#define XBPSTATIC_SYSICON_ICONQUESTION 12 +#define XBPSTATIC_SYSICON_ICONERROR 13 +#define XBPSTATIC_SYSICON_ICONWARNING 14 +#define XBPSTATIC_SYSICON_ILLEGAL 18 +#define XBPSTATIC_SYSICON_FILE 19 +#define XBPSTATIC_SYSICON_FOLDER 20 +#define XBPSTATIC_SYSICON_MULTFILE 21 +#define XBPSTATIC_SYSICON_PROGRAM 22 +#define XBPSTATIC_SYSICON_DISPLAY_PTRS 22 +#define XBPSTATIC_SYSICON_PENFIRST 23 +#define XBPSTATIC_SYSICON_PENLAST 39 + +/*----------------------------------------------------------------------*/ #define _XBP_CH #endif -/*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbxbp/xbp3state.prg b/harbour/contrib/hbxbp/xbp3state.prg index c9662b265a..616177fdcf 100644 --- a/harbour/contrib/hbxbp/xbp3state.prg +++ b/harbour/contrib/hbxbp/xbp3state.prg @@ -100,7 +100,7 @@ CLASS Xbp3State INHERIT XbpWindow, XbpDataRef METHOD Xbp3State:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - ::initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + ::xbpWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) RETURN Self diff --git a/harbour/contrib/hbxbp/xbpcheckbox.prg b/harbour/contrib/hbxbp/xbpcheckbox.prg index 2b7b33da1a..1a2b970331 100644 --- a/harbour/contrib/hbxbp/xbpcheckbox.prg +++ b/harbour/contrib/hbxbp/xbpcheckbox.prg @@ -100,7 +100,7 @@ CLASS XbpCheckBox INHERIT XbpWindow, XbpDataRef METHOD XbpCheckBox:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - ::Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + ::xbpWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) RETURN Self @@ -108,7 +108,7 @@ METHOD XbpCheckBox:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) METHOD XbpCheckBox:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - ::Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + ::xbpWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::oWidget := QCheckBox():New( QT_PTROF( ::oParent:oWidget ) ) ::Connect( ::pWidget, "stateChanged(int)", {|o,i| ::exeBlock( i,o ) } ) diff --git a/harbour/contrib/hbxbp/xbpcombobox.prg b/harbour/contrib/hbxbp/xbpcombobox.prg index baadf2a452..ee10b6e174 100644 --- a/harbour/contrib/hbxbp/xbpcombobox.prg +++ b/harbour/contrib/hbxbp/xbpcombobox.prg @@ -128,7 +128,7 @@ CLASS XbpComboBox INHERIT XbpWindow METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - ::Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + ::xbpWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) RETURN Self diff --git a/harbour/contrib/hbxbp/xbpdialog.prg b/harbour/contrib/hbxbp/xbpdialog.prg index 2f1685a590..407fadaade 100644 --- a/harbour/contrib/hbxbp/xbpdialog.prg +++ b/harbour/contrib/hbxbp/xbpdialog.prg @@ -213,16 +213,26 @@ METHOD XbpDialog:destroy() /*----------------------------------------------------------------------*/ METHOD XbpDialog:setFrameState( nState ) - LOCAL lSuccess := .f. + LOCAL lSuccess := .T. + LOCAL nCurState := ::getFrameState() DO CASE - CASE nState == XBPDLG_FRAMESTAT_MINIMIZED - + IF nCurState != XBPDLG_FRAMESTAT_MINIMIZED + ::oWidget:setWindowState( Qt_WindowMinimized ) + ENDIF CASE nState == XBPDLG_FRAMESTAT_MAXIMIZED - + IF nCurState == XBPDLG_FRAMESTAT_MINIMIZED + ::oWidget:show() + ::oWidget:setWindowState( Qt_WindowMaximized ) + ELSEIF nCurState == XBPDLG_FRAMESTAT_NORMALIZED + ::oWidget:setWindowState( Qt_WindowMaximized ) + ENDIF CASE nState == XBPDLG_FRAMESTAT_NORMALIZED - + IF nCurState != XBPDLG_FRAMESTAT_MINIMIZED + ::oWidget:show() + ENDIF + ::oWidget:setWindowState( Qt_WindowNoState ) ENDCASE RETURN lSuccess @@ -230,15 +240,13 @@ METHOD XbpDialog:setFrameState( nState ) /*----------------------------------------------------------------------*/ METHOD XbpDialog:getFrameState() + LOCAL nState := ::oWidget:windowState() - #if 0 - IF Qtc_IsIconic( ::hWnd ) + IF ( hb_bitAnd( nState, Qt_WindowMinimized ) == Qt_WindowMinimized ) RETURN XBPDLG_FRAMESTAT_MINIMIZED - ENDIF - IF Qtc_IsZoomed( ::hWnd ) + ELSEIF ( hb_bitAnd( nState, Qt_WindowMaximized ) == Qt_WindowMaximized ) RETURN XBPDLG_FRAMESTAT_MAXIMIZED ENDIF - #endif RETURN XBPDLG_FRAMESTAT_NORMALIZED diff --git a/harbour/contrib/hbxbp/xbpmenubar.prg b/harbour/contrib/hbxbp/xbpmenubar.prg index 3af2b09c40..c40a261d18 100644 --- a/harbour/contrib/hbxbp/xbpmenubar.prg +++ b/harbour/contrib/hbxbp/xbpmenubar.prg @@ -686,6 +686,8 @@ METHOD xbpMenu:new( oParent, aPresParams, lVisible ) ::aPresParams := aPresParams ::visible := lVisible + ::xbpWindow:new( ::oParent, , , , ::aPresParams, ::visible ) + RETURN Self /*----------------------------------------------------------------------*/ @@ -700,6 +702,8 @@ METHOD xbpMenu:create( oParent, aPresParams, lVisible ) ::aPresParams := aPresParams ::visible := lVisible + ::xbpWindow:create( ::oParent, , , , ::aPresParams, ::visible ) + ::oWidget := QMenu():new( ::pParent ) ::oParent:oWidget:addMenu( ::pWidget ) diff --git a/harbour/contrib/hbxbp/xbpmle.prg b/harbour/contrib/hbxbp/xbpmle.prg index 75ccaf3aef..ec9a34ef5c 100644 --- a/harbour/contrib/hbxbp/xbpmle.prg +++ b/harbour/contrib/hbxbp/xbpmle.prg @@ -132,7 +132,7 @@ CLASS XbpMLE INHERIT XbpWindow, XbpDataRef METHOD XbpMLE:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - ::Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + ::xbpWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) RETURN Self diff --git a/harbour/contrib/hbxbp/xbpradiobutton.prg b/harbour/contrib/hbxbp/xbpradiobutton.prg index 9d517c7ddd..5f23a2eaa2 100644 --- a/harbour/contrib/hbxbp/xbpradiobutton.prg +++ b/harbour/contrib/hbxbp/xbpradiobutton.prg @@ -99,7 +99,7 @@ CLASS XbpRadioButton INHERIT XbpWindow, XbpDataRef METHOD XbpRadioButton:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - ::Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + ::xbpWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) RETURN Self diff --git a/harbour/contrib/hbxbp/xbpscrollbar.prg b/harbour/contrib/hbxbp/xbpscrollbar.prg index 3f840be0cc..fceff4ce88 100644 --- a/harbour/contrib/hbxbp/xbpscrollbar.prg +++ b/harbour/contrib/hbxbp/xbpscrollbar.prg @@ -103,7 +103,7 @@ CLASS XbpScrollBar INHERIT XbpWindow, XbpDataRef METHOD XbpScrollBar:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - ::Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + ::xbpWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) RETURN Self diff --git a/harbour/contrib/hbxbp/xbpsle.prg b/harbour/contrib/hbxbp/xbpsle.prg index 99d84ab23f..d57d14d94e 100644 --- a/harbour/contrib/hbxbp/xbpsle.prg +++ b/harbour/contrib/hbxbp/xbpsle.prg @@ -121,7 +121,7 @@ CLASS XbpSLE INHERIT XbpWindow, XbpDataRef METHOD XbpSLE:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - ::Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + ::xbpWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) RETURN Self diff --git a/harbour/contrib/hbxbp/xbpspinbutton.prg b/harbour/contrib/hbxbp/xbpspinbutton.prg index 0faa656211..6dc46bd6f0 100644 --- a/harbour/contrib/hbxbp/xbpspinbutton.prg +++ b/harbour/contrib/hbxbp/xbpspinbutton.prg @@ -131,7 +131,7 @@ CLASS XbpSpinButton INHERIT XbpWindow, XbpDataRef METHOD XbpSpinButton:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - ::Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + ::xbpWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) RETURN Self diff --git a/harbour/contrib/hbxbp/xbpstatusbar.prg b/harbour/contrib/hbxbp/xbpstatusbar.prg index 71b9ab7e09..f96e031114 100644 --- a/harbour/contrib/hbxbp/xbpstatusbar.prg +++ b/harbour/contrib/hbxbp/xbpstatusbar.prg @@ -103,18 +103,31 @@ CLASS XbpStatusBar INHERIT XbpWindow METHOD XbpStatusBar:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - ::Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + ::xbpWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) RETURN Self /*----------------------------------------------------------------------*/ METHOD XbpStatusBar:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + LOCAL oPar ::xbpWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - ::oWidget := QStatusBar():new( ::pParent ) - ::oParent:oWidget:setStatusBar( ::pWidget ) + IF upper( ::oParent:className ) == "XBPDIALOG" + oPar := ::oParent + ELSEIF upper( ::oParent:className ) == "XBPDRAWINGAREA" + oPar := ::oParent:oParent + ELSE + RETURN Self + ENDIF + + ::oWidget := QToolBar():new( QT_PTROF( oPar:oWidget ) ) + oPar:oWidget:addToolBar_1( ::pWidget ) + + ::oWidget := QStatusBar():new( QT_PTROF( oPar:oWidget ) ) + oPar:oWidget:setStatusBar( ::pWidget ) + ::oWidget:setSizeGripEnabled( ::sizeGrip ) IF ::visible diff --git a/harbour/contrib/hbxbp/xbptabpage.prg b/harbour/contrib/hbxbp/xbptabpage.prg index 0834dce300..20ed89920a 100644 --- a/harbour/contrib/hbxbp/xbptabpage.prg +++ b/harbour/contrib/hbxbp/xbptabpage.prg @@ -105,7 +105,7 @@ CLASS XbpTabPage INHERIT XbpWindow METHOD XbpTabPage:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - ::Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + ::xbpWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) RETURN Self diff --git a/harbour/contrib/hbxbp/xbptreeview.prg b/harbour/contrib/hbxbp/xbptreeview.prg index 3ace2413bc..10e09697c0 100644 --- a/harbour/contrib/hbxbp/xbptreeview.prg +++ b/harbour/contrib/hbxbp/xbptreeview.prg @@ -132,7 +132,7 @@ CLASS XbpTreeView INHERIT XbpWindow, XbpDataRef METHOD XbpTreeView:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - ::xbpWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + ::xbpWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) RETURN Self diff --git a/harbour/contrib/hbxbp/xbpwindow.prg b/harbour/contrib/hbxbp/xbpwindow.prg index 429573e7f9..0560711e27 100644 --- a/harbour/contrib/hbxbp/xbpwindow.prg +++ b/harbour/contrib/hbxbp/xbpwindow.prg @@ -103,11 +103,6 @@ CLASS XbpWindow INHERIT XbpPartHandler DATA helpLink DATA tooltipText INIT "" - DATA clr_FG - DATA clr_BG - DATA fnt_COMMPOUNDNAME - DATA fnt_hFont - /* CALLBACK SLOTS */ DATA sl_enter DATA sl_leave @@ -277,6 +272,8 @@ EXPORTED: METHOD setStyle() INLINE NIL + DATA lTrack INIT .f. + ENDCLASS /*----------------------------------------------------------------------*/ @@ -306,6 +303,7 @@ METHOD XbpWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) /*----------------------------------------------------------------------*/ METHOD XbpWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + LOCAL aPP, i, cClass := __objGetClsName( Self ) DEFAULT oParent TO ::oParent DEFAULT oOwner TO ::oOwner @@ -323,6 +321,34 @@ METHOD XbpWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::XbpPartHandler:create( oParent, oOwner ) + aPP := Xbp_PresParam() + FOR i := 1 TO len( ::aPresParams ) + Xbp_SetPresParam( aPP, ::aPresParams[ i,1 ], ::aPresParams[ i,2 ] ) + NEXT + ::aPresParams := aPP + + DO CASE + CASE cClass $ 'XBPDIALOG,XBPDRAWINGAREA' + Xbp_SetPresParamIfNil( ::aPresParams, XBP_PP_BGCLR , XBPSYSCLR_DIALOGBACKGROUND ) + Xbp_SetPresParamIfNil( ::aPresParams, XBP_PP_DISABLED_BGCLR, XBPSYSCLR_DIALOGBACKGROUND ) + CASE cClass $ 'XBPPUSHBUTTON' + Xbp_SetPresParamIfNil( ::aPresParams, XBP_PP_FGCLR , XBPSYSCLR_BUTTONTEXT ) + Xbp_SetPresParamIfNil( ::aPresParams, XBP_PP_BGCLR , XBPSYSCLR_BUTTONMIDDLE ) + Xbp_SetPresParamIfNil( ::aPresParams, XBP_PP_DISABLED_BGCLR, XBPSYSCLR_BUTTONMIDDLE ) + CASE cClass $ 'XBPTABPAGE' + Xbp_SetPresParamIfNil( ::aPresParams, XBP_PP_BGCLR , XBPSYSCLR_BUTTONMIDDLE ) + Xbp_SetPresParamIfNil( ::aPresParams, XBP_PP_DISABLED_BGCLR, XBPSYSCLR_BUTTONMIDDLE ) + CASE cClass $ 'XBPLISTBOX' + Xbp_SetPresParamIfNil( ::aPresParams, XBP_PP_BGCLR , XBPSYSCLR_ENTRYFIELD ) + CASE cClass $ 'XBPSCROLLBAR' + Xbp_SetPresParamIfNil( ::aPresParams, XBP_PP_BGCLR , XBPSYSCLR_SCROLLBAR ) + CASE cClass $ 'XBPSLE,XBPMLE' + Xbp_SetPresParamIfNil( ::aPresParams, XBP_PP_BGCLR , XBPSYSCLR_ENTRYFIELD ) + Xbp_SetPresParamIfNil( ::aPresParams, XBP_PP_DISABLED_BGCLR, XBPSYSCLR_3DFACE ) + CASE cClass $ 'XBPSPINBUTTON,XBPCOMBOBOX,XBPTREEVIEW' + Xbp_SetPresParamIfNil( ::aPresParams, XBP_PP_BGCLR , XBPSYSCLR_ENTRYFIELD ) + ENDCASE + RETURN Self /*----------------------------------------------------------------------*/ @@ -432,14 +458,18 @@ METHOD XbpWindow:grabEvent( nEvent, pEvent, oXbp ) ENDCASE EXIT CASE QEvent_Enter // :enter() - oEvent := QMouseEvent() - oEvent:pPtr := pEvent - SetAppEvent( xbeM_Enter, { oEvent:x(), oEvent:y() }, NIL, self ) + IF ( ::lTrack ) + oEvent := QMouseEvent() + oEvent:pPtr := pEvent + SetAppEvent( xbeM_Enter, { oEvent:x(), oEvent:y() }, NIL, self ) + ENDIF EXIT CASE QEvent_Leave // :leave() - oEvent := QMouseEvent() - oEvent:pPtr := pEvent - SetAppEvent( xbeM_Leave, { oEvent:x(), oEvent:y() }, NIL, self ) + IF ( ::lTrack ) + oEvent := QMouseEvent() + oEvent:pPtr := pEvent + SetAppEvent( xbeM_Leave, { oEvent:x(), oEvent:y() }, NIL, self ) + ENDIF EXIT CASE QEvent_Wheel // :wheel() oEvent := QWheelEvent() @@ -651,7 +681,7 @@ METHOD XbpWindow:configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible METHOD XbpWindow:destroy() -hb_outDebug( "Destroy: "+pad(__ObjGetClsName( self ),12)+ IF(empty(::cargo),'',str(::cargo) ) ) +//hb_outDebug( "Destroy: "+pad(__ObjGetClsName( self ),12)+ IF(empty(::cargo),'',str(::cargo) ) ) IF Len( ::aChildren ) > 0 aeval( ::aChildren, {|o| o:destroy() } ) @@ -671,15 +701,25 @@ hb_outDebug( "Destroy: "+pad(__ObjGetClsName( self ),12)+ IF(empty(::cargo),'',s ::oWidget:close() -hb_outDebug( " Destroy: "+pad(__ObjGetClsName( self ),12)+ IF(empty(::cargo),'',str(::cargo) ) ) +//hb_outDebug( " Destroy: "+pad(__ObjGetClsName( self ),12)+ IF(empty(::cargo),'',str(::cargo) ) ) RETURN NIL /*----------------------------------------------------------------------*/ -METHOD XbpWindow:captureMouse() +METHOD XbpWindow:captureMouse( lCapture ) + LOCAL lSuccess := .f. - RETURN Self + IF hb_isLogical( lCapture ) + IF lCapture + ::oWidget:grabMouse() + ELSE + ::oWidget:releaseMouse() + ENDIF + lSuccess := .t. /* QT cannot determine if it succeeded */ + ENDIF + + RETURN lSuccess /*----------------------------------------------------------------------*/ @@ -688,7 +728,7 @@ METHOD XbpWindow:disable() ::oWidget:setDisabled( .t. ) ::is_enabled := ::oWidget:isEnabled() - RETURN .f. + RETURN ( ! ::is_enabled ) /*----------------------------------------------------------------------*/ @@ -697,7 +737,7 @@ METHOD XbpWindow:enable() ::oWidget:setEnabled( .t. ) ::is_enabled := ::oWidget:isEnabled() - RETURN .f. + RETURN ( ::is_enabled ) /*----------------------------------------------------------------------*/ @@ -705,16 +745,17 @@ METHOD XbpWindow:hide() IF hb_isObject( ::oWidget ) ::oWidget:hide() - ::is_hidden := .t. ENDIF + ::is_hidden := ::oWidget:isHidden() - RETURN Self + RETURN ::is_hidden /*----------------------------------------------------------------------*/ METHOD XbpWindow:invalidateRect( aRect ) HB_SYMBOL_UNUSED( aRect ) + // TODO: RETURN self @@ -722,12 +763,16 @@ METHOD XbpWindow:invalidateRect( aRect ) METHOD XbpWindow:lockPS() + // TODO: + RETURN Self /*----------------------------------------------------------------------*/ METHOD XbpWindow:lockUpdate() + // TODO: + RETURN Self /*----------------------------------------------------------------------*/ @@ -742,35 +787,35 @@ METHOD XbpWindow:setStyleSheet( cNewSheet ) /*----------------------------------------------------------------------*/ METHOD XbpWindow:setColorBG( nRGB ) - #if 0 - LOCAL cClass := __ObjGetClsName( self ) + //LOCAL cClass := __ObjGetClsName( self ) + LOCAL oColor := QColor():new( nRGB ) + LOCAL oldRGB IF hb_isNumeric( nRGB ) - IF empty( ::oPalette ) - ::oPalette := QPalette() - ::oPalette:pPtr := ::oWidget:palette() - ENDIF - - DO CASE - CASE cClass $ 'XBPPUSHBUTTON,XBPMENUBAR,XBPMENU,XBPTOOLBAR,XBPTABPAGE,XBPLISTBOX' - ::oPalette:setColor( QPalette_Button , QT_PTROF( QColor():new( nRGB ) ) ) - OTHERWISE - ::oPalette:setColor( QPalette_Background, QT_PTROF( QColor():new( nRGB ) ) ) - ENDCASE - - ::oWidget:setPalette( QT_PTROF( ::oPalette ) ) + oldRGB := Xbp_SetPresParam( ::aPresParams, XBP_PP_BGCLR, nRGB ) + ::setStyleSheet( "background-color: "+ oColor:name +";" ) + ELSE + oldRGB := Xbp_SetPresParam( ::aPresParams, XBP_PP_BGCLR ) ENDIF - #endif - LOCAL oColor := QColor():new( nRGB ) - - ::setStyleSheet( "background-color: "+ oColor:name +";" ) - - RETURN Self + RETURN oldRGB /*----------------------------------------------------------------------*/ METHOD XbpWindow:setColorFG( nRGB ) + //LOCAL cClass := __ObjGetClsName( self ) + LOCAL oColor := QColor():new( nRGB ) + LOCAL oldRGB + + IF hb_isNumeric( nRGB ) + oldRGB := Xbp_SetPresParam( ::aPresParams, XBP_PP_FGCLR, nRGB ) + ::setStyleSheet( "color: "+ oColor:name +";" ) + ELSE + oldRGB := Xbp_SetPresParam( ::aPresParams, XBP_PP_FGCLR ) + ENDIF + + RETURN oldRGB + #if 0 LOCAL cClass := __ObjGetClsName( self ) @@ -790,13 +835,12 @@ METHOD XbpWindow:setColorFG( nRGB ) ::oWidget:setPalette( QT_PTROF( ::oPalette ) ) ENDIF - #endif LOCAL oColor := QColor():new( nRGB ) - + Xbp_SetPresParam( ::aPresParams, XBP_PP_FGCLR, nRGB ) ::setStyleSheet( "color: "+ oColor:name +";" ) - RETURN Self + #endif /*----------------------------------------------------------------------*/ @@ -804,7 +848,7 @@ METHOD XbpWindow:setFontCompoundName( xFont ) LOCAL cOldFont, s, n, nPoint, cFont, cAttr, cFace LOCAL aAttr := { "normal","italic","bold" } - cOldFont := ::fnt_COMMPOUNDNAME + cOldFont := Xbp_SetPresParam( ::aPresParams, XBP_PP_COMPOUNDNAME ) IF hb_isNumeric( cFont ) @@ -828,6 +872,8 @@ METHOD XbpWindow:setFontCompoundName( xFont ) ENDIF cFace := alltrim( cFont ) + Xbp_SetPresParam( ::aPresParams, XBP_PP_COMPOUNDNAME, xFont ) + ::setStyleSheet( 'font-family: "'+ cFace +'"; font-style: '+ cAttr +'; font-size: '+ hb_ntos( nPoint )+'pt;' ) ENDIF ENDIF @@ -836,21 +882,107 @@ METHOD XbpWindow:setFontCompoundName( xFont ) /*----------------------------------------------------------------------*/ -METHOD XbpWindow:setModalState() +METHOD XbpWindow:setModalState( nState ) + + DO CASE + CASE nState == XBP_DISP_MODELESS + ::oWidget:setWindowModality( Qt_NonModal ) + CASE nState == XBP_DISP_APPMODAL + ::oWidget:setWindowModality( Qt_ApplicationModal ) + CASE nState == XBP_DISP_SYSMODAL + // TODO: + ENDCASE RETURN Self /*----------------------------------------------------------------------*/ -METHOD XbpWindow:setPointer() +STATIC FUNCTION Xbp_SetCursor( oXbp, nShape ) + LOCAL oCursor := QCursor():new() + oCursor:setShape( nShape ) + oXbp:oWidget:setCursor( oCursor:pPtr ) + + RETURN nil + +/*----------------------------------------------------------------------*/ + +METHOD XbpWindow:setPointer( cDllName, nResID, nType ) + + HB_SYMBOL_UNUSED( cDllName ) + + DEFAULT nType TO XBPWINDOW_POINTERTYPE_POINTER + + DO CASE + CASE nType == XBPWINDOW_POINTERTYPE_POINTER + // TODO: + + CASE nType == XBPWINDOW_POINTERTYPE_SYSPOINTER + DO CASE + CASE nResID == XBPSTATIC_SYSICON_DEFAULT // Default mouse pointer + CASE nResID == XBPSTATIC_SYSICON_ARROW // Normal arrow + Xbp_SetCursor( Self, Qt_ArrowCursor ) + CASE nResID == XBPSTATIC_SYSICON_WAIT // Hour glass or clock + Xbp_SetCursor( Self, Qt_WaitCursor ) + CASE nResID == XBPSTATIC_SYSICON_MOVE // Move the window + Xbp_SetCursor( Self, Qt_OpenHandCursor ) + CASE nResID == XBPSTATIC_SYSICON_SIZE // Change size (all directions) + Xbp_SetCursor( Self, Qt_SizeAllCursor ) + CASE nResID == XBPSTATIC_SYSICON_SIZENWSE // Change size (North west-South east) + Xbp_SetCursor( Self, Qt_SizeFDiagCursor ) + CASE nResID == XBPSTATIC_SYSICON_SIZENESW // Change size (North east-South west) + Xbp_SetCursor( Self, Qt_SizeBDiagCursor ) + CASE nResID == XBPSTATIC_SYSICON_SIZEWE // Change size (West-East) + Xbp_SetCursor( Self, Qt_SizeHorCursor ) + CASE nResID == XBPSTATIC_SYSICON_SIZENS // Change size (North-South) + Xbp_SetCursor( Self, Qt_SizeVerCursor ) + + /* Possible Harbour-QT extensions */ + + CASE nResID == Qt_UpArrowCursor + Xbp_SetCursor( Self, Qt_UpArrowCursor ) + CASE nResID == Qt_CrossCursor + Xbp_SetCursor( Self, Qt_CrossCursor ) + CASE nResID == Qt_IBeamCursor + Xbp_SetCursor( Self, Qt_IBeamCursor ) + CASE nResID == Qt_BlankCursor + Xbp_SetCursor( Self, Qt_BlankCursor ) + CASE nResID == Qt_SplitVCursor + Xbp_SetCursor( Self, Qt_SplitVCursor ) + CASE nResID == Qt_SplitHCursor + Xbp_SetCursor( Self, Qt_SplitHCursor ) + CASE nResID == Qt_PointingHandCursor + Xbp_SetCursor( Self, Qt_PointingHandCursor ) + CASE nResID == Qt_ForbiddenCursor + Xbp_SetCursor( Self, Qt_ForbiddenCursor ) + CASE nResID == Qt_ClosedHandCursor + Xbp_SetCursor( Self, Qt_ClosedHandCursor ) + CASE nResID == Qt_WhatsThisCursor + Xbp_SetCursor( Self, Qt_WhatsThisCursor ) + CASE nResID == Qt_BusyCursor + Xbp_SetCursor( Self, Qt_BusyCursor ) + CASE nResID == Qt_BitmapCursor + Xbp_SetCursor( Self, Qt_BitmapCursor ) + + ENDCASE + + CASE nType == XBPWINDOW_POINTERTYPE_ICON + // TODO: + + ENDCASE RETURN Self /*----------------------------------------------------------------------*/ -METHOD XbpWindow:setTrackPointer() +METHOD XbpWindow:setTrackPointer( lTrack ) + LOCAL lRet := .f. - RETURN Self + IF hb_isLogical( lTrack ) + ::lTrack := lTrack + lRet := .T. + ENDIF + + RETURN ( lRet ) /*----------------------------------------------------------------------*/ @@ -898,7 +1030,7 @@ METHOD XbpWindow:setSize( aSize, lPaint ) METHOD XbpWindow:isDerivedFrom( cClassORoObject ) LOCAL lTrue := .f. - LOCAL cCls := __ObjGetClsName( self ) + LOCAL cCls := __ObjGetClsName( Self ) /* Compares without Xbp or Wvg prefixes */ @@ -929,37 +1061,58 @@ METHOD XbpWindow:show() METHOD XbpWindow:toBack() + // TODO: + RETURN self /*----------------------------------------------------------------------*/ METHOD XbpWindow:toFront() + // TODO: + RETURN self /*----------------------------------------------------------------------*/ METHOD XbpWindow:unlockPS() + // TODO: + RETURN Self /*----------------------------------------------------------------------*/ METHOD XbpWindow:winDevice() + // TODO: + RETURN Self /*----------------------------------------------------------------------*/ METHOD XbpWindow:setFont() + // TODO: + RETURN Self /*----------------------------------------------------------------------*/ -METHOD XbpWindow:setPresParam() +METHOD XbpWindow:setPresParam( aPPNew ) + LOCAL i, aPP - RETURN Self + aPP := aclone( ::aPresParams ) + + IF hb_isArray( aPPNew ) + FOR i := 1 TO len( aPPNew ) + Xbp_SetPresParam( ::aPresParams, aPPNew[ i,1 ], aPPNew[ i,2 ] ) + NEXT + ENDIF + + // Build Style Sheet + + RETURN aPP /*----------------------------------------------------------------------*/ @@ -982,14 +1135,25 @@ METHOD XbpWindow:getHWND() /*----------------------------------------------------------------------*/ METHOD XbpWindow:getModalState() + LOCAL nState - RETURN Self + nState := ::oWidget:windowModality() + + IF hb_bitAnd( nState, Qt_NonModal ) == Qt_NonModal + RETURN ( XBP_DISP_MODELESS ) + ELSEIF hb_bitAnd( nState, Qt_ApplicationModal ) == Qt_ApplicationModal + RETURN ( XBP_DISP_APPMODAL ) + ELSE + // TODO: XBP_DISP_SYSMODAL + ENDIF + + RETURN -1 /*----------------------------------------------------------------------*/ METHOD XbpWindow:hasInputFocus() - RETURN Self + RETURN ::oWidget:hasFocus() /*----------------------------------------------------------------------*/ * Callback Methods @@ -1524,3 +1688,59 @@ METHOD xbpWindow:setStyle() RETURN self #endif /*----------------------------------------------------------------------*/ + +STATIC FUNCTION Xbp_PresParam() + LOCAL aPP := {} + + aadd( aPP, { XBP_PP_FGCLR , NIL } ) + aadd( aPP, { XBP_PP_BGCLR , NIL } ) + aadd( aPP, { XBP_PP_HILITE_FGCLR , NIL } ) + aadd( aPP, { XBP_PP_HILITE_BGCLR , NIL } ) + aadd( aPP, { XBP_PP_DISABLED_FGCLR , NIL } ) + aadd( aPP, { XBP_PP_DISABLED_BGCLR , NIL } ) + aadd( aPP, { XBP_PP_BORDER_CLR , NIL } ) + aadd( aPP, { XBP_PP_COMPOUNDNAME , NIL } ) + aadd( aPP, { XBP_PP_FONT , NIL } ) + aadd( aPP, { XBP_PP_ACTIVE_CLR , NIL } ) + aadd( aPP, { XBP_PP_INACTIVE_CLR , NIL } ) + aadd( aPP, { XBP_PP_ACTIVETEXT_FGCLR , NIL } ) + aadd( aPP, { XBP_PP_ACTIVETEXT_BGCLR , NIL } ) + aadd( aPP, { XBP_PP_INACTIVETEXT_FGCLR , NIL } ) + aadd( aPP, { XBP_PP_INACTIVETEXT_BGCLR , NIL } ) + aadd( aPP, { XBP_PP_CAPTION , NIL } ) + aadd( aPP, { XBP_PP_ALIGNMENT , NIL } ) + aadd( aPP, { XBP_PP_ORIGIN , NIL } ) + + RETURN aPP + +/*----------------------------------------------------------------------*/ + +STATIC FUNCTION Xbp_SetPresParamIfNil( aPP, nParam, xValue ) + LOCAL n + + IF xValue != NIL + IF ( n := ascan( aPP, {|e_| e_[ 1 ] == nParam } ) ) > 0 + IF aPP[ n,2 ] == NIL + aPP[ n,2 ] := xValue + ENDIF + ENDIF + ENDIF + + RETURN nil + +/*----------------------------------------------------------------------*/ + +STATIC FUNCTION Xbp_SetPresParam( aPP, nParam, xValue ) + LOCAL oldValue, n + + IF ( n := ascan( aPP, {|e_| e_[ 1 ] == nParam } ) ) > 0 + oldValue := aPP[ n,2 ] + IF xValue != NIL + aPP[ n,2 ] := xValue + ENDIF + ENDIF + + RETURN oldValue + +/*----------------------------------------------------------------------*/ +