]> git.saurik.com Git - wxWidgets.git/commitdiff
Applied patch for multiple file selection, documented.
authorRobert Roebling <robert@roebling.de>
Wed, 1 Dec 1999 14:08:42 +0000 (14:08 +0000)
committerRobert Roebling <robert@roebling.de>
Wed, 1 Dec 1999 14:08:42 +0000 (14:08 +0000)
  Fixed some compilation warnings,
  Minor change to OpenGL code.
  Documented wxImageHandler::GetImageCount() and related.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4784 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

22 files changed:
docs/latex/wx/filedlg.tex
docs/latex/wx/function.tex
docs/latex/wx/image.tex
include/wx/generic/filedlgg.h
samples/help/doc/wxhelp.map
src/generic/filedlgg.cpp
src/gtk/app.cpp
src/gtk/dataobj.cpp
src/gtk/font.cpp
src/gtk/mdi.cpp
src/gtk/minifram.cpp
src/gtk/win_gtk.c
src/gtk1/app.cpp
src/gtk1/dataobj.cpp
src/gtk1/font.cpp
src/gtk1/mdi.cpp
src/gtk1/minifram.cpp
src/gtk1/win_gtk.c
utils/glcanvas/gtk/glcanvas.cpp
utils/glcanvas/samples/cube/Makefile
utils/glcanvas/samples/cube/cube.cpp
utils/glcanvas/samples/penguin/Makefile

index e46490205f47ece8728bf464f625259debb515a2..f6fe6531e1f9607f38ad730753d8ec394f6c9836 100644 (file)
@@ -26,7 +26,7 @@ If path is ``", the current directory will be used. If filename is ``",
 no default filename will be supplied. The wildcard determines what files
 are displayed in the file selector, and file extension supplies a type
 extension for the required filename. Flags may be a combination of wxOPEN,
-wxSAVE, wxOVERWRITE\_PROMPT, wxHIDE\_READONLY, or 0.
+wxSAVE, wxOVERWRITE\_PROMPT, wxHIDE\_READONLY, wxMULTIPLE or 0.
 
 Both the X and Windows versions implement a wildcard filter. Typing a
 filename containing wildcards (*, ?) in the filename text item, and
index e3deb8d61a15a22821669f615f57173e2bb6b46c..f522dc3be33cdedc06b1782e07b21ab4c1688519 100644 (file)
@@ -481,7 +481,7 @@ If path is empty, the current directory will be used. If filename is empty,
 no default filename will be supplied. The wildcard determines what files
 are displayed in the file selector, and file extension supplies a type
 extension for the required filename. Flags may be a combination of wxOPEN,
-wxSAVE, wxOVERWRITE\_PROMPT, wxHIDE\_READONLY, or 0.
+wxSAVE, wxOVERWRITE\_PROMPT, wxHIDE\_READONLY, wxMULTIPLE or 0.
 
 Both the Unix and Windows versions implement a wildcard filter. Typing a
 filename containing wildcards (*, ?) in the filename text item, and
index 8578e0f634b6a323233258a9df819a8ddd1f2d49..bb30df8ff87b383e53450fe3d2c314fa93446692 100644 (file)
@@ -625,6 +625,20 @@ Gets the name of this handler.
 
 Gets the file extension associated with this handler.
 
+\membersection{wxImageHandler::GetImageCount}\label{wximagehandlergetimagecount}
+
+\func{int}{GetImageCount}{\param{wxInputStream\&}{ stream}}
+
+If the image file contains more than one image and the image handler is capable 
+of retrieving these individually, this function will return the number of
+available images.
+
+\docparam{stream}{Opened input stream for reading image file.}
+
+\wxheading{Return value}
+
+Number of available images. For most image handles, this defaults to 1.
+
 \membersection{wxImageHandler::GetType}
 
 \constfunc{long}{GetType}{\void}
@@ -639,16 +653,21 @@ Gets the MIME type associated with this handler.
 
 \membersection{wxImageHandler::LoadFile}\label{wximagehandlerloadfile}
 
