Changeset 144

User picture

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;

Affected files

Updated low_layer/Point2D.h Download diff

143144
178
        Vector2D(const Vector2D<int_type2>& arg):Point2D<type>(arg)
178
        Vector2D(const Vector2D<int_type2>& arg):Point2D<type>(arg)
179
        {
179
        {
180
        }
180
        }
181
182
        template<class int_type2>
183
        explicit Vector2D(const Point2D<int_type2>& arg):Point2D<type>(arg)
184
        {
185
        }
181
    };
186
    };
182
187
183
    template<class type>
188
    template<class type>

Updated low_layer/String.h Download diff

143144
310
            std::vector<std::basic_string<charT> >(n,_val)
310
            std::vector<std::basic_string<charT> >(n,_val)
311
            {}
311
            {}
312
312
313
        template <class InputIterator>
313
        template<class InputIterator>
314
        Multiline_string(InputIterator first, InputIterator last):
314
        Multiline_string(InputIterator first, InputIterator last):
315
            std::vector<std::basic_string<charT> >(first,last)
315
            std::vector<std::basic_string<charT> >(first,last)
316
            {}
316
            {}
...
...
323
                _line_ending);
323
                _line_ending);
324
        }
324
        }
325
325
326
        template<class fromCharT>
327
        Multiline_string(const fromCharT* _val,const fromCharT* _line_ending)
328
        {
329
            std::basic_string<charT> val,line_ending;
330
            Str::to_string(val,std::basic_string<fromCharT>(_val));
331
            Str::to_string(line_ending,std::basic_string<fromCharT>(_line_ending));
332
            Str::to_string_vec(const_cast<Multiline_string&>(*this),
333
                val,
334
                line_ending);
335
        }
336
337
        template<class fromCharT>
338
        Multiline_string(const std::basic_string<fromCharT>& _val,
339
            const std::basic_string<fromCharT>& _line_ending)
340
        {
341
            std::basic_string<charT> val,line_ending;
342
            Str::to_string(val,_val);
343
            Str::to_string(line_ending,_line_ending);
344
            Str::to_string_vec(const_cast<Multiline_string&>(*this),
345
                val,
346
                line_ending);
347
        }
348
326
        template<class toChar>
349
        template<class toChar>
327
        void to_basic_string(std::basic_string<toChar>& _to,
350
        void to_basic_string(std::basic_string<toChar>& _to,
328
            const std::basic_string<toChar>& _line_ending)const
351
            const std::basic_string<toChar>& _line_ending)const

Updated low_layer/Text.cpp Download diff

143144
68
    Vector2D<int> Text<textType>::size_multiline(const Sint32 line_skip)
68
    Vector2D<int> Text<textType>::size_multiline(const Sint32 line_skip)
69
    {
69
    {
70
        return text_displayer->size_multiline(line_skip);
70
        return text_displayer->size_multiline(line_skip);
71
    }
72
73
    template<class textType>
74
    Vector2D<int> Text<textType>::size_multiline()
75
    {
76
        if(attributes.get_font()==0)
77
            return Vector2D<int>();
78
        return text_displayer->size_multiline(attributes.get_font()->line_skip());
71
    }
79
    }
72
    //constructors
80
    //constructors
73
81

Updated low_layer/Text.h Download diff

143144
304
        ///'line_skip' (height of each line); for empty vector of strings
304
        ///'line_skip' (height of each line); for empty vector of strings
305
        ///returns (0,line_skip), assuming the first empty line is there;
305
        ///returns (0,line_skip), assuming the first empty line is there;
306
        Vector2D<int> size_multiline(const Sint32 line_skip);
306
        Vector2D<int> size_multiline(const Sint32 line_skip);
307
        ///returns the size of the current text rendered with the default
308
        ///'line_skip' of the current font (height of each line);
309
        ///for empty vector of strings returns (0,line_skip), assuming
310
        ///the first empty line is there;
311
        Vector2D<int> size_multiline();
307
        ///renders a single line of text using SDL_ttf function hidden in
312
        ///renders a single line of text using SDL_ttf function hidden in
308
        ///'mode' object with attributes given by the class object
