home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Linux / Enlightenment / enl_BETA-0.13.src.tar.gz / enl_BETA-0.13.src.tar / enl-0.13 / infobox.c < prev    next >
C/C++ Source or Header  |  1997-11-18  |  9KB  |  385 lines

  1. #include "enlightenment.h"
  2.  
  3.  
  4. static int ShowIdLine(int id, char *s, char *params);
  5.  
  6.  
  7. void InitInfoBox()
  8. {
  9. }
  10.  
  11. void ShowLine(int *x,int *y,int i,int j,
  12.         char *s,Window *wlst,Pixmap *plst,Pixmap *mlst) {
  13.     int k;
  14.     GC gcp;
  15.     GC gcm;
  16.     XGCValues gcv;
  17.  
  18.     k=0;
  19.     while (wlst[k]) k++;
  20.  
  21.     wlst[k]=CreateBasicWin(root,*x,*y,ifb.width,ifb.height);
  22.     *y=*y+ifb.height;
  23.     plst[k]=XCreatePixmap(disp,wlst[k],ifb.width,ifb.height,depth);
  24.     mlst[k]=XCreatePixmap(disp,wlst[k],ifb.width,ifb.height,1);
  25.     gcp=XCreateGC(disp,plst[k],0,&gcv);
  26.     gcm=XCreateGC(disp,mlst[k],0,&gcv);
  27.     XSetForeground(disp,gcm,0);
  28.     XFillRectangle(disp,mlst[k],gcm,0,0,ifb.width,ifb.height);
  29.     DrawText(plst[k],s,ifb.mouse_width+ifb.key_width,0,
  30.             ifb.width-(ifb.mouse_width+ifb.key_width),ifb.height);
  31.     DrawTextMask(mlst[k],s,ifb.mouse_width+ifb.key_width,0,
  32.             ifb.width-(ifb.mouse_width+ifb.key_width),ifb.height);
  33.     XSetForeground(disp,gcp,1);
  34.     XSetForeground(disp,gcm,1);
  35.     if (i==1) {
  36.         XCopyArea(disp,ifb.k2_pmap,plst[k],gcp,0,0,
  37.                 ifb.key_width,ifb.height,0,0);
  38.         XCopyArea(disp,ifb.k2_mask,mlst[k],gcm,0,0,
  39.                 ifb.key_width,ifb.height,0,0);
  40.     }
  41.     if (i==2) {
  42.         XCopyArea(disp,ifb.k3_pmap,plst[k],gcp,0,0,
  43.                 ifb.key_width,ifb.height,0,0);
  44.         XCopyArea(disp,ifb.k3_mask,mlst[k],gcm,0,0,
  45.                 ifb.key_width,ifb.height,0,0);
  46.     }
  47.     if (i==3) {
  48.         XCopyArea(disp,ifb.k4_pmap,plst[k],gcp,0,0,
  49.                 ifb.key_width,ifb.height,0,0);
  50.         XCopyArea(disp,ifb.k4_mask,mlst[k],gcm,0,0,
  51.                 ifb.key_width,ifb.height,0,0);
  52.     }
  53.     if (j==0) {
  54.         XCopyArea(disp,ifb.m1_pmap,plst[k],gcp,0,0,
  55.                 ifb.mouse_width,ifb.height,ifb.key_width,0);
  56.         XCopyArea(disp,ifb.m1_mask,mlst[k],gcm,0,0,
  57.                 ifb.mouse_width,ifb.height,ifb.key_width,0);
  58.     }
  59.     if (j==1) {
  60.         XCopyArea(disp,ifb.m2_pmap,plst[k],gcp,0,0,
  61.                 ifb.mouse_width,ifb.height,ifb.key_width,0);
  62.         XCopyArea(disp,ifb.m2_mask,mlst[k],gcm,0,0,
  63.                 ifb.mouse_width,ifb.height,ifb.key_width,0);
  64.     }
  65.     if (j==2) {
  66.         XCopyArea(disp,ifb.m3_pmap,plst[k],gcp,0,0,
  67.                 ifb.mouse_width,ifb.height,ifb.key_width,0);
  68.         XCopyArea(disp,ifb.m3_mask,mlst[k],gcm,0,0,
  69.                 ifb.mouse_width,ifb.height,ifb.key_width,0);
  70.     }
  71.     XShapeCombineMask(disp,wlst[k],ShapeBounding,0,0,mlst[k],ShapeSet);
  72.     XSetWindowBackgroundPixmap(disp,wlst[k],plst[k]);
  73.     XMapWindow(disp,wlst[k]);
  74.     XFreeGC(disp,gcp);
  75.     XFreeGC(disp,gcm);
  76. }
  77.  
  78. static int ShowIdLine(int id,char *s, char *params) {
  79.     unsigned char showit=1;
  80.     if(id < ACTION_KILL_NASTY) 
  81.     switch(id)
  82.            {
  83.         case ACTION_MOVE:
  84.             sprintf(s,"Move Window");break;
  85.         case ACTION_RESIZE:
  86.             sprintf(s,"Resize Window");break;
  87.         case ACTION_ICONIFY:
  88.             sprintf(s,"Iconify Window");break;
  89.         case ACTION_KILL:
  90.             sprintf(s,"Kill Window");break;
  91.         case ACTION_RAISE:
  92.             sprintf(s,"Raise Window To Top");break;
  93.         case ACTION_LOWER:
  94.             sprintf(s,"Lower Window To Bottom");break;
  95.         case ACTION_RAISE_LOWER:
  96.             sprintf(s,"Raise/Lower Window");break;
  97.         case ACTION_MAX_HEIGHT:
  98.             sprintf(s,"Toggle Window Max Height");break;
  99.         case ACTION_MAX_WIDTH:
  100.             sprintf(s,"Toggle Window Max Width");break;
  101.         case ACTION_MAX_SIZE:
  102.             sprintf(s,"Toggle Window Max Size");break;
  103.         case ACTION_CONFIGURE:
  104.             sprintf(s,"Configure Enlightenment");break;
  105.         case ACTION_MENU:
  106.             sprintf(s,"Menu : %s",params);break;
  107.         case ACTION_EXEC:
  108.             sprintf(s,"Execute : %s",params);break;
  109.         case ACTION_EXIT:
  110.             sprintf(s,"Exit");break;
  111.            }
  112.     else
  113.     switch(id)
  114.            {
  115.         case ACTION_KILL_NASTY:
  116.             sprintf(s,"Forcibly Kill Window");break;
  117.         case ACTION_RESTART:
  118.             sprintf(s,"Restart");break;
  119.         case ACTION_RESTART_THEME:
  120.             sprintf(s,"Restart Theme : %s",params);break;
  121.         case ACTION_BACKGROUND:
  122.             sprintf(s,"Root Background : %s",params);break;
  123.         case ACTION_DESKTOP:
  124.             sprintf(s,"Change Desktop : %s",params);break;
  125.         case ACTION_STICKY:
  126.             sprintf(s,"Toggle Sticky Window");break;
  127.         case ACTION_CYCLE_NEXT:
  128.             sprintf(s,"Cycle to Next Window");break;
  129.         case ACTION_CYCLE_PREV:
  130.             sprintf(s,"Cycle to Previous Window");break;
  131.         case ACTION_MOUSEFOCUS:
  132.             sprintf(s,"Change Mouse Focus : %s",params);break;
  133.         case ACTION_DRAG:
  134.             sprintf(s,"Drag Window Icon");break;
  135.         case ACTION_SKIP:
  136.             sprintf(s,"Skip Window");break;
  137.         case ACTION_SNAPSHOT:
  138.             sprintf(s,"Snapshot Window");break;
  139.         case ACTION_UNSNAPSHOT:
  140.             sprintf(s,"Unsnapshot Window");break;
  141.         case ACTION_SHADE:
  142.             sprintf(s,"Shade Window"); break;
  143.         default:
  144.             showit=0;
  145.             break;
  146.     }
  147.     return showit;
  148.  
  149. }
  150.  
  151. void GenListBtn(BWin *bwin) {
  152.     int i,j,th;
  153.     int x,y,d;
  154.     unsigned int dui;
  155.     Window w1,w2;
  156.     char s[1024];
  157.     Window wlst[64];
  158.     Pixmap plst[64];
  159.     Pixmap mlst[64];
  160.     XEvent xev;
  161.  
  162.     for (i=0;i<64;i++) {
  163.         wlst[i]=0;
  164.         plst[i]=0;
  165.         mlst[i]=0;
  166.     }
  167.  
  168.     XQueryPointer(disp,root,&w1,&w2,&x,&y,&d,&d,&dui);
  169.     th=0;
  170.     for(i=0;i<4;i++)
  171.         for(j=0;j<3;j++) 
  172.             if(ShowIdLine(bwin->action[j][i].id,s,bwin->action[j][i].params)) 
  173.                 th+=ifb.height;
  174.     if ((DisplayHeight(disp,screen)-y) < th)
  175.         y=DisplayHeight(disp,screen)-th;
  176.  
  177.     if ((DisplayWidth(disp,screen)-x)<ifb.width)
  178.         x=DisplayWidth(disp,screen)-ifb.width;
  179.  
  180.     for (i=0;i<4;i++)
  181.         for (j=0;j<3;j++)
  182.             if(ShowIdLine(bwin->action[j][i].id,s,bwin->action[j][i].params))
  183.                 ShowLine(&x,&y,i,j,s,wlst,plst,mlst);
  184.     XSync(disp,False);
  185.     XNextEvent(disp,&xev);
  186.     XPutBackEvent(disp,&xev);
  187.     i=0;
  188.     while(wlst[i]) {
  189.         XDestroyWindow(disp,wlst[i]);
  190.         ImlibFreePixmap(imd,plst[i]);
  191.         ImlibFreePixmap(imd,mlst[i]);
  192.         i++;
  193.     }
  194. }
  195.  
  196.  
  197. void GenListEWin(int b) {
  198.     int i,j, th;
  199.     int x,y,d;
  200.     unsigned int dui;
  201.     Window w1,w2;
  202.     char s[1024];
  203.     Window wlst[64];
  204.     Pixmap plst[64];
  205.     Pixmap mlst[64];
  206.     XEvent xev;
  207.  
  208.     ifb.moveresize=0;
  209.     for (i=0;i<64;i++) {
  210.         wlst[i]=0;
  211.         plst[i]=0;
  212.         mlst[i]=0;
  213.     }
  214.  
  215.  
  216.     XQueryPointer(disp,root,&w1,&w2,&x,&y,&d,&d,&dui);
  217.     th=0;
  218.     for(i=0;i<4;i++)
  219.         for(j=0;j<3;j++) 
  220.             if(ShowIdLine(cfg.subwin_action[b][j][i].id,
  221.                     s,cfg.subwin_action[b][j][j].params))
  222.                th+=ifb.height;
  223.     if ((DisplayHeight(disp,screen)-y) < th)
  224.         y=DisplayHeight(disp,screen)-th;
  225.  
  226.  
  227.     if ((DisplayWidth(disp,screen)-x)<ifb.width)
  228.         x=DisplayWidth(disp,screen)-ifb.width;
  229.     for (i=0;i<4;i++)
  230.         for (j=0;j<3;j++)
  231.             if(ShowIdLine(cfg.subwin_action[b][j][i].id,s,
  232.                     cfg.subwin_action[b][j][j].params))
  233.                 ShowLine(&x,&y,i,j,s,wlst,plst,mlst);
  234.     i=0;
  235.     while(!i) {
  236.         XSync(disp,False);
  237.         XNextEvent(disp,&xev);
  238.         switch (xev.type) {
  239.         case KeyPress:
  240.         case KeyRelease:
  241.         case ButtonPress:
  242.         case ButtonRelease:
  243.         case MotionNotify:
  244.             i=1;
  245.             break;
  246.         default:
  247.             break;
  248.         }
  249.     }
  250.     i=0;
  251.     while(wlst[i]) {
  252.         XDestroyWindow(disp,wlst[i]);
  253.         ImlibFreePixmap(imd,plst[i]);
  254.         ImlibFreePixmap(imd,mlst[i]);
  255.         i++;
  256.     }
  257.     ifb.moveresize=1;
  258. }
  259.  
  260. void GenListIcon(Icon *Icon_We_Are_Over) {
  261.  
  262.     int i,j,th;
  263.     int x,y,d;
  264.     unsigned int dui;
  265.     Window w1,w2;
  266.     char s[1024];
  267.     Window wlst[64];
  268.     Pixmap plst[64];
  269.     Pixmap mlst[64];
  270.     XEvent xev;
  271.  
  272.     for (i=0;i<64;i++) {
  273.         wlst[i]=0;
  274.         plst[i]=0;
  275.         mlst[i]=0;
  276.     }
  277.  
  278.  
  279.     XQueryPointer(disp,root,&w1,&w2,&x,&y,&d,&d,&dui);
  280.     th=0;
  281.     for(i=0;i<4;i++)
  282.         for(j=0;j<3;j++) 
  283.             if (ShowIdLine(icfg.action[j][i].id,s,icfg.action[j][i].params))
  284.                 th+=ifb.height;
  285.     if ((DisplayHeight(disp,screen)-y) < th)
  286.         y=DisplayHeight(disp,screen)-th;
  287.  
  288.     if ((DisplayWidth(disp,screen)-x)<ifb.width)
  289.         x=DisplayWidth(disp,screen)-ifb.width;
  290.     if(Icon_We_Are_Over)
  291.         ShowLine(&x,&y,i,j,Icon_We_Are_Over->ewin->title,wlst,plst,mlst);
  292.     for (i=0;i<4;i++)
  293.         for (j=0;j<3;j++)
  294.             if (ShowIdLine(icfg.action[j][i].id,s,icfg.action[j][i].params))
  295.                 ShowLine(&x,&y,i,j,s,wlst,plst,mlst);
  296.     XSync(disp,False);
  297.     XNextEvent(disp,&xev);
  298.     XPutBackEvent(disp,&xev);
  299.     i=0;
  300.     while(wlst[i]) {
  301.         XDestroyWindow(disp,wlst[i]);
  302.         ImlibFreePixmap(imd,plst[i]);
  303.         ImlibFreePixmap(imd,mlst[i]);
  304.         i++;
  305.     }
  306. }
  307.  
  308. void InfoBox() {
  309.     int x,y,d;
  310.     Window w1,w2;
  311.     unsigned int dui;
  312.  
  313.     if (ifb.nodo)
  314.         ifb.moveresize=1;
  315.     if (ifb.nodo) 
  316.         return;
  317.     XQueryPointer(disp,root,&w1,&w2,&x,&y,&d,&d,&dui);
  318.     if (w2) {
  319.         ShowInfo(w2);
  320.     } else {
  321.         ifb.moveresize=1;
  322.     }
  323.     timer_mode = 0;
  324. }
  325.  
  326. void ShowInfo(Window win) {
  327.     EWin *ewin;
  328.     BWin *bwin;
  329.     int wb,dsk;
  330.     int x,y,d;
  331.     unsigned int dui;
  332.     Window w1,w2;
  333.     EWin *wwin;
  334.     Window win2;
  335.     int i; /* j; */
  336.     Window wlst[2];
  337.     Pixmap plst[2];
  338.     Pixmap mlst[2];
  339.     XEvent xev;
  340.  
  341.     ewin=ListGetWinID(global_l,win);
  342.     if (ewin) {
  343.         XQueryPointer(disp,win,&w1,&w2,&x,&y,&d,&d,&dui);
  344.         win=w2;
  345.     }
  346.     ewin=ListGetSubWinID(global_l,win);
  347.     if ((dsk=WindowIsDeskInfo(win))>=0) {
  348.         XQueryPointer(disp,win,&w1,&win2,&d,&d,&d,&d,&dui);
  349.         wwin=WindowIsDeskInfoWin(win2);
  350.         if(wwin) {
  351.             XQueryPointer(disp,root,&w1,&w2,&x,&y,&d,&d,&dui);
  352.             if ((DisplayWidth(disp,screen)-x)<ifb.width)
  353.                 x=DisplayWidth(disp,screen)-ifb.width;
  354.             for(i=0;i<2;i++) {
  355.                 wlst[i]=0;
  356.                 plst[i]=0;
  357.                 mlst[i]=0;
  358.             }
  359.             ShowLine(&x,&y,4,4,wwin->title,wlst,plst,mlst);
  360.                XSync(disp,False);
  361.                XNextEvent(disp,&xev);
  362.                XPutBackEvent(disp,&xev);
  363.             for(i=0;i<2;i++) {
  364.                 XDestroyWindow(disp,wlst[i]);
  365.                 ImlibFreePixmap(imd,plst[i]);
  366.                 ImlibFreePixmap(imd,mlst[i]);
  367.             }
  368.         }
  369.     }
  370.     if (ewin) {
  371.         wb=GetEWinButtonID(ewin,win);
  372.         if((evmd.mode!=MODE_MOVE) && (evmd.mode!=MODE_RESIZE))
  373.             GenListEWin(wb);
  374.     } else {
  375.         bwin=GetButtonWinID(win);
  376.         if (bwin) {
  377.             GenListBtn(bwin);
  378.         } else if (win==icfg.bg_win) {
  379.             XQueryPointer(disp,win,&w1,&w2,&x,&y,&d,&d,&dui);
  380.             win=w2;
  381.             GenListIcon(GetIconWinID(win));
  382.         }
  383.     }
  384. }
  385.