Files
harbour-core/harbour/source/rtl/alert.prg
Viktor Szakats 339c86f1bc 2009-05-12 16:10 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
* utils/hbmk2/hbmk2.prg
    + Added -hbrun option which will run the target without trying to
      build it. If target is missing, the command will fail.
    + -run/-hbrun options will now run GUI target executable using 'start'
      command on Windows platforms so that hbmk2 will return and leave
      the app running.

  * include/hbextern.ch
    + Added HB_GZPUTC().

  * include/hbsetup.ch
    - Removed HB_EXTENSION from documented list of build modified macros.

  * source/common/hbverdsp.c
    - Deleted HB_EXTENSION dependent part.

  * source/rtl/mlcfunc.c
    - Deleted HB_EXTENSION branch. Please modify your program to
      use Set( _SET_EOL ) instead of passing EOLs explicitly to
      memo functions. This works also in xhb.
      INCOMPATIBLE when for HB_EXTENSION builds.

  * source/rtl/alert.prg
    ! Minor in comment.

  * source/rtl/saverest.c
    - Removed SAVESCREEN()/RESTSCREEN() extra "lNoCheck" parameter
      when HB_EXTENSION is enabled. Please report on the list
      if you need this functionality.

  * source/compiler/hbfunchk.c
    ! Fix to prev: AT() declaration.

  ; TODO: Clean rest of HB_EXTENSION stuff.
2009-05-12 14:11:21 +00:00

176 lines
4.3 KiB
Plaintext

/*
* $Id$
*/
/*
* Harbour Project source code:
* ALERT(), HB_ALERT() functions
*
* Released to Public Domain by Vladimir Kazimirchik <v_kazimirchik@yahoo.com>
* www - http://www.harbour-project.org
*
*/
/*
* The following parts are Copyright of the individual authors.
* www - http://www.harbour-project.org
*
* Copyright 1999-2001 Viktor Szakats <viktor.szakats@syenar.hu>
* Changes for higher Clipper compatibility, console mode, extensions
* __NONOALERT()
*
* See COPYING for licensing terms.
*
*/
#include "box.ch"
#include "common.ch"
#include "inkey.ch"
#include "setcurs.ch"
#include "hbgtinfo.ch"
/* TOFIX: Clipper defines a clipped window for Alert() [vszakats] */
/* NOTE: Clipper will return NIL if the first parameter is not a string, but
this is not documented. [vszakats] */
/* NOTE: Clipper handles these buttons { "Ok", "", "Cancel" } in a buggy way.
This is fixed. [vszakats] */
#ifdef HB_C52_UNDOC
STATIC s_lNoAlert
#endif
FUNCTION Alert( cMessage, aOptions, cColorNorm )
LOCAL cColorHigh
LOCAL aOptionsOK
LOCAL nEval
#ifdef HB_C52_UNDOC
DEFAULT s_lNoAlert TO hb_argCheck( "NOALERT" )
IF s_lNoAlert
RETURN NIL
ENDIF
#endif
IF ! ISCHARACTER( cMessage )
RETURN NIL
ENDIF
cMessage := StrTran( cMessage, ";", Chr( 10 ) )
IF ! ISARRAY( aOptions )
aOptions := {}
ENDIF
IF ! ISCHARACTER( cColorNorm ) .OR. Empty( cColorNorm )
cColorNorm := "W+/R" // first pair color (Box line and Text)
cColorHigh := "W+/B" // second pair color (Options buttons)
ELSE
cColorHigh := StrTran( StrTran( iif( At( "/", cColorNorm ) == 0, "N", SubStr( cColorNorm, At( "/", cColorNorm ) + 1 ) ) + "/" +;
iif( At( "/", cColorNorm ) == 0, cColorNorm, Left( cColorNorm, At( "/", cColorNorm ) - 1 ) ), "+", "" ), "*", "" )
ENDIF
aOptionsOK := {}
FOR nEval := 1 TO Len( aOptions )
IF ISCHARACTER( aOptions[ nEval ] ) .AND. ! Empty( aOptions[ nEval ] )
AAdd( aOptionsOK, aOptions[ nEval ] )
ENDIF
NEXT
IF Len( aOptionsOK ) == 0
aOptionsOK := { "Ok" }
#ifdef HB_C52_STRICT
/* NOTE: Clipper allows only four options [vszakats] */
ELSEIF Len( aOptionsOK ) > 4
ASize( aOptionsOK, 4 )
#endif
ENDIF
RETURN hb_gtAlert( cMessage, aOptionsOK, cColorNorm, cColorHigh )
/* NOTE: xMessage can be of any type. This is a Harbour extension over Alert(). */
/* NOTE: nDelay parameter is a Harbour extension over Alert(). */
FUNCTION hb_Alert( xMessage, aOptions, cColorNorm, nDelay )
LOCAL cMessage
LOCAL cColorHigh
LOCAL aOptionsOK
LOCAL nEval
LOCAL lFirst
LOCAL cLine
#ifdef HB_C52_UNDOC
DEFAULT s_lNoAlert TO hb_argCheck( "NOALERT" )
IF s_lNoAlert
RETURN NIL
ENDIF
#endif
IF PCount() == 0
RETURN NIL
ENDIF
IF ISARRAY( xMessage )
cMessage := ""
lFirst := .T.
FOR nEval := 1 TO Len( xMessage )
IF ISCHARACTER( cLine := xMessage[ nEval ] )
cMessage += iif( lFirst, "", Chr( 10 ) ) + cLine
lFirst := .F.
ENDIF
NEXT
ELSEIF ISCHARACTER( xMessage )
cMessage := StrTran( xMessage, ";", Chr( 10 ) )
ELSE
cMessage := hb_CStr( xMessage )
ENDIF
IF ! ISARRAY( aOptions )
aOptions := {}
ENDIF
IF !ISCHARACTER( cColorNorm ) .OR. Empty( cColorNorm )
cColorNorm := "W+/R" // first pair color (Box line and Text)
cColorHigh := "W+/B" // second pair color (Options buttons)
ELSE
cColorHigh := StrTran( StrTran( iif( At( "/", cColorNorm ) == 0, "N", SubStr( cColorNorm, At( "/", cColorNorm ) + 1 ) ) + "/" +;
iif( At( "/", cColorNorm ) == 0, cColorNorm, Left( cColorNorm, At( "/", cColorNorm ) - 1 ) ), "+", "" ), "*", "" )
ENDIF
aOptionsOK := {}
FOR nEval := 1 TO Len( aOptions )
IF ISCHARACTER( aOptions[ nEval ] ) .AND. ! Empty( aOptions[ nEval ] )
AAdd( aOptionsOK, aOptions[ nEval ] )
ENDIF
NEXT
IF Len( aOptionsOK ) == 0
aOptionsOK := { "Ok" }
#ifdef HB_C52_STRICT
/* NOTE: Clipper allows only four options [vszakats] */
ELSEIF Len( aOptionsOK ) > 4
ASize( aOptionsOK, 4 )
#endif
ENDIF
RETURN hb_gtAlert( cMessage, aOptionsOK, cColorNorm, cColorHigh, nDelay )
#ifdef HB_C52_UNDOC
PROCEDURE __NONOALERT()
s_lNoAlert := .F.
RETURN
#endif