313
        ///'mode' object with attributes given by the class object
309
        SURFACE_PTR render_line(const std::basic_string<char_type>&)const;
314
        SURFACE_PTR render_line(const std::basic_string<char_type>&)const;

Updated miscellaneous_widgets.cpp Download diff

143144
3
#if defined(PKGUI_IN_COLLECTIVE) or not defined(PKGUI_BUILD_COLLECTIVELY)
3
#if defined(PKGUI_IN_COLLECTIVE) or not defined(PKGUI_BUILD_COLLECTIVELY)
4
#include "miscellaneous_widgets.h"
4
#include "miscellaneous_widgets.h"
5
5
6
void miscellaneous_widgets::create_widgets(pkgui::Layer& layer)
6
//specific using directives are here so that you can see
7
//what is being used in this file;
8
using pkgui::W_updated_caption;
9
using pkgui::W_progress_bar;
10
using pkgui::W_described_checkbox;
11
using pkgui::W_caption;
12
using pkgui::W_checkbox;
13
using pkgui::W_button;
14
using pkgui::W_editbox;
15
using pkgui::W_empty_table;
16
using pkgui::W_diagram;
17
using pkgui::W_pull_down_menu;
18
using pkgui::Pull_down_menu_element_button;
19
using pkgui::Widget;
20
using pkgui::Layer;
21
using pkgui::Surface;
22
using pkgui::MB_action;
23
using pkgui::String_vec;
24
using pkgui::Point;
25
using pkgui::Point2D;
26
using pkgui::Size;
27
using pkgui::create_SDL_Rect;
28
using pkgui::create_SDL_Color;
29
using pkgui::get_Graphical_data;
30
using pkgui::Ptr;
31
using pkgui::Str;
32
using pkgui::Text_align;
33
using pkgui::Default_text_displayer_factory;
34
using pkgui::Text_format_UNICODE;
35
using pkgui::Text_displayer_type;
36
namespace Text_displayer_types=pkgui::Text_displayer_types;
37
38
39
void miscellaneous_widgets::create_widgets(Layer& layer)
7
{
40
{
8
    ///this does not demonstrate the recommended way of creating widgets
41
    ///this does not demonstrate the recommended way of creating widgets
9
    ///it is here just to show that they may be created by invoking
42
    ///it is here just to show that they may be created by invoking
...
...
12
    ///class;
45
    ///class;
13
46
14
    ///lets create an empty
47
    ///lets create an empty
15
    pkgui::WIDGET_PTR widget_ptr=new pkgui::Widget();
48
    Ptr<Widget> widget_ptr=new Widget();
16
    ///set rectangle in which the widget will be drawn; the default size is
49
    ///set rectangle in which the widget will be drawn; the default size is
17
    ///(100,20) (in pixels), but it is recommended to keep setting the size
50
    ///(100,20) (in pixels), but it is recommended to keep setting the size
18
    ///according to what is right in particular application;
51
    ///according to what is right in particular application;
19
    widget_ptr->set_coord(pkgui::create_SDL_Rect(600,10,140,80));
52
    widget_ptr->set_coord(create_SDL_Rect(600,10,140,80));
20
    ///color of the border around the widget; this widget will have
53
    ///color of the border around the widget; this widget will have
21
    widget_ptr->set_frame_color(pkgui::create_SDL_Color(255,99,0));
54
    widget_ptr->set_frame_color(create_SDL_Color(255,99,0));
22
    widget_ptr->set_texture_unit(data.texture1);
55
    widget_ptr->set_texture_unit(data.texture1);
23
    //widget_ptr->get_image()->set_blitting_strategy(blit_strat_pos_ptr);
24
56
25
    pkgui::W_CAPTION_PTR w_caption_ptr=new pkgui::W_caption();
57
    Ptr<W_caption> w_caption_ptr=new W_caption();
26
    w_caption_ptr->set_coord(pkgui::create_SDL_Rect(600,410,140,80));
58
    w_caption_ptr->set_coord(create_SDL_Rect(600,410,140,80));
27
    w_caption_ptr->set_font(data.font);
59
    w_caption_ptr->set_font(data.font);
28
    w_caption_ptr->set_text_color(pkgui::create_SDL_Color(0,99,0));
60
    w_caption_ptr->set_text_color(create_SDL_Color(0,99,0));
29
    w_caption_ptr->set_string_vec(pkgui::Str::to_Uint16_string_vec(
61
    w_caption_ptr->set_string_vec(String_vec(
30
        string("dadati\n gfdd "),
62
        "this is a caption\nwith text centered\nat the top","\n"));
31
        string("\n")));
32
    w_caption_ptr->set_show_caption(true);
63
    w_caption_ptr->set_show_caption(true);
33
    w_caption_ptr->set_texture_unit(data.texture3);
64
    w_caption_ptr->set_texture_unit(data.texture3);
34
65
35
    pkgui::W_CHECKBOX_PTR w_checkbox_ptr=
66
    Ptr<W_checkbox> w_checkbox_ptr=
36
        new pkgui::W_checkbox();
67
        new W_checkbox();
37
    w_checkbox_ptr->set_coord(pkgui::create_SDL_Rect(600,210,120,100));
68
    w_checkbox_ptr->set_coord(create_SDL_Rect(600,210,120,100));
38
    w_checkbox_ptr->set_texture_unit(data.texture1);
69
    w_checkbox_ptr->set_texture_unit(data.texture1);
39
    w_checkbox_ptr->set_action_texture_unit(data.texture2,
70
    w_checkbox_ptr->set_action_texture_unit(data.texture2,
40
        pkgui::MB_action::HOLD);
71
        MB_action::HOLD);
41
    w_checkbox_ptr->set_checkbox_texture_unit(data.texture3);
72
    w_checkbox_ptr->set_checkbox_texture_unit(data.texture3);
42
//    w_checkbox_ptr->get_checkbox_image()->set_blitting_strategy(
43
//        new pkgui::PKblitting_strategy_center());
44
73
45
    pkgui::W_BUTTON_PTR w_button_ptr=
74
    Ptr<W_button> w_button_ptr=
46
        new pkgui::W_button();
75
        new W_button();
47
    w_button_ptr->set_coord(pkgui::create_SDL_Rect(100,110,140,90));
76
    w_button_ptr->set_coord(create_SDL_Rect(100,110,140,90));
48
    w_button_ptr->set_color(pkgui::create_SDL_Color(40,255,0));
77
    w_button_ptr->set_color(create_SDL_Color(40,255,0));
49
    w_button_ptr->set_frame_color(pkgui::create_SDL_Color(2,99,255));
78
    w_button_ptr->set_frame_color(create_SDL_Color(2,99,255));
50
79
51
    pkgui::W_BUTTON_PTR w_button2_ptr=
80
    Ptr<W_button> w_button2_ptr=
52
        new pkgui::W_button();
81
        new W_button();
53
    w_button2_ptr->set_coord(pkgui::create_SDL_Rect(100,500,140,90));
82
    w_button2_ptr->set_coord(create_SDL_Rect(100,500,140,90));
54
    ///this demonstrates loading a surface from a file manually,
83
    ///this demonstrates loading a surface from a file manually,
55
    ///giving it to surface manager and setting it in a widget;
84
    ///giving it to surface manager and setting it in a widget;
56
    pkgui::SURFACE_PTR styl1_sfc_ptr=new pkgui::Surface(
85
    Ptr<Surface> styl1_sfc_ptr=new Surface(
57
        "example_app_resources/styl1.bmp");
86
        "example_app_resources/styl1.bmp");
58
    data.surface_manager.use_bitmap_set(styl1_sfc_ptr,"dadada");
87
    data.surface_manager.use_bitmap_set(styl1_sfc_ptr,"dadada");
59
    w_button2_ptr->set_texture_unit(
88
    w_button2_ptr->set_texture_unit(
60
        pkgui::get_Graphical_data().create_texture_unit(
89
        get_Graphical_data().create_texture_unit(
61
            data.surface_manager.get_surface(
90
            data.surface_manager.get_surface(
62
            "dadada",w_button2_ptr->get_size())
91
            "dadada",w_button2_ptr->get_size())
63
        ));
92
        ));
64
    ///this demonstrates loading a surface from a file using the surface
93
    ///this demonstrates loading a surface from a file using the surface
65
    ///manager
94
    ///manager
66
    w_button2_ptr->set_button_texture_unit(
95
    w_button2_ptr->set_button_texture_unit(
67
        pkgui::get_Graphical_data().create_texture_unit(
96
        get_Graphical_data().create_texture_unit(
68
            data.surface_manager.get_surface_by_filename(
97
            data.surface_manager.get_surface_by_filename(
69
            "example_app_resources/styl1pressed.bmp",
98
            "example_app_resources/styl1pressed.bmp",
70
            w_button2_ptr->get_size())),
99
            w_button2_ptr->get_size())),
71
        pkgui::MB_action::PRESS);
100
        MB_action::PRESS);
72
    w_button2_ptr->set_button_texture_unit(
101
    w_button2_ptr->set_button_texture_unit(
73
        pkgui::get_Graphical_data().create_texture_unit(
102
        get_Graphical_data().create_texture_unit(
74
            data.surface_manager.get_surface_by_filename(
103
            data.surface_manager.get_surface_by_filename(
75
            "example_app_resources/styl1held.bmp",w_button2_ptr->get_size())),
104
            "example_app_resources/styl1held.bmp",w_button2_ptr->get_size())),
76
        pkgui::MB_action::HOLD);
105
        MB_action::HOLD);
77
    w_button2_ptr->set_button_texture_unit(
106
    w_button2_ptr->set_button_texture_unit(
78
        pkgui::get_Graphical_data().create_texture_unit(
107
        get_Graphical_data().create_texture_unit(
79
            data.surface_manager.get_surface_by_filename(
108
            data.surface_manager.get_surface_by_filename(
80
            "example_app_resources/styl1released.bmp",w_button2_ptr->get_size())),
109
            "example_app_resources/styl1released.bmp",w_button2_ptr->get_size())),
81
        pkgui::MB_action::RELEASE);
110
        MB_action::RELEASE);
82
111
83
    pkgui::W_PULL_DOWN_MENU_PTR drop_down_list_ptr=
112
    Ptr<W_pull_down_menu> drop_down_list_ptr=
84
        new pkgui::W_pull_down_menu();
113
        new W_pull_down_menu();
85
    drop_down_list_ptr->set_coord(pkgui::create_SDL_Rect(300,310,140,90));
114
    drop_down_list_ptr->set_coord(create_SDL_Rect(300,310,140,90));
86
    drop_down_list_ptr->add_element(
115
    drop_down_list_ptr->add_element(
87
        new pkgui::Pull_down_menu_element_button(
116
        new Pull_down_menu_element_button(
88
            *drop_down_list_ptr,0,w_button_ptr));
117
            *drop_down_list_ptr,0,w_button_ptr));
89
    drop_down_list_ptr->set_font(data.font);
118
    drop_down_list_ptr->set_font(data.font);
90
    drop_down_list_ptr->set_string_vec(pkgui::Str::to_Uint16_string_vec(
119
    drop_down_list_ptr->set_string_vec(String_vec("pull down\nmenu","\n"));
91
        string("pull down\nmenu"),
92
        string("\n")));
93
    drop_down_list_ptr->set_show_caption(true);
120
    drop_down_list_ptr->set_show_caption(true);
94
121
95
    pkgui::W_UPDATED_CAPTION_PTR updated_caption_ptr=
122
    Ptr<W_updated_caption> updated_caption_ptr=
96
        new pkgui::W_updated_caption();
123
        new W_updated_caption();
97
    updated_caption_ptr->set_coord(pkgui::create_SDL_Rect(300,510,140,80));
124
98
    updated_caption_ptr->set_string_vec(pkgui::Str::to_Uint16_string_vec(
125
    updated_caption_ptr->set_string_vec(Str::to_Uint16_string_vec(
99
        string("aaa qwert \npp gf dd f z"),string("\n")));
126
        string("button on the left\n"
127
               "shows how graphics\n"
128
               "is splitto create\n"
129
               "a widget image"),string("\n")));
100
    updated_caption_ptr->set_font(data.font);
130
    updated_caption_ptr->set_font(data.font);
101
    updated_caption_ptr->set_show_caption(true);
131
    updated_caption_ptr->set_show_caption(true);
132
    updated_caption_ptr->set_text_align(Text_align::LEFT);
133
    updated_caption_ptr->set_pos(Point(300,500));
134
    Size sssss(updated_caption_ptr->get_text_size()+Point2D<int>(5,5));
135
//    sssss+=;
136
    updated_caption_ptr->set_size(sssss);
102
137
103
    pkgui::W_DESCRIBED_CHECKBOX_PTR described_chechbox_pointer=
138
    Ptr<W_described_checkbox> described_chechbox_pointer=
104
        new pkgui::W_described_checkbox();
139
        new W_described_checkbox();
105
    described_chechbox_pointer->set_coord(
140
    described_chechbox_pointer->set_coord(
106
        pkgui::create_SDL_Rect(100,260,140,80));
141
        create_SDL_Rect(100,260,140,80));
107
    described_chechbox_pointer->set_frame_color(
142
    described_chechbox_pointer->set_frame_color(
108
        pkgui::create_SDL_Color(255,99,0));
143
        create_SDL_Color(255,99,0));
109
    described_chechbox_pointer->set_font(data.font);
144
    described_chechbox_pointer->set_font(data.font);
110
    described_chechbox_pointer->set_string_vec(
145
    described_chechbox_pointer->set_string_vec(String_vec(
111
        pkgui::Str::to_Uint16_string_vec(
146
        "described\ncheckbox","\n"));
112
            string("described\ncheckbox"),string("\n")));
113
    described_chechbox_pointer->set_show_caption(true);
147
    described_chechbox_pointer->set_show_caption(true);
114
148
115
    pkgui::Ptr<pkgui::W_diagram<double,double,string> > diagram_ptr;
149
    Ptr<W_diagram<double,double,string> > diagram_ptr;
116
    diagram_ptr=new pkgui::W_diagram<double,double,string>;
150
    diagram_ptr=new W_diagram<double,double,string>;
117
    diagram_ptr->set_coord(pkgui::create_SDL_Rect(60,80,600,400));
151
    diagram_ptr->set_coord(create_SDL_Rect(60,80,600,400));
118
    diagram_ptr->get_diagram()->set_font(data.font);
152
    diagram_ptr->get_diagram()->set_font(data.font);
119
    diagram_ptr->get_diagram()->set_key_direction(pkgui::BOTTOM);
153
    diagram_ptr->get_diagram()->set_key_direction(pkgui::BOTTOM);
120
    diagram_ptr->get_diagram()->set_value_direction(pkgui::RIGHT);
154
    diagram_ptr->get_diagram()->set_value_direction(pkgui::RIGHT);
...
...
129
    map_for_diagram2[4.4]=35;
163
    map_for_diagram2[4.4]=35;
130
164
131
    diagram_ptr->get_diagram()->set_data("dfsds",make_pair(&map_for_diagram,
165
    diagram_ptr->get_diagram()->set_data("dfsds",make_pair(&map_for_diagram,
132
        pkgui::create_SDL_Color(0x99,0x88,0x77)));
166
        create_SDL_Color(0x99,0x88,0x77)));
133
    diagram_ptr->get_diagram()->set_data("dffsds",make_pair(&map_for_diagram2,
167
    diagram_ptr->get_diagram()->set_data("dffsds",make_pair(&map_for_diagram2,
134
        pkgui::create_SDL_Color(0x99,0,0)));
168
        create_SDL_Color(0x99,0,0)));
135
    diagram_ptr->get_diagram()->set_conv_functions_to_defaults();
169
    diagram_ptr->get_diagram()->set_conv_functions_to_defaults();
136
170
137
    pkgui::W_EDITBOX_PTR w_editbox_ptr=new pkgui::W_editbox();
171
    Ptr<W_editbox> w_editbox_ptr=new W_editbox();
138
    w_editbox_ptr->set_coord(pkgui::create_SDL_Rect(200,160,140,80));
172
    w_editbox_ptr->set_coord(create_SDL_Rect(200,160,140,80));
139
    w_editbox_ptr->set_color(pkgui::create_SDL_Color(140,160,180));
173
    w_editbox_ptr->set_color(create_SDL_Color(140,160,180));
140
    w_editbox_ptr->get_contents()->set_font(data.font2);
174
    w_editbox_ptr->get_contents()->set_font(data.font2);
141
    w_editbox_ptr->get_contents()->set_color(pkgui::create_SDL_Color(77,0,0));
175
    w_editbox_ptr->get_contents()->set_color(create_SDL_Color(77,0,0));
142
    w_editbox_ptr->get_contents()->set_line_height(20);
176
    w_editbox_ptr->get_contents()->set_line_height(20);
143
    pkgui::Default_text_displayer_factory<pkgui::Text_format_UNICODE>
177
    Default_text_displayer_factory<Text_format_UNICODE>
144
      text_disp_factory;
178
      text_disp_factory;
145
    w_editbox_ptr->get_contents()->set_text_displayer(
179
    w_editbox_ptr->get_contents()->set_text_displayer(
146
        text_disp_factory,pkgui::Text_displayer_type(
180
        text_disp_factory,Text_displayer_type(
147
            pkgui::Text_displayer_types::PER_LINE));
181
            Text_displayer_types::PER_LINE));
148
//    w_editbox_ptr->get_contents()->set_string_vec(
149
//        pkgui::Str::to_Uint16_string_vec(
150
//        string("uuu\nnnn"),
151
//        string("\n")));
152
//    w_editbox_ptr->get_contents()->set_show_caption(true);
153
182
154
    pkgui::W_EMPTY_TABLE_PTR empty_table_ptr=new pkgui::W_empty_table();
183
    Ptr<W_empty_table> empty_table_ptr=new W_empty_table();
155
    empty_table_ptr->set_coord(pkgui::create_SDL_Rect(200,10,200,100));
184
    empty_table_ptr->set_coord(create_SDL_Rect(200,10,200,100));
156
    empty_table_ptr->set_number_of_rows(4);
185
    empty_table_ptr->set_number_of_rows(4);
157
    empty_table_ptr->set_frame_color(pkgui::create_SDL_Color(9,200,100));
186
    empty_table_ptr->set_frame_color(create_SDL_Color(9,200,100));
158
    empty_table_ptr->set_number_of_columns(6);
187
    empty_table_ptr->set_number_of_columns(6);
159
188
160
    pkgui::W_PROGRESS_BAR_PTR progress_bar_ptr=
189
    Ptr<W_progress_bar> progress_bar_ptr=
161
        new pkgui::W_progress_bar();
190
        new W_progress_bar();
162
    progress_bar_ptr->get_bar()->set_clip_rect(
191
    progress_bar_ptr->get_bar()->set_clip_rect(
163
        pkgui::create_SDL_Rect(500,108,200,10));
192
        create_SDL_Rect(500,108,200,10));
164
193
194
    Ptr<W_caption> instruction_on_the_top=
195
        new W_caption();
196
    instruction_on_the_top->set_pos(Point(5,5));
197
    instruction_on_the_top->set_font(data.font);
198
    instruction_on_the_top->set_text_color(create_SDL_Color(0,99,0));
199
    instruction_on_the_top->set_string_vec(String_vec(
200
        "press keyboard digits to see "
201
        "different demomstrations","\n"));
202
    instruction_on_the_top->set_show_caption(true);
203
    instruction_on_the_top->set_size(
204
        Size(instruction_on_the_top->get_text_size()+Size(5,5)));
205
    instruction_on_the_top->set_texture_unit(
206
        get_Graphical_data().create_texture_unit(
207
            data.surface_manager.get_surface(
208
            data.stylereal_id,instruction_on_the_top->get_size())));
209
165
    layer.add_widget(get_in(widget_ptr));
210
    layer.add_widget(get_in(widget_ptr));
166
    layer.add_widget(get_in(w_caption_ptr));
211
    layer.add_widget(get_in(w_caption_ptr));
167
    layer.add_widget(get_in(w_checkbox_ptr));
212
    layer.add_widget(get_in(w_checkbox_ptr));
...
...
170
    layer.add_widget(get_in(drop_down_list_ptr));
215
    layer.add_widget(get_in(drop_down_list_ptr));
171
    layer.add_widget(get_in(updated_caption_ptr));
216
    layer.add_widget(get_in(updated_caption_ptr));
172
    layer.add_widget(get_in(described_chechbox_pointer));
217
    layer.add_widget(get_in(described_chechbox_pointer));
173
//    layer.add_widget(get_in(diagram_ptr));
174
    layer.add_widget(get_in(w_editbox_ptr));
218
    layer.add_widget(get_in(w_editbox_ptr));
175
    layer.add_widget(get_in(empty_table_ptr));
219
    layer.add_widget(get_in(empty_table_ptr));
176
    layer.add_widget(get_in(progress_bar_ptr));
220
    layer.add_widget(get_in(progress_bar_ptr));
221
    layer.add_widget(get_in(instruction_on_the_top));
177
}
222
}
178
#endif
223
#endif

