Back to index

nux  3.0.0
FloatingWindow.h
Go to the documentation of this file.
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 "Layout.h"
00032 #include "HLayout.h"
00033 #include "VLayout.h"
00034 #include "Validator.h"
00035 #include "StaticTextBox.h"
00036 
00037 namespace nux
00038 {
00039 
00040   class HLayout;
00041   class PopUpWindow;
00042 
00043   class FloatingWindow: public BaseWindow
00044   {
00045     NUX_DECLARE_OBJECT_TYPE(FloatingWindow, BaseWindow);
00046   public:
00047     FloatingWindow(const char *WindowName = "", NUX_FILE_LINE_PROTO);
00048     ~FloatingWindow();
00049 
00050     void SetVisibleSizeGrip(bool b)
00051     {
00052       if (b && (m_bSizeMatchLayout))
00053         m_bIsVisibleSizeGrip = false;
00054       else
00055         m_bIsVisibleSizeGrip = b;
00056     }
00057 
00058     bool IsVisibleSizeGrip()
00059     {
00060       return m_bIsVisibleSizeGrip;
00061     }
00062 
00063 
00064     void EnableTitleBar(bool b);
00065     bool HasTitleBar() const;
00066     void OnSizeGrigMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
00067     void OnSizeGrigMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
00068     void RecvCloseButtonClick(int x, int y, unsigned long button_flags, unsigned long key_flags);
00069 
00070     void RecvTitleBarMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
00071     void RecvTitleBarMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
00072 
00073     void SetWindowTitle(const char *title);
00074     NString GetWindowTitle();
00075 
00077     /*
00078         Return true if this object can break the layout, meaning, the layout can be done on the composition layout only without
00079         recomputing the whole window layout.
00080         Inherited from View
00081     */
00082     virtual bool CanBreakLayout()
00083     {
00084       if (IsSizeMatchContent())
00085         return false;
00086 
00087       return true;
00088     }
00089 
00090   protected:
00091     virtual Area* FindAreaUnderMouse(const Point& mouse_position, NuxEventType event_type);
00092     virtual void Draw(GraphicsEngine &graphics_engine, bool force_draw);
00093     virtual void DrawContent(GraphicsEngine &graphics_engine, bool force_draw);
00094     virtual void PostDraw(GraphicsEngine &graphics_engine, bool force_draw);
00095 
00096     virtual void PreLayoutManagement();
00097     virtual long PostLayoutManagement(long LayoutResult);
00098     virtual void ComputeContentPosition(float offsetX, float offsetY);
00099 
00101 
00105     virtual void LayoutWindowElements();
00106 
00107     int m_SizeGripDragPositionX;
00108     int m_SizeGripDragPositionY;
00109 
00110   private:
00111     int _resize_handle_width;
00112     int _resize_handle_height;
00113     int _title_bar_height;
00114 
00115     InputArea *_resize_handle;
00116     InputArea *_title_bar;
00117     Point _title_bar_mouse_down_location;
00118 
00119     InputArea *_minimize_button;
00120     InputArea *_close_button;
00121     StaticTextBox *_window_title_bar;
00122     bool m_hasTitleBar;
00123 
00124     bool m_bIsVisible;
00125     bool m_bIsVisibleSizeGrip;
00126     bool m_bIsModal;
00128     bool m_bSizeMatchLayout;
00129 
00130 
00131     BaseTexture* CloseIcon;
00132     BaseTexture* MinimizeIcon;
00133 
00134     std::list<View *> m_InterfaceObject;
00135     HLayout *_title_bar_layout;
00136 
00137     NString _window_title;
00138 
00139     friend class PopUpWindow;
00140     friend class ComboBox_Logic_WindowView;
00141     friend class ComboBoxComplex;
00142     friend class WindowCompositor;
00143   };
00144 }
00145 
00146 #endif // FLOATINGWINDOW_H