~ubuntu-branches/ubuntu/oneiric/nux/oneiric

« back to all changes in this revision

Viewing changes to Nux/FloatingWindow.h

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-11-18 19:17:32 UTC
  • Revision ID: james.westby@ubuntu.com-20101118191732-rn35790vekj6o4my
Tags: upstream-0.9.4
ImportĀ upstreamĀ versionĀ 0.9.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2010 Inalogic Inc.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it
 
5
 * under the terms of the GNU Lesser General Public License version 3, as
 
6
 * published by the  Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful, but
 
9
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 
10
 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
 
11
 * PURPOSE.  See the applicable version of the GNU Lesser General Public
 
12
 * License for more details.
 
13
 *
 
14
 * You should have received a copy of both the GNU Lesser General Public
 
15
 * License version 3 along with this program.  If not, see
 
16
 * <http://www.gnu.org/licenses/>
 
17
 *
 
18
 * Authored by: Jay Taoko <jay.taoko_AT_gmail_DOT_com>
 
19
 *
 
20
 */
 
21
 
 
22
 
 
23
#ifndef FLOATINGWINDOW_H
 
24
#define FLOATINGWINDOW_H
 
25
 
 
26
#include "ScrollView.h"
 
27
#include "BaseWindow.h"
 
28
 
 
29
#if defined(NUX_OS_WINDOWS)
 
30
#include "NuxGraphics/Events.h"
 
31
#elif defined(NUX_OS_LINUX)
 
32
#include "NuxGraphics/Events.h"
 
33
#endif
 
34
 
 
35
#include "InputArea.h"
 
36
#include "MouseHandler.h"
 
37
#include "Layout.h"
 
38
#include "HLayout.h"
 
39
#include "VLayout.h"
 
40
#include "Validator.h"
 
41
#include "StaticTextBox.h"
 
42
 
 
43
namespace nux
 
44
{
 
45
 
 
46
  class HLayout;
 
47
  class PopUpWindow;
 
48
 
 
49
  class FloatingWindow: public BaseWindow
 
50
  {
 
51
    NUX_DECLARE_OBJECT_TYPE (FloatingWindow, BaseWindow);
 
52
  public:
 
53
    FloatingWindow (const TCHAR *WindowName = TEXT (""), NUX_FILE_LINE_PROTO);
 
54
    ~FloatingWindow();
 
55
 
 
56
 
 
57
    virtual long ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
 
58
    virtual void Draw (GraphicsEngine &GfxContext, bool force_draw);
 
59
    virtual void DrawContent (GraphicsEngine &GfxContext, bool force_draw);
 
60
    virtual void PostDraw (GraphicsEngine &GfxContext, bool force_draw);
 
61
 
 
62
    void SetVisibleSizeGrip (bool b)
 
63
    {
 
64
      if (b && (m_bSizeMatchLayout) )
 
65
        m_bIsVisibleSizeGrip = false;
 
66
      else
 
67
        m_bIsVisibleSizeGrip = b;
 
68
    }
 
69
 
 
70
    bool IsVisibleSizeGrip()
 
71
    {
 
72
      return m_bIsVisibleSizeGrip;
 
73
    }
 
74
 
 
75
 
 
76
    void EnableTitleBar (bool b);
 
77
    bool HasTitleBar() const;
 
78
    void OnSizeGrigMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags);
 
79
    void OnSizeGrigMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
 
80
    void RecvCloseButtonClick (int x, int y, unsigned long button_flags, unsigned long key_flags);
 
81
 
 
82
    void RecvTitleBarMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags);
 
83
    void RecvTitleBarMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
 
84
 
 
85
    void SetWindowTitle (const char *title);
 
86
    const TCHAR *GetWindowTitle();
 
87
 
 
88
    //! Return true if this object can break the layout.
 
89
    /*
 
90
        Return true if this object can break the layout, meaning, the layout can be done on the composition layout only without
 
91
        recomputing the whole window layout.
 
92
        Inherited from View
 
93
    */
 
94
    virtual bool CanBreakLayout()
 
95
    {
 
96
      if (IsSizeMatchContent() )
 
97
        return false;
 
98
 
 
99
      return true;
 
100
    }
 
101
  protected:
 
102
    virtual void PreLayoutManagement();
 
103
    virtual long PostLayoutManagement (long LayoutResult);
 
104
    virtual void PositionChildLayout (float offsetX, float offsetY);
 
105
    //! Layout the window elements.
 
106
    /*!
 
107
        Layout elements such as button on the title bar, and the resize widget according to the current
 
108
        geometry of the window. Also initiate the computation of the child layout if there is one.
 
109
    */
 
110
    virtual void LayoutWindowElements();
 
111
 
 
112
    int m_SizeGripDragPositionX;
 
113
    int m_SizeGripDragPositionY;
 
114
 
 
115
  private:
 
116
    CoreArea *m_SizeGrip;
 
117
    CoreArea *m_TitleBar;
 
118
    Point m_TitleBarMouseDown;
 
119
 
 
120
    CoreArea *m_MinimizeButton;
 
121
    CoreArea *m_CloseButton;
 
122
    StaticTextBox *m_WindowTitleBar;
 
123
    bool m_hasTitleBar;
 
124
 
 
125
    bool m_bIsVisible;
 
126
    bool m_bIsVisibleSizeGrip;
 
127
    bool m_bIsModal;
 
128
    //! If true then the FloatingWindow is resized to match the size of the layout.
 
129
    bool m_bSizeMatchLayout;
 
130
 
 
131
 
 
132
    BaseTexture* CloseIcon;
 
133
    BaseTexture* MinimizeIcon;
 
134
 
 
135
    std::list<View *> m_InterfaceObject;
 
136
    HLayout *m_TitleBarLayout;
 
137
 
 
138
    TCHAR *m_WindowTitle;
 
139
 
 
140
    friend class PopUpWindow;
 
141
    friend class ComboBox_Logic_WindowView;
 
142
    friend class WindowCompositor;
 
143
  };
 
144
 
 
145
}
 
146
#endif // FLOATINGWINDOW_H