~hikiko/nux/arb-srgba-shader

« back to all changes in this revision

Viewing changes to Nux/TextView/TextViewWidget.h

  • Committer: Neil Jagdish Patel
  • Date: 2010-09-02 03:28:11 UTC
  • Revision ID: neil.patel@canonical.com-20100902032811-i2m18tfb6pkasnvt
Remove Win EOL chars

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 */
21
21
 
22
22
 
23
 
#ifndef TEXTVIEWWIDGET_H
24
 
#define TEXTVIEWWIDGET_H
25
 
 
26
 
#include "../InterfaceControl.h"
27
 
 
28
 
NAMESPACE_BEGIN_GUI
29
 
 
30
 
class HScrollBar;
31
 
class VScrollBar;
32
 
 
33
 
// Rename it to ScrollArea or ScrollWindow
34
 
class TextViewWidget: public ActiveInterfaceObject
35
 
{
36
 
public:
37
 
    TextViewWidget();
38
 
    virtual ~TextViewWidget();
39
 
 
40
 
    virtual long ProcessEvent(IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
41
 
    virtual void Draw(GraphicsContext& GfxContext, bool force_draw);
42
 
    virtual void DrawContent(GraphicsContext& GfxContext, bool force_draw);
43
 
    virtual void PostDraw(GraphicsContext& GfxContext, bool force_draw) {};
44
 
 
45
 
    // API
46
 
    void EnableVerticalScrollBar(bool b);
47
 
    void EnableHorizontalScrollBar(bool b);
48
 
 
49
 
public:
50
 
    //! Set the table size to be constrained by the size content.
51
 
    /*!
52
 
    Set the table size to be such that all the content items of the table are visible .
53
 
    The scrollbar will be useless as the content is entirely visible all the time. If the table is empty, then it assume its minimum size.
54
 
    This is needed for table inside ComboBox drop down memu.
55
 
    @param b If b is true, the size of the table is constrained by its content.
56
 
    @see IsSizeMatchLayout()
57
 
    */
58
 
    void SetSizeMatchContent(bool b);
59
 
 
60
 
    //! Check if the table size is constrained by the content of the table.
61
 
    /*!
62
 
    Check if the table size is constrained by its content.
63
 
    @return If the return value is true, the table size is constrained by its content.
64
 
    @see SetSizeMatchContent
65
 
    */
66
 
    bool IsSizeMatchContent() const;
67
 
 
68
 
    //    bool SetMaxSizeMatchLayout(Size size) 
69
 
    //    {
70
 
    //        m_MaxSizeMatchLayout = size;
71
 
    //        if(m_MaxSizeMatchLayout.GetWidth() < 0)
72
 
    //            m_MaxSizeMatchLayout.SetWidth(0);
73
 
    //        if(m_MaxSizeMatchLayout.GetBaseHeight() < 0)
74
 
    //            m_MaxSizeMatchLayout.SetHeight(0);
75
 
    //    }
76
 
 
77
 
private:
78
 
    bool m_bSizeMatchContent;
79
 
 
80
 
public:
81
 
    // Inherited from BaseObject
82
 
    virtual void setGeometry(const Geometry& geo);
83
 
 
84
 
    /////////////////
85
 
    //  EMITERS    //
86
 
    /////////////////
87
 
    void OnSizeGrigMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
88
 
    void OnSizeGrigMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
89
 
    void EmitMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
90
 
    //void EmitInternalResize(int x, int y, int w, int h);
91
 
 
92
 
 
93
 
    /////////////////
94
 
    //  RECEIVERS  //
95
 
    /////////////////
96
 
//     virtual void ScrollLeft(float stepx, int mousedx);
97
 
//     virtual void ScrollRight(float stepx, int mousedx);
98
 
//     virtual void ScrollUp(float stepy, int mousedy);
99
 
//     virtual void ScrollDown(float stepy, int mousedy);
100
 
 
101
 
    virtual void ResetScrollToLeft();
102
 
    virtual void ResetScrollToRight();
103
 
    virtual void ResetScrollToUp();
104
 
    virtual void ResetScrollToDown();
105
 
 
106
 
    int m_ContentOffsetX;
107
 
    int m_ContentOffsetY;
108
 
 
109
 
    // Geometry of the layout that encompass the child layouts.
110
 
    int m_ViewContentX;
111
 
    int m_ViewContentY;
112
 
    int m_ViewContentWidth;
113
 
    int m_ViewContentHeight;
114
 
 
115
 
    //Client View Area
116
 
    int m_ViewX;
117
 
    int m_ViewY;
118
 
    int m_ViewWidth;
119
 
    int m_ViewHeight;
120
 
    Geometry m_ViewGeometry;
121
 
    Geometry m_ContentGeometry;
122
 
 
123
 
    // signals
124
 
    sigc::signal<void> SigTest;
125
 
    sigc::signal<void> sigMoveWindow;
126
 
    sigc::signal<void, int, int, int, int> sigResize;
127
 
 
128
 
protected:
129
 
    //SmartPtrGLTexture m_BackgroundTexture;
130
 
 
131
 
    // Backup texture to speed up scrolling
132
 
    TRefGL<IOpenGLFrameBufferObject> m_FrameBufferObject;
133
 
    TRefGL<IOpenGLTexture2D> m_TextureBuffer[2];
134
 
    void SwapTextureIndex() {m_TextureIndex = (m_TextureIndex == 0)? 1 : 0;}
135
 
    void SetTextureIndex(int index) {m_TextureIndex = index;}
136
 
    int GetTextureIndex() {return m_TextureIndex;}
137
 
    int m_TextureIndex;
138
 
    bool m_ReformatTexture;
139
 
 
140
 
 
141
 
    // ScrollBars
142
 
    HScrollBar *hscrollbar;
143
 
    VScrollBar *vscrollbar;
144
 
    bool m_horizontal_scrollbar_enable;
145
 
    bool m_vertical_scrollbar_enable;
146
 
 
147
 
    int m_SizeGripDragPositionX; //<<<--- remove this
148
 
    int m_SizeGripDragPositionY;
149
 
 
150
 
    //int viewx;
151
 
    // Internal function
152
 
    int getBorder() const;
153
 
    int getTopBorder() const;
154
 
    void setBorder(int border);
155
 
    void setTopBorder(int top_border);
156
 
 
157
 
    int m_top_border;
158
 
    int m_border;
159
 
 
160
 
public:
161
 
    void    SetViewContentLeftMargin(int margin)    { m_ViewContentLeftMargin = margin; }
162
 
    int     GetViewContentLeftMargin() const        { return m_ViewContentLeftMargin; }
163
 
    void    SetViewContentRightMargin(int margin)   { m_ViewContentRightMargin = margin; }
164
 
    int     GetViewContentRightMargin() const       { return m_ViewContentRightMargin; }
165
 
    void    SetViewContentTopMargin(int margin)     { m_ViewContentTopMargin = margin; }
166
 
    int     GetViewContentTopMargin() const         { return m_ViewContentTopMargin; }
167
 
    void    SetViewContentBottomMargin(int margin)  { m_ViewContentBottomMargin = margin; }
168
 
    int     GetViewContentBottomMargin() const      { return m_ViewContentBottomMargin; }
169
 
private:
170
 
    int m_ViewContentLeftMargin;
171
 
    int m_ViewContentRightMargin;
172
 
    int m_ViewContentTopMargin;
173
 
    int m_ViewContentBottomMargin;
174
 
 
175
 
protected:
176
 
    void FormatContent();
177
 
    virtual void PreLayoutManagement();
178
 
    virtual long PostLayoutManagement(long LayoutResult);
179
 
    virtual void PositionChildLayout(float offsetX, float offsetY);
180
 
 
181
 
    virtual void PreLayoutManagement2();
182
 
    virtual long PostLayoutManagement2(long LayoutResult);
183
 
 
184
 
public:
185
 
    NFontPtr m_TextFont;
186
 
 
187
 
    ///////////////////////////////////////////////////////
188
 
    // AbstractInterfaceObject
189
 
    ///////////////////////////////////////////////////////
190
 
};
191
 
 
192
 
NAMESPACE_END_GUI
193
 
 
194
 
#endif // TEXTVIEWWIDGET_H
 
23
#ifndef TEXTVIEWWIDGET_H
 
24
#define TEXTVIEWWIDGET_H
 
25
 
 
26
#include "../InterfaceControl.h"
 
27
 
 
28
NAMESPACE_BEGIN_GUI
 
29
 
 
30
class HScrollBar;
 
31
class VScrollBar;
 
32
 
 
33
// Rename it to ScrollArea or ScrollWindow
 
34
class TextViewWidget: public ActiveInterfaceObject
 
35
{
 
36
public:
 
37
    TextViewWidget();
 
38
    virtual ~TextViewWidget();
 
39
 
 
40
    virtual long ProcessEvent(IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
 
41
    virtual void Draw(GraphicsContext& GfxContext, bool force_draw);
 
42
    virtual void DrawContent(GraphicsContext& GfxContext, bool force_draw);
 
43
    virtual void PostDraw(GraphicsContext& GfxContext, bool force_draw) {};
 
44
 
 
45
    // API
 
46
    void EnableVerticalScrollBar(bool b);
 
47
    void EnableHorizontalScrollBar(bool b);
 
48
 
 
49
public:
 
50
    //! Set the table size to be constrained by the size content.
 
51
    /*!
 
52
    Set the table size to be such that all the content items of the table are visible .
 
53
    The scrollbar will be useless as the content is entirely visible all the time. If the table is empty, then it assume its minimum size.
 
54
    This is needed for table inside ComboBox drop down memu.
 
55
    @param b If b is true, the size of the table is constrained by its content.
 
56
    @see IsSizeMatchLayout()
 
57
    */
 
58
    void SetSizeMatchContent(bool b);
 
59
 
 
60
    //! Check if the table size is constrained by the content of the table.
 
61
    /*!
 
62
    Check if the table size is constrained by its content.
 
63
    @return If the return value is true, the table size is constrained by its content.
 
64
    @see SetSizeMatchContent
 
65
    */
 
66
    bool IsSizeMatchContent() const;
 
67
 
 
68
    //    bool SetMaxSizeMatchLayout(Size size) 
 
69
    //    {
 
70
    //        m_MaxSizeMatchLayout = size;
 
71
    //        if(m_MaxSizeMatchLayout.GetWidth() < 0)
 
72
    //            m_MaxSizeMatchLayout.SetWidth(0);
 
73
    //        if(m_MaxSizeMatchLayout.GetBaseHeight() < 0)
 
74
    //            m_MaxSizeMatchLayout.SetHeight(0);
 
75
    //    }
 
76
 
 
77
private:
 
78
    bool m_bSizeMatchContent;
 
79
 
 
80
public:
 
81
    // Inherited from BaseObject
 
82
    virtual void setGeometry(const Geometry& geo);
 
83
 
 
84
    /////////////////
 
85
    //  EMITERS    //
 
86
    /////////////////
 
87
    void OnSizeGrigMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
 
88
    void OnSizeGrigMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
 
89
    void EmitMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
 
90
    //void EmitInternalResize(int x, int y, int w, int h);
 
91
 
 
92
 
 
93
    /////////////////
 
94
    //  RECEIVERS  //
 
95
    /////////////////
 
96
//     virtual void ScrollLeft(float stepx, int mousedx);
 
97
//     virtual void ScrollRight(float stepx, int mousedx);
 
98
//     virtual void ScrollUp(float stepy, int mousedy);
 
99
//     virtual void ScrollDown(float stepy, int mousedy);
 
100
 
 
101
    virtual void ResetScrollToLeft();
 
102
    virtual void ResetScrollToRight();
 
103
    virtual void ResetScrollToUp();
 
104
    virtual void ResetScrollToDown();
 
105
 
 
106
    int m_ContentOffsetX;
 
107
    int m_ContentOffsetY;
 
108
 
 
109
    // Geometry of the layout that encompass the child layouts.
 
110
    int m_ViewContentX;
 
111
    int m_ViewContentY;
 
112
    int m_ViewContentWidth;
 
113
    int m_ViewContentHeight;
 
114
 
 
115
    //Client View Area
 
116
    int m_ViewX;
 
117
    int m_ViewY;
 
118
    int m_ViewWidth;
 
119
    int m_ViewHeight;
 
120
    Geometry m_ViewGeometry;
 
121
    Geometry m_ContentGeometry;
 
122
 
 
123
    // signals
 
124
    sigc::signal<void> SigTest;
 
125
    sigc::signal<void> sigMoveWindow;
 
126
    sigc::signal<void, int, int, int, int> sigResize;
 
127
 
 
128
protected:
 
129
    //SmartPtrGLTexture m_BackgroundTexture;
 
130
 
 
131
    // Backup texture to speed up scrolling
 
132
    TRefGL<IOpenGLFrameBufferObject> m_FrameBufferObject;
 
133
    TRefGL<IOpenGLTexture2D> m_TextureBuffer[2];
 
134
    void SwapTextureIndex() {m_TextureIndex = (m_TextureIndex == 0)? 1 : 0;}
 
135
    void SetTextureIndex(int index) {m_TextureIndex = index;}
 
136
    int GetTextureIndex() {return m_TextureIndex;}
 
137
    int m_TextureIndex;
 
138
    bool m_ReformatTexture;
 
139
 
 
140
 
 
141
    // ScrollBars
 
142
    HScrollBar *hscrollbar;
 
143
    VScrollBar *vscrollbar;
 
144
    bool m_horizontal_scrollbar_enable;
 
145
    bool m_vertical_scrollbar_enable;
 
146
 
 
147
    int m_SizeGripDragPositionX; //<<<--- remove this
 
148
    int m_SizeGripDragPositionY;
 
149
 
 
150
    //int viewx;
 
151
    // Internal function
 
152
    int getBorder() const;
 
153
    int getTopBorder() const;
 
154
    void setBorder(int border);
 
155
    void setTopBorder(int top_border);
 
156
 
 
157
    int m_top_border;
 
158
    int m_border;
 
159
 
 
160
public:
 
161
    void    SetViewContentLeftMargin(int margin)    { m_ViewContentLeftMargin = margin; }
 
162
    int     GetViewContentLeftMargin() const        { return m_ViewContentLeftMargin; }
 
163
    void    SetViewContentRightMargin(int margin)   { m_ViewContentRightMargin = margin; }
 
164
    int     GetViewContentRightMargin() const       { return m_ViewContentRightMargin; }
 
165
    void    SetViewContentTopMargin(int margin)     { m_ViewContentTopMargin = margin; }
 
166
    int     GetViewContentTopMargin() const         { return m_ViewContentTopMargin; }
 
167
    void    SetViewContentBottomMargin(int margin)  { m_ViewContentBottomMargin = margin; }
 
168
    int     GetViewContentBottomMargin() const      { return m_ViewContentBottomMargin; }
 
169
private:
 
170
    int m_ViewContentLeftMargin;
 
171
    int m_ViewContentRightMargin;
 
172
    int m_ViewContentTopMargin;
 
173
    int m_ViewContentBottomMargin;
 
174
 
 
175
protected:
 
176
    void FormatContent();
 
177
    virtual void PreLayoutManagement();
 
178
    virtual long PostLayoutManagement(long LayoutResult);
 
179
    virtual void PositionChildLayout(float offsetX, float offsetY);
 
180
 
 
181
    virtual void PreLayoutManagement2();
 
182
    virtual long PostLayoutManagement2(long LayoutResult);
 
183
 
 
184
public:
 
185
    NFontPtr m_TextFont;
 
186
 
 
187
    ///////////////////////////////////////////////////////
 
188
    // AbstractInterfaceObject
 
189
    ///////////////////////////////////////////////////////
 
190
};
 
191
 
 
192
NAMESPACE_END_GUI
 
193
 
 
194
#endif // TEXTVIEWWIDGET_H