Example #1
0
		void p_length() {
			init();

			int n = atoi(inbox_search.get_string().c_str());
			if(n < 0) {
				textlist->push_back(new Text(Point(10, text_y), "(nil)"));
				attach((*textlist)[0]);
				Fl::redraw();
				return;
			}

			string s = "word == ";
			unordered_map<string, int> list;
			if(inbox_search.get_string() == "max") s += to_string(length(words, list, -1));
			else if(inbox_search.get_string() == "min") s += to_string(length(words, list, -2));
			else s += to_string(length(words, list, n));
			textlist->push_back(new Text(Point(10, text_y), s));

			int count = 1;
			if(list.size() == 0) textlist->push_back(new Text(Point(10, text_y + 20), "(nil)"));
			for(unordered_map<string, int>::const_iterator it = list.begin(); it != list.end(); ++it) {
				textlist->push_back(new Text(Point(10, text_y + 20 * count), it->first + ": " + to_string(it->second)));
				++count;
			}

			for(int i = 0; i < textlist->size(); ++i)
				attach((*textlist)[i]);
			Fl::redraw();	// 再描画
		}
Example #2
0
		void p_freq() {
			init();

			int n = atoi(inbox_search.get_string().c_str());
			if(n < 0) {
				textlist->push_back(new Text(Point(10, text_y), "(nil)"));
				attach((*textlist)[0]);
				Fl::redraw();
				return;
			}

			string s = "frequency == ";
			vector<string> list;
			if(inbox_search.get_string() == "max") s += to_string(frequency(words, list, -1));
			else if(inbox_search.get_string() == "min") s += to_string(frequency(words, list, -2));
			else s += to_string(frequency(words, list, n));
			textlist->push_back(new Text(Point(10, text_y), s));

			int count = 1;
			if(list.size() == 0) textlist->push_back(new Text(Point(10, text_y + 20), "(nil)"));
			for(vector<string>::const_iterator it = list.begin(); it != list.end(); ++it) {
				textlist->push_back(new Text(Point(10, text_y + 20 * count), *it));
				++count;
			}

			for(int i = 0; i < textlist->size(); ++i)
				attach((*textlist)[i]);
			Fl::redraw();	// 再描画
		}
void Lines_window::next() {
	int x = next_x.get_int();
	int y = next_y.get_int();
	lines.add(Point{x,y});
	ostringstream os;
	os << '(' << x << ',' << y << ')';
	xy_out.put(os.str());
	redraw();
}
Example #4
0
File: 01.cpp Project: fanqo/PPPCpp
void Lines_window::next()
{
  int x = next_x.get_int();
  int y = next_y.get_int();
  lines.add(Point{x, y});
  // update current position readout:
  ostringstream ss;
  ss << '(' << x << ',' << y << ')';
  xy_out.put(ss.str());

  redraw();
}
Example #5
0
void Lines_window::next()
{
    int x = next_x.get_int();
    int y = next_y.get_int();

    lines.add(Point(x, y));

    stringstream ss;
    ss << '(' << x << ',' << y << ')';
    xy_out.put(ss.str());

    redraw();
}
Example #6
0
		void p_count() {
			init();

			string s = "Count == " + to_string(wordcount(words, inbox_search.get_string()));
			textlist->push_back(new Text(Point(10, text_y), s));

			attach((*textlist)[0]);
			Fl::redraw();	// 再描画
		}
double get_double(In_box& ib)
{
    string s;
    s = ib.get_string();
    if (s == "") error("No value in ",ib.label);
    istringstream iss(s);
    double d;
    iss >> d;
    if (!iss) error("Invalid value in ",ib.label);
    return d;
}
Example #8
0
		// 初期化
		void init() {
			words.clear();
			string tmp;
			ifstream ifs(inbox_file.get_string().c_str());
			while(ifs >> tmp) ++words[tmp];

			list_v.clear();
			if(textlist != nullptr) {
				for(int i = 0; i < textlist->size(); ++i)
					detach((*textlist)[i]);
				delete textlist;
			}
			textlist = new Vector_ref<Text>;
		}
Example #9
0
		void p_find() {
			init();

			unordered_map<string, int> list;

			f_search(words, list, inbox_search.get_string());
			textlist->push_back(new Text(Point(10, text_y), "find == " + to_string(list.size())));

			int count = 1;
			if(list.size() == 0) textlist->push_back(new Text(Point(10, text_y + 20), "(nil)"));
			for(unordered_map<string, int>::const_iterator it = list.begin(); it != list.end(); ++it) {
				textlist->push_back(new Text(Point(10, text_y + 20 * count), it->first + ": " + to_string(it->second)));
				++count;
			}

			for(int i = 0; i < textlist->size(); ++i)
				attach((*textlist)[i]);
			Fl::redraw();	// 再描画
		}
int get_int(In_box& ib)
{
    int i = ib.get_int();
    if (i == -999999) error("Invalid value in ",ib.label);
    return i;
}
Example #11
0
		void hexagon_push(){
			kind.hide();
			shapes.push_back(new Regular_polygon(Point(inbox_x.get_int(), inbox_y.get_int()), radius, 6));
			attach(shapes[shapes.size() - 1]);
			menu.show();
		}
Example #12
0
		void circle_push(){
			kind.hide(); 
			shapes.push_back(new Circle(Point(inbox_x.get_int(), inbox_y.get_int()), radius));
			attach(shapes[shapes.size()-1]); 
			menu.show(); 
		}