nux-0.9.48
|
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 00052 virtual long ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo); 00053 virtual void Draw (GraphicsEngine &GfxContext, bool force_draw); 00054 virtual void DrawContent (GraphicsEngine &GfxContext, bool force_draw); 00055 virtual void PostDraw (GraphicsEngine &GfxContext, bool force_draw); 00056 00057 void SetVisibleSizeGrip (bool b) 00058 { 00059 if (b && (m_bSizeMatchLayout) ) 00060 m_bIsVisibleSizeGrip = false; 00061 else 00062 m_bIsVisibleSizeGrip = b; 00063 } 00064 00065 bool IsVisibleSizeGrip() 00066 { 00067 return m_bIsVisibleSizeGrip; 00068 } 00069 00070 00071 void EnableTitleBar (bool b); 00072 bool HasTitleBar() const; 00073 void OnSizeGrigMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags); 00074 void OnSizeGrigMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); 00075 void RecvCloseButtonClick (int x, int y, unsigned long button_flags, unsigned long key_flags); 00076 00077 void RecvTitleBarMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags); 00078 void RecvTitleBarMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); 00079 00080 void SetWindowTitle (const char *title); 00081 NString GetWindowTitle(); 00082 00084 /* 00085 Return true if this object can break the layout, meaning, the layout can be done on the composition layout only without 00086 recomputing the whole window layout. 00087 Inherited from View 00088 */ 00089 virtual bool CanBreakLayout() 00090 { 00091 if (IsSizeMatchContent() ) 00092 return false; 00093 00094 return true; 00095 } 00096 protected: 00097 virtual void PreLayoutManagement(); 00098 virtual long PostLayoutManagement (long LayoutResult); 00099 virtual void PositionChildLayout (float offsetX, float offsetY); 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 WindowCompositor; 00142 }; 00143 00144 } 00145 #endif // FLOATINGWINDOW_H