Updated specific_layer/widget_components/Text_module.cpp Download diff

143144
11
        text->set_align(Text_align::CENTER);
11
        text->set_align(Text_align::CENTER);
12
    }
12
    }
13
13
14
    Vector2D<int> Text_module::get_text_size()
15
    {
16
        return text->size_multiline();
17
    }
18
14
    ///draws the text with respect to the text_align and other properties
19
    ///draws the text with respect to the text_align and other properties
15
    void Text_module::draw_text(Display_target& _target,
20
    void Text_module::draw_text(Display_target& _target,
16
        const SDL_Rect& _part,Point _pos,const SDL_Rect& _coord)
21
        const SDL_Rect& _part,Point _pos,const SDL_Rect& _coord)

Updated specific_layer/widget_components/Text_module.h Download diff

143144
49
        ///similar to Base::draw with 3 arguments;
49
        ///similar to Base::draw with 3 arguments;
50
        void draw_text(Display_target& _target,const SDL_Rect& _part,
50
        void draw_text(Display_target& _target,const SDL_Rect& _part,
51
            Point _pos,const SDL_Rect& _coord);
51
            Point _pos,const SDL_Rect& _coord);
52
        ///gives size of the rendered text without rendering it
53
        ///like Text::size_multiline();
54
        Vector2D<int> get_text_size();
