예제 #1
0
파일: text.cs 프로젝트: kwanboy/mcs
 //-------------------------------------------------
 //  line::ctor
 //-------------------------------------------------
 public line(text_layout layout, text_justify justify, float yoffset, float height)
 {
     m_layout  = layout;
     m_justify = justify;
     m_yoffset = yoffset;
     m_width   = 0;
     m_height  = height;
 }
예제 #2
0
            // methods

            //-------------------------------------------------
            //  line::add_character
            //-------------------------------------------------
            public void add_character(text_layout layout, char32_t ch, char_style style, source_info source)
            {
                // get the width of this character
                float chwidth = layout.get_char_width(ch, style.size);

                // append the positioned character
                m_characters.emplace_back(new positioned_char()
                {
                    character = ch, style = style, source = source, xoffset = m_width, xwidth = chwidth
                });
                m_width += chwidth;

                // we might be bigger
                m_height = std.max(m_height, style.size * layout.yscale());
            }
예제 #3
0
파일: text.cs 프로젝트: kwanboy/mcs
        //-------------------------------------------------
        //  ctor (move)
        //-------------------------------------------------
        text_layout(text_layout that)
        {
            m_font   = that.m_font;
            m_xscale = that.m_xscale;
            m_yscale = that.m_yscale;
            m_width  = that.m_width;
            m_calculated_actual_width = that.m_calculated_actual_width;
            m_justify       = that.m_justify;
            m_wrap          = that.m_wrap;
            m_lines         = new std.vector <line>(that.m_lines);
            m_current_line  = that.m_current_line;
            m_last_break    = that.m_last_break;
            m_text_position = that.m_text_position;
            m_truncating    = false;


            that.invalidate_calculated_actual_width();
        }
예제 #4
0
 protected override void populate_text(text_layout layout, float width, int lines)
 {
     throw new emu_unimplemented();
 }
예제 #5
0
        //virtual ~menu_dats_view() override;


        public static void add_info_text(text_layout layout, string text, rgb_t color, float size = 1.0f)
        {
            throw new emu_unimplemented();
        }
예제 #6
0
 // accessors
 public float xoffset(text_layout layout)
 {
     return((layout.width() * m_anchor_target) - (m_width * m_anchor_pos));
 }
예제 #7
0
            public void align_text(text_layout layout)
            {
                assert(m_right_justify_start >= m_center_justify_start);

                if (m_characters.empty() || m_center_justify_start != 0)
                {
                    // at least some of the text is left-justified - anchor to left
                    m_anchor_pos    = 0.0f;
                    m_anchor_target = 0.0f;
                    if ((layout.width() > m_width) && (m_characters.size() > m_center_justify_start))
                    {
                        // at least some text is not left-justified
                        if (m_right_justify_start == m_center_justify_start)
                        {
                            // all text that isn't left-justified is right-justified
                            float right_offset = layout.width() - m_width;
                            for (size_t i = m_right_justify_start; m_characters.size() > i; ++i)
                            {
                                m_characters[i] = new positioned_char()
                                {
                                    character = m_characters[i].character, style = m_characters[i].style, source = m_characters[i].source, xoffset = m_characters[i].xoffset + right_offset, xwidth = m_characters[i].xwidth
                                }
                            }
                            ;                                                                                                                                                                                                                                          //m_characters[i].xoffset += right_offset;

                            m_width = layout.width();
                        }
                        else if (m_characters.size() <= m_right_justify_start)
                        {
                            // all text that isn't left-justified is center-justified
                            float center_width  = m_width - m_characters[m_center_justify_start].xoffset;
                            float center_offset = ((layout.width() - center_width) * 0.5f) - m_characters[m_center_justify_start].xoffset;
                            if (0.0f < center_offset)
                            {
                                for (size_t i = m_center_justify_start; m_characters.size() > i; ++i)
                                {
                                    m_characters[i] = new positioned_char()
                                    {
                                        character = m_characters[i].character, style = m_characters[i].style, source = m_characters[i].source, xoffset = m_characters[i].xoffset + center_offset, xwidth = m_characters[i].xwidth
                                    }
                                }
                                ;                                                                                                                                                                                                                                           //m_characters[i].xoffset += center_offset;

                                m_width += center_offset;
                            }
                        }
                        else
                        {
                            // left, right and center-justified parts
                            float center_width  = m_characters[m_right_justify_start].xoffset - m_characters[m_center_justify_start].xoffset;
                            float center_offset = ((layout.width() - center_width) * 0.5f) - m_characters[m_center_justify_start].xoffset;
                            float right_offset  = layout.width() - m_width;
                            if (center_offset > right_offset)
                            {
                                // right-justified text pushes centre-justified text to the left
                                for (size_t i = m_center_justify_start; m_right_justify_start > i; ++i)
                                {
                                    m_characters[i] = new positioned_char()
                                    {
                                        character = m_characters[i].character, style = m_characters[i].style, source = m_characters[i].source, xoffset = m_characters[i].xoffset + right_offset, xwidth = m_characters[i].xwidth
                                    }
                                }
                                ;                                                                                                                                                                                                                                          //m_characters[i].xoffset += right_offset;
                            }
                            else if (0.0f < center_offset)
                            {
                                // left-justified text doesn't push centre-justified text to the right
                                for (size_t i = m_center_justify_start; m_right_justify_start > i; ++i)
                                {
                                    m_characters[i] = new positioned_char()
                                    {
                                        character = m_characters[i].character, style = m_characters[i].style, source = m_characters[i].source, xoffset = m_characters[i].xoffset + center_offset, xwidth = m_characters[i].xwidth
                                    }
                                }
                                ;                                                                                                                                                                                                                                           //m_characters[i].xoffset += center_offset;
                            }

                            for (size_t i = m_right_justify_start; m_characters.size() > i; ++i)
                            {
                                m_characters[i] = new positioned_char()
                                {
                                    character = m_characters[i].character, style = m_characters[i].style, source = m_characters[i].source, xoffset = m_characters[i].xoffset + right_offset, xwidth = m_characters[i].xwidth
                                }
                            }
                            ;                                                                                                                                                                                                                                          //m_characters[i].xoffset += right_offset;

                            m_width = layout.width();
                        }
                    }
                }
                else if (m_characters.size() <= m_right_justify_start)
                {
                    // all text is center-justified - anchor to center
                    m_anchor_pos    = 0.5f;
                    m_anchor_target = 0.5f;
                }
                else
                {
                    // at least some text is right-justified - anchor to right
                    m_anchor_pos    = 1.0f;
                    m_anchor_target = 1.0f;
                    if ((layout.width() > m_width) && (m_right_justify_start > m_center_justify_start))
                    {
                        // mixed center-justified and right-justified text
                        float center_width  = m_characters[m_right_justify_start].xoffset;
                        float center_offset = (layout.width() - m_width + (center_width * 0.5f)) - (layout.width() * 0.5f);
                        if (0.0f < center_offset)
                        {
                            for (size_t i = m_right_justify_start; m_characters.size() > i; ++i)
                            {
                                m_characters[i] = new positioned_char()
                                {
                                    character = m_characters[i].character, style = m_characters[i].style, source = m_characters[i].source, xoffset = m_characters[i].xoffset + center_offset, xwidth = m_characters[i].xwidth
                                }
                            }
                            ;                                                                                                                                                                                                                                           //m_characters[i].xoffset += center_offset;

                            m_width += center_offset;
                        }
                    }
                }
            }
예제 #8
0
        //virtual ~menu_textbox() override;


        //void reset_layout();
        //void handle_key(int key);

        protected abstract void populate_text(text_layout layout, float width, int lines);