2009-06-20 12:01 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)

* harbour/contrib/hbxbp/xbpdataref.prg
  + harbour/contrib/hbxbp/xbpspinbutton.prg
  * harbour/contrib/hbxbp/xbptoolbar.prg
    + Added XbpSpinButton() class [P] Two features left.

  * harbour/contrib/hbxbp/tests/demoxbp.prg
    + Demoonstrated XbpSpinButton() implementation - Click Tab#3
This commit is contained in:
Pritpal Bedi
2009-06-20 19:04:26 +00:00
parent fe9ab29884
commit 7f85d980ce
6 changed files with 310 additions and 11 deletions

View File

@@ -17,6 +17,16 @@
past entries belonging to author(s): Viktor Szakats.
*/
2009-06-20 12:01 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
* harbour/contrib/hbxbp/xbpdataref.prg
+ harbour/contrib/hbxbp/xbpspinbutton.prg
* harbour/contrib/hbxbp/xbptoolbar.prg
+ Added XbpSpinButton() class [P] Two features left.
* harbour/contrib/hbxbp/tests/demoxbp.prg
+ Demoonstrated XbpSpinButton() implementation - Click Tab#3
2009-06-20 20:31 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* source/vm/fm.c
! Renamed s_fInited to s_fInitedFM to avoid collision
@@ -68,11 +78,11 @@
* ChangeLog
* Item marked DONE.
2009-06-20 14:40 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
2009-06-20 02:40 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
* harbour/contrib/hbxbp/Makefile
! Deleted files were not deleted from make tree.
2009-06-20 14:40 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
2009-06-20 02:40 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
- harbour/contrib/hbxbp/apig.ch
- harbour/contrib/hbxbp/xbp_temp.prg
- Delted dummy constants and functions.
@@ -102,7 +112,7 @@
* harbour/contrib/hbxbp/tests/demoxbp.prg
! Demonstrated XbpMLE() implementation - click on tab#2.
2009-06-20 14:34 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
2009-06-20 02:34 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
* harbour/contrib/hbqt/hbqt.ch
* harbour/contrib/hbqt/hbqt_qlineedit.cpp
* harbour/contrib/hbqt/moc_slots.cpp

View File

@@ -56,6 +56,7 @@ PRG_SOURCES=\
xbpscrollbar.prg \
xbpsle.prg \
xbpmle.prg \
xbpspinbutton.prg \
PRG_HEADERS=\
xbp.ch \

View File

