~qcumber-some/widelands/spice-up-cmake

« back to all changes in this revision

Viewing changes to src/ui_basic/textarea.h

  • Committer: Jens Beyer (Qcumber-some)
  • Date: 2010-05-28 14:51:37 UTC
  • mfrom: (5149.1.226 trunk)
  • Revision ID: qcumber-some@buerotiger.de-20100528145137-0pyil9qw7szyztsw
MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
/**
30
30
 * This defines a non responsive (to clicks) text area, where a text
31
 
 * can easily be printed
 
31
 * can easily be printed.
 
32
 *
 
33
 * Textareas can operate in auto-move mode or in layouted mode.
 
34
 *
 
35
 * In auto-move mode, which is selected by constructors that take x/y coordinates
 
36
 * as parameters, the given (x,y) is used as the anchor for the text.
 
37
 * The panel automatically changes its size and position so that the
 
38
 * given (x,y) always stay the anchor point. This is incompatible with
 
39
 * using the Textarea in a layouted situation, e.g. inside \ref Box.
 
40
 *
 
41
 * In layouted mode, which is selected by the constructor that does not
 
42
 * take coordinates, the textarea simply sets its desired size
 
43
 * appropriately for the contained text.
 
44
 *
 
45
 * Finally, there is static mode, which does not change desired or actual
 
46
 * size in any way based on the text.
 
47
 *
 
48
 * A multiline Textarea differs from a \ref Multiline_Textarea in that
 
49
 * the latter provides scrollbars.
32
50
 */
33
51
struct Textarea : public Panel {
 
52
        enum LayoutMode {
 
53
                AutoMove,
 
54
                Layouted,
 
55
                Static
 
56
        };
34
57
 
35
 
        /**
36
 
         * For non-multiline textareas, the dimensions are set automatically,
37
 
         * depending on the text. For multiline textareas, only the height and
38
 
         * vertical position is adjusted automatically. A multiline Textarea differs
39
 
         * from a Multiline_Textarea in that Multiline_Textarea provides scrollbars.
40
 
         */
41
58
        Textarea
42
59
                (Panel * parent,
43
60
                 int32_t x, int32_t y,
44
61
                 std::string const & text = std::string(),
45
62
                 Align align = Align_Left, bool multiline = false);
46
 
 
47
63
        Textarea
48
64
                (Panel * parent,
49
65
                 int32_t x, int32_t y, uint32_t w, uint32_t h,
50
66
                 Align align = Align_Left, bool multiline = false);
51
 
 
52
67
        Textarea
53
68
                (Panel *  const parent,
54
69
                 int32_t x, int32_t y, uint32_t w, uint32_t h,
55
70
                 const std::string & text,
56
71
                 Align align = Align_Left, bool multiline = false);
 
72
        Textarea
 
73
                (Panel * parent,
 
74
                 const std::string & text = std::string(),
 
75
                 Align align = Align_Left, bool multiline = false, uint32_t width = 0);
57
76
 
 
77
        void set_layout_mode(LayoutMode lm);
 
78
        void set_fixed_size(const std::string & text);
58
79
        void set_text(const std::string &);
59
80
        std::string get_text();
60
81
        void set_align(Align);
62
83
        // Drawing and event handlers
63
84
        void draw(RenderTarget &);
64
85
 
65
 
        void set_font(std::string const & name, int32_t size, RGBColor fg) {
66
 
                m_fontname = name;
67
 
                m_fontsize = size;
68
 
                m_fcolor   = fg;
69
 
                set_text(m_text);
70
 
        }
 
86
        void set_font(std::string const & name, int32_t size, RGBColor fg);
 
87
 
 
88
protected:
 
89
        virtual void update_desired_size();
71
90
 
72
91
private:
73
92
        void collapse();
74
93
        void expand();
75
94
 
 
95
        LayoutMode m_layoutmode;
76
96
        std::string m_text;
77
97
        Align       m_align;
78
98
        bool        m_multiline;