-\func{bool}{LoadFile}{\param{wxImage* }{image}, \param{wxInputStream\&}{ stream}}
+\func{bool}{LoadFile}{\param{wxImage* }{image}, \param{wxInputStream\&}{ stream}, \param{bool}{ verbose=TRUE}, \param{int}{ index=0}}
 
-Loads a image from a stream, putting the resulting data into {\it image}.
+Loads a image from a stream, putting the resulting data into {\it image}. If the image file contains
+more than one image and the image handler is capable of retrieving these individually, {\it index}
+indicates which image to read from the stream.
 
 \wxheading{Parameters}
 
 \docparam{image}{The image object which is to be affected by this operation.}
 
-\docparam{stream}{Opened input stream.
-The meaning of {\it stream} is determined by the {\it type} parameter.}
+\docparam{stream}{Opened input stream for reading images.}
+
+\docparam{verbose}{If set to TRUE, errors reported by the image handler will produce wxLogMessages.}
+
+\docparam{index}{The index of the image in the file (starting from zero).}
 
 \wxheading{Return value}
 
@@ -670,7 +689,7 @@ Saves a image in the output stream.
 
 \docparam{image}{The image object which is to be affected by this operation.}
 
-\docparam{stream}{A stream. The meaning of {\it stream} is determined by the {\it type} parameter.}
+\docparam{stream}{An opened stream for writing images.}
 
 \wxheading{Return value}
 
index 59f717de5c66002a6e6ff992b589e7af28595f8b..2fc5b0731900baf5915bd7e2ff37c421ced964bf 100644 (file)
@@ -154,7 +154,11 @@ public:
     wxString GetFilename() const { return m_fileName; }
     wxString GetWildcard() const { return m_wildCard; }
     long GetStyle() const { return m_dialogStyle; }
-    int GetFilterIndex() const { return m_filterIndex ; }
+    int GetFilterIndex() const { return m_filterIndex; }
+    
+    // for multiple file selection
+    void GetPaths(wxArrayString& paths) const;
+    void GetFilenames(wxArrayString& files) const;
 
     void OnSelected( wxListEvent &event );
     void OnActivated( wxListEvent &event );
@@ -195,7 +199,8 @@ enum
     wxSAVE = 2,
     wxOVERWRITE_PROMPT = 4,
     wxHIDE_READONLY = 8,
-    wxFILE_MUST_EXIST = 16
+    wxFILE_MUST_EXIST = 16,
+    wxMULTIPLE = 32
 };
 
 // File selector - backward compatibility
index 3fdaa8f48d230f1adac95b8b591ec6431568de1e..33f7b9d5f202c253151296aef5f49fd1f9042c13 100644 (file)
@@ -5,7 +5,7 @@
 ; First, some wxWindows documentation files:
 ;
 0 wx.html                  ;wxWindows: Help index; additional keywords like overview
-1 wx34.htm#classref           ;  wxWindows Class References
+1 wxwin.htm           ;  wxWindows Class References
 2 wx204.htm#functions         ;  wxWindows Function References; methods
 ;
 ; Some doc++ generated files:
