Changeset 144
Author: poliklosio
(2011/06/04 04:24) 12 months ago
ADDITIONS: constructor in String_vec which accepts value/line ending pair of any std::string or c-string type; interface for text size measurement in Text, Text_module, W_caption; constructor for creating Vector2D out of Point2D explicitly; example application slightly better, but still lame; CHANGES: improvement and cleanup of the miscellaneous_widgets.cpp file;
{{{{}{}template <class InputIterator>{}{}{{{{{void miscellaneous_widgets::create_widgets(pkgui::Layer& layer)//specific using directives are here so that you can see//what is being used in this file;using pkgui::W_updated_caption;using pkgui::W_progress_bar;using pkgui::W_described_checkbox;using pkgui::W_caption;using pkgui::W_checkbox;using pkgui::W_button;using pkgui::W_editbox;using pkgui::W_empty_table;using pkgui::W_diagram;using pkgui::W_pull_down_menu;using pkgui::Pull_down_menu_element_button;using pkgui::Widget;using pkgui::Layer;using pkgui::Surface;using pkgui::MB_action;using pkgui::String_vec;using pkgui::Point;using pkgui::Point2D;using pkgui::Size;using pkgui::create_SDL_Rect;using pkgui::create_SDL_Color;using pkgui::get_Graphical_data;using pkgui::Ptr;using pkgui::Str;using pkgui::Text_align;using pkgui::Default_text_displayer_factory;using pkgui::Text_format_UNICODE;using pkgui::Text_displayer_type;namespace Text_displayer_types=pkgui::Text_displayer_types;void miscellaneous_widgets::create_widgets(Layer& layer){{pkgui::WIDGET_PTR widget_ptr=new pkgui::Widget();Ptr<Widget> widget_ptr=new Widget();widget_ptr->set_coord(pkgui::create_SDL_Rect(600,10,140,80));widget_ptr->set_frame_color(pkgui::create_SDL_Color(255,99,0));//widget_ptr->get_image()->set_blitting_strategy(blit_strat_pos_ptr);pkgui::W_CAPTION_PTR w_caption_ptr=new pkgui::W_caption();Ptr<W_caption> w_caption_ptr=new W_caption();w_caption_ptr->set_coord(pkgui::create_SDL_Rect(600,410,140,80));w_caption_ptr->set_text_color(pkgui::create_SDL_Color(0,99,0));w_caption_ptr->set_string_vec(pkgui::Str::to_Uint16_string_vec(w_caption_ptr->set_string_vec(String_vec(string("dadati\n gfdd "),"this is a caption\nwith text centered\nat the top","\n"));string("\n")));pkgui::W_CHECKBOX_PTR w_checkbox_ptr=Ptr<W_checkbox> w_checkbox_ptr=new pkgui::W_checkbox();w_checkbox_ptr->set_coord(pkgui::create_SDL_Rect(600,210,120,100));pkgui::MB_action::HOLD);// w_checkbox_ptr->get_checkbox_image()->set_blitting_strategy(// new pkgui::PKblitting_strategy_center());pkgui::W_BUTTON_PTR w_button_ptr=Ptr<W_button> w_button_ptr=new pkgui::W_button();w_button_ptr->set_coord(pkgui::create_SDL_Rect(100,110,140,90));w_button_ptr->set_color(pkgui::create_SDL_Color(40,255,0));w_button_ptr->set_frame_color(pkgui::create_SDL_Color(2,99,255));pkgui::W_BUTTON_PTR w_button2_ptr=Ptr<W_button> w_button2_ptr=new pkgui::W_button();w_button2_ptr->set_coord(pkgui::create_SDL_Rect(100,500,140,90));pkgui::SURFACE_PTR styl1_sfc_ptr=new pkgui::Surface(Ptr<Surface> styl1_sfc_ptr=new Surface(pkgui::get_Graphical_data().create_texture_unit(pkgui::get_Graphical_data().create_texture_unit(pkgui::MB_action::PRESS);pkgui::get_Graphical_data().create_texture_unit(pkgui::MB_action::HOLD);pkgui::get_Graphical_data().create_texture_unit(pkgui::MB_action::RELEASE);pkgui::W_PULL_DOWN_MENU_PTR drop_down_list_ptr=Ptr<W_pull_down_menu> drop_down_list_ptr=new pkgui::W_pull_down_menu();drop_down_list_ptr->set_coord(pkgui::create_SDL_Rect(300,310,140,90));new pkgui::Pull_down_menu_element_button(drop_down_list_ptr->set_string_vec(pkgui::Str::to_Uint16_string_vec(drop_down_list_ptr->set_string_vec(String_vec("pull down\nmenu","\n"));string("pull down\nmenu"),string("\n")));pkgui::W_UPDATED_CAPTION_PTR updated_caption_ptr=Ptr<W_updated_caption> updated_caption_ptr=new pkgui::W_updated_caption();updated_caption_ptr->set_coord(pkgui::create_SDL_Rect(300,510,140,80));updated_caption_ptr->set_string_vec(pkgui::Str::to_Uint16_string_vec(string("aaa qwert \npp gf dd f z"),string("\n")));string("button on the left\n""shows how graphics\n""is splitto create\n""a widget image"),string("\n")));pkgui::W_DESCRIBED_CHECKBOX_PTR described_chechbox_pointer=Ptr<W_described_checkbox> described_chechbox_pointer=new pkgui::W_described_checkbox();pkgui::create_SDL_Rect(100,260,140,80));pkgui::create_SDL_Color(255,99,0));described_chechbox_pointer->set_string_vec(String_vec(pkgui::Str::to_Uint16_string_vec("described\ncheckbox","\n"));string("described\ncheckbox"),string("\n")));pkgui::Ptr<pkgui::W_diagram<double,double,string> > diagram_ptr;Ptr<W_diagram<double,double,string> > diagram_ptr;diagram_ptr=new pkgui::W_diagram<double,double,string>;diagram_ptr->set_coord(pkgui::create_SDL_Rect(60,80,600,400));diagram_ptr->get_diagram()->set_data("dfsds",make_pair(&map_for_diagram,diagram_ptr->get_diagram()->set_data("dfsds",make_pair(&map_for_diagram,pkgui::create_SDL_Color(0x99,0x88,0x77)));diagram_ptr->get_diagram()->set_data("dffsds",make_pair(&map_for_diagram2,diagram_ptr->get_diagram()->set_data("dffsds",make_pair(&map_for_diagram2,pkgui::create_SDL_Color(0x99,0,0)));pkgui::W_EDITBOX_PTR w_editbox_ptr=new pkgui::W_editbox();Ptr<W_editbox> w_editbox_ptr=new W_editbox();w_editbox_ptr->set_coord(pkgui::create_SDL_Rect(200,160,140,80));w_editbox_ptr->set_color(pkgui::create_SDL_Color(140,160,180));w_editbox_ptr->get_contents()->set_color(pkgui::create_SDL_Color(77,0,0));pkgui::Default_text_displayer_factory<pkgui::Text_format_UNICODE>Default_text_displayer_factory<Text_format_UNICODE>text_disp_factory,pkgui::Text_displayer_type(pkgui::Text_displayer_types::PER_LINE));// w_editbox_ptr->get_contents()->set_string_vec(// pkgui::Str::to_Uint16_string_vec(// string("uuu\nnnn"),// string("\n")));// w_editbox_ptr->get_contents()->set_show_caption(true);pkgui::W_EMPTY_TABLE_PTR empty_table_ptr=new pkgui::W_empty_table();Ptr<W_empty_table> empty_table_ptr=new W_empty_table();empty_table_ptr->set_coord(pkgui::create_SDL_Rect(200,10,200,100));empty_table_ptr->set_frame_color(pkgui::create_SDL_Color(9,200,100));pkgui::W_PROGRESS_BAR_PTR progress_bar_ptr=Ptr<W_progress_bar> progress_bar_ptr=new pkgui::W_progress_bar();pkgui::create_SDL_Rect(500,108,200,10));// layer.add_widget(get_in(diagram_ptr));{// void set_align_within_text(Text_align arg);// Text_align get_align_within_text()const;{text_module.set_string_vec(arg);}{text_module.set_string_vec(arg);}{text_module.set_text_color(arg);}{text_module.set_text_color(arg);}// inline void W_caption::set_align_within_text(Text_align arg)// {text_module.set_align_within_text(arg);}{text_module.set_align(arg);}{text_module.set_align(arg);}{return text_module.get_string_vec();}{return text_module.get_string_vec();}{return text_module.get_text_color();}{return text_module.get_text_color();}// inline Text_align W_caption::get_align_within_text()const// {return text_module.get_align_within_text();}{return text_module.get_align();}{return text_module.get_align();}{return text_module.get_text_pos_rel();}{return text_module.get_text_pos_rel();}{{return new Decorated_widget_proxy(const_cast<W_caption&>(*this));}return new Decorated_widget_proxy(inline Vector2D<int> W_caption::get_text_size()const_cast<W_caption&>(*this));{return text_module.get_text_size();}}* @see get_coord move;* @see get_coord,move;{{appearance.set_image(arg);}{appearance.set_image(arg);}