winmain.c File Reference

#include "winmain.h"
#include "WinConsole.h"
#include "wtext.h"
#include "Messages.h"
#include "Warnings.h"
#include "Errors.h"
#include "GraphWindows.h"
#include "MenuWindows.h"
#include "win_mem_alloc.h"

Include dependency graph for winmain.c:

Go to the source code of this file.

Defines

#define stricmp   _stricmp
#define strnicmp   _strnicmp

Functions

void PrintFile (char *filename)
void ChangeCursorWhenScilabIsReady (void)
TW InitTWStruct (void)
void CreateSplashscreen (void)
void settexmacs (void)
void MessageBoxNewGraphicMode (void)
int ExitScilab (void)
void SetWITH_GUI (BOOL ON)
BOOL GetWITH_GUI (void)
void disp_scilab_version (void)
int Console_Main (int argc, char **argv)
int WINAPI Windows_Main (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
void InitWindowGraphDll (void)
void add_sci_argv (char *p)
int sci_iargc ()
int sci_getarg (int *n, char *s, long int ls)
int InteractiveMode ()
int C2F() showlogo ()
void Kill_Scilex (void)
BOOL ForbiddenToUseScilab (void)
int IsNoInteractiveWindow (void)
char * stristr (const char *psz, const char *tofind)

Variables

BOOL ScilabIsStarting = TRUE
int sci_show_banner = 1
static LPSTR my_argv [MAXCMDTOKENS]


Define Documentation

#define stricmp   _stricmp

Definition at line 44 of file winmain.c.

#define strnicmp   _strnicmp

Definition at line 45 of file winmain.c.

Referenced by stristr().


Function Documentation

void add_sci_argv ( char *  p  ) 

Definition at line 537 of file winmain.c.

References my_argc, and my_argv.

Referenced by Initialize().

00538 {
00539         if (*p) my_argv[++my_argc]=p;
00540 }

Here is the caller graph for this function:

void ChangeCursorWhenScilabIsReady ( void   ) 

Definition at line 110 of file x_zzledt.c.

References C2F, tagTW::CharSize, tagTW::ClientSize, EnableNMenus(), EnableToolBar(), FALSE, GetTextWinScilab(), tagTW::hInstance, tagTW::hWndParent, tagTW::hWndText, InvalidateCursor(), IsWindowInterface(), nc, nl, NULL, ScilabIsStarting, scilines(), and SetFocus().

Referenced by Windows_Main(), and zzledt().

00111 {
00112   if ( (IsWindowInterface()) && (ScilabIsStarting) )
00113   {
00114         HCURSOR hCursor;
00115         LPTW lptw=GetTextWinScilab();
00116         int NumsMenu = 0;
00117         int nl=0, nc=0;
00118         HMENU hMenu=NULL;
00119                 
00120         hCursor=LoadCursor(  lptw->hInstance,IDC_ARROW);
00121         SetClassLong(lptw->hWndParent, GCL_HCURSOR,     (LONG) hCursor); 
00122         SetClassLong(lptw->hWndText,GCL_HCURSOR,(LONG) hCursor); 
00123         InvalidateCursor(); 
00124         hMenu=GetMenu(lptw->hWndParent);
00125         NumsMenu=GetMenuItemCount (hMenu);
00126         EnableNMenus(lptw,NumsMenu);
00127         EnableToolBar(lptw);
00128 
00129         ScilabIsStarting=FALSE;
00130 
00131         ShowWindow (lptw->hWndParent,SW_SHOWDEFAULT);
00132         BringWindowToTop (lptw->hWndParent);
00133         SetFocus(lptw->hWndParent);
00134         SetFocus(lptw->hWndText);
00135         
00136         /* Initialize 'lines' */
00137         nc = lptw->ClientSize.x / lptw->CharSize.x;
00138         nl = lptw->ClientSize.y / lptw->CharSize.y;
00140         if ((lptw->ClientSize.x>0) && (lptw->ClientSize.y>0))   C2F (scilines) (&nl, &nc);
00141 
00142   }
00143 }

Here is the call graph for this function:

Here is the caller graph for this function:

int Console_Main ( int  argc,
char **  argv 
)

Definition at line 63 of file winmain.c.

References tagTW::CursorFlag, disp_scilab_version(), ExitScilab(), FALSE, ForbiddenToUseScilab(), FREE, GetScilabDirectory(), GetszGraphMenuName(), GetszMenuName(), graphwin, hdllInstance, tagTW::hInstance, tagGW::hInstance, tagTW::hPrevInstance, tagGW::hPrevInstance, i, InitGWStruct(), InitMWStruct(), InitszGraphMenuName(), InitTWStruct(), tagTW::KeyBufSize, tagTW::lpmw, tagGW::lptw, Max, memory, menuwin, MIN_STACKSIZE, MSG_ERROR20, MSG_ERROR38, MSG_ERROR79, MSG_SCIMSG122, MSG_SCIMSG123, MSG_SCIMSG124, MSG_SCIMSG125, MSG_SCIMSG126, MSG_SCIMSG127, MSG_SCIMSG128, MSG_SCIMSG129, MSG_SCIMSG130, MSG_SCIMSG131, MSG_SCIMSG132, MSG_SCIMSG133, MSG_SCIMSG134, MSG_SCIMSG135, MSG_SCIMSG21, MSG_SCIMSG23, MSG_SCIMSG24B, MSG_SCIMSG9, my_argc, my_argv, tagTW::nCmdShow, nointeractive, NULL, path, RenameConsole(), SaveConsoleColors(), sci_show_banner, sci_windows_main(), ScilabIsStarting, tagTW::ScreenSize, settexmacs(), SetWindowMode(), SetWITH_GUI(), startupf, stricmp, tagMW::szMenuName, tagGW::szMenuName, textwin, tagTW::Title, tagGW::Title, TRUE, and UpdateConsoleColors().

Referenced by main().

00064 {
00065   int nowin = 0, argcount = 0, lpath = 0, pathtype=0;
00066   char *path = NULL;
00067   char *ScilabDirectory=NULL;
00068   int i=0;
00069 
00070   my_argc = -1;
00071 
00072   ForbiddenToUseScilab();
00073 
00074   SetWindowMode(FALSE);
00075   ScilabIsStarting=TRUE;
00076   
00077   for (i=0;i<argc;i++)
00078   {
00079           my_argv[i] = argv[i];
00080   }
00081   my_argc =argc;
00082 
00083   ScilabDirectory=GetScilabDirectory(FALSE);
00084 
00085   if (ScilabDirectory == NULL)
00086   {
00087         MessageBox (NULL, MSG_ERROR20 ,MSG_ERROR38, MB_ICONSTOP | MB_OK);
00088         exit(1);
00089   }
00090 
00091   InitszGraphMenuName(ScilabDirectory);
00092  
00093   if (ScilabDirectory){FREE(ScilabDirectory);ScilabDirectory=NULL;}
00094 
00095   /* Load common control library * */
00096   InitCommonControls ();
00097 
00098   textwin=InitTWStruct();
00099 
00100   textwin.hInstance = GetModuleHandle(MSG_SCIMSG9);
00101   textwin.hPrevInstance = 0;
00102   textwin.nCmdShow = 1;
00103   textwin.Title = MSG_SCIMSG21;
00104   textwin.lpmw = &menuwin;
00105   textwin.ScreenSize.x = 120;
00106   textwin.ScreenSize.y = 80;
00107   textwin.KeyBufSize = 2048;
00108   textwin.CursorFlag = 1;       /* scroll to cursor after \n & \r */
00109  
00110   menuwin=InitMWStruct();
00111   menuwin.szMenuName = GetszMenuName();
00112 
00113   graphwin=InitGWStruct();  
00114   graphwin.hInstance = GetModuleHandle(MSG_SCIMSG9);
00115   graphwin.hPrevInstance = 0;
00116   graphwin.Title =  MSG_SCIMSG23 ;
00117   graphwin.szMenuName = GetszGraphMenuName();
00118   graphwin.lptw = &textwin;
00119   argcount = my_argc;
00120   while (argcount > 0)
00121     {
00122       argcount--;
00123       if (stricmp (my_argv[argcount], "-NW") == 0) nowin = 1;
00124       else if (stricmp (my_argv[argcount], "-NS") == 0) startupf = 1;
00125       else if ( stricmp(my_argv[argcount],"-NB") == 0) { sci_show_banner = 0; }
00126       else if (stricmp (my_argv[argcount], "-NWNI") == 0)
00127                 {
00128                         nowin = 1;
00129                         nointeractive = 1;
00130                 }
00131       else if (stricmp (my_argv[argcount], "-F") == 0 && argcount + 1 < my_argc)
00132                 {
00133                         path = my_argv[argcount + 1];
00134                         lpath = strlen (my_argv[argcount + 1]);
00135                 }
00136       else if (stricmp (my_argv[argcount], "-E") == 0 && argcount + 1 < my_argc)
00137                 {
00138                         path = my_argv[argcount + 1];
00139                         lpath = strlen (my_argv[argcount + 1]);
00140                         pathtype=1;
00141                 }
00142       else if ( stricmp(my_argv[argcount],"-MEM") == 0 && argcount + 1 < my_argc)
00143                 {
00144                         memory = Max(atoi( my_argv[argcount + 1]),MIN_STACKSIZE );
00145                 } 
00146           else if ( stricmp(my_argv[argcount],"-TEXMACS") == 0 )
00147           {
00148                   settexmacs();
00149           }
00150           else if ( stricmp(my_argv[argcount],"-NOGUI") == 0 )
00151           {
00152                   nowin = 1;
00153                   nointeractive = 1;
00154                   SetWITH_GUI(FALSE);
00155           }
00156           else if ( (stricmp (my_argv[argcount],"-VERSION")==0) ||
00157                   (stricmp (my_argv[argcount],"-VER")==0) )
00158           {
00159                         disp_scilab_version();
00160                         exit(1);
00161           }
00162           else if ( (stricmp (my_argv[argcount],"-H")==0) ||
00163                   (stricmp (my_argv[argcount],"-?")==0) ||
00164                   (stricmp (my_argv[argcount],"-HELP")==0) )
00165           {
00166                     printf(MSG_SCIMSG24B);
00167                     printf(MSG_SCIMSG122); 
00168                         printf(MSG_SCIMSG123); 
00169                         printf(MSG_SCIMSG124); 
00170                         printf(MSG_SCIMSG125); 
00171                         printf(MSG_SCIMSG126); 
00172                         printf(MSG_SCIMSG127); 
00173                         printf(MSG_SCIMSG128); 
00174                         printf(MSG_SCIMSG129); 
00175                         printf(MSG_SCIMSG130); 
00176                         printf(MSG_SCIMSG131); 
00177                         printf(MSG_SCIMSG132); 
00178                         printf(MSG_SCIMSG133); 
00179                         printf(MSG_SCIMSG134); 
00180                         printf(MSG_SCIMSG135); 
00181 
00182                   printf("\n");
00183                   exit(1);
00184           }
00185         }
00186 
00187   hdllInstance = GetModuleHandle(MSG_SCIMSG9);
00188 
00189   if (nowin == 1)
00190     {
00191           SaveConsoleColors();
00192           if (nointeractive!=1)
00193           {
00194                   RenameConsole();
00195                   UpdateConsoleColors();
00196           }
00197           
00198           sci_windows_main (nowin, &startupf,path,pathtype, &lpath,memory);
00199          
00200     }
00201   else
00202     {
00203         MessageBox(NULL,MSG_ERROR79,MSG_ERROR20,MB_ICONWARNING);
00204     }
00205 
00206   ExitScilab();
00207   
00208   return 0;
00209 }

Here is the call graph for this function:

Here is the caller graph for this function:

void CreateSplashscreen ( void   ) 

Definition at line 8 of file Splashscreen.c.

00009 {
00010         HWND hdlg;
00011         hdlg = CreateDialog(hdllInstance, "IDD_SPLASH", NULL,NULL);
00012 
00013         ShowWindow(hdlg, SW_SHOWNORMAL);
00014         UpdateWindow(hdlg);
00015         Sleep(1500);
00016 
00017         DestroyWindow(hdlg);
00018 }

void disp_scilab_version ( void   ) 

Definition at line 13 of file version.c.

References IsConsoleMode(), NULL, SCI_VERSION_MAINTENANCE, SCI_VERSION_MAJOR, SCI_VERSION_MINOR, SCI_VERSION_REVISION, and SCI_VERSION_STRING.

00014 {
00015         if (!IsConsoleMode())
00016         {
00017                 #ifdef _MSC_VER
00018                 {
00019                         char msg[1024];
00020                         wsprintf(msg,"Scilab version \"%d.%d.%d.%d\"\n%s\n",SCI_VERSION_MAJOR,SCI_VERSION_MINOR,SCI_VERSION_MAINTENANCE,SCI_VERSION_REVISION,SCI_VERSION_STRING);
00021                         MessageBox(NULL,msg,"Scilab Version Info.",MB_ICONINFORMATION);
00022                 }
00023                 
00024                 #else
00025                 printf("Scilab version \"%d.%d.%d.%d\"\n",SCI_VERSION_MAJOR,SCI_VERSION_MINOR,SCI_VERSION_MAINTENANCE,SCI_VERSION_REVISION);
00026                 printf("%s\n\n",SCI_VERSION_STRING);
00027                 #endif
00028         }
00029         else
00030         {
00031                 printf("Scilab version \"%d.%d.%d.%d\"\n",SCI_VERSION_MAJOR,SCI_VERSION_MINOR,SCI_VERSION_MAINTENANCE,SCI_VERSION_REVISION);
00032                 printf("%s\n\n",SCI_VERSION_STRING);
00033         }
00034 }

Here is the call graph for this function:

int ExitScilab ( void   ) 

TODO : comment

Returns:

Definition at line 24 of file sciquit.c.

References TerminateCorePart1(), TerminateCorePart2(), TerminateGraphics(), TerminateGUI(), TerminateJVMs(), TerminateLocalization(), and TerminateTclTk().

00025 {
00026         TerminateCorePart1();
00027 
00028         TerminateGraphics();
00029 
00030         TerminateGUI();
00031   
00032         #ifdef WITH_TK
00033         TerminateTclTk();
00034         #endif
00035 
00036         #ifdef _MSC_VER
00037         TerminateJVMs();
00038         #endif
00039 
00040         TerminateLocalization();
00041 
00042         TerminateCorePart2();
00043 
00044         return 0;
00045 }

Here is the call graph for this function:

BOOL ForbiddenToUseScilab ( void   ) 

Definition at line 590 of file winmain.c.

References BITSPIXEL, FALSE, hdc, MSG_ERROR42, MSG_WARNING22, NULL, and TRUE.

Referenced by Console_Main(), InitWindowGraphDll(), and Windows_Main().

00591 {
00592         BOOL bOK=FALSE;
00593         HDC hdc=GetDC(NULL);
00594         int BitsByPixel = GetDeviceCaps(hdc, BITSPIXEL);
00595 
00596     ReleaseDC (NULL, hdc);
00597 
00598         if ( BitsByPixel < 8 )
00599         {
00600                 MessageBox(NULL,MSG_WARNING22,MSG_ERROR42,MB_ICONSTOP);
00601                 exit(1);
00602                 return bOK;
00603         }
00604 
00605         bOK=TRUE;
00606         return bOK;
00607 }

Here is the caller graph for this function:

BOOL GetWITH_GUI ( void   ) 

TODO : comment

Returns:

Definition at line 297 of file inisci-c.c.

00298 {
00299         return WITH_GUI;
00300 }

TW InitTWStruct ( void   ) 

Definition at line 15 of file TextWindows.c.

References tagTW::Attr, tagTW::AttrBuffer, tagTW::bFocus, tagTW::bGetCh, tagTW::bSysColors, tagTW::ButtonHeight, tagTW::CaretHeight, tagTW::CharAscent, tagTW::CharSize, tagTW::ClientSize, tagTW::CursorFlag, tagTW::CursorPos, FALSE, tagTW::fontname, tagTW::fontsize, tagTW::hbrBackground, tagTW::hfont, tagTW::hIcon, tagTW::hInstance, tagTW::hPopMenu, tagTW::hPrevInstance, tagTW::hWndParent, tagTW::hWndText, tagTW::KeyBuf, tagTW::KeyBufIn, tagTW::KeyBufOut, tagTW::KeyBufSize, tagTW::lpmw, tagTW::lpr, tagTW::MarkBegin, tagTW::MarkEnd, tagTW::Marking, tagTW::nCmdShow, NULL, tagTW::Origin, tagTW::ScreenBuffer, tagTW::ScreenSize, tagTW::ScrollMax, tagTW::ScrollPos, tagTW::Size, and tagTW::Title.

Referenced by Console_Main(), and Windows_Main().

00016 {
00017         TW TWStruct;
00018 
00019         TWStruct.lpr=NULL;
00020         TWStruct.hInstance=NULL;
00021         TWStruct.hPrevInstance=NULL;
00022         TWStruct.Title=NULL;
00023         TWStruct.lpmw=NULL;
00024 
00025         TWStruct.ScreenSize.x=0;
00026         TWStruct.ScreenSize.y=0;
00027 
00028         TWStruct.KeyBufSize=0;
00029         TWStruct.nCmdShow=0;
00030         TWStruct.hIcon=NULL;
00031         TWStruct.hPopMenu=NULL;
00032         TWStruct.hWndText=NULL;
00033         TWStruct.hWndParent=NULL;
00034 
00035         TWStruct.Origin.x=0;
00036         TWStruct.Origin.y=0;
00037 
00038         TWStruct.Size.x=0;
00039         TWStruct.Size.y=0;
00040 
00041         TWStruct.ScreenBuffer=NULL;
00042         TWStruct.AttrBuffer=NULL;
00043         TWStruct.KeyBuf=NULL;
00044         TWStruct.KeyBufIn=NULL;
00045         TWStruct.KeyBufOut=NULL;
00046         TWStruct.Attr=0;
00047         TWStruct.bFocus=FALSE;
00048         TWStruct.bGetCh=FALSE;
00049         TWStruct.bSysColors=FALSE;
00050         TWStruct.hbrBackground=NULL;
00051         wsprintf(TWStruct.fontname,"Lucida Console");
00052         TWStruct.fontsize=11;
00053         TWStruct.hfont=NULL;
00054         TWStruct.CharAscent=0;
00055         TWStruct.ButtonHeight=0;
00056         TWStruct.CaretHeight=0;
00057         TWStruct.CursorFlag=0;
00058 
00059         TWStruct.CursorPos.x=0;
00060         TWStruct.CursorPos.y=0;
00061 
00062         TWStruct.ClientSize.x=0;
00063         TWStruct.ClientSize.y=0;
00064 
00065         TWStruct.CharSize.x=0;
00066         TWStruct.CharSize.y=0;
00067 
00068         TWStruct.ScrollPos.x=0;
00069         TWStruct.ScrollPos.y=0;
00070 
00071         TWStruct.ScrollMax.x=0;
00072         TWStruct.ScrollMax.y=0;
00073 
00074         TWStruct.MarkBegin.x=0;
00075         TWStruct.MarkBegin.y=0;
00076 
00077         TWStruct.MarkEnd.x=0;
00078         TWStruct.MarkEnd.y=0;
00079 
00080         TWStruct.Marking=FALSE;
00081 
00082         return TWStruct;
00083 }

Here is the caller graph for this function:

void InitWindowGraphDll ( void   ) 

Definition at line 491 of file winmain.c.

References FALSE, ForbiddenToUseScilab(), FREE, getenv(), GetScilabDirectory(), GetszGraphMenuName(), GetWITH_GUI(), graphwin, hdllInstance, tagGW::hInstance, tagGW::hPrevInstance, InitGWStruct(), InitszGraphMenuName(), tagGW::lptw, MSG_ERROR20, MSG_ERROR38, MSG_ERROR39, MSG_SCIMSG11, MSG_SCIMSG23, NULL, tagGW::szMenuName, textwin, and tagGW::Title.

Referenced by Initialize(), and StartScilab().

00496 {
00497         if ( GetWITH_GUI() )
00498         {
00499                 char *ScilabDirectory=NULL;
00500 
00501                 HINSTANCE hdllInstanceTmp=NULL;
00502                 char *p1 = (char*)getenv ("SCI");
00503                 hdllInstanceTmp=(HINSTANCE)GetModuleHandle(MSG_SCIMSG11);
00504 
00505                 if (hdllInstanceTmp==NULL) 
00506                 {
00507                         MessageBox(NULL,MSG_ERROR39,MSG_ERROR20,MB_ICONWARNING|MB_OK);
00508                         exit(1);
00509                 }
00510 
00511                 ForbiddenToUseScilab();
00512 
00513                 hdllInstance=hdllInstanceTmp;
00514                 ScilabDirectory=GetScilabDirectory(FALSE);
00515 
00516                 if (ScilabDirectory == NULL)
00517                 {
00518                         MessageBox (NULL, MSG_ERROR20, MSG_ERROR38, MB_ICONSTOP | MB_OK);
00519                         exit(1);
00520                 }       
00521 
00522                 InitszGraphMenuName(ScilabDirectory);
00523                 if (ScilabDirectory){FREE(ScilabDirectory);ScilabDirectory=NULL;}               
00524 
00525                 InitCommonControls ();
00526 
00527                 graphwin=InitGWStruct();
00528                 graphwin.hInstance = hdllInstance;
00529                 graphwin.hPrevInstance = NULL;
00530                 graphwin.Title = MSG_SCIMSG23;
00531                 graphwin.szMenuName = GetszGraphMenuName();
00532                 graphwin.lptw = &textwin;
00533         }
00534 }

Here is the call graph for this function:

Here is the caller graph for this function:

int InteractiveMode ( void   ) 

Definition at line 565 of file winmain.c.

References nointeractive.

00566 {
00567         return nointeractive;
00568 }

int IsNoInteractiveWindow ( void   ) 

Definition at line 609 of file winmain.c.

References nointeractive.

00610 {
00611         return nointeractive;
00612 }

void Kill_Scilex ( void   ) 

Definition at line 575 of file winmain.c.

References FALSE, MSG_WARNING20, MSG_WARNING21, and NULL.

00576 {
00577         HANDLE hProcess;
00578         /* Ouverture de ce Process avec droit pour le tuer */
00579 
00580         hProcess=OpenProcess(PROCESS_TERMINATE,FALSE,GetCurrentProcessId());
00581         if (hProcess)
00582         {
00583                 /* Tue ce Process */
00584 
00585                 TerminateProcess(hProcess,0);
00586         }
00587         else MessageBox(NULL,MSG_WARNING20,MSG_WARNING21,MB_ICONWARNING);
00588 }

void MessageBoxNewGraphicMode ( void   ) 

Definition at line 17 of file MessageBoxNewGraphicMode.c.

00018 {
00019         HKEY key;
00020         DWORD result,size=4;
00021         char Clef[MAX_PATH];
00022         int DontShowMessageNewGraphicMode,Ans;
00023 
00024         wsprintf(Clef,"SOFTWARE\\Scilab\\%s\\Settings",SCI_VERSION_STRING);
00025   result=RegOpenKeyEx(HKEY_CURRENT_USER, Clef, 0, KEY_QUERY_VALUE , &key);
00026 
00027         if ( RegQueryValueEx(key, "DontShowMessageNewGraphicMode", 0, NULL, (LPBYTE)&Ans, &size) !=  ERROR_SUCCESS )
00028   {
00029         DontShowMessageNewGraphicMode = 0;
00030         }
00031         else
00032         {
00033                 DontShowMessageNewGraphicMode = Ans;
00034         }
00035 
00036         if ( result == ERROR_SUCCESS ) RegCloseKey(key);
00037 
00038         if (DontShowMessageNewGraphicMode == 0)
00039         {
00040                 DialogBox(hdllInstance, "IDD_MESSAGE_NEW_GRAPHIC", NULL,MessageBoxNewGraphicModeDlgProc);
00041         }
00042 }

void PrintFile ( char *  filename  ) 

Definition at line 180 of file TextToPrint.c.

00181 {
00182 #define MAXBUF 4096
00183         HDC PrintDC;
00184         HFONT hFont, hOldFont;
00185         HDC hDCmem;
00186         DOCINFO di;
00187         int Index2 = 3;
00188         int numero=1;
00189         // Extrait les informations sur la police
00190         TEXTMETRIC tm;
00191         int NbLigneParPage = 0;
00192         int HauteurCaractere=0;
00193         int NombredeCaracteresparLignes=0;
00194         FILE * pFile;
00195         char  line[MAXBUF];
00196 
00197         PrintDC=GetPrinterDC();
00198         if (PrintDC != NULL)
00199         {
00200 
00201                 hFont=EzCreateFont (PrintDC, TEXT ("Courier New"),120, 0, 0, TRUE) ;
00202                 hOldFont = SelectObject(PrintDC, hFont );
00203 
00204                 hDCmem = CreateCompatibleDC(PrintDC);
00205                 memset( &di, 0, sizeof( DOCINFO ) );
00206                 di.cbSize      = sizeof( DOCINFO );
00207                 di.lpszDocName = MSG_SCIMSG105;
00208 
00209                 GetTextMetrics(PrintDC,(TEXTMETRIC *)&tm);
00210 
00211                 NombredeCaracteresparLignes=GetDeviceCaps(PrintDC,HORZRES) / (tm.tmMaxCharWidth+1);
00212                 // la valeur HauteurCaractere contient hauteur des caractéres + l'interligne
00213                 HauteurCaractere= tm.tmHeight+tm.tmExternalLeading;
00214                 NbLigneParPage = GetDeviceCaps(PrintDC,VERTRES) / HauteurCaractere;
00215 
00216                 pFile = fopen (filename,"rt");
00217                 if (pFile)
00218                 {
00219                         if ( StartDoc( PrintDC, &di ) > 0 )
00220                         {
00221                                 char *LignePrint=NULL;
00222                                 StartPage(PrintDC);
00223                                 PageHeader(PrintDC,filename);
00224 
00225                                 while(fgets (line,sizeof(line),pFile) != NULL)
00226                                 {
00227                                         if (line[strlen(line)-1] == '\n') line[strlen(line)-1]='\0'; /* enleve le retour chariot */
00228                                         if (line[strlen(line)-2] == '\r') line[strlen(line)-2]='\0'; /* enleve le retour chariot */
00229 
00230                                         if ( strlen(line)> (unsigned int )NombredeCaracteresparLignes)
00231                                         {
00232                                                 int i=0;
00233                                                 int j=0;
00234                                                 int subline=0;
00235                                                 int restsubline=0;
00236                                                 subline = (int)strlen(line) / NombredeCaracteresparLignes ;
00237                                                 restsubline=(int)strlen(line) % NombredeCaracteresparLignes ;
00238 
00239                                                 for (i=0;i<subline;i++)
00240                                                 {
00241                                                         LignePrint=(char*)MALLOC( (NombredeCaracteresparLignes+1)*sizeof(char));
00242                                                         for (j=0;j<(NombredeCaracteresparLignes);j++)
00243                                                         {
00244                                                                 if (line[(i*NombredeCaracteresparLignes)+j] == 9) /* == \t */
00245                                                                 {
00246                                                                         LignePrint[j]=' ';
00247                                                                 }
00248                                                                 else
00249                                                                 {
00250                                                                         LignePrint[j]=line[(i*NombredeCaracteresparLignes)+j];
00251                                                                 }
00252 
00253                                                         }
00254                                                         LignePrint[j]='\0';
00255 
00256                                                         TextOut (PrintDC,(tm.tmMaxCharWidth+10), Index2*HauteurCaractere, LignePrint, (int)strlen(LignePrint));
00257                                                         if (LignePrint)
00258                                                         {
00259                                                                 FREE(LignePrint);
00260                                                                 LignePrint=NULL;
00261                                                         }
00262                                                         Index2 ++;
00263                                                         if (Index2 == NbLigneParPage-4)
00264                                                         {
00265                                                                 Footer(PrintDC,numero);
00266                                                                 EndPage (PrintDC);
00267                                                                 StartPage(PrintDC);
00268                                                                 numero++;
00269                                                                 PageHeader(PrintDC,filename);
00270                                                                 Index2 = 3;
00271                                                         }
00272                                                 }
00273                                                 if (restsubline>0)
00274                                                 {
00275                                                         LignePrint=(char*)MALLOC( (NombredeCaracteresparLignes+1)*sizeof(char));
00276                                                         for (j=0;j<(restsubline);j++)
00277                                                         {
00278                                                                 if (line[(i*NombredeCaracteresparLignes)+j] == 9) /* == \t */
00279                                                                 {
00280                                                                         LignePrint[j]=' ';
00281                                                                 }
00282                                                                 else
00283                                                                 {
00284                                                                         LignePrint[j]=line[(i*NombredeCaracteresparLignes)+j];
00285                                                                 }
00286                                                         }
00287                                                         LignePrint[j]='\0';
00288                                                         TextOut (PrintDC,(tm.tmMaxCharWidth+10), Index2*HauteurCaractere, LignePrint, (int)strlen(LignePrint));
00289                                                         if (LignePrint)
00290                                                         {
00291                                                                 FREE(LignePrint);
00292                                                                 LignePrint=NULL;
00293                                                         }
00294                                                         Index2 ++;
00295                                                         if (Index2 == NbLigneParPage-4)
00296                                                         {
00297                                                                 Footer(PrintDC,numero);
00298                                                                 EndPage (PrintDC);
00299                                                                 StartPage(PrintDC);
00300                                                                 numero++;
00301                                                                 PageHeader(PrintDC,filename);
00302                                                                 Index2 = 3;
00303                                                         }
00304                                                 }
00305                                         }
00306                                         else
00307                                         {
00308                                                 LignePrint=(char*)MALLOC( (NombredeCaracteresparLignes+1)*sizeof(char));
00309                                                 strcpy(LignePrint,line);
00310                                                 TextOut (PrintDC,(tm.tmMaxCharWidth+10), Index2*HauteurCaractere, LignePrint, (int)strlen(LignePrint));
00311                                                 if (LignePrint)
00312                                                 {
00313                                                         FREE(LignePrint);
00314                                                         LignePrint=NULL;
00315                                                 }
00316                                                 Index2 ++;
00317                                                 if (Index2 == NbLigneParPage-4)
00318                                                 {
00319                                                         Footer(PrintDC,numero);
00320                                                         EndPage (PrintDC);
00321                                                         StartPage(PrintDC);
00322                                                         numero++;
00323                                                         PageHeader(PrintDC,filename);
00324                                                         Index2 = 3;
00325                                                 }
00326                                         }
00327                                 }
00328                                 fclose(pFile);
00329 
00330                                 Footer(PrintDC,numero);
00331                                 EndPage (PrintDC);
00332                                 EndDoc (PrintDC);
00333                         }
00334                 }
00335                 SelectObject(PrintDC, hOldFont );
00336         }
00337 }

int sci_getarg ( int n,
char *  s,
long int  ls 
)

Definition at line 548 of file winmain.c.

References i, my_argc, my_argv, and t.

00549 {
00550         register char *t;
00551         register int i;
00552         
00553         if(*n>=0 && *n <= my_argc)
00554         t = my_argv[*n];
00555         else
00556         t = "";
00557 
00558         for(i = 0; i < ls && *t!='\0' ; ++i)
00559         *s++ = *t++;
00560         for( ; i<ls ; ++i)
00561         *s++ = ' ';
00562         return 0;
00563 }

int sci_iargc ( void   ) 

Definition at line 543 of file winmain.c.

References my_argc.

00544 {
00545         return my_argc -1 ;
00546 }

void settexmacs ( void   ) 

Definition at line 24 of file texmacs.c.

00024                   {
00025   texmacs_mode=1;
00026 }

void SetWITH_GUI ( BOOL  ON  ) 

Definition at line 292 of file inisci-c.c.

00293 {
00294         if ( (ON == FALSE) || (ON == TRUE) ) WITH_GUI=ON;
00295 }

int C2F() showlogo (  ) 

Definition at line 570 of file winmain.c.

References show_logo.

00571 {
00572         return show_logo;
00573 }

char* stristr ( const char *  psz,
const char *  tofind 
)

Definition at line 615 of file winmain.c.

References strchr(), and strnicmp.

Referenced by Windows_Main().

00616 {
00617         const char *ptr = psz;
00618         const char *ptr2;
00619 
00620         while(1)
00621         {
00622                 ptr = strchr(psz,toupper(*tofind));
00623                 ptr2 = strchr(psz,tolower(*tofind));
00624                 if (!ptr)
00625                 {
00626                         ptr = ptr2; /* was ptr2 = ptr.  Big bug fixed 10/22/99 */
00627                 }
00628                 if (!ptr)
00629                 {
00630                         break;
00631                 }
00632                 if (ptr2 && (ptr2 < ptr))
00633                 {
00634                         ptr = ptr2;
00635                 }
00636                 if (!strnicmp(ptr,tofind,strlen(tofind)))
00637                 {
00638                         return (char *) ptr;
00639                 }
00640                 psz = ptr+1;
00641         }
00642         return 0;
00643 } 

Here is the call graph for this function:

Here is the caller graph for this function:

int WINAPI Windows_Main ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
PSTR  szCmdLine,
int  iCmdShow 
)

