[dasher: 11/28] Refactor: simplify startup by RMing SetupUI
- From: Patrick Welche <pwelche src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dasher: 11/28] Refactor: simplify startup by RMing SetupUI
- Date: Tue, 22 Nov 2011 17:03:35 +0000 (UTC)
commit cda12b28e681ef1a3d887523581d20e44820c70b
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date: Wed Sep 14 15:14:12 2011 +0100
Refactor: simplify startup by RMing SetupUI
Was the first thing in Realize; subclasses which need it, can perform whatever
action they needed to, before calling Realize().
Src/DasherCore/DasherInterfaceBase.cpp | 1 -
Src/DasherCore/DasherInterfaceBase.h | 10 ----------
Src/Gtk2/DasherControl.cpp | 15 ++++++---------
Src/Gtk2/DasherControl.h | 1 -
Src/MacOSX/COSXDasherControl.h | 1 -
Src/MacOSX/COSXDasherControl.mm | 6 ------
Src/MacOSX/TODO | 2 +-
Src/Win32/Dasher.cpp | 19 ++++++++++---------
Src/Win32/Dasher.h | 1 -
Src/iPhone/Classes/CDasherInterfaceBridge.h | 1 -
Src/iPhone/Classes/CDasherInterfaceBridge.mm | 4 ----
11 files changed, 17 insertions(+), 44 deletions(-)
---
diff --git a/Src/DasherCore/DasherInterfaceBase.cpp b/Src/DasherCore/DasherInterfaceBase.cpp
index 6c92a03..e665b63 100644
--- a/Src/DasherCore/DasherInterfaceBase.cpp
+++ b/Src/DasherCore/DasherInterfaceBase.cpp
@@ -124,7 +124,6 @@ void CDasherInterfaceBase::Realize(unsigned long ulTime) {
srand(ulTime);
- SetupUI();
SetupPaths();
std::vector<std::string> vAlphabetFiles;
diff --git a/Src/DasherCore/DasherInterfaceBase.h b/Src/DasherCore/DasherInterfaceBase.h
index e7b00ca..815b63f 100644
--- a/Src/DasherCore/DasherInterfaceBase.h
+++ b/Src/DasherCore/DasherInterfaceBase.h
@@ -451,16 +451,6 @@ protected:
virtual void ScanColourFiles(std::vector<std::string> &vFileList) = 0;
- ///
- /// Set up the platform dependent UI for the widget (not the wider
- /// app). Note that the constructor of the derived class will
- /// probably want to return details of what was created - this will
- /// have to happen separately, but we'll need to be careful with the
- /// semantics.
- ///
-
- virtual void SetupUI() = 0;
-
/// @}
diff --git a/Src/Gtk2/DasherControl.cpp b/Src/Gtk2/DasherControl.cpp
index a06afa7..55703a2 100644
--- a/Src/Gtk2/DasherControl.cpp
+++ b/Src/Gtk2/DasherControl.cpp
@@ -83,6 +83,12 @@ CDasherControl::CDasherControl(GtkVBox *pVBox, GtkDasherControl *pDasherControl)
m_pScreen = new CCanvas(m_pCanvas);
ChangeScreen(m_pScreen);
+ //This was done in old SetupUI, i.e. the first thing in Realize().
+ // TODO: Use system defaults?
+ if(GetStringParameter(SP_DASHER_FONT) == "")
+ SetStringParameter(SP_DASHER_FONT, "Sans 10");
+ else
+ m_pScreen->SetFont(GetStringParameter(SP_DASHER_FONT));
Realize(get_time());
// m_pKeyboardHelper = new CKeyboardHelper(this);
@@ -110,15 +116,6 @@ void CDasherControl::CreateModules() {
#endif
}
-void CDasherControl::SetupUI() {
- // TODO: Use system defaults?
- if(GetStringParameter(SP_DASHER_FONT) == "")
- SetStringParameter(SP_DASHER_FONT, "Sans 10");
- else
- m_pScreen->SetFont(GetStringParameter(SP_DASHER_FONT));
-}
-
-
void CDasherControl::SetupPaths() {
char *home_dir;
char *user_data_dir;
diff --git a/Src/Gtk2/DasherControl.h b/Src/Gtk2/DasherControl.h
index e9aa8a1..9a57653 100644
--- a/Src/Gtk2/DasherControl.h
+++ b/Src/Gtk2/DasherControl.h
@@ -171,7 +171,6 @@ private:
virtual void ScanColourFiles(std::vector<std::string> &vFileList);
virtual void SetupPaths();
virtual void CreateModules();
- virtual void SetupUI();
GtkWidget *m_pVBox;
GtkWidget *m_pCanvas;
diff --git a/Src/MacOSX/COSXDasherControl.h b/Src/MacOSX/COSXDasherControl.h
index 35fc331..27ccc53 100644
--- a/Src/MacOSX/COSXDasherControl.h
+++ b/Src/MacOSX/COSXDasherControl.h
@@ -62,7 +62,6 @@ private:
virtual void ScanColourFiles(std::vector<std::string> &vFileList);
virtual void SetupPaths();
virtual void CreateModules();
- virtual void SetupUI();
virtual bool SupportsSpeech();
virtual void Speak(const std::string &strText, bool bInterrupt);
virtual bool SupportsClipboard() {return true;}
diff --git a/Src/MacOSX/COSXDasherControl.mm b/Src/MacOSX/COSXDasherControl.mm
index 326f736..1011bb9 100644
--- a/Src/MacOSX/COSXDasherControl.mm
+++ b/Src/MacOSX/COSXDasherControl.mm
@@ -98,12 +98,6 @@ COSXDasherControl::~COSXDasherControl() {
}
}
-void COSXDasherControl::SetupUI() {
- NSLog(@"COSXDasherControl::SetupUI");
-}
-
-// TODO: hack to get around things being used before they were created. is there a better way?
-// TODO: maybe this should go in setupui?
void COSXDasherControl::Realize2() {
CDasherInterfaceBase::Realize(get_time());
[dasherApp startTimer];
diff --git a/Src/MacOSX/TODO b/Src/MacOSX/TODO
index 566f37d..109eb1c 100644
--- a/Src/MacOSX/TODO
+++ b/Src/MacOSX/TODO
@@ -10,7 +10,7 @@ Basically the way things work right now is that you should subclass CDasherInter
http://www.inference.phy.cam.ac.uk/pjc51/dasher_doxygen/classDasher_1_1CDasherInterfaceBase.html
-under 'Platform dependent utility functions'. The GTK implementation of these is CDasherControl, which might help explain what they're supposed to do. The general aim is for the CDasherInterfaceBase subclass to be something which can be treated as a custom user interface component in the appropriate platform toolkit (like a button or a list box), so SetupUI() should be used to set up anything needed for that. Once a drawing area has been created, a subclass of CDasherScreen should be created, and CDasherInterfaceBase::ChangeScreen should be called to tell the core about it.
+under 'Platform dependent utility functions'. The GTK implementation of these is CDasherControl, which might help explain what they're supposed to do. The general aim is for the CDasherInterfaceBase subclass to be something which can be treated as a custom user interface component in the appropriate platform toolkit (like a button or a list box). Once a drawing area has been created, a subclass of CDasherScreen should be created, and CDasherInterfaceBase::ChangeScreen should be called to tell the core about it.
Having created the custom UI component derived from CDasherInterfaceBase, embed it in the rest of the user interface as normal. Communication into the core is mainly through setting parameters (eg CDasherInterfaceBase::SetBoolParameter), which should cause instantaneous changes to Dasher's state. See Parameters.h for a list of all parameters (some of which are obsolete I'm afraid). Outbound messages are passed through CDasherInterfaceBase::ExternalEventHandler, which receives event objects which are either directly passed to a callback, or translated into platform dependent messages as would be used to eg notify an application that a menu item had been selected.
diff --git a/Src/Win32/Dasher.cpp b/Src/Win32/Dasher.cpp
index f7f7f88..c9d01a5 100644
--- a/Src/Win32/Dasher.cpp
+++ b/Src/Win32/Dasher.cpp
@@ -45,6 +45,16 @@ CDasher::CDasher(HWND Parent, CDasherWindow *pWindow, CEdit *pEdit)
#endif
DWORD dwTicks = GetTickCount();
+
+ //The following was done in SetupUI, i.e. the first thing in Realize.
+ // So doing here:
+ m_pCanvas = new CCanvas(this);
+ m_pCanvas->Create(m_hParent); // TODO - check return
+
+ // TODO: See MessageLoop, Main in CDasherWindow - should be brought into this class
+ // Framerate settings: currently 40fps.
+ SetTimer(m_pCanvas->getwindow(), 1, 25, NULL);
+
Realize(dwTicks);
}
@@ -268,15 +278,6 @@ void CDasher::SetupPaths() {
SetStringParameter(SP_USER_LOC, UserData2);
}
-void CDasher::SetupUI() {
- m_pCanvas = new CCanvas(this);
- m_pCanvas->Create(m_hParent); // TODO - check return
-
- // TODO: See MessageLoop, Main in CDasherWindow - should be brought into this class
- // Framerate settings: currently 40fps.
- SetTimer(m_pCanvas->getwindow(), 1, 25, NULL);
-}
-
int CDasher::GetFileSize(const std::string &strFileName) {
#ifndef _WIN32_WCE
struct _stat sStatInfo;
diff --git a/Src/Win32/Dasher.h b/Src/Win32/Dasher.h
index e5966a8..7e51f33 100644
--- a/Src/Win32/Dasher.h
+++ b/Src/Win32/Dasher.h
@@ -68,7 +68,6 @@ private:
virtual void ScanAlphabetFiles(std::vector<std::string> &vFileList);
virtual void ScanColourFiles(std::vector<std::string> &vFileList);
virtual void SetupPaths();
- virtual void SetupUI();
virtual void CreateModules();
void ScanDirectory(const Tstring &strMask, std::vector<std::string> &vFileList);
diff --git a/Src/iPhone/Classes/CDasherInterfaceBridge.h b/Src/iPhone/Classes/CDasherInterfaceBridge.h
index 04aca70..064c70d 100644
--- a/Src/iPhone/Classes/CDasherInterfaceBridge.h
+++ b/Src/iPhone/Classes/CDasherInterfaceBridge.h
@@ -74,7 +74,6 @@ private:
virtual void ScanColourFiles(std::vector<std::string> &vFileList);
virtual void SetupPaths();
virtual void CreateModules();
- virtual void SetupUI();
///
/// Pass events coming from the core to the appropriate handler.
diff --git a/Src/iPhone/Classes/CDasherInterfaceBridge.mm b/Src/iPhone/Classes/CDasherInterfaceBridge.mm
index f0f8604..59ed81a 100644
--- a/Src/iPhone/Classes/CDasherInterfaceBridge.mm
+++ b/Src/iPhone/Classes/CDasherInterfaceBridge.mm
@@ -115,10 +115,6 @@ void CDasherInterfaceBridge::SetTiltAxes(Vec3 main, float off, Vec3 slow, float
m_pTiltDevice->SetAxes(main, off, slow, off2);
}
-void CDasherInterfaceBridge::SetupUI() {
- NSLog(@"CDasherInterfaceBridge::SetupUI");
-}
-
void CDasherInterfaceBridge::Realize() {
CDashIntfScreenMsgs::Realize(get_time());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]