//-class INputTextfield begin //------------------------------------------// class INputTextfield { float x, y, w, h, tfw, tfh, ntl; int l; //leading int tlength; String textContents; String labeltext; String samet; float margin; PFont pf; Brect fieldArea; Textbox textField, textField2; boolean isTyping; boolean reset; INputTextfield(String a_, float x_, float y_, float w_, float h_,int l_,PFont ts_){ labeltext = a_; textContents = labeltext; samet = labeltext; x = x_; y = y_; w = w_; h = h_; l = l_; pf = ts_; margin = 6; tfw = w-margin*2; tfh = h-margin*2; //textfield textField = new Textbox(textContents, x+margin, y+margin, tfw, tfh, l, pf ); textField2 = new Textbox(textContents, x+margin, y+margin, tfw, tfh, l, pf ); tlength = 1; reset = false; // backgroud of box fieldArea = new Brect(x, y, w, h, 1); fieldArea.n = color(255); fieldArea.r = color(255); fieldArea.o = color(255); fieldArea.p = color(255); fieldArea.b = color(0,60); } void display(){ update(); fieldArea.display(); fill(0,100); textField.textBox(); fill(0,160); textField2.textBox(); } void update(){ // check activate it or not if(fieldArea.isPressed){ fieldArea.isLocked = true; fieldArea.b = color(234,82,21); } if(!fieldArea.isOver && mousePressed){ fieldArea.isLocked = false; fieldArea.b = color(0,60); } // reset intro-text if(reset){ //labeltext = textContents ; textField2.textContent = textField.textContent = labeltext; } } void write(){ // start-clean up if(fieldArea.isLocked){ if(labeltext.length() > 0){ textContents = ""; labeltext = ""; reset = false; } // add character char k = char(key); textContents = textContents + str(k); textField.textContent = textContents; // light color textField2.textContent = textContents.substring(0, textContents.length()-1); // dark color } } void delete(){ if(fieldArea.isLocked){ if(textContents.length() >0){ int temm = textContents.length()-1; textContents = textContents.substring(0, temm); textField.textContent = textContents; // light color // check null- zero point of length() of dark color type if(textField2.textContent.length() > 0){ textField2.textContent = textContents.substring(0, textContents.length()-1);// dark color } // temporary reset if(textContents.length() == 0){ textField.textContent = "Rewrite"; } } } } float getTextLegnth(String xx){ float teml = textWidth(xx); ntl = teml; return ntl; } int getLineNums(float teml){ return ceil(teml/tfw); } int getStringL(){ return textContents.length(); } } //class INputTextfield end /////////////////////////////////////////////////////////////// // class Textbox start -----------------------------// class Textbox{ float x, y, w, h, tl, fonth ; float th, ted, tea; String textContent; PFont px; int leading; Textbox(){ } Textbox(String a_, float x_, float y_, float w_, float h_,int l_,PFont ts_){ textContent = a_; px = ts_; textFont(px); tl = textWidth(textContent); fonth = textDescent()+textAscent(); ted = textDescent(); tea = textAscent(); x = x_; y = y_; w = w_; h = h_; leading = l_; } void textBox(){ textFont(px); textLeading(leading); text(textContent,int(x), int(y), int(w),int(h)); //getTh(); //rect(x, y,10, th); } void textBox_R(){ pushMatrix(); translate(x,y); rotate(radians(90)); textFont(px); textLeading(leading); text(textContent,-textWidth(textContent)/2, 0); popMatrix(); } void setPosition(float x_, float y_){ x = x_; y = y_; } void setString(String dd){ textContent = dd; } float getTh(){ int lineNum = ceil(tl/w); if(lineNum > 1){ float hh =leading*lineNum-ted; // println(tea); return th = hh; } else { float hh =leading*lineNum; return th = hh; } } float getLength(){ return tl; //=textWidth(textContent); } } // class Textbox end -----------------------------// ////class Choise start////////////////////////////////////////////// class Choise { String[] item; String selectItem; float x,y, w, sellh; int num; int caseID; int selectId; Button[] sellB; BArrow baB; boolean isFirst; boolean isSpread; PFont pff; Choise(String[] a, float x_, float y_,float w_, PFont pff_){ item = a; num = item.length; //println(num); pff = pff_; x = x_; y = y_; w = w_; isFirst = true; isSpread = false; caseID = 1; selectId = 0; selectItem = item[0]; sellB = new Button[num]; for(int i=0; ix+sellB[0].w+baB.w && mousePressed) || (mouseY < y && mousePressed) || (mouseY > y+(sellB[0].h*num) && mousePressed) ){ caseID = 2; } } } void showHide(int xx){ switch(xx){ case 1: selectId =0; for(int i=0; i= x_ && mouseX <= x_+w_ && mouseY >= y_ && mouseY <= y_+h_){ return true; } else{ return false; } } void setColor_o(color x){ o = x; } void setColor_p(color x){ p = x; } void setColor_n(color x){ n = x; } void setColor_r(color x){ r = x; } void setColor_b(color x){ b = x; } float getX(){ return x; } float getY(){ return y; } float getW(){ return w; } float getH(){ return h; } } ///class Brect end/////////////////////////////////////