Ejemplo n.º 1
0
int ListInsertItem(HWND Window,int Pos,char *String)
{
  HANDLE ListHandle;

  ListHandle=WindowList(Window);
  if (Pos>ListGetTotal(ListHandle))
  {
//   printf("pos is invalid. window=%d, pos=%d\n",Window,Pos);
     return(INVAILEDPARAM);
  }
  if (ListGetTotal(ListHandle)>=MAXLISTCHAR/ListGetItemLength(ListHandle))
  {
//   printf("Too many items.\n");
     return(TOOMANYLISTITEMS);
  }
  memmove(ListGetItem(ListHandle,Pos+1),ListGetItem(ListHandle,Pos),
          ListGetItemLength(ListHandle)*(ListGetTotal(ListHandle)-Pos));
  ListSetItem(ListHandle,Pos,String);
  ListIncTotal(ListHandle,1);

#ifdef USE_SCROLL
  if (ListGetTotal(ListHandle)==ListGetHeight(ListHandle)+1)
  {
     HWND MidWindow;
     MidWindow=CreatVScroll(WindowGetWidth(Window)-2-SYSSCROLLWIDTH,1,
                 WindowGetHeight(Window)-2,NULL,Window);
//   MessageInsert(MidWindow,REDRAWMESSAGE,0L,
//             MAKELONG(WindowGetWidth(Window),WindowGetHeight(Window)) );
  }
#endif

  ReturnOK();
}
Ejemplo n.º 2
0
NCURSES_SP_NAME(_nc_freeall) (NCURSES_SP_DCL0)
{
    WINDOWLIST *p, *q;
    static va_list empty_va;

    T((T_CALLED("_nc_freeall()")));
#if NO_LEAKS
    if (SP_PARM != 0) {
	if (SP_PARM->_oldnum_list != 0) {
	    FreeAndNull(SP_PARM->_oldnum_list);
	}
	if (SP_PARM->_panelHook.destroy != 0) {
	    SP_PARM->_panelHook.destroy(SP_PARM->_panelHook.stdscr_pseudo_panel);
	}
    }
#endif
    if (SP_PARM != 0) {
	_nc_lock_global(curses);

	while (WindowList(SP_PARM) != 0) {
	    bool deleted = FALSE;

	    /* Delete only windows that're not a parent */
	    for (each_window(SP_PARM, p)) {
		bool found = FALSE;

		for (each_window(SP_PARM, q)) {
		    if ((p != q)
			&& (q->win._flags & _SUBWIN)
			&& (&(p->win) == q->win._parent)) {
			found = TRUE;
			break;
		    }
		}

		if (!found) {
		    if (delwin(&(p->win)) != ERR)
			deleted = TRUE;
		    break;
		}
	    }

	    /*
	     * Don't continue to loop if the list is trashed.
	     */
	    if (!deleted)
		break;
	}
	delscreen(SP_PARM);
	_nc_unlock_global(curses);
    }
Ejemplo n.º 3
0
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));
}
Ejemplo n.º 4
0
int ListDeleteItem(HWND Window,int Pos)
{
  HANDLE ListHandle;

  ListHandle=WindowList(Window);
  if (Pos>=ListGetTotal(ListHandle)||Pos<0)
     return(INVAILEDPARAM);
  memmove(ListGetItem(ListHandle,Pos),ListGetItem(ListHandle,Pos+1),
          ListGetItemLength(ListHandle)*(ListGetTotal(ListHandle)-Pos-1));
  ListDecTotal(ListHandle,1);

#ifdef USE_SCROLL
  if (ListGetTotal(ListHandle)==ListGetHeight(ListHandle))
     if (!WindowIsChildless(Window))
        MessageGo(WindowGetChild(Window),WINDOWCLOSE,0l,0l);
#endif

  ReturnOK();
}
Ejemplo n.º 5
0
static unsigned long WildCardList(HWND Window,HMSG Message,long Param1,long Param2)
{
  switch (Message)
  {
    case WINDOWINIT:
         {
           char  *wd=NowOpenFile->wildcard;
           char  wid[10];

           MessageGo(Window,LISTSETITEMHEIGHT,16,0);
           MessageGo(Window,LISTSETITEMLENGTH,12,0);
           MessageGo(Window,SETLINEBUFFER,FP2LONG(wd),0L);
           while(*wd)
           {
             strcpy(wid,wd);
             MessageGo(Window,LISTAPPENDITEM,FP2LONG(wid),0L);
             while(*wd) wd++;
             wd++;              // point to next wildcast name:
                                // exp.  *.tif;*.bmp;*.pcx
           }
         }
         break;
    case ITEMSELECT:
         {
           HWND MidWin,hlist;

          // ComboDefaultProcedure(Window,COMBOPULL,0l,0l);   //ByHance,96,1.23
           ComboDefaultProcedure(Window,Message,Param1,Param2);
           MidWin = ComboFindListBox(Window);
           hlist = WindowList(MidWin);
           strcpy(NowOpenFile->wildcard,ListGetItem(hlist,ListGetCurrent(hlist)));

           MidWin = WindowGetFather(Window); ///Dialog
           MessageGo(MidWin,DIRCHANGE,0l,0l);
         }
         break;
    default:
         return(ComboDefaultProcedure(Window,Message,Param1,Param2));
  }
  return(TRUE);
}
Ejemplo n.º 6
0
_nc_freewin(WINDOW *win)
{
    WINDOWLIST *p, *q;
    int i;
    int result = ERR;
#ifdef USE_SP_WINDOWLIST
    SCREEN *sp = _nc_screen_of(win);	/* pretend this is parameter */
#endif

    T((T_CALLED("_nc_freewin(%p)"), (void *) win));

    if (win != 0) {
	if (_nc_nonsp_try_global(curses) == 0) {
	    q = 0;
	    for (each_window(SP_PARM, p)) {
		if (&(p->win) == win) {
		    remove_window_from_screen(win);
		    if (q == 0)
			WindowList(SP_PARM) = p->next;
		    else
			q->next = p->next;

		    if (!(win->_flags & _SUBWIN)) {
			for (i = 0; i <= win->_maxy; i++)
			    FreeIfNeeded(win->_line[i].text);
		    }
		    free(win->_line);
		    free(p);

		    result = OK;
		    T(("...deleted win=%p", (void *) win));
		    break;
		}
		q = p;
	    }
	    _nc_nonsp_unlock_global(curses);
	}
    }
Ejemplo n.º 7
0
static int ListVScroll(HWND Window)
{
  HANDLE Handle;

  Handle=WindowList(Window);
  if (ListGetCurrent(Handle)<ListGetTop(Handle))
  {
     ListSetTop(Handle,ListGetCurrent(Handle));
     //MessageInsert(Window,DRAWWINDOW,0l,
     //            MAKELONG(WindowGetWidth(Window),WindowGetHeight(Window)));
     MessageInsert(Window,WMPAINT,0l,ListGetHeight(Handle)*CHARHEIGHT);
     return(TRUE);
  }
  if (ListGetCurrent(Handle)>=ListGetTop(Handle)+ListGetHeight(Handle))
  {
     ListSetTop(Handle,ListGetCurrent(Handle)-ListGetHeight(Handle)+1);
     //MessageInsert(Window,DRAWWINDOW,0l,
     //            MAKELONG(WindowGetWidth(Window),WindowGetHeight(Window)));
     MessageInsert(Window,WMPAINT,0l,ListGetHeight(Handle)*CHARHEIGHT);
     return(TRUE);
  }
  return(FALSE);
}
Ejemplo n.º 8
0
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);
}
Ejemplo n.º 9
0
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);
         }
