clipboard.c File Reference

#include "clipboard.h"
#include "Messages.h"
#include "Warnings.h"
#include "Errors.h"
#include "wgnuplib.h"
#include "WindowList.h"
#include "win_mem_alloc.h"

Include dependency graph for clipboard.c:

Go to the source code of this file.

Defines

#define TEMPOTOUCHE   1

Functions

HDC TryToGetDC (HWND hWnd)
LPTW GetTextWinScilab (void)
int IsAScalar (int RhsNumber)
void CreateThreadPaste (char *Text)
BOOL IsReadyForAnewLign (void)
void SetReadyOrNotForAnewLign (BOOL Ready)
DWORD WINAPI SendInputText (LPVOID lpParam)
void PasteFunction (LPTW lptw, BOOL special)
BOOL IsEmptyClipboard (LPTW lptw)
void TextCopyClip (LPTW lptw)
void CleanClipboard (LPTW lptw)
HANDLE GetHandleThreadPaste (void)
BOOL GetThreadPasteRunning (void)
void SetThreadPasteRunning (BOOL Running)
int InterfaceWindowsClipboard (char *fname, unsigned long l)
char * GetTextFromClipboard (LPTW lptw)
void PutTextInClipboard (LPTW lptw, char *Text)

Variables

static BOOL ThreadPasteRunning = FALSE
static HANDLE hThreadPaste
static char * PasteForThread = NULL
static BOOL ReadyForAnewLign = FALSE
static BOOL SpecialPaste = FALSE


Define Documentation

#define TEMPOTOUCHE   1

Referenced by SendInputText(), and WriteTextThread().


Function Documentation

void CleanClipboard ( LPTW  lptw  ) 

Definition at line 276 of file clipboard.c.

References FALSE, hThreadPaste, tagTW::hWndParent, and ThreadPasteRunning.

Referenced by Callback_EMPTYCLIPBOARD().

00277 {
00278         if (ThreadPasteRunning)
00279         {
00280                 SuspendThread(hThreadPaste);
00281                 TerminateThread(hThreadPaste,1);
00282         ThreadPasteRunning=FALSE;
00283         CloseHandle( hThreadPaste );
00284         }
00285 
00286         OpenClipboard(lptw->hWndParent);
00287         EmptyClipboard();
00288         CloseClipboard();
00289 }

Here is the caller graph for this function:

void CreateThreadPaste ( char *  Text  ) 

Definition at line 28 of file clipboard.c.

References hThreadPaste, MALLOC, NULL, PasteForThread, and SendInputText().

Referenced by ON_WND_TEXT_WM_SETTEXT().

00029 {
00030         DWORD IdThreadPaste;
00031         PasteForThread=(char*)MALLOC( (strlen(Text)+1)*sizeof(char));
00032         strcpy(PasteForThread,Text);
00033         PasteForThread[strlen(PasteForThread)]='\0';
00034         /* PasteForThread défini en global car passage via CreateThread plante sous Win98 */
00035         hThreadPaste=CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)SendInputText,NULL,0,(LPDWORD)&IdThreadPaste);
00036         
00037 }

Here is the call graph for this function:

Here is the caller graph for this function:

HANDLE GetHandleThreadPaste ( void   ) 

Definition at line 291 of file clipboard.c.

References hThreadPaste.

Referenced by ExitWindow().

00292 {
00293         return hThreadPaste;
00294 }

Here is the caller graph for this function:

char* GetTextFromClipboard ( LPTW  lptw  ) 

Definition at line 847 of file clipboard.c.

References hdc, tagTW::hfont, tagTW::hWndText, MALLOC, NULL, TEXTMETRIC, TryToGetDC(), type, and UINT.

Referenced by InterfaceWindowsClipboard().

00848 {
00849         char *Text=NULL;
00850 
00851         HDC hdc;
00852         HGLOBAL hGMem;
00853         TEXTMETRIC tm;
00854         UINT type;
00855         LPSTR lpMem; /* Pointeur sur la chaine du clipboard */
00856         
00857         
00858         /* find out what type to get from clipboard */
00859         hdc = (HDC)TryToGetDC (lptw->hWndText);
00860         SelectObject(hdc, lptw->hfont);
00861         GetTextMetrics(hdc,(TEXTMETRIC FAR *)&tm);
00862         if (tm.tmCharSet == OEM_CHARSET) type = CF_OEMTEXT;
00863         else type = CF_TEXT;
00864         ReleaseDC (lptw->hWndText, hdc);
00865         
00866         /* now get it from clipboard */
00867         OpenClipboard (lptw->hWndText);
00868         hGMem = GetClipboardData (type);
00869         
00870         if (hGMem)
00871                 {
00872                         lpMem  = GlobalLock( hGMem );
00873                         Text= (char*) MALLOC (sizeof(char)*(strlen(lpMem)+1));
00874                         strcpy(Text,lpMem);
00875                         GlobalUnlock (hGMem);
00876                 }
00877         CloseClipboard ();
00878 
00879         return Text;
00880 }

Here is the call graph for this function:

Here is the caller graph for this function:

LPTW GetTextWinScilab ( void   ) 

Definition at line 10 of file TextWindows.c.

00011 {
00012         return &textwin;
00013 }

BOOL GetThreadPasteRunning ( void   ) 

Definition at line 296 of file clipboard.c.

References ThreadPasteRunning.

Referenced by ExitWindow(), and TextGetCh().

00297 {
00298         return ThreadPasteRunning;
00299 }

Here is the caller graph for this function:

int InterfaceWindowsClipboard ( char *  fname,
unsigned long  l 
)

Definition at line 306 of file clipboard.c.

References buffer, C2F, Callback_EMPTYCLIPBOARD(), Callback_MCOPY(), Callback_PASTE(), CheckLhs, CheckRhs, CopyToClipboardBitmap(), CopyToClipboardEMF(), CreateVar, CreateVarFromPtr, cstk, FREE, GetRhsVar, GetTextFromClipboard(), GetTextWinScilab(), GetType, getWindowXgcNumber(), i, IsAScalar(), istk, IsWindowInterface(), j, LhsVar, m1, MALLOC, Max, MSG_ERROR10, MSG_ERROR7, n1, NULL, output(), putlhsvar(), PutTextInClipboard(), Rhs, and sci_strings.

Referenced by C2F().

00307 {
00308         static int l1,n1,m1;
00309         char *param1=NULL,*param2=NULL,*param3=NULL;
00310 
00311         Rhs=Max(0,Rhs);
00312         CheckRhs(0,2);
00313         CheckLhs(0,1);
00314 
00315         if ( IsWindowInterface() )
00316         {
00317                 if ( (Rhs == 1) && (GetType(1)==sci_strings) )
00318                 {
00319                         GetRhsVar(1,"c",&m1,&n1,&l1);
00320                         param1=cstk(l1);
00321 
00322                         if ( ( strcmp(param1,"paste") == 0 ) || ( strcmp(param1,"pastespecial") == 0 ) )
00323                         {
00324                                 char *output=NULL ;
00325                                 LPTW lptw=GetTextWinScilab();
00326 
00327                                 output=GetTextFromClipboard(lptw);
00328 
00329                                 if (output)
00330                                 {
00331                                         CreateVarFromPtr( 1, "c",(m1=strlen(output), &m1),&n1,&output);
00332                                         FREE(output);
00333                                         LhsVar(1)=1;
00334                                 }
00335                                 else
00336                                 {
00337                                         m1=0;
00338                                         n1=0;
00339                                         l1=0;
00340                                         CreateVar(1,"d",  &m1, &n1, &l1);
00341                                         LhsVar(1)=1;
00342                                 }
00343 
00344                                 C2F(putlhsvar)();       
00345                                 return 0;
00346                         }
00347                         else
00348                         {
00349                                 Scierror(999,MSG_ERROR7);
00350                                 return 0;
00351                         }
00352                 }
00353 
00354                 if (Rhs == 2)
00355                 {
00356                         if ( (GetType(1)==sci_strings) && (GetType(2)==sci_strings) )
00357                         {
00358                                 GetRhsVar(1,"c",&m1,&n1,&l1);
00359                                 param1=cstk(l1);
00360 
00361                                 if ( strcmp(param1,"do") == 0 )
00362                                 {
00363                                         GetRhsVar(2,"c",&m1,&n1,&l1);
00364                                         param2=cstk(l1);
00365 
00366                                         if ( strcmp(param2,"paste") == 0 )
00367                                         {
00368                                                 Callback_PASTE();
00369                                         }
00370                                         else if ( strcmp(param2,"copy") == 0 )
00371                                         {
00372                                                 Callback_MCOPY();
00373                                         }
00374                                         else if ( strcmp(param2,"empty") == 0 )
00375                                         {
00376                                                 Callback_EMPTYCLIPBOARD();
00377                                         }
00378                                         else
00379                                         {
00380                                                 Scierror(999,"Incorrect second parameter.");
00381                                                 return 0;
00382                                         }
00383 
00384                                         m1=0;
00385                                         n1=0;
00386                                         l1=0;
00387                                         CreateVar(1,"d",  &m1, &n1, &l1);
00388                                         LhsVar(1)=1;
00389                                         C2F(putlhsvar)();       
00390                                         return 0;
00391                                 }
00392 
00393                                 if ( strcmp(param1,"copy") == 0 )
00394                                 {
00395                                         char *TextToPutInClipboard=NULL;
00396                                         char **Str=NULL;
00397                                         LPTW lptw=GetTextWinScilab();
00398 
00399                                         GetRhsVar(2,"S",&m1,&n1,&Str);
00400 
00401 
00402                                         if ( (m1==1) && (n1==1) )
00403                                         {
00404                                                 TextToPutInClipboard=Str[0];
00405                                                 PutTextInClipboard(lptw,TextToPutInClipboard);
00406                                         }
00407                                         else
00408                                         {
00409                                                 int i=0;
00410                                                 int j=0;
00411                                                 int l=0;
00412                                                 char *TextToSendInClipboard=NULL;
00413                                                 int SizeofTextToSendInClipboard=0;
00414                                                 char **buffer = (char**)MALLOC( (m1*n1)*sizeof(char *) );
00415                                         
00416                                                 for (i=0; i<m1; i++) for (j=0; j<n1; j++) 
00417                                                 {
00418                                                         SizeofTextToSendInClipboard=SizeofTextToSendInClipboard+strlen(Str[j*m1+i])+strlen(" \n");
00419                                                         buffer[i*n1+j]=(char*)MALLOC(strlen(Str[j*m1+i])+1);
00420                                                         sprintf(buffer[i*n1+j],"%s",Str[j*m1+i]);
00421                                                 }
00422 
00423                                                 TextToSendInClipboard=(char*)MALLOC( (SizeofTextToSendInClipboard)*sizeof(char) );
00424                                                 strcpy(TextToSendInClipboard,"");
00425 
00426                                                 for (i=0; i<m1; i++)
00427                                                 {
00428                                                                 for (j=0; j<n1; j++) 
00429                                                                 {
00430                                                                         strcat(TextToSendInClipboard,buffer[l++]);
00431                                                                         strcat(TextToSendInClipboard," ");
00432                                                                 }
00433                                                                 if ( i != (m1-1) ) strcat(TextToSendInClipboard,"\n");
00434                                                 }
00435 
00436                                                 PutTextInClipboard(lptw,TextToSendInClipboard);
00437 
00438                                                 if (buffer) {FREE(buffer);buffer=NULL;}
00439 
00440                                                 if(TextToSendInClipboard) {FREE(TextToSendInClipboard);TextToSendInClipboard=NULL;}
00441                                         }
00442 
00443                                         m1=0;
00444                                         n1=0;
00445                                         l1=0;
00446                                         CreateVar(1,"d",  &m1, &n1, &l1);
00447                                         LhsVar(1)=1;
00448                                         C2F(putlhsvar)();       
00449                                         return 0;
00450                                 }
00451                                 else
00452                                 {
00453                                         Scierror(999,"Incorrect parameters. See : help clipboard");
00454                                         return 0;
00455                                 }
00456                         }
00457 
00458                         if ( (IsAScalar(1)) && (GetType(2)==sci_strings) )
00459                         {
00460                                 GetRhsVar(2,"c",&m1,&n1,&l1);
00461                                 param2=cstk(l1);
00462 
00463                                 if ( ( strcmp(param2,"EMF") == 0 ) || ( strcmp(param2,"DIB") == 0 ) )
00464                                 {
00465                                         int num_win=-2;
00466                                         GetRhsVar(1,"i",&m1,&n1,&l1);
00467                                         num_win=*istk(l1);
00468                                         if (num_win>=0)
00469                                         {
00470                                                 struct BCG *ScilabGC=NULL;
00471                                                 ScilabGC = getWindowXgcNumber (num_win);
00472 
00473                                                 if (ScilabGC)
00474                                                 {
00475                                                         if ( strcmp(param2,"EMF") == 0 )
00476                                                         {
00477                                                                 CopyToClipboardEMF (ScilabGC);
00478                                                         }
00479                                                         else
00480                                                         {
00481                                                                 CopyToClipboardBitmap (ScilabGC);
00482                                                         }
00483 
00484                                                         m1=0;
00485                                                         n1=0;
00486                                                         l1=0;
00487                                                         CreateVar(1,"d",  &m1, &n1, &l1);
00488                                                         LhsVar(1)=1;
00489                                                         C2F(putlhsvar)();       
00490                                                         return 0;
00491                                                 }
00492                                                 else
00493                                                 {
00494                                                         Scierror(999,"Invalid Windows number.");
00495                                                         return 0;
00496                                                 }
00497                                         }
00498                                         else
00499                                         {
00500                                                 Scierror(999,"parameter must be >= 0.");
00501                                                 return 0;
00502                                         }
00503                                 }
00504                                 else
00505                                 {
00506                                         Scierror(999,"Second parameter must be 'EMF' or 'DIB'.");
00507                                         return 0;
00508                                 }
00509                         }
00510                 }
00511                 else
00512                 {
00513                         Scierror(999,"Incorrect parameters. See : help clipboard");
00514                         return 0;       
00515                 }
00516         }
00517         else
00518         {
00519                 if ( (Rhs == 2) && (IsAScalar(1)) && (GetType(2)==sci_strings) )
00520                 {
00521                         GetRhsVar(2,"c",&m1,&n1,&l1);
00522                         param2=cstk(l1);
00523                         if ( ( strcmp(param2,"EMF") == 0 ) || ( strcmp(param2,"DIB") == 0 ) )
00524                         {
00525                                 int num_win=-2;
00526                                 GetRhsVar(1,"i",&m1,&n1,&l1);
00527                                 num_win=*istk(l1);
00528                                 if (num_win>=0)
00529                                 {
00530                                         struct BCG *ScilabGC=NULL;
00531                                         ScilabGC = getWindowXgcNumber (num_win);
00532 
00533                                         if (ScilabGC)
00534                                         {
00535                                                 if ( strcmp(param2,"EMF") == 0 )
00536                                                 {
00537                                                         CopyToClipboardEMF (ScilabGC);
00538                                                 }
00539                                                 else
00540                                                 {
00541                                                         CopyToClipboardBitmap (ScilabGC);
00542                                                 }
00543 
00544                                                 m1=0;
00545                                                 n1=0;
00546                                                 l1=0;
00547                                                 CreateVar(1,"d",  &m1, &n1, &l1);
00548                                                 LhsVar(1)=1;
00549                                                 C2F(putlhsvar)();       
00550                                                 return 0;
00551                                         }
00552                                         else
00553                                         {
00554                                                 Scierror(999,"Invalid Windows number.");
00555                                                 return 0;
00556                                         }
00557                                 }
00558                                 else
00559                                 {
00560                                         Scierror(999,"parameter must be >= 0.");
00561                                         return 0;
00562                                 }
00563                         }
00564                         else
00565                         {
00566                                 Scierror(999,"Second parameter must be 'EMF' or 'DIB'.");
00567                                 return 0;
00568                         }
00569                 }
00570                 else
00571                 {
00572                         Scierror(999,MSG_ERROR10);
00573                         return 0;
00574                 }
00575                 Scierror(999,MSG_ERROR10);
00576                 return 0;
00577         }
00578         return 0;
00579 
00580  // static int l1,n1,m1;
00581 
00582  // char *param1=NULL,*param2=NULL,*param3=NULL;
00583 
00584  // Rhs=Max(0,Rhs);
00585  // CheckRhs(0,2);
00586  // CheckLhs(0,1);
00587 
00588  // if ( IsWindowInterface() )
00589  // {
00590         //if (Rhs == 1)
00591         //{
00592         //  GetRhsVar(1,"c",&m1,&n1,&l1);
00593         //  param1=cstk(l1);
00594 
00595         //  if ( ( strcmp(param1,"paste") == 0 ) || ( strcmp(param1,"pastespecial") == 0 ) )
00596         //  {
00597         //        char *output=NULL ;
00598         //        LPTW lptw=GetTextWinScilab();
00599 
00600         //        output=GetTextFromClipboard(lptw);
00601 
00602         //        if (output)
00603         //        {
00604         //                CreateVarFromPtr( 1, "c",(m1=strlen(output), &m1),&n1,&output);
00605         //                FREE(output);
00606         //                LhsVar(1)=1;
00607         //        }
00608         //        else
00609         //        {
00610         //                m1=0;
00611         //                n1=0;
00612         //                l1=0;
00613         //                CreateVar(1,"d",  &m1, &n1, &l1);
00614         //                LhsVar(1)=1;
00615         //        }
00616 
00617         //              C2F(putlhsvar)();       
00618         //              return 0;
00619         //  }
00620         //  else
00621         //  {
00622         //        Scierror(999,MSG_ERROR7);
00623         //        return 0;
00624         //  }
00625         //}
00626         //else
00627         //if (Rhs == 2)
00628         //{
00629         //      if (IsAScalar(1))
00630         //      {
00631         //              if (GetType(2)==sci_strings)
00632         //              {
00633         //                      GetRhsVar(2,"c",&m1,&n1,&l1);
00634         //                      param2=cstk(l1);
00635 
00636         //                      if ( ( strcmp(param2,"EMF") == 0 ) || ( strcmp(param2,"DIB") == 0 ) )
00637         //                      {
00638         //                              int num_win=-2;
00639         //                              GetRhsVar(1,"i",&m1,&n1,&l1);
00640         //                              num_win=*istk(l1);
00641 
00642         //                              if (num_win>=0)
00643         //                              {
00644         //                                      struct BCG *ScilabGC=NULL;
00645         //                                      ScilabGC = getWindowXgcNumber (num_win);
00646 
00647         //                                      if (ScilabGC)
00648         //                                      {
00649         //                                              if ( strcmp(param2,"EMF") == 0 )
00650         //                                              {
00651         //                                                      CopyToClipboardEMF (ScilabGC);
00652         //                                              }
00653         //                                              else
00654         //                                              {
00655         //                                                      CopyToClipboardBitmap (ScilabGC);
00656         //                                              }
00657         //                                      }
00658         //                                      else
00659         //                                      {
00660         //                                              Scierror(999,"Invalid Windows number.");
00661         //                                              return 0;
00662         //                                      }
00663         //                              }
00664         //                              else
00665         //                              {
00666         //                                      Scierror(999,"parameter must be >= 0.");
00667         //                                      return 0;
00668         //                              }
00669         //                      }
00670         //                      else
00671         //                      {
00672         //                              Scierror(999,"Second parameter must be 'EMF' or 'DIB'.");
00673         //                              return 0;
00674         //                      }
00675         //              }
00676         //              else
00677         //              {
00678         //                      Scierror(999,"Second parameter must be 'EMF' or 'DIB'.");
00679         //                      return 0;
00680         //              }
00681         //      }
00682         //      else
00683         //      if ( (GetType(1)==sci_strings) && (GetType(2)==sci_strings) )
00684         //      {
00685         //              GetRhsVar(1,"c",&m1,&n1,&l1);
00686         //              param1=cstk(l1);
00687 
00688         //              if ( strcmp(param1,"do") == 0 )
00689         //              {
00690         //                      GetRhsVar(2,"c",&m1,&n1,&l1);
00691         //                      param2=cstk(l1);
00692 
00693         //                      if ( strcmp(param2,"paste") == 0 )
00694         //                      {
00695         //                              Callback_PASTE();
00696         //                      }
00697         //                      else
00698         //                      if ( strcmp(param2,"copy") == 0 )
00699         //                      {
00700         //                              Callback_MCOPY();
00701         //                      }
00702         //                      else
00703         //                      if ( strcmp(param2,"empty") == 0 )
00704         //                      {
00705         //                              Callback_EMPTYCLIPBOARD();
00706         //                      }
00707         //                      else
00708         //                      {
00709         //                              Scierror(999,"Incorrect second parameter.");
00710         //                              return 0;
00711         //                      }
00712         //              }
00713         //              else
00714         //              if ( strcmp(param1,"copy") == 0 )
00715         //              {
00716         //                      char *TextToPutInClipboard=NULL;
00717         //                      char **Str=NULL;
00718         //                      LPTW lptw=GetTextWinScilab();
00719         //                      
00720         //                      GetRhsVar(2,"S",&m1,&n1,&Str);
00721 
00722         //                      if ( (m1==1) && (n1==1) )
00723         //                      {
00724         //                              TextToPutInClipboard=Str[0];
00725         //                              PutTextInClipboard(lptw,TextToPutInClipboard);
00726         //                      }
00727         //                      else
00728         //                      {
00729         //                              int i=0;
00730         //                              int j=0;
00731         //                              int l=0;
00732         //                              char *TextToSendInClipboard=NULL;
00733         //                              int SizeofTextToSendInClipboard=0;
00734         //                              char **buffer = (char**)MALLOC( (m1*n1)*sizeof(char *) );
00735         //                      
00736         //                              for (i=0; i<m1; i++) for (j=0; j<n1; j++) 
00737         //                              {
00738         //                                      SizeofTextToSendInClipboard=SizeofTextToSendInClipboard+strlen(Str[j*m1+i])+strlen(" \n");
00739         //                                      buffer[i*n1+j]=(char*)MALLOC(strlen(Str[j*m1+i]));
00740         //                                      sprintf(buffer[i*n1+j],"%s",Str[j*m1+i]);
00741         //                              }
00742 
00743         //                              TextToSendInClipboard=(char*)MALLOC( (SizeofTextToSendInClipboard)*sizeof(char) );
00744         //                              strcpy(TextToSendInClipboard,"");
00745 
00746         //                              for (i=0; i<m1; i++)
00747         //                              {
00748         //                                      for (j=0; j<n1; j++) 
00749         //                                      {
00750         //                                              strcat(TextToSendInClipboard,buffer[l++]);
00751         //                                              strcat(TextToSendInClipboard," ");
00752         //                                      }
00753         //                                      if ( i != (m1-1) ) strcat(TextToSendInClipboard,"\n");
00754         //                              }
00755         //                              PutTextInClipboard(lptw,TextToSendInClipboard);
00756 
00757         //                              if (buffer)
00758         //                              {
00759         //                                      for(i=0;i<m1*n1;i++) if (buffer[i]) {free(buffer[i]);buffer[i]=NULL;}
00760         //                                      FREE(buffer);buffer=NULL;
00761         //                              }
00762 
00763         //                              if(TextToSendInClipboard) {FREE(TextToSendInClipboard);TextToSendInClipboard=NULL;}
00764         //                      }
00765         //              }
00766         //              else
00767         //              {
00768         //                      Scierror(999,MSG_ERROR9);
00769         //                      return 0;
00770         //              }
00771         //      }
00772         //      else
00773         //      {
00774         //              Scierror(999,"Incorrect parameters. See : help clipboard");
00775         //              return 0;
00776         //      }
00777  //   LhsVar(1)=0;
00778         //      C2F(putlhsvar)();       
00779         //}
00780  // }
00781  // else
00782  // {
00783         //  if ( IsAScalar(1) && (Rhs == 2) )
00784         //  {
00785         //        if (GetType(2)==sci_strings)
00786         //        {
00787         //                GetRhsVar(2,"c",&m1,&n1,&l1);
00788         //                param2=cstk(l1);
00789 
00790         //                if ( ( strcmp(param2,"EMF") == 0 ) || ( strcmp(param2,"DIB") == 0 ) )
00791         //                {
00792         //                        int num_win=-2;
00793         //                        GetRhsVar(1,"i",&m1,&n1,&l1);
00794         //                        num_win=*istk(l1);
00795 
00796         //                        if (num_win>=0)
00797         //                        {
00798         //                                struct BCG *ScilabGC=NULL;
00799         //                                ScilabGC = GetWindowXgcNumber (num_win);
00800 
00801         //                                if (ScilabGC)
00802         //                                {
00803         //                                        if ( strcmp(param2,"EMF") == 0 )
00804         //                                        {
00805         //                                                CopyToClipboardEMF (ScilabGC);
00806         //                                        }
00807         //                                        else
00808         //                                        {
00809         //                                                CopyToClipboardBitmap (ScilabGC);
00810         //                                        }
00811         //                                }
00812         //                                else
00813         //                                {
00814         //                                        Scierror(999,"Invalid Windows number.");
00815         //                                        return 0;
00816         //                                }
00817         //                        }
00818         //                        else
00819         //                        {
00820         //                                Scierror(999,"parameter must be >= 0.");
00821         //                                return 0;
00822         //                        }
00823         //                }
00824         //                else
00825         //                {
00826         //                        Scierror(999,"Second parameter must be 'EMF' or 'DIB'.");
00827         //                        return 0;
00828         //                }
00829         //        }
00830         //        else
00831         //        {
00832         //                Scierror(999,"Second parameter must be 'EMF' or 'DIB'.");
00833         //                return 0;
00834         //        }
00835         //              LhsVar(1)=0;
00836         //              C2F(putlhsvar)();       
00837         //  }
00838         //  else
00839         //  {
00840         //        Scierror(999,MSG_ERROR10);
00841         //        return 0;
00842         //  }
00843  // }
00844  // return 0;
00845 }

