nux-0.9.46

Nux/ClientArea.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 CLIENTAREA_H
00024 #define CLIENTAREA_H
00025 
00026 #include "InputArea.h"
00027 #include "Painter.h"
00028 #include "View.h"
00029 #include "TimerProc.h"
00030 
00031 namespace nux
00032 {
00033 
00034   class ClientArea;
00035   class TimerFunctor;
00036   class TimerHandle;
00037 
00038   struct ClientAreaDraw
00039   {
00040     ClientArea *clientarea;
00041     Geometry clipgeometry;
00042   };
00043 
00044   class ClientArea: public View
00045   {
00046   public:
00047     ClientArea (NUX_FILE_LINE_PROTO);
00048     ~ClientArea();
00049 
00050     virtual void BeginDraw (GraphicsEngine &GfxContext, bool force_draw);
00051     virtual void Draw (GraphicsEngine &GfxContext, bool force_draw);
00052     virtual void DrawContent (GraphicsEngine &GfxContext, bool force_draw);
00053     virtual void PostDraw (GraphicsEngine &GfxContext, bool force_draw);
00054     virtual long ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
00055     virtual void NeedRedraw();
00056 
00057     void EnableClientDraw (bool b)
00058     {
00059       m_IsClientAreaEnabled = b;
00060     };
00061     bool IsClientDrawEnabled() const
00062     {
00063       return m_IsClientAreaEnabled;
00064     };
00065 
00066     virtual void ClientDraw (GraphicsEngine &GfxContext, DrawAreaContext &ctx, bool force_draw);
00067     virtual void RecvMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags);
00068     virtual void RecvMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags);
00069     virtual void RecvMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
00070     virtual void RecvMouseMove (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
00071     virtual void RecvKeyEvent (
00072       GraphicsEngine &    ,   /*Graphics Context for text operation*/
00073       unsigned long       ,   /*event type*/
00074       unsigned long       ,   /*event keysym*/
00075       unsigned long       ,   /*event state*/
00076       const TCHAR*        ,   /*character*/
00077       unsigned short          /*key repeat count*/
00078     );
00079 
00080     sigc::signal<void, DrawAreaContext, bool> sigClientDraw;
00081     void SetClientViewport (GraphicsEngine &GfxContext);
00082     void Setup2DMode (GraphicsEngine &GfxContext);
00083 
00084     // Before the client start drawing we set up a framebuffer object. We don't want the client to start messing
00085     // up the whole rendering by. If we setup a framebuffer instead, the client can never know the framebuffer
00086     // we use fror the whole rendering. all we have to do is to copy the client framebuffer into the main framebuffer
00087     // after the client as finished with the draw.
00088     ObjectPtr<IOpenGLFrameBufferObject>& GetWindowFrameBufferObject()
00089     {
00090       return m_FrameBufferObject;
00091     }
00092     ObjectPtr<IOpenGLFrameBufferObject> m_FrameBufferObject;
00093 
00094   private:
00095     // We use Rectangle texture to attach to the framebuffer because some GPU like the Geforce FX 5600 do not
00096     // have support for ARB_texture_non_power_of_two. However it does support ARB_texture_recatangle.
00097     ObjectPtr<IOpenGLBaseTexture> m_MainColorRT;
00098     ObjectPtr<IOpenGLBaseTexture> m_MainDepthRT;
00099 
00100     DrawAreaContext m_ctx;
00101     bool m_IsClientAreaEnabled;
00102   };
00103 
00104 
00105 }
00106 
00107 #endif // CLIENTAREA_H