void acprog_ondraw(void * x){
  ACONTROLP ctl= (ACONTROLP) x;
  APROGDP   d  = (APROGDP) ctl->d;
  CANVAS *  pc = &ctl->win->c;
  CANVAS *  c  = &d->control;
  
  if (d->hidden){
    ag_draw_ex(pc, ctl->win->bg, ctl->x, ctl->y, ctl->x, ctl->y, ctl->w, ctl->h);
    return;
  }
  
  if (d->onwait){
    int hp2    = floor(ctl->h/2.0);
    int draw_w = floor(ctl->w / 1.618);
    int move_w = ctl->w - draw_w;
    float crps = d->waitpos;
    if (crps>1.0) crps=2.0-crps;
    int move_x = round(move_w * crps);
    ag_draw(c,&d->bg,0,0);
    if (!atheme_draw("img.prograss.fill",c,move_x,0,draw_w,ctl->h)){
      dword hl1 = ag_calchighlight(acfg()->selectbg,acfg()->selectbg_g);      
      ag_roundgrad(c,move_x,0,draw_w,ctl->h,acfg()->selectbg_g,acfg()->selectbg,hp2);
      ag_roundgrad(c,move_x+2,2,draw_w-4,ctl->h-4,acfg()->selectbg,acfg()->selectbg_g,hp2-2);
      ag_roundgrad_ex(c,move_x+3,3,draw_w-6,ceil((ctl->h-6)/2.0),LOWORD(hl1),HIWORD(hl1),hp2,2,2,0,0);
    }
  }
  else if (!d->drawed){
    int issmall = -1;
    int draw_w  = d->width_current;
    int hp2     = floor(ctl->h/2.0);
    
    if (d->width_current<ctl->h){
      issmall   = d->width_current;
      draw_w    = ctl->h;
    }
    
    ag_draw(c,&d->bg,0,0);
    if (!atheme_draw("img.prograss.fill",c,0,0,draw_w,ctl->h)){
      dword hl1 = ag_calchighlight(acfg()->selectbg,acfg()->selectbg_g);      
      ag_roundgrad(c,0,0,draw_w,ctl->h,acfg()->selectbg_g,acfg()->selectbg,hp2);
      
      ag_roundgrad(c,2,2,draw_w-4,ctl->h-4,acfg()->selectbg,acfg()->selectbg_g,hp2-2);
      ag_roundgrad_ex(c,3,3,draw_w-6,ceil((ctl->h-6)/2.0),LOWORD(hl1),HIWORD(hl1),hp2,2,2,0,0);
    }
    
    if (issmall>=0)
      ag_draw_ex(c,&d->bg,issmall,0,issmall,0,ctl->w-issmall,ctl->h);

    d->drawed=1;
  }
  
  ag_draw(pc, &d->control,  ctl->x, ctl->y);
}
void acime2_drawbutton(ACIMEDP d, int x, int y, int w, int h, int id) {
  d->keyX[id] = x;
  d->keyW[id] = w;
  d->keyD[id] = 0;
  x++;
  y++;
  w -= 2;
  h -= 2;
  
  if (!atheme_draw("img.button", &d->control_rest, x, y, w, h)) {
    ag_roundgrad(&d->control_rest, x, y, w, h,          acfg()->border,     acfg()->border_g,    acfg()->roundsz);
    ag_roundgrad(&d->control_rest, x + 1, y + 1, w - 2, h - 2,  acfg()->controlbg,  acfg()->controlbg_g, acfg()->roundsz - 1);
  }
  
  if (!atheme_draw("img.button.push", &d->control_push, x, y, w, h)) {
    ag_roundgrad(&d->control_push, x, y, w, h,          acfg()->selectbg_g,     acfg()->selectbg,    acfg()->roundsz);
    ag_roundgrad(&d->control_push, x + 1, y + 1, w - 2, h - 2,  acfg()->selectbg,       acfg()->selectbg_g,  acfg()->roundsz - 1);
  }
}
void accb_ondraw(void * x){
  ACONTROLP   ctl= (ACONTROLP) x;
  ACCBDP      d  = (ACCBDP) ctl->d;
  CANVAS *    pc = &ctl->win->c;
  
  ag_draw(pc,&d->control,ctl->x,ctl->y);
  
  int halfdp   = ceil(((float) agdp())/2);
  int halfdp2  = halfdp*2;
  int chkY = ((ctl->h-d->chkS) / 2);
  
  byte drawed = 0;
  
  //-- Draw Check UI
  int minpad = 3*agdp();
  int addpad = 6*agdp();
  if (!d->checked){
    if (d->pushed)
      drawed=atheme_draw("img.checkbox.push", pc,ctl->x+halfdp,ctl->y+chkY-minpad,d->chkS+addpad,d->chkS+addpad);
    else if (d->focused)
      drawed=atheme_draw("img.checkbox.focus", pc,ctl->x+halfdp,ctl->y+chkY-minpad,d->chkS+addpad,d->chkS+addpad);
    else
      drawed=atheme_draw("img.checkbox", pc,ctl->x+halfdp,ctl->y+chkY-minpad,d->chkS+addpad,d->chkS+addpad);
  }
  else{
    if (d->pushed)
      drawed=atheme_draw("img.checkbox.on.push", pc,ctl->x+halfdp,ctl->y+chkY-minpad,d->chkS+addpad,d->chkS+addpad);
    else if (d->focused)
      drawed=atheme_draw("img.checkbox.on.focus", pc,ctl->x+halfdp,ctl->y+chkY-minpad,d->chkS+addpad,d->chkS+addpad);
    else
      drawed=atheme_draw("img.checkbox.on", pc,ctl->x+halfdp,ctl->y+chkY-minpad,d->chkS+addpad,d->chkS+addpad);
  }
  
  //-- Generic Draw
  if (!drawed){
    if (d->pushed)
      ag_roundgrad(pc, minpad+ctl->x+halfdp,  ctl->y+chkY,         d->chkS,          d->chkS,          acfg()->selectbg_g,  acfg()->selectbg, 0);
    else if(d->focused)
      ag_roundgrad(pc, minpad+ctl->x+halfdp,  ctl->y+chkY,         d->chkS,          d->chkS,          acfg()->selectbg,  acfg()->selectbg_g, 0);
    else
      ag_roundgrad(pc, minpad+ctl->x+halfdp,  ctl->y+chkY,         d->chkS,          d->chkS,          acfg()->controlbg_g,  acfg()->controlbg, 0);
    ag_roundgrad(pc, minpad+ctl->x+halfdp2, ctl->y+chkY+halfdp,  d->chkS-halfdp2,  d->chkS-halfdp2,  acfg()->textbg,       acfg()->textbg,    0);
    if (d->checked){
      ag_roundgrad(pc, minpad+ctl->x+halfdp+halfdp2, ctl->y+chkY+halfdp2,  d->chkS-(halfdp2*2),  d->chkS-(halfdp2*2),  acfg()->selectbg,   acfg()->selectbg_g,0);
    }
  }
}
void accheck_redrawitem(ACONTROLP ctl, int index){
  ACCHECKDP d = (ACCHECKDP) ctl->d;
  if (d->acheck_signature != 133) return; //-- Not Valid Signature
  if ((index>=d->itemn)||(index<0)) return; //-- Not Valid Index
  
  ACCHECKIP p = d->items[index];
  CANVAS *  c = &d->client;
  
  //-- Cleanup Background
  ag_rect(c,0,p->y,d->clientWidth,p->h,acfg()->textbg);
  
  if (p->isTitle){
    ag_roundgrad(c,0,p->y,d->clientWidth,p->h,acfg()->titlebg,acfg()->titlebg_g,0);
    ag_textf(c,d->clientTextW+(agdp()*14),(d->clientTextX-(agdp()*14))+1,p->y+p->ty,p->title,acfg()->titlebg_g,0);
    ag_text(c,d->clientTextW+(agdp()*14),d->clientTextX-(agdp()*14),p->y+p->ty-1,p->title,acfg()->titlefg,0);
  }
  else{
    color txtcolor = acfg()->textfg;
    color graycolor= acfg()->textfg_gray;
    byte isselectcolor=0;
    if (index==d->touchedItem){
      if (!atheme_draw("img.selection.push", c,0,p->y+agdp(),d->clientWidth,p->h-(agdp()*2))){
        color pshad = ag_calpushad(acfg()->selectbg_g);
        dword hl1 = ag_calcpushlight(acfg()->selectbg,pshad);
        ag_roundgrad(c,0,p->y+agdp(),d->clientWidth,p->h-(agdp()*2),acfg()->selectbg,pshad,(agdp()*acfg()->roundsz));
        ag_roundgrad(c,0,p->y+agdp(),d->clientWidth,(p->h-(agdp()*2))/2,LOWORD(hl1),HIWORD(hl1),(agdp()*acfg()->roundsz));
      }
      
      graycolor = txtcolor = acfg()->selectfg;
      isselectcolor=1;
    }
    else if ((index==d->focusedItem)&&(d->focused)){
      if (!atheme_draw("img.selection", c,0,p->y+agdp(),d->clientWidth,p->h-(agdp()*2))){
        dword hl1 = ag_calchighlight(acfg()->selectbg,acfg()->selectbg_g);
        ag_roundgrad(c,0,p->y+agdp(),d->clientWidth,p->h-(agdp()*2),acfg()->selectbg,acfg()->selectbg_g,(agdp()*acfg()->roundsz));
        ag_roundgrad(c,0,p->y+agdp(),d->clientWidth,(p->h-(agdp()*2))/2,LOWORD(hl1),HIWORD(hl1),(agdp()*acfg()->roundsz));
      }
      graycolor = txtcolor = acfg()->selectfg;
      isselectcolor=1;
    }
    if (index<d->itemn-1){
      //-- Not Last... Add Separator
      color sepcl = ag_calculatealpha(acfg()->textbg,acfg()->textfg_gray,80);
      ag_rect(c,0,p->y+p->h-1,d->clientWidth,1,sepcl);
    }
    
    //-- Now Draw The Text
    if (isselectcolor){
      ag_textf(c,d->clientTextW,d->clientTextX,p->y+p->ty,p->title,acfg()->selectbg_g,0);
      ag_textf(c,d->clientTextW,d->clientTextX,p->y+p->dy,p->desc,acfg()->selectbg_g,0);
    }
    ag_text(c,d->clientTextW,d->clientTextX-1,p->y+p->ty-1,p->title,txtcolor,0);
    ag_text(c,d->clientTextW,d->clientTextX-1,p->y+p->dy-1,p->desc,graycolor,0);
    
    //-- Now Draw The Checkbox
    int halfdp   = ceil(((float) agdp())/2);
    int halfdp2  = halfdp*2;
    int chkbox_s = (agdp()*10);
    int chkbox_x = round((d->clientTextX/2)- ((chkbox_s+2)/2));
    int chkbox_y = p->y + round((p->h/2) - (chkbox_s/2));
    
    byte drawed = 0;
    int minpad = 3*agdp();
    int addpad = 6*agdp();
    if (p->checked){
      if (index==d->touchedItem)
        drawed=atheme_draw("img.checkbox.on.push", c,chkbox_x-minpad,chkbox_y-minpad,chkbox_s+addpad,chkbox_s+addpad);
      else if ((index==d->focusedItem)&&(d->focused))
        drawed=atheme_draw("img.checkbox.on.focus", c,chkbox_x-minpad,chkbox_y-minpad,chkbox_s+addpad,chkbox_s+addpad);
      else
        drawed=atheme_draw("img.checkbox.on", c,chkbox_x-minpad,chkbox_y-minpad,chkbox_s+addpad,chkbox_s+addpad);
    }
    else{
      if (index==d->touchedItem)
        drawed=atheme_draw("img.checkbox.push", c,chkbox_x-minpad,chkbox_y-minpad,chkbox_s+addpad,chkbox_s+addpad);
      else if ((index==d->focusedItem)&&(d->focused))
        drawed=atheme_draw("img.checkbox.focus", c,chkbox_x-minpad,chkbox_y-minpad,chkbox_s+addpad,chkbox_s+addpad);
      else
        drawed=atheme_draw("img.checkbox", c,chkbox_x-minpad,chkbox_y-minpad,chkbox_s+addpad,chkbox_s+addpad);
    }
    if (!drawed){
      ag_roundgrad(c,
        chkbox_x,
        chkbox_y,
        chkbox_s,
        chkbox_s,
        acfg()->controlbg_g,
        acfg()->controlbg,
        0);
      ag_roundgrad(c,
        chkbox_x+halfdp,
        chkbox_y+halfdp,
        chkbox_s-halfdp2,
        chkbox_s-halfdp2,
        acfg()->textbg,
        acfg()->textbg,
        0);
      if (p->checked){
        ag_roundgrad(c,
          chkbox_x+halfdp2,
          chkbox_y+halfdp2,
          chkbox_s-(halfdp2*2),
          chkbox_s-(halfdp2*2),
          acfg()->selectbg,
          acfg()->selectbg_g,
          0);
      }
    }
  }
}
void acopt_redrawitem(ACONTROLP ctl, int index) {
  ACOPTDP d = (ACOPTDP) ctl->d;
  
  if (d->acheck_signature != 136) {
    return;  //-- Not Valid Signature
  }
  
  if ((index >= d->itemn) || (index < 0)) {
    return;  //-- Not Valid Index
  }
  
  ACOPTIP p = d->items[index];
  CANVAS  * c = &d->client;
  //-- Cleanup Background
  ag_rect(c, 0, p->y, d->clientWidth, p->h, acfg()->textbg);
  
  if (p->isTitle) {
    ag_roundgrad(c, 0, p->y, d->clientWidth, p->h, acfg()->controlbg,  acfg()->controlbg_g, 0);
    ag_rect(c, 0, p->y + p->h - 1, d->clientWidth, 1, acfg()->border);
    ag_rect(c, 0, p->y + p->h - 2, d->clientWidth, 1, acfg()->controlbg);
    char ntitle[256];
    snprintf(ntitle, 256, "<b>%s</b>", p->title);
    ag_textf(c, d->clientTextW + (agdp() * 14), (d->clientTextX - (agdp() * 14)) + 1, p->y + p->ty, ntitle, acfg()->controlbg, 0);
    ag_text(c, d->clientTextW + (agdp() * 14), d->clientTextX - (agdp() * 14), p->y + p->ty - 1, ntitle, acfg()->controlfg, 0);
  }
  else {
    color txtcolor = acfg()->textfg;
    color graycolor = acfg()->textfg_gray;
    byte isselectcolor = 0;
    
    if (index == d->touchedItem) {
      if (!atheme_draw("img.selection.push", c, 0, p->y + agdp(), d->clientWidth, p->h - (agdp() * 2))) {
        color pshad = ag_calpushad(acfg()->selectbg_g);
        dword hl1 = ag_calcpushlight(acfg()->selectbg, pshad);
        ag_roundgrad(c, 0, p->y + agdp(), d->clientWidth, p->h - (agdp() * 2), acfg()->selectbg, pshad, (agdp()*acfg()->roundsz));
        ag_roundgrad(c, 0, p->y + agdp(), d->clientWidth, (p->h - (agdp() * 2)) / 2, LOWORD(hl1), HIWORD(hl1), (agdp()*acfg()->roundsz));
      }
      
      graycolor = txtcolor = acfg()->selectfg;
      isselectcolor = 1;
    }
    else if ((index == d->focusedItem) && (d->focused)) {
      if (!atheme_draw("img.selection", c, 0, p->y + agdp(), d->clientWidth, p->h - (agdp() * 2))) {
        dword hl1 = ag_calchighlight(acfg()->selectbg, acfg()->selectbg_g);
        ag_roundgrad(c, 0, p->y + agdp(), d->clientWidth, p->h - (agdp() * 2), acfg()->selectbg, acfg()->selectbg_g, (agdp()*acfg()->roundsz));
        ag_roundgrad(c, 0, p->y + agdp(), d->clientWidth, (p->h - (agdp() * 2)) / 2, LOWORD(hl1), HIWORD(hl1), (agdp()*acfg()->roundsz));
      }
      
      graycolor = txtcolor = acfg()->selectfg;
      isselectcolor = 1;
    }
    
    if (index < d->itemn - 1) {
      //-- Not Last... Add Separator
      color sepcl = ag_calculatealpha(acfg()->textbg, acfg()->textfg_gray, 80);
      ag_rect(c, 0, p->y + p->h - 1, d->clientWidth, 1, sepcl);
    }
    
    //-- Now Draw The Text
    if (isselectcolor) {
      ag_textf(c, d->clientTextW, d->clientTextX, p->y + p->ty, p->title, acfg()->selectbg_g, 1);
      ag_textf(c, d->clientTextW, d->clientTextX, p->y + p->dy, p->desc, acfg()->selectbg_g, 0);
    }
    
    ag_text(c, d->clientTextW, d->clientTextX - 1, p->y + p->ty - 1, p->title, txtcolor, 1);
    ag_text(c, d->clientTextW, d->clientTextX - 1, p->y + p->dy - 1, p->desc, graycolor, 0);
    //-- Now Draw The Checkbox
    int halfdp   = ceil(((float) agdp()) / 2);
    int halfdp2  = halfdp * 2;
    int optbox_s = (agdp() * 10);
    int optbox_r = floor(optbox_s / 2);
    int optbox_x = round((d->clientTextX / 2) - (optbox_s / 2));
    int optbox_y = p->y + round((p->h / 2) - (optbox_s / 2));
    byte drawed = 0;
    int minpad = 3 * agdp();
    int addpad = 6 * agdp();
    
    if (p->id == d->selectedIndexs[p->group]) {
      if (index == d->touchedItem) {
        drawed = atheme_draw("img.radio.on.push", c, optbox_x - minpad, optbox_y - minpad, optbox_s + addpad, optbox_s + addpad);
      }
      else if ((index == d->focusedItem) && (d->focused)) {
        drawed = atheme_draw("img.radio.on.focus", c, optbox_x - minpad, optbox_y - minpad, optbox_s + addpad, optbox_s + addpad);
      }
      else {
        drawed = atheme_draw("img.radio.on", c, optbox_x - minpad, optbox_y - minpad, optbox_s + addpad, optbox_s + addpad);
      }
    }
    else {
      if (index == d->touchedItem) {
        drawed = atheme_draw("img.radio.push", c, optbox_x - minpad, optbox_y - minpad, optbox_s + addpad, optbox_s + addpad);
      }
      else if ((index == d->focusedItem) && (d->focused)) {
        drawed = atheme_draw("img.radio.focus", c, optbox_x - minpad, optbox_y - minpad, optbox_s + addpad, optbox_s + addpad);
      }
      else {
        drawed = atheme_draw("img.radio", c, optbox_x - minpad, optbox_y - minpad, optbox_s + addpad, optbox_s + addpad);
      }
    }
    
    if (!drawed) {
      ag_roundgrad(c,
                   optbox_x,
                   optbox_y,
                   optbox_s,
                   optbox_s,
                   acfg()->controlbg_g,
                   acfg()->controlbg,
                   optbox_r
                  );
      ag_roundgrad(c,
                   optbox_x + halfdp,
                   optbox_y + halfdp,
                   optbox_s - halfdp2,
                   optbox_s - halfdp2,
                   acfg()->textbg,
                   acfg()->textbg,
                   optbox_r - halfdp);
                   
      if (p->id == d->selectedIndexs[p->group]) {
        ag_roundgrad(c,
                     optbox_x + halfdp2,
                     optbox_y + halfdp2,
                     optbox_s - (halfdp2 * 2),
                     optbox_s - (halfdp2 * 2),
                     acfg()->selectbg,
                     acfg()->selectbg_g,
                     optbox_r - halfdp2);
      }
    }
  }
}
예제 #6
0
byte aw_confirm(AWINDOWP parent, char * titlev,char * textv,char * img,char * yes_text,char * no_text){
  CANVAS * tmpc = aw_muteparent(parent);
  //-- Set Mask
  on_dialog_window = 1;
  ag_rectopa(agc(),0,0,agw(),agh(),0x0000,180);
  ag_sync();
  
  char title[64];
  char text[512];
  snprintf(title,64,"%s",titlev);
  snprintf(text,512,"%s",textv);
  
  int pad   = agdp()*4;
  int winW  = agw()-(pad*2);
  int txtW  = winW-(pad*2);
  int txtX  = pad*2;
  int btnH  = agdp()*20;
  int titW  = ag_txtwidth(title,1);
  int titH  = ag_fontheight(1) + (pad*2);
  
  PNGCANVASP winp = atheme("img.dialog");
  PNGCANVASP titp = atheme("img.dialog.titlebar");
  APNG9      winv;
  APNG9      titv;
  int vtitY = -1;
  int vpadB = -1;
  int vimgX = pad*2;
  if (titp!=NULL){
    if (apng9_calc(titp,&titv,1)){
      int tmptitH = titH - (pad*2);
      titH        = tmptitH + (titv.t+titv.b);
      vtitY       = titv.t;
    }
  }
  if (winp!=NULL){
    if (apng9_calc(winp,&winv,1)){
      txtW = winW - (winv.l+winv.r);
      txtX = pad  + (winv.l);
      vimgX= pad  + (winv.l);
      vpadB= winv.b;
    }
  }
  
  //-- Load Icon
  PNGCANVAS ap;
  byte imgE = 0; int imgW = 0; int imgH = 0;
  if (apng_load(&ap,img)){
    imgE      = 1;
    imgW      = min(ap.w,agdp()*30);
    imgH      = min(ap.h,agdp()*30);
    int imgA  = pad + imgW;
    txtX     += imgA;
    txtW     -= imgA;
  }
  
  int txtH    = ag_txtheight(txtW,text,0);
  int infH    = ((imgE)&&(txtH<imgH))?imgH:txtH;
    
  //-- Calculate Window Size & Position
  int winH    = titH + infH + btnH + (pad*3);
  if (vpadB!=-1){
    winH    = titH + infH + btnH + (pad*2) + vpadB;
  }
  int winX    = pad;
  int winY    = (agh()/2) - (winH/2);
  
  //-- Calculate Title Size & Position
  int titX    = (agw()/2) - (titW/2);
  int titY    = winY + pad;
  if (vtitY!=-1) titY = winY+vtitY;

  //-- Calculate Text Size & Position
  int infY    = winY + titH + pad;
  int txtY    = infY + ((infH - txtH) / 2);
  int imgY    = infY;
  
  //-- Calculate Button Size & Position
  int btnW    = (txtW / 2) - (pad/2);
  int btnY    = infY+infH+pad;
  int btnX    = txtX;
  int btnX2   = txtX+(txtW/2)+(pad/2);
  
  //-- Initializing Canvas
  CANVAS alertbg;
  ag_canvas(&alertbg,agw(),agh());
  ag_draw(&alertbg,agc(),0,0);
  
  //-- Draw Window
  if (!atheme_draw("img.dialog", &alertbg, winX-1,winY-1,winW+2,winH+2)){
    ag_roundgrad(&alertbg,winX-1,winY-1,winW+2,winH+2,acfg_var.border,acfg_var.border_g,(acfg_var.roundsz*agdp())+1);
    ag_roundgrad(&alertbg,winX,winY,winW,winH,acfg_var.dialogbg,acfg_var.dialogbg_g,acfg_var.roundsz*agdp());
  }
  
  //-- Draw Title
  if (!atheme_draw("img.dialog.titlebar", &alertbg, winX,winY,winW,titH)){
    ag_roundgrad_ex(&alertbg,winX,winY,winW,titH,acfg_var.dlgtitlebg,acfg_var.dlgtitlebg_g,acfg_var.roundsz*agdp(),1,1,0,0);
  }
  ag_textf(&alertbg,titW,titX+1,titY+1,title,acfg_var.dlgtitlebg_g,1);
  ag_text(&alertbg,titW,titX,titY,title,acfg_var.dlgtitlefg,1);
  
  //-- Draw Image
  if (imgE){
    apng_draw_ex(&alertbg,&ap,vimgX,imgY,0,0,imgW,imgH);
    apng_close(&ap);
  }
  
  //-- Draw Text
  ag_textf(&alertbg,txtW,txtX+1,txtY+1,text,acfg_var.dialogbg,0);
  ag_text(&alertbg,txtW,txtX,txtY,text,acfg_var.dialogfg,0);
  
  AWINDOWP hWin   = aw(&alertbg);
  
  acbutton(hWin,btnX,btnY,btnW,btnH,(yes_text==NULL?acfg_var.text_yes:yes_text),0,6);
  acbutton(hWin,btnX2,btnY,btnW,btnH,(no_text==NULL?acfg_var.text_no:no_text),0,5);
      
  aw_show(hWin);
  byte ondispatch = 1;
  byte res = 0;
  while(ondispatch){
    dword msg=aw_dispatch(hWin);
    switch (aw_gm(msg)){
      case 6: res=1; ondispatch = 0; break;
      case 5: ondispatch = 0; break;
    }
  }
  aw_destroy(hWin);
  ag_ccanvas(&alertbg);
  on_dialog_window = 0;
  aw_unmuteparent(parent,tmpc);
  return res;
}
예제 #7
0
void aw_textdialog(AWINDOWP parent,char * titlev,char * text,char * ok_text){
  
  // actext(hWin,txtX,txtY,txtW,txtH,text,0);
  CANVAS * tmpc = aw_muteparent(parent);
  //-- Set Mask
  on_dialog_window = 1;
  ag_rectopa(agc(),0,0,agw(),agh(),0x0000,180);
  ag_sync();
  
  char title[64];
  snprintf(title,64,"%s",titlev);
  
  int pad   = agdp()*4;
  int winW  = agw()-(pad*2);
  int txtW  = winW-(pad*2);
  int txtX  = pad*2;
  int btnH  = agdp()*20;
  int titW  = ag_txtwidth(title,1);
  int titH  = ag_fontheight(1) + (pad*2);
  
  PNGCANVASP winp = atheme("img.dialog");
  PNGCANVASP titp = atheme("img.dialog.titlebar");
  APNG9      winv;
  APNG9      titv;
  int vtitY = -1;
  int vpadB = pad;
  int vimgX = pad*2;
  if (titp!=NULL){
    if (apng9_calc(titp,&titv,1)){
      int tmptitH = titH - (pad*2);
      titH        = tmptitH + (titv.t+titv.b);
      vtitY       = titv.t;
    }
  }
  if (winp!=NULL){
    if (apng9_calc(winp,&winv,1)){
      txtW = winW - (winv.l+winv.r);
      txtX = pad  + (winv.l);
      vimgX= pad  + (winv.l);
      vpadB= winv.b;
    }
  }
  
  byte imgE = 0; int imgW = 0; int imgH = 0;
  int txtH    = agh()/2;
  int infH    = txtH;
  
  //-- Calculate Window Size & Position
  int winH    = titH + infH + btnH + (pad*2) + vpadB;
  
  int winX    = pad;
  int winY    = (agh()/2) - (winH/2);
  
  //-- Calculate Title Size & Position
  int titX    = (agw()/2) - (titW/2);
  int titY    = winY + pad;
  if (vtitY!=-1) titY = winY+vtitY;
  
  //-- Calculate Text Size & Position
  int infY    = winY + titH + pad;
  int txtY    = infY;
  
  //-- Calculate Button Size & Position
  int btnW    = winW / 2;
  int btnY    = infY+infH+pad;
  int btnX    = (agw()/2) - (btnW/2);
  
  //-- Initializing Canvas
  CANVAS alertbg;
  ag_canvas(&alertbg,agw(),agh());
  ag_draw(&alertbg,agc(),0,0);
  
  //-- Draw Window
  if (!atheme_draw("img.dialog", &alertbg, winX,winY,winW,winH)){
    ag_roundgrad(&alertbg,winX-1,winY-1,winW+2,winH+2,acfg_var.border,acfg_var.border_g,(acfg_var.roundsz*agdp())+1);
    ag_roundgrad(&alertbg,winX,winY,winW,winH,acfg_var.dialogbg,acfg_var.dialogbg_g,acfg_var.roundsz*agdp());
  }
  
  //-- Draw Title
  if (!atheme_draw("img.dialog.titlebar", &alertbg, winX,winY,winW,titH)){
    ag_roundgrad_ex(&alertbg,winX,winY,winW,titH,acfg_var.dlgtitlebg,acfg_var.dlgtitlebg_g,acfg_var.roundsz*agdp(),1,1,0,0);
  }
  
  ag_textf(&alertbg,titW,titX+1,titY+1,title,acfg_var.dlgtitlebg_g,1);
  ag_text(&alertbg,titW,titX,titY,title,acfg_var.dlgtitlefg,1);
  
  AWINDOWP hWin   = aw(&alertbg);
  actext(hWin,txtX,txtY,txtW,txtH,text,0);
  ACONTROLP okbtn=acbutton(hWin,btnX,btnY,btnW,btnH,(ok_text==NULL?acfg_var.text_ok:ok_text),0,5);
    
  aw_show(hWin);
  aw_setfocus(hWin,okbtn);
  byte ondispatch = 1;
  while(ondispatch){
    dword msg=aw_dispatch(hWin);
    switch (aw_gm(msg)){
      case 5: ondispatch = 0; break;
    }
  }
  aw_destroy(hWin);
  ag_ccanvas(&alertbg);
  on_dialog_window = 0;
  aw_unmuteparent(parent,tmpc);
}
예제 #8
0
/*
 * Descriptions:
 * -------------
 * AROMA File Manager : Permission File
 *
 */