Here is the call graph for this function:

Here is the caller graph for this function:

int IsAScalar ( int  RhsNumber  ) 

Definition at line 11 of file IsAScalar.c.

00012 {
00013         int bOK=0;
00014 
00015         if ( GetType(RhsNumber) == sci_matrix )
00016         {
00017                 static int l1,n1,m1;
00018                 GetRhsVar(RhsNumber,"d",&m1,&n1,&l1);
00019                 if ( (m1 == 1) && (n1 == 1) )
00020                 {
00021                         bOK=1;
00022                 }
00023         }
00024         return bOK;
00025 }

BOOL IsEmptyClipboard ( LPTW  lptw  ) 

Definition at line 167 of file clipboard.c.

References FALSE, hdc, tagTW::hfont, tagTW::hWndText, NULL, TEXTMETRIC, TRUE, TryToGetDC(), type, and UINT.

Referenced by Callback_PASTE(), and ON_WND_TEXT_WM_RBUTTONDOWN().

00169 {
00170         BOOL Retour=TRUE;
00171         HDC hdc;
00172         HGLOBAL hGMem;
00173         TEXTMETRIC tm;
00174         UINT type;
00175         LPSTR lpMem=NULL; /* Pointeur sur la chaine du clipboard */
00176         
00177 
00178         /* find out what type to get from clipboard */
00179         hdc = (HDC)TryToGetDC (lptw->hWndText);
00180         SelectObject(hdc, lptw->hfont);
00181         GetTextMetrics(hdc,(TEXTMETRIC FAR *)&tm);
00182         if (tm.tmCharSet == OEM_CHARSET) type = CF_OEMTEXT;
00183         else type = CF_TEXT;
00184         ReleaseDC (lptw->hWndText, hdc);
00185         
00186         /* now get it from clipboard */
00187         OpenClipboard (lptw->hWndText);
00188         hGMem = GetClipboardData (type);
00189         
00190         if (hGMem)
00191                 {
00192                         lpMem  = GlobalLock( hGMem );
00193                         if (lpMem==NULL) Retour=TRUE;
00194                         else Retour=FALSE;
00195                         GlobalUnlock (hGMem);
00196                 }
00197         CloseClipboard ();
00198         
00199         return Retour;
00200 }

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL IsReadyForAnewLign ( void   ) 

Definition at line 39 of file clipboard.c.

References ReadyForAnewLign.

Referenced by SendInputText().

00040 {
00041         return ReadyForAnewLign;
00042 }

Here is the caller graph for this function:

void PasteFunction ( LPTW  lptw,
BOOL  special 
)

Definition at line 132 of file clipboard.c.

References hdc, tagTW::hfont, tagTW::hWndText, SpecialPaste, TEXTMETRIC, ThreadPasteRunning, TryToGetDC(), type, and UINT.

Referenced by Callback_PASTE(), ON_WND_TEXT_WM_COMMAND(), and ON_WND_TEXT_WM_MBUTTONUP().

00138 {
00139         HDC hdc;
00140         HGLOBAL hGMem;
00141         TEXTMETRIC tm;
00142         UINT type;
00143         LPSTR lpMem; /* Pointeur sur la chaine du clipboard */
00144         
00145         SpecialPaste=special;   
00146         /* find out what type to get from clipboard */
00147         hdc = (HDC)TryToGetDC (lptw->hWndText);
00148         SelectObject(hdc, lptw->hfont);
00149         GetTextMetrics(hdc,(TEXTMETRIC FAR *)&tm);
00150         if (tm.tmCharSet == OEM_CHARSET) type = CF_OEMTEXT;
00151         else type = CF_TEXT;
00152         ReleaseDC (lptw->hWndText, hdc);
00153         
00154         /* now get it from clipboard */
00155         OpenClipboard (lptw->hWndText);
00156         hGMem = GetClipboardData (type);
00157         
00158         if (hGMem)
00159                 {
00160                         lpMem  = GlobalLock( hGMem );
00161                         if (!ThreadPasteRunning) SendMessage(lptw->hWndText, WM_SETTEXT, 0,(LPARAM) lpMem);
00162                         GlobalUnlock (hGMem);
00163                 }
00164         CloseClipboard ();
00165 }

Here is the call graph for this function:

Here is the caller graph for this function:

void PutTextInClipboard ( LPTW  lptw,
char *  Text 
)

Definition at line 882 of file clipboard.c.

References hdc, tagTW::hfont, tagTW::hWndParent, tagTW::hWndText, NULL, size, TEXTMETRIC, TryToGetDC(), type, and UINT.

Referenced by InterfaceWindowsClipboard().

00883 {
00884         int size;
00885         HGLOBAL hGMem;
00886         LPSTR cbuf;
00887         
00888         TEXTMETRIC tm;
00889         UINT type;
00890         HDC hdc;
00891 
00892         size=strlen(Text)+1;
00893 
00894         hGMem = GlobalAlloc(GMEM_MOVEABLE, (DWORD)size);
00895         cbuf = (LPSTR)GlobalLock(hGMem);
00896         if (cbuf == (LPSTR)NULL) return;
00897         strcpy(cbuf,Text);
00898 
00899         /* find out what type to put into clipboard */
00900         hdc = (HDC)TryToGetDC(lptw->hWndText);
00901         SelectObject(hdc, lptw->hfont);
00902         GetTextMetrics(hdc,(TEXTMETRIC FAR *)&tm);
00903         if (tm.tmCharSet == OEM_CHARSET)
00904                 type = CF_OEMTEXT;
00905         else
00906                 type = CF_TEXT;
00907         ReleaseDC(lptw->hWndText, hdc);
00908 
00909         /* give buffer to clipboard */
00910         OpenClipboard(lptw->hWndParent);
00911         EmptyClipboard();
00912         SetClipboardData(type, hGMem);
00913         CloseClipboard();
00914 }

Here is the call graph for this function:

Here is the caller graph for this function:

DWORD WINAPI SendInputText ( LPVOID  lpParam  ) 

Definition at line 49 of file clipboard.c.

References tagTW::bGetCh, C2F, count, FALSE, FREE, GetTextWinScilab(), hThreadPaste, i, ismenu(), IsReadyForAnewLign(), tagTW::KeyBuf, tagTW::KeyBufIn, tagTW::KeyBufOut, tagTW::KeyBufSize, MALLOC, NULL, PasteForThread, SetReadyOrNotForAnewLign(), TEMPOTOUCHE, ThreadPasteRunning, and TRUE.

Referenced by CreateThreadPaste().

00051 {
00052         #define TEMPOTOUCHE  1
00053         int lg=0;
00054         int i=0;
00055         
00056         char *TextToSend=NULL;
00057         
00058         LPTW lptw=GetTextWinScilab();
00059         
00060         ThreadPasteRunning=TRUE;
00061         
00062         lg=strlen((char*)PasteForThread)+1;
00063         TextToSend=(char*)MALLOC(lg*sizeof(char));
00064         strcpy(TextToSend,(char*)PasteForThread);
00065         TextToSend[strlen(TextToSend)]='\0';
00066 
00067         FREE(PasteForThread);
00068         PasteForThread=NULL;
00069 
00070         //if (SpecialPaste==TRUE)CleanPromptFromText(TextToSend); /* Desactiver pour le moment */
00071                 
00072         while ( C2F (ismenu) () == 1 ) {Sleep(TEMPOTOUCHE);}
00073         /* Il n'y a plus rien dans la queue des commandes */
00074         while ( lptw->bGetCh == FALSE ) {Sleep(TEMPOTOUCHE);}
00075         /* Nous sommes au prompt */
00076         
00077         
00078         lg=strlen(TextToSend);
00079         i=0;
00080         while(i<lg)
00081         {
00082                 long count;
00083                 
00084                 
00085                 count = lptw->KeyBufIn - lptw->KeyBufOut;
00086                         
00087                 if (count < 0) count = count+lptw->KeyBufSize;
00088                 if (count < (long) (lptw->KeyBufSize-1)) 
00089                         {
00090                                 if (TextToSend[i] == '\t') *lptw->KeyBufIn++ = ' ';
00091                                 else *lptw->KeyBufIn++ = TextToSend[i];
00092                                 if (lptw->KeyBufIn - lptw->KeyBuf >= (signed)lptw->KeyBufSize)
00093                                 lptw->KeyBufIn = lptw->KeyBuf;  /* wrap around */
00094                         }
00095         
00096                 if (TextToSend[i]==10) 
00097                         {
00098                                 /* LF not preceded by a CR */
00099                                 /* fool it: turn LF into CR */
00100                                 /* Bug 1960 corrected - Francois VOGEL June 2006 */
00101                                 *lptw->KeyBufIn = 13;
00102                                 SetReadyOrNotForAnewLign(FALSE);
00103                                 while ( IsReadyForAnewLign() == FALSE ) {Sleep(TEMPOTOUCHE);}
00104                                 while ( C2F (ismenu) () == 1 ) {Sleep(TEMPOTOUCHE);}
00105                                 while ( lptw->bGetCh == FALSE ) {Sleep(TEMPOTOUCHE);}
00106                         }
00107                 if (TextToSend[i]==13) 
00108                         {
00109                                 SetReadyOrNotForAnewLign(FALSE);
00110                                 while ( IsReadyForAnewLign() == FALSE ) {Sleep(TEMPOTOUCHE);}
00111                                 while ( C2F (ismenu) () == 1 ) {Sleep(TEMPOTOUCHE);}
00112                                 while ( lptw->bGetCh == FALSE ) {Sleep(TEMPOTOUCHE);}
00113                                 if (i<lg-1)
00114                                 {
00115                                         /* skip LF that follows CR*/
00116                                         if (TextToSend[i+1]==10) i++;
00117                                 }
00118                         }
00119                 i++;    
00120                 
00121         }
00122 
00123         
00124         FREE(TextToSend);
00125         TextToSend=NULL;
00126         ThreadPasteRunning=FALSE;
00127         CloseHandle( hThreadPaste );
00128         
00129         return 0;       
00130 }