Definition at line 211 of file winmain.c.

References ChangeCursorWhenScilabIsReady(), CloseScilabConsole(), CommandByFileExtension(), CreateScilabConsole(), CreateSplashscreen(), tagTW::CursorFlag, disp_scilab_version(), ExitScilab(), FALSE, ForbiddenToUseScilab(), ForceToActiveWindowParent(), FREE, GetScilabDirectory(), GetszGraphMenuName(), GetszMenuName(), graphwin, hdllInstance, HideScilex(), tagTW::hInstance, tagGW::hInstance, tagTW::hPrevInstance, tagGW::hPrevInstance, i, InitGWStruct(), InitMWStruct(), InitszGraphMenuName(), InitszMenuName(), InitTWStruct(), IsAGraphFile(), IsAScicosFile(), j, tagTW::KeyBufSize, LINE, tagTW::lpmw, tagGW::lptw, MALLOC, Max, MAX_PATH, memory, menuwin, MessageBoxNewGraphicMode(), MIN_STACKSIZE, MSG_ERROR20, MSG_ERROR38, MSG_SCIMSG122, MSG_SCIMSG123, MSG_SCIMSG124, MSG_SCIMSG125, MSG_SCIMSG126, MSG_SCIMSG127, MSG_SCIMSG128, MSG_SCIMSG129, MSG_SCIMSG130, MSG_SCIMSG131, MSG_SCIMSG132, MSG_SCIMSG133, MSG_SCIMSG134, MSG_SCIMSG135, MSG_SCIMSG21, MSG_SCIMSG23, MSG_SCIMSG24, MSG_SCIMSG30, my_argc, my_argv, tagTW::nCmdShow, NULL, path, sci_show_banner, sci_windows_main(), ScilabIsStarting, tagTW::ScreenSize, SetWindowMode(), SetXsciOn(), startupf, stricmp, stristr(), SW_SHOWNORMAL, tagMW::szMenuName, tagGW::szMenuName, TextInit(), textwin, tagTW::Title, tagGW::Title, TRUE, and WSCILEX.

Referenced by WinMain().

00212 {
00213         int i=0;
00214         BOOL ShortCircuitExec=FALSE;
00215         BOOL LaunchAFile=FALSE;
00216         BOOL ShowMessageBoxInfo=TRUE;           
00217         char FileName[MAX_PATH];
00218         int nowin = 0, argcount = 0, lpath = 0, pathtype=0;
00219         char *path = NULL;
00220         char *ScilabDirectory=NULL;
00221 
00222         HANDLE hOut = NULL;
00223         
00224         char *pFullCmdLine=NULL;
00225         char *pFullCmdLineTmp=NULL;
00226         char *pPathCmdLine=NULL;
00227 
00228         ForbiddenToUseScilab();
00229 
00230         SetWindowMode(TRUE);
00231         ScilabIsStarting=TRUE;
00232 
00233         strcpy(FileName,"Empty");
00234         
00235         ScilabDirectory=GetScilabDirectory(FALSE);
00236 
00237         if (ScilabDirectory == NULL)
00238         {
00239                 MessageBox (NULL,MSG_ERROR20 , MSG_ERROR38, MB_ICONSTOP | MB_OK);
00240                 exit(1);
00241         }       
00242         InitszMenuName(ScilabDirectory);
00243         InitszGraphMenuName(ScilabDirectory);
00244 
00245         if (ScilabDirectory){FREE(ScilabDirectory);ScilabDirectory=NULL;}
00246 
00247         /* Load common control library * */
00248         InitCommonControls ();
00249 
00250         textwin=InitTWStruct();
00251 
00252         textwin.hInstance = hInstance;
00253         textwin.hPrevInstance = hPrevInstance;
00254         textwin.nCmdShow = iCmdShow;
00255         textwin.Title = MSG_SCIMSG21;
00256         textwin.lpmw = &menuwin;
00257         textwin.ScreenSize.x = 120;
00258         textwin.ScreenSize.y = 80;
00259         textwin.KeyBufSize = 4096;
00260         textwin.CursorFlag = 1; /* scroll to cursor after \n & \r */
00261 
00262         menuwin=InitMWStruct();
00263         menuwin.szMenuName = GetszMenuName();
00264 
00265         graphwin=InitGWStruct();
00266         graphwin.hInstance = hInstance;
00267         graphwin.hPrevInstance = hPrevInstance;
00268         graphwin.Title = MSG_SCIMSG23;
00269         graphwin.szMenuName = GetszGraphMenuName();
00270         graphwin.lptw = &textwin;
00271 
00272         pFullCmdLineTmp=GetCommandLine();
00273         {
00274                 char LineCommand[MAX_PATH];
00275                 char LineCommandBis[MAX_PATH];
00276                 char ShortPath[MAX_PATH];
00277                 char *pPathCmdLine=NULL;
00278                 char PathCmdLineCopy[1024];
00279                 char StrWscilexToSearch[MAX_PATH];
00280                 
00281                 sprintf(StrWscilexToSearch,"%s\" ",WSCILEX);
00282 
00283                 strcpy(LineCommand,pFullCmdLineTmp);
00284                 LineCommand[strlen(LineCommand)]='\0';
00285                 strcpy(LineCommandBis,pFullCmdLineTmp);
00286                 LineCommandBis[strlen(LineCommandBis)]='\0';
00287 
00288                 pPathCmdLine=stristr(LineCommand,StrWscilexToSearch);
00289                 
00290                 if ( (pPathCmdLine != NULL) && ( (strlen(pPathCmdLine)-strlen(StrWscilexToSearch)-1) > 0) ) 
00291                 {
00292                         char LINE[1024];
00293 
00294                         strcpy(PathCmdLineCopy,pPathCmdLine);   
00295                         if ( PathCmdLineCopy[strlen(StrWscilexToSearch)-2] == '\"' ) PathCmdLineCopy[strlen(StrWscilexToSearch)-2] = ' ';
00296                         strncpy(LINE,&LineCommandBis[1],strlen(LineCommandBis)-strlen(PathCmdLineCopy)-1);
00297                         LINE[strlen(LineCommandBis)-strlen(PathCmdLineCopy)-1]='\0';
00298                 
00299                         GetShortPathName(LINE,ShortPath,MAX_PATH);
00300                         strcat(ShortPath,PathCmdLineCopy);
00301                 
00302                         pFullCmdLine=(char*)MALLOC(sizeof(char)*(strlen(ShortPath)+1));
00303                         strcpy(pFullCmdLine,ShortPath);
00304                 }
00305                 else
00306                 {
00307                         pFullCmdLine=(char*)MALLOC(sizeof(char)*(strlen(LineCommandBis)+1));
00308                         strcpy(pFullCmdLine,LineCommandBis);
00309                 }
00310                 
00311         }
00312         
00313         my_argv[++my_argc] = strtok (pFullCmdLine, " ");
00314         while (my_argv[my_argc] != NULL)
00315         {
00316                 my_argv[++my_argc] = strtok(NULL, " ");
00317         }
00318         
00319         for (i=1;i<my_argc;i++)
00320         {
00321                 if  ( stricmp (my_argv[i], "-NB") == 0 )
00322                 {
00323                         ShowMessageBoxInfo=FALSE;
00324                 }
00325         }
00326 
00327         if (ShowMessageBoxInfo)
00328         {
00329                 /* New Graphics Mode Warning */
00330                 MessageBoxNewGraphicMode();
00331         }
00332 
00333         for (i=1;i<my_argc;i++)
00334         {
00335                 if  ( (stricmp (my_argv[i], "-NW") == 0) || (stricmp (my_argv[i], "-NWI") == 0) || (stricmp (my_argv[i], "-TEXMACS") == 0) || (stricmp (my_argv[i], "-NOGUI") == 0) )
00336                 {
00337                         MessageBox(NULL,"Not with Windows Console","Error",MB_ICONINFORMATION);
00338                         exit(1);
00339                 }
00340 
00341                 if ( (stricmp (my_argv[i], "-VERSION") == 0) ||
00342                         (stricmp (my_argv[i], "-VER") == 0) )
00343                 {
00344                         disp_scilab_version();
00345                         exit(1);
00346                 }
00347 
00348                 if ( (stricmp (my_argv[i], "-H") == 0) ||
00349                          (stricmp (my_argv[i], "-?") == 0) ||
00350                          (stricmp (my_argv[i], "-HELP") == 0) )
00351                 {
00352                         char Msg[2048];
00353                         strcpy(Msg,MSG_SCIMSG24);
00354                         strcat(Msg,MSG_SCIMSG122); 
00355                         strcat(Msg,MSG_SCIMSG123); 
00356                         strcat(Msg,MSG_SCIMSG124); 
00357                         strcat(Msg,MSG_SCIMSG125); 
00358                         strcat(Msg,MSG_SCIMSG126); 
00359                         strcat(Msg,MSG_SCIMSG127); 
00360                         strcat(Msg,MSG_SCIMSG128); 
00361                         strcat(Msg,MSG_SCIMSG129); 
00362                         strcat(Msg,MSG_SCIMSG130); 
00363                         strcat(Msg,MSG_SCIMSG131); 
00364                         strcat(Msg,MSG_SCIMSG132); 
00365                         strcat(Msg,MSG_SCIMSG133); 
00366                         strcat(Msg,MSG_SCIMSG134); 
00367                         strcat(Msg,MSG_SCIMSG135); 
00368 
00369                         MessageBox(NULL,Msg,MSG_SCIMSG30,MB_ICONINFORMATION);
00370                         exit(1);
00371                 }
00372         }
00373         argcount = my_argc;
00374 
00375         if (argcount > 2)
00376         {
00377                 if ( (stricmp (my_argv[1], "-X") == 0) ||
00378                      (stricmp (my_argv[1], "-O") == 0) ||       
00379                      (stricmp (my_argv[1], "-P") == 0) )
00380                 {
00381                         char *Commande=NULL;
00382                         int CodeAction=-1;
00383                         int j=0;
00384 
00385                         LaunchAFile=TRUE;
00386 
00387                         strcpy(FileName,my_argv[2]);
00388                         for (j=3;j<argcount;j++)
00389                         {
00390                                 strcat(FileName," ");
00391                                 strcat(FileName,my_argv[j]);
00392                         }
00393                         if (stricmp (my_argv[1], "-O") == 0) CodeAction=0;
00394                         if (stricmp (my_argv[1], "-X") == 0) CodeAction=1; 
00395                         if (stricmp (my_argv[1], "-P") == 0) CodeAction=2;
00396 
00397                         Commande=(char*)MALLOC(MAX_PATH*sizeof(char));
00398                         strcpy(Commande,"empty");
00399                         CommandByFileExtension(FileName,CodeAction,Commande);
00400 
00401                         if (
00402                                 ( ( IsAScicosFile(FileName)== TRUE ) && (CodeAction==1) ) ||
00403                                 ( ( IsAGraphFile(FileName)== TRUE  ) && (CodeAction==1) )
00404                             )
00405                         {
00406                                 my_argc=-1;
00407                                 my_argv[++my_argc]=Commande;
00408                                 argcount = my_argc;
00409                                 ShortCircuitExec=TRUE;
00410                         }
00411                         else
00412                         {
00413                                 my_argc=-1;
00414                                 my_argv[++my_argc] = strtok (Commande, " ");
00415                                 while (my_argv[my_argc] != NULL)
00416                                 {
00417                                         my_argv[++my_argc] = strtok(NULL, " ");
00418                                 }
00419                                 argcount = my_argc;
00420                         }
00421                 }
00422         }       
00423         
00424         if ( ShortCircuitExec == TRUE)
00425         {
00426                 char PathWScilex[MAX_PATH];
00427                 int lenPathWScilex=0;
00428                 GetModuleFileName ((HINSTANCE)GetModuleHandle(NULL), PathWScilex, MAX_PATH);
00429                 lenPathWScilex=strlen(PathWScilex);
00430                 path = my_argv[argcount]+lenPathWScilex+3;
00431                 lpath = strlen (my_argv[argcount]+lenPathWScilex+3);
00432                 pathtype=1;
00433                 LaunchAFile=TRUE;
00434         }
00435         else
00436         while (argcount > 0)
00437         {
00438     char ArgTmp[MAX_PATH];
00439                 
00440                 argcount--;
00441                 strcpy(ArgTmp,my_argv[argcount]);
00442                 
00443                 if (stricmp (ArgTmp, "-NS") == 0) startupf = 1;
00444                 else if ( stricmp(ArgTmp,"-NB") == 0) { sci_show_banner = 0; }
00445                 else if (stricmp (ArgTmp, "-F") == 0 && argcount + 1 < my_argc)
00446                 {
00447                         path = my_argv[argcount + 1];
00448                         lpath = strlen (my_argv[argcount + 1]);
00449                 }
00450                 else if (stricmp (ArgTmp, "-E") == 0 && argcount + 1 < my_argc)
00451                 {
00452                         path = my_argv[argcount + 1];
00453                         lpath = strlen (my_argv[argcount + 1]);
00454                         pathtype=1;
00455                 }
00456                 else if ( stricmp(ArgTmp,"-MEM") == 0 && argcount + 1 < my_argc)
00457                 {
00458                         memory = Max(atoi( my_argv[argcount + 1]),MIN_STACKSIZE );
00459                 }
00460         }               
00461         hdllInstance = hInstance;
00462 
00463         /* Splashscreen*/
00464         if ( (sci_show_banner) && (LaunchAFile == FALSE) )CreateSplashscreen();
00465 
00466         CreateScilabConsole(sci_show_banner);
00467 
00468         if (TextInit (&textwin)) exit (1);
00469 
00470         textwin.hIcon = LoadIcon (hInstance, "texticon");
00471         SetClassLong (textwin.hWndParent, GCL_HICON, (DWORD) textwin.hIcon);
00472         SetXsciOn ();
00473 
00474         ShowWindow (textwin.hWndParent, SW_SHOWNORMAL);
00475         ForceToActiveWindowParent();
00476         HideScilex(); /* Cache la fenetre Console */
00477 
00478         if (LaunchAFile) ChangeCursorWhenScilabIsReady();
00479 
00480         
00481         sci_windows_main (nowin, &startupf, path,pathtype, &lpath,memory);
00482         
00483         CloseScilabConsole();
00484 
00485         ExitScilab();
00486 
00487 
00488         return 0;
00489 }

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

LPSTR my_argv[MAXCMDTOKENS] [static]

Definition at line 61 of file winmain.c.

Referenced by add_sci_argv(), Console_Main(), sci_getarg(), and Windows_Main().

int sci_show_banner = 1

Definition at line 48 of file winmain.c.

BOOL ScilabIsStarting = TRUE

Definition at line 47 of file winmain.c.

Referenced by ChangeCursorWhenScilabIsReady(), Console_Main(), and Windows_Main().


Generated on Sun Mar 4 15:59:12 2007 for Scilab [trunk] by  doxygen 1.5.1