[Avida-SVN] r1819 - in development: . source/targets/viewer-fltk source/viewer-coreGUI

ofria at myxo.css.msu.edu ofria at myxo.css.msu.edu
Wed Jul 18 12:11:06 PDT 2007


Author: ofria
Date: 2007-07-18 15:11:05 -0400 (Wed, 18 Jul 2007)
New Revision: 1819

Modified:
   development/CMakeLists.txt
   development/source/targets/viewer-fltk/cDriver_FLTKViewer.cc
   development/source/targets/viewer-fltk/cDriver_FLTKViewer.h
   development/source/targets/viewer-fltk/tFLTKButton.h
   development/source/viewer-coreGUI/cGUIButton.h
   development/source/viewer-coreGUI/tGUIButton.h
Log:
Checking in some minor tweaks in fltk viewer.


Modified: development/CMakeLists.txt
===================================================================
--- development/CMakeLists.txt	2007-07-18 18:59:29 UTC (rev 1818)
+++ development/CMakeLists.txt	2007-07-18 19:11:05 UTC (rev 1819)
@@ -505,6 +505,10 @@
     TARGET_LINK_LIBRARIES(avida-fltkview ${AVIDA_FLTK_VIEWER_LIBS})
     SET_TARGET_PROPERTIES(avida-fltkview PROPERTIES LINK_FLAGS ${FLTK_PLATFORM_DEPENDENT_LIBS})
 
+    IF(APPLE AND NOT FLTK_APPLE_X11)
+       SET( LINK_FLAGS_avida_fltkview ${LINK_FLAGS} "-framework Carbon -framework Cocoa -framework ApplicationServices -lz")
+    ENDIF(APPLE AND NOT FLTK_APPLE_X11)
+
     INSTALL_TARGETS(/work avida-fltkview)
 
   ENDIF(FLTK_BASE_LIBRARY AND FLTK_INCLUDE_PATH)

Modified: development/source/targets/viewer-fltk/cDriver_FLTKViewer.cc
===================================================================
--- development/source/targets/viewer-fltk/cDriver_FLTKViewer.cc	2007-07-18 18:59:29 UTC (rev 1818)
+++ development/source/targets/viewer-fltk/cDriver_FLTKViewer.cc	2007-07-18 19:11:05 UTC (rev 1819)
@@ -51,16 +51,24 @@
 
 using namespace std;
 
+#define FLTK_MAINWIN_WIDTH  800
+#define FLTK_MAINWIN_HEIGHT 600
+#define FLTK_MENUBAR_HEIGHT 35
+#define FLTK_BODY_HEIGHT (FLTK_MAINWIN_HEIGHT - FLTK_MENUBAR_HEIGHT)
+
+#define FLTK_MENU_FONT_SIZE 20
+
 cDriver_FLTKViewer::cDriver_FLTKViewer(cWorld* world)
   : m_world(world)
   , m_info(world->GetPopulation(), 12)
   , m_done(false)