index cd53a8017f2d12d65e69bdb0afde35a6fa7b4825..5a6f3fe32869d95fbededc97359cbd6b15e46405 100644 (file)
@@ -574,6 +574,10 @@ wxFileDialog::wxFileDialog(wxWindow *parent,
 
     m_message = message;
     m_dialogStyle = style;
+    
+    if ((m_dialogStyle & wxMULTIPLE ) && !(m_dialogStyle & wxOPEN))
+        m_dialogStyle &= ~wxMULTIPLE;
+    
     m_dir = defaultDir;
     if (m_dir.IsEmpty())
     {
@@ -657,8 +661,12 @@ wxFileDialog::wxFileDialog(wxWindow *parent,
     staticsizer->Add( m_static, 1 );
     mainsizer->Add( staticsizer, 0, wxEXPAND | wxLEFT|wxRIGHT|wxBOTTOM, 10 );
 
-    m_list = new wxFileCtrl( this, ID_LIST_CTRL, m_dir, firstWild, wxDefaultPosition, wxSize(440,180),
-      wxLC_LIST | wxSUNKEN_BORDER | wxLC_SINGLE_SEL );
+    if (m_dialogStyle & wxMULTIPLE)
+        m_list = new wxFileCtrl( this, ID_LIST_CTRL, m_dir, firstWild, wxDefaultPosition, 
+                                wxSize(440,180), wxLC_LIST | wxSUNKEN_BORDER );
+    else
+        m_list = new wxFileCtrl( this, ID_LIST_CTRL, m_dir, firstWild, wxDefaultPosition, 
+                                wxSize(440,180), wxLC_LIST | wxSUNKEN_BORDER | wxLC_SINGLE_SEL );
     mainsizer->Add( m_list, 1, wxEXPAND | wxLEFT|wxRIGHT, 10 );
 
     wxBoxSizer *textsizer = new wxBoxSizer( wxHORIZONTAL );
@@ -890,6 +898,44 @@ void wxFileDialog::SetPath( const wxString& path )
     }
 }
 
+void wxFileDialog::GetPaths( wxArrayString& paths ) const
+{
+    paths.Empty();
+    paths.Alloc( m_list->GetSelectedItemCount() );
+
+    wxString dir;
+    m_list->GetDir( dir );
+    if (dir != wxT("/")) dir += wxT("/");
+
+    wxListItem item;
+    item.m_mask = wxLIST_MASK_TEXT;
+
+    item.m_itemId = m_list->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
+    while ( item.m_itemId != -1 ) {
+        m_list->GetItem( item );
+        paths.Add( dir + item.m_text );
+        item.m_itemId = m_list->GetNextItem( item.m_itemId + 1,
+            wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
+    }
+}
+
+void wxFileDialog::GetFilenames(wxArrayString& files) const
+{
+    files.Empty();
+    files.Alloc( m_list->GetSelectedItemCount() );
+
+    wxListItem item;
+    item.m_mask = wxLIST_MASK_TEXT;
+
+    item.m_itemId = m_list->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
+    while ( item.m_itemId != -1 ) {
+        m_list->GetItem( item );
+        files.Add( item.m_text );
+        item.m_itemId = m_list->GetNextItem( item.m_itemId + 1,
+            wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
+    }
+}
+
 // ----------------------------------------------------------------------------
 // global functions
 // ----------------------------------------------------------------------------
index 26a9ea36e6d6e023559aee039d0f3761e21ebaa2..e399efa119ee5ea0e3a61c461a2a9b78b679a9aa 100644 (file)
@@ -226,12 +226,25 @@ void wxapp_install_idle_handler()
 {
     wxASSERT_MSG( wxTheApp->m_idleTag == 0, wxT("attempt to install idle handler twice") );
 
-    /* this routine gets called by all event handlers
-       indicating that the idle is over. */
+    /* This routine gets called by all event handlers
+       indicating that the idle is over. It may also
+       get called from other thread for sending events
+       to the main thread (and processing these in
+       idle time). */
+
+#if wxUSE_THREADS
+    if (!wxThread::IsMain())
+        GDK_THREADS_ENTER ();
+#endif
 
     wxTheApp->m_idleTag = gtk_idle_add( wxapp_idle_callback, (gpointer) NULL );
 
     g_isIdle = FALSE;
+    
+#if wxUSE_THREADS
+    if (!wxThread::IsMain())
+        GDK_THREADS_LEAVE ();
+#endif
 }
 
 #if wxUSE_THREADS
index e901b6ea57338cc732503d46303d8e916f278490..bde950fbb6682491d1e4eb13b9ad51600c6397ea 100644 (file)
@@ -204,7 +204,7 @@ size_t wxFileDataObject::GetDataSize() const
     return res + 1;
 }
 
-bool wxFileDataObject::SetData(size_t size, const void *buf)
+bool wxFileDataObject::SetData(size_t WXUNUSED(size), const void *buf)
 {
     // VZ: old format
 #if 0
index 6cd4c22b1cec62195d15b078ba99a8ce70b1c539..a957f4f68ae6fe08227e0e3d5a12a0bc9f42f4e2 100644 (file)
@@ -188,7 +188,7 @@ wxFont::wxFont( const wxString& fontname, const wxFontData& fontdata )
 
     tmp = tn.GetNextToken();                     // pointsize
     long num = wxStrtol (tmp.c_str(), (wxChar **) NULL, 10);
-    M_FONTDATA->m_pointSize = num / 10;
+    M_FONTDATA->m_pointSize = (int)(num / 10);
 
     tn.GetNextToken();                           // x-res
     tn.GetNextToken();                           // y-res
index 8c29530da57164887c71fb0caf8c3b47a0f79815..3fa7de98fd7f1b19ef7b60264db6a99fd57c8821 100644 (file)
@@ -48,7 +48,7 @@ extern wxList wxPendingDelete;
 //-----------------------------------------------------------------------------
 
 static void 
-gtk_mdi_page_change_callback( GtkNotebook *widget,
+gtk_mdi_page_change_callback( GtkNotebook *WXUNUSED(widget),
                               GtkNotebookPage *page,
                              gint WXUNUSED(page_num),
                              wxMDIParentFrame *parent )
index 47acb2a6f0dfff662599e35bc82e86a5ebf22f10..36217adb2a4e1462e28152acfb27824ea606cd00 100644 (file)
@@ -179,7 +179,7 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
                           GDK_BUTTON1_MOTION_MASK),
                       (GdkWindow *) NULL,
                       (GdkCursor *) NULL,
-                      GDK_CURRENT_TIME );
+                      (unsigned int) GDK_CURRENT_TIME );
                      
     win->m_diffX = (int)gdk_event->x;
     win->m_diffY = (int)gdk_event->y;
index 2097a2db33d513361ba7f909c349543839c30f10..164a855b49996ea73f91e8215f98d972147098e1 100644 (file)
@@ -201,7 +201,7 @@ gtk_pizza_new ()
     return GTK_WIDGET (pizza);
 }
 
-void  
+static void  
 gtk_pizza_scroll_set_adjustments (GtkPizza     *pizza,
                                    GtkAdjustment  *hadj,
                                    GtkAdjustment  *vadj)
index 26a9ea36e6d6e023559aee039d0f3761e21ebaa2..e399efa119ee5ea0e3a61c461a2a9b78b679a9aa 100644 (file)
@@ -226,12 +226,25 @@ void wxapp_install_idle_handler()
 {
     wxASSERT_MSG( wxTheApp->m_idleTag == 0, wxT("attempt to install idle handler twice") );
 
-    /* this routine gets called by all event handlers
-       indicating that the idle is over. */
+    /* This routine gets called by all event handlers
+       indicating that the idle is over. It may also
+       get called from other thread for sending events
+       to the main thread (and processing these in
+       idle time). */
+
+#if wxUSE_THREADS
+    if (!wxThread::IsMain())
+        GDK_THREADS_ENTER ();
+#endif
 
     wxTheApp->m_idleTag = gtk_idle_add( wxapp_idle_callback, (gpointer) NULL );
 
     g_isIdle = FALSE;
+    
+#if wxUSE_THREADS
+    if (!wxThread::IsMain())
+        GDK_THREADS_LEAVE ();
+#endif
 }
 
 #if wxUSE_THREADS
index e901b6ea57338cc732503d46303d8e916f278490..bde950fbb6682491d1e4eb13b9ad51600c6397ea 100644 (file)
@@ -204,7 +204,7 @@ size_t wxFileDataObject::GetDataSize() const
     return res + 1;
 }
 
-bool wxFileDataObject::SetData(size_t size, const void *buf)
+bool wxFileDataObject::SetData(size_t WXUNUSED(size), const void *buf)
 {
     // VZ: old format
 #if 0
index 6cd4c22b1cec62195d15b078ba99a8ce70b1c539..a957f4f68ae6fe08227e0e3d5a12a0bc9f42f4e2 100644 (file)
@@ -188,7 +188,7 @@ wxFont::wxFont( const wxString& fontname, const wxFontData& fontdata )
 
     tmp = tn.GetNextToken();                     // pointsize
     long num = wxStrtol (tmp.c_str(), (wxChar **) NULL, 10);
-    M_FONTDATA->m_pointSize = num / 10;
+    M_FONTDATA->m_pointSize = (int)(num / 10);
 
     tn.GetNextToken();                           // x-res
     tn.GetNextToken();                           // y-res
index 8c29530da57164887c71fb0caf8c3b47a0f79815..3fa7de98fd7f1b19ef7b60264db6a99fd57c8821 100644 (file)
@@ -48,7 +48,7 @@ extern wxList wxPendingDelete;
 //-----------------------------------------------------------------------------
 
 static void 
-gtk_mdi_page_change_callback( GtkNotebook *widget,
+gtk_mdi_page_change_callback( GtkNotebook *WXUNUSED(widget),
                               GtkNotebookPage *page,
                              gint WXUNUSED(page_num),
                              wxMDIParentFrame *parent )
index 47acb2a6f0dfff662599e35bc82e86a5ebf22f10..36217adb2a4e1462e28152acfb27824ea606cd00 100644 (file)
@@ -179,7 +179,7 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
                           GDK_BUTTON1_MOTION_MASK),
                       (GdkWindow *) NULL,
                       (GdkCursor *) NULL,
-                      GDK_CURRENT_TIME );
+                      (unsigned int) GDK_CURRENT_TIME );
                      
     win->m_diffX = (int)gdk_event->x;
     win->m_diffY = (int)gdk_event->y;
index 2097a2db33d513361ba7f909c349543839c30f10..164a855b49996ea73f91e8215f98d972147098e1 100644 (file)
@@ -201,7 +201,7 @@ gtk_pizza_new ()
     return GTK_WIDGET (pizza);
 }
 
-void  
+static void  
 gtk_pizza_scroll_set_adjustments (GtkPizza     *pizza,
                                    GtkAdjustment  *hadj,
                                    GtkAdjustment  *vadj)
index 811c0fcb803453ef697a0e527e13b1cce4a56bcd..71d8228192e7daa9dce8a3fb770df4e2c301f55c 100644 (file)
@@ -154,6 +154,26 @@ gtk_glwindow_realized_callback( GtkWidget * WXUNUSED(widget), wxGLCanvas *win )
     return FALSE;
 }
 
+//-----------------------------------------------------------------------------
+// "map" from m_wxwindow
+//-----------------------------------------------------------------------------
+
+static gint
+gtk_glwindow_map_callback( GtkWidget * WXUNUSED(widget), wxGLCanvas *win )
+{
+    if (win->m_glContext/* && win->m_exposed*/)
+    {
+        wxPaintEvent event( win->GetId() );
+        event.SetEventObject( win );
+        win->GetEventHandler()->ProcessEvent( event );
+
+        win->m_exposed = FALSE;
+        win->GetUpdateRegion().Clear();
+    }
+
+    return FALSE;
+}
+
 //-----------------------------------------------------------------------------
 // "expose_event" of m_wxwindow
 //-----------------------------------------------------------------------------
@@ -314,6 +334,9 @@ bool wxGLCanvas::Create( wxWindow *parent,
     gtk_signal_connect( GTK_OBJECT(m_wxwindow), "realize",
                             GTK_SIGNAL_FUNC(gtk_glwindow_realized_callback), (gpointer) this );
 
+    gtk_signal_connect( GTK_OBJECT(m_wxwindow), "map",
+                            GTK_SIGNAL_FUNC(gtk_glwindow_map_callback), (gpointer) this );
+
     gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event",
         GTK_SIGNAL_FUNC(gtk_glwindow_expose_callback), (gpointer)this );
 