52
        void perform_scale(Size _new_resolution,
55
        void perform_scale(Size _new_resolution,
53
            Size _from);
56
            Size _from);
54
    };
57
    };

Updated specific_layer/widgets/W_caption.h Download diff

143144
21
        void set_string_vec(const String_vec& arg);
21
        void set_string_vec(const String_vec& arg);
22
        void set_text_color(SDL_Color arg);
22
        void set_text_color(SDL_Color arg);
23
        void set_text_align(Text_align arg);
23
        void set_text_align(Text_align arg);
24
//        void set_align_within_text(Text_align arg);
25
        void set_font(const FONT_PTR& arg);
24
        void set_font(const FONT_PTR& arg);
26
        void set_show_caption(bool arg);
25
        void set_show_caption(bool arg);
27
        void set_text_pos_rel(Point arg);
26
        void set_text_pos_rel(Point arg);
...
...
30
        const String_vec* get_string_vec()const;
29
        const String_vec* get_string_vec()const;
31
        SDL_Color get_text_color()const;
30
        SDL_Color get_text_color()const;
32
        Text_align get_text_align()const;
31
        Text_align get_text_align()const;
33
//        Text_align get_align_within_text()const;
34
        FONT_PTR get_font()const;
32
        FONT_PTR get_font()const;
35
        bool get_show_caption()const;
33
        bool get_show_caption()const;
36
        Point get_text_pos_rel()const;
34
        Point get_text_pos_rel()const;
35
        Vector2D<int> get_text_size();
37
        //constructors
36
        //constructors
38
        W_caption();
37
        W_caption();
39
        //another functions
38
        //another functions
...
...
74
        {text_module.set_string_vec(arg);}
73
        {text_module.set_string_vec(arg);}
75
    inline void W_caption::set_text_color(SDL_Color arg)
74
    inline void W_caption::set_text_color(SDL_Color arg)
76
        {text_module.set_text_color(arg);}
75
        {text_module.set_text_color(arg);}
77
//    inline void W_caption::set_align_within_text(Text_align arg)
78
//        {text_module.set_align_within_text(arg);}
79
    inline void W_caption::set_text_align(Text_align arg)
76
    inline void W_caption::set_text_align(Text_align arg)
80
        {text_module.set_align(arg);}
77
        {text_module.set_align(arg);}
81
    inline void W_caption::set_font(const FONT_PTR& arg)
78
    inline void W_caption::set_font(const FONT_PTR& arg)
...
...
92
        {return text_module.get_string_vec();}
89
        {return text_module.get_string_vec();}
93
    inline SDL_Color W_caption::get_text_color()const
