nux-1.14.0
BaseWindow.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 BASEWINDOW_H
00024 #define BASEWINDOW_H
00025 
00026 
00027 #include <boost/scoped_ptr.hpp>
00028 #include "ScrollView.h"
00029 
00030 #if defined(NUX_OS_WINDOWS)
00031 #include "NuxGraphics/Events.h"
00032 #elif defined(NUX_OS_LINUX)
00033 #include "NuxGraphics/Events.h"
00034 #include "NuxGraphics/XInputWindow.h"
00035 #endif
00036 
00037 #include "InputArea.h"
00038 #include "MouseHandler.h"
00039 #include "PaintLayer.h"
00040 
00041 namespace nux
00042 {
00043 
00044   class BaseWindow;
00045   typedef BaseWindow ViewWindow;
00046 
00047   class HLayout;
00048   class PopUpWindow;
00049 
00050   //typedef TopView BaseWindow;
00051 
00061   typedef void (*ConfigureNotifyCallback) (int, int, Geometry &, void *);
00062 
00067   class BaseWindow: public View
00068   {
00069     NUX_DECLARE_OBJECT_TYPE (BaseWindow, View);
00070   public:
00071     BaseWindow (const TCHAR *WindowName = TEXT (""), NUX_FILE_LINE_PROTO);
00072     virtual ~BaseWindow();
00073 
00074     nux::Property<bool> premultiply;
00075 
00076     virtual Area* FindAreaUnderMouse(const Point& mouse_position, NuxEventType event_type);
00077     virtual long ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
00078     virtual void Draw (GraphicsEngine &GfxContext, bool force_draw);
00079     virtual void DrawContent (GraphicsEngine &GfxContext, bool force_draw);
00080     virtual void PostDraw (GraphicsEngine &GfxContext, bool force_draw);
00081 
00082     void AddWidget (View *ic);
00083     void AddWidget (View *ic, int stretchfactor);
00084     void AddWidget (std::list<View *> *ViewList);
00085     
00086     virtual Layout* GetLayout();
00087     virtual bool SetLayout(Layout *layout);
00088 
00090 
00093     void PushHigher (BaseWindow* floating_view);
00094 
00096 
00099     void PushLower (BaseWindow* floating_view);
00100 
00102 
00108     void PushToFront ();
00109       
00111 
00114     void PushToBack ();
00115 
00117 
00123     virtual void SetWindowSizeMatchLayout (bool b)
00124     {
00125       _size_match_layout = b;
00126     }
00128 
00132     bool IsSizeMatchContent() const
00133     {
00134       return _size_match_layout;
00135     }
00136 
00137     virtual void ShowWindow (bool b, bool StartModal = false);
00138     void StopModal ();
00139     bool IsModal () const;
00140     bool IsVisible () const;
00141 
00142     virtual void SetGeometry (const Geometry &geo);
00143 
00150     void SetConfigureNotifyCallback (ConfigureNotifyCallback Callback, void *Data);
00151 
00152     void SetBackgroundLayer (AbstractPaintLayer *layer);
00153     void SetBackgroundColor (const Color &color);
00154 
00155     void  SetOpacity (float opacity);
00156     float GetOpacity ();
00157 
00158     #if defined(NUX_OS_LINUX)
00159     void EnableInputWindow (bool        b,
00160                             const char* title = "nux input window",
00161                             bool        take_focus = False,
00162                             bool        override_redirect = False);
00163     bool InputWindowEnabled ();
00164     void InputWindowEnableStruts (bool enable);
00165     bool InputWindowStrutsEnabled ();
00166     void SetInputFocus ();
00167     Window GetInputWindowId ();
00168     #endif
00169 
00171 
00175     void SetEnterFocusInputArea (InputArea *input_area);
00176 
00177 
00179     void* GetBackupTextureData (int &width, int &height, int &format);
00180 
00182     sigc::signal<void, BaseWindow*> sigVisible;
00184     sigc::signal<void, BaseWindow*> sigHidden;
00185 
00186     NString GetWindowName ()
00187     {
00188       return _name;
00189     }
00190   protected:
00191     
00192     void SetAcceptKeyNavFocus(bool accept);
00193     bool accept_key_nav_focus_;
00194     virtual bool AcceptKeyNavFocus();
00195 
00197     ConfigureNotifyCallback m_configure_notify_callback;
00199     void *m_configure_notify_callback_data;
00200 
00201     //sigc::signal< bool, unsigned int, unsigned int, Geometry & > sigRequestConfigure;
00202 
00203     Layout *m_layout;
00204 
00205     friend class ComboBox_Logic_WindowView;
00206 
00207     virtual void PreLayoutManagement ();
00208     virtual long PostLayoutManagement (long LayoutResult);
00209     virtual void PositionChildLayout (float offsetX, float offsetY);
00211 
00215     virtual void LayoutWindowElements();
00216 
00223     virtual void NotifyConfigurationChange (int Width, int Height);
00224 
00225     int GetBorder() const;
00226     int GetTopBorder() const;
00227     void SetBorder (int border);
00228     void SetTopBorder (int border);
00229     int m_TopBorder;
00230     int m_Border;
00231     boost::scoped_ptr<AbstractPaintLayer> _paint_layer;
00232 
00233     bool _entering_visible_state;  
00234     bool _entering_hidden_state;   
00235     
00236     bool ChildNeedsRedraw ();
00237 
00238     #if defined(NUX_OS_LINUX)
00239     bool m_input_window_enabled;
00240     XInputWindow *m_input_window;
00241     #endif
00242     
00243   private:
00245     ObjectPtr<BaseTexture> _background_texture;
00246    
00247     NString _name;
00248     bool _size_match_layout;
00249     bool _is_visible;
00250     bool _is_modal;
00251 
00252     InputArea *_enter_focus_input_area;  
00253 
00254     std::list<View *> m_InterfaceObject;
00255 
00256     bool _child_need_redraw;   
00257     float _opacity;
00258 
00259     friend class PopUpWindow;
00260 
00261     friend class WindowThread;
00262     friend class WindowCompositor;
00263   };
00264 
00265 }
00266 
00267 #endif // BASEWINDOW_H
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends