Back to index

nux  3.0.0
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 
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 "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 char *WindowName = "", NUX_FILE_LINE_PROTO);
00071     virtual ~BaseWindow();
00072 
00073     nux::Property<bool> premultiply;
00074 
00075     virtual Area* FindAreaUnderMouse(const Point& mouse_position, NuxEventType event_type);
00076     virtual void Draw(GraphicsEngine &graphics_engine, bool force_draw);
00077     virtual void DrawContent(GraphicsEngine &graphics_engine, bool force_draw);
00078     virtual void PostDraw(GraphicsEngine &graphics_engine, bool force_draw);
00079 
00080     virtual Layout* GetLayout();
00081     virtual bool SetLayout(Layout *layout);
00082 
00084 
00087     void PushHigher(BaseWindow* floating_view);
00088 
00090 
00093     void PushLower(BaseWindow* floating_view);
00094 
00096 
00102     void PushToFront();
00103 
00105 
00108     void PushToBack();
00109 
00111 
00117     virtual void SetWindowSizeMatchLayout(bool b)
00118     {
00119       _size_match_layout = b;
00120     }
00122 
00126     bool IsSizeMatchContent() const
00127     {
00128       return _size_match_layout;
00129     }
00130 
00131     virtual void ShowWindow(bool b, bool StartModal = false);
00132     void StopModal();
00133     bool IsModal() const;
00134     bool IsVisible() const;
00135 
00136     virtual void SetGeometry(const Geometry &geo);
00137 
00144     void SetConfigureNotifyCallback(ConfigureNotifyCallback Callback, void *Data);
00145 
00146     void SetBackgroundLayer(AbstractPaintLayer *layer);
00147     void SetBackgroundColor(const Color &color);
00148 
00149     void  SetOpacity(float opacity);
00150     float GetOpacity();
00151 
00152     #if defined(NUX_OS_LINUX)
00153     void EnableInputWindow(bool        b,
00154                             const char* title = "nux input window",
00155                             bool        take_focus = False,
00156                             bool        override_redirect = False);
00157     bool InputWindowEnabled();
00158 
00159     void InputWindowEnableStruts(bool enable);
00160     bool InputWindowStrutsEnabled();
00161 
00162     void InputWindowEnableOverlayStruts(bool enable);
00163     bool InputWindowOverlayStrutsEnabled();
00164 
00165     void SetInputFocus();
00166     Window GetInputWindowId();
00167     #endif
00168 
00170 
00174     void SetEnterFocusInputArea(InputArea *input_area);
00175 
00176 
00178     void* GetBackupTextureData(int &width, int &height, int &format);
00179 
00181     sigc::signal<void, BaseWindow*> sigVisible;
00183     sigc::signal<void, BaseWindow*> sigHidden;
00184 
00185     NString GetWindowName()
00186     {
00187       return _name;
00188     }
00189   protected:
00190 
00191     void SetAcceptKeyNavFocus(bool accept);
00192     bool accept_key_nav_focus_;
00193     virtual bool AcceptKeyNavFocus();
00194 
00196     ConfigureNotifyCallback m_configure_notify_callback;
00198     void *m_configure_notify_callback_data;
00199 
00200     //sigc::signal< bool, unsigned int, unsigned int, Geometry & > sigRequestConfigure;
00201 
00202     Layout *m_layout;
00203 
00204     friend class ComboBox_Logic_WindowView;
00205 
00206     virtual void PreLayoutManagement();
00207     virtual long PostLayoutManagement(long LayoutResult);
00208     virtual void ComputeContentPosition(float offsetX, float offsetY);
00210 
00214     virtual void LayoutWindowElements();
00215 
00222     virtual void NotifyConfigurationChange(int Width, int Height);
00223 
00224     int GetBorder() const;
00225     int GetTopBorder() const;
00226     void SetBorder(int border);
00227     void SetTopBorder(int border);
00228     int m_TopBorder;
00229     int m_Border;
00230     boost::scoped_ptr<AbstractPaintLayer> _paint_layer;
00231 
00232     bool _entering_visible_state;  
00233     bool _entering_hidden_state;   
00234 
00235     bool ChildNeedsRedraw();
00236 
00237     #if defined(NUX_OS_LINUX)
00238     bool m_input_window_enabled;
00239     XInputWindow *m_input_window;
00240     #endif
00241 
00242   private:
00244     ObjectPtr<BaseTexture> _background_texture;
00245 
00246     NString _name;
00247     bool _size_match_layout;
00248     bool _is_visible;
00249     bool _is_modal;
00250 
00251     InputArea *_enter_focus_input_area;  
00252 
00253     std::list<View *> m_InterfaceObject;
00254 
00255     bool _child_need_redraw;   
00256     float _opacity;
00257 
00258     friend class PopUpWindow;
00259 
00260     friend class WindowThread;
00261     friend class WindowCompositor;
00262   };
00263 
00264 }
00265 
00266 #endif // BASEWINDOW_H