Here is the call graph for this function:

Here is the caller graph for this function:

void SetReadyOrNotForAnewLign ( BOOL  Ready  ) 

Definition at line 44 of file clipboard.c.

References ReadyForAnewLign.

Referenced by SendInputText(), and zzledt().

00045 {
00046         ReadyForAnewLign=Ready;
00047 }

Here is the caller graph for this function:

void SetThreadPasteRunning ( BOOL  Running  ) 

Definition at line 301 of file clipboard.c.

References ThreadPasteRunning.

Referenced by ExitWindow().

00302 {
00303         ThreadPasteRunning=Running;
00304 }

Here is the caller graph for this function:

void TextCopyClip ( LPTW  lptw  ) 

Definition at line 206 of file clipboard.c.

References count, hdc, tagTW::MarkBegin, tagTW::MarkEnd, NULL, pt, tagTW::ScreenBuffer, tagTW::ScreenSize, size, TEXTMETRIC, type, and UINT.

Referenced by Callback_MCOPY(), Callback_PRINT(), CtrlCHit(), EvaluateSelection(), HelpOn(), ON_WND_TEXT_WM_COMMAND(), ON_WND_TEXT_WM_KEY(), OpenSelection(), and TextGetCh().

00207 {
00208         int size, count;
00209         HGLOBAL hGMem;
00210         LPSTR cbuf, cp;
00211         POINT pt, end;
00212         TEXTMETRIC tm;
00213         UINT type;
00214         HDC hdc;
00215 
00216         if ((lptw->MarkBegin.x == lptw->MarkEnd.x) && 
00217             (lptw->MarkBegin.y == lptw->MarkEnd.y) ) {
00218                 /* copy user text */
00219                 return;
00220         }
00221 
00222         size = (lptw->MarkEnd.y - lptw->MarkBegin.y + 1) 
00223                 * (lptw->ScreenSize.x + 2) + 1;
00224         hGMem = GlobalAlloc(GMEM_MOVEABLE, (DWORD)size);
00225         cbuf = cp = (LPSTR)GlobalLock(hGMem);
00226         if (cp == (LPSTR)NULL)
00227                 return;
00228         
00229         pt.x = lptw->MarkBegin.x;
00230         pt.y = lptw->MarkBegin.y;
00231         end.x   = lptw->MarkEnd.x;
00232         end.y   = lptw->MarkEnd.y;
00233 
00234         while (pt.y < end.y) {
00235                 /* copy to global buffer */
00236                 count = lptw->ScreenSize.x - pt.x;
00237                 _fmemcpy(cp, lptw->ScreenBuffer + lptw->ScreenSize.x*pt.y+pt.x, count);
00238                 /* remove trailing spaces */
00239                 for (count=count-1; count>=0; count--) {
00240                         if (cp[count]!=' ')
00241                                 break;
00242                         cp[count] = '\0';
00243                 }
00244                 cp[++count] = '\r';
00245                 cp[++count] = '\n';
00246                 cp[++count] = '\0';
00247                 cp += count;
00248                 pt.y++;
00249                 pt.x=0;
00250         }
00251         /* partial line */
00252         count = end.x - pt.x;
00253         if (end.y != lptw->ScreenSize.y) {
00254                 _fmemcpy(cp, lptw->ScreenBuffer + lptw->ScreenSize.x*pt.y+pt.x, count);
00255                 cp[count] = '\0';
00256         }
00257         size = _fstrlen(cbuf) + 1;
00258         GlobalUnlock(hGMem);
00259         hGMem = GlobalReAlloc(hGMem, (DWORD)size, GMEM_MOVEABLE);
00260         /* find out what type to put into clipboard */
00261         hdc = (HDC)TryToGetDC(lptw->hWndText);
00262         SelectObject(hdc, lptw->hfont);
00263         GetTextMetrics(hdc,(TEXTMETRIC FAR *)&tm);
00264         if (tm.tmCharSet == OEM_CHARSET)
00265                 type = CF_OEMTEXT;
00266         else
00267                 type = CF_TEXT;
00268         ReleaseDC(lptw->hWndText, hdc);
00269         /* give buffer to clipboard */
00270         OpenClipboard(lptw->hWndParent);
00271         EmptyClipboard();
00272         SetClipboardData(type, hGMem);
00273         CloseClipboard();
00274 }

Here is the caller graph for this function:

HDC TryToGetDC ( HWND  hWnd  ) 

Definition at line 11 of file TryToGetDC.c.

Referenced by CopyPrint(), CopyToClipboardBitmap(), CopyToClipboardEMF(), ExportBMP(), ExportEMF(), GetTextFromClipboard(), HwndToBmpFile(), IsEmptyClipboard(), LoadMacros(), MaybeSetWinhdc(), ON_WND_TEXT_WM_CREATE(), PasteFunction(), PrintSelection(), PutTextInClipboard(), sci_pixmap_resize(), ScilabGResize(), setcolormapg(), SetGHdc(), setpixmapOn(), SetWinhdc(), and show().

00012 {
00013         HDC hDCRet=NULL;
00014 
00015         if (hWnd)
00016         {
00017                 hDCRet=GetDC(hWnd);
00018                 if (hDCRet == NULL)
00019                 {
00020 #ifdef _DEBUG
00021                         MessageBox(NULL,MSG_ERROR36,MSG_ERROR20,MB_ICONWARNING);
00022 #endif
00023                 }
00024         }
00025         else
00026         {
00027 #ifdef _DEBUG
00028                 MessageBox(NULL,MSG_ERROR37,MSG_ERROR20,MB_ICONWARNING);
00029 #endif
00030         }
00031 
00032         return (HDC)hDCRet;
00033 }

Here is the caller graph for this function:


Variable Documentation

HANDLE hThreadPaste [static]

Definition at line 13 of file clipboard.c.

Referenced by CleanClipboard(), CreateThreadPaste(), GetHandleThreadPaste(), and SendInputText().

char* PasteForThread = NULL [static]

Definition at line 14 of file clipboard.c.

Referenced by CreateThreadPaste(), and SendInputText().

BOOL ReadyForAnewLign = FALSE [static]

Definition at line 16 of file clipboard.c.

Referenced by IsReadyForAnewLign(), and SetReadyOrNotForAnewLign().

BOOL SpecialPaste = FALSE [static]

Definition at line 22 of file clipboard.c.

Referenced by PasteFunction().

BOOL ThreadPasteRunning = FALSE [static]

Definition at line 12 of file clipboard.c.

Referenced by CleanClipboard(), GetThreadPasteRunning(), PasteFunction(), SendInputText(), and SetThreadPasteRunning().


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