#include "FiveWin.ch"
REQUEST DBFCDX
REQUEST DBFFPT
memvar oApp
FUNCTION Main()
PUBLIC oApp
RddSetDefault( "DBFCDX" )
SetHandleCount( 100 )
SET DATE FORMAT "dd-mm-yyyy"
SET DELETED ON
SET CENTURY ON
SET EPOCH TO year( date() ) - 20
SET MULTIPLE OFF
WITH OBJECT oApp := TApplication():New()
:Activate()
END
RETURN nil
CLASS tApplication
data cAppName
data cVersion
data cEdicion
data cBuild
data cUrl
data cMsgBar
DATA cIniFile
DATA cZipPath
DATA oWndMain
DATA oFont
DATA oBar
DATA oExit
DATA oIcon
DATA oMsgItem1
DATA oMsgItem2
DATA oMsgItem3
DATA oDlg
DATA oGrid
DATA oTab
DATA oSplit
DATA nEdit
DATA nLanguage
DATA aStrings
DATA aMissing
METHOD New() CONSTRUCTOR
METHOD Activate()
METHOD BuildMenu()
METHOD BuildBtnBar()
METHOD Close()
METHOD End() INLINE ( /*SetWinCoors( ::oWndMain, ::cIniFile ),*/ ::oWndMain:End() )
METHOD ExitFromX()
METHOD ExitFromBtn()
METHOD ExitFromSource()
METHOD LanguageID()
METHOD LoadPreferences()
METHOD SavePreferences()
METHOD FWSetLanguage( nNewLanguage )
METHOD FWAddLanguage( aLang, nLang )
METHOD FWString( cString )
METHOD FWMissingStrings()
METHOD FWLoadStrings( cFileName )
METHOD FWAddString()
ENDCLASS
/*_____________________________________________________________________________*/
METHOD New() CLASS tApplication
::cAppName := i18n("Fsdi 2013")
::cVersion := "1.00 RC-1"
::cBuild := "build 08.10.13"
::cUrl := "http://www.eoeo.it"
::cMsgBar := "© eoeo software"
::cIniFile := cFilePath( GetModuleFileName( GetInstance() ) ) + "fsdi.ini"
::nLanguage := 2 // Spanish. By default it is 1 English
::aMissing := {}
::oFont = TFont():New( GetDefaultFontName(), 0, GetDefaultFontHeight(),, )
::aMissing := {}
::astrings:=::FWLoadStrings("lang.lng")
::FWSetLanguage( ::nLanguage) // Spanish. By default it is 1 English
::LoadPreferences()
? ::LanguageID()
DEFINE WINDOW ::oWndMain ;
TITLE ::cAppName + ::cVersion ;
MENU ::BuildMenu() ;
COLOR CLR_BLACK, GetSysColor( 15 ) - Rgb( 30, 30, 30 ) ;
ICON ::oIcon
SET MESSAGE OF ::oWndMain TO ::cMsgBar CENTER NOINSET
DEFINE MSGITEM ::oMsgItem2;
OF ::oWndMain:oMsgBar ;
PROMPT ::cMsgBar ;
SIZE 100 ;
BITMAPS "MSG_LOTUS", "MSG_LOTUS";
TOOLTIP " " + i18n("Acerca de...") + " ";
ACTION MsgInfo( "Test with strings" )
DEFINE MSGITEM ::oMsgItem3 OF ::oWndMain:oMsgBar ;
SIZE 132 ;
TOOLTIP i18n( "Visitare il sito web di eoeo in internet" ) ;
PROMPT "www.eoeo.it" ;
COLOR CLR_HBLUE, GetSysColor(15) ;
ACTION NIL
::oWndMain:oMsgBar:DateOn()
::BuildBtnBar()
RETURN Self
/*_____________________________________________________________________________*/
method Activate() class TApplication
//GetWinCoors( ::oWndMain, ::cInifile )
::oWndMain:bResized := {|| ResizeWndMain() }
ACTIVATE WINDOW ::oWndMain ;
VALID ::ExitFromX()
::oFont:End()
return NIL
/*_____________________________________________________________________________*/
METHOD BuildMenu() CLASS TApplication
local oMenu
MENU oMenu 2010
* MENUITEM "&Archivo"
MENUITEM ::FWSTRING("&Archivo")
MENU
MENUITEM i18n( "Especificar impresora" ) ;
ACTION PrinterSetup() ;
MESSAGE i18n( " Establecer la Configuración de su impresora. " )
SEPARATOR
MENUITEM i18n( "Configuración" ) ;
ACTION Preferences() ;
MESSAGE i18n( " Establecer la Configuración de su impresora. " )
SEPARATOR
MENUITEM i18n( "Salir" ) ;
ACTION ::ExitFromBtn() ;
MESSAGE i18n( " Terminar la ejecución del programa. " )
ENDMENU
ENDMENU
RETURN oMenu
/*_____________________________________________________________________________*/
METHOD BuildBtnBar() CLASS TApplication
local oBtnTbl
DEFINE BUTTONBAR ::oBar _3D SIZE 44, 46 OF ::oWndMain //36, 40
::oBar:bRClicked := { || .t. }
DEFINE BUTTON OF ::oBar ;
RESOURCE "BB1" ;
TOOLTIP i18n( "Gestión de documentos" ) ;
MESSAGE i18n( "Gestión de del fichero de documentos." ) ;
NOBORDER
DEFINE BUTTON OF ::oBar ;
RESOURCE "BB1" ;
TOOLTIP i18n( "Gestión de documentos" ) ;
MESSAGE i18n( "Gestión de del fichero de documentos." ) ;
NOBORDER
DEFINE BUTTON ::oExit OF ::oBar ;
RESOURCE "BB2" ;
TOOLTIP i18n( "Salir del programa" ) ;
MESSAGE i18n( "Finalizar el uso del programa." ) ;
ACTION ( ::ExitFromBtn() ) ;
GROUP NOBORDER
RETURN Self
/*_____________________________________________________________________________*/
METHOD Close() CLASS TApplication
ResAllFree()
RETURN nil
/*_____________________________________________________________________________*/
METHOD ExitFromBtn() CLASS tApplication
::oWndMain:End()
RETURN nil
/*_____________________________________________________________________________*/
METHOD ExitFromX() CLASS tApplication
if oApp:oDlg != nil
if oApp:nEdit > 0
msgStop( i18n("No puede salir del programa hasta que no cierre las ventanas abiertas sobre el mantenimiento que está manejando.") )
RETURN .f.
end
end
if msgYesNo( i18n("¿Desea finalizar el programa?") )
if oApp:oDlg != nil
oApp:oDlg:End()
endif
// SetWinCoors( ::oWndMain, ::cIniFile )
RETURN .t.
end
RETURN .F.
/*_____________________________________________________________________________*/
METHOD ExitFromSource() CLASS tApplication
::oWndMain:bValid := { ||::FWMissingStrings() /*SetWinCoors( ::oWndMain, ::cIniFile )*/, .t. }
::oWndMain:End()
RETURN nil
//----------------------------------------------------------------------------//
METHOD LanguageID() CLASS tApplication
if Empty( ::nLanguage )
::nLanguage = Max( 1, AScan( { "EN", "ES", "FR", "PT", "DE", "IT" },;
Upper( Left( HB_LangSelect(), 2 ) ) ) )
endif
return ::nLanguage
//----------------------------------------------------------------------------//
METHOD LoadPreferences() CLASS tApplication
::nLanguage := GetIni( ::cIniFile, "Default", "Language", ::FWSetLanguage() )
::FWSetLanguage( ::nLanguage )
return nil
//----------------------------------------------------------------------------//
METHOD SavePreferences() CLASS tApplication
::nLanguage := ::FWSetLanguage()
SetIni( ::cIniFile, "Default", "Language",::nLanguage )
return nil
//----------------------------------------------------------------------------//
METHOD FWSetLanguage( nNewLanguage ) CLASS tApplication
local nOldLanguage := ::LanguageID()
if ! Empty( nNewLanguage )
::nLanguage := Max( 1, Min( nNewLanguage, Len( ::aStrings[ 1 ] ) ) )
endif
return nOldLanguage
//----------------------------------------------------------------------------//
METHOD FWAddLanguage( aLang, nLang ) CLASS tApplication
if ValType( aLang ) == 'A' .and. ! Empty( aLang )
::aStrings := ArrTranspose( ::aStrings )
if nLang == nil .or. nLang > Len( ::aStrings )
AAdd( ::aStrings, aLang )
nLang := Len( ::aStrings )
else
::aStrings[ nLang ] := aLang
endif
::aStrings := ArrTranspose( ::aStrings )
::FWSetLanguage( nLang )
endif
return nLang
//----------------------------------------------------------------------------//
METHOD FWString( cString ) CLASS tApplication
local nAt
if ::LanguageID() == 1
return cString
elseif ( nAt := AScan( ::aStrings, { | aString | Upper( aString[ 1 ] ) == Upper( cString ) } ) ) != 0
return IfNil( ::aStrings[ nAt ][ ::LanguageID() ], cString )
else
if '&' $ cString
cString := StrTran( cString, '&', '' )
if ( nAt := AScan( ::aStrings, { | aString | Upper( aString[ 1 ] ) == Upper( cString ) } ) ) != 0
return '&' + IfNil( ::aStrings[ nAt ][::LanguageID() ], cString )
endif
endif
MsgInfo( 'La stringa: "' + cString + '"' + CRLF + ;
"definita in: " + ProcName( 1 ) + " linea " + ;
AllTrim( Str( ProcLine( 1 ) ) ) + " in " + ProcFile( 1 ) + CRLF + ;
"non è stata trovata in archivio lingue" + CRLF + ;
" " )
AAdd( ::aMissing, cString )
endif
return cString
//----------------------------------------------------------------------------//
METHOD FWMissingStrings() CLASS tApplication
local cResult := ""
AEval( ::aMissing, { | cString | cResult += Space( 7 ) + '{ "' + cString + ;
'", "" },;' + CRLF } )
if ! Empty( cResult )
MemoEdit( cResult, "Copy and paste in FWH\source\function\strings.prg" )
endif
return cResult
//----------------------------------------------------------------------------//
/*
METHOD FWLoadStrings( cFileName ) CLASS tApplication
local cLine :="", n := 1
local aStrings := {}
DEFAULT cFileName := cFilePath( GetModuleFileName( GetInstance() ) ) + ;
"fwstrings.ini"
while ! Empty( cLine := GetProfString( cFileName, "LANG", AllTrim( Str( n++, 4 ) ) ) )
AAdd( ::aStrings, { AllTrim( StrToken( cLine, 1, "|" ) ),;
AllTrim( StrToken( cLine, 2, "|" ) ),;
AllTrim( StrToken( cLine, 3, "|" ) ),;
AllTrim( StrToken( cLine, 4, "|" ) ),;
AllTrim( StrToken( cLine, 5, "|" ) ),;
AllTrim( StrToken( cLine, 6, "|" ) ) } )
end
return aStrings
*/
METHOD FWLoadStrings( cFileName ) CLASS tApplication
Local cInistrings:=cFilePath(GetModuleFileName( GetInstance() ) ) + "lang.lng"
LOCAL cString :=""
LOCAL i := 1
LOCAL lContinue := .T.
Local aTranslates := {}
DO WHILE lContinue = .T.
cString := GetIni( cInistrings, "LANG", ALLTRIM(STR(i++,4)), "" )
IF .NOT. EMPTY( cString )
AADD( aTranslates, { ALLTRIM( StrToken( cString, 1, "|" ) ), ;
ALLTRIM( StrToken( cString, 2, "|" ) ), ;
ALLTRIM( StrToken( cString, 3, "|" ) ), ;
ALLTRIM( StrToken( cString, 4, "|" ) ), ;
ALLTRIM( StrToken( cString, 5, "|" ) ), ;
ALLTRIM( StrToken( cString, 6, "|" ) ) } )
ELSE
lContinue := .F.
ENDIF
ENDDO
IF LEN( aTranslates ) = 0
MsgStop( "Nessuna lingua definita in " + ALLTRIM( cInistrings ) )
RETURN(.F.)
ELSE
//only for trace
// xbrowser aTranslates
ENDIF
RETURN aTranslates
//----------------------------------------------------------------------------//
METHOD FWAddString() CLASS tApplication
return AAdd( ::aStrings, aString )
//----------------------------------------------------------------------------//
FUNCTION oApp()
Return oApp
FUNCTION FWString(cMessage)
Return oApp():FWString(cMessage)
Function ResizeWndMain()
return NIL
function Preferences()
local oDlg
DEFINE DIALOG oDlg TITLE FWString( "Preferences" ) SIZE 400, 300
@ 4.6, 1.5 SAY FWString( "Language" ) OF oDlg
DEFAULT oApp:nLanguage := ::FWSetLanguage()
@ 6, 1.2 COMBOBOX oApp:nLanguage ;
ITEMS { FWString( "English" ), FWString( "Spanish" ), FWString( "French" ),;
FWString( "Portuguese" ), FWString( "German" ) , FWString( "Italian" ) } ;
OF oDlg SIZE 180, 150 ;
ON CHANGE ( oApp:FWSetLanguage( oApp:nLanguage ), oApp:oWndMain:SetMenu( oApp:BuildMenu() ),;
oApp:BuildBtnBar() )
@ 7, 7 BUTTON FWString( "&Ok" ) OF oDlg SIZE 45, 13 ;
ACTION (oApp:SavePreferences(), oDlg:End() )
@ 7, 18 BUTTON FWString( "&Cancel" ) OF oDlg SIZE 45, 13 ACTION oDlg:End()
ACTIVATE DIALOG oDlg CENTERED
return nil
FUNCTION SetIni( cIni, cSection, cEntry, xVar )
LOCAL oIni
DEFAULT cIni := oApp:cIniFile
INI oIni FILE cIni
SET SECTION cSection ;
ENTRY cEntry ;
TO xVar ;
OF oIni
ENDINI
RETURN nil
/*_____________________________________________________________________________*/
FUNCTION GetIni( cIni, cSection, cEntry, xDefault )
LOCAL oIni
LOCAL xVar := xDefault
DEFAULT cIni := oApp:cIniFile
INI oIni FILE cIni
GET xVar ;
SECTION cSection ;
ENTRY cEntry ;
DEFAULT xDefault ;
OF oIni
ENDINI
RETURN xVar
/*_____________________________________________________________________________*/
//___ manejo de fuentes © Paco García 2006 ____________________________________//
#pragma BEGINDUMP
#include "Windows.h"
#include "hbapi.h"
HB_FUNC( GETDEFAULTFONTNAME )
{
LOGFONT lf;
GetObject( ( HFONT ) GetStockObject( DEFAULT_GUI_FONT ) , sizeof( LOGFONT ), &lf );
hb_retc( lf.lfFaceName );
}
HB_FUNC( GETDEFAULTFONTHEIGHT )
{
LOGFONT lf;
GetObject( ( HFONT ) GetStockObject( DEFAULT_GUI_FONT ) , sizeof( LOGFONT ), &lf );
hb_retni( lf.lfHeight );
}
#pragma ENDDUMP
//_____________________________________________________________________________//