예제 #1
0
파일: listc.c 프로젝트: CivilPol/sdcboot
// write the file (or pipe) to another file
static void _near ListSaveFile( void )
{
	int i, nFH, nMode;
	long lTemp;
	POPWINDOWPTR wn;
	TCHAR szBuffer[ MAXLISTLINE+1 ];
	
	// disable ^C / ^BREAK handling
	HoldSignals();
	
	wn = wOpen( 2, 1, 4, GetScrCols() - 2, nInverse, LIST_SAVE_TITLE, NULL );
	wn->nAttrib = nNormal;
	wClear();
	wWriteListStr( 0, 1, wn, LIST_QUERY_SAVE );
	egets( szBuffer, MAXFILENAME, EDIT_DATA | EDIT_BIOS_KEY );
	
	if ( szBuffer[0] ) {
		
		// save start position
		lTemp = LFile.lViewPtr;
		
		nMode = _O_BINARY;
		
		if (( nFH = _sopen( szBuffer, ( nMode | _O_WRONLY | _O_CREAT | _O_TRUNC ), _SH_DENYNO, _S_IWRITE | _S_IREAD )) >= 0 ) {
			
			// reset to beginning of file

				ListSetCurrent( 0L );
			
			do {
				
				for ( i = 0; ( i < MAXLISTLINE ); i++ ) {
					
					// don't call GetNextChar unless absolutely necessary
					if ( LFile.lpCurrent == LFile.lpEOF )
						break;

					szBuffer[i] = (TCHAR)GetNextChar();
				}

				szBuffer[i] = _TEXT('\0');
				
			} while (( i > 0 ) && ( wwrite( nFH, szBuffer, i ) > 0 ));
			
			_close( nFH );
			
			// restore start position
			LFile.lViewPtr = lTemp;
			ListSetCurrent( LFile.lViewPtr );
			
		} else
			honk();
	}
	
	wRemove( wn );
	
	// enable ^C / ^BREAK handling
	EnableSignals();
}
예제 #2
0
파일: PRINTPRO.C 프로젝트: Inzaghi2012/EZP
unsigned long PrP1(HWND Window,HMSG Message,long Param1,long Param2)
{
    int i;
    char str[10];
    int hlist;

    if (Message==WINDOWINIT)
    {   
        PrintCutWin[1]=Window;
        if (InitOver)
        {
            MessageGo(Window,LISTSETITEMHEIGHT,16,0);
            MessageGo(Window,LISTSETITEMLENGTH,7,0);
            MessageGo(Window,LISTDELETEALL,0L,0L);
            for (i=PG.Blocks-1;i>=0;i--)
             {
              sprintf(str,"BBNN%d",i+1);
              MessageGo(Window, LISTINSERTITEM, FP2LONG(str), 0L);
             }
        
            if (PG.Blocks>0)
                SetPrintPara();
            return TRUE;
        }
    }

    if (Message==LISTBOXCONFIRM||Message==ITEMSELECT)
    {
        hlist = WindowList(Window);
        GetPrintPara();
        CurrentBlock=ListGetCurrent(hlist);
        SetPrintPara();

        i=ListGetTop(hlist);
        MessageGo(Window,WINDOWINIT,0l,0l);
        MessageGo(Window,WMPAINT,0,ListGetHeight(hlist)*CHARHEIGHT);
        ListSetTop(hlist,i);
        ListSetCurrent(hlist,CurrentBlock);
        MessageGo(Window,REDRAWMESSAGE,0L,
                MAKELONG(WindowGetWidth(Window),
                WindowGetHeight(Window)) );
        REFLASH;
        return TRUE;
    }

    return(ListBoxDefaultProcedure(Window,Message,Param1,Param2));
}
예제 #3
0
파일: LISTBOXC.C 프로젝트: Inzaghi2012/EZP
long ListBoxDefaultProcedure(HWND Window,HMSG Message,long Param1,long Param2)
{
  struct viewporttype TmpViewPort;
  int  i,Length,key;
  HWND MidWindow;
  int  DisplayItem;
  int DisplayWidth;
  char MidString[100];
  int Left,Top,Right,Bottom;
  int SaveColor;

  switch (Message)
  {
    case WINDOWQUIT:
         ListHandleFree();
         break;
    case KEYSTRING:
         break;
    case KEYDOWN:
         switch (MAKELO(Param1))
         {
           case HOME:
                Param2=ListGetCurrent(WindowList(Window));
                goto lbl_upward;
           case PGUP:
                Param2=ListGetHeight(WindowList(Window));
                goto lbl_upward;
           case UP:
                Param2=1;
           lbl_upward:
                Length=Param2;
                if (ListGetCurrent(WindowList(Window))-Length<0)
                   Length=ListGetCurrent(WindowList(Window));
                if (!Length)
                {
                   //Alarm();
                   break;
                }
                Length=-Length;
                goto lbl_process_up_down;
           case END:
                Param2=ListGetTotal(WindowList(Window))-1
                          -ListGetCurrent(WindowList(Window));
                goto lbl_downward;
           case PGDN:
                Param2=ListGetHeight(WindowList(Window));
                goto lbl_downward;
           case DOWN:
                Param2=1;
            lbl_downward:
                Length=Param2;
                if (ListGetCurrent(WindowList(Window))+Length>=
                    ListGetTotal(WindowList(Window))-1)
                   Length=ListGetTotal(WindowList(Window))-1
                          -ListGetCurrent(WindowList(Window));
                if (!Length)
                {
                   // Alarm();
                   break;
                }

             lbl_process_up_down:
                ListIncCurrent(WindowList(Window),Length);
                MessageInsert(Window,ITEMSELECT,
                              ListGetCurrent(WindowList(Window)),Window);

              #ifdef USE_SCROLL
                MidWindow=GetVVScroll(Window);
                if (MidWindow)
                {
                   i=WindowGetHeight(Window)-3*SYSSCROLLWIDTH-2;
                   i*=ListGetCurrent(WindowList(Window));
                   // i/=ListGetTotal(WindowList(Window));
                   i/=ListGetTotal(WindowList(Window))-1;
                   i=i-WindowGetTop(MidWindow)+SYSSCROLLWIDTH;
                //*------
                   if(WindowGetBottom(MidWindow)+i>
                   WindowGetHeight(WindowGetFather(MidWindow))-2-SYSSCROLLWIDTH)
                        i=WindowGetHeight(WindowGetFather(MidWindow))-2
                            -SYSSCROLLWIDTH-WindowGetBottom(MidWindow);
                //--------------------------*/

                   MessageInsert(MidWindow,WINDOWMOVE,0l,i);
                }
              #endif

                if (!ListVScroll(Window))
                {
                   DisplayItem=ListGetCurrent(WindowList(Window))
                               -ListGetTop(WindowList(Window));
                   // MessageInsert(Window,WMPAINT,MAKELONG(0,
                   MessageInsert(Window,REDRAWMESSAGE,MAKELONG(0,
                                 (DisplayItem-Length)*CHARHEIGHT),
                                 MAKELONG(0,(DisplayItem-Length+1))*CHARHEIGHT);
                   // MessageInsert(Window,WMPAINT,MAKELONG(0,DisplayItem*CHARHEIGHT),
                   MessageInsert(Window,REDRAWMESSAGE,MAKELONG(0,DisplayItem*CHARHEIGHT),
                                 MAKELONG(0,(DisplayItem+1)*CHARHEIGHT));
                }
                break;
           case TAB:
                WindowTableOrderNext(Window);
                break;
           case SHIFT_TAB:
                WindowTableOrderPrev(Window);
                break;
           case ENTER:
           #ifdef USE_SCROLL
                if (!WindowIsChildless(Window))
                   MessageGo(WindowGetChild(Window),WINDOWCLOSE,0l,0l);
           #endif
                MessageInsert(Window,LISTBOXCONFIRM,0L,0L);
                break;
           case ESC:
           #ifdef USE_SCROLL            // Added ByHance, 96,4.2
                if (!WindowIsChildless(Window))
                   MessageGo(WindowGetChild(Window),WINDOWCLOSE,0l,0l);
           #endif
                MessageInsert(WindowGetFather(Window),Message,Param1,Param2);
                break;
           default:
                key=MAKELO(Param1);
                key=toupper(key);
                if(key>='A' && key<='Z')
                {                       // quick select FirstLetterItem
                  for(i=0;i<ListGetTotal(WindowList(Window));i++)
                  {
                    int ch;
                    char *str;
                    str=ListGetItem( WindowList(Window),i ),
                    ch=toupper(str[0]);
                    if(ch>=key) break;
                  }
                  if( i>=ListGetTotal(WindowList(Window)) )
                      i=ListGetTotal(WindowList(Window))-1;  //the last

                  Param2=i-ListGetCurrent(WindowList(Window));
                  goto lbl_downward;
                }
                break;
         }
         break;
    case MOUSELEFTDOWN:
         //key=ListGetCurrent(WindowList(Window));

         if (MAKELO(Param1)/CHARHEIGHT!=ListGetCurrent(WindowList(Window))
                                        -ListGetTop(WindowList(Window))
             &&MAKELO(Param1)/CHARHEIGHT<ListGetTotal(WindowList(Window))
             /*-ListGetHeight(WindowList(Window))*/)
         {
            if (ListGetCurrent(WindowList(Window)) >= ListGetTop(WindowList(Window))
            && ListGetCurrent(WindowList(Window)) <
                  ListGetTop(WindowList(Window))+ListGetHeight(WindowList(Window)))
               MessageGo(Window,WMPAINT,
                      MAKELONG(0,(ListGetCurrent(WindowList(Window))-
                          ListGetTop(WindowList(Window)))*CHARHEIGHT),
                      MAKELONG(0,(ListGetCurrent(WindowList(Window))+1-
                          ListGetTop(WindowList(Window)))*CHARHEIGHT));
            ListSetCurrent(WindowList(Window),MAKELO(Param1)/CHARHEIGHT
                           +ListGetTop(WindowList(Window)));

            if (WindowGetProcedure(WindowGetFather(Window))==(Function *)ComboDefaultProcedure)
               MessageInsert(WindowGetFather(Window),COMBOPULL,Param1,Param2);
            else
            {
               #ifdef USE_SCROLL
                 MidWindow=GetVVScroll(Window);
                 if (MidWindow)
                 {
                   i=WindowGetHeight(Window)-3*SYSSCROLLWIDTH-2;
                   i*=ListGetCurrent(WindowList(Window));
                   // i/=ListGetTotal(WindowList(Window));
                   i/=ListGetTotal(WindowList(Window))-1;
                   i=i-WindowGetTop(MidWindow)+SYSSCROLLWIDTH;
                //*------
                   if(WindowGetBottom(MidWindow)+i>
                   WindowGetHeight(WindowGetFather(MidWindow))-2-SYSSCROLLWIDTH)
                        i=WindowGetHeight(WindowGetFather(MidWindow))-2
                            -SYSSCROLLWIDTH-WindowGetBottom(MidWindow);
                //------*/

                   MessageGo(MidWindow,WINDOWMOVE,0l,i);
                 }
               #endif

               MessageGo(Window,WMPAINT,
                             MAKELONG(0,(ListGetCurrent(WindowList(Window))-
                                 ListGetTop(WindowList(Window)))*CHARHEIGHT),
                             MAKELONG(0,(ListGetCurrent(WindowList(Window))+1-
                                 ListGetTop(WindowList(Window)))*CHARHEIGHT));
            }
         }

         //if( key != ListGetCurrent(WindowList(Window)) )   // ByHance, 97,5.11
           MessageInsert(Window,ITEMSELECT,ListGetCurrent(WindowList(Window)),Window);
         break;
    case VVSCROLLMOVE:
         /*
         //i=Param1*ListGetTotal(WindowList(Window))
         i=Param1*(ListGetTotal(WindowList(Window))-1)
           /(WindowGetHeight(Window)-3*SYSSCROLLWIDTH-2) ;
         if(i<ListGetTop(WindowList(Window)) ||
          i>=ListGetTop(WindowList(Window))+ListGetHeight(WindowList(Window)) )
         {
            i=( ListGetTotal(WindowList(Window)) - 1 ) * Param1;
            i=0.5+(float)i/(WindowGetHeight(Window)-3*SYSSCROLLWIDTH-2);
            Length=ListGetTotal(WindowList(Window))
                  -ListGetHeight(WindowList(Window));
            if(i>Length) i=Length;

            ListSetTop(WindowList(Window),i);
            MessageInsert(Window,WMPAINT,0l,
                          ListGetHeight(WindowList(Window))*CHARHEIGHT);
         }
         */  // modi by zjh for smooth move 96.12.6
         {
            i=( ListGetTotal(WindowList(Window)) - 1 ) * Param1;
            i=0.5+(float)i/(WindowGetHeight(Window)-3*SYSSCROLLWIDTH-2);
            Length=ListGetTotal(WindowList(Window))-1;
            if(i>Length) i=Length;
            Length=(WindowGetHeight(Window)+0)/16;
            i=i-Length/2;
            if (i<0) i=0;
            if (i+Length>ListGetTotal(WindowList(Window))-1)
              i=ListGetTotal(WindowList(Window)) - 1-Length+1;
            if (i<0) i=0;

            if (i!=ListGetTop(WindowList(Window)))
            {
             ListSetTop(WindowList(Window),i);
             MessageInsert(Window,WMPAINT,0l,
                          ListGetHeight(WindowList(Window))*CHARHEIGHT);
            }
         }
         break;
    case MOUSELEFTDOUBLE:
         //MessageInsert(Window,LISTBOXCONFIRM,0L,0L);
         MessageInsert(Window,KEYDOWN,MAKELONG(0,ENTER),1l);
         break;
    case GETFOCUS:             // ByHance, 95,11.23
    case LOSTFOCUS:
         WindowDefaultProcedure(Window,Message,Param1,Param2);
         MidWindow=WindowGetFather(Window);
         if(MidWindow)     // has combo list
            if( WindowGetHeight(MidWindow)<=SYSBUTTONWIDTH+1) // not pull down
                 break;

         if(!ListGetTotal(WindowList(Window)))  // if no item, break
               break;

         MouseHidden();
         getviewsettings(&TmpViewPort);
         SaveColor=getcolor();

         WindowGetRealRect(Window,&Left,&Top,&Right,&Bottom);
         setviewport(Left+1,Top+1,Right-1,Bottom-1,1);

         DisplayWidth=ListGetItemLength(WindowList(Window))*CHARWIDTH/2;
         if (DisplayWidth<WindowGetWidth(Window))
            DisplayWidth=WindowGetWidth(Window);
         if (!WindowIsChildless(Window))
            DisplayWidth-=SYSSCROLLWIDTH+1+CHARWIDTH/2;   //by jerry
            //  DisplayWidth-=SYSSCROLLWIDTH+4;

         i=ListGetCurrent(WindowList(Window))-ListGetTop(WindowList(Window));
         i*=CHARHEIGHT;
         if(Message==GETFOCUS) {
            DisplayVirtualRect(3,i+1,2+DisplayWidth-1,i+CHARHEIGHT-1);
            //if(ListGetTotal(WindowList(Window))==1)
            if(fGetFocusByKey)      // ByHance, 97,5.11
              MessageInsert(Window,ITEMSELECT,ListGetCurrent(WindowList(Window)),Window);
         } else {               // LOSTFOCUS
             DisplayWidth/=CHARWIDTH/2;
             strncpy(MidString,
                 ListGetItem( WindowList(Window),ListGetCurrent(WindowList(Window)) ),
                 DisplayWidth);
             Length=strlen(MidString);
             if (Length<DisplayWidth)
                memset(MidString+Length,' ',DisplayWidth-Length);
             MidString[DisplayWidth]=0;
             ViewportDisplayString(MidString,2,i,LISTBKCOLOR,LISTCOLOR);
         }
         setviewport(TmpViewPort.left,TmpViewPort.top,TmpViewPort.right,
                TmpViewPort.bottom,TmpViewPort.clip);
         setcolor(SaveColor);
         MouseShow();
         break;
    case DRAWWINDOW:
         WindowDefaultProcedure(Window,Message,Param1,Param2);
    case WMPAINT:
         getviewsettings(&TmpViewPort);
         SaveColor=getcolor();
         MouseHidden();
         WindowGetRealRect(Window,&Left,&Top,&Right,&Bottom);
         setviewport(Left+1,Top+1,Right-1,Bottom-1,1);
         setfillstyle(1,EGA_WHITE);

         if (!WindowIsChildless(Window))
              Right-=SYSSCROLLWIDTH+10;      // ByHance, 96,3.24

         bar(0,0,Right-Left,Bottom-Top);      // clear area

         Param1 = 0;
         Param2 = Bottom-Top;

         DisplayWidth=ListGetItemLength(WindowList(Window))*CHARWIDTH/2;
         if (DisplayWidth<WindowGetWidth(Window))
            DisplayWidth=WindowGetWidth(Window);

         if (!WindowIsChildless(Window))
            DisplayWidth-=SYSSCROLLWIDTH+1+CHARWIDTH/2;           // by jerry
            //DisplayWidth-=SYSSCROLLWIDTH+4;

         DisplayWidth/=CHARWIDTH/2;

         for (i=MAKELO(Param1);i<MAKELO(Param2);i+=CHARHEIGHT)
         {
             if (i/CHARHEIGHT+ListGetTop(WindowList(Window))
                 >=ListGetTotal(WindowList(Window)))
                break;
             strncpy(MidString,ListGetItem(WindowList(Window),i/CHARHEIGHT
                     +ListGetTop(WindowList(Window))),DisplayWidth);
             Length=strlen(MidString);
             if (Length<DisplayWidth)
                memset(MidString+Length,' ',DisplayWidth-Length);
             MidString[DisplayWidth]=0;

             if (i/CHARHEIGHT==ListGetCurrent(WindowList(Window))
                               -ListGetTop(WindowList(Window)))
             {
                ViewportDisplayString(MidString,2,i,LISTBKCOLOR,LISTCOLOR);
                if (Window==ActiveWindow)               // ByHance
                     DisplayVirtualRect(3,i+1,
                            2+DisplayWidth*ASC16WIDTH-1,i+CHARHEIGHT-1);
             }
             else
                ViewportDisplayString(MidString,2,i,LISTCOLOR,LISTBKCOLOR);
         }

         setviewport(TmpViewPort.left,TmpViewPort.top,TmpViewPort.right,
                TmpViewPort.bottom,TmpViewPort.clip);
         setcolor(SaveColor);
         MouseShow();
         break;
    case LISTAPPENDITEM:
         ListInsertItem(Window,ListGetTotal(WindowList(Window)),(char *)LONG2FP(Param1));
         break;
    case LISTINSERTITEM:
         ListInsertItem(Window,Param2,(char *)LONG2FP(Param1));
         break;
    case LISTINSERTITEMSORTED:
         {
            char *p1,*p2;

            p2 = (char *)LONG2FP(Param1);
            for (i=0;i<ListGetTotal(WindowList(Window));i++) {
                p1 = ListGetItem(WindowList(Window),i);
                if (strcmp(p2,p1)>0) continue;
                ListInsertItem(Window,i,p2);
                break;
            }
            if (i==ListGetTotal(WindowList(Window))) ListInsertItem(Window,i,p2);
         }
         break;
    case LISTDELETEITEM:
         if (Param1<ListGetTotal(WindowList(Window)))
            ListDeleteItem(Window,Param1);
         break;
    case LISTDELETELASTITEM:
         if (ListGetTotal(WindowList(Window))>0)
            ListDeleteItem(Window,ListGetTotal(WindowList(Window))-1);
         MessageInsert(Window,WMPAINT,0l,
              ListGetHeight(WindowList(Window))*CHARHEIGHT);

         break;
    case LISTDELETEALL:
         ListSetTotal(WindowList(Window),0);
         ListSetTop(WindowList(Window),0);
         ListSetCurrent(WindowList(Window),0);

    #ifdef USE_SCROLL
         if (!WindowIsChildless(Window))
            MessageGo(WindowGetChild(Window),WINDOWCLOSE,0l,0l);
    #endif
         break;

    case LISTSETITEMLENGTH:
         if (Param1>0)
            ListSetItemLength(WindowList(Window),Param1);
         break;
    case LISTSETITEMHEIGHT:
         if (Param1>0)
            ListSetHeight(WindowList(Window),(WindowGetHeight(Window)+Param1-2)/Param1);
         break;
    case LISTSETTOTALITEM:
         ListSetTotal(WindowList(Window),Param1);
         if (!Param1)
            ListHandleFree();
         break;
    case ITEMSELECT:
         MessageInsert(WindowGetFather(Window),ITEMSELECT,
            ListGetCurrent(WindowList(Window)),Window);
         break;
    case MOUSEMOVE:
         //MouseShow();
         DialogMouseMove(Window,Message,Param1,Param2); // ByHance, 95,12.6
         break;
    default:
         return(WindowDefaultProcedure(Window,Message,Param1,Param2));
  }
  return(TRUE);
}
예제 #4
0
파일: OPENFILC.C 프로젝트: Inzaghi2012/EZP
static unsigned long DriverList(HWND Window,HMSG Message,long Param1,long Param2)
{
  switch (Message)
  {
    case WINDOWINIT:
         {
           unsigned save,disk,total,UnusedDisk;
           char diskn[3];
           char *dri=diskn;

           diskn[1] = ':';
           diskn[2] = '\0';

           MessageGo(Window,LISTSETITEMHEIGHT,16,0);
           MessageGo(Window,LISTSETITEMLENGTH,3,0);

               /* save original drive */
           save = getdisk();
//           diskn[0] = save+'A';
           diskn[0] = save+'A'-1;
//           _harderr(handler);
           MessageGo(Window,SETLINEBUFFER,FP2LONG(dri),0L);
           MessageGo(Window,LISTDELETEALL,0L,0L);

       /*------------
           for (disk = 1;disk < 26;++disk) {
                 setdisk(disk);
                 if (disk == getdisk()) {
                      setdisk(save);
       ------------*/

           disk = 1;            // from diskette A:
           UnusedDisk=0;
           {                         // ByHance, for diskette error
                 char *p=(char *)0x410;           // equipment list
                 total=*p;
                 if(total&1) {          // diskette present, count how many
                    total=(total>>6)&0x3;
                    if(!total) UnusedDisk=2;    // if only 1, can not use B:
                 } else disk=3;         // no diskette present, so, from C:
           }
           for (; disk<26; ++disk) {
                 if(disk==UnusedDisk) continue;
                 _dos_setdrive(disk,&total);
                 if (disk == getdisk()) {
                      _dos_setdrive(save,&total);
                      if(first && disk==save) {           // ByHance
                          HWND MidWindow=ComboFindListBox(Window);
                          if (MidWindow)
                               ListSetCurrent(WindowList(MidWindow),
                                        ListGetTotal(WindowList(MidWindow)) );
                          first=0;
                      }
                      diskn[0] = disk+'A'-1;
                      MessageGo(Window,LISTAPPENDITEM,FP2LONG(dri),0L);
                 }
           }

       /*---------
           setdisk(save);
           diskn[0] = save+'A';
        ----------*/
           _dos_setdrive(save,&total);
           diskn[0] = save+'A'-1;

           strcpy(NowOpenFile->drive,diskn);
         }
예제 #5
0
파일: OPENFILC.C 프로젝트: Inzaghi2012/EZP
static unsigned long DirectoryList(HWND Window,HMSG Message,long Param1,long Param2)
{
  int hlist;

  switch (Message)
  {
    case WINDOWINIT:
         {
           //int   i,j;
           char  *dirs=NowOpenFile->dirs;
           char  *drive=NowOpenFile->drive;
           #ifdef _TURBOC_
              struct ffblk opffblk;
           #else
              struct find_t opffblk;
           #endif

           char  fn[128];
           int   r;

           MessageGo(Window,LISTSETITEMHEIGHT,16,0);
           MessageGo(Window,LISTSETITEMLENGTH,13,0);

           /*------ ByHance, 96,3.25 ----
           hlist = WindowList(Window);
           ListSetTotal(hlist,0);
           ListSetCurrent(hlist,0);
           ListSetTop(hlist,0);
           --------------------*/
           MessageGo(Window,LISTDELETEALL,0L,0L);

//           _harderr(handler);
           if( ! drive[0] )
            {
 //             *drive     = (char)getdisk()+'A';
             *drive     = (char)getdisk()+'A'-1;
             *(drive+1) = ':';
             *(drive+2) = 0;
            }

           if( !dirs[0] ) {
              #ifdef __TURBOC__
                 getcurdir((int)(*drive-'A'+1), dirs);
              #else
                 unsigned total,old;
                 _dos_getdrive(&old);
                 if(old!=*drive-'A'+1)
                    _dos_setdrive( *drive-'A'+1 , &total );
                 getcwd(dirs, 64);
                 memmove(dirs,dirs+3,61);       // cancel "C:\"
                 if(!dirs[0])
                     strcpy(dirs,"\\");
                 if(old!=*drive-'A'+1)
                    _dos_setdrive( old, &total );
              #endif
           }

           memset(&opffblk, 0, sizeof(opffblk));
           strcpy(fn,drive);

           //if( strcmp(dirs,"\\") && strcmp(dirs,"/") )
           //{
           //    strcat(fn,dirs);
           //    strcat(fn,"\\");
           //}
           if(dirs[0])
           {
                  char ch;
                  int len;

                  ch=dirs[0];
                  if(ch!='\\' && ch!='/')
                       strcat(fn,"\\");

                  strcat(fn,dirs);
                  len=strlen(fn);
                  ch=fn[len-1];
                  if(ch!='\\' && ch!='/')
                       strcat(fn,"\\");
           }

           strcat(fn,"*.*");

           r = findfirst(fn, &opffblk, FA_DIREC);
           while (!r)
           {
            if((opffblk.ff_attrib & FA_DIREC) && strcmp(opffblk.ff_name,"."))
              MessageGo(Window, LISTINSERTITEMSORTED, FP2LONG(opffblk.ff_name), 0L);
            r = findnext(&opffblk);
           }

           //MessageGo(Window,WMPAINT,0,ListGetHeight(hlist)*CHARHEIGHT);
           //   ByHance, 95,12.11
           MessageInsert(Window,REDRAWMESSAGE,0L,
               MAKELONG(WindowGetWidth(Window),WindowGetHeight(Window)) );

           {    /*--- display directory's name ----*/
              #define max_n  (304/ASC16WIDTH)
                 int x,y,w,h;
                 unsigned total,old;
                 int len;
                 int SaveColor;
                 struct viewporttype TmpViewPort;
                 char disk[20],dirs[64],file[14],ext[5];

                 strupr(fn);
                 _splitpath(fn,disk,dirs,file,ext);

                 _dos_getdrive(&old);
                 if(old!=disk[0]-'A'+1)
                    _dos_setdrive( disk[0]-'A'+1 , &total );
                 len=strlen(dirs);
                 if(len>1)
                 {
                   char ch=dirs[len-1];
                   if(ch=='\\' || ch=='/') dirs[len-1]=0;
                 }

                 chdir(dirs);
                 getcwd(dirs, 64);
                 _dos_setdrive( old, &total );

                 MouseHidden();
                 SaveColor=getcolor();
                 getviewsettings(&TmpViewPort);
                 setviewport(0,0,getmaxx(),getmaxy(),1);

                 WindowGetRealRect(Window,&x,&y,&w,&h);
                 y-=26;

                 len=strlen(dirs);
                 if(len>max_n)
                 {
                    int i;
                    i=len-1;
                    while(dirs[i]!='\\' && dirs[i]!='/' && i>max_n-12) i--;
                    strcpy(dirs,"...");
                    strcat(dirs,&dirs[i]);
                 }

                 // WaitMessageEmpty();
                 setfillstyle(1,EGA_LIGHTGRAY);
                 bar(x,y,x+304,y+25);            /*--- clear old area --*/
                 DisplayString(dirs,x,y,EGA_BLACK,EGA_LIGHTGRAY);

                 setviewport(TmpViewPort.left,TmpViewPort.top,TmpViewPort.right,
                             TmpViewPort.bottom,TmpViewPort.clip);
                 setcolor(SaveColor);
                 MouseShow();
              #undef max_n
            }
         }
         break;

    case LISTBOXCONFIRM:{
         char dir[20];
         char path[40];

         hlist = WindowList(Window);
         strcpy(dir,ListGetItem(hlist,ListGetCurrent(hlist)));
         strcpy(path,NowOpenFile->drive);
         strcat(path,dir);
         chdir(path);
         #ifdef __TURBOC__
            getcurdir(path[0]-'A'+1,NowOpenFile->dirs);
         #else
         {
            unsigned total,old;
            _dos_getdrive(&old);
            if(old!=path[0]-'A'+1)
               _dos_setdrive( path[0]-'A'+1 , &total );
            getcwd(NowOpenFile->dirs, 64);
            memmove(NowOpenFile->dirs,NowOpenFile->dirs+3,61); // cancel "C:\"
            if(old!=path[0]-'A'+1)
               _dos_setdrive( old, &total );
         }
         #endif

         MessageGo(Window,WINDOWINIT,0,0);
         MessageGo(Window,WMPAINT,0,ListGetHeight(hlist)*CHARHEIGHT);
         ListSetTop(hlist,0);
         ListSetCurrent(hlist,0);
         MessageGo(WindowGetFather(Window),DIRCHANGE,0L,0L);
         }
         break;
    default:
         return(ListBoxDefaultProcedure(Window,Message,Param1,Param2));
  }
  return(TRUE);
}
예제 #6
0
파일: PRINTPRO.C 프로젝트: Inzaghi2012/EZP
unsigned long PrP0(HWND Window,HMSG Message,long Param1,long Param2)
{
    int i,saveI,j;
    int x0,y0,x1,y1,dx,dy;
    static int LastX,LastY;
    float Midf;
    /*
    x0=MouseXToWinX(Param1>>16);
    y0=MouseYToWinY(Param1&0xffff);
    x1=MouseXToWinX(Param2>>16);
    y1=MouseYToWinY(Param2&0xffff);
    */
    x0=(Param1>>16);
    y0=(Param1&0xffff);
    x1=(Param2>>16);
    y1=(Param2&0xffff);
    switch (Message)
    {
        case MOUSELEFTDOUBLE:
                i=IsCurrentPage(x0,y0);
                if (i>0)
                  switch(i)
                  {
                    case 13:
                    case 14:
                            x0=MouseXToWinX(x0);
                            ColLead[ColLeadNum++]=SCRscaleX*x0;
                            for (i=0;i<ColLeadNum-1;i++)
                              if (fabs(ColLead[i]-ColLead[ColLeadNum-1])<10.0f)
                                {
                                    ColLeadNum--;
                                    break;
                                }
                            REFLASH;
                            break;
                    case 11:
                    case 12:
                            y0=MouseYToWinY(y0);
                            RowLead[RowLeadNum++]=SCRscaleY*y0;
                            for (i=0;i<RowLeadNum-1;i++)
                              if (fabs(RowLead[i]-RowLead[RowLeadNum-1])<10.0f)
                                {
                                    RowLeadNum--;
                                    break;
                                }
                            REFLASH;
                            break;
                    case 21:                                  //Edit  Col
                            break;
                    case 22:                                  //Edit  Row
                            break;
                  }

                break;

        case MOUSERIGHTDOUBLE:
                i=IsCurrentPage(x0,y0);
                if (i>0)
                  switch(i)
                  {
                    case 21:                                  //Edit  Row
                            for (i=CurrRow;i<RowLeadNum-1;i++) RowLead[i]=RowLead[i+1];
                            RowLeadNum--;
                            REFLASH;
                            break;
                    case 22:                                  //Edit  Col
                            for (i=CurrCol;i<ColLeadNum-1;i++) ColLead[i]=ColLead[i+1];
                            ColLeadNum--;
                            REFLASH;
                            break;
                  }
                break;
        case MOUSEMOVE:
                i=IsCurrentPage(x0,y0);
                if (i>=0)
                 switch (i)
                    {
                        case 11:
                        case 12:
                        case 13:
                        case 14:
                                MouseSetGraph(FINGERMOUSE2);
                                MouseStat=0;
                                break;
                        case 0:
                                MouseSetGraph(MOVINGMOUSE);
                                MouseStat=5;
                                break;
                        case 1:
                        case 2:
                        case 22:
                                MouseSetGraph(HRESIZEMOUSE);
                                MouseStat=i;
                                break;
                        case 3:
                        case 4:
                        case 21:
                                MouseSetGraph(VRESIZEMOUSE);
                                MouseStat=i;
                                break;
                        default:
                                MouseSetGraph(ARRAWMOUSE);
                                MouseStat=0;
                    }
                else
                {
                 MouseSetGraph(ARRAWMOUSE);
                 MouseStat=0;
                }
                
                x0=MouseXToWinX(x0);
                y0=MouseYToWinY(y0);
                if (x0>=0&&y0>=0&&x0<=mXw&&y0<=mYw)
                {
                    char ss[30];
                    sprintf(ss,"(%6.1f ,%6.1f)",SCRscaleX*x0,SCRscaleY*y0);
                    Window=WindowGetFather(Window);
                    x0=WindowGetLeft(Window);
                    y0=WindowGetTop(Window);
                    //setwritemode(COPY_PUT);
                    DisplayString(ss,x0+360,y0+5,15,1);
                    //setwritemode(COPY_PUT);
                }

                break;

        case MOUSELEFTDROP:
                switch (MouseStat)
                 {
                    case 22:
                            dx=x1-LastX;
                            DrawCol(LEADCOLOR);
                            Midf=(float)dx*SCRscaleX;
                            ColLead[CurrCol] += Midf;
                            DrawCol(LEADCOLOR);
                            LastX=x1;
                            LastY=y1;
                            break;
                    case 21:
                            dy=y1-LastY;
                            DrawRow(LEADCOLOR);
                            Midf=(float)dy*SCRscaleY;
                            RowLead[CurrRow] += Midf;
                            DrawRow(LEADCOLOR);
                            LastX=x1;
                            LastY=y1;
                            break;
                    case 1:
                            dx=x1-LastX;
                            DrawCurr(CURRCOLOR);
                            Midf=(float)dx*SCRscaleX;
                            PG.PageBlock[CurrentBlock].Xoffset += Midf;

                            if (PG.PageBlock[CurrentBlock].Rotate&1)
                            PG.PageBlock[CurrentBlock].Yscale -= Midf/PageH;
                               else
                            PG.PageBlock[CurrentBlock].Xscale -= Midf/PageW;

                            DrawCurr(CURRCOLOR);
                            SetPrintPara1();
                            SetPrintPara2();
                            LastX=x1;
                            LastY=y1;
                            break;
                    case 2:
                            dx=x1-LastX;
                            DrawCurr(CURRCOLOR);
                            Midf=(float)dx*SCRscaleX;
                            //PG.PageBlock[CurrentBlock].Xoffset += Midf;

                            if (PG.PageBlock[CurrentBlock].Rotate&1)
                            PG.PageBlock[CurrentBlock].Yscale += Midf/PageH;
                               else
                            PG.PageBlock[CurrentBlock].Xscale += Midf/PageW;

                            DrawCurr(CURRCOLOR);
                            //SetPrintPara1();
                            SetPrintPara2();
                            LastX=x1;
                            LastY=y1;
                            break;
                    case 3:
                            dy=y1-LastY;
                            DrawCurr(CURRCOLOR);
                            Midf=(float)dy*SCRscaleY;
                            PG.PageBlock[CurrentBlock].Yoffset += Midf;

                            if (PG.PageBlock[CurrentBlock].Rotate&1)
                            PG.PageBlock[CurrentBlock].Xscale -= Midf/PageW;
                               else
                            PG.PageBlock[CurrentBlock].Yscale -= Midf/PageH;

                            DrawCurr(CURRCOLOR);
                            SetPrintPara1();
                            SetPrintPara2();
                            LastX=x1;
                            LastY=y1;
                            break;
                    case 4:
                            dy=y1-LastY;
                            DrawCurr(CURRCOLOR);
                            Midf=(float)dy*SCRscaleY;
                            //PG.PageBlock[CurrentBlock].Yoffset += Midf;

                            if (PG.PageBlock[CurrentBlock].Rotate&1)
                            PG.PageBlock[CurrentBlock].Xscale += Midf/PageW;
                               else
                            PG.PageBlock[CurrentBlock].Yscale += Midf/PageH;

                            DrawCurr(CURRCOLOR);
                            //SetPrintPara1();
                            SetPrintPara2();
                            LastX=x1;
                            LastY=y1;
                            break;
                    case 5:
                            dx=x1-LastX;
                            dy=y1-LastY;
                            DrawCurr(CURRCOLOR);
                            PG.PageBlock[CurrentBlock].Xoffset += (float)dx*SCRscaleX;
                            PG.PageBlock[CurrentBlock].Yoffset += (float)dy*SCRscaleY;
                            DrawCurr(CURRCOLOR);
                            SetPrintPara1();
                            LastX=x1;
                            LastY=y1;
                            break;
                 }

                x0=MouseXToWinX(x1);
                y0=MouseYToWinY(y1);
                if (x0>=0&&y0>=0&&x0<=mXw&&y0<=mYw)
                {
                    char ss[30];
                    sprintf(ss,"(%6.1f ,%6.1f)",SCRscaleX*x0,SCRscaleY*y0);
                    Window=WindowGetFather(Window);
                    x0=WindowGetLeft(Window);
                    y0=WindowGetTop(Window);
                    //setwritemode(COPY_PUT);
                    DisplayString(ss,x0+360,y0+5,15,1);
                    //setwritemode(COPY_PUT);
                }
                break;
        case MOUSELEFTUP:
                /*
                if (MouseStat)
                {
                  MouseStat=0;
                  REFLASH;
                }
                */
                break;
        case WINDOWINIT:
                PrintCutWin[0]=Window;
                //InitPrintCut();
                break;
        case MOUSELEFTDOWN:
                
                GetPrintPara();
                SetPrintPara();

                DrawCurr(0);

                if (PG.Blocks>0)
                {
                  saveI=CurrentBlock;
                  for (i=0;i<PG.Blocks;i++)
                  {
                    if (i==saveI) continue;
                    CurrentBlock=i;
                    DrawCurr(EXISTCOLOR);
                  }

                  CurrentBlock=saveI;
                  DrawCurr(CURRCOLOR);
                }

                if (Param1==-1l&&Param2==-1l) break;     //REFLASH
                LastX=x0;
                LastY=y0;
                i=IsCurrentPage(x0,y0);
                if (i<0||i>5)
                 {
                    GetPrintPara();
                    saveI=CurrentBlock;
                    for (i=0;i<PG.Blocks;i++)
                      {
                        CurrentBlock=i;
                        j=IsCurrentPage(x0,y0);
                        if (j>=0&&j<=5)
                        {
                            MouseStat=5;
                            MouseSetGraph(MOVINGMOUSE);
                            SetPrintPara();
                            ListSetCurrent(WindowList(PrintCutWin[wPAGEADDWIN]),i);
                            MessageGo(PrintCutWin[wPAGEADDWIN],ITEMSELECT,0l,0l);
                            //REFLASH;
                            break;
                        }
                        else
                            CurrentBlock=saveI;
                      }
                 }
               break;
       default:
               return (ListBoxDefaultProcedure(Window,Message,Param1,Param2));
    }
    return TRUE;
}
예제 #7
0
파일: PRINTPRO.C 프로젝트: Inzaghi2012/EZP
unsigned long UserWinProcedure(HWND Window,HMSG Message,long Param1,long Param2)
{
  int hlist,i,j;
  float Midf;
  switch (Message)
  {
     case DIALOGBOXOK:
            GetPrintPara();
            if (PG.Blocks>0)
                PG.Enable=1;
            else
                PG.Enable=0;
            return(DialogDefaultProcedure(Window, Message, Param1, Param2));
     case DIALOGBOXCANCEL:
            PG.Enable=0;
            return(DialogDefaultProcedure(Window, Message, Param1, Param2));
     case REDRAWMESSAGE:
            i=DialogDefaultProcedure(Window, Message, Param1, Param2);
            WaitMessageEmpty();
            InitOver=1;
            InitPrintCut();
            CurrentBlock=0;
            SetPrintPara();
            REFLASH;
            MessageInsert(PrintCutWin[wPAGEADDWIN],WINDOWINIT,0l,0l);
            ListSetCurrent(WindowList(PrintCutWin[wPAGEADDWIN]),CurrentBlock);
            
            REFLASHADD;
            return i;
            break;
     case WINDOWINIT:
            InitOver=0;

            i=DialogDefaultProcedure(Window, Message, Param1, Param2);
            //WaitMessageEmpty();
            return i;
            break;
     case ADDWIN:
            GetPrintPara();
            if (PG.Blocks<99) PG.Blocks++;
            CurrentBlock=PG.Blocks-1;
            if (CurrentBlock>0) CopyBlock(CurrentBlock,CurrentBlock-1);
            else InitBlock(CurrentBlock);
            SetPrintPara();
            hlist = WindowList(PrintCutWin[wPAGEADDWIN]);
            MessageGo(PrintCutWin[wPAGEADDWIN],WINDOWINIT,0,0);
            MessageGo(PrintCutWin[wPAGEADDWIN],WMPAINT,0,ListGetHeight(hlist)*CHARHEIGHT);
            if (CurrentBlock>=7)
             ListSetTop(hlist,CurrentBlock-7);
            else
            ListSetTop(hlist,0);
            ListSetCurrent(hlist,CurrentBlock);
            MessageGo(PrintCutWin[wPAGEADDWIN],REDRAWMESSAGE,0L,
                MAKELONG(WindowGetWidth(PrintCutWin[wPAGEADDWIN]),
                WindowGetHeight(PrintCutWin[wPAGEADDWIN])) );
            //MessageGo(PrintCutWin[wPAGEADDWIN],KEYDOWN,UP,0l);
            //MessageGo(PrintCutWin[wPAGEADDWIN],KEYDOWN,DOWN,0l);
            //ListSetTop(hlist,0);
            REFLASH;
            break;
     case DELETEWIN:
            GetPrintPara();
            for (i=CurrentBlock+1;i<PG.Blocks;i++) CopyBlock1(i-1,i);
            if (PG.Blocks>0) PG.Blocks--;
            if (CurrentBlock>=PG.Blocks&&CurrentBlock) CurrentBlock=PG.Blocks-1;
            SetPrintPara();
            hlist = WindowList(PrintCutWin[wPAGEADDWIN]);
            MessageGo(PrintCutWin[wPAGEADDWIN],WINDOWINIT,0,0);
            MessageGo(PrintCutWin[wPAGEADDWIN],WMPAINT,0,ListGetHeight(hlist)*CHARHEIGHT);
            if (CurrentBlock>=7)
             ListSetTop(hlist,CurrentBlock-7);
            else
            ListSetTop(hlist,0);
            ListSetCurrent(hlist,CurrentBlock);
            MessageGo(PrintCutWin[wPAGEADDWIN],REDRAWMESSAGE,0L,
                MAKELONG(WindowGetWidth(PrintCutWin[wPAGEADDWIN]),
                WindowGetHeight(PrintCutWin[wPAGEADDWIN])) );
            REFLASH;
            break;
     case DELETETAILWIN:
            GetPrintPara();
            PG.Blocks=CurrentBlock;
            if (CurrentBlock>=PG.Blocks&&CurrentBlock) CurrentBlock=PG.Blocks-1;
            SetPrintPara();
            hlist = WindowList(PrintCutWin[wPAGEADDWIN]);
            MessageGo(PrintCutWin[wPAGEADDWIN],WINDOWINIT,0,0);
            MessageGo(PrintCutWin[wPAGEADDWIN],WMPAINT,0,ListGetHeight(hlist)*CHARHEIGHT);
            if (CurrentBlock>=7)
             ListSetTop(hlist,CurrentBlock-7);
            else
            ListSetTop(hlist,0);
            ListSetCurrent(hlist,CurrentBlock);
            MessageGo(PrintCutWin[wPAGEADDWIN],REDRAWMESSAGE,0L,
                MAKELONG(WindowGetWidth(PrintCutWin[wPAGEADDWIN]),
                WindowGetHeight(PrintCutWin[wPAGEADDWIN])) );
            REFLASH;
            break;
     case COPYWIN:
            i=GetPrintPara();
            if (i<0)
              switch(i)
                {
                    case -99:
                        {
                        if (MessageBox("设置打印纸","     确认您的打印机可使用\n"
                                                    "     您所定义的纸张大小, \n"
                                                    "       否则,打印可能出错!"
                        ,2,1)) break;
                        }
                        PaperW=Tmp1;
                        PaperH=Tmp2;
                        if (PaperW<20.0) PaperW=20.0;
                        if (PaperW>1100.0) PaperW=1100.0;
                        if (PaperH<20.0) PaperH=20.0;
                        if (PaperH>1100.0) PaperH=1100.0;
                        printer->xpixel=PaperW*PrinterDPI/25.4;
                        printer->ypixel=PaperH*PrinterDPI/25.4;
                        InitPrintCut();
                        break;
                    case -5:               //Tmp1 = Scale
                        Tmp2=PageH*Tmp4;
                        Tmp1=PageW*Tmp3;
                        if (PG.Blocks)
                        {
                          j=(PG.PageBlock[0].Rotate&1);

                        }
                        else
                          j=0;
                        if (j)
                          {
                            Midf=Tmp2;
                            Tmp2=Tmp1;
                            Tmp1=Midf;
                          }
                    case -1:

                        if (Tmp1>5.0f)
                        {
                            Midf=0.0f;
                            ColLeadNum=0;
                            while (Midf+Tmp1<PaperW)
                             {
                                Midf +=Tmp1;
                                ColLead[ColLeadNum++]=Midf;
                             }
                        }

                        if (Tmp2>5.0f)
                        {
                            Midf=0.0f;
                            RowLeadNum=0;
                            while (Midf+Tmp1<PaperH)
                             {
                                Midf +=Tmp2;
                                RowLead[RowLeadNum++]=Midf;
                             }
                        }
                        break;
                    case -2:
                        ColLeadNum=0;
                        RowLeadNum=0;
                        break;
                    case -3:
                        ColLeadNum=0;
                        break;
                    case -4:
                        RowLeadNum=0;
                        break;
                    case -6:             //Auto Scale Fit
                        if (!PG.Blocks) break;
                        PG.Blocks=0;
                        CurrentBlock=0;
                        hlist=PG.PageBlock[0].Rotate;
                        for (i=0;i<RowLeadNum;i++)
                        {
                         for (j=0;j<ColLeadNum;j++)
                          {
                              if (GetColWidth(j)-5.0f>Tmp1+Tmp3&&
                                 GetRowHeight(i)-5.0f>Tmp2+Tmp4)
                              {
                                if (hlist&1)
                                {
                                    PG.PageBlock[PG.Blocks].Yscale=(GetColWidth(j)-Tmp1-Tmp3)/PageH;
                                    PG.PageBlock[PG.Blocks].Xscale=(GetRowHeight(i)-Tmp2-Tmp4)/PageW;
                                }
                                else
                                {
                                    PG.PageBlock[PG.Blocks].Xscale=(GetColWidth(j)-Tmp1-Tmp3)/PageW;
                                    PG.PageBlock[PG.Blocks].Yscale=(GetRowHeight(i)-Tmp2-Tmp4)/PageH;
                                }

                                PG.PageBlock[PG.Blocks].Xoffset=GetColOffset(j)+Tmp1;
                                PG.PageBlock[PG.Blocks].Yoffset=GetRowOffset(i)+Tmp3;
                                PG.PageBlock[PG.Blocks].PageOffset=0;
                                PG.PageBlock[PG.Blocks++].Rotate=hlist;
                              }
                              if (PG.Blocks>=99) break;
                          }
                          if (PG.Blocks>=99) break;
                        }
                        break;
                    case -7:             //Auto Scale Fit
                        if (!PG.Blocks) break;
                        PG.Blocks=0;
                        CurrentBlock=0;
                        hlist=PG.PageBlock[0].Rotate;
                        for (i=0;i<=RowLeadNum;i++)
                        {
                         for (j=0;j<=ColLeadNum;j++)
                          {
                              if (GetColWidth(j)-5.0f>Tmp1+Tmp3&&
                                 GetRowHeight(i)-5.0f>Tmp2+Tmp4)
                              {
                                if (hlist&1)
                                {
                                    PG.PageBlock[PG.Blocks].Yscale=(GetColWidth(j)-Tmp1-Tmp3)/PageH;
                                    PG.PageBlock[PG.Blocks].Xscale=(GetRowHeight(i)-Tmp2-Tmp4)/PageW;
                                }
                                else
                                {
                                    PG.PageBlock[PG.Blocks].Xscale=(GetColWidth(j)-Tmp1-Tmp3)/PageW;
                                    PG.PageBlock[PG.Blocks].Yscale=(GetRowHeight(i)-Tmp2-Tmp4)/PageH;
                                }

                                PG.PageBlock[PG.Blocks].Xoffset=GetColOffset(j)+Tmp1;
                                PG.PageBlock[PG.Blocks].Yoffset=GetRowOffset(i)+Tmp3;
                                PG.PageBlock[PG.Blocks].PageOffset=0;
                                PG.PageBlock[PG.Blocks++].Rotate=hlist;
                              }
                              if (PG.Blocks>=99) break;
                          }
                          if (PG.Blocks>=99) break;
                        }
                        break;

                    case -8:
                        if (!PG.Blocks) break;
                        PG.Blocks=0;
                        CurrentBlock=0;
                        for (i=0;i<RowLeadNum;i++)
                        {
                         for (j=0;j<ColLeadNum;j++)
                          {
                              if (GetColWidth(j)-5.0f>Tmp1&&
                                 GetRowHeight(i)-5.0f>Tmp2)
                              {
                                PG.PageBlock[PG.Blocks].Xoffset=GetColOffset(j)+Tmp1;
                                PG.PageBlock[PG.Blocks].Yoffset=GetRowOffset(i)+Tmp2;
                                PG.PageBlock[PG.Blocks].Xscale=PG.PageBlock[0].Xscale;
                                PG.PageBlock[PG.Blocks].Yscale=PG.PageBlock[0].Yscale;
                                PG.PageBlock[PG.Blocks].PageOffset=0;
                                PG.PageBlock[PG.Blocks++].Rotate=PG.PageBlock[0].Rotate;
                              }
                              if (PG.Blocks>=99) break;
                          }
                          if (PG.Blocks>=99) break;
                        }
                        break;
                    case -9:
                        if (!PG.Blocks) break;
                        PG.Blocks=0;
                        CurrentBlock=0;
                        for (i=0;i<=RowLeadNum;i++)
                        {
                         for (j=0;j<=ColLeadNum;j++)
                          {
                              if (GetColWidth(j)-5.0f>Tmp1&&
                                 GetRowHeight(i)-5.0f>Tmp2)
                              {
                                PG.PageBlock[PG.Blocks].Xoffset=GetColOffset(j)+Tmp1;
                                PG.PageBlock[PG.Blocks].Yoffset=GetRowOffset(i)+Tmp2;
                                PG.PageBlock[PG.Blocks].Xscale=PG.PageBlock[0].Xscale;
                                PG.PageBlock[PG.Blocks].Yscale=PG.PageBlock[0].Yscale;
                                PG.PageBlock[PG.Blocks].PageOffset=0;
                                PG.PageBlock[PG.Blocks++].Rotate=PG.PageBlock[0].Rotate;
                              }
                              if (PG.Blocks>=99) break;
                          }
                          if (PG.Blocks>=99) break;
                        }
                        break;

                }
            REFLASH;
            REFLASHADD;
            break;
     default:
            return(DialogDefaultProcedure(Window, Message, Param1, Param2));
  }
  /* return(DialogDefaultProcedure(Window, Message, Param1, Param2)); */
  return(TRUE);
}
예제 #8
0
파일: listc.c 프로젝트: CivilPol/sdcboot
// print the file on the default printer
void ListPrintFile( void )
{
	register int i, n;
	int c, nRows, nBytesPrinted, nFH;
	long lTemp;
	POPWINDOWPTR wn;
	TCHAR szBuffer[MAXLISTLINE+1];
	int fKBHit;
	
	// disable ^C / ^BREAK handling
	HoldSignals();
	
	wn = wOpen( 2, 1, 4, strlen( LIST_PRINTING ) + 8, nInverse, LIST_PRINT_TITLE, NULL );
	wn->nAttrib = nNormal;
	wClear();
	sprintf( szBuffer, LIST_QUERY_PRINT, LIST_PRINT_FILE_CHAR, LIST_PRINT_PAGE_CHAR );
	wWriteListStr( 0, 1, wn, szBuffer );
	
	if ((( c = GetKeystroke( EDIT_ECHO | EDIT_UC_SHIFT | EDIT_BIOS_KEY )) == LIST_PRINT_FILE_CHAR ) || ( c == LIST_PRINT_PAGE_CHAR )) {
		
		// save start position
		lTemp = LFile.lViewPtr;
		
		// display "Printing ..."
		wWriteListStr( 0, 1, wn, LIST_PRINTING );
	
		if (( nFH = _sopen((( gpIniptr->Printer != INI_EMPTYSTR ) ? gpIniptr->StrData + gpIniptr->Printer : _TEXT("LPT1") ), (_O_BINARY | _O_WRONLY | _O_CREAT), _SH_DENYNO, _S_IWRITE | _S_IREAD )) >= 0 ) {

			if ( setjmp( cv.env ) == -1 ) {
				_close( nFH );
				return;
			}

			// reset to beginning of file
			if ( c == LIST_PRINT_FILE_CHAR )
				ListSetCurrent( 0L );
			else {
				nRows = GetScrRows();
				ListSetCurrent( LFile.lViewPtr );
			}
			
			// print the header (filename, date & time)
			qprintf( nFH, _TEXT("%s   %s  %s\r\n\r\n"), LFile.szName, gdate( 0 ), gtime( gaCountryInfo.fsTimeFmt ) );

			do {
				// abort printing if a key is hit

				// kbhit() in DOS tries to read from STDIN, which screws
				//	 up a LIST /S pipe
				_asm {
					mov 	ah, 1
					int 	16h
					mov 	fKBHit, 1
					jnz 	KBHDone
					mov 	fKBHit, 0
KBHDone:
				}
				if ( fKBHit && ( GetKeystroke( EDIT_NO_ECHO | EDIT_BIOS_KEY ) == ESC ))
					break;

				i = FormatLine( szBuffer, MAXLISTLINE, LFile.lViewPtr, &nBytesPrinted, TRUE );
				LFile.lViewPtr += 16;
				
				// replace 0-31 with "."
				if ( lListFlags & LIST_HEX ) {
					for ( n = 0; ( n < i ); n++ ) {
						if ( szBuffer[n] < 32 )
							szBuffer[n] = _TEXT('.');
					}
				}
				
				if (( c == LIST_PRINT_PAGE_CHAR ) && ( nRows-- <= 0 ))
					break;
				
			} while (( nBytesPrinted > 0 ) && ( qprintf( nFH, _TEXT("%.*s\r\n"), i, szBuffer ) > 0 ));
			
			// print a formfeed
			qputc( nFH, _TEXT('\014') );
			_close( nFH );
			
			// restore start position
			LFile.lViewPtr = lTemp;
			ListSetCurrent( LFile.lViewPtr );
			
		} else
			honk();
	}
	
	wRemove( wn );
	
	// enable ^C / ^BREAK handling
	EnableSignals();
}
예제 #9
0
파일: listc.c 프로젝트: CivilPol/sdcboot
static int _fastcall _list( LPTSTR pszFileName )
{
	register int c, i;
	TCHAR szDescription[512], szHeader[132], szLine[32];
	long lTemp, lRow;
	POPWINDOWPTR wn = NULL;
	FILESEARCH dir;
	
	// get default normal and inverse attributes
	if ( gpIniptr->ListColor != 0 ) {
		SetScrColor( nScreenRows, nScreenColumns, gpIniptr->ListColor );

	}
	
	// set colors
	GetAtt( (unsigned int *)&nNormal, (unsigned int *)&nInverse );
	if ( gpIniptr->ListStatusColor != 0 )
		nInverse = gpIniptr->ListStatusColor;
	
	// flip the first line to inverse video
	clear_header();
	
	// open the file & initialize buffers
	if ( ListOpenFile( pszFileName ))
		return ERROR_EXIT;
	
	// kludge for empty files or pipes
	if ( LFile.lSize == 0L )
		LFile.lSize = 1L;
	
	for ( ; ; ) {
		
		// display header
		if ( fDirtyHeader ) {
			clear_header();
			sprintf( szHeader, LIST_HEADER, fname_part(LFile.szName), gchVerticalBar, gchVerticalBar, gchVerticalBar );
			WriteStrAtt( 0, 0, nInverse, szHeader );
			fDirtyHeader = 0;
		}
		
		// display location within file
		//	(don't use color_printf() so we won't have
		//	problems with windowed sessions)

		i = sprintf( szHeader, LIST_LINE, LFile.nListHorizOffset, LFile.lCurrentLine + gpIniptr->ListRowStart, (int)((( LFile.lViewPtr + 1 ) * 100 ) / LFile.lSize ));

		WriteStrAtt( 0, ( nScreenColumns - i ), nInverse, szHeader );
		SetCurPos( 0, 0 );
		
		if ( lListFlags & LIST_SEARCH ) {
			
			lListFlags &= ~LIST_SEARCH;
			fSearchFlags = 0;
			if ( lListFlags & LIST_REVERSE ) {
				
				c = LIST_FIND_CHAR_REVERSE;
				fSearchFlags |= FFIND_REVERSE_SEARCH;
				
				// goto the last row
				while ( ListMoveLine( 1 ) != 0 )
					;
			} else
				c = LIST_FIND_CHAR;
			
			if ( lListFlags & LIST_NOWILDCARDS )
				fSearchFlags |= FFIND_NOWILDCARDS;
			bListSkipLine = 0;
			goto FindNext;
		}
		
		// get the key from the BIOS, because
		//	 STDIN might be redirected
		
		if ((( c = cvtkey( GetKeystroke( EDIT_NO_ECHO | EDIT_BIOS_KEY | EDIT_UC_SHIFT), MAP_GEN | MAP_LIST)) == (TCHAR)ESC ))
			break;
		
		switch ( c ) {
		case CTRLC:
			return CTRLC;
			
		case CUR_LEFT:
		case CTL_LEFT:
			
			if (( lListFlags & LIST_WRAP ) || ( LFile.nListHorizOffset == 0 ))
				goto bad_key;
			
			if (( LFile.nListHorizOffset -= (( c == CUR_LEFT ) ? 8 : 40 )) < 0 )
				LFile.nListHorizOffset = 0;
			break;
			
		case CUR_RIGHT:
		case CTL_RIGHT:
			
			if (( lListFlags & LIST_WRAP ) || ( LFile.nListHorizOffset >= MAXLISTLINE + 1 ))
				goto bad_key;
			
			if ((LFile.nListHorizOffset += ((c == CUR_RIGHT) ? 8 : 40 )) > MAXLISTLINE + 1 )
				LFile.nListHorizOffset = MAXLISTLINE+1;
			break;
			
		case CUR_UP:
			
			if ( ListMoveLine( -1 ) == 0 )
				goto bad_key;
			
			Scroll(1, 0, nScreenRows, nScreenColumns, -1, nNormal);
			DisplayLine( 1, LFile.lViewPtr );
			continue;
			
		case CUR_DOWN:
			
			if ( ListMoveLine( 1 ) == 0 )
				goto bad_key;
			
			Scroll( 1, 0, nScreenRows, nScreenColumns, 1, nNormal );
			
			// display last line
			lTemp = LFile.lViewPtr;
			lRow = (nScreenRows - 1);
			lTemp += MoveViewPtr( lTemp, &lRow );
			if ( lRow == ( nScreenRows - 1 ))
				DisplayLine( nScreenRows, lTemp );
			continue;
			
		case HOME:
			
			ListHome();
			break;
			
		case END:
			
			// goto the last row
			list_wait( LIST_WAIT );
			while ( ListMoveLine( 1 ) != 0 )
				;

		case PgUp:
			
			// already at TOF?
			if ( LFile.lViewPtr == 0L )
				goto bad_key;
			
			for ( i = 1; (( i < nScreenRows ) && ( ListMoveLine( -1 ) != 0 )); i++ )
				;
			
			break;
			
		case PgDn:
		case SPACE:
			
			if ( ListMoveLine( nScreenRows - 1 ) == 0 )
				goto bad_key;
			
			break;
			
		case F1:	// help

			// don't allow a ^X exit from HELP
			_help( gpInternalName, HELP_NX );

			continue;
			
		case TAB:
			// change tab size
			
			// disable ^C / ^BREAK handling
			HoldSignals();
			
			wn = wOpen( 2, 5, 4, strlen( LIST_TABSIZE ) + 10, nInverse, LIST_TABSIZE_TITLE, NULL );
			wn->nAttrib = nNormal;
			wClear();
			
			wWriteListStr( 0, 1, wn, LIST_TABSIZE );
			egets( szLine, 2, (EDIT_DIALOG | EDIT_BIOS_KEY | EDIT_NO_CRLF | EDIT_DIGITS));
			wRemove( wn );
			if (( i = atoi( szLine )) > 0 )
				TABSIZE = i;
			
			// enable ^C / ^BREAK handling
			EnableSignals();
			break;
			
		case DEL:
			// delete this file
			if (( lListFlags & LIST_STDIN ) == 0 ) {
				
				// disable ^C / ^BREAK handling
				HoldSignals();
				
				wn = wOpen( 2, 5, 4, strlen( LIST_DELETE ) + 10, nInverse, LIST_DELETE_TITLE, NULL );
				wn->nAttrib = nNormal;
				wClear();
				
				wWriteListStr( 0, 1, wn, LIST_DELETE );
				i = GetKeystroke( EDIT_ECHO | EDIT_BIOS_KEY | EDIT_UC_SHIFT );
				wRemove( wn );
				
				// enable ^C / ^BREAK handling
				EnableSignals();
				
				if ( i == (TCHAR)YES_CHAR ) {
					if ( LFile.hHandle > 0 )
						_close( LFile.hHandle );
					LFile.hHandle = -1;
					
					remove( pszFileName );
					return 0;
				}
			}
			break;
			
		case INS:
			// save to a file
			ListSaveFile();
			break;
			
		case LIST_INFO_CHAR:
			{
				unsigned int uSize = 1024;
				TCHAR _far *lpszText, _far *lpszArg;
				int fFSType, fSFN = 1;
				TCHAR szBuf[16];

				DOSFILEDATE laDir, crDir;

				// disable ^C / ^BREAK handling
				HoldSignals();
				
				memset( &dir, '\0', sizeof(FILESEARCH) );
				if (( lListFlags & LIST_STDIN ) == 0 ) {
					if ( find_file( FIND_FIRST, LFile.szName, 0x07 | FIND_CLOSE | FIND_EXACTLY, &dir, NULL ) == NULL ) {
						honk();
						continue;
					}
				}
				
				// display info on the current file
				i = (( lListFlags & LIST_STDIN ) ? 5 : 10 );
				if (( fFSType = ifs_type( LFile.szName )) != FAT )
					i = 11;
				wn = wOpen( 2, 1, i, 77, nInverse, gpInternalName, NULL );
				
				wn->nAttrib = nNormal;
				wClear();
				i = 0;
				
				if ( lListFlags & LIST_STDIN )
					wWriteStrAtt( 0, 1, nNormal, LIST_INFO_PIPE );
				
				else {
					
					szDescription[0] = _TEXT('\0');
					process_descriptions( LFile.szName, szDescription, DESCRIPTION_READ );
					
					lpszText = lpszArg = (TCHAR _far *)AllocMem( &uSize );

					strcpy(szBuf, FormatDate( dir.fd.file_date.months, dir.fd.file_date.days, dir.fd.file_date.years + 80, 0 ));
					
					if (fFSType != FAT) {
						FileTimeToDOSTime( &(dir.ftLastAccessTime), &( laDir.ft.wr_time), &( laDir.fd.wr_date) );
						FileTimeToDOSTime( &(dir.ftCreationTime), &(crDir.ft.wr_time), &(crDir.fd.wr_date) );
						strcpy( szLine, FormatDate( laDir.fd.file_date.months, laDir.fd.file_date.days, laDir.fd.file_date.years + 80, 0 ));
						sprintf_far( lpszText, LIST_INFO_LFN,
							LFile.szName, szDescription, dir.ulSize,
							szBuf,
							dir.ft.file_time.hours, gaCountryInfo.szTimeSeparator[0],dir.ft.file_time.minutes,
							szLine,
							laDir.ft.file_time.hours, gaCountryInfo.szTimeSeparator[0], laDir.ft.file_time.minutes,
							FormatDate( crDir.fd.file_date.months, crDir.fd.file_date.days, crDir.fd.file_date.years + 80, 0 ),
							crDir.ft.file_time.hours, gaCountryInfo.szTimeSeparator[0], crDir.ft.file_time.minutes);
					} else {
						
						sprintf_far( lpszText, LIST_INFO_FAT,
							LFile.szName, szDescription, dir.ulSize,
							szBuf, dir.ft.file_time.hours, 
							gaCountryInfo.szTimeSeparator[0],dir.ft.file_time.minutes );
					}

					// print the text
					for ( ; ( *lpszArg != _TEXT('\0') ); i++ ) {
						sscanf_far( lpszArg, _TEXT("%[^\n]%*c%n"), szHeader, &uSize );

						// allow for long filenames ...
						if (( i == 0 ) && ( strlen( szHeader ) > 73 )) {
							c = szHeader[73];
							szHeader[73] = _TEXT('\0');
							wWriteStrAtt( i++, 1, nNormal, szHeader );
							szHeader[73] = (TCHAR)c;
							wWriteStrAtt( i, 15, nNormal, szHeader+73 );
							fSFN = 0;
						} else

							wWriteStrAtt( i, 1, nNormal, szHeader );
						lpszArg += uSize;
					}
					
					FreeMem( lpszText );
				}
				
				wWriteListStr( i+fSFN, 1, wn, PAUSE_PROMPT );
				GetKeystroke( EDIT_NO_ECHO | EDIT_BIOS_KEY );
				
				wRemove( wn );
				
				// enable ^C / ^BREAK handling
				EnableSignals();
				
				continue;
			}
			
		case LIST_GOTO_CHAR:
			
			// goto the specified line / hex offset
			
			// disable ^C / ^BREAK handling
			HoldSignals();
			
			wn = wOpen( 2, 5, 4, strlen( LIST_GOTO_OFFSET ) + 20, nInverse, LIST_GOTO_TITLE, NULL );
			wn->nAttrib = nNormal;
			wClear();
			
			wWriteListStr( 0, 1, wn, (( lListFlags & LIST_HEX) ? LIST_GOTO_OFFSET : LIST_GOTO));
			i = egets( szLine, 10, (EDIT_DIALOG | EDIT_BIOS_KEY | EDIT_NO_CRLF));
			wRemove( wn );
			
			// enable ^C / ^BREAK handling
			EnableSignals();
			
			if ( i == 0 )
				break;
			list_wait( LIST_WAIT );
			
			// if in hex mode, jump to offset 
			if ( lListFlags & LIST_HEX ) {
				strupr( szLine );
				sscanf( szLine, _TEXT("%lx"), &lRow );
				lRow = lRow / 0x10;
			} else if ( sscanf( szLine, FMT_LONG, &lRow ) == 0 )
				continue;
			
			lRow -= gpIniptr->ListRowStart;
			if ( lRow >= 0 ) {
				LFile.lViewPtr = MoveViewPtr( 0L, &lRow );
				LFile.lCurrentLine = lRow;
			} else {
				LFile.lViewPtr += MoveViewPtr( LFile.lViewPtr, &lRow );
				LFile.lCurrentLine += lRow;
			}
			break;
			
		case LIST_HIBIT_CHAR:
			
			// toggle high bit filter
			lListFlags ^= LIST_HIBIT;
			break;
			
		case LIST_WRAP_CHAR:
			
			// toggle line wrap
			lListFlags ^= LIST_WRAP;
			nRightMargin = (( lListFlags & LIST_WRAP ) ? GetScrCols() : MAXLISTLINE );
			
			// recalculate current line
			list_wait( LIST_WAIT );
			
			// get start of line
			LFile.nListHorizOffset = 0;
			
			// line number probably changed, so recompute everything
			LFile.lCurrentLine = ComputeLines( 0L, LFile.lViewPtr );
			LFile.lViewPtr = MoveViewPtr( 0L, &(LFile.lCurrentLine ));
			break;
			
		case LIST_HEX_CHAR:
			
			// toggle hex display
			lListFlags ^= LIST_HEX;
			
			// if hex, reset to previous 16-byte
			//	 boundary
			if ( lListFlags & LIST_HEX ) {

				LFile.lViewPtr -= ( LFile.lViewPtr % 16 );
			} else {
				// if not hex, reset to start of line
				ListMoveLine( 1 );
				ListMoveLine( -1 );
			}
			
			// recalculate current line
			list_wait( LIST_WAIT );
			LFile.lCurrentLine = ComputeLines( 0L, LFile.lViewPtr );
			break;
			
		case LIST_FIND_CHAR:
		case LIST_FIND_CHAR_REVERSE:
			// find first matching string
			bListSkipLine = 0;
			//lint -fallthrough
			
		case LIST_FIND_NEXT_CHAR:
		case LIST_FIND_NEXT_CHAR_REVERSE:
			// find next matching string
			
			if (( c == LIST_FIND_CHAR ) || ( c == LIST_FIND_CHAR_REVERSE )) {
				
				// disable ^C / ^BREAK handling
				HoldSignals();
				
				fSearchFlags = 0;
				wn = wOpen( 2, 1, 4, 75, nInverse, (( c == LIST_FIND_NEXT_CHAR_REVERSE ) ? LIST_FIND_TITLE_REVERSE : LIST_FIND_TITLE ), NULL );
				wn->nAttrib = nNormal;
				wClear();
				
				if ( lListFlags & LIST_HEX ) {
					wWriteListStr( 0, 1, wn, LIST_FIND_HEX );
					if ( GetKeystroke( EDIT_ECHO | EDIT_BIOS_KEY | EDIT_UC_SHIFT ) == YES_CHAR )
						fSearchFlags |= FFIND_HEX_SEARCH;
					wClear();
				}
				
				wWriteListStr( 0, 1, wn, LIST_FIND );
				egets( szListFindWhat, 64, (EDIT_DIALOG | EDIT_BIOS_KEY | EDIT_NO_CRLF));
				wRemove( wn );
				
				// enable ^C / ^BREAK handling
				EnableSignals();
				
			} else {
FindNext:
			// a "Next" has to be from current position
			fSearchFlags &= ~FFIND_TOPSEARCH;
			}
			
			if ( szListFindWhat[0] == _TEXT('\0') )
				continue;
			
			sprintf( szDescription, LIST_FIND_WAIT, szListFindWhat );
			list_wait( szDescription );
			
			// save start position
			lTemp = LFile.lViewPtr;
			lRow = LFile.lCurrentLine;
			
			if (( c == LIST_FIND_CHAR_REVERSE ) || ( c == LIST_FIND_NEXT_CHAR_REVERSE )) {
				// start on the previous line
				fSearchFlags |= FFIND_REVERSE_SEARCH;
			} else {
				fSearchFlags &= ~FFIND_REVERSE_SEARCH;
				// skip the first line (except on /T"xxx")
				if ( bListSkipLine )
					ListMoveLine( 1 );
			}
			
			bListSkipLine = 1;
			if ( SearchFile( fSearchFlags ) != 1 ) {
				ListSetCurrent( lTemp );
				LFile.lViewPtr = lTemp;
				LFile.lCurrentLine = lRow;
			} else
				LFile.fDisplaySearch = (( fSearchFlags & FFIND_CHECK_CASE ) ? 2 : 1 );
			
			break;
			
		case LIST_PRINT_CHAR:
			
			// print the file
			ListPrintFile();
			continue;
			
		case LIST_CONTINUE_CHAR:
		case CTL_PgDn:
			return 0;
			
		case LIST_PREVIOUS_CHAR:
		case CTL_PgUp:
			// previous file
			if ( nCurrent > 0 ) {
				nCurrent--;
				return 0;
			}
			//lint -fallthrough
			
		default:
bad_key:
			honk();
			continue;
		}
		
		// rewrite the display
		ListUpdateScreen();
	}
	
	return 0;
}