index 6e852b2dd482463546428adfb844ced5b088bc91..2b48e8478a8587d97f810faddb4af9717cf49f91 100644 (file)
 # on your system.
 #
 
-CC = g++
+CC = gcc
 
 cube: cube.o glcanvas.o
-       $(CC) -o cube \
-       cube.o glcanvas.o \
-       `wx-config --libs` -lMesaGL -lMesaGLU
+       $(CC) -o cube cube.o glcanvas.o `wx-config --libs` -lMesaGL -lMesaGLU
 
 cube.o: cube.cpp
        $(CC) `wx-config --cflags` -I../../gtk -c cube.cpp
index ccc6834c1f720bb97498189fb5e6cf414573976f..be5d196b336e23e06e8181f1eb09591a007da677 100644 (file)
@@ -76,6 +76,7 @@ void ScanCodeCtrl::OnKeyDown( wxKeyEvent& event )
 /*------------------------------------------------------------------
  Dialog for defining a keypress
 -------------------------------------------------------------------*/
+
 class ScanCodeDialog : public wxDialog
 {
 public:
@@ -85,16 +86,8 @@ public:
 private:
   ScanCodeCtrl       *m_ScanCode;
   wxTextCtrl         *m_Description;
-// any class wishing to process wxWindows events must use this macro
-  DECLARE_EVENT_TABLE()
 };
 
-BEGIN_EVENT_TABLE( ScanCodeDialog, wxDialog )
-//
-END_EVENT_TABLE()
-
-/* ---------------------------------------------------------------- */
-
 ScanCodeDialog::ScanCodeDialog( wxWindow* parent, wxWindowID id, 
                const int code, const wxString &descr, const wxString& title )
           : wxDialog( parent, id, title, wxPoint(-1, -1), wxSize(96*2,76*2) )
@@ -172,46 +165,49 @@ TestGLCanvas::TestGLCanvas(wxWindow *parent, wxWindowID id,
     const wxPoint& pos, const wxSize& size, long style, const wxString& name):
   wxGLCanvas(parent, NULL, id, pos, size, style, name )
 {
-  m_init = FALSE;
-  m_gllist = 0;
-  m_rleft = WXK_LEFT;
-  m_rright = WXK_RIGHT;
+    m_init = FALSE;
+    m_gllist = 0;
+    m_rleft = WXK_LEFT;
+    m_rright = WXK_RIGHT;
 }
+
 TestGLCanvas::TestGLCanvas(wxWindow *parent, const TestGLCanvas &other, 
     wxWindowID id, const wxPoint& pos, const wxSize& size, long style,
     const wxString& name ) :
       wxGLCanvas(parent, other.GetContext(), id, pos, size, style, name  )
 {
-  m_init = FALSE;
-  m_gllist = other.m_gllist;    /* share display list */
-  m_rleft = WXK_LEFT;
-  m_rright = WXK_RIGHT;
+    m_init = FALSE;
+    m_gllist = other.m_gllist;    /* share display list */
+    m_rleft = WXK_LEFT;
+    m_rright = WXK_RIGHT;
 }
-TestGLCanvas::~TestGLCanvas(void)
+
+TestGLCanvas::~TestGLCanvas()
 {
 }
 