@@ -119,6 +119,9 @@ PROCEDURE BuildADialog()
/* Install ScrollBar */
Build_ScrollBar( aTabs[ 1 ] )
/* Install Spin Buttons */
Build_SpinButtons( aTabs[ 3 ] )
/* Present the dialog on the screen */
oDlg:Show()
@@ -134,7 +137,7 @@ PROCEDURE BuildADialog()
/* Very important - destroy resources */
oDlg:destroy()
RETURN
RETURN nil
/*----------------------------------------------------------------------*/
@@ -392,9 +395,7 @@ FUNCTION Build_TabPages( oDlg )
oTab1:minimized := .F.
oTab1:caption := "Customer"
oTab1:create()
oTab1:TabActivate := ;
{|| oTab2:minimize(), oTab3:minimize(),;
oTab1:maximize(), MsgBox( oTab1:caption ) }
oTab1:TabActivate := {|| oTab2:minimize(), oTab3:minimize(), oTab1:maximize() }
oTab1:setColorBG( GraMakeRGBColor( {198,198,198} ) )
// Second tab page is minimized
@@ -405,7 +406,7 @@ FUNCTION Build_TabPages( oDlg )
oTab2:create()
oTab2:TabActivate := ;
{|| oTab1:minimize(), oTab3:minimize(),;
oTab2:maximize(), MsgBox( oTab2:caption ) }
oTab2:maximize() }
// Third tab page is minimized
oTab3 := XbpTabPage():new( oDlg:drawingArea, , { 510, 20 }, { 360, nHeight } )
@@ -414,8 +415,7 @@ FUNCTION Build_TabPages( oDlg )
oTab3:postOffset := 40
oTab3:create()
oTab3:TabActivate := ;
{|x,y,oTab| x := y, oTab1:minimize(), oTab2:minimize(),;
oTab3:maximize(), MsgBox( oTab:caption ) }
{|x,y,oTab| x := y, oTab1:minimize(), oTab2:minimize(), oTab3:maximize() }
RETURN { oTab1, oTab2, oTab3 }
@@ -496,7 +496,7 @@ FUNCTION Build_SLEs( oWnd )
oXbp:setData()
//oXbp:setInputFocus := { |x,y,oSLE| oSLE:getData(), Qt_QDebug( "Var A =" + cVarA ) }
//oXbp:setInputFocus := { |x,y,oSLE| oSLE:getData() }
hb_outDebug("nnnn")
oXbp := XbpSLE():new()
oXbp:autoTab := .T.
oXbp:bufferLength := 20
@@ -530,3 +530,58 @@ FUNCTION Build_MLE( oWnd )
RETURN nil
/*----------------------------------------------------------------------*/
FUNCTION Build_SpinButtons( oWnd )
LOCAL oSpinRed, oSpinGreen, oSpinBlue, bBlock
LOCAL nGreen := 5, nBlue := 12, nRed := 35
LOCAL nX := 230, nY := 190
// Callback code block
bCallback := {|mp1, mp2, oXbp| nRed := oXbp:getData(), ;
RGB( nRed, nGreen, nBlue ) }
// Create spinbutton for red (without using :dataLink)
oSpinRed := XbpSpinButton():new( oWnd,, {nX,nY+00}, {100,40} )
oSpinRed:align := 2
oSpinRed:fastSpin := .T.
oSpinRed:create()
oSpinRed:setNumLimits( 0, 255 )
oSpinRed:endSpin := bCallback
oSpinRed:keyboard := bCallback
oSpinRed:setData( 121 )
// Callback code block
bCallback := {|mp1, mp2, oXbp| oXbp:getData(), ;
RGB( nRed, nGreen, nBlue ) }
// Create spinbutton for green (using :dataLink)
oSpinGreen := XbpSpinButton():new( oWnd,, {nX,nY+50}, {100,40} )
oSpinGreen:align := 3
oSpinGreen:create()
oSpinGreen:setNumLimits( 0, 255 )
oSpinGreen:dataLink := {|x| IIf( x==NIL, nGreen, nGreen := x ) }
oSpinGreen:endSpin := bCallback
oSpinGreen:keyboard := bCallback
oSpinGreen:setData()
// Create spinbutton for blue (using :dataLink)
// (Master is oSpinGreen)
oSpinBlue := XbpSpinButton():new( oWnd,, {nX,nY+100}, {100,40} )
oSpinBlue:master := oSpinGreen
oSpinBlue:create()
oSpinBlue:setNumLimits( 0, 255 )
oSpinBlue:dataLink := {|x| IIf( x==NIL, nBlue, nBlue := x ) }
oSpinBlue:endSpin := bCallback
oSpinBlue:keyboard := bCallback
RETURN nil
/*----------------------------------------------------------------------*/
STATIC FUNCTION RGB( r, g, b )
// Display a static window with flashing color of rgb
RETURN nil
/*----------------------------------------------------------------------*/

View File

@@ -123,6 +123,9 @@ METHOD XbpDataRef:getData()
CASE cClass == "XBPSCROLLBAR"
::sl_editBuffer := ::oWidget:value()
CASE cClass == "XBPSPINBUTTON"
::sl_editBuffer := ::oWidget:value()
ENDCASE
IF hb_isBlock( ::dataLink )
@@ -169,6 +172,9 @@ METHOD XbpDataRef:setData( xValue, mp2 )
::oWidget:setText( ::sl_editBuffer )
ENDIF
CASE cClass == "XBPSPINBUTTON"
::oWidget:setValue( ::sl_editBuffer )
CASE cClass == "XBPSCROLLBAR"
IF ::sl_editBuffer <> NIL
::oWidget:setValue( ::sl_editBuffer )

View File