90
    inline SDL_Color W_caption::get_text_color()const
94
        {return text_module.get_text_color();}
91
        {return text_module.get_text_color();}
95
//    inline Text_align W_caption::get_align_within_text()const
96
//        {return text_module.get_align_within_text();}
97
    inline Text_align W_caption::get_text_align()const
92
    inline Text_align W_caption::get_text_align()const
98
        {return text_module.get_align();}
93
        {return text_module.get_align();}
99
    inline FONT_PTR W_caption::get_font()const
94
    inline FONT_PTR W_caption::get_font()const
...
...
104
        {return text_module.get_text_pos_rel();}
99
        {return text_module.get_text_pos_rel();}
105
    inline Ptr<Positioned_decorable_proxy>
100
    inline Ptr<Positioned_decorable_proxy>
106
        W_caption::get_dec_pos_proxy()
101
        W_caption::get_dec_pos_proxy()
107
    {
102
        {return new Decorated_widget_proxy(const_cast<W_caption&>(*this));}
108
        return new Decorated_widget_proxy(
103
    inline Vector2D<int> W_caption::get_text_size()
109
            const_cast<W_caption&>(*this));
104
        {return text_module.get_text_size();}
110
    }
111
}
105
}
112
#endif
106
#endif

Updated specific_layer/widgets/Widget.h Download diff

143144
166
         * @param arg the rectangle that contains said position and size;
166
         * @param arg the rectangle that contains said position and size;
167
         * @note if the widget has children, calling this function does not
167
         * @note if the widget has children, calling this function does not
168
         * move them; call 'move' to achieve this;
168
         * move them; call 'move' to achieve this;
169
         * @see get_coord move;
169
         * @see get_coord,move;
170
         */
170
         */
171
        virtual void set_coord(SDL_Rect arg);
171
        virtual void set_coord(SDL_Rect arg);
172
        ///like 'set_coord' but only sets position of the widget
172
        ///like 'set_coord' but only sets position of the widget
...
...
174
        ///@param arg pair of coordinates in pixels;
174
        ///@param arg pair of coordinates in pixels;
175
        ///@see set_coord;
175
        ///@see set_coord;
176
        virtual void set_pos(Point arg);
176
        virtual void set_pos(Point arg);
177
        ///like 'set_coord' but only sets the size of the widget
178
        ///(width and height);
179
        ///@param arg pair of dimensions in pixels;
180
        ///@see set_coord;
181
        virtual void set_size(Size arg);
177
        //getters
182
        //getters
178
        ///returns the value which can be set with set_color;
183
        ///returns the value which can be set with set_color;
179
        ///@see set_color;
184
        ///@see set_color;
...
...
354
        coord.x=arg.x;
359
        coord.x=arg.x;
355
        coord.y=arg.y;
360
        coord.y=arg.y;
356
    }
361
    }
362
    inline void Widget::set_size(Size arg)
363
    {
364
        coord.w=arg.x;
365
        coord.h=arg.y;
366
    }
357
    inline void Widget::set_image(const BACKGROUND_OF_WIDGET_PTR& arg)
367
    inline void Widget::set_image(const BACKGROUND_OF_WIDGET_PTR& arg)
358
        {appearance.set_image(arg);}
368
        {appearance.set_image(arg);}
359
    inline const BACKGROUND_OF_WIDGET_PTR& Widget::get_image()const
369
    inline const BACKGROUND_OF_WIDGET_PTR& Widget::get_image()const