static void pop(Iarg *sp, Iarg *a) { print_func_entry(); Iarg *p; p = amem(sp->cpu, a->len, RSS, ar(sp)); aw(a, ar(p)); aw(sp, p->off + a->len); print_func_exit(); }
static void push(Iarg *sp, Iarg *a) { print_func_entry(); Iarg *p; p = amem(sp->cpu, a->len, RSS, ar(sp)); p->off -= a->len; p->off &= mask(sp->len*8); aw(p, ar(a)); aw(sp, p->off); print_func_exit(); }
static void oplahf(Cpu *cpu, Inst *i) { print_func_entry(); aw(i->a1, cpu->reg[RFL]); print_func_exit(); }
static void opleave(Cpu *cpu, Inst *i) { print_func_entry(); Iarg *sp; sp = areg(cpu, cpu->slen, RSP); aw(sp, ar(areg(cpu, cpu->slen, RBP))); pop(sp, areg(cpu, i->olen, RBP)); print_func_exit(); }
static void opret(Cpu *cpu, Inst *i) { print_func_entry(); Iarg *sp; unsigned long c; sp = areg(cpu, cpu->slen, RSP); pop(sp, areg(cpu, i->olen, RIP)); if(c = ar(i->a1)) aw(sp, ar(sp) + c); print_func_exit(); }
void aw_textdialog(AWINDOWP parent,char * title,char * text,char * ok_text){ CANVAS * tmpc = aw_muteparent(parent); on_dialog_window = 1; ag_rectopa(agc(),0,0,agw(),agh(),0x0000,180); ag_sync(); int elmP = agdp()*4; int winP = agdp()*4; int winW = agw() - (winP*2); int winH = (agh() / 2) + (winP*4); int winX = winP; int winY = (agh() / 2) - (winH/2); int titW = ag_txtwidth(title,1); int capH = ag_fontheight(1) + (elmP*2); int btnH = agdp()*20; int txtH = winH - (btnH + capH + (elmP*3)); int txtY = winY + capH + elmP; int btnY = txtY + txtH + elmP; int btnW = (winW/2) - elmP; int btnX = winX + ((winW/2) - (btnW/2)); int txtX = winX + elmP; int txtW = winW - (elmP*2); CANVAS alertbg; ag_canvas(&alertbg,agw(),agh()); ag_draw(&alertbg,agc(),0,0); ag_roundgrad(&alertbg,winX,winY,winW,winH,acfg_var.border,acfg_var.border_g,acfg_var.roundsz*agdp()); ag_roundgrad(&alertbg,winX+1,winY+1,winW-2,winH-2,acfg_var.winbg,acfg_var.winbg_g,(acfg_var.roundsz*agdp())-1); ag_roundgrad_ex(&alertbg,winX+1,winY+1,winW-2,capH-1,acfg_var.titlebg,acfg_var.titlebg_g,(acfg_var.roundsz*agdp())-1,1,1,0,0); ag_textf(&alertbg,titW,((agw()/2)-(titW/2))+1,winY+elmP+1,title,acfg_var.titlebg_g,1); ag_text(&alertbg,titW,(agw()/2)-(titW/2),winY+elmP,title,acfg_var.titlefg,1); AWINDOWP hWin = aw(&alertbg); actext(hWin,txtX,txtY,txtW,txtH,text,0); acbutton(hWin,btnX,btnY,btnW,btnH,(ok_text==NULL?acfg_var.text_ok:ok_text),0,5); aw_show(hWin); 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); }
/* * 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; }
int VCS_SOLVE::vcs_rank(const double * awtmp, size_t numSpecies, const double matrix[], size_t numElemConstraints, std::vector<size_t> &compRes, std::vector<size_t>& elemComp, int * const usedZeroedSpecies) const { int lindep; size_t j, k, jl, i, l, ml; int numComponents = 0; compRes.clear(); elemComp.clear(); vector<double> sm(numElemConstraints*numSpecies); vector<double> sa(numSpecies); vector<double> ss(numSpecies); double test = -0.2512345E298; #ifdef DEBUG_MODE if (m_debug_print_lvl >= 2) { plogf(" "); for(i=0; i<77; i++) plogf("-"); plogf("\n"); plogf(" --- Subroutine vcs_rank called to "); plogf("calculate the rank and independent rows /colums of the following matrix\n"); if (m_debug_print_lvl >= 5) { plogf(" --- Species | "); for (j = 0; j < numElemConstraints; j++) { plogf(" "); plogf(" %3d ", j); } plogf("\n"); plogf(" --- -----------"); for (j = 0; j < numElemConstraints; j++) { plogf("---------"); } plogf("\n"); for (k = 0; k < numSpecies; k++) { plogf(" --- "); plogf(" %3d ", k); plogf(" |"); for (j = 0; j < numElemConstraints; j++) { plogf(" %8.2g", matrix[j*numSpecies + k]); } plogf("\n"); } plogf(" ---"); plogendl(); } } #endif /* * Calculate the maximum value of the number of components possible * It's equal to the minimum of the number of elements and the * number of total species. */ int ncTrial = std::min(numElemConstraints, numSpecies); numComponents = ncTrial; *usedZeroedSpecies = false; /* * Use a temporary work array for the mole numbers, aw[] */ std::vector<double> aw(numSpecies); for (j = 0; j < numSpecies; j++) { aw[j] = awtmp[j]; } int jr = -1; /* * Top of a loop of some sort based on the index JR. JR is the * current number of component species found. */ do { ++jr; /* - Top of another loop point based on finding a linearly */ /* - independent species */ do { /* * Search the remaining part of the mole number vector, AW, * for the largest remaining species. Return its identity in K. * The first search criteria is always the largest positive * magnitude of the mole number. */ k = basisOptMax1(VCS_DATA_PTR(aw), numSpecies); if ((aw[k] != test) && fabs(aw[k]) == 0.0) { *usedZeroedSpecies = true; } if (aw[k] == test) { numComponents = jr; goto L_CLEANUP; } /* * Assign a small negative number to the component that we have * just found, in order to take it out of further consideration. */ aw[k] = test; /* *********************************************************** */ /* **** CHECK LINEAR INDEPENDENCE WITH PREVIOUS SPECIES ****** */ /* *********************************************************** */ /* * Modified Gram-Schmidt Method, p. 202 Dalquist * QR factorization of a matrix without row pivoting. */ jl = jr; for (j = 0; j < numElemConstraints; ++j) { sm[j + jr*numElemConstraints] = matrix[j*numSpecies + k]; } if (jl > 0) { /* * Compute the coefficients of JA column of the * the upper triangular R matrix, SS(J) = R_J_JR * (this is slightly different than Dalquist) * R_JA_JA = 1 */ for (j = 0; j < jl; ++j) { ss[j] = 0.0; for (i = 0; i < numElemConstraints; ++i) { ss[j] += sm[i + jr* numElemConstraints] * sm[i + j* numElemConstraints]; } ss[j] /= sa[j]; } /* * Now make the new column, (*,JR), orthogonal to the * previous columns */ for (j = 0; j < jl; ++j) { for (l = 0; l < numElemConstraints; ++l) { sm[l + jr*numElemConstraints] -= ss[j] * sm[l + j*numElemConstraints]; } } } /* * Find the new length of the new column in Q. * It will be used in the denominator in future row calcs. */ sa[jr] = 0.0; for (ml = 0; ml < numElemConstraints; ++ml) { sa[jr] += SQUARE(sm[ml + jr * numElemConstraints]); } /* **************************************************** */ /* **** IF NORM OF NEW ROW .LT. 1E-3 REJECT ********** */ /* **************************************************** */ if (sa[jr] < 1.0e-6) lindep = true; else lindep = false; } while(lindep); /* ****************************************** */ /* **** REARRANGE THE DATA ****************** */ /* ****************************************** */ compRes.push_back(k); elemComp.push_back(jr); } while (jr < (ncTrial-1)); L_CLEANUP: ; if (numComponents == ncTrial && numElemConstraints == numSpecies) { return numComponents; } int numComponentsR = numComponents; ss.resize(numElemConstraints); sa.resize(numElemConstraints); elemComp.clear(); aw.resize(numElemConstraints); for (j = 0; j < numSpecies; j++) { aw[j] = 1.0; } jr = -1; do { ++jr; do { k = basisOptMax1(VCS_DATA_PTR(aw), numElemConstraints); if (aw[k] == test) { numComponents = jr; goto LE_CLEANUP; } aw[k] = test; jl = jr; for (j = 0; j < numSpecies; ++j) { sm[j + jr*numSpecies] = matrix[k*numSpecies + j]; } if (jl > 0) { for (j = 0; j < jl; ++j) { ss[j] = 0.0; for (i = 0; i < numSpecies; ++i) { ss[j] += sm[i + jr* numSpecies] * sm[i + j* numSpecies]; } ss[j] /= sa[j]; } for (j = 0; j < jl; ++j) { for (l = 0; l < numSpecies; ++l) { sm[l + jr*numSpecies] -= ss[j] * sm[l + j*numSpecies]; } } } sa[jr] = 0.0; for (ml = 0; ml < numSpecies; ++ml) { sa[jr] += SQUARE(sm[ml + jr * numSpecies]); } if (sa[jr] < 1.0e-6) lindep = true; else lindep = false; } while(lindep); elemComp.push_back(k); } while (jr < (ncTrial-1)); numComponents = jr; LE_CLEANUP: ; #ifdef DEBUG_MODE if (m_debug_print_lvl >= 2) { plogf(" --- vcs_rank found rank %d\n", numComponents); if (m_debug_print_lvl >= 5) { if (compRes.size() == elemComp.size()) { printf(" --- compRes elemComp\n"); for (int i = 0; i < (int) compRes.size(); i++) { printf(" --- %d %d \n", (int) compRes[i], (int) elemComp[i]); } } else { for (int i = 0; i < (int) compRes.size(); i++) { printf(" --- compRes[%d] = %d \n", (int) i, (int) compRes[i]); } for (int i = 0; i < (int) elemComp.size(); i++) { printf(" --- elemComp[%d] = %d \n", (int) i, (int) elemComp[i]); } } } } #endif if (numComponentsR != numComponents) { printf("vcs_rank ERROR: number of components are different: %d %d\n", numComponentsR, numComponents); throw Cantera::CanteraError("vcs_rank ERROR:", " logical inconsistency"); exit(-1); } return numComponents; }
void AudioInputConfig::on_qpbAudioWizard_clicked() { AudioWizard aw(this); aw.exec(); loadSettings(); }
void Bottle::beforeMatch(int i, int j) { if(_state<0) return; if(j + 1 < kMatrixWidth) { if (_gemStoneMatrix[i][j+1]) { GemType type = (GemType)((_type - redbottle) / 5 + 1); if (_gemStoneMatrix[i][j+1]->getGemType() == type && _gemStoneMatrix[i][j+1]->getState() != -1) { _state-- ; MyPoint mp = MyPoint(i, j + 1); _gemStoneMatrix[i][j+1]->explode(mp, mp, 0, 0); AnimationWraper aw(NULL, e_aid_normal_explode, e_priority_normal_explode); _animationWraperVector->push_back(aw); __String *str = __String::create(""); if (_state == 2) { if (type == red ) { str = __String::create("bottle1_red.png"); } else if (type == yellow) { str = __String::create("bottle1_yellow.png"); } else if (type == blue) { _state = 2; str = __String::create("bottle1_blue.png"); } else if (type == green) { str = __String::create("bottle1_green.png"); } else if (type == purple) { str = __String::create("bottle1_purple.png"); } else if (type == white) { str = __String::create("bottle1_white.png"); } } else if(_state == 1) { if (type == red) { str = __String::create("bottle2_red.png"); } else if (type == yellow) { str = __String::create("bottle2_yellow.png"); } else if (type == blue) { str = __String::create("bottle2_blue.png"); } else if (type == green) { str = __String::create("bottle2_green.png"); } else if (type == purple) { str = __String::create("bottle2_purple.png"); } else if (type == white) { str = __String::create("bottle2_white.png"); } } else if(_state == 0) { if (type == red) { str = __String::create("bottle3_red.png"); } else if (type == yellow) { str = __String::create("bottle3_yellow.png"); } else if (type == blue) { str = __String::create("bottle3_blue.png"); } else if (type == green) { str = __String::create("bottle3_green.png"); } else if (type == purple) { str = __String::create("bottle3_purple.png"); } else if (type == white) { str = __String::create("bottle3_white.png"); } } else if(_state == -1) { if (type == red) { str = __String::create("bottle4_red.png"); } else if (type == yellow) { str = __String::create("bottle4_yellow.png"); } else if (type == blue) { str = __String::create("bottle4_blue.png"); } else if (type == green) { str = __String::create("bottle4_green.png"); } else if (type == purple) { str = __String::create("bottle4_purple.png"); } else if (type == white) { str = __String::create("bottle4_white.png"); } } _spr->setTexture(str->getCString()); } } if (_state == -1) { AnimationWraper aw2(NULL,e_aid_normal_explode,e_priority_normal_explode); _animationWraperVector->push_back(aw2); } } }
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; }
byte auifav_win(CANVAS * bg, char *path, char **out_char, int titY, int titH, int boxY, int boxH, byte first) { int btnS = agdp() * 20; int btnP = agdp() * 2; AWINDOWP hWin = aw(bg); ACONTROLP title = aclabel(hWin, btnS + btnP, titY, agw() - ((btnS + btnP) * 2), titH, alang_get("tools.favorite"), 1, 1, 2, acfg()->winfg); ACONTROLP addthis = imgbtn(hWin, btnP, titY + btnP, btnS, btnS, aui_icons(6), NULL, 1, 55); ACONTROLP cancel = imgbtn(hWin, agw() - (btnS + btnP), titY + btnP, btnS, btnS, aui_icons(0), NULL, 1, 5); ACONTROLP hFile = afbox(hWin, 0, boxY, agw(), boxH, 7, 8, 2, 6); auifav_fetch(hFile); aw_show_ex(hWin, first ? 1 : 100, titY, hFile); byte ondispatch = 1; byte reshow = 0; do { dword msg = aw_dispatch_ex(hWin, titY); switch (aw_gm(msg)) { case 5: { //-- DONE ondispatch = 0; } break; case 55: { //-- REFRESH ondispatch = 0; reshow = 1; } break; //-- ITEM CLICK case 7: { dword fl = afbox_ddata(hFile); char *fpath = auifav_getpath(fl); if (fpath != NULL) { aui_setpath(out_char, fpath, "", 0); free(fpath); ondispatch = 0; } } break; //-- ITEM TAP & HOLD case 8: { dword fl = afbox_ddata(hFile); char *fpath = auifav_getpath(fl); if (fpath != NULL) { int cp = 0; AWMENUITEM mi[2]; aw_menuset(mi, cp++, "select", 33); aw_menuset(mi, cp++, "tools.favorite.del", 8); byte ret = aw_menu(hWin, NULL, mi, cp); if (ret == 2) { auifav_del(fpath); reshow = 1; free(fpath); ondispatch = 0; } else if (ret == 1) { aui_setpath(out_char, fpath, "", 0); ondispatch = 0; } free(fpath); } } break; } } while (ondispatch); aw_destroy(hWin); return reshow; }
void h () { av (); aw (); }
int VCS_SOLVE::vcs_inest_TP() { int retn = 0; Cantera::clockWC tickTock; if (m_doEstimateEquil > 0) { /* * Calculate the elemental abundances */ vcs_elab(); if (vcs_elabcheck(0)) { if (DEBUG_MODE_ENABLED && m_debug_print_lvl >= 2) { plogf("%s Initial guess passed element abundances on input\n", pprefix); plogf("%s m_doEstimateEquil = 1 so will use the input mole " "numbers as estimates", pprefix); plogendl(); } return retn; } else if (DEBUG_MODE_ENABLED && m_debug_print_lvl >= 2) { plogf("%s Initial guess failed element abundances on input\n", pprefix); plogf("%s m_doEstimateEquil = 1 so will discard input " "mole numbers and find our own estimate", pprefix); plogendl(); } } /* * Malloc temporary space for usage in this routine and in * subroutines * sm[ne*ne] * ss[ne] * sa[ne] * aw[m] */ std::vector<double> sm(m_numElemConstraints*m_numElemConstraints, 0.0); std::vector<double> ss(m_numElemConstraints, 0.0); std::vector<double> sa(m_numElemConstraints, 0.0); std::vector<double> aw(m_numSpeciesTot+ m_numElemConstraints, 0.0); /* * Go get the estimate of the solution */ if (DEBUG_MODE_ENABLED && m_debug_print_lvl >= 2) { plogf("%sGo find an initial estimate for the equilibrium problem", pprefix); plogendl(); } double test = -1.0E20; vcs_inest(VCS_DATA_PTR(aw), VCS_DATA_PTR(sa), VCS_DATA_PTR(sm), VCS_DATA_PTR(ss), test); /* * Calculate the elemental abundances */ vcs_elab(); /* * If we still fail to achieve the correct elemental abundances, * try to fix the problem again by calling the main elemental abundances * fixer routine, used in the main program. This * attempts to tweak the mole numbers of the component species to * satisfy the element abundance constraints. * * Note: We won't do this unless we have to since it involves inverting * a matrix. */ bool rangeCheck = vcs_elabcheck(1); if (!vcs_elabcheck(0)) { if (DEBUG_MODE_ENABLED && m_debug_print_lvl >= 2) { plogf("%sInitial guess failed element abundances\n", pprefix); plogf("%sCall vcs_elcorr to attempt fix", pprefix); plogendl(); } vcs_elcorr(VCS_DATA_PTR(sm), VCS_DATA_PTR(aw)); rangeCheck = vcs_elabcheck(1); if (!vcs_elabcheck(0)) { plogf("%sInitial guess still fails element abundance equations\n", pprefix); plogf("%s - Inability to ever satisfy element abundance " "constraints is probable", pprefix); plogendl(); retn = -1; } else { if (DEBUG_MODE_ENABLED && m_debug_print_lvl >= 2) { if (rangeCheck) { plogf("%sInitial guess now satisfies element abundances", pprefix); plogendl(); } else { plogf("%sElement Abundances RANGE ERROR\n", pprefix); plogf("%s - Initial guess satisfies NC=%d element abundances, " "BUT not NE=%d element abundances", pprefix, m_numComponents, m_numElemConstraints); plogendl(); } } } } else { if (DEBUG_MODE_ENABLED && m_debug_print_lvl >= 2) { if (rangeCheck) { plogf("%sInitial guess satisfies element abundances", pprefix); plogendl(); } else { plogf("%sElement Abundances RANGE ERROR\n", pprefix); plogf("%s - Initial guess satisfies NC=%d element abundances, " "BUT not NE=%d element abundances", pprefix, m_numComponents, m_numElemConstraints); plogendl(); } } } if (DEBUG_MODE_ENABLED && m_debug_print_lvl >= 2) { plogf("%sTotal Dimensionless Gibbs Free Energy = %15.7E", pprefix, vcs_Total_Gibbs(VCS_DATA_PTR(m_molNumSpecies_old), VCS_DATA_PTR(m_feSpecies_new), VCS_DATA_PTR(m_tPhaseMoles_old))); plogendl(); } /* * Record time */ m_VCount->T_Time_inest += tickTock.secondsWC(); (m_VCount->T_Calls_Inest)++; return retn; }
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; }
int linesel (char * * v, int n, char * init_str) { char ibuf[0x100]; char obuf[0x100]; acx1_event_t e; uint16_t w, h, r; int line, rc, st; int i, opt_lines, first, crt, nleft, c, ilen, ipos; int * xmap; char ichg; xmap = malloc(n * sizeof(int)); A(!xmap); // if (!xmap) return -2; ichg = 1; for (i = 0; i < n; ++i) xmap[i] = i; ibuf[sizeof(ibuf) - 1] = 0; strncpy(ibuf, init_str, sizeof(ibuf) - 1); ilen = strlen(ibuf); ipos = ilen; A(acx1_get_screen_size(&h, &w)); A(acx1_set_cursor_pos(h, 1)); nleft = n; first = crt = 0; A(acx1_write_start()); A(acx1_attr(0, 7, 0)); A(acx1_clear()); A(acx1_write_stop()); for (;;) { opt_lines = h - 3; A(opt_lines <= 0); // if (opt_lines <= 0) // { // // screen too small; wait for resize // return -2; // } if (ichg) { ichg = 0; first = xmap[first]; crt = xmap[crt]; for (nleft = i = 0; i < n; ++i) if (strstrci(v[i], ibuf)) xmap[nleft++] = i; for (i = 0; i < nleft && first > xmap[i]; ++i); first = i ? i - 1 : 0; for (i = 0; i < nleft && crt > xmap[i]; ++i); if (i == nleft) --i; if (!i || crt == xmap[i]) crt = i; else crt = i - 1; } if (first + opt_lines <= crt) first = crt + 1 - opt_lines; if (first + opt_lines > nleft) first = nleft - opt_lines; if (first < 0) first = 0; if (crt < first) first = crt; A(acx1_write_start()); r = nleft > opt_lines ? 1 : 1 + opt_lines - nleft; for (i = 1; i < r; ++i) { A(acx1_write_pos(i, 1)); A(acx1_fill(' ', w)); } for (i = first; r <= opt_lines; ++i, ++r) { size_t bpar, cpar, wpar; A(acx1_write_pos(r, 1)); c = strlen(v[xmap[i]]); st = acx1_utf8_str_measure(acx1_term_char_width_wctx, NULL, v[xmap[i]], c, SIZE_MAX - 3, w - 2, &bpar, &cpar, &wpar); if (st < 0) { A(acx1_attr(1, 9, 0)); A(aw("BAD UTF8 string!")); c = strlen("BAD UTF8 string!"); wpar = c; bpar = 0; } if (crt != i) { A(acx1_attr(normal_bg, normal_fg, 0)); } else { A(acx1_attr(sel_bg, sel_fg, 0)); } // if (c > w) c = w; A(acx1_write(v[xmap[i]], bpar)); if (wpar + 2 < w) { A(acx1_fill(' ', w - wpar - 2)); } A(acx1_attr(2, 7, 0)); A(aw("| ")); } A(acx1_write_pos(opt_lines + 1, 1)); A(acx1_attr(0, 11, 0)); A(aw("Filter text: ")); A(acx1_attr(0, 10, 0)); A(aw(ibuf)); A(acx1_attr(0, 7, 0)); c = strlen("Filter text: ") + ilen + 1; if (c > w) c = w; A(acx1_fill(' ', w - c - 1)); A(acx1_write_pos(opt_lines + 2, 1)); A(acx1_attr(0, 6, 0)); r = nleft - first; if (r > opt_lines) r = opt_lines; if (nleft) sprintf(obuf, "%u option%s: %u filtered, %u available " "(%u above, %u displayed, %u below)", n, n == 1 ? "" : "s", n - nleft, nleft, first, r, nleft - first - r); else sprintf(obuf, "%u option%s: all filtered, none available", n, n == 1 ? "" : "s"); c = strlen(obuf); A(acx1_write(obuf, c)); A(acx1_fill(' ', w - c)); A(acx1_write_stop()); A(acx1_set_cursor_pos(opt_lines + 1, strlen("Filter text: ") + ipos + 1)); A(acx1_read_event(&e)); if (e.type == ACX1_RESIZE) { w = e.size.w; h = e.size.h; continue; } if (e.type != ACX1_KEY) return -2; switch (e.km) { case ACX1_ESC: case ACX1_ALT | 'q': case ACX1_ALT | 'x': case ACX1_CTRL | 'Q': case ACX1_CTRL | 'X': return -1; case ACX1_UP: case ACX1_ALT | 'k': if (crt > 0) crt -= 1; break; case ACX1_DOWN: case ACX1_ALT | 'j': if (crt < nleft - 1) crt += 1; break; case ACX1_LEFT: case ACX1_ALT | 'h': if (ipos) ipos -= 1; break; case ACX1_RIGHT: case ACX1_ALT | 'l': if (ipos < ilen) ipos += 1; break; case ACX1_PAGE_UP: case ACX1_CTRL | 'B': crt -= opt_lines - 1; if (crt < 0) crt = 0; break; case ACX1_PAGE_DOWN: case ACX1_CTRL | 'F': crt += opt_lines - 1; if (crt >= nleft) crt = nleft - 1; first += opt_lines - 1; if (first >= nleft - opt_lines) first = nleft - opt_lines; break; case ACX1_CTRL | ACX1_PAGE_UP: case ACX1_ALT | 'U': crt = 0; break; case ACX1_CTRL | ACX1_PAGE_DOWN: case ACX1_ALT | 'D': crt = nleft - 1; break; case ACX1_ENTER: if (!nleft) break; return xmap[crt]; case ACX1_ALT | 'H': crt = first; break; case ACX1_ALT | 'M': i = first + opt_lines - 1; if (i >= nleft) i = nleft - 1; // crt = first + opt_lines / 2; crt = (first + i) / 2; if (crt >= nleft) crt = nleft - 1; break; case ACX1_ALT | 'L': crt = first + opt_lines - 1; if (crt >= nleft) crt = nleft - 1; break; case ACX1_ALT | 'd': crt = crt + opt_lines / 4; if (crt >= nleft) crt = nleft - 1; // if (first >= nleft - opt_lines) first = nleft - opt_lines; // if (first < 0) first = 0; break; case ACX1_ALT | 'u': crt = crt - opt_lines / 4; if (crt < 0) crt = 0; break; case ACX1_CTRL | 'U': if (!ipos) break; if (ipos < ilen) { memmove(ibuf, &ibuf[ipos], ilen - ipos); } ilen -= ipos; ibuf[ilen] = 0; ipos = 0; ichg = 1; break; case ACX1_CTRL | ACX1_BACKSPACE: case ACX1_BACKSPACE: if (!ipos) break; --ipos; memmove(&ibuf[ipos], &ibuf[ipos + 1], ilen - ipos); --ilen; ichg = 1; break; } if (e.km >= 0x20 && e.km <= 0x7E) { if (ilen == sizeof(ibuf) - 1) continue; if (ipos < ilen) { memmove(&ibuf[ipos + 1], &ibuf[ipos], ilen - ipos); } ibuf[ipos] = e.km; ipos += 1; ilen += 1; ibuf[ilen] = 0; ichg = 1; } } l_acx_fail: { FILE * f = log_file ? log_file : stderr; fprintf(f, "Error: %s (line %u)\n", acx1_status_str(rc), line); } return -2; }
//* //* SHOW MAIN DIRECTORY LIST UI //* byte aui_show(char ** path, byte * state, char * selfile, byte back_ani) { //-- REDRAW BG aui_setbg(NULL); //-- Main Variable AUI_VARS v; //-- Return Value v.reshow = 0; //-- Init Drawing Data v.selfile = selfile; v.path = *path; v.state = state; v.pad = agdp() * 2; v.btnH = agdp() * 20; v.boxH = agh() - (aui_minY + (v.btnH * 2) + (v.pad * 4)); v.boxY = aui_minY + v.btnH + (v.pad * 2); v.btnY = v.boxY + v.boxH + v.pad; v.navW = agw() - (v.pad * 2); v.pthW = v.navW; v.navY = aui_minY + v.pad; v.btnW = floor(v.navW / 4); v.hFileType = (*v.state == 3) ? 1 : 0; v.btnFH = aui_cfg_btnFH(); //-- Draw Navigation Bar aui_drawtopbar(&aui_win_bg, 0, aui_minY, agw(), v.btnH + (v.pad * 2)); aui_drawnav(&aui_win_bg, 0, v.btnY - (v.pad + v.btnFH), agw(), v.btnH + (v.pad * 2) + v.btnFH); //-- Check is ROOT Filesystem v.isRoot = (strcmp(v.path, "/") != 0) ? 0 : 1; //-- Justify Path UI Width if (!v.isRoot) { v.pthW -= v.btnH + v.pad; } //-- Draw Path UI aui_pathui(&aui_win_bg, v.pad, v.navY, v.pthW, v.btnH, v.path); //-- Create Main Window v.hWin = aw(&aui_win_bg); //****************************[ INIT WINDOW CONTROLS ]****************************/ //-- REFRESH BUTTON imgbtn(v.hWin, v.pad, v.navY, v.btnH, v.btnH, &UI_ICONS[14], NULL, 2, 10); //-- PARENT BUTTON if (!v.isRoot) imgbtn(v.hWin, agw() - (v.btnH + v.pad), v.navY, v.btnH, v.btnH, &UI_ICONS[12], NULL, 0, 11); //-- FILE LIST BOX v.hFile = afbox(v.hWin, 0, v.boxY, agw(), v.boxH - v.btnFH, 7, 8, v.hFileType, 6); //-- TOOLS v.b1 = imgbtn(v.hWin, v.pad, v.btnY - v.btnFH, v.btnW, v.btnH + v.btnFH, &UI_ICONS[11], aui_tbtitle(0), 1, 20); //-- NEW FOLDER v.b2 = imgbtn(v.hWin, v.pad + v.btnW, v.btnY - v.btnFH, v.btnW, v.btnH + v.btnFH, &UI_ICONS[6], aui_tbtitle(1), 1, 21); //-- FAVORITE v.b3 = imgbtn(v.hWin, v.pad + v.btnW * 2, v.btnY - v.btnFH, v.btnW, v.btnH + v.btnFH, &UI_ICONS[16], aui_tbtitle(2), 1, 22); //-- SELECT ALL v.b4 = imgbtn(v.hWin, v.pad + v.btnW * 3, v.btnY - v.btnFH, v.btnW, v.btnH + v.btnFH, &UI_ICONS[10], aui_tbtitle(7), 1, 3); //-- MENU //-- SET TOOLBAR STATE if (*v.state != 3) { *v.state = 0; } *v.state = aui_tbstate(&v, *v.state, 0); //-- FETCH ITEMS FROM DIRECTORY aui_fetch(v.path, v.hFile, v.selfile); afbox_scrolltoitem(v.hFile); snprintf(v.selfile, 256, ""); //-- Show Window aw_show_ex(v.hWin, back_ani ? 3 : 4, 0, v.hFile); // aw_setfocus(v.hWin,v.hFile); //-- Set Filebox Type if (*v.state == 3) { afbox_changeboxtype(v.hFile, 1); aui_changetitle(&v, alang_get("paste.location")); } else { aui_changetitle(&v, AROMA_NAME); } aui_showtips(&v); do { } while (aui_dispatch(&v)); //-- Window aw_destroy(v.hWin); //-- Set New Path printf("RESHOW PATH [%s]\n", v.path); *path = v.path; return v.reshow; }
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); }
//* //* SHOW TIPS //* void aui_showtips(AUI_VARSP v) { if (aui_is_show_tips) { aui_is_show_tips = 0; CANVAS * tmpc = aw_muteparent(v->hWin); aw_set_on_dialog(2); ag_rectopa(agc(), 0, 0, agw(), agh(), 0x0000, 180); ag_sync(); CANVAS alertbg; ag_canvas(&alertbg, agw(), agh()); ag_draw(&alertbg, agc(), 0, 0); //-- Load Tips Font ag_loadbigfont("fonts/HTC Hand/HTCHand.otf", 18, AROMA_DIR "/"); PNGCANVAS ap; int imS = agdp() * 12; int bHH = v->btnH / 2; int w75 = round(agw() * 0.6); if (apng_load(&ap, "common/tips1")) { apng_stretch(&alertbg, &ap, v->pad + v->btnH, v->boxY - bHH, imS, imS, 0, 0, ap.w, ap.h); apng_close(&ap); } ag_text(&alertbg, w75, v->pad + v->btnH + imS, v->boxY - bHH, "Here is the path of the current working directory", 0xffff, 1); if (apng_load(&ap, "common/tips2")) { apng_stretch(&alertbg, &ap, agw() - (v->btnH + imS), v->boxY + (v->btnH * 4.5), imS, imS, 0, 0, ap.w, ap.h); apng_close(&ap); } ag_text(&alertbg, w75, agw() - (v->btnH + imS + w75), v->boxY + (v->btnH * 4.5), "<@right>Tap the checkbox to select multiple files</@>", 0xffff, 1); if (apng_load(&ap, "common/tips3")) { apng_stretch(&alertbg, &ap, agw() - (v->btnH + imS * 3), v->btnY - (v->pad + v->btnFH + imS), imS, imS, 0, 0, ap.w, ap.h); apng_close(&ap); } ag_text(&alertbg, w75, agw() - (v->btnH + imS * 3 + w75), v->btnY - (v->pad + v->btnFH + (imS * 2)), "<@right>All functions you need is on this toolbar</@>", 0xffff, 1); //-- Revert Font aui_cfg_reloadfonts(); //-- Create Window AWINDOWP hWin = aw(&alertbg); aw_show(hWin); byte ondispatch = 1; while (ondispatch) { dword msg = aw_dispatch_ex(hWin, agh()); byte msgm = aw_gm(msg); if (msgm == 5) { ondispatch = 0; } } aw_destroy(hWin); ag_ccanvas(&alertbg); aw_set_on_dialog(0); aw_unmuteparent(v->hWin, tmpc); } }
void UploadWindow::handleCommand(int res) { if (res == 1) { if (!smugMug.isUploading() || AlertWindow::showOkCancelBox(AlertWindow::InfoIcon, "Komodo Drop", "There is an upload in progress, quit anyway?") == 1) { JUCEApplication::quit(); } } else if (res == 2) { Settings::getInstance()->showSettingsDialog(); } else if (res == 3) { AlertWindow::showMessageBox(AlertWindow::InfoIcon, "Komodo Drop " + JUCEApplication::getInstance()->getApplicationVersion(), "Created By: Roland Rabien ([email protected])\nBased on JUCE (www.rawmaterialsoftware.com)"); } else if (res == 4) { setVisible(!isVisible()); } else if (res == 5) { if (!smugMug.isLoggedIn()) smugMug.login(Settings::getInstance()->email, Settings::getInstance()->password); OwnedArray<Album> albums; smugMug.getAlbumList(albums); if (albums.size() > 0) { ComboBox* album = new ComboBox(""); album->setSize(300, 26); album->setVisible(true); for (int i = 0; i < albums.size(); i++) album->addItem(albums[i]->getDisplayTitle(), i + 1); album->setSelectedItemIndex(0); AlertWindow aw("Komodo Drop", "Delete album:", AlertWindow::InfoIcon); aw.addCustomComponent(album); aw.addButton("ok", 1); aw.addButton("cancel", 2); if (aw.runModalLoop() == 1) { smugMug.deleteAlbum(albums[album->getSelectedId() - 1]->id); } delete album; } } else if (res == 6) { if (!smugMug.isLoggedIn()) smugMug.login(Settings::getInstance()->email, Settings::getInstance()->password); OwnedArray<Category> categories; smugMug.getCategoryList(categories); if (categories.size()) { ComboBox* cats = new ComboBox(""); cats->setSize(300, 26); cats->setVisible(true); for (int i = 0; i < categories.size(); i++) cats->addItem(categories[i]->title, categories[i]->id + 1); cats->setSelectedItemIndex(0); AlertWindow aw("Komodo Drop", "Delete category:", AlertWindow::InfoIcon); aw.addCustomComponent(cats); aw.addButton("ok", 1); aw.addButton("cancel", 2); if (aw.runModalLoop() == 1) { smugMug.deleteCategory(cats->getSelectedId() - 1); } delete cats; } } else if (res == 7) { if (!smugMug.isLoggedIn()) smugMug.login(Settings::getInstance()->email, Settings::getInstance()->password); OwnedArray<Category> categories; smugMug.getCategoryList(categories); OwnedArray<SubCategory> subCategories; smugMug.getSubCategoryList(subCategories); if (subCategories.size()) { ComboBox* cats = new ComboBox(""); cats->setSize(300, 26); cats->setVisible(true); for (int i = 0; i < subCategories.size(); i++) { int j; for (j = 0; j < categories.size(); j++) { if (categories[j]->id == subCategories[i]->parentId) break; } cats->addItem(categories[j]->title + " >> " + subCategories[i]->title, subCategories[i]->id + 1); } cats->setSelectedItemIndex(0); AlertWindow aw("Komodo Drop", "Delete sub category:", AlertWindow::InfoIcon); aw.addCustomComponent(cats); aw.addButton("ok", 1); aw.addButton("cancel", 2); if (aw.runModalLoop() == 1) { smugMug.deleteSubCategory(cats->getSelectedId() - 1); } delete cats; } } else if (res == 8) { if (!smugMug.isLoggedIn()) smugMug.login(Settings::getInstance()->email, Settings::getInstance()->password); AlertWindow aw("Komodo Drop", "Create category:", AlertWindow::InfoIcon); aw.addTextEditor("name", "", "category name:"); aw.addButton("ok", 1); aw.addButton("cancel", 2); if (aw.runModalLoop() == 1 && aw.getTextEditorContents("name").isNotEmpty()) { smugMug.createCategory(aw.getTextEditorContents("name")); } } else if (res == 9) { if (!smugMug.isLoggedIn()) smugMug.login(Settings::getInstance()->email, Settings::getInstance()->password); OwnedArray<Category> categories; smugMug.getCategoryList(categories); if (categories.size()) { ComboBox* cats = new ComboBox(""); cats->setSize(300, 26); cats->setVisible(true); for (int i = 0; i < categories.size(); i++) cats->addItem(categories[i]->title, categories[i]->id + 1); cats->setSelectedItemIndex(0); AlertWindow aw("Komodo Drop", "Create sub category:", AlertWindow::InfoIcon); aw.addCustomComponent(cats); aw.addTextEditor("name", "", "sub category name:"); aw.addButton("ok", 1); aw.addButton("cancel", 2); if (aw.runModalLoop() == 1 && aw.getTextEditorContents("name").isNotEmpty()) { smugMug.createSubCategory(cats->getSelectedId() - 1, aw.getTextEditorContents("name")); } delete cats; } } else if (res == 10) { smugMug.cancelUploads(); } else if (res == 11) { FileChooser fc("Komodo Drop", File::getSpecialLocation(File::userDocumentsDirectory)); if (fc.browseForMultipleFilesToOpen()) { const Array<File>& files = fc.getResults(); StringArray names; for (int i = 0; i < files.size(); i++) names.add(files[i].getFullPathName()); filesDropped(names, 0, 0); } } else if (res == 12) { FileChooser fc("Komodo Drop", File::getSpecialLocation(File::userDocumentsDirectory)); if (fc.browseForDirectory()) { File dir = fc.getResult(); Array<File> files; StringArray names; dir.findChildFiles(files, File::findFiles, false); for (int i = 0; i < files.size(); i++) names.add(files[i].getFullPathName()); if (names.size()) filesDropped(names, 0, 0); } } else if (res == 13) { FileChooser fc("Komodo Drop", File::getSpecialLocation(File::userDocumentsDirectory)); if (fc.browseForDirectory()) { File dir = fc.getResult(); Array<File> files; StringArray names; dir.findChildFiles(files, File::findFiles, true); for (int i = 0; i < files.size(); i++) names.add(files[i].getFullPathName()); if (names.size()) filesDropped(names, 0, 0); } } else if (res == 19) { FileChooser fc("Komodo Drop", File::getSpecialLocation(File::userDocumentsDirectory)); if (fc.browseForDirectory()) { File dir = fc.getResult(); Array<File> folders; dir.findChildFiles(folders, File::findDirectories, false); for (int i = 0; i < folders.size(); i++) { Array<File> files; folders[i].findChildFiles(files, File::findFiles, true); StringArray names; for (int j = 0; j < files.size(); j++) names.add(files[j].getFullPathName()); if (names.size()) filesDropped(names, 0, 0); } } } else if (res == 14) { smugMug.showLogFile(); } else if (res == 15) { smugMug.clearLogFile(); } else if (res == 16) { if (!smugMug.isLoggedIn()) smugMug.login(Settings::getInstance()->email, Settings::getInstance()->password); OwnedArray<Album> albums; smugMug.getAlbumList(albums); if (albums.size() > 0) { ComboBox* album = new ComboBox(""); album->setSize(300, 26); album->setVisible(true); for (int i = 0; i < albums.size(); i++) album->addItem(albums[i]->getDisplayTitle(), i + 1); album->setSelectedItemIndex(0); AlertWindow aw("Komodo Drop", "Delete duplicate images from album:", AlertWindow::InfoIcon); aw.addCustomComponent(album); aw.addButton("ok", 1); aw.addButton("cancel", 2); if (aw.runModalLoop() == 1) { smugMug.deleteDuplicates(albums[album->getSelectedId() - 1]->id); } delete album; } } else if (res == 17) { smugMug.showQueue(); } else if (res == 18) { if (!smugMug.isLoggedIn()) smugMug.login(Settings::getInstance()->email, Settings::getInstance()->password); smugMug.showTopPhotos(); } }
byte aw_showmenu(AWINDOWP parent){ CANVAS * tmpc = aw_muteparent(parent); //-- Set Mask on_dialog_window = 2; ag_rectopa(agc(),0,0,agw(),agh(),0x0000,180); ag_sync(); int btnH = agdp()*20; int pad = agdp()*4; int vpad = agdp()*2; int winH = ((btnH+vpad) * 3) + pad; int winW = agw()-(pad*2); int winX = pad; int winY = agh()-winH; int btnY = winY + pad; int btnX = winX + pad; int btnW = winW - (pad*2); //-- Initializing Canvas CANVAS alertbg; ag_canvas(&alertbg,agw(),agh()); ag_draw(&alertbg,agc(),0,0); //-- Draw Window Background ag_roundgrad_ex(&alertbg,winX-1,winY-1,winW+2,winH+2,acfg_var.border,acfg_var.border_g,(acfg_var.roundsz*agdp())+1,1,1,0,0); ag_roundgrad_ex(&alertbg,winX,winY,winW,winH,acfg_var.navbg,acfg_var.navbg_g,acfg_var.roundsz*agdp(),1,1,0,0); //-- Create Window AWINDOWP hWin = aw(&alertbg); acbutton(hWin,btnX,btnY,btnW,btnH,acfg_var.text_about,0,11); //acbutton(hWin,btnX,btnY+((btnH+vpad)*1),btnW,btnH,"Help",0,12); acbutton(hWin,btnX,btnY+((btnH+vpad)*1),btnW,btnH,acfg_var.text_calibrating,0,13); acbutton(hWin,btnX,btnY+((btnH+vpad)*2),btnW,btnH,acfg_var.text_quit,0,14); aw_show(hWin); byte ondispatch = 1; byte res = 0; while(ondispatch){ dword msg=aw_dispatch(hWin); switch (aw_gm(msg)){ case 5: ondispatch = 0; break; case 11: res=1; ondispatch = 0; break; case 12: res=2; ondispatch = 0; break; case 13: res=3; ondispatch = 0; break; case 14: res=4; ondispatch = 0; break; } } aw_destroy(hWin); ag_ccanvas(&alertbg); on_dialog_window = 0; aw_unmuteparent(parent,tmpc); if (res==1){ aw_about_dialog(parent); } else if (res==2){ aw_help_dialog(parent); } else if (res==3){ aw_calibtools(parent); } else if (res==4){ byte res = aw_confirm(parent, AROMA_NAME " " AROMA_VERSION, acfg_var.text_quit_msg,"@alert",NULL,NULL); if (res) return 2; } return 0; }
int VCS_SOLVE::vcs_setMolesLinProg() { size_t ik, irxn; double test = -1.0E-10; if (DEBUG_MODE_ENABLED && m_debug_print_lvl >= 2) { plogf(" --- call setInitialMoles\n"); } double dg_rt; int idir; double nu; double delta_xi, dxi_min = 1.0e10; bool redo = true; int retn; int iter = 0; bool abundancesOK = true; bool usedZeroedSpecies; vector_fp sm(m_numElemConstraints*m_numElemConstraints, 0.0); vector_fp ss(m_numElemConstraints, 0.0); vector_fp sa(m_numElemConstraints, 0.0); vector_fp wx(m_numElemConstraints, 0.0); vector_fp aw(m_numSpeciesTot, 0.0); for (ik = 0; ik < m_numSpeciesTot; ik++) { if (m_speciesUnknownType[ik] != VCS_SPECIES_INTERFACIALVOLTAGE) { m_molNumSpecies_old[ik] = max(0.0, m_molNumSpecies_old[ik]); } } if (DEBUG_MODE_ENABLED && m_debug_print_lvl >= 2) { printProgress(m_speciesName, m_molNumSpecies_old, m_SSfeSpecies); } while (redo) { if (!vcs_elabcheck(0)) { if (DEBUG_MODE_ENABLED && m_debug_print_lvl >= 2) { plogf(" --- seMolesLinProg Mole numbers failing element abundances\n"); plogf(" --- seMolesLinProg Call vcs_elcorr to attempt fix\n"); } retn = vcs_elcorr(&sm[0], &wx[0]); if (retn >= 2) { abundancesOK = false; } else { abundancesOK = true; } } else { abundancesOK = true; } /* * Now find the optimized basis that spans the stoichiometric * coefficient matrix, based on the current composition, m_molNumSpecies_old[] * We also calculate sc[][], the reaction matrix. */ retn = vcs_basopt(false, &aw[0], &sa[0], &sm[0], &ss[0], test, &usedZeroedSpecies); if (retn != VCS_SUCCESS) { return retn; } if (DEBUG_MODE_ENABLED && m_debug_print_lvl >= 2) { plogf("iteration %d\n", iter); } redo = false; iter++; if (iter > 15) { break; } // loop over all reactions for (irxn = 0; irxn < m_numRxnTot; irxn++) { // dg_rt is the Delta_G / RT value for the reaction ik = m_numComponents + irxn; dg_rt = m_SSfeSpecies[ik]; dxi_min = 1.0e10; const double* sc_irxn = m_stoichCoeffRxnMatrix.ptrColumn(irxn); for (size_t jcomp = 0; jcomp < m_numElemConstraints; jcomp++) { dg_rt += m_SSfeSpecies[jcomp] * sc_irxn[jcomp]; } // fwd or rev direction. // idir > 0 implies increasing the current species // idir < 0 implies decreasing the current species idir = (dg_rt < 0.0 ? 1 : -1); if (idir < 0) { dxi_min = m_molNumSpecies_old[ik]; } for (size_t jcomp = 0; jcomp < m_numComponents; jcomp++) { nu = sc_irxn[jcomp]; // set max change in progress variable by // non-negativity requirement if (nu*idir < 0) { delta_xi = fabs(m_molNumSpecies_old[jcomp]/nu); // if a component has nearly zero moles, redo // with a new set of components if (!redo && delta_xi < 1.0e-10 && (m_molNumSpecies_old[ik] >= 1.0E-10)) { if (DEBUG_MODE_ENABLED && m_debug_print_lvl >= 2) { plogf(" --- Component too small: %s\n", m_speciesName[jcomp]); } redo = true; } dxi_min = std::min(dxi_min, delta_xi); } } // step the composition by dxi_min, check against zero, since // we are zeroing components and species on every step. // Redo the iteration, if a component went from positive to zero on this step. double dsLocal = idir*dxi_min; m_molNumSpecies_old[ik] += dsLocal; m_molNumSpecies_old[ik] = max(0.0, m_molNumSpecies_old[ik]); for (size_t jcomp = 0; jcomp < m_numComponents; jcomp++) { bool full = false; if (m_molNumSpecies_old[jcomp] > 1.0E-15) { full = true; } m_molNumSpecies_old[jcomp] += sc_irxn[jcomp] * dsLocal; m_molNumSpecies_old[jcomp] = max(0.0, m_molNumSpecies_old[jcomp]); if (full && m_molNumSpecies_old[jcomp] < 1.0E-60) { redo = true; } } } if (DEBUG_MODE_ENABLED && m_debug_print_lvl >= 2) { printProgress(m_speciesName, m_molNumSpecies_old, m_SSfeSpecies); } } if (DEBUG_MODE_ENABLED && m_debug_print_lvl == 1) { printProgress(m_speciesName, m_molNumSpecies_old, m_SSfeSpecies); plogf(" --- setInitialMoles end\n"); } retn = 0; if (!abundancesOK) { retn = -1; } else if (iter > 15) { retn = 1; } return retn; }
//* //* SHOW MAIN DIRECTORY LIST UI //* void aui_show_setting() { printf("SHOW SETTINGS\n"); //-- REDRAW BG aui_setbg(NULL); //-- Main Variable AUI_VARS v; //-- Return Value v.reshow = 0; //-- Init Drawing Data v.selfile = ""; v.path = ""; v.state = 0; v.pad = agdp() * 2; v.btnH = agdp() * 20; v.boxH = agh() - (aui_minY + (v.btnH) + (v.pad * 2)); v.boxY = aui_minY; v.btnY = v.boxY + v.boxH + v.pad; v.navW = agw() - (v.pad * 2); v.pthW = v.navW; v.navY = aui_minY + v.pad; v.btnW = floor(v.navW / 3); int btnHlv = v.navW - (v.pad / 2); v.hFileType = 0; v.btnFH = aui_cfg_btnFH(); //-- Draw Navigation Bar // aui_drawtopbar(&aui_win_bg, 0, aui_minY, agw(), v.btnH + (v.pad * 2)); aui_drawnav(&aui_win_bg, 0, v.btnY - (v.pad + v.btnFH), agw(), v.btnH + (v.pad * 2) + v.btnFH); //-- Create Main Window v.hWin = aw(&aui_win_bg); //****************************[ INIT WINDOW CONTROLS ]****************************/ // imgbtn(v.hWin, v.pad, v.navY, btnHlv, v.btnH, &UI_ICONS[20], alang_get("settings.mount"), 3, 22); /*imgbtn(v.hWin, v.pad, v.navY, btnHlv, v.btnH, &UI_ICONS[17], alang_get("settings.calib"), 3, 21); */ v.hFile = acopt(v.hWin, 0, v.boxY, agw(), (v.boxH - v.btnFH)); //-- Toolbar style : 1 acopt_addgroup(v.hFile, alang_get("settings.toolbar"), ""); acopt_add(v.hFile, alang_get("settings.toolbar.icontext"), "", auic()->tooltext ? 1 : 0); acopt_add(v.hFile, alang_get("settings.toolbar.icononly"), "", auic()->tooltext ? 0 : 1); //-- Font size : 2 acopt_addgroup(v.hFile, alang_get("settings.fontsize"), ""); acopt_add(v.hFile, alang_get("settings.fontsize.small"), "", (auic()->fontsize == 1) ? 1 : 0); acopt_add(v.hFile, alang_get("settings.fontsize.medium"), "", (auic()->fontsize == 2) ? 1 : 0); acopt_add(v.hFile, alang_get("settings.fontsize.big"), "", (auic()->fontsize == 3) ? 1 : 0); //-- Font Family : 3 acopt_addgroup(v.hFile, alang_get("settings.fontfamily"), ""); if (1) { AZREADDIRP rz_fonts = az_readdir(AROMA_DIR "/fonts/"); if (rz_fonts != NULL) { int i = 0; for (i = 0; i < rz_fonts->n; i++) { if (rz_fonts->t[i] == 1) { char desc[256]; auis_readinfo(desc, AROMA_DIR "/fonts/", rz_fonts->f[i]); acopt_add(v.hFile, rz_fonts->f[i], desc, (strcmp (auic()->fontfamily, rz_fonts->f[i]) == 0) ? 1 : 0); } } az_readdir_free(rz_fonts); } } //-- Icon set : 4 acopt_addgroup(v.hFile, alang_get("settings.iconset"), ""); if (1) { AZREADDIRP rz_icons = az_readdir(AROMA_DIR "/icons/"); if (rz_icons != NULL) { int i = 0; for (i = 0; i < rz_icons->n; i++) { if (rz_icons->t[i] == 1) { char desc[256]; auis_readinfo(desc, AROMA_DIR "/icons/", rz_icons->f[i]); acopt_add(v.hFile, rz_icons->f[i], desc, (strcmp (auic()->iconset, rz_icons->f[i]) == 0) ? 1 : 0); } } az_readdir_free(rz_icons); } } //-- Theme : 5 acopt_addgroup(v.hFile, alang_get("settings.themes"), ""); acopt_add(v.hFile, "Generic", "Unskinned AROMA File Manager", (strcmp(auic()->theme, "") == 0) ? 1 : 0); if (1) { AZREADDIRP rz_theme = az_readdir(AROMA_DIR "/themes/"); if (rz_theme != NULL) { int i = 0; for (i = 0; i < rz_theme->n; i++) { if (rz_theme->t[i] == 1) { char desc[256]; auis_readinfo(desc, AROMA_DIR "/themes/", rz_theme->f[i]); acopt_add(v.hFile, rz_theme->f[i], desc, (strcmp (auic()->theme, rz_theme->f[i]) == 0) ? 1 : 0); } } az_readdir_free(rz_theme); } } //-- Languages : 6 acopt_addgroup(v.hFile, alang_get("settings.lang"), ""); if (1) { AZREADDIRP rz_langs = az_readdir(AROMA_DIR "/langs/"); if (rz_langs != NULL) { int i = 0; for (i = 0; i < rz_langs->n; i++) { if (rz_langs->t[i] == 1) { char desc[256]; auis_readinfo(desc, AROMA_DIR "/langs/", rz_langs->f[i]); acopt_add(v.hFile, rz_langs->f[i], desc, (strcmp (auic()->language, rz_langs->f[i]) == 0) ? 1 : 0); } } az_readdir_free(rz_langs); } } //-- Font size : 7 acopt_addgroup(v.hFile, alang_get("settings.trans"), ""); acopt_add(v.hFile, alang_get("settings.trans.0"), "", (acfg()->fadeframes == 0) ? 1 : 0); acopt_add(v.hFile, alang_get("settings.trans.1"), "", (acfg()->fadeframes == 2) ? 1 : 0); acopt_add(v.hFile, alang_get("settings.trans.2"), "", (acfg()->fadeframes == 4) ? 1 : 0); acopt_add(v.hFile, alang_get("settings.trans.3"), "", (acfg()->fadeframes == 6) ? 1 : 0); acopt_add(v.hFile, alang_get("settings.trans.4"), "", (acfg()->fadeframes == 8) ? 1 : 0); //-- Automount : 8 acopt_addgroup(v.hFile, alang_get("settings.mount"), ""); acopt_add(v.hFile, alang_get("settings.mount.all"), "", auic()->automount ? 1 : 0); acopt_add(v.hFile, alang_get("settings.mount.none"), "", auic()->automount ? 0 : 1); //-- colorspace : 9 acopt_addgroup(v.hFile, alang_get("settings.colorspace"), ""); acopt_add(v.hFile, alang_get("settings.colorspace.rgba"), "", (auic()->colorspace == 1) ? 1 : 0); acopt_add(v.hFile, alang_get("settings.colorspace.abgr"), "", (auic()->colorspace == 2) ? 1 : 0); acopt_add(v.hFile, alang_get("settings.colorspace.argb"), "", (auic()->colorspace == 3) ? 1 : 0); acopt_add(v.hFile, alang_get("settings.colorspace.bgra"), "", (auic()->colorspace == 4) ? 1 : 0); //-- Font size : 8 /* acopt_addgroup(v.hFile,"Automount Partitions",""); acopt_add(v.hFile,"All partitions","",0); acopt_add(v.hFile,"None","",1); */ //-- TOOLS v.b1 = imgbtn(v.hWin, v.pad, v.btnY - v.btnFH, v.btnW, v.btnH + v.btnFH, &UI_ICONS[33], aui_tbtitle(9), 1, 12); //-- Done v.b2 = imgbtn(v.hWin, v.pad + v.btnW, v.btnY - v.btnFH, v.btnW, v.btnH + v.btnFH, &UI_ICONS[14], aui_tbtitle(10), 1, 22); //-- Reset v.b3 = imgbtn(v.hWin, v.pad + v.btnW * 2, v.btnY - v.btnFH, v.btnW, v.btnH + v.btnFH, &UI_ICONS[0], aui_tbtitle(8), 1, 20); //-- Cancel //-- Show Window aw_show_ex(v.hWin, 2, 0, v.hFile); // aw_setfocus(v.hWin,v.hFile); aui_changetitle(&v, alang_get("settings")); byte ondispatch = 1; byte saveconfig = 1; byte save_to_file = 0; do { dword msg = aw_dispatch(v.hWin); switch (aw_gm(msg)) { case 12: { //-- DONE ondispatch = 0; } break; case 20: { //-- CANCEL ondispatch = 0; saveconfig = 0; } break; case 22: { //-- RESET if (aw_confirm(v.hWin, alang_get("settings.reset"), alang_get("settings.reset.msg"), aui_icons(39), NULL, NULL)) { ondispatch = 0; saveconfig = 0; aui_cfg_init(); aui_load_icons(); aui_cfg_reloadfonts(); aui_langreload(); aui_themereload(); save_to_file = 1; } } break; case 21: { //-- CALIB if (aw_calibtools(NULL)) { aui_cfg_save(); } } break; } } while (ondispatch); if (saveconfig) { byte font_reloaded = 0; byte colorspace_refreshed = 0; //-- Text on toolbar auic()->tooltext = (acopt_getvalue(v.hFile, 1) == 1) ? 1 : 0; auic()->automount = (acopt_getvalue(v.hFile, 8) == 1) ? 1 : 0; //-- Font Size byte newfontsz = (byte) acopt_getvalue(v.hFile, 2); if (newfontsz != auic()->fontsize) { auic()->fontsize = newfontsz; font_reloaded = 1; } byte newcolorspace = (byte) acopt_getvalue(v.hFile, 9); if (newcolorspace != auic()->colorspace) { auic()->colorspace = newcolorspace; colorspace_refreshed = 1; } //-- Font Family char * fontsel = acopt_getseltitle(v.hFile, 3); if ((fontsel != NULL) && (strcmp(fontsel, auic()->fontfamily) != 0)) { snprintf(auic()->fontfamily, 256, "%s", fontsel); font_reloaded = 1; } //-- Iconset fontsel = acopt_getseltitle(v.hFile, 4); if ((fontsel != NULL) && (strcmp(fontsel, auic()->iconset) != 0)) { snprintf(auic()->iconset, 256, "%s", fontsel); aui_unload_icons(); aui_load_icons(); } //-- Theme fontsel = acopt_getseltitle(v.hFile, 5); if ((fontsel != NULL) && (strcmp(fontsel, auic()->theme) != 0)) { int newtheme = acopt_getvalue(v.hFile, 5); if (newtheme == 1) { if (strcmp(auic()->theme, "") != 0) { snprintf(auic()->theme, 256, ""); aui_themereload(); } } else { snprintf(auic()->theme, 256, "%s", fontsel); aui_themereload(); } } //-- Language fontsel = acopt_getseltitle(v.hFile, 6); if ((fontsel != NULL) && (strcmp(fontsel, auic()->language) != 0)) { snprintf(auic()->language, 256, "%s", fontsel); aui_langreload(); } //-- Transition int transition = acopt_getvalue(v.hFile, 7); acfg()->fadeframes = (transition - 1) * 2; //-- Reload Font if (font_reloaded) { aui_cfg_reloadfonts(); } // set new color space if (colorspace_refreshed) { aui_cfg_setcolorspace(); } save_to_file = 1; } //-- Window aw_destroy(v.hWin); //-- Save if (save_to_file) { aui_cfg_save(); } }
/*! * This is done by running * each reaction as far forward or backward as possible, subject * to the constraint that all mole numbers remain * non-negative. Reactions for which \f$ \Delta \mu^0 \f$ are * positive are run in reverse, and ones for which it is negative * are run in the forward direction. The end result is equivalent * to solving the linear programming problem of minimizing the * linear Gibbs function subject to the element and * non-negativity constraints. */ int VCS_SOLVE::vcs_setMolesLinProg() { int ik, irxn; double test = -1.0E-10; #ifdef DEBUG_MODE std::string pprefix(" --- seMolesLinProg "); if (m_debug_print_lvl >= 2) { plogf(" --- call setInitialMoles\n"); } #endif // m_mu are standard state chemical potentials // Boolean on the end specifies standard chem potentials // m_mix->getValidChemPotentials(not_mu, DATA_PTR(m_mu), true); // -> This is already done coming into the routine. double dg_rt; int idir; double nu; double delta_xi, dxi_min = 1.0e10; bool redo = true; int jcomp; int retn; int iter = 0; bool abundancesOK = true; int usedZeroedSpecies; std::vector<double> sm(m_numElemConstraints*m_numElemConstraints, 0.0); std::vector<double> ss(m_numElemConstraints, 0.0); std::vector<double> sa(m_numElemConstraints, 0.0); std::vector<double> wx(m_numElemConstraints, 0.0); std::vector<double> aw(m_numSpeciesTot, 0.0); for (ik = 0; ik < m_numSpeciesTot; ik++) { if (m_speciesUnknownType[ik] != VCS_SPECIES_INTERFACIALVOLTAGE) { m_molNumSpecies_old[ik] = MAX(0.0, m_molNumSpecies_old[ik]); } } #ifdef DEBUG_MODE if (m_debug_print_lvl >= 2) { printProgress(m_speciesName, m_molNumSpecies_old, m_SSfeSpecies); } #endif while (redo) { if (!vcs_elabcheck(0)) { #ifdef DEBUG_MODE if (m_debug_print_lvl >= 2) { plogf("%s Mole numbers failing element abundances\n", pprefix.c_str()); plogf("%sCall vcs_elcorr to attempt fix\n", pprefix.c_str()); } #endif retn = vcs_elcorr(VCS_DATA_PTR(sm), VCS_DATA_PTR(wx)); if (retn >= 2) { abundancesOK = false; } else { abundancesOK = true; } } else { abundancesOK = true; } /* * Now find the optimized basis that spans the stoichiometric * coefficient matrix, based on the current composition, m_molNumSpecies_old[] * We also calculate sc[][], the reaction matrix. */ retn = vcs_basopt(FALSE, VCS_DATA_PTR(aw), VCS_DATA_PTR(sa), VCS_DATA_PTR(sm), VCS_DATA_PTR(ss), test, &usedZeroedSpecies); if (retn != VCS_SUCCESS) return retn; #ifdef DEBUG_MODE if (m_debug_print_lvl >= 2) { plogf("iteration %d\n", iter); } #endif redo = false; iter++; if (iter > 15) break; // loop over all reactions for (irxn = 0; irxn < m_numRxnTot; irxn++) { // dg_rt is the Delta_G / RT value for the reaction ik = m_numComponents + irxn; dg_rt = m_SSfeSpecies[ik]; dxi_min = 1.0e10; const double *sc_irxn = m_stoichCoeffRxnMatrix[irxn]; for (jcomp = 0; jcomp < m_numElemConstraints; jcomp++) { dg_rt += m_SSfeSpecies[jcomp] * sc_irxn[jcomp]; } // fwd or rev direction. // idir > 0 implies increasing the current species // idir < 0 implies decreasing the current species idir = (dg_rt < 0.0 ? 1 : -1); if (idir < 0) { dxi_min = m_molNumSpecies_old[ik]; } for (jcomp = 0; jcomp < m_numComponents; jcomp++) { nu = sc_irxn[jcomp]; // set max change in progress variable by // non-negativity requirement if (nu*idir < 0) { delta_xi = fabs(m_molNumSpecies_old[jcomp]/nu); // if a component has nearly zero moles, redo // with a new set of components if (!redo) { if (delta_xi < 1.0e-10 && (m_molNumSpecies_old[ik] >= 1.0E-10)) { #ifdef DEBUG_MODE if (m_debug_print_lvl >= 2) { plogf(" --- Component too small: %s\n", m_speciesName[jcomp].c_str()); } #endif redo = true; } } if (delta_xi < dxi_min) dxi_min = delta_xi; } } // step the composition by dxi_min, check against zero, since // we are zeroing components and species on every step. // Redo the iteration, if a component went from positive to zero on this step. double dsLocal = idir*dxi_min; m_molNumSpecies_old[ik] += dsLocal; m_molNumSpecies_old[ik] = MAX(0.0, m_molNumSpecies_old[ik]); for (jcomp = 0; jcomp < m_numComponents; jcomp++) { bool full = false; if (m_molNumSpecies_old[jcomp] > 1.0E-15) { full = true; } m_molNumSpecies_old[jcomp] += sc_irxn[jcomp] * dsLocal; m_molNumSpecies_old[jcomp] = MAX(0.0, m_molNumSpecies_old[jcomp]); if (full) { if (m_molNumSpecies_old[jcomp] < 1.0E-60) { redo = true; } } } } // set the moles of the phase objects to match // updateMixMoles(); // Update the phase objects with the contents of the m_molNumSpecies_old vector // vcs_updateVP(0); #ifdef DEBUG_MODE if (m_debug_print_lvl >= 2) { printProgress(m_speciesName, m_molNumSpecies_old, m_SSfeSpecies); } #endif } #ifdef DEBUG_MODE if (m_debug_print_lvl == 1) { printProgress(m_speciesName, m_molNumSpecies_old, m_SSfeSpecies); plogf(" --- setInitialMoles end\n"); } #endif retn = 0; if (!abundancesOK) { retn = -1; } else if (iter > 15) { retn = 1; } return retn; }
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); }