//-- Add Item Into Control
byte acopt_add(ACONTROLP ctl,char * title, char * desc, byte selected){
  ACOPTDP d = (ACOPTDP) ctl->d;
  if (d->acheck_signature != 136) return 0; //-- Not Valid Signature
  
  //-- Allocating Memory For Item Data
  ACOPTIP newip = (ACOPTIP) malloc(sizeof(ACOPTI));
  snprintf(newip->title,64,"%s",title);
  snprintf(newip->desc,128,"%s",desc);
  newip->th       = ag_txtheight(d->clientTextW,newip->title,1);
  if (strlen(newip->desc)==0)
    newip->dh       = 0;
  else
    newip->dh       = ag_txtheight(d->clientTextW,newip->desc,0);
  
  newip->h        = (agdp()*10) + newip->dh + newip->th;
  
  //newip->ty       = agdp()*5;
  //newip->dy       = (agdp()*5)+newip->th;
  
  if (newip->h<(agdp()*22)) newip->h = (agdp()*22);
    
  int hp2   = newip->h/2;
  int tth   = (newip->dh + newip->th) / 2;
  newip->ty = hp2-tth;
  newip->dy = newip->ty+newip->th;
    
  newip->id       = d->itemn;
  newip->group    = d->groupCounts;
  newip->groupid  = ++d->groupCurrId;
  newip->isTitle  = 0;
  newip->y        = d->nextY;
  d->nextY       += newip->h;
  if (selected){
    d->selectedIndexs[newip->group] = newip->id;
  }
  
  if (d->itemn>0){
    int i;
    ACOPTIP * tmpitms   = d->items;
    d->items              = malloc( sizeof(ACOPTIP)*(d->itemn+1) );
    for (i=0;i<d->itemn;i++)
      d->items[i]=tmpitms[i];
    d->items[d->itemn] = newip;
    free(tmpitms);
  }
  else{
    d->items    = malloc(sizeof(ACOPTIP));
    d->items[0] = newip;
  }
  d->itemn++;
  return 1;
}
ACONTROLP accb(
  AWINDOWP win,
  int x,
  int y,
  int w,
  int h,
  char * textv,
  byte checked
){
  //-- Validate Minimum Size
  if (h<agdp()*16) h=agdp()*16;
  if (w<agdp()*16) w=agdp()*16;
  
  //-- Limit Title Length  
  char title[128];
  snprintf(title,128,"%s",textv);
  
  //-- Initializing Button Data
  ACCBDP d = (ACCBDP) malloc(sizeof(ACCBD));
  memset(d,0,sizeof(ACCBD));
  
  //-- Save Touch Message & Set Stats
  d->checked   = checked;
  d->focused   = 0;
  d->pushed    = 0;
  
  //-- Initializing Canvas
  ag_canvas(&d->control,w,h);
  
  //-- Draw Control Background
  ag_draw_ex(&d->control,&win->c,0,0,x,y,w,h);
  
  //-- Calculate Position & Size
  int minpad    = 5*agdp();
  d->chkS       = (agdp()*10);
  int txtW      = w - ((d->chkS+6)+(agdp()*4));
  int txtX      = (d->chkS+(agdp()*4));
  int txtH      = ag_txtheight(txtW,title,0);
  int txtY      = ((h-txtH) / 2);
  if (txtY<1) txtY = 1;
  ag_textf(&d->control,txtW,minpad+txtX,txtY,title,acfg()->textbg,0);
  ag_text(&d->control,txtW,minpad+txtX-1,txtY-1,title,acfg()->textfg,0);
  
  //-- Initializing Control
  ACONTROLP ctl  = malloc(sizeof(ACONTROL));
  ctl->ondestroy= &accb_ondestroy;
  ctl->oninput  = &accb_oninput;
  ctl->ondraw   = &accb_ondraw;
  ctl->onblur   = &accb_onblur;
  ctl->onfocus  = &accb_onfocus;
  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;
}
//-- Add Item Into Control
byte afbox_add(ACONTROLP ctl,char * title, char * desc, byte checked, PNGCANVAS * img,
  byte d_type, char * d_perm, dword d_data, byte selDef){
  
  AFBOXDP d = (AFBOXDP) ctl->d;
  if (d->acheck_signature != 177) return 0; //-- Not Valid Signature
  
  //-- Allocating Memory For Item Data
  AFBOXIP newip = (AFBOXIP) malloc(sizeof(AFBOXI));
  
  newip->d_type   = d_type;
  newip->d_data   = d_data;
  
  snprintf(newip->d_perm,10,"%s",d_perm);
  snprintf(newip->title,256,"%s",title);
  snprintf(newip->desc,256,"%s",desc);
  newip->img      = img;
  
  int imgS        = agdp()*24;
  newip->drawed   = 0;
  newip->th       = ag_txtheight(d->clientTextW,newip->title,1);
  newip->dh       = ag_fontheight(0); // ag_txtheight(d->clientTextW,newip->desc,0);
  newip->ty       = agdp()*4;
  newip->dy       = newip->ty+newip->th;
  newip->h        = (agdp()*8) + newip->dh + newip->th;
  if (newip->h<(agdp()*26)) newip->h = (agdp()*26);
  newip->checked  = checked;
  newip->id       = d->itemn;
  newip->group    = d->groupCounts;
  newip->groupid  = ++d->groupCurrId;
  newip->isTitle  = 0;
  newip->y        = d->nextY;
  d->nextY       += newip->h;
  
  if (selDef){
    d->focusedItem = d->itemn;
    d->selectedId  = d->itemn;
  }
  
  if (checked) d->check_n++;
  
  if (d->itemn>0){
    int i;
    AFBOXIP * tmpitms   = d->items;
    d->items              = malloc( sizeof(AFBOXIP)*(d->itemn+1) );
    for (i=0;i<d->itemn;i++)
      d->items[i]=tmpitms[i];
    d->items[d->itemn] = newip;
    free(tmpitms);
  }
  else{
    d->items    = malloc(sizeof(AFBOXIP));
    d->items[0] = newip;
  }
  d->itemn++;
  return 1;
}
//-- Add Item Into Control
byte accheck_add(ACONTROLP ctl,char * title, char * desc, byte checked){
  ACCHECKDP d = (ACCHECKDP) ctl->d;
  if (d->acheck_signature != 133) return 0; //-- Not Valid Signature
  
  //-- Allocating Memory For Item Data
  ACCHECKIP newip = (ACCHECKIP) malloc(sizeof(ACCHECKI));
  snprintf(newip->title,31,"%s",title);
  snprintf(newip->desc,127,"%s",desc);
  newip->th       = ag_txtheight(d->clientTextW,newip->title,0);
  newip->dh       = ag_txtheight(d->clientTextW,newip->desc,0);
  newip->ty       = agdp()*5;
  newip->dy       = (agdp()*5)+newip->th;
  newip->h        = (agdp()*10) + newip->dh + newip->th;
  if (newip->h<(agdp()*22)) newip->h = (agdp()*22);
  newip->checked  = checked;
  newip->id       = d->itemn;
  newip->group    = d->groupCounts;
  newip->groupid  = ++d->groupCurrId;
  newip->isTitle  = 0;
  newip->y        = d->nextY;
  d->nextY       += newip->h;
  
  if (d->itemn>0){
    int i;
    ACCHECKIP * tmpitms   = d->items;
    d->items              = malloc( sizeof(ACCHECKIP)*(d->itemn+1) );
    for (i=0;i<d->itemn;i++)
      d->items[i]=tmpitms[i];
    d->items[d->itemn] = newip;
    free(tmpitms);
  }
  else{
    d->items    = malloc(sizeof(ACCHECKIP));
    d->items[0] = newip;
  }
  d->itemn++;
  return 1;
}
//-- Add Item Into Control
byte acopt_addgroup(ACONTROLP ctl, char * title, char * desc) {
  ACOPTDP d = (ACOPTDP) ctl->d;
  
  if (d->acheck_signature != 136) {
    return 0;  //-- Not Valid Signature
  }
  
  if (d->groupCounts + 1 >= ACOPT_MAX_GROUP) {
    return 0;
  }
  
  //-- Allocating Memory For Item Data
  ACOPTIP newip = (ACOPTIP) malloc(sizeof(ACOPTI));
  snprintf(newip->title, 64, "%s", title);
  snprintf(newip->desc, 128, "%s", desc);
  newip->th       = ag_txtheight(d->clientTextW + (agdp() * 14), newip->title, 0);
  newip->dh       = 0;// ag_txtheight(d->clientTextW+(agdp()*14),newip->desc,0);
  newip->ty       = agdp() * 4;
  newip->dy       = (agdp() * 4) + newip->th;
  newip->h        = (agdp() * 8) + newip->th;
  newip->id       = d->itemn;
  newip->group    = ++d->groupCounts;
  d->groupCurrId  = -1;
  newip->groupid  = -1;
  newip->isTitle  = 1;
  newip->y        = d->nextY;
  d->nextY       += newip->h;
  
  if (d->itemn > 0) {
    int i;
    ACOPTIP * tmpitms   = d->items;
    d->items              = malloc( sizeof(ACOPTIP) * (d->itemn + 1) );
    
    for (i = 0; i < d->itemn; i++) {
      d->items[i] = tmpitms[i];
    }
    
    d->items[d->itemn] = newip;
    free(tmpitms);
  }
  else {
    d->items    = malloc(sizeof(ACOPTIP));
    d->items[0] = newip;
  }
  
  d->itemn++;
  return 1;
}
void aclabel_ondraw(void * x){
  ACONTROLP   ctl= (ACONTROLP) x;
  ACLABELDP   d  = (ACLABELDP) ctl->d;
  CANVAS *    pc = &ctl->win->c;
  
  if (!d->drawed){
    ag_draw_ex(&d->control,ctl->win->bg,0,0,ctl->x,ctl->y,ctl->w,ctl->h);
    
    int h = 0;
    int y = 0;
    int x = 0;
    
    if (d->vpos!=0){
      if (d->sigleAligment==0)
        h=ag_txtheight(ctl->w,d->text,d->isbig);
      else{
        h     = ag_fontheight(d->isbig);
        int w = ag_txtwidth(d->text,d->isbig);
        
        if (d->sigleAligment==2){
          //-- Center
          x = (ctl->w/2) - (w/2);
        }
        else if (d->sigleAligment==3){
          //-- Right
          x = ctl->w - w;
        }
      }
    }
    
    if (d->vpos==1){
      y = (ctl->h / 2) - (h / 2);
    }
    else if(d->vpos==2){
      y = ctl->h - h;
    }
    
    if (d->sigleAligment==0)
      ag_text(&d->control,ctl->w,x,y,d->text,d->cl,d->isbig);
    else
      ag_texts(&d->control,ctl->w,x,y,d->text,d->cl,d->isbig);

    d->drawed=1;
  }
  ag_draw(pc, &d->control,  ctl->x, ctl->y);
}
Example #7
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;
}
ACONTROLP actext(
  AWINDOWP win,
  int x,
  int y,
  int w,
  int h,
  char * text,
  byte isbig
){
  //-- Validate Minimum Size
  if (h<agdp()*16) h=agdp()*16;
  if (w<agdp()*16) w=agdp()*16;
    
  //-- Initializing Client Area
  int minpadding = max(acfg()->roundsz,4);
  int cw            = w-(agdp()*(minpadding*2));
  int ch            = 0;
  if (text!=NULL)
    ch = ag_txtheight(cw,text,isbig)+(agdp()*(minpadding*2));
  else
    ch = h-(agdp()*2);
  
  //-- Initializing Text Data
  ACTEXTDP d        = (ACTEXTDP) malloc(sizeof(ACTEXTD));
  memset(d,0,sizeof(ACTEXTD));
  
  //-- Initializing Canvas
  ag_canvas(&d->control,w,h);
  ag_canvas(&d->control_focused,w,h);
  ag_canvas(&d->client,cw,ch);
  
  //-- Draw Control
  ag_draw_ex(&d->control,&win->c,0,0,x,y,w,h);
  ag_roundgrad(&d->control,0,0,w,h,acfg()->border,acfg()->border_g,(agdp()*acfg()->roundsz));
  ag_roundgrad(&d->control,1,1,w-2,h-2,acfg()->textbg,acfg()->textbg,(agdp()*acfg()->roundsz)-1);
  
  //-- Draw Focused Control
  ag_draw_ex(&d->control_focused,&win->c,0,0,x,y,w,h);
  ag_roundgrad(&d->control_focused,0,0,w,h,acfg()->selectbg,acfg()->selectbg_g,(agdp()*acfg()->roundsz));
  ag_roundgrad(&d->control_focused,agdp(),agdp(),w-(agdp()*2),h-(agdp()*2),acfg()->textbg,acfg()->textbg,(agdp()*(acfg()->roundsz-1)));
  
  
  //-- Draw Client
  ag_rect(&d->client,0,0,cw,ch,acfg()->textbg);
  if (text!=NULL)
    ag_text(&d->client,cw,0,agdp()*minpadding,text,acfg()->textfg,isbig);
  
  d->isbigtxt    = isbig;
  d->targetY     = 0;
  d->focused     = 0;
  d->scrollY     = 0;
  d->appendPos   = agdp()*minpadding;
  d->forceGlowTop= 0;
  d->isFixedText = 0;
  if (text!=NULL)
    d->maxScrollY  = ch-(h-(agdp()*minpadding));
  else{
    d->maxScrollY  = 0;
    d->isFixedText = 1;
  }
  if (d->maxScrollY<0) d->maxScrollY=0;
  
  ACONTROLP ctl  = malloc(sizeof(ACONTROL));
  ctl->ondestroy= &actext_ondestroy;
  ctl->oninput  = &actext_oninput;
  ctl->ondraw   = &actext_ondraw;
  ctl->onblur   = actext_onblur;
  ctl->onfocus  = actext_onfocus;
  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;
}
void actext_rebuild(
  ACONTROLP ctl,
  int x,
  int y,
  int w,
  int h,
  char * text,
  byte isbig,
  byte toBottom
){
  ACTEXTDP  d  = (ACTEXTDP) ctl->d;
  int minpadding = max(acfg()->roundsz,4);
  //-- Cleanup
  ag_ccanvas(&d->control);
  ag_ccanvas(&d->control_focused);
  ag_ccanvas(&d->client);
  memset(d,0,sizeof(ACTEXTD));
  
  //-- Rebuild
  //-- Validate Minimum Size
  if (h<agdp()*16) h=agdp()*16;
  if (w<agdp()*16) w=agdp()*16;
    
  //-- Initializing Client Area
  int cw            = w-(agdp()*(minpadding*2));
  int ch            = 0;
  if (text!=NULL)
    ch = ag_txtheight(cw,text,isbig)+(agdp()*(minpadding*2));
  else
    ch = h-(agdp()*2);

  //-- Initializing Canvas
  ag_canvas(&d->control,w,h);
  ag_canvas(&d->control_focused,w,h);
  ag_canvas(&d->client,cw,ch);
  
  //-- Draw Control
  ag_draw_ex(&d->control,ctl->win->bg,0,0,x,y,w,h);
  ag_roundgrad(&d->control,0,0,w,h,acfg()->border,acfg()->border_g,(agdp()*acfg()->roundsz));
  ag_roundgrad(&d->control,1,1,w-2,h-2,acfg()->textbg,acfg()->textbg,(agdp()*acfg()->roundsz)-1);
  
  //-- Draw Focused Control
  ag_draw_ex(&d->control_focused,ctl->win->bg,0,0,x,y,w,h);
  ag_roundgrad(&d->control_focused,0,0,w,h,acfg()->selectbg,acfg()->selectbg_g,(agdp()*acfg()->roundsz));
  ag_roundgrad(&d->control_focused,agdp(),agdp(),w-(agdp()*2),h-(agdp()*2),acfg()->textbg,acfg()->textbg,(agdp()*(acfg()->roundsz-1)));
  
  //-- Draw Client
  ag_rect(&d->client,0,0,cw,ch,acfg()->textbg);
  if (text!=NULL)
    ag_text(&d->client,cw,0,agdp()*minpadding,text,acfg()->textfg,isbig);
  
  d->isbigtxt    = isbig;
  d->targetY     = 0;
  d->focused     = 0;
  d->scrollY     = 0;
  d->appendPos   = agdp()*minpadding;
  d->forceGlowTop= 0;
  d->isFixedText = 0;
  if (text!=NULL)
    d->maxScrollY  = ch-(h-(agdp()*minpadding));
  else{
    d->maxScrollY  = 0;
    d->isFixedText = 1;
  }
  if (d->maxScrollY<0) d->maxScrollY=0;
  ctl->x        = x;
  ctl->y        = y;
  ctl->w        = w;
  ctl->h        = h;
  ctl->forceNS  = 0;
  
  if (toBottom){
    d->scrollY = d->maxScrollY;
  }
  
  ctl->ondraw(ctl);
  aw_draw(ctl->win);
}
void actext_appendtxt(ACONTROLP ctl,char * txt){
  ACTEXTDP   d  = (ACTEXTDP) ctl->d;
  int ch          = ag_txtheight(d->client.w,txt,d->isbigtxt);
  int canvas_h    = d->client.h;
  
  if ((d->appendPos+ch)>=canvas_h){
    int step_up = (d->appendPos+ch) - canvas_h;
    int y; int ynew=0;
    for (y=step_up; y<canvas_h; y++){
      color * rowdest = agxy(&d->client,0,ynew++);
      color * rowsrc  = agxy(&d->client,0,y);
      memcpy(rowdest,rowsrc,sizeof(color)*d->client.w);
    }
    d->appendPos -= step_up;
  }
  
  ag_rect(&d->client,0,d->appendPos,d->client.w,ch,acfg()->textbg);
  ag_text(&d->client,
    d->client.w,
    0,d->appendPos,
    txt,
    acfg()->textfg,
    d->isbigtxt);

  d->appendPos+=ch;
  
  /*
  int minpadding = max(acfg()->roundsz,4);
  int ch        = ag_txtheight(d->client.w,txt,d->isbigtxt);
  int my        = d->client.h-(agdp()*2); // -(agdp()*(minpadding*2));
  if ((d->appendPos+ch)>=my){
    if (d->appendPos<my){
      ch-=(my-d->appendPos);
    }
    int y; int ynew=0;
    for (y=ch;y<d->client.h;y++){
      color * rowdest = agxy(&d->client,0,ynew++);
      color * rowsrc  = agxy(&d->client,0,y);
      memcpy(rowdest,rowsrc,sizeof(color)*d->client.w);
    }
    int ypos = my-ch;
    ag_rect(&d->client,0,ypos,d->client.w,ch,acfg()->textbg);
    ag_text(&d->client,
      d->client.w,
      0,ypos,
      txt,
      acfg()->textfg,
      d->isbigtxt);
    d->forceGlowTop=1;
    d->appendPos=my;
  }
  else{
    ag_text(&d->client,
      d->client.w,
      0,d->appendPos,
      txt,
      acfg()->textfg,
      d->isbigtxt);
    d->appendPos+=ch;
  }
  */
  ctl->ondraw(ctl);
  aw_draw(ctl->win);
}
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[32];
  char text[513];
  snprintf(title,31,"%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);
  
  //-- 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);
  int winX    = pad;
  int winY    = (agh()/2) - (winH/2);
  
  //-- Calculate Title Size & Position
  int titX    = (agw()/2) - (titW/2);
  int titY    = winY + pad;
  
  //-- 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
  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.winbg,acfg_var.winbg_g,acfg_var.roundsz*agdp());
  
  //-- Draw Title
  ag_roundgrad_ex(&alertbg,winX,winY,winW,titH,acfg_var.titlebg,acfg_var.titlebg_g,acfg_var.roundsz*agdp(),1,1,0,0);
  ag_textf(&alertbg,titW,titX+1,titY+1,title,acfg_var.titlebg_g,1);
  ag_text(&alertbg,titW,titX,titY,title,acfg_var.titlefg,1);
  
  //-- Draw Image
  if (imgE){
    apng_draw_ex(&alertbg,&ap,pad*2,imgY,0,0,imgW,imgH);
    apng_close(&ap);
  }
  
  //-- Draw Text
  ag_textf(&alertbg,txtW,txtX+1,txtY+1,text,acfg_var.textbg,0);
  ag_text(&alertbg,txtW,txtX,txtY,text,acfg_var.textfg,0);
  
  AWINDOWP hWin   = aw(&alertbg);
  
  acbutton(hWin,btnX,btnY,btnW,btnH,(yes_text==NULL?"Yes":yes_text),0,6);
  acbutton(hWin,btnX2,btnY,btnW,btnH,(no_text==NULL?"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;
}