GLSubWindow.h

00001 // -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
00002 /* 
00003  * Copyright (C) 2008 Micha Hersch, EPFL
00004  * RobotCub Consortium, European Commission FP6 Project IST-004370
00005  * email:   micha.hersch@robotcub.org
00006  * website: www.robotcub.org
00007  * Permission is granted to copy, distribute, and/or modify this program
00008  * under the terms of the GNU General Public License, version 2 or any
00009  * later version published by the Free Software Foundation.
00010  *
00011  * A copy of the license can be found at
00012  * http://www.robotcub.org/icub/license/gpl.txt
00013  *
00014  * This program is distributed in the hope that it will be useful, but
00015  * WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
00017  * Public License for more details
00018  */
00019 #ifndef __GLSUBWINDOW_H__
00020 #define __GLSUBWINDOW_H__
00021 
00022 #include <GL/glut.h>
00023 #include <stdio.h>
00024 #include <stdlib.h>
00025 #include <string>
00026 #include <vector>
00027 using namespace std;
00028 
00029 #define GLSW_TITLE_HEIGHT   14
00030 
00031 
00032 class Rect;
00033 typedef Rect *pRect;
00034 class Rect
00035 {
00036 public:
00037   int m_X,
00038       m_Y,
00039       m_Width,
00040       m_Height;
00041 public:
00042   Rect();
00043   Rect(int x, int y, int w, int h);
00044   void Set(int x, int y, int w, int h);
00045   void Copy(pRect rect);
00046   bool IsInside(int px, int py);
00047 };
00048 
00049 class GLSubWindow;
00050 typedef GLSubWindow *pGLSubWindow;
00051 typedef vector<pGLSubWindow> GLSubWindow_List;
00052 
00053 class GLSubWindow
00054 {
00055 public:
00056   pGLSubWindow      m_ParentWindow;
00057   GLSubWindow_List  m_ChildWindows;
00058 
00059   Rect              m_WindowRect;
00060   Rect              m_ClientRect;
00061 
00062   float             m_BackgroundColor[3];
00063   float             m_BackgroundAlpha;
00064 
00065   bool              m_Miminized;
00066 
00067   bool              m_HasFocus;
00068 
00069   string            m_Title;
00070 
00071   bool              m_Move;
00072   int               m_MoveStartX;
00073   int               m_MoveStartY;
00074   int               m_MouseButton;
00075 
00076   bool              m_Resize;
00077   int               m_ResizeStartX;
00078   int               m_ResizeStartY;
00079 
00080 
00081 public:
00082           GLSubWindow(pGLSubWindow parentWindow = NULL);
00083           virtual ~GLSubWindow();
00084 
00085           void  GetAbsoluteRect(pRect rect);
00086 
00087           void  SetSize(int w, int h);
00088           void  SetPos (int x, int y);
00089           void  Minimize(bool state);
00090 
00091           void  RenderWindow();
00092 
00093           void  SetTitle(string title);
00094 
00095   virtual void  Render();
00096 
00097   virtual void  Resize(int w, int h);
00098 
00099   virtual void  OnNormalKey(char key);
00100   virtual void  OnSpecialKey(int key);
00101   virtual int   OnClick(int button, int state, int x, int y);
00102   virtual int   OnDoubleClick(int button, int x, int y);
00103   virtual int   OnMove(int x, int y);
00104 
00105           void  OnWindowNormalKey(char key);
00106           void  OnWindowSpecialKey(int key);
00107           int   OnWindowClick(int button, int state, int x, int y);
00108           int   OnWindowDoubleClick(int button, int x, int y);
00109           int   OnWindowMove(int x, int y);
00110 
00111           int   IsParentMinimized();
00112 };
00113 
00114 #endif
 All Data Structures Functions Variables

Generated on Wed Sep 22 16:51:25 2010 for Body_Schema_Learning by  doxygen 1.6.1