diff --git a/harbour/ChangeLog b/harbour/ChangeLog index a3cdd67983..4acc4e41d4 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,12 @@ The license applies to all entries newer than 2009-04-28. */ +2011-05-06 11:46 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/hbxbp/xbp.ch + * contrib/hbxbp/xbpdialog.prg + * contrib/hbxbp/xbppushbutton.prg + + Implemented: XbpDialog():showModal() functionality. + 2011-05-06 11:46 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbxbp/xbpdialog.prg * contrib/hbxbp/xbpwindow.prg diff --git a/harbour/contrib/hbxbp/xbp.ch b/harbour/contrib/hbxbp/xbp.ch index d6df6a6204..80ff4b9fd4 100644 --- a/harbour/contrib/hbxbp/xbp.ch +++ b/harbour/contrib/hbxbp/xbp.ch @@ -445,6 +445,13 @@ #define APPTYPE_PM 3 +#define XBP_MRESULT_NONE 0 +#define XBP_MRESULT_OK 1 +#define XBP_MRESULT_CANCEL 2 +#define XBP_MRESULT_RETRY 4 +#define XBP_MRESULT_YESTOALL 8 +#define XBP_MRESULT_ERROR ( -1 ) + /*----------------------------------------------------------------------*/ /* Harbour Parts Constants */ /*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbxbp/xbpdialog.prg b/harbour/contrib/hbxbp/xbpdialog.prg index 743349dc16..b62cf8715d 100644 --- a/harbour/contrib/hbxbp/xbpdialog.prg +++ b/harbour/contrib/hbxbp/xbpdialog.prg @@ -93,6 +93,10 @@ CLASS XbpDialog FROM XbpWindow DATA origin INIT XBPDLG_ORIGIN_OWNER DATA sysMenu INIT .T. + DATA modalResult INIT XBP_MRESULT_NONE + DATA l_modalState INIT .f. + METHOD setModalResult( nResult ) INLINE ::modalResult := nResult + METHOD init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) METHOD configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) @@ -251,6 +255,10 @@ METHOD XbpDialog:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::oWidget:setAttribute( Qt_WA_DeleteOnClose, .f. ) + IF empty( SetAppWindow() ) + SetAppWindow( Self ) + ENDIF + RETURN Self /*----------------------------------------------------------------------*/ @@ -332,14 +340,33 @@ METHOD XbpDialog:minSize( aSize ) /*----------------------------------------------------------------------*/ METHOD XbpDialog:showModal() + LOCAL nEvent, mp1, mp2, oXbp ::hide() - ::oWidget:setWindowModality( 2 ) + ::oWidget:setWindowModality( XBP_DISP_APPMODAL ) ::show() ::is_hidden := .f. ::lHasInputFocus := .t. + ::l_modalState := .t. - RETURN .t. + nEvent := 0 + DO WHILE nEvent != xbeP_Close + nEvent := AppEvent( @mp1, @mp2, @oXbp ) + IF ::modalResult != XBP_MRESULT_NONE + EXIT + ENDIF + oXbp:handleEvent( nEvent, mp1, mp2 ) + ENDDO + IF nEvent == xbeP_Close + ::modalResult := XBP_MRESULT_CANCEL + ENDIF + + ::l_modalState := .f. + ::hide() + ::oWidget:setWindowModality( XBP_DISP_MODELESS ) + ::show() + + RETURN ::modalResult /*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbxbp/xbppushbutton.prg b/harbour/contrib/hbxbp/xbppushbutton.prg index 10576ef21b..aa132f8ec0 100644 --- a/harbour/contrib/hbxbp/xbppushbutton.prg +++ b/harbour/contrib/hbxbp/xbppushbutton.prg @@ -145,10 +145,22 @@ METHOD XbpPushButton:execSlot( cSlot, p ) DO CASE CASE cSlot == "clicked()" ::activate() + IF ::oParent:className() == "XBPDRAWINGAREA" + IF ::oParent:oParent:l_modalState + IF ::default + ::oParent:oParent:setModalResult( XBP_MRESULT_OK ) + ENDIF + IF ::cancel + ::oParent:oParent:setModalResult( XBP_MRESULT_CANCEL ) + ENDIF + ENDIF + ENDIF + CASE cSlot == "QEvent_KeyPress" IF hbxbp_QKeyEventToAppEvent( p ) == xbeK_ENTER ::oWidget:click() ENDIF + ENDCASE RETURN nil