-void TestGLCanvas::Render( void  )
+void TestGLCanvas::Render()
 {
-  wxPaintDC dc(this);
+    wxPaintDC dc(this);
 
 #ifndef __WXMOTIF__
-  if (!GetContext()) return;
+    if (!GetContext()) return;
 #endif
-  SetCurrent();
-  /* init OpenGL once, but after SetCurrent */
-  if (!m_init)
-  {
-    InitGL();
-    m_init = TRUE;
-  }
-  /* clear color and depth buffers */
-  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+    SetCurrent();
+    /* init OpenGL once, but after SetCurrent */
+    if (!m_init)
+    {
+        InitGL();
+        m_init = TRUE;
+    }
+    
+    /* clear color and depth buffers */
+    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
   if( m_gllist == 0 )
   {
     m_gllist = glGenLists( 1 );
-    printf( "List=%d\n", m_gllist );
     glNewList( m_gllist, GL_COMPILE_AND_EXECUTE );        
     /* draw six faces of a cube */
     glBegin(GL_QUADS);
@@ -251,26 +247,26 @@ void TestGLCanvas::Render( void  )
 
 void TestGLCanvas::OnEnterWindow( wxMouseEvent& event )
 {
-  SetFocus();
+    SetFocus();
 }
 
 void TestGLCanvas::OnPaint( wxPaintEvent& event )
 {
-  Render();
+    Render();
 }
 
 void TestGLCanvas::OnSize(wxSizeEvent& event)
 {
-  int width, height;
-  GetClientSize(& width, & height);
+    int width, height;
+    GetClientSize(& width, & height);
 
 #ifndef __WXMOTIF__
-  if (GetContext())
+    if (GetContext())
 #endif
-  {
-    SetCurrent();
-    glViewport(0, 0, width, height);
-  }
+    {
+        SetCurrent();
+        glViewport(0, 0, width, height);
+    }
 }
 
 void TestGLCanvas::OnEraseBackground(wxEraseEvent& event)
@@ -278,25 +274,25 @@ void TestGLCanvas::OnEraseBackground(wxEraseEvent& event)
   // Do nothing, to avoid flashing.
 }
 
-void TestGLCanvas::InitGL(void)
+void TestGLCanvas::InitGL()
 {
-  SetCurrent();
+    SetCurrent();
     
-  /* set viewing projection */
-  glMatrixMode(GL_PROJECTION);
-  glFrustum(-0.5F, 0.5F, -0.5F, 0.5F, 1.0F, 3.0F);
+    /* set viewing projection */
+    glMatrixMode(GL_PROJECTION);
+    glFrustum(-0.5F, 0.5F, -0.5F, 0.5F, 1.0F, 3.0F);
 
-  /* position viewer */
-  glMatrixMode(GL_MODELVIEW);
-  glTranslatef(0.0F, 0.0F, -2.0F);
+    /* position viewer */
+    glMatrixMode(GL_MODELVIEW);
+    glTranslatef(0.0F, 0.0F, -2.0F);
 
-  /* position object */
-  glRotatef(30.0F, 1.0F, 0.0F, 0.0F);
-  glRotatef(30.0F, 0.0F, 1.0F, 0.0F);
+    /* position object */
+    glRotatef(30.0F, 1.0F, 0.0F, 0.0F);
+    glRotatef(30.0F, 0.0F, 1.0F, 0.0F);
 
-  glEnable(GL_DEPTH_TEST);
-  glEnable(GL_LIGHTING);
-  glEnable(GL_LIGHT0);
+    glEnable(GL_DEPTH_TEST);
+    glEnable(GL_LIGHTING);
+    glEnable(GL_LIGHT0);
 }
 
 GLfloat TestGLCanvas::CalcRotateSpeed( unsigned long acceltime )
@@ -314,65 +310,74 @@ GLfloat TestGLCanvas::CalcRotateSpeed( unsigned long acceltime )
 
   return(v);
 }
+
 GLfloat TestGLCanvas::CalcRotateAngle( unsigned long lasttime,
                                   unsigned long acceltime )
 {
-  GLfloat t,s1,s2;
+    GLfloat t,s1,s2;
 
-  t = ((GLfloat)(acceltime - lasttime)) / 1000.0f;
-  s1 = CalcRotateSpeed( lasttime );
-  s2 = CalcRotateSpeed( acceltime );
-  return( t * (s1 + s2) * 135.0f );
+    t = ((GLfloat)(acceltime - lasttime)) / 1000.0f;
+    s1 = CalcRotateSpeed( lasttime );
+    s2 = CalcRotateSpeed( acceltime );
+    
+    return( t * (s1 + s2) * 135.0f );
 }