byte auido_setperm(AWINDOWP parent,char * path, char * fn)
{
  struct stat fst;
  byte buf[12];
  memset(buf,0,12);
	if (!stat(path, &fst)) {		  
		buf[11] = (fst.st_mode & S_IXOTH) ? 1 : 0;
		buf[10] = (fst.st_mode & S_IWOTH) ? 1 : 0;
		buf[9]  = (fst.st_mode & S_IROTH) ? 1 : 0;
		  
		buf[8] = (fst.st_mode & S_IXGRP) ? 1 : 0;
		buf[7] = (fst.st_mode & S_IWGRP) ? 1 : 0;
		buf[6] = (fst.st_mode & S_IRGRP) ? 1 : 0;
		  
		buf[5] = (fst.st_mode & S_IXUSR) ? 1 : 0;
		buf[4] = (fst.st_mode & S_IWUSR) ? 1 : 0;
		buf[3] = (fst.st_mode & S_IRUSR) ? 1 : 0;
		
		buf[2] = (fst.st_mode & S_ISVTX) ? 1 : 0;
		buf[1] = (fst.st_mode & S_ISGID) ? 1 : 0;
		buf[0] = (fst.st_mode & S_ISUID) ? 1 : 0;
	}
	
  //-- Init Dialog Window
	CANVAS *tmpc = aw_muteparent(parent);
	aw_set_on_dialog(2);
	ag_rectopa(agc(), 0, 0, agw(), agh(), 0x0000, 180);
	ag_sync();

	//-- Initializing Canvas
	CANVAS bg;
	ag_canvas(&bg, agw(), agh());
	ag_draw(&bg, agc(), 0, 0);

	//-- Size & Position
	/*
	   MainTitle
	   SubTitle
	   [PAD]
	   user  group others
	   [x] r [x] w [x] x
	   [x] r [x] w [x] x
	   [x] r [x] w [x] x
	   [x] s [x] g [x] t
	   [PAD]
	   [ BUTTONS ]
	 */
	 
	int pad  = agdp() * 4;
	int padB = pad;
	int padT = pad;
	int padL = pad;
	int padR = pad;
	PNGCANVASP winp = atheme("img.dialog");
	APNG9 winv;
	if (winp != NULL) {
		if (apng9_calc(winp, &winv, 1)) {
			padL = winv.l;
			padR = winv.r;
			padB = winv.b;
			padT = winv.t;
		}
	}

	int hpad = agdp() * 2;
	int winW = agw() - (pad * 2);	//-- Window
	int winX = pad;
	int cliW = winW - (padL + padR + (hpad*2));	//-- Window Client
	int cliX = pad + padL + hpad;
	int titH = ag_fontheight(1) + (agdp() * 2);	//-- Title Height
	int chkH = agdp()*20;
	int txtH = ag_fontheight(0) + agdp();	      //-- Text Interface Height
	int btnH = agdp() * 24;
	int cliH = titH + txtH + (chkH * 4) + btnH + (pad);
	int winH = cliH + padT + padB;
	int winY = (agh() / 2) - (winH / 2);
	int cliY = winY + padT;
	int _Y   = cliY;

	//-- Draw Canvas
	if (!atheme_draw("img.dialog", &bg, winX, winY, winW, winH)) {
		ag_roundgrad(&bg, winX - 1, winY - 1, winW + 2, winH + 2,
			     acfg()->border, acfg()->border_g,
			     (acfg()->roundsz * agdp()) + 1);
		ag_roundgrad(&bg, winX, winY, winW, winH, acfg()->dialogbg,
			     acfg()->dialogbg_g, acfg()->roundsz * agdp());
	}

	//-- Init Window & Controls
	AWINDOWP hWin = aw(&bg);

  ACONTROLP txtTitle =
    aclabel(hWin, cliX, _Y, cliW, titH,
	    alang_get("tools.chmod"), 1, 1, 2, acfg()->winfg);
	_Y+=titH;
	
  ACONTROLP txtFilename =
    aclabel(hWin, cliX, _Y, cliW, txtH,
	    fn, 0, 1, 2, acfg()->winfg);
  _Y+=txtH+pad;
  
  int colW = cliW / 4;
  int col1 = cliX;
  int col2 = col1 + colW;
  int col3 = col2 + colW;
  int col4 = col3 + colW;
  
  aclabel(hWin, col1, _Y, colW, chkH,
	    alang_get("tools.chmod.user"), 0, 1, 1, acfg()->winfg);
  ACONTROLP cbR1 = accb(hWin,col2,_Y,colW,chkH,alang_get("tools.chmod.read"),buf[3]);
  ACONTROLP cbW1 = accb(hWin,col3,_Y,colW,chkH,alang_get("tools.chmod.write"),buf[4]);
  ACONTROLP cbX1 = accb(hWin,col4,_Y,colW,chkH,alang_get("tools.chmod.exec"),buf[5]);
  _Y+=chkH;
  
  aclabel(hWin, col1, _Y, colW, chkH,
	    alang_get("tools.chmod.group"), 0, 1, 1, acfg()->winfg);
  ACONTROLP cbR2 = accb(hWin,col2,_Y,colW,chkH,alang_get("tools.chmod.read"),buf[6]);
  ACONTROLP cbW2 = accb(hWin,col3,_Y,colW,chkH,alang_get("tools.chmod.write"),buf[7]);
  ACONTROLP cbX2 = accb(hWin,col4,_Y,colW,chkH,alang_get("tools.chmod.exec"),buf[8]);
  _Y+=chkH;
  
  aclabel(hWin, col1, _Y, colW, chkH,
	    alang_get("tools.chmod.others"), 0, 1, 1, acfg()->winfg);
  ACONTROLP cbR3 = accb(hWin,col2,_Y,colW,chkH,alang_get("tools.chmod.read"),buf[9]);
  ACONTROLP cbW3 = accb(hWin,col3,_Y,colW,chkH,alang_get("tools.chmod.write"),buf[10]);
  ACONTROLP cbX3 = accb(hWin,col4,_Y,colW,chkH,alang_get("tools.chmod.exec"),buf[11]);
  _Y+=chkH;

  ACONTROLP cbZ1 = accb(hWin,col2,_Y,colW,chkH,alang_get("tools.chmod.setuid"),buf[0]);
  ACONTROLP cbZ2 = accb(hWin,col3,_Y,colW,chkH,alang_get("tools.chmod.setgid"),buf[1]);
  ACONTROLP cbZ3 = accb(hWin,col4,_Y,colW,chkH,alang_get("tools.chmod.sticky"),buf[2]);
  
  _Y+=chkH;
  int btnW = cliW / 2;
  int btn1 = cliX;
  int btn2 = btn1 + btnW;
	ACONTROLP okBtn =
	    imgbtn(hWin, btn1, _Y, btnW-(pad/2), btnH, aui_icons(33), alang_get("ok"), 3, 6);

  ACONTROLP cancelBtn =
	    imgbtn(hWin, btn2+(pad/2), _Y, btnW-(pad/2), btnH, aui_icons(0), alang_get("cancel"), 3, 5);
	    
	//-- Show Window
	aw_show_ex(hWin, 0, 0, okBtn);
	byte ondispatch = 1;
  byte retval = 1;
	//-- Dispatch
	do {
		dword msg = aw_dispatch(hWin);
		switch (aw_gm(msg)) {
		case 5:
			{
				ondispatch = 0;
			}
			break;
		case 6:
			{
				// ondispatch = 0;
				buf[0]=accb_ischecked(cbZ1);
        buf[1]=accb_ischecked(cbZ2);
        buf[2]=accb_ischecked(cbZ3);
        buf[3]=accb_ischecked(cbR1);
        buf[4]=accb_ischecked(cbW1);
        buf[5]=accb_ischecked(cbX1);
        buf[6]=accb_ischecked(cbR2);
        buf[7]=accb_ischecked(cbW2);
        buf[8]=accb_ischecked(cbX2);
        buf[9]=accb_ischecked(cbR3);
        buf[10]=accb_ischecked(cbW3);
        buf[11]=accb_ischecked(cbX3);
        
        mode_t newmod = 0;
        if (buf[0]) newmod |= S_ISUID;
        if (buf[1]) newmod |= S_ISGID;
        if (buf[2]) newmod |= S_ISVTX;
        if (buf[3]) newmod |= S_IRUSR;
        if (buf[4]) newmod |= S_IWUSR;
        if (buf[5]) newmod |= S_IXUSR;
        if (buf[6]) newmod |= S_IRGRP;
        if (buf[7]) newmod |= S_IWGRP;
        if (buf[8]) newmod |= S_IXGRP;
        if (buf[9]) newmod |= S_IROTH;
        if (buf[10]) newmod |= S_IWOTH;
        if (buf[11]) newmod |= S_IXOTH;

        printf("CHMOD %o - %s\n",newmod,path);
        chmod(path,newmod);
        
        ondispatch = 0;
        retval = 0;
			}
			break;
		}
	}
	while (ondispatch);

	//-- Release Resources
	aw_destroy(hWin);
	ag_ccanvas(&bg);
	aw_set_on_dialog(0);
	aw_unmuteparent(parent, tmpc);
	
	return retval;
}
ACONTROLP acprog(
  AWINDOWP win,
  int x,
  int y,
  int w,
  int h,
  float value
){
  //-- Validate Minimum Size
  if (h<agdp()*5)  h=agdp()*5;
  if (w<agdp()*10) w=agdp()*10;
  
  //-- Initializing Button Data
  APROGDP d = (APROGDP) malloc(sizeof(APROGD));
  memset(d,0,sizeof(APROGD));
  
  //-- Save Touch Message & Set Stats
  d->value        = value;
  d->drawed       = 0;
  d->width_current= ceil(value * w);
  d->hidden       = 0;
  d->onwait       = 0;
  d->waitpos      = 0.0;
  d->wait_thread  = 0;
  
  //-- Initializing Canvas
  ag_canvas(&d->control,w,h);
  ag_canvas(&d->bg,w,h);
  
  //-- Draw Background
  CANVAS * c = &d->bg;
  int hp2 = floor(h/2.0);
  ag_draw_ex(c,win->bg,0,0,x,y,w,h);
  if (!atheme_draw("img.progress",c,0,0,w,h)){
    dword hl1 = ag_calchighlight(acfg()->controlbg,acfg()->controlbg_g);
    ag_roundgrad(c,0,0,w,h,acfg()->border,acfg()->border_g,hp2);
    ag_roundgrad(c,1,1,w-2,h-2,
      ag_calculatealpha(acfg()->controlbg,  0xffff,180),
      ag_calculatealpha(acfg()->controlbg_g,0xffff,160),
      hp2-1);
    ag_roundgrad(c,2,2,w-4,h-4,acfg()->controlbg,acfg()->controlbg_g,hp2-2);
    ag_roundgrad_ex(c,2,2,w-4,ceil((h-4)/2.0),LOWORD(hl1),HIWORD(hl1),hp2-2,2,2,0,0);
  }
  
  //-- Initializing Control
  ACONTROLP ctl  = malloc(sizeof(ACONTROL));
  ctl->ondestroy= &acprog_ondestroy;
  ctl->oninput  = &acprog_oninput;
  ctl->ondraw   = &acprog_ondraw;
  ctl->onblur   = &acprog_onblur;
  ctl->onfocus  = NULL;
  ctl->win      = win;
  ctl->x        = x;
  ctl->y        = y;
  ctl->w        = w;
  ctl->h        = h;
  ctl->forceNS  = 0;
  ctl->d        = (void *) d;
  aw_add(win,ctl);
  return ctl;
}
ACONTROLP imgbtn_reinit(
  AWINDOWP win,
  ACONTROLP ctl,
  int x,
  int y,
  int w,
  int h,
  PNGCANVAS * img,
  char * text,
  byte isflat,
  byte touchmsg
) {
  if ((ctl != NULL) && (x == 0) && (y == 0) && (h == 0) && (w == 0)) {
    x = ctl->x;
    y = ctl->y;
    w = ctl->w;
    h = ctl->h;
  }
  
  int txtw = 0;
  int txth = 0;
  int txtx = 0;
  int txty = 0;
  
  if (w < agdp() * 20) {
    w = agdp() * 20;
  }
  
  if (h < agdp() * 20) {
    h = agdp() * 20;
  }
  
  if (text != NULL) {
    //-- Initializing Text Metrics
    if ((isflat == 3) || (isflat == 4)) {
      txtw = ag_txtwidth(text, 0);
      txth = ag_fontheight(0);
      
      if (w < ((agdp() * 22) + txtw)) {
        w = ((agdp() * 22) + txtw);
      }
      
      txtx = round(w / 2) - round(((agdp() * 20) + txtw) / 2);
      txty = round(h / 2) - round(txth / 2);
    }
    else {
      txtw = ag_txtwidth(text, 0);
      txth = ag_fontheight(0);
      
      if (h < ((agdp() * 20) + txth)) {
        h = ((agdp() * 20) + txth);
      }
      
      txtx = round(w / 2) - round(txtw / 2);
      txty = (agdp() * 16);
    }
  }
  
  int imgS = agdp() * 16;
  int imgX = round(w / 2) - round(imgS / 2);
  int imgY = 0; // agdp()*2;
  int contentH = (agdp() * 16) +  txth;
  int contentY = (h / 2) - (contentH / 2);
  
  if ((isflat == 3) || (isflat == 4)) {
    imgY = round(h / 2) - round(imgS / 2);
    imgX = txtx + (agdp() * 2);
    txtx += agdp() * 20;
  }
  else {
    imgY += contentY;
    txty += contentY;
  }
  
  if (isflat == 3) {
    isflat = 0;
  }
  
  //-- Initializing Button Data
  IMGBTNDP d = NULL;
  
  if (ctl != NULL) {
    d = ctl->d;
    win = ctl->win;
  }
  else {
    d = (IMGBTNDP) malloc(sizeof(IMGBTND));
    memset(d, 0, sizeof(IMGBTND));
    //-- Save Touch Message & Set Stats
    d->focused   = 0;
    d->pushed    = 0;
    //-- Initializing Canvas
    ag_canvas(&d->control, w, h);
    ag_canvas(&d->control_pushed, w, h);
    ag_canvas(&d->control_focused, w, h);
  }
  
  d->touchmsg  = touchmsg;
  //-- Draw Rest Control
  dword hl1 = ag_calchighlight(acfg()->controlbg, acfg()->controlbg_g);
  ag_draw_ex(&d->control, win->bg, 0, 0, x, y, w, h);
  
  if (!isflat) {
    if (!atheme_draw("img.button", &d->control, 0, 0, w, h)) {
      ag_roundgrad(&d->control, 0, 0, w, h, acfg()->border, acfg()->border_g, (agdp()*acfg()->btnroundsz));
      ag_roundgrad(&d->control, 1, 1, w - 2, h - 2,
                   ag_calculatealpha(acfg()->controlbg, acfg()->winbg, 180),
                   ag_calculatealpha(acfg()->controlbg_g, acfg()->winbg, 160),
                   (agdp()*acfg()->btnroundsz) - 1
                  );
      ag_roundgrad(&d->control, 2, 2, w - 4, h - 4, acfg()->controlbg, acfg()->controlbg_g, (agdp()*acfg()->btnroundsz) - 2);
      ag_roundgrad_ex(&d->control, 2, 2, w - 4, (h - 4) / 2, LOWORD(hl1), HIWORD(hl1), (agdp()*acfg()->btnroundsz) - 2, 1, 1, 0, 0);
    }
  }
  
  ag_textf(&d->control, txtw, txtx + 1, txty + 1, text, acfg()->controlbg, 0);
  ag_text(&d->control, txtw, txtx, txty, text, acfg()->controlfg, 0);
  color pshad = ag_calpushad(acfg()->selectbg_g);
  ag_draw_ex(&d->control_pushed, win->bg, 0, 0, x, y, w, h);
  int wadd = (isflat == 2) ? 2 : 0;
  int wdel = wadd * 2;
  
  //-- Draw Pushed Control
  if (!isflat) {
    hl1 = ag_calcpushlight(acfg()->selectbg, pshad);
    
    if (!atheme_draw("img.button.push", &d->control_pushed, 0, 0, w, h)) {
      ag_roundgrad(&d->control_pushed, 0, 0, w, h, acfg()->border, acfg()->border_g, (agdp()*acfg()->btnroundsz));
      //ag_roundgrad(&d->control_pushed,1,1,w-2,h-2,acfg()->controlbg,acfg()->controlbg_g,(agdp()*acfg()->btnroundsz)-1);
      ag_roundgrad(&d->control_pushed, 1, 1, w - 2, h - 2, acfg()->selectbg, pshad, (agdp()*acfg()->btnroundsz) - 1);
      ag_roundgrad_ex(&d->control_pushed, 1, 1, w - 2, (h - 2) / 2, LOWORD(hl1), HIWORD(hl1), (agdp()*acfg()->btnroundsz) - 1, 1, 1, 0, 0);
    }
    
    ag_textf(&d->control_pushed, txtw, txtx + 1, txty + 1, text, acfg()->selectbg_g, 0);
    ag_text(&d->control_pushed, txtw, txtx, txty, text, acfg()->selectfg, 0);
  }
  else {
    hl1 = ag_calchighlight(acfg()->controlbg, acfg()->controlbg_g);
    
    if (!atheme_draw("img.button", &d->control_pushed, 0, 0, w, h)) {
      ag_roundgrad(&d->control_pushed, wadd, wadd, w - wdel, h - wdel, acfg()->border, acfg()->border_g, (agdp()*acfg()->btnroundsz));
      /*ag_roundgrad(&d->control_pushed,wadd+1,wadd+1,w-(2+wdel),h-(2+wdel),
        ag_calculatealpha(acfg()->controlbg,acfg()->winbg,180),
        ag_calculatealpha(acfg()->controlbg_g,acfg()->winbg,160),
        (agdp()*acfg()->btnroundsz)-1
      );*/
      ag_roundgrad(&d->control_pushed, wadd + 1, wadd + 1, w - (2 + wdel), h - (2 + wdel), acfg()->controlbg, acfg()->controlbg_g, (agdp()*acfg()->btnroundsz) - 1);
      ag_roundgrad_ex(&d->control_pushed, wadd + 1, wadd + 1, w - (2 + wdel), (h - (1 + wdel)) / 2, LOWORD(hl1), HIWORD(hl1), (agdp()*acfg()->btnroundsz) - 1, 1, 1, 0, 0);
    }
    
    ag_textf(&d->control_pushed, txtw, txtx + 1, txty + 1, text, acfg()->controlbg, 0);
    ag_text(&d->control_pushed, txtw, txtx, txty, text, acfg()->controlfg, 0);
  }
  
  //-- Draw Focused Control
  hl1 = ag_calchighlight(acfg()->selectbg, acfg()->selectbg_g);
  ag_draw_ex(&d->control_focused, win->bg, 0, 0, x, y, w, h);
  
  if (!atheme_draw("img.button.focus", &d->control_focused, 0, 0, w, h)) {
    ag_roundgrad(&d->control_focused, wadd, wadd, w - wdel, h - wdel, acfg()->border, acfg()->border_g, (agdp()*acfg()->btnroundsz));
    //ag_roundgrad(&d->control_focused,wadd+1,wadd+1,w-(wdel+2),h-(wdel+2),acfg()->controlbg,acfg()->controlbg_g,(agdp()*acfg()->btnroundsz)-1);
    ag_roundgrad(&d->control_focused, wadd + 1, wadd + 1, w - (wdel + 2), h - (wdel + 2), acfg()->selectbg, acfg()->selectbg_g, (agdp()*acfg()->btnroundsz) - 1);
    ag_roundgrad_ex(&d->control_focused, wadd + 1, wadd + 1, w - (wdel + 2), (h - (wdel + 2)) / 2, LOWORD(hl1), HIWORD(hl1), (agdp()*acfg()->btnroundsz) - 1, 1, 1, 0, 0);
  }
  
  ag_textf(&d->control_focused, txtw, txtx + 1, txty + 1, text, acfg()->selectbg_g, 0);
  ag_text(&d->control_focused, txtw, txtx, txty, text, acfg()->selectfg, 0);
  
  if (img != NULL) {
    apng_stretch(&d->control, img, imgX, imgY, imgS, imgS, 0, 0, img->w, img->h);
    apng_stretch(&d->control_pushed, img, imgX, imgY, imgS, imgS, 0, 0, img->w, img->h);
    apng_stretch(&d->control_focused, img, imgX, imgY, imgS, imgS, 0, 0, img->w, img->h);
  }
  
  //-- Initializing Control
  if (ctl == NULL) {
    ctl  = malloc(sizeof(ACONTROL));
    ctl->ondestroy = &imgbtn_ondestroy;
    ctl->oninput  = &imgbtn_oninput;
    ctl->ondraw   = &imgbtn_ondraw;
    ctl->onblur   = &imgbtn_onblur;
    ctl->onfocus  = &imgbtn_onfocus;
    ctl->win      = win;
    ctl->forceNS  = 0;
    ctl->d        = (void *) d;
    ctl->x        = x;
    ctl->y        = y;
    ctl->w        = w;
    ctl->h        = h;
    aw_add(win, ctl);
  }
  else {
    ctl->x        = x;
    ctl->y        = y;
    ctl->w        = w;
    ctl->h        = h;
    imgbtn_ondraw(ctl);
  }
  
  return ctl;
}
void afbox_redrawitem_ex(ACONTROLP ctl, int index){
  AFBOXDP d = (AFBOXDP) ctl->d;
  if (d->acheck_signature != 177) return; //-- Not Valid Signature
  if ((index>=d->itemn)||(index<0)) return; //-- Not Valid Index
  
  AFBOXIP p = d->items[index];
  CANVAS *  c = &d->client;
  
  //-- Cleanup Background
  ag_rect(c,0,p->y,d->clientWidth,p->h,acfg()->textbg);
  
  if (p->isTitle){
    ag_roundgrad(c,0,p->y,d->clientWidth,p->h,acfg()->titlebg,acfg()->titlebg_g,0);
    ag_textf(c,d->clientTextW+(agdp()*14),(d->clientTextX-(agdp()*14))+1,p->y+p->ty,p->title,acfg()->titlebg_g,0);
    ag_text(c,d->clientTextW+(agdp()*14),d->clientTextX-(agdp()*14),p->y+p->ty-1,p->title,acfg()->titlefg,0);
  }
  else{
    color txtcolor = acfg()->textfg;
    color graycolor= acfg()->textfg_gray;
    byte isselectcolor=0;
    if (index==d->touchedItem){
      if (!atheme_draw("img.selection.push", c,0,p->y+1,d->clientWidth,p->h-2)){
        color pshad = ag_calpushad(acfg()->selectbg_g);
        dword hl1 = ag_calcpushlight(acfg()->selectbg,pshad);
        ag_roundgrad(c,0,p->y+1,d->clientWidth,p->h-3,acfg()->selectbg,pshad,(agdp()*2));
        ag_roundgrad(c,0,p->y+1,d->clientWidth,(p->h-3)/2,LOWORD(hl1),HIWORD(hl1),(agdp()*2));
      }
      graycolor = txtcolor = acfg()->selectfg;
      isselectcolor=1;
    }
    else if ((index==d->focusedItem)&&(d->focused)){
      if (!atheme_draw("img.selection", c,0,p->y+1,d->clientWidth,p->h-2)){
        dword hl1 = ag_calchighlight(acfg()->selectbg,acfg()->selectbg_g);
        ag_roundgrad(c,0,p->y+1,d->clientWidth,p->h-3,acfg()->selectbg,acfg()->selectbg_g,(agdp()*2));
        ag_roundgrad(c,0,p->y+1,d->clientWidth,(p->h-3)/2,LOWORD(hl1),HIWORD(hl1),(agdp()*2));
      }
      graycolor = txtcolor = acfg()->selectfg;
      isselectcolor=1;
    }
    if (index<d->itemn-1){
      //-- Not Last... Add Separator
      color sepcl = ag_calculatealpha(acfg()->textbg,acfg()->textfg_gray,80);
      ag_rect(c,0,p->y+p->h-1,d->clientWidth,1,sepcl);
    }
    
    //-- Now Draw The Checkbox
    int imgS = agdp()*24;
    if (p->img!=NULL){
      apng_stretch(c,p->img,agdp(),p->y+agdp(),imgS,imgS,0,0,p->img->w,p->img->h);
    }
    
    
    int txt_h = p->th+p->dh;
    int tit_y = (p->h / 2) - (txt_h / 2);
    int des_y = tit_y+p->th;
    int des_add = 0;
    if (d->boxtype!=0){
      des_add = (agdp()*16);
    }
    
    char permstr[64];
    snprintf(permstr,64,"%s",p->d_perm);
    //-- Now Draw The Text
    if (isselectcolor){
      ag_textf(c,d->clientTextW,d->clientTextX,p->y+tit_y,p->title,acfg()->selectbg_g,1);
      ag_textf(c,d->clientTextW+des_add,d->clientTextX,p->y+des_y,p->desc,acfg()->selectbg_g,0);
      ag_textf(c,d->clientTextW+des_add,d->clientTextX-1,p->y+des_y-1,p->desc,graycolor,0);
      
      ag_textf(c,d->clientTextW+des_add,d->clientTextX,p->y+des_y,permstr,acfg()->selectbg_g,0);
      ag_textf(c,d->clientTextW+des_add,d->clientTextX-1,p->y+des_y-1,permstr,graycolor,0);
    }
    else{
      ag_text(c,d->clientTextW+des_add,d->clientTextX-1,p->y+des_y-1,p->desc,graycolor,0);
      ag_text(c,d->clientTextW+des_add,d->clientTextX-1,p->y+des_y-1,permstr,graycolor,0);
    }
    ag_textf(c,d->clientTextW,d->clientTextX-1,p->y+tit_y-1,p->title,txtcolor,1);
    
    
    
    // img
    
    //-- Now Draw The Checkbox
    int halfdp   = ceil(((float) agdp())/2);
    int halfdp2  = halfdp*2;
    int chkbox_s = (agdp()*10);
    int chkbox_x = (d->clientTextX+d->clientTextW+(agdp()*9)) - ((chkbox_s+2)/2);
    int chkbox_y = p->y + round((p->h/2) - (chkbox_s/2));
    
    byte drawed = 0;
    int minpad = 3*agdp();
    int addpad = 6*agdp();
    
    if (d->boxtype==0){
      if (p->checked){
        if (index==d->touchedItem)
          drawed=atheme_draw("img.checkbox.on.push", c,chkbox_x-minpad,chkbox_y-minpad,chkbox_s+addpad,chkbox_s+addpad);
        else if ((index==d->focusedItem)&&(d->focused))
          drawed=atheme_draw("img.checkbox.on.focus", c,chkbox_x-minpad,chkbox_y-minpad,chkbox_s+addpad,chkbox_s+addpad);
        else
          drawed=atheme_draw("img.checkbox.on", c,chkbox_x-minpad,chkbox_y-minpad,chkbox_s+addpad,chkbox_s+addpad);
      }
      else{
        if (index==d->touchedItem)
          drawed=atheme_draw("img.checkbox.push", c,chkbox_x-minpad,chkbox_y-minpad,chkbox_s+addpad,chkbox_s+addpad);
        else if ((index==d->focusedItem)&&(d->focused))
          drawed=atheme_draw("img.checkbox.focus", c,chkbox_x-minpad,chkbox_y-minpad,chkbox_s+addpad,chkbox_s+addpad);
        else
          drawed=atheme_draw("img.checkbox", c,chkbox_x-minpad,chkbox_y-minpad,chkbox_s+addpad,chkbox_s+addpad);
      }
      if (!drawed){
        ag_roundgrad(c,
          chkbox_x,
          chkbox_y,
          chkbox_s,
          chkbox_s,
          acfg()->controlbg_g,
          acfg()->controlbg,
          0);
        ag_roundgrad(c,
          chkbox_x+halfdp,
          chkbox_y+halfdp,
          chkbox_s-halfdp2,
          chkbox_s-halfdp2,
          acfg()->textbg,
          acfg()->textbg,
          0);
        if (p->checked){
          ag_roundgrad(c,
            chkbox_x+halfdp2,
            chkbox_y+halfdp2,
            chkbox_s-(halfdp2*2),
            chkbox_s-(halfdp2*2),
            acfg()->selectbg,
            acfg()->selectbg_g,
            0);
        }
      }
    }
  }
}
예제 #12
0
void auido_show_del(byte * copy_status, char **source_path, int number_files)
{
	//-- Init Dialog Window
	CANVAS *tmpc = aw_muteparent(NULL);
	aw_set_on_dialog(2);
	//ag_rectopa(agc(), 0, 0, agw(), agh(), 0x0000, 180);
	CANVAS * maskc = aw_maskparent();
	ag_sync();

	//-- Initializing Canvas
	CANVAS bg;
	ag_canvas(&bg, agw(), agh());
	ag_draw(&bg, agc(), 0, 0);

	//-- Size & Position
	/*
	   [PAD]
	   mainInfo
	   extraInfo
	   [*************perProg*************]
	   perInfo
	   [PAD]
	   [ CANCEL BUTTON ]
	   [PAD]
	 */
	int pad = agdp() * 4;

	int padB = pad;
	int padT = pad;
	int padL = pad;
	int padR = pad;
	PNGCANVASP winp = atheme("img.dialog");
	APNG9 winv;
	if (winp != NULL) {
		if (apng9_calc(winp, &winv, 1)) {
			padL = winv.l;
			padR = winv.r;
			padB = winv.b;
			padT = winv.t;
		}
	}

	int hpad = agdp() * 2;
	int winW = agw() - (pad * 2);	//-- Window
	int winX = pad;
	int cliW = winW - (padL + padR);	//-- Window Client
	int cliX = pad + padL;

	int titH = ag_fontheight(1) + (agdp() * 2);	//-- Title Height
	int txtH = ag_fontheight(0) + agdp();	//-- Text Interface Height
	int prgH = agdp() * 12;	//-- Progress Height
	int btnH = agdp() * 24;
	int btnW = winW / 2;
	int btnX = agw() / 2 - btnW / 2;

	int winH = (pad * 2) + titH + (txtH * 2) + (prgH) + btnH + padB + padT;
	int winY = (agh() / 2) - (winH / 2);

	int titY = winY + padT;
	int curY = titY + titH + pad;

	int defW = cliW - pad;
	int txtW1 = (int)(defW * 0.8);
	int txtW2 = defW - txtW1;
	int txtX1 = cliX + hpad;
	int txtX2 = txtX1 + txtW1;

	//-- Draw Canvas
	if (!atheme_draw("img.dialog", &bg, winX, winY, winW, winH)) {
		ag_roundgrad(&bg, winX - 1, winY - 1, winW + 2, winH + 2,
			     acfg()->border, acfg()->border_g,
			     (acfg()->roundsz * agdp()) + 1);
		ag_roundgrad(&bg, winX, winY, winW, winH, acfg()->dialogbg,
			     acfg()->dialogbg_g, acfg()->roundsz * agdp());
	}
	//-- Init Window & Controls
	AWINDOWP hWin = aw(&bg);

	ACONTROLP mainInfo =
	    aclabel(hWin, cliX, titY, cliW, titH, alang_get("delete.prepare"),
		    1, 1,
		    2, acfg()->winfg);
	ACONTROLP extraInfo =
	    aclabel(hWin, cliX, curY, cliW, txtH, alang_get("calculating"), 0,
		    1, 2,
		    acfg()->winfg);
	curY += txtH;

	ACONTROLP perProg =
	    acprog(hWin, cliX, curY + agdp(), cliW, prgH - (agdp() * 2), 0);
	curY += prgH;
	ACONTROLP perInfo =
	    aclabel(hWin, cliX, curY, cliW, txtH, "", 0, 1, 2,
		    acfg()->textfg_gray);
	curY += txtH + pad;
	imgbtn(hWin, btnX, curY, btnW, btnH, aui_icons(0), alang_get("cancel"),
	       3, 55);

	//-- Show Window
	//aw_show(hWin);
	aw_show_ex2(hWin, 5, winX - 1, winY - 1, winW + 2, winH + 2, NULL);
	
	byte ondispatch = 1;
	acprog_setonwait(perProg, 1);

	//-- Start Delete Proc
	AFSDT dt;
	memset(&dt, 0, sizeof(AFSDT));
	int curr_id = 0;
	byte proc_state = 0;

	long kbps_tick = 0;
	if (auido_next_del_size
	    (&dt, &curr_id, copy_status, source_path, number_files)) {

		//-- Dispatch
		do {
			dword msg = aw_dispatch(hWin);
			switch (aw_gm(msg)) {

				//-- CALCULATING
			case 10:
				{
					//-- Discovery Tick
					if (proc_state == 0) {
						char info[256];
						char strfl[64];
						char format[256];
						snprintf(strfl, 64, "%i", dt.n);
						snprintf(format, 256,
							 "%s ( %s )",
							 alang_get("deleting"),
							 "\%0.1f");
						snprintf(info, 256, format,
							 strfl,
							 ((float)dt.k) / 1024);
						aclabel_settext(perInfo,
								dt.curr, 0);
						aclabel_settext(extraInfo, info,
								1);
					}
				} break;

			case 11:
				{
					//-- Discovery Finish
					if (proc_state == 0) {
						curr_id++;
						if (!auido_next_del_size
						    (&dt, &curr_id, copy_status,
						     source_path,
						     number_files)) {
							ondispatch = 0;
							aclabel_settext
							    (mainInfo,
							     alang_get
							     ("finishing"), 1);
						}
					} else if (proc_state == 2) {
						ondispatch = 0;
						aclabel_settext(mainInfo,
								alang_get
								("finishing"),
								1);
					}
				}
				break;
			case 55:
				{
					if (proc_state == 0) {
						aclabel_settext(mainInfo,
								alang_get
								("canceling"),
								1);
						proc_state = 2;
						dt.status = 0;
					}
				}
				break;
			}
		}
		while (ondispatch);
	}
	//-- Release Resources
	aw_destroy(hWin);
	ag_ccanvas(&bg);
	aw_set_on_dialog(0);
	//aw_unmuteparent(NULL, tmpc);
	aw_unmaskparent(NULL, tmpc, maskc, winX - 1, winY - 1, winW + 2, winH + 2);
}