/* * Proyecto: LLDominus * Fichero: TFormLLDominusAskString.prg * Descripcion: dialogo moderno para resolver variables AskString(). */ #include "Xailer.ch" CLASS TFormLLDominusAskString FROM TForm COMPONENT oIconBack COMPONENT oIconFront COMPONENT oLabelTitulo COMPONENT oLabelSubtitulo COMPONENT oHeaderSeparator COMPONENT oInputPanel COMPONENT oLabelPrompt COMPONENT oEditValue COMPONENT oLabelLimit COMPONENT oButtonAccept COMPONENT oButtonCancel DATA cValue INIT "" DATA lAccepted INIT .F. DATA nMaxLength INIT 0 METHOD CreateForm( lCreate ) METHOD Execute( hDefinition, nIndex, nTotal ) METHOD AcceptValue() METHOD CancelValue() METHOD DisplayText( uValue ) ENDCLASS //------------------------------------------------------------------------------ METHOD CreateForm( lCreate ) CLASS TFormLLDominusAskString DEFAULT lCreate TO .T. IF HB_ISOBJECT( ::oEditValue ) RETURN Self ENDIF IF lCreate ::SetBounds( 310, 269, 604, 330 ) ::SetClientSize( 596, 296 ) ::cText := "LL-Dominus" ::oFont := TFont():Create( "Segoe UI", 10, 0, 400 ) ::nClrPane := clWhite ::lCentered := .T. ::nBorderStyle := bsDIALOG ::lSysMenu := .F. ::lCloseBox := .F. ::lMinimizeBox := .F. ::lMaximizeBox := .F. ::Create() ENDIF ::Super:CreateForm( .F. ) WITH OBJECT ::oIconBack := TBevel():New( Self ) :SetBounds( 38, 26, 35, 43 ) :nClrPane := RGB( 229, 237, 248 ) :nBorderStyle := bvWIN10 :nPenColor := RGB( 161, 180, 205 ) :nPenSize := 1 :Create() END WITH OBJECT ::oIconFront := TBevel():New( Self ) :SetBounds( 45, 20, 35, 43 ) :nClrPane := clWhite :nBorderStyle := bvWIN10 :nPenColor := RGB( 52, 64, 84 ) :nPenSize := 1 :Create() END WITH OBJECT ::oLabelTitulo := TLabel():New( Self ) :SetBounds( 104, 23, 454, 28 ) :cText := "Datos del informe" :oFont := TFont():Create( "Segoe UI", 15, 0, 600 ) :nClrText := RGB( 34, 43, 56 ) :lAutoSize := .F. :Create() END WITH OBJECT ::oLabelSubtitulo := TLabel():New( Self ) :SetBounds( 104, 54, 454, 20 ) :cText := "Complete el valor solicitado por la plantilla" :oFont := TFont():Create( "Segoe UI", 9, 0, 400 ) :nClrText := RGB( 112, 122, 137 ) :lAutoSize := .F. :Create() END WITH OBJECT ::oHeaderSeparator := TBevel():New( Self ) :SetBounds( 34, 91, 528, 1 ) :nClrPane := RGB( 224, 229, 235 ) :nBorderStyle := bvNONE :Create() END WITH OBJECT ::oInputPanel := TBevel():New( Self ) :SetBounds( 34, 111, 528, 104 ) :nClrPane := RGB( 247, 249, 251 ) :nBorderStyle := bvNONE :Create() END WITH OBJECT ::oLabelPrompt := TLabel():New( ::oInputPanel ) :SetBounds( 16, 14, 496, 22 ) :cText := "Valor" :oFont := TFont():Create( "Segoe UI", 10, 0, 500 ) :nClrText := RGB( 52, 64, 84 ) :lAutoSize := .F. :Create() END WITH OBJECT ::oEditValue := TEditMod():New( ::oInputPanel ) :SetBounds( 16, 42, 496, 32 ) :nMaxLength := 32767 :nClrPane := clWhite :oFont := TFont():Create( "Segoe UI", 11, 0, 400 ) :cText := "" :Create() END WITH OBJECT ::oLabelLimit := TLabel():New( ::oInputPanel ) :SetBounds( 16, 79, 496, 18 ) :cText := "" :oFont := TFont():Create( "Segoe UI", 8, 0, 400 ) :nClrText := RGB( 112, 122, 137 ) :lAutoSize := .F. :Create() END WITH OBJECT ::oButtonCancel := TButtonMod():New( Self ) :SetBounds( 292, 235, 126, 36 ) :cText := "Cancelar" :oFont := TFont():Create( "Segoe UI", 10, 0, 500 ) :nClrPane := RGB( 241, 244, 247 ) :nClrText := RGB( 52, 64, 84 ) :nClrBorder := RGB( 194, 202, 212 ) :nBorderRadius := 4 :lFlat := .F. :lCancel := .T. :OnClick := {|| ::CancelValue(), .F. } :Create() END WITH OBJECT ::oButtonAccept := TButtonMod():New( Self ) :SetBounds( 436, 235, 126, 36 ) :cText := "Aceptar" :oFont := TFont():Create( "Segoe UI", 10, 0, 500 ) :nClrPane := RGB( 52, 64, 84 ) :nClrText := clWhite :nClrBorder := RGB( 52, 64, 84 ) :nBorderRadius := 4 :lFlat := .F. :lDefault := .T. :OnClick := {|| ::AcceptValue(), .F. } :Create() END RETURN Self //------------------------------------------------------------------------------ METHOD Execute( hDefinition, nIndex, nTotal ) CLASS TFormLLDominusAskString LOCAL cPrompt := "Valor solicitado" LOCAL cDefault := "" DEFAULT nIndex TO 1 DEFAULT nTotal TO 1 IF HB_ISHASH( hDefinition ) cPrompt := ::DisplayText( iif( hb_HHasKey( hDefinition, "cPrompt" ), hDefinition[ "cPrompt" ], cPrompt ) ) cDefault := ::DisplayText( iif( hb_HHasKey( hDefinition, "cDefault" ), hDefinition[ "cDefault" ], "" ) ) ::nMaxLength := iif( hb_HHasKey( hDefinition, "nMaxLength" ) .AND. HB_ISNUMERIC( hDefinition[ "nMaxLength" ] ), Max( 0, Int( hDefinition[ "nMaxLength" ] ) ), 0 ) ENDIF ::lAccepted := .F. ::cValue := cDefault ::oLabelPrompt:cText := cPrompt ::oLabelSubtitulo:cText := "Dato " + LTrim( Str( nIndex ) ) + " de " + LTrim( Str( Max( 1, nTotal ) ) ) + " solicitado por la plantilla" ::oEditValue:nMaxLength := iif( ::nMaxLength > 0, ::nMaxLength, 32767 ) ::oEditValue:cText := iif( ::nMaxLength > 0, Left( cDefault, ::nMaxLength ), cDefault ) ::oLabelLimit:cText := iif( ::nMaxLength > 0, "Longitud maxima: " + LTrim( Str( ::nMaxLength ) ) + " caracteres", "" ) ::oEditValue:SetFocus() ::ShowModal() RETURN { "lAccepted" => ::lAccepted, "cValue" => ::cValue } //------------------------------------------------------------------------------ METHOD AcceptValue() CLASS TFormLLDominusAskString ::cValue := ::oEditValue:cText IF ::nMaxLength > 0 ::cValue := Left( ::cValue, ::nMaxLength ) ENDIF ::lAccepted := .T. ::Close( .T. ) RETURN NIL //------------------------------------------------------------------------------ METHOD CancelValue() CLASS TFormLLDominusAskString ::lAccepted := .F. ::cValue := "" ::Close( .T. ) RETURN NIL //------------------------------------------------------------------------------ METHOD DisplayText( uValue ) CLASS TFormLLDominusAskString LOCAL cText := iif( HB_ISSTRING( uValue ), uValue, hb_ValToStr( uValue ) ) IF hb_StrIsUTF8( cText ) RETURN hb_UTF8ToStr( cText, "ESWIN" ) ENDIF RETURN cText