@@ -0,0 +1,226 @@
/*
* $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 )
*
* Xbase++ XbpSpinButton compatible Class
*
* Pritpal Bedi <pritpal@vouchcac.com>
* 17Jun2009
*/
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
#include "hbclass.ch"
#include "common.ch"
#include "xbp.ch"
#include "appevent.ch"
#include "hbqt.ch"
/*----------------------------------------------------------------------*/
CLASS XbpSpinButton INHERIT XbpWindow, XbpDataRef
DATA fastSpin INIT .f.
DATA master
DATA padWithZero INIT .f.
DATA align INIT XBPSLE_LEFT
DATA autoKeyboard INIT .T.
DATA autoSize INIT .F.
DATA autoTab INIT .F.
DATA border INIT .T.
DATA bufferLength INIT 32
DATA editable INIT .T.
DATA unReadable INIT .F.
DATA changed INIT .F.
METHOD new()
METHOD create()
METHOD configure() VIRTUAL
METHOD destroy()
METHOD handleEvent()
METHOD exeBlock()
METHOD clear() INLINE ::oWidget:clear()
METHOD copyMarked() INLINE ::oWidget:copy()
METHOD cutMarked() INLINE ::oWidget:cut()
METHOD delMarked() INLINE ::oWidget:del()
METHOD editBuffer() INLINE ::oWidget:text()
METHOD pasteMarked() INLINE ::oWidget:paste()
METHOD queryFirstChar() VIRTUAL
METHOD queryMarked() INLINE { ::oWidget:selectionStart(), ::oWidget:selectionEnd() }
METHOD setFirstChar( nPos ) VIRTUAL
METHOD setMarked( aStartEnd ) INLINE ::setSelection( aStartEnd[ 1 ], aStartEnd[ 2 ] )
METHOD spinDown( nDecrement ) INLINE ::oWidget:stepBy( -nDecrement )
METHOD spinUp( nIncrement ) INLINE ::oWidget:stepBy( nIncrement )
METHOD setNumLimits( nMin, nMax ) INLINE ::oWidget:setRange( nMin, nMax )
DATA sl_xbeSpinDown
ACCESS down INLINE ::sl_hScroll
ASSIGN down( bBlock ) INLINE ::sl_hScroll := bBlock
DATA sl_xbeSpinUp
ACCESS up INLINE ::sl_xbeSpinUp
ASSIGN up( bBlock ) INLINE ::sl_xbeSpinUp := bBlock
DATA sl_xbeSpinEndSpin
ACCESS endSpin INLINE ::sl_xbeSpinEndSpin
ASSIGN endSpin( bBlock ) INLINE ::sl_xbeSpinEndSpin := bBlock
ENDCLASS
/*----------------------------------------------------------------------*/
METHOD XbpSpinButton:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
::Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
RETURN Self
/*----------------------------------------------------------------------*/
METHOD XbpSpinButton:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
LOCAL es_:= { Qt_AlignLeft, Qt_AlignRight, Qt_AlignHCenter }
::xbpWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
::oWidget := QSpinBox():new( ::pParent )
::oWidget:setKeyboardTracking( .t. )
IF ::fastSpin
::oWidget:setAccelerated( .t. )
ENDIF
::oWidget:setReadOnly( ! ::editable )
::oWidget:setFrame( ::border )
::oWidget:setAlignment( es_[ ::align ] )
QT_QObject_InstallEventFilter( ::pWidget, SetEventFilter() )
::connectEvent( ::pWidget, QEvent_FocusIn , {|o,e| ::exeBlock( 7, e, o ) } )
::connectEvent( ::pWidget, QEvent_FocusOut, {|o,e| ::exeBlock( 8, e, o ) } )
::connectEvent( ::pWidget, QEvent_KeyPress, {|o,e| ::exeBlock( 9, e, o ) } )
::connect( ::pWidget, "valueChanged(int)" , {|| ::sl_editBuffer := ::oWidget:value() } )
::setPosAndSize()
IF ::visible
::show()
ENDIF
::setData()
#if 0
IF hb_isBlock( ::datalink )
eval( ::datalink )
ENDIF
#endif
::oParent:addChild( Self )
RETURN Self
/*----------------------------------------------------------------------*/
METHOD XbpSpinButton:exeBlock( nMsg, p1, p2 )
HB_SYMBOL_UNUSED( p1 )
HB_SYMBOL_UNUSED( p2 )
::sl_editBuffer := ::oWidget:value()
DO CASE
CASE nMsg == 9 // valueChanged
IF hb_isBlock( ::sl_keyboard )
eval( ::sl_keyboard, NIL, NIL, self )
ENDIF
CASE nMsg == 7 // QEvent_FocusIn
IF hb_isBlock( ::sl_setInputFocus )
eval( ::sl_setInputFocus, NIL, NIL, Self )
ENDIF
CASE nMsg == 8 // QEvent_FocusOut
IF hb_isBlock( ::sl_killInputFocus )
eval( ::sl_killInputFocus, NIL, NIL, Self )
ENDIF
ENDCASE
RETURN .t.
/*----------------------------------------------------------------------*/
METHOD XbpSpinButton:handleEvent( nEvent, mp1, mp2 )
HB_SYMBOL_UNUSED( nEvent )
HB_SYMBOL_UNUSED( mp1 )
HB_SYMBOL_UNUSED( mp2 )
RETURN HBXBP_EVENT_UNHANDLED
/*----------------------------------------------------------------------*/
METHOD XbpSpinButton:destroy()
::xbpWindow:destroy()
RETURN NIL
/*----------------------------------------------------------------------*/

View File

@@ -410,3 +410,4 @@ METHOD XbpToolbarButton:new( cCaption, nStyle, cKey )
RETURN Self
/*----------------------------------------------------------------------*/