Exemplo n.º 1
0
int imagecache___::proc__(std::deque<Glib::ustring>* p,char*buf,long siz,char**addr_ret,void*shangji) {
    if((*p)[0]==name__()) {
        if(siz==-1)return 1;
        sprintf(buf,"%lx|%lx",(long)imagecache__,(long)this);
        return 1;
    }
    return 0;
}
Exemplo n.º 2
0
int file___::get__(const string& filename,string& filename1, bool is_src,string& ret){
	err_.del__();
	int err;
#ifdef ver_android_
	if((err = aam_get_file__(filename.c_str(), ret))){
		err_ << filename;
		return err;
	}
#else
	if((err=name__(filename,filename1))){
		err_<<filename;
		return err;
	}
	ifstream* f=new ifstream(filename1.c_str());

	//streampos
	ifstream::pos_type o=f->tellg();
	f->seekg(0,ios::end);
	int bufsiz=f->tellg();
	f->seekg(o);
	char* buf=new char[bufsiz+1];
	if(!buf){
		err_<<filename;
		return errinfo_new_;
	}
	f->read(buf,bufsiz);
	buf[bufsiz]=0;

	f->close();
	delete f;

	ret=buf;
	if(is_src && ret.length() > 2 && ret[0] == '#' && ret[1] == '!') {
		size_t i = ret.find('\n');
		if(i != string::npos) {
			ret = ret.substr(i + 1);
		}
	}
	delete buf;
#endif

	return 0;
}
Exemplo n.º 3
0
int huitu___::proc__(std::deque<Glib::ustring>* p,char*buf,long siz,char**addr_ret,void*shangji,void*ce) {
	if((*p)[0]==name__()){
		if(siz==-1)return 1;
		if(p->size()>1){
			area___* a;
			try{
				if((*p)[1]=="裁剪域"){
					if((a=get_area2__(p,sh_,d_)))
						a->clip__();
					return 1;
				}
				if((*p)[1]=="描画二"){
					if((a=get_area2__(p,sh_,d_)))
						a->stroke_preserve__();
					return 1;
				}
				if((*p)[1]=="描画"){
					if((a=get_area2__(p,sh_,d_)))
						a->stroke__();
					return 1;
				}
				if((*p)[1]=="填充二"){
					if((a=get_area2__(p,sh_,d_)))
						a->fill_preserve__();
					return 1;
				}
				if((*p)[1]=="填充"){
					if((a=get_area2__(p,sh_,d_)))
						a->fill__();
					return 1;
				}
				if((*p)[1]=="恢复"){
					if((a=get_area2__(p,sh_,d_)))
						a->restore__();
					return 1;
				}
				if((*p)[1]=="上色"||(*p)[1]=="绘制"){
					if((a=get_area2__(p,sh_,d_)))
						a->paint__();
					return 1;
				}
				if((*p)[1]=="保存"){
					if((a=get_area2__(p,sh_,d_)))
						a->save__();
					return 1;
				}
				if((*p)[1]=="平移"){
					if((a=get_area2__(p,sh_,d_,4)))
						a->translate__((*p)[2],(*p)[3]);
					return 1;
				}
				if((*p)[1]=="线宽"){
					if((a=get_area2__(p,sh_,d_,3)))
						a->set_line_width__((*p)[2]);
					return 1;
				}
				if((*p)[1]=="弧线"){
					if((a=get_area2__(p,sh_,d_,7)))
						a->arc__((*p)[2],(*p)[3],(*p)[4],(*p)[5],(*p)[6]);
					return 1;
				}
				if((*p)[1]=="坐标"){
					if((a=get_area2__(p,sh_,d_,4)))
						a->move_to__((*p)[2],(*p)[3]);
					return 1;
				}
				if((*p)[1]=="直线到"){
					if((a=get_area2__(p,sh_,d_,4)))
						a->line_to__((*p)[2],(*p)[3]);
					return 1;
				}
				if((*p)[1]=="颜色"){
					if((a=get_area2__(p,sh_,d_,6)))
						a->set_source_rgba__((*p)[2],(*p)[3],(*p)[4],(*p)[5]);
					return 1;
				}
				if((*p)[1]=="范围"){
					if((a=get_area2__(p,sh_,d_,4)))
						a->scale__((*p)[2],(*p)[3]);
					return 1;
				}
				if((*p)[1]=="缩放"){
					if((a=get_area2__(p,sh_,d_,4)))
						a->scale2__((*p)[2],(*p)[3]);
					return 1;
				}
				if((*p)[1]=="圆形线帽"){
					if((a=get_area2__(p,sh_,d_)))
						a->set_line_cap__(Cairo::LINE_CAP_ROUND);
					return 1;
				}
				if((*p)[1]=="源"){
					if((a=get_area2__(p,sh_,d_,5)))
						a->set_source__((*p)[2],(*p)[3],(*p)[4]);
					return 1;
				}
				if((*p)[1]=="旋转"){
					if((a=get_area2__(p,sh_,d_,3)))
						a->rotate__((*p)[2]);
					return 1;
				}

				if((*p)[1]=="cos"){
					if((a=get_area2__(p,sh_,d_,3)))
						cos__((*p)[2],buf);
					return 1;
				}
				if((*p)[1]=="sin"){
					if((a=get_area2__(p,sh_,d_,3)))
						sin__((*p)[2],buf);
					return 1;
				}
				if((*p)[1]=="宽"){
					if((a=get_area__(p,sh_,d_)))
						a->get_width__(buf);
					return 1;
				}
				if((*p)[1]=="高"){
					if((a=get_area__(p,sh_,d_)))
						a->get_height__(buf);
					return 1;
				}

				if((*p)[1]=="获得画具"){
					if((a=get_area__(p,sh_,d_)))
						a->huaju__(buf);
					return 1;
				}
				if((*p)[1]=="画架"){
					Gtk::DrawingArea* da;
					sh_->builder_->get_widget((*p)[2], da);
					if(!da){
						d_(sh_,err_show_wufa_,3,p,2,1);
						return 1;
					}
					a=new area___(da,this,sh_,d_);
					l2s__((long)a,buf);
					return 1;
				}
				if((*p)[1]=="代码"){
					if((a=get_area__(p,sh_,d_,3)))
						a->code_=(*p)[2];
					return 1;
				}
				if((*p)[1]=="刷新"){
					if((a=get_area__(p,sh_,d_)))
						a->shuaxin__();
					return 1;
				}
			}catch(...){
				d_(sh_,err_show_wufa_,3,p,0,1);
				return 1;
			}

			d_(sh_,err_show_buzhichi_,1,p);
			return 1;
		}
		d_(sh_,err_show_buzu_,p);
		return 1;
	}
	return 0;
}
Exemplo n.º 4
0
int sourceview___::proc__(deque<ustring>* p,char*buf,long siz,char**addr_ret,void*shangji,void*ce) {
	char sdz=0;
	if((*p)[0]==name__()){
		if(siz==-1)return 1;
		sdz='s';
	}else
		return 0;
	if(p->size()<=2){
		d_(sh_,err_show_buzu_,p);
		return 1;
	}
	switch(sdz){
	case's':
	{
		SourceView* sv=NULL;
		char sdz1=0;
		const ustring& p1=(*p)[1];
		if(p1=="撤销")
			sdz1='u';
		else if(p1=="重做")
			sdz1='r';
		else if(p1=="撤销不记始")
			sdz1='B';
		else if(p1=="撤销不记终")
			sdz1='E';
		else if(p1=="语法高亮")
			sdz1='h';
#ifdef ver_all_
		else if(p1=="剪切")
			sdz1='x';
		else if(p1=="复制")
			sdz1='c';
		else if(p1=="粘贴")
			sdz1='v';
		else if(p1=="已修改")
			sdz1='m';
		else if(p1=="内容")
			sdz1=' ';
		else if(p1=="打开文件")
			sdz1='o';
		else if(p1=="保存文件")
			sdz1='s';
		else if(p1=="焦点")
			sdz1='.';
		else if(p1=="不可编辑")
			sdz1='e';
		else if(p1=="光标位置")
			sdz1='p';
		else if(p1=="光标行列")
			sdz1='l';
		else if(p1=="插入")
			return insert__(p,1);
#endif
		else{
			switch(sdz){
			case's':
			{
				Gtk::ScrolledWindow* sw;
				sh_->builder_->get_widget((*p)[2], sw);
				if(!sw){
					d_(sh_,err_show_wufa_,2,p,2);
					return 1;
				}

				sv=Gtk::manage(new SourceView());
				sv->set_show_line_numbers(true);
				sv->set_auto_indent (true);
				sv->set_tab_width(4);
				//GTK_SOURCE_SMART_HOME_END_ALWAYS
				sv->set_smart_home_end((SourceSmartHomeEndType)2);
				sv->set_can_focus(true);

				names_[p1]=sv;
				sw->add(*sv);
				sw->show_all_children ();
				return 1;
			}
			}
		}
		sv=tv__(p,2);
		if(!sv)
			return 1;
		RefPtr < SourceBuffer > sb=sv->get_source_buffer();
		switch(sdz1){
#ifdef ver_all_
		case'x':
		case'c':
		case'v':
		{
			RefPtr<Gtk::Clipboard> cb = Gtk::Clipboard::get();
			switch(sdz1){
			case'x':
				sb->cut_clipboard(cb);
				break;
			case'c':
				sb->copy_clipboard(cb);
				break;
			case'v':
				sb->paste_clipboard(cb);
				break;
			}
			break;
		}
		case'm':
			if(p->size()>3){
				const ustring&s=(*p)[3];
				if(s=="侦听"){
					control___* ctl=Gtk::manage(new control___(sh_,d_,(*p)[0],(*p)[2],p1));
					if(p->size()>4)
						ctl->code__((*p)[4]);
					sb->signal_modified_changed().connect(sigc::mem_fun(*ctl,&control___::modified_changed__),false);
				}else
					sb->set_modified(d_(sh_,bool_,s.c_str()));
			}else
				l2s__(sb->get_modified(),buf);
			break;
		case' ':
			if(p->size()>3)
				sb->set_text((*p)[3]);
			else
				*addr_ret=dup__(sb->get_text().c_str());
			break;
		case'o':
			if(p->size()>3){
				ustring s;
				file_get__((*p)[3].c_str(),s);
				sb->set_text(s);
			}
			break;
		case's':
			if(p->size()>3){
				GError *error = NULL;
				g_file_set_contents ((*p)[3].c_str(), sb->get_text().c_str(), -1, &error);
			    if (error != NULL) {
			    	cpy__(buf,error->message,siz);
			        g_clear_error(&error);
			    }
			}
			break;
		case'.':
			sv->grab_focus();
			break;
		case'e':
			if(p->size()>3)
				sv->set_editable(d_(sh_,bool_,(*p)[3].c_str()));
			else
				sv->set_editable(false);
			break;
		case'p':
		case'l':
		{
			Gtk::TextIter ti=sb->get_iter_at_mark(sb->get_mark("insert"));
			if(sdz1=='l'){
				if(p->size()<=3)
					sprintf(buf,"%d,%d,",ti.get_line (),ti.get_line_offset ());
				else{
					int line_offset=ti.get_line_offset ();
					if(p->size()>3)
						ti.set_line (s2i_plus__((*p)[3],ti.get_line ()));
					if(p->size()>4)
						ti.set_line_offset (s2i_plus__((*p)[4],line_offset));
					//sb->place_cursor(ti);
					scroll2__(sv,ti);
				}
			}else{
				if(p->size()>3){
					ti.set_offset (s2i_plus__((*p)[3],ti.get_offset ()));
					//sb->place_cursor(ti);
					scroll2__(sv,ti);
				}else
					l2s__(ti.get_offset (),buf);
			}
			break;
		}
#endif
		case'u':
			if(sb->can_undo())
				sb->undo();
			break;
		case'r':
			if(sb->can_redo())
				sb->redo();
			break;
		case'B':
			sb->begin_not_undoable_action();
			break;
		case'E':
			sb->end_not_undoable_action();
			break;
		case'h':
			if(p->size()>3){
				RefPtr<SourceLanguageManager> slm=SourceLanguageManager::get_default();
				RefPtr<SourceLanguage> sl=slm->get_language((*p)[3]);
				if(sl){
					sb->set_language(sl);
					sb->set_highlight_syntax(true);
					break;
				}
			}
			sb->set_highlight_syntax(false);
			break;
		}
		break;
	}
	}
	return 1;
}
Exemplo n.º 5
0
int textview___::proc__(std::deque<Glib::ustring>* p,char*buf,long siz,char**addr_ret,void*shangji) {
	char sdz=0;
	if((*p)[0]=="插入"){
		if(siz==-1)return 1;
		sdz='i';
	}else if((*p)[0]==name__()){
		if(siz==-1)return 1;
		sdz='t';
	}else
		return 0;
	if(p->size()<=2){
		d_(sh_,err_show_buzu_,p);
		return 1;
	}
	switch(sdz){
	case'i':
		return insert__(p,0);
	case't':
	{
		Gtk::TextView* tv;
		char sdz1=0;
		const Glib::ustring& p1=(*p)[1];
		if(p1=="剪切")
			sdz1='x';
		else if(p1=="复制")
			sdz1='c';
		else if(p1=="粘贴")
			sdz1='v';
		else if(p1=="已修改")
			sdz1='m';
		else if(p1=="内容")
			sdz1=' ';
		else if(p1=="焦点")
			sdz1='.';
		else if(p1=="不可编辑")
			sdz1='e';
		else if(p1=="光标位置")
			sdz1='p';
		else if(p1=="光标行列")
			sdz1='l';
		else if(p1=="选择")
			sdz1='S';
		else if(p1=="插入")
			return insert__(p,1);
		else{
			switch(sdz){
			case't':
				d_(sh_,err_show_buzhichi_,2,p,1);
				return 1;
			}
		}
		tv=tv__(p,2);
		if(!tv)
			return 1;
		Glib::RefPtr < Gtk::TextBuffer > tb = tv->get_buffer();
		switch(sdz1){
		case'x':
		case'c':
		case'v':
		{
			Glib::RefPtr<Gtk::Clipboard> cb = Gtk::Clipboard::get();
			switch(sdz1){
			case'x':
				tb->cut_clipboard(cb);
				break;
			case'c':
				tb->copy_clipboard(cb);
				break;
			case'v':
				tb->paste_clipboard(cb);
				break;
			}
			break;
		}
		case'm':
			if(p->size()>3){
				const Glib::ustring&s=(*p)[3];
				if(s=="侦听"){
					control___* ctl=Gtk::manage(new control___(sh_,d_,(*p)[0],(*p)[2],p1));
					if(p->size()>4)
						ctl->code__((*p)[4]);
					tb->signal_modified_changed().connect(sigc::mem_fun(*ctl,&control___::modified_changed__),false);
				}else
					tb->set_modified(d_(sh_,bool_,s.c_str()));
			}else
				l2s__(tb->get_modified(),buf);
			break;
		case' ':
			if(p->size()>3)
				tb->set_text((*p)[3]);
			else
				*addr_ret=dup__(tb->get_text().c_str());
			break;
		case'.':
			tv->grab_focus();
			break;
		case'e':
			if(p->size()>3)
				tv->set_editable(d_(sh_,bool_,(*p)[3].c_str()));
			else
				tv->set_editable(false);
			break;
		case'p':
		case'l':
		{
			Gtk::TextIter ti=tb->get_iter_at_mark(tb->get_mark("insert"));
			if(sdz1=='l'){
				if(p->size()<=3)
					sprintf(buf,"%d,%d,",ti.get_line (),ti.get_line_offset ());
				else{
					int line_offset=ti.get_line_offset ();
					if(p->size()>3)
						ti.set_line (s2i_plus__((*p)[3],ti.get_line ()));
					if(p->size()>4)
						ti.set_line_offset (s2i_plus__((*p)[4],line_offset));
					tb->place_cursor(ti);
				}
			}else{
				if(p->size()>3){
					ti.set_offset (s2i_plus__((*p)[3],ti.get_offset ()));
					tb->place_cursor(ti);
				}else
					l2s__(ti.get_offset (),buf);
			}
			break;
		}
		case'S':
			if(p->size()>4){
				Gtk::TextIter ti1=tb->begin(),ti2=tb->begin();
				ti1.set_offset(s2i__((*p)[3]));
				ti2.set_offset(s2i__((*p)[4]));
				tb->select_range(ti1,ti2);
			}
			break;
		}
		break;
	}
	}
	return 1;
}
Exemplo n.º 6
0
int dnd___::proc__(std::deque<Glib::ustring>* p,char*buf,long siz,char**addr_ret,void*shangji,void*ce) {
	if((*p)[0]==name__()){
		if(siz==-1)return 1;
		if(p->size()<3){
			d_(sh_,err_show_buzu_,p);
			return 1;
		}
		Gtk::Widget* w;
		sh_->builder_->get_widget((*p)[2], w);
		if(!w){
			d_(sh_,err_show_wufa_,2,p,2);
			return 1;
		}
		GtkWidget* w1=w->gobj();
		if((*p)[1]=="移除"){
			del__(w1);
			return 1;
		}
		if((*p)[1]=="目标"){
			if(p->size()<6){
				d_(sh_,err_show_buzu_,p);
				return 1;
			}
			int gdd=0,gda=0;

			dnd_cb___* cb=new dnd_cb___('d',w1,sh_,d_);
			for(size_t i=3;i<p->size();i++){
				const Glib::ustring& p1=(*p)[i];
				if(p1=="代码"){
					if(++i>=p->size()){
						d_(sh_,err_show_buzu_,p);
						delete cb;
						return 1;
					}
					cb->code_=(*p)[i];
					continue;
				}
				if(p1=="复制"){
					gda|=GDK_ACTION_COPY;
					continue;
				}
				if(p1=="移动"){
					gda|=GDK_ACTION_MOVE;
					continue;
				}
				if(p1=="链接"){
					gda|=GDK_ACTION_LINK;
					continue;
				}
				if(p1=="高亮"){
					gdd|=GTK_DEST_DEFAULT_HIGHLIGHT|GTK_DEST_DEFAULT_MOTION;
					continue;
				}
				if(p1=="按钮"){
					gdd|=GTK_DEST_DEFAULT_DROP|GTK_DEST_DEFAULT_MOTION;
					continue;
				}
				delete cb;
				d_(sh_,err_show_buzhichi_,2,p,i);
				return 1;
			}

			gtk_drag_dest_set (w1, (GtkDestDefaults)gdd, 0, 0, (GdkDragAction)gda);
			gtk_drag_dest_add_uri_targets(w1);
			cb->sid_=g_signal_connect (w1, "drag-data-received",G_CALLBACK(drag_data_received__), cb);

			cb_.push_back(cb);
			return 1;
		}
		d_(sh_,err_show_buzhichi_,2,p,1);
		return 1;
	}
	return 0;
}