Exemplo n.º 1
0
void Menu2ws(Menu *menu,short ws)
{
  XSetWindowAttributes wattr;
  XGCValues xgcv;
  Node *mi;

  xgcv.foreground=TheScreen.Colors[ws][UDE_Light].pixel;
  XChangeGC(disp,TheScreen.MenuLightGC,GCForeground,&xgcv);
  xgcv.foreground=TheScreen.Colors[ws][UDE_Shadow].pixel;
  XChangeGC(disp,TheScreen.MenuShadowGC,GCForeground,&xgcv);
  xgcv.foreground=TheScreen.Colors[ws][UDE_Back].pixel;
  XChangeGC(disp,TheScreen.MenuBackGC,GCForeground,&xgcv);
  xgcv.foreground=TheScreen.Colors[ws][UDE_StandardText].pixel;
  XChangeGC(disp,TheScreen.MenuTextGC,GCForeground,&xgcv);

  wattr.background_pixel=TheScreen.Colors[ws][UDE_Back].pixel;
  XChangeWindowAttributes(disp,menu->win,CWBackPixel,&wattr);
  mi=NULL;
  while((mi=NodeNext(menu->Items,mi))){
    MenuItem *item;
    item=mi->data;
    if(item->type!=I_LINE) {
      XChangeWindowAttributes(disp,item->win,CWBackPixel,&wattr);
      if(item->type==I_SUBMENU) Menu2ws(item->data,ws);
    }
  }
}
Exemplo n.º 2
0
size_t CgiListGetValues(Cgi const cgi,char ***darray,char const *name)
{
  size_t        size  = 0;
  size_t        idx   = 0;
  char        **store = NULL;
  struct pair  *pair;
  
  assert(darray != NULL);
  assert(name   != NULL);
  
  pair = CgiListGetPair(cgi,name);
  if (pair == NULL)
  {
    *darray = NULL;
    return(0);
  }
  
  while(NodeValid(&pair->node))
  {
    if (strcmp(pair->name,name) == 0)
    {
      if (idx == size)
      {
        store = realloc(store,size+256);
        size  += 256;
      }
      store[idx++] = pair->value;
    }
    pair = (struct pair *)NodeNext(&pair->node);
  }
  *darray = store;
  return(idx);
}
Exemplo n.º 3
0
void DrawMenuFrame(Menu *menu, int items)
{
  int a;
  Node *mi;

  XClearWindow(disp,menu->win);

  DrawBevel(menu->win,0,0,menu->width-1,menu->height-1,MENUBORDERW,\
                                      TheScreen.MenuLightGC,TheScreen.MenuShadowGC);
  if(menu->name) {
    DrawBevel(menu->win,MENUBORDERW,MENUBORDERW,menu->width-MENUBORDERW-1,\
                               menu->ItemHeight+MENUBORDERW-1,MENUBORDERW,\
                                             TheScreen.MenuShadowGC,TheScreen.MenuLightGC);
    XDrawString(disp,menu->win,TheScreen.MenuTextGC,MENUXOFS+2*MENUBORDERW,MENUYOFS+\
             2*MENUBORDERW+menu->font->ascent,menu->name,strlen(menu->name));
  }

  mi=NULL;
  while((mi=NodeNext(menu->Items,mi))){
    MenuItem *item;
    item=mi->data;
    if(item->type != I_LINE) {
      if(items) DrawItem(item, 0);
    } else {
      int h;
      h=item->y;
      for(a=0;a<MENUBORDERW;a++) {
        XDrawLine(disp,menu->win,TheScreen.MenuShadowGC,a+1,h-1-a,menu->width-a,h-1-a);
        XDrawLine(disp,menu->win,TheScreen.MenuLightGC,a,a+h,menu->width-a-2,a+h);
      }
    }
  }
}
Exemplo n.º 4
0
void ChangeWS(short WS)
{
  Node *n;
  short oldws;

  if(OnActiveWS(WS) || (WS >= TheScreen.desktop.WorkSpaces)
     || (Handle == MoveHandle) || (Handle == ResizeHandle)) return;

  oldws=TheScreen.desktop.ActiveWorkSpace;
  TheScreen.desktop.ActiveWorkSpace=WS;

  UpdateDesktop();
  SetWSBackground();

  n=NULL;
  while((n= NodeNext(TheScreen.UltimateList, n))) {
    UltimateContext *uc;

    uc = n->data;
    if(IsNormal(uc)) {
      if(uc->WorkSpace == oldws) {
	UnmapWin(uc);
      } else if(uc->WorkSpace==WS) {
        MapWin(uc,True);
      } else if(uc->WorkSpace==-1) {
        DrawWinBorder(uc);
      }
    }
  }

  if(activemen) {
    Menu2ws(RootMenu(activemen),WS);
    RedrawMenuTree();
  }
}
Exemplo n.º 5
0
void AppendMenuItem(Menu *menu,char *name,void *data,short type)
{
  MenuItem *item;
  XSetWindowAttributes wattr;
  int width;

  item=MyCalloc(1,sizeof(MenuItem));
  item->y=menu->height;
  item->menu=menu;

  if((item->type=type)==I_LINE) {
    menu->height+=2*MENUBORDERW;
    item->win=None;
    item->name=linename;
  } else {
    item->name=MyCalloc(strlen(name)+1,sizeof(char));
    strcpy(item->name,name);
    item->data=data;

    width=XTextWidth(menu->font,item->name,strlen(item->name)) +\
                                    4 * MENUBORDERW + 2*MENUXOFS;
    if(item->type==I_SUBMENU) width+=7*MENUBORDERW;
    if((item->type==I_SWITCH_ON)||(item->type==I_SWITCH_OFF))
      width+=6*MENUBORDERW;
    if(width>menu->width) {
      Node *mi=NULL;
      menu->width=width;
      while((mi=NodeNext(menu->Items,mi)))
        if(((MenuItem *)(mi->data))->type!=I_LINE)
          XResizeWindow(disp,((MenuItem *)(mi->data))->win,\
                menu->width-2*MENUBORDERW,menu->ItemHeight);
    }

    wattr.background_pixel=TheScreen.Colors[TheScreen.desktop.ActiveWorkSpace]\
                                                              [UDE_Back].pixel;
    wattr.backing_store=WhenMapped;
    wattr.override_redirect=True;
    item->win=XCreateWindow(disp,menu->win,MENUBORDERW,menu->height-MENUBORDERW\
                   ,menu->width-2*MENUBORDERW,menu->ItemHeight,0,CopyFromParent,
                                                     InputOutput,CopyFromParent,
                              (TheScreen.DoesBackingStore ? CWBackingStore : 0)|
                                         CWBackPixel|CWOverrideRedirect,&wattr);

    XSelectInput(disp, item->win, EnterWindowMask|ExposureMask);

    menu->height+=menu->ItemHeight;

    XSaveContext(disp,item->win,TheScreen.MenuContext,(XPointer)item);
  }

  if(!NodeAppend(menu->Items,item))
    SeeYa(1,"FATAL: out of memory!");
  XResizeWindow(disp,menu->win,menu->width,menu->height);
}
Exemplo n.º 6
0
void WithWin2WS(UltimateContext *uc,short ws)
{
  if(uc->group) {
    Node *n = NULL;
    while((n = NodeNext(uc->group->members, n))) { 
      ((UltimateContext *)(n->data))->WorkSpace = ws;
    }
    uc->group->WorkSpace = uc->WorkSpace;
  } else uc->WorkSpace = ws;
  ChangeWS(uc->WorkSpace);
}
Exemplo n.º 7
0
void StickyWin(UltimateContext *uc)
{
  if(uc->WorkSpace==-1) Win2WS(uc, TheScreen.desktop.ActiveWorkSpace);
  else Win2WS(uc, -1);
  if(uc->group) {
    Node *n = NULL;
    while((n = NodeNext(uc->group->members, n))) { 
      Win2WS(n->data, uc->WorkSpace);
    }
    uc->group->WorkSpace = uc->WorkSpace;
  }
}
Exemplo n.º 8
0
void DeleteSubMenus(Menu *menu)
{
  Node *mi;

  mi=NULL;
  while((mi=NodeNext(menu->Items,mi))){
    MenuItem *item;
    item=mi->data;
    if(item->type==I_SUBMENU) {
      DeleteMenuTree(item->data);
    }
  }
}
Exemplo n.º 9
0
void DeleteMenuTree(Menu *menu)
{
  Node *mi;

  mi=NULL;
  while((mi=NodeNext(menu->Items,mi))){
    MenuItem *item;
    item=mi->data;
    if(item->type==I_SUBMENU) {
      DeleteMenuTree(item->data);
    }
  }
  XUnmapWindow(disp,menu->win);
}
Exemplo n.º 10
0
void RemoveMenuBottomLines(Menu *men)
{
  Node *n;
  if((n=NodePrev(men->Items,NULL))&&(((MenuItem *)(n->data))->type == I_LINE)) {
    free(n->data);
    NodeDelete(men->Items,n);
    men->height-=2*MENUBORDERW;
    XResizeWindow(disp,men->win,men->width,men->height);
  }
  n=NULL;
  while((n=NodeNext(men->Items,n))){
    MenuItem *mi;
    mi=n->data;
    if(mi->type==I_SUBMENU) RemoveMenuBottomLines(mi->data);
  }
}
Exemplo n.º 11
0
size_t RFC822HeadersWrite(FILE *out,const List *list)
{
  struct pair *ppair;
  size_t       size;

  assert(out  != NULL);
  assert(list != NULL);
  
  for
  (
    size = 0 , ppair = (struct pair *)ListGetHead((List *)list);
    NodeValid(&ppair->node);
    ppair = (struct pair *)NodeNext(&ppair->node)
  )
  {
    size += RFC822HeaderWrite(out,ppair->name,ppair->value);
  }
  return(size);
}
Exemplo n.º 12
0
void DestroyMenu(Menu *menu)
{
  Node *mi;

  mi=NULL;
  while((mi=NodeNext(menu->Items,mi))) {
    MenuItem *item;
    item=mi->data;
    if(item->type!=I_LINE) {
      XDeleteContext(disp,item->win,TheScreen.MenuContext);
      XDestroyWindow(disp,item->win);
    }
    if(item->type==I_SUBMENU) DestroyMenu(item->data); /***/
    if(item->name!=linename) free(item->name);
    free(item);
  }
  XDeleteContext(disp, menu->win, TheScreen.MenuFrameContext);
  XDestroyWindow(disp,menu->win);
  NodeListDelete(&(menu->Items));
  if(menu->name) free(menu->name);
  free(menu);
}