nux-1.14.0
FloatingWindow.h
00001 /*
00002  * Copyright 2010 Inalogic® Inc.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License, as
00006  * published by the  Free Software Foundation; either version 2.1 or 3.0
00007  * of the License.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranties of
00011  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00012  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00013  * License for more details.
00014  *
00015  * You should have received a copy of both the GNU Lesser General Public
00016  * License along with this program. If not, see <http://www.gnu.org/licenses/>
00017  *
00018  * Authored by: Jay Taoko <jaytaoko@inalogic.com>
00019  *
00020  */
00021 
00022 
00023 #ifndef FLOATINGWINDOW_H
00024 #define FLOATINGWINDOW_H
00025 
00026 #include "NuxGraphics/Events.h"
00027 
00028 #include "ScrollView.h"
00029 #include "BaseWindow.h"
00030 #include "InputArea.h"
00031 #include "MouseHandler.h"
00032 #include "Layout.h"
00033 #include "HLayout.h"
00034 #include "VLayout.h"
00035 #include "Validator.h"
00036 #include "StaticTextBox.h"
00037 
00038 namespace nux
00039 {
00040 
00041   class HLayout;
00042   class PopUpWindow;
00043 
00044   class FloatingWindow: public BaseWindow
00045   {
00046     NUX_DECLARE_OBJECT_TYPE (FloatingWindow, BaseWindow);
00047   public:
00048     FloatingWindow (const TCHAR *WindowName = TEXT (""), NUX_FILE_LINE_PROTO);
00049     ~FloatingWindow();
00050 
00051     void SetVisibleSizeGrip (bool b)
00052     {
00053       if (b && (m_bSizeMatchLayout) )
00054         m_bIsVisibleSizeGrip = false;
00055       else
00056         m_bIsVisibleSizeGrip = b;
00057     }
00058 
00059     bool IsVisibleSizeGrip()
00060     {
00061       return m_bIsVisibleSizeGrip;
00062     }
00063 
00064 
00065     void EnableTitleBar (bool b);
00066     bool HasTitleBar() const;
00067     void OnSizeGrigMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags);
00068     void OnSizeGrigMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
00069     void RecvCloseButtonClick (int x, int y, unsigned long button_flags, unsigned long key_flags);
00070 
00071     void RecvTitleBarMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags);
00072     void RecvTitleBarMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
00073 
00074     void SetWindowTitle (const char *title);
00075     NString GetWindowTitle();
00076 
00078     /*
00079         Return true if this object can break the layout, meaning, the layout can be done on the composition layout only without
00080         recomputing the whole window layout.
00081         Inherited from View
00082     */
00083     virtual bool CanBreakLayout()
00084     {
00085       if (IsSizeMatchContent() )
00086         return false;
00087 
00088       return true;
00089     }
00090 
00091   protected:
00092     virtual long ProcessEvent(IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
00093     virtual Area* FindAreaUnderMouse(const Point& mouse_position, NuxEventType event_type);
00094     virtual void Draw(GraphicsEngine &GfxContext, bool force_draw);
00095     virtual void DrawContent(GraphicsEngine &GfxContext, bool force_draw);
00096     virtual void PostDraw(GraphicsEngine &GfxContext, bool force_draw);
00097 
00098     virtual void PreLayoutManagement();
00099     virtual long PostLayoutManagement(long LayoutResult);
00100     virtual void PositionChildLayout(float offsetX, float offsetY);
00101 
00103 
00107     virtual void LayoutWindowElements();
00108 
00109     int m_SizeGripDragPositionX;
00110     int m_SizeGripDragPositionY;
00111 
00112   private:
00113     int _resize_handle_width;
00114     int _resize_handle_height;
00115     int _title_bar_height;
00116 
00117     InputArea *_resize_handle;
00118     InputArea *_title_bar;
00119     Point _title_bar_mouse_down_location;
00120 
00121     InputArea *_minimize_button;
00122     InputArea *_close_button;
00123     StaticTextBox *_window_title_bar;
00124     bool m_hasTitleBar;
00125 
00126     bool m_bIsVisible;
00127     bool m_bIsVisibleSizeGrip;
00128     bool m_bIsModal;
00130     bool m_bSizeMatchLayout;
00131 
00132 
00133     BaseTexture* CloseIcon;
00134     BaseTexture* MinimizeIcon;
00135 
00136     std::list<View *> m_InterfaceObject;
00137     HLayout *_title_bar_layout;
00138 
00139     NString _window_title;
00140 
00141     friend class PopUpWindow;
00142     friend class ComboBox_Logic_WindowView;
00143     friend class ComboBoxComplex;
00144     friend class WindowCompositor;
00145   };
00146 }
00147 
00148 #endif // FLOATINGWINDOW_H
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends