nux-0.9.48

Nux/BaseWindow.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 BASEWINDOW_H
00024 #define BASEWINDOW_H
00025 
00026 #include "ScrollView.h"
00027 
00028 #if defined(NUX_OS_WINDOWS)
00029 #include "NuxGraphics/Events.h"
00030 #elif defined(NUX_OS_LINUX)
00031 #include "NuxGraphics/Events.h"
00032 #include "NuxGraphics/XInputWindow.h"
00033 #endif
00034 
00035 #include "InputArea.h"
00036 #include "MouseHandler.h"
00037 #include "StaticTextBox.h"
00038 #include "PaintLayer.h"
00039 
00040 namespace nux
00041 {
00042 
00043   class BaseWindow;
00044   typedef BaseWindow ViewWindow;
00045 
00046   class HLayout;
00047   class PopUpWindow;
00048 
00049   //typedef TopView BaseWindow;
00050 
00060   typedef void (*ConfigureNotifyCallback) (int, int, Geometry &, void *);
00061 
00066   class BaseWindow: public View
00067   {
00068     NUX_DECLARE_OBJECT_TYPE (BaseWindow, View);
00069   public:
00070     BaseWindow (const TCHAR *WindowName = TEXT (""), NUX_FILE_LINE_PROTO);
00071     virtual ~BaseWindow();
00072 
00073     virtual long ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
00074     virtual void Draw (GraphicsEngine &GfxContext, bool force_draw);
00075     virtual void DrawContent (GraphicsEngine &GfxContext, bool force_draw);
00076     virtual void PostDraw (GraphicsEngine &GfxContext, bool force_draw);
00077 
00078     void AddWidget (View *ic);
00079     void AddWidget (View *ic, int stretchfactor);
00080     void AddWidget (std::list<View *> *ViewList);
00081     
00082     virtual Layout* GetLayout();
00083     virtual bool SetLayout(Layout *layout);
00084 
00086 
00089     void PushHigher (BaseWindow* floating_view);
00090 
00092 
00095     void PushLower (BaseWindow* floating_view);
00096 
00098 
00104     void PushToFront ();
00105       
00107 
00110     void PushToBack ();
00111 
00113 
00119     virtual void SetWindowSizeMatchLayout (bool b)
00120     {
00121       _size_match_layout = b;
00122     }
00124 
00128     bool IsSizeMatchContent() const
00129     {
00130       return _size_match_layout;
00131     }
00132 
00133     virtual void ShowWindow (bool b, bool StartModal = false);
00134     void StopModal ();
00135     bool IsModal () const;
00136     bool IsVisible () const;
00137 
00138     virtual void SetGeometry (const Geometry &geo);
00139 
00146     void SetConfigureNotifyCallback (ConfigureNotifyCallback Callback, void *Data);
00147 
00148     void SetBackgroundLayer (AbstractPaintLayer *layer);
00149     void SetBackgroundColor (const Color &color);
00150 
00151     void  SetOpacity (float opacity);
00152     float GetOpacity ();
00153 
00154     #if defined(NUX_OS_LINUX)
00155     void EnableInputWindow (bool        b,
00156                             const char* title = "nux input window",
00157                             bool        take_focus = False,
00158                             bool        override_redirect = False);
00159     bool InputWindowEnabled ();
00160     void InputWindowEnableStruts (bool enable);
00161     bool InputWindowStrutsEnabled ();
00162     void SetInputFocus ();
00163     Window GetInputWindowId ();
00164     #endif
00165 
00167 
00171     void SetEnterFocusInputArea (InputArea *input_area);
00172 
00173 
00175     void* GetBackupTextureData (int &width, int &height, int &format);
00176 
00178     sigc::signal<void, BaseWindow*> sigVisible;
00180     sigc::signal<void, BaseWindow*> sigHidden;
00181 
00182     NString GetWindowName ()
00183     {
00184       return _name;
00185     }
00186   protected:
00187     
00189     ConfigureNotifyCallback m_configure_notify_callback;
00191     void *m_configure_notify_callback_data;
00192 
00193     //sigc::signal< bool, unsigned int, unsigned int, Geometry & > sigRequestConfigure;
00194 
00195     Layout *m_layout;
00196 
00197     friend class ComboBox_Logic_WindowView;
00198 
00199     virtual void PreLayoutManagement ();
00200     virtual long PostLayoutManagement (long LayoutResult);
00201     virtual void PositionChildLayout (float offsetX, float offsetY);
00203 
00207     virtual void LayoutWindowElements();
00208 
00215     virtual void NotifyConfigurationChange (int Width, int Height);
00216 
00217     int GetBorder() const;
00218     int GetTopBorder() const;
00219     void SetBorder (int border);
00220     void SetTopBorder (int border);
00221     int m_TopBorder;
00222     int m_Border;
00223     AbstractPaintLayer *_paint_layer;
00224 
00225     bool _entering_visible_state;  
00226     bool _entering_hidden_state;   
00227     
00228     bool ChildNeedsRedraw ();
00229 
00230     #if defined(NUX_OS_LINUX)
00231     bool m_input_window_enabled;
00232     XInputWindow *m_input_window;
00233     #endif
00234     
00235   private:
00237     ObjectPtr<BaseTexture> _background_texture;
00238    
00239     NString _name;
00240     bool _size_match_layout;
00241     bool _is_visible;
00242     bool _is_modal;
00243 
00244     InputArea *_enter_focus_input_area;  
00245 
00246     std::list<View *> m_InterfaceObject;
00247 
00248     bool _child_need_redraw;   
00249     float _opacity;
00250 
00251     friend class PopUpWindow;
00252 
00253     friend class WindowThread;
00254     friend class WindowCompositor;
00255   };
00256 
00257 }
00258 
00259 #endif // BASEWINDOW_H