-  , m_main_window(800, 600, "Avida")
-  , m_menu_box(m_main_window, 0, 0, 800, 50)
-  , m_body_box(m_main_window, 0, 50, 800, 550)
-  , m_update_box(m_main_window, 0, 0, 200, 50, "Update 0")
-  , m_title_box(m_main_window, 600, 0, 200, 50, "Avida")
-  , m_quit_button(m_main_window, 200, 0, 200, 50, "Quit")
+  , m_main_window(FLTK_MAINWIN_WIDTH, FLTK_MAINWIN_HEIGHT, "Avida")
+  , m_menu_box(m_main_window, 0, 0, FLTK_MAINWIN_WIDTH, FLTK_MENUBAR_HEIGHT)
+  , m_body_box(m_main_window, 0, FLTK_MENUBAR_HEIGHT, FLTK_MAINWIN_WIDTH, FLTK_BODY_HEIGHT)
+  , m_update_box(m_main_window, 0, 0, 200, FLTK_MENUBAR_HEIGHT, "Update 0")
+  , m_title_box(m_main_window, 600, 0, 200, FLTK_MENUBAR_HEIGHT, "Avida")
+  , m_quit_button(m_main_window, 200, 0, 200, FLTK_MENUBAR_HEIGHT, "Quit")
+  , m_pause_button(m_main_window, 400, 0, 200, FLTK_MENUBAR_HEIGHT, "Pause", cGUIButton::BUTTON_LIGHT)
 {
   // Setup the initial view mode (loaded from avida.cfg)
   m_info.SetViewMode(world->GetConfig().VIEW_MODE.Get());
@@ -68,23 +76,29 @@
   cDriverManager::Register(static_cast<cAvidaDriver*>(this));
   world->SetDriver(this);
 
-  m_main_window.SetSizeRange(800, 600);
+  m_main_window.SetSizeRange(FLTK_MAINWIN_WIDTH, FLTK_MAINWIN_HEIGHT);
 
   m_menu_box.SetType(cGUIBox::BOX_RAISED_FRAME);
   m_menu_box.Refresh();
 
   m_update_box.SetType(cGUIBox::BOX_RAISED);
-  m_update_box.SetFontSize(30);
+  m_update_box.SetFontSize(FLTK_MENU_FONT_SIZE);
   m_update_box.Refresh();
  
   m_title_box.SetType(cGUIBox::BOX_RAISED);
-  m_title_box.SetFontSize(30);
+  m_title_box.SetFontSize(FLTK_MENU_FONT_SIZE);
   m_title_box.Refresh();
 
   m_main_window.Resizable(m_body_box);
 
   m_quit_button.SetCallback(this, &cDriver_FLTKViewer::ButtonCallback_Quit);
+  m_quit_button.SetFontSize(FLTK_MENU_FONT_SIZE);
+  m_quit_button.Refresh();
 
+  m_pause_button.SetCallback(this, &cDriver_FLTKViewer::ButtonCallback_Pause);
+  m_pause_button.SetFontSize(FLTK_MENU_FONT_SIZE);
+  m_pause_button.Refresh();
+
   m_main_window.Finalize();
 }
 
@@ -347,20 +361,11 @@
     m_info.SetPauseLevel(cCoreView_Info::PAUSE_ON);
   }
 
-//   // If we are paused at all, delay doing anything else until we recieve user input.
-//   if (pause_level != cCoreView_Info::PAUSE_OFF) nodelay(stdscr, false);
-
-  // If there is any input in the buffer, process all of it.
+  // If we are paused, keep checking the interface until we are done.
   int cur_char = 0;
-  while ((cur_char = GetKeypress()) != 0 || m_info.GetPauseLevel() == cCoreView_Info::PAUSE_ON) {
-    bool found_keypress = ProcessKeypress(cur_char);
-
-    // If we couldn't manage the keypress here, check the current screen.
-//    if (found_keypress == false && cur_screen) cur_screen->DoInput(cur_char);
+  while (m_info.GetPauseLevel() == cCoreView_Info::PAUSE_ON) {
+    error = Fl::check();
   }
-
-//   nodelay(stdscr, true);
-
 }
 
 void cDriver_FLTKViewer::NotifyComment(const cString& in_string)
@@ -409,7 +414,14 @@
   exit(0);
 }
 
+void cDriver_FLTKViewer::ButtonCallback_Pause(double ignore)
+{
+  m_info.TogglePause();
+}
 
+
+
+
 void ExitFLTKViewer(int exit_code)
 {
   signal(SIGINT, SIG_IGN);           // Ignore all future interupts.

Modified: development/source/targets/viewer-fltk/cDriver_FLTKViewer.h
===================================================================
--- development/source/targets/viewer-fltk/cDriver_FLTKViewer.h	2007-07-18 18:59:29 UTC (rev 1818)
+++ development/source/targets/viewer-fltk/cDriver_FLTKViewer.h	2007-07-18 19:11:05 UTC (rev 1819)
@@ -66,6 +66,7 @@
   cFLTKBox m_title_box;
 
   tFLTKButton<cDriver_FLTKViewer> m_quit_button;
+  tFLTKButton<cDriver_FLTKViewer> m_pause_button;
 
 public:
   cDriver_FLTKViewer(cWorld* world);
@@ -103,6 +104,7 @@
 
   // Button Callbacks...
   void ButtonCallback_Quit(double ignore);
+  void ButtonCallback_Pause(double ignore);
 };
 
 

Modified: development/source/targets/viewer-fltk/tFLTKButton.h
===================================================================
--- development/source/targets/viewer-fltk/tFLTKButton.h	2007-07-18 18:59:29 UTC (rev 1818)
+++ development/source/targets/viewer-fltk/tFLTKButton.h	2007-07-18 19:11:05 UTC (rev 1819)
@@ -31,16 +31,27 @@
 #include "fltk-defs.h"
 
 #include "FL/Fl_Button.H"
+#include "FL/Fl_Light_Button.H"
 
 template <class T> class tFLTKButton : public tGUIButton<T> {
 protected:
   Fl_Button * m_button;
 
 public:
-  tFLTKButton(cGUIContainer & parent, int x, int y, int width, int height, const cString & name="")
-    : tGUIButton<T>(parent, x, y, width, height, name)
+  tFLTKButton(cGUIContainer & parent, int x, int y, int width, int height, const cString & name="",
+	      cGUIButton::eButtonType type=cGUIButton::BUTTON_NORMAL)
+    : tGUIButton<T>(parent, x, y, width, height, name, type)
   {
-    m_button = new Fl_Button(x, y, width, height, name);
+    if (type == cGUIButton::BUTTON_NORMAL) {
+      m_button = new Fl_Button(x, y, width, height, name);
+    }
+    else if (type == cGUIButton::BUTTON_LIGHT) {
+      m_button = new Fl_Light_Button(x, y, width, height, name);
+    }
+    else {
+      assert(false); // Unknown button type!
+    }
+
     m_button->callback((Fl_Callback*) GenericButtonCallback, (void*)(this));
   }
   ~tFLTKButton() { delete m_button; }

Modified: development/source/viewer-coreGUI/cGUIButton.h
===================================================================
--- development/source/viewer-coreGUI/cGUIButton.h	2007-07-18 18:59:29 UTC (rev 1818)
+++ development/source/viewer-coreGUI/cGUIButton.h	2007-07-18 19:11:05 UTC (rev 1819)
@@ -39,8 +39,9 @@
   int m_binding; // What keypress is this button bound to?
 
 public:
-  cGUIButton(cGUIContainer & parent, int x, int y, int width, int height, const cString & name="")
-    : cGUIWidget(parent, x, y, width, height, name) { ; }
+  cGUIButton(cGUIContainer & parent, int x, int y, int width, int height, const cString & name="",
+	     eButtonType type=BUTTON_NORMAL)
+    : cGUIWidget(parent, x, y, width, height, name), m_type(type) { ; }
   virtual ~cGUIButton() { ; }
 
   virtual void Press() = 0;

Modified: development/source/viewer-coreGUI/tGUIButton.h
===================================================================
--- development/source/viewer-coreGUI/tGUIButton.h	2007-07-18 18:59:29 UTC (rev 1818)
+++ development/source/viewer-coreGUI/tGUIButton.h	2007-07-18 19:11:05 UTC (rev 1819)
@@ -36,8 +36,13 @@
   double m_arg;
 
 public:
-  tGUIButton(cGUIContainer & parent, int x, int y, int width, int height, const cString & name="")
-    : cGUIButton(parent, x, y, width, height, name), m_target(NULL), m_callback(NULL), m_arg(0.0) { ; }
+  tGUIButton(cGUIContainer & parent, int x, int y, int width, int height, const cString & name="",
+	     cGUIButton::eButtonType type=cGUIButton::BUTTON_NORMAL)
+    : cGUIButton(parent, x, y, width, height, name, type)
+    , m_target(NULL)
+    , m_callback(NULL)
+    , m_arg(0.0)
+  { ; }
   virtual ~tGUIButton() { ; }
 
   T & GetTarget() { return *m_target; }




More information about the Avida-cvs mailing list