+
 void TestGLCanvas::Action( long code, unsigned long lasttime,
                            unsigned long acceltime )
 {
-  GLfloat angle = CalcRotateAngle( lasttime, acceltime );
+    GLfloat angle = CalcRotateAngle( lasttime, acceltime );
 
-  if( code == m_rleft ) Rotate( angle );
-  else if( code == m_rright ) Rotate( -angle );
+    if (code == m_rleft) 
+        Rotate( angle );
+    else if (code == m_rright) 
+            Rotate( -angle );
 }
 
 void TestGLCanvas::OnKeyDown( wxKeyEvent& event )
 {
-  long evkey = event.KeyCode();
-  if( evkey == 0 ) return;
-
-  if( !m_TimeInitialized )
-  {
-    m_TimeInitialized = 1;
-    m_xsynct = event.m_timeStamp;
-    m_gsynct = wxStopWatch(&m_secbase);
-
-    m_Key = evkey;
-    m_StartTime = 0;
-    m_LastTime = 0;
-    m_LastRedraw = 0;
-  }
-
-  unsigned long currTime = event.m_timeStamp - m_xsynct;
+    long evkey = event.KeyCode();
+    if (evkey == 0) return;
+
+    if (!m_TimeInitialized)
+    {
+        m_TimeInitialized = 1;
+        m_xsynct = event.m_timeStamp;
+        m_gsynct = wxStopWatch(&m_secbase);
+
+        m_Key = evkey;
+        m_StartTime = 0;
+        m_LastTime = 0;
+        m_LastRedraw = 0;
+    }
+
+    unsigned long currTime = event.m_timeStamp - m_xsynct;
   
-  if( evkey != m_Key )
-  {
-    m_Key = evkey;
-    m_LastRedraw = m_StartTime = m_LastTime = currTime;
-  }
-
-  if( currTime >= m_LastRedraw )      // Redraw:
-  {
-    Action( m_Key, m_LastTime-m_StartTime, currTime-m_StartTime );
+    if (evkey != m_Key)
+    {
+        m_Key = evkey;
+        m_LastRedraw = m_StartTime = m_LastTime = currTime;
+    }
+
+    if (currTime >= m_LastRedraw)      // Redraw:
+    {
+        Action( m_Key, m_LastTime-m_StartTime, currTime-m_StartTime );
                   
-    m_LastRedraw = wxStopWatch(&m_secbase) - m_gsynct;
-    m_LastTime = currTime;
-  }
+        m_LastRedraw = wxStopWatch(&m_secbase) - m_gsynct;
+        m_LastTime = currTime;
+    }
+    
+    event.Skip();
 }
 
 void TestGLCanvas::OnKeyUp( wxKeyEvent& event )
 {
-  m_Key = 0;
-  m_StartTime = 0;
-  m_LastTime = 0;
-  m_LastRedraw = 0;
+    m_Key = 0;
+    m_StartTime = 0;
+    m_LastTime = 0;
+    m_LastRedraw = 0;
+    
+    event.Skip();
 }
 
 void TestGLCanvas::Rotate( GLfloat deg )
index 8e02865f7095e6c3950fdd0997914a73cc419d18..340df1537f0df5b61f3d46cc25c8ceaed8dab6ad 100644 (file)
 # on your system.
 #
 
-CPP = g++
+CPP = gcc
 CC = gcc
 
 Penguin: penguin.o trackball.o lw.o glcanvas.o
-       $(CPP) -o Penguin \
-       penguin.o trackball.o lw.o glcanvas.o \
-       `wx-config --libs` -lMesaGL -lMesaGLU
+       $(CPP) -o Penguin penguin.o trackball.o lw.o glcanvas.o `wx-config --libs` -lMesaGL -lMesaGLU
 
 penguin.o: penguin.cpp
-       $(CPP) `wx-config --cflags` -g -I../../gtk -c penguin.cpp
+       $(CPP) `wx-config --cflags` -I../../gtk -c penguin.cpp
 
 lw.o: lw.cpp
        $(CPP) `wx-config --cflags` -I../../gtk -c lw.cpp