Ejemplo n.º 10
0
static unsigned long FileNameList(HWND Window,HMSG Message,long Param1,long Param2)
{
  int hlist;

  switch (Message)
  {
    case DIRCHANGE:
         MessageGo(Window,WINDOWINIT,0,0);
         hlist = WindowList(Window);
         MessageGo(Window,WMPAINT,0,ListGetHeight(hlist)*CHARHEIGHT);
         break;

    case ITEMSELECT:
         MessageGo(WindowGetFather(Window),FILECHANGE,Param1,Param2);
         break;

    case LISTBOXCONFIRM:
         hlist=WindowGetUserData(Window);
         strcpy(NowOpenFile->filename,ListGetItem(hlist,ListGetCurrent(hlist)));
         MessageGo(WindowGetFather(Window),DIALOGBOXOK,0l,0l);
         break;

    case WINDOWINIT:
         {
           char  *filename=NowOpenFile->filename;
           char  *dirs=NowOpenFile->dirs;
           char  *drive=NowOpenFile->drive;
           char  fn[128];
           int   r;

           #ifdef _TURBOC_
              struct ffblk opffblk;
           #else
              struct find_t opffblk;
           #endif

           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( !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);
           //strcat(fn,"\\");
           //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,filename);

           r = findfirst(fn, &opffblk, _A_NORMAL);

           if (!r)              // found at least 1 file
              strcpy(NowOpenFile->filename, opffblk.ff_name);

           while (!r)
           {
              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)) );
         }
         break;
    default:
         return(ListBoxDefaultProcedure(Window,Message,Param1,Param2));
  }
  return(TRUE);
}
Ejemplo n.º 11
0
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);
}
Ejemplo n.º 12
0
void PAGE::InitDlgControl ( void )
{
	char 	name[OBJECTNAMESIZE+1];
	RECT	lorect;
  POINT	pt;

	data0 = LockPageData0(objectId);

  snap = data0->snap;
	CheckDlgButton(hDialog, PAGEGRID, data0->snap);

	AObjGetName(objectId, name, OBJECTNAMESIZE);
	SetWindowText(hDialog, name);

	hRemoveButton   = GetDlgItem(hDialog, PAGEREMOVE);
	hAddButton      = GetDlgItem(hDialog, PAGEADD);
	hEditButton     = GetDlgItem(hDialog, PAGEEDIT);
  hPageLayout			= GetDlgItem(hDialog, PAGELOUT);  

	SetFocus(hAddButton);

	GetClientRect(hDialog, &dialogRect);

	// key layout to the position of the label "Page Layout"
	GetWindowRect(hPageLayout, &lorect);
	pt.x = lorect.left;
  pt.y = lorect.bottom;
	ScreenToClient(hDialog, &pt);
  dialogRect.top = pt.y + 1;
  dialogRect.left = pt.x;

	grid_height = dialogRect.bottom - dialogRect.top;

	// make sure grid increments are even numbers
	// otherwise snap to grid will not work
	grid_inc_y = grid_height/14;
	grid_inc_x = grid_inc_y*(float(aspecty)/float(aspectx));

	grid_inc_y = (grid_inc_y % 2) ? grid_inc_y-1 : grid_inc_y;
	grid_inc_x = (grid_inc_x % 2) ? grid_inc_x-1 : grid_inc_x;

	grid_height = grid_inc_y * 14;
	grid_width  = (grid_inc_x * 8.5)+4;

	pixinch_x = grid_inc_x;
	pixinch_y = grid_inc_y;

	CreateLayoutClass();
	CreateLayoutWindow();
	FontSetup();

	WindowList();

	CreateObjectClass();
	SelectedList();

	UpdateRemoveButton();
	UpdateEditButton();
	UpdateAddButton();

	UnlockPageData0(objectId);
}
Ejemplo n.º 13
0
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;
}
Ejemplo n.º 14
0
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);
}
Ejemplo n.º 15
0
WindowList AbstractGroupableItem::winIds() const
{
    return WindowList();
}
Ejemplo n.º 16
0
NCURSES_SP_NAME(_nc_freeall) (NCURSES_SP_DCL0)
{
    static va_list empty_va;

    T((T_CALLED("_nc_freeall()")));
#if NO_LEAKS
    _nc_globals.leak_checking = TRUE;
    if (SP_PARM != 0) {
	if (SP_PARM->_oldnum_list != 0) {
	    FreeAndNull(SP_PARM->_oldnum_list);
	}
	if (SP_PARM->_panelHook.destroy != 0) {
	    SP_PARM->_panelHook.destroy(SP_PARM->_panelHook.stdscr_pseudo_panel);
	}
#if USE_NEW_PAIR
	_nc_new_pair_leaks(SP_PARM);
#endif
    }
#endif
    if (SP_PARM != 0) {
	_nc_lock_global(curses);

	while (WindowList(SP_PARM) != 0) {
	    WINDOWLIST *p, *q;
	    bool deleted = FALSE;

	    /* Delete only windows that're not a parent */
	    for (each_window(SP_PARM, p)) {
		WINDOW *p_win = &(p->win);
		bool found = FALSE;

#ifndef USE_SP_WINDOWLIST
		if (p->screen != SP_PARM)
		    continue;
#endif

		for (each_window(SP_PARM, q)) {
		    WINDOW *q_win = &(q->win);

#ifndef USE_SP_WINDOWLIST
		    if (q->screen != SP_PARM)
			continue;
#endif

		    if ((p != q)
			&& (q_win->_flags & _SUBWIN)
			&& (p_win == q_win->_parent)) {
			found = TRUE;
			break;
		    }
		}

		if (!found) {
		    if (delwin(p_win) != ERR)
			deleted = TRUE;
		    break;
		}
	    }

	    /*
	     * Don't continue to loop if the list is trashed.
	     */
	    if (!deleted)
		break;
	}
	delscreen(SP_PARM);
	_nc_unlock_global(curses);
    }