[dasher: 9/43] Win32 fixes: clipboard; rm refs to Opts::ColorSchemes, GC various bits of Screen
- From: Patrick Welche <pwelche src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dasher: 9/43] Win32 fixes: clipboard; rm refs to Opts::ColorSchemes, GC various bits of Screen
- Date: Thu, 23 Jun 2011 18:56:30 +0000 (UTC)
commit 36f42e95b73c9f9c23ed1b9165c673129fef1a99
Author: Patrick Welche <prlw1 cam ac uk>
Date: Thu Jun 9 15:04:44 2011 +0100
Win32 fixes: clipboard; rm refs to Opts::ColorSchemes, GC various bits of Screen
Speech code inside #ifdef WIN32_SPEECH. Todo, how were we compiling this before?
Other fixes involving CEdit, SetScreenInterface, etc.
Now compiles on the windows laptop (w/o speech), but doesn't run - missing
libexpat.dll - so haven't tested functionality...
Src/DasherCore/DasherCore_vc80.vcproj | 8 ++++++++
Src/Win32/Dasher.cpp | 18 +++++++++---------
Src/Win32/Dasher.h | 13 ++++++++++---
Src/Win32/DasherWindow.cpp | 4 ++--
Src/Win32/Dasher_vc80.sln | 24 ++++++++++++------------
Src/Win32/Widgets/Canvas.cpp | 11 ++++-------
Src/Win32/Widgets/Canvas.h | 2 --
Src/Win32/Widgets/Edit.h | 1 -
Src/Win32/Widgets/Screen.cpp | 18 +-----------------
Src/Win32/Widgets/Screen.h | 25 ++++---------------------
Src/Win32/Widgets/Screen.inl | 2 +-
11 files changed, 51 insertions(+), 75 deletions(-)
---
diff --git a/Src/DasherCore/DasherCore_vc80.vcproj b/Src/DasherCore/DasherCore_vc80.vcproj
index c2fb1ba..83a02dc 100644
--- a/Src/DasherCore/DasherCore_vc80.vcproj
+++ b/Src/DasherCore/DasherCore_vc80.vcproj
@@ -1643,6 +1643,14 @@
</File>
</Filter>
<File
+ RelativePath=".\AbstractXMLParser.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\AbstractXMLParser.h"
+ >
+ </File>
+ <File
RelativePath=".\ActionButton.cpp"
>
</File>
diff --git a/Src/Win32/Dasher.cpp b/Src/Win32/Dasher.cpp
index c45742f..a893856 100644
--- a/Src/Win32/Dasher.cpp
+++ b/Src/Win32/Dasher.cpp
@@ -8,6 +8,8 @@
#include "Common\WinUTF8.h"
#include "Widgets/Canvas.h"
#include "DasherMouseInput.h"
+#include "DasherWindow.h"
+#include "Widgets/Edit.h"
#ifndef _WIN32_WCE
#include "Sockets/SocketInput.h"
@@ -322,7 +324,7 @@ void CDasher::Move(int iX, int iY, int iWidth, int iHeight) {
void CDasher::TakeFocus() {
// TODO: Implement me
}
-#ifndef _WIN32_WCE
+#ifdef WIN32_SPEECH
bool CDasher::SupportsSpeech() {
if (!m_bAttemptedSpeech) {
//try to create speech synthesizer lazily, saving resources if no speech req'd.
@@ -346,24 +348,20 @@ void CDasher::Speak(const string &strText, bool bInterrupt) {
pVoice->Speak(strText.c_str(), SPF_ASYNC, NULL);
}
#endif
-bool CDasher::SupportsClipboard {
- return true;
-}
void CDasher::CopyToClipboard(const string &strText) {
- CString cText(strText.c_str());
- if (OpenClipboard())
+ if (OpenClipboard(m_hParent))
{
EmptyClipboard(); //also frees memory containing any previous data
//Allocate global memory for string - enough for characters + NULL.
- HGLOBAL hClipboardData = GlobalAlloc(GMEM_DDESHARE, strData.GetLength()+1);
+ HGLOBAL hClipboardData = GlobalAlloc(GMEM_DDESHARE, strText.length()+1);
//GlobalLock returns a pointer to the data associated with the handle returned from GlobalAlloc
char * pchData = (char*)GlobalLock(hClipboardData);
//now fill it...
- strcpy(pchData, LPCSTR(strData));
+ strcpy(pchData, strText.c_str());
//Unlock memory, i.e. release our access to it -
// but don't free it (with GlobalFree), as it will "belong"
@@ -384,7 +382,9 @@ std::string CDasher::GetAllContext() {
int speechlength = m_pEdit->GetWindowTextLength();
LPTSTR allspeech = new TCHAR[speechlength + 1];
m_pEdit->GetWindowText(allspeech, speechlength + 1);
- return allspeech;
+ string res;
+ wstring_to_UTF8string(wstring(allspeech),res);
+ return res;
}
std::string CDasher::GetContext(unsigned int iStart, unsigned int iLength) {
diff --git a/Src/Win32/Dasher.h b/Src/Win32/Dasher.h
index 3cc0a3a..1b128aa 100644
--- a/Src/Win32/Dasher.h
+++ b/Src/Win32/Dasher.h
@@ -4,7 +4,15 @@
#include "../DasherCore/DasherInterfaceBase.h"
#include "../DasherCore/UserLog.h"
+#ifdef _WIN32_WCE
+//on WinCE, do not support speech
+#undef WIN32_SPEECH
+#endif
+
+#ifdef WIN32_SPEECH
#include <sapi.h>
+#endif
+
#include <string>
#include <vector>
@@ -51,8 +59,7 @@ public:
virtual std::string GetAllContext();
std::string GetContext(unsigned int iStart, unsigned int iLength);
-#ifndef _WIN32_WCE
- //on WinCE, do not support speech - so use defaults from CDasherInterfaceBase
+#ifdef WIN32_SPEECH
bool SupportsSpeech();
void Speak(const std::string &text, bool bInterrupt);
#endif
@@ -79,7 +86,7 @@ private:
HWND m_hParent;
CDasherWindow *m_pWindow;
CEdit *m_pEdit;
-#ifndef _WIN32_WCE
+#ifdef WIN32_SPEECH
ISpVoice *pVoice;
bool attemptedSpeech;
#endif
diff --git a/Src/Win32/DasherWindow.cpp b/Src/Win32/DasherWindow.cpp
index 5a2b84a..890b499 100644
--- a/Src/Win32/DasherWindow.cpp
+++ b/Src/Win32/DasherWindow.cpp
@@ -292,8 +292,8 @@ LRESULT CDasherWindow::OnCommand(UINT message, WPARAM wParam, LPARAM lParam, BOO
m_pEdit->Copy();
return 0;
case ID_EDIT_COPY_ALL:
- if(m_pEdit)
- m_pEdit->CopyAll();
+ if(m_pDasher)
+ m_pDasher->CopyToClipboard(m_pDasher->GetAllContext());
return 0;
case ID_EDIT_PASTE:
if(m_pEdit)
diff --git a/Src/Win32/Dasher_vc80.sln b/Src/Win32/Dasher_vc80.sln
index a81f019..924a3f9 100644
--- a/Src/Win32/Dasher_vc80.sln
+++ b/Src/Win32/Dasher_vc80.sln
@@ -137,9 +137,9 @@ Global
{4A4CEB83-FBC8-4E93-831E-009875E54794}.Release (W2K)|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Release (W2K)|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{4A4CEB83-FBC8-4E93-831E-009875E54794}.Release|Any CPU.ActiveCfg = Release|Win32
{4A4CEB83-FBC8-4E93-831E-009875E54794}.Release|Any CPU.Build.0 = Release|Win32
- {4A4CEB83-FBC8-4E93-831E-009875E54794}.Release|Mixed Platforms.ActiveCfg = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
- {4A4CEB83-FBC8-4E93-831E-009875E54794}.Release|Mixed Platforms.Build.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
- {4A4CEB83-FBC8-4E93-831E-009875E54794}.Release|Mixed Platforms.Deploy.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
+ {4A4CEB83-FBC8-4E93-831E-009875E54794}.Release|Mixed Platforms.ActiveCfg = Release|Win32
+ {4A4CEB83-FBC8-4E93-831E-009875E54794}.Release|Mixed Platforms.Build.0 = Release|Win32
+ {4A4CEB83-FBC8-4E93-831E-009875E54794}.Release|Mixed Platforms.Deploy.0 = Release|Win32
{4A4CEB83-FBC8-4E93-831E-009875E54794}.Release|Pocket PC 2003 (ARMV4).ActiveCfg = Release|Pocket PC 2003 (ARMV4)
{4A4CEB83-FBC8-4E93-831E-009875E54794}.Release|Pocket PC 2003 (ARMV4).Build.0 = Release|Pocket PC 2003 (ARMV4)
{4A4CEB83-FBC8-4E93-831E-009875E54794}.Release|Pocket PC 2003 (ARMV4).Deploy.0 = Release|Pocket PC 2003 (ARMV4)
@@ -182,9 +182,9 @@ Global
{752501D3-5B04-4F3C-A141-DE426E354D23}.Release (W2K)|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{752501D3-5B04-4F3C-A141-DE426E354D23}.Release|Any CPU.ActiveCfg = Release|Win32
{752501D3-5B04-4F3C-A141-DE426E354D23}.Release|Any CPU.Build.0 = Release|Win32
- {752501D3-5B04-4F3C-A141-DE426E354D23}.Release|Mixed Platforms.ActiveCfg = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
- {752501D3-5B04-4F3C-A141-DE426E354D23}.Release|Mixed Platforms.Build.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
- {752501D3-5B04-4F3C-A141-DE426E354D23}.Release|Mixed Platforms.Deploy.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
+ {752501D3-5B04-4F3C-A141-DE426E354D23}.Release|Mixed Platforms.ActiveCfg = Release|Win32
+ {752501D3-5B04-4F3C-A141-DE426E354D23}.Release|Mixed Platforms.Build.0 = Release|Win32
+ {752501D3-5B04-4F3C-A141-DE426E354D23}.Release|Mixed Platforms.Deploy.0 = Release|Win32
{752501D3-5B04-4F3C-A141-DE426E354D23}.Release|Pocket PC 2003 (ARMV4).ActiveCfg = Release|Pocket PC 2003 (ARMV4)
{752501D3-5B04-4F3C-A141-DE426E354D23}.Release|Pocket PC 2003 (ARMV4).Build.0 = Release|Pocket PC 2003 (ARMV4)
{752501D3-5B04-4F3C-A141-DE426E354D23}.Release|Pocket PC 2003 (ARMV4).Deploy.0 = Release|Pocket PC 2003 (ARMV4)
@@ -229,9 +229,9 @@ Global
{3998D966-9B9E-4214-ACEA-B777985AF4DD}.Release (W2K)|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Release (W2K)|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{3998D966-9B9E-4214-ACEA-B777985AF4DD}.Release|Any CPU.ActiveCfg = Release|Win32
{3998D966-9B9E-4214-ACEA-B777985AF4DD}.Release|Any CPU.Build.0 = Release|Win32
- {3998D966-9B9E-4214-ACEA-B777985AF4DD}.Release|Mixed Platforms.ActiveCfg = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
- {3998D966-9B9E-4214-ACEA-B777985AF4DD}.Release|Mixed Platforms.Build.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
- {3998D966-9B9E-4214-ACEA-B777985AF4DD}.Release|Mixed Platforms.Deploy.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
+ {3998D966-9B9E-4214-ACEA-B777985AF4DD}.Release|Mixed Platforms.ActiveCfg = Release|Win32
+ {3998D966-9B9E-4214-ACEA-B777985AF4DD}.Release|Mixed Platforms.Build.0 = Release|Win32
+ {3998D966-9B9E-4214-ACEA-B777985AF4DD}.Release|Mixed Platforms.Deploy.0 = Release|Win32
{3998D966-9B9E-4214-ACEA-B777985AF4DD}.Release|Pocket PC 2003 (ARMV4).ActiveCfg = Release|Pocket PC 2003 (ARMV4)
{3998D966-9B9E-4214-ACEA-B777985AF4DD}.Release|Pocket PC 2003 (ARMV4).Build.0 = Release|Pocket PC 2003 (ARMV4)
{3998D966-9B9E-4214-ACEA-B777985AF4DD}.Release|Pocket PC 2003 (ARMV4).Deploy.0 = Release|Pocket PC 2003 (ARMV4)
@@ -276,9 +276,9 @@ Global
{192C1E5C-2D1E-4AA3-91C3-FF2D7ABD67F8}.Release (W2K)|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Release (W2K)|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{192C1E5C-2D1E-4AA3-91C3-FF2D7ABD67F8}.Release|Any CPU.ActiveCfg = Release|Win32
{192C1E5C-2D1E-4AA3-91C3-FF2D7ABD67F8}.Release|Any CPU.Build.0 = Release|Win32
- {192C1E5C-2D1E-4AA3-91C3-FF2D7ABD67F8}.Release|Mixed Platforms.ActiveCfg = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
- {192C1E5C-2D1E-4AA3-91C3-FF2D7ABD67F8}.Release|Mixed Platforms.Build.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
- {192C1E5C-2D1E-4AA3-91C3-FF2D7ABD67F8}.Release|Mixed Platforms.Deploy.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
+ {192C1E5C-2D1E-4AA3-91C3-FF2D7ABD67F8}.Release|Mixed Platforms.ActiveCfg = Release|Win32
+ {192C1E5C-2D1E-4AA3-91C3-FF2D7ABD67F8}.Release|Mixed Platforms.Build.0 = Release|Win32
+ {192C1E5C-2D1E-4AA3-91C3-FF2D7ABD67F8}.Release|Mixed Platforms.Deploy.0 = Release|Win32
{192C1E5C-2D1E-4AA3-91C3-FF2D7ABD67F8}.Release|Pocket PC 2003 (ARMV4).ActiveCfg = Release|Pocket PC 2003 (ARMV4)
{192C1E5C-2D1E-4AA3-91C3-FF2D7ABD67F8}.Release|Pocket PC 2003 (ARMV4).Build.0 = Release|Pocket PC 2003 (ARMV4)
{192C1E5C-2D1E-4AA3-91C3-FF2D7ABD67F8}.Release|Pocket PC 2003 (ARMV4).Deploy.0 = Release|Pocket PC 2003 (ARMV4)
diff --git a/Src/Win32/Widgets/Canvas.cpp b/Src/Win32/Widgets/Canvas.cpp
index 6bf7ffd..d668075 100644
--- a/Src/Win32/Widgets/Canvas.cpp
+++ b/Src/Win32/Widgets/Canvas.cpp
@@ -108,10 +108,6 @@ HWND CCanvas::Create(HWND hParent) {
return hWnd;
}
-
-void CCanvas::SetScreenInterface(Dasher::CDasherInterfaceBase *dasherinterface) {
- m_pScreen->SetInterface(dasherinterface);
-}
LRESULT CCanvas::OnCreate(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
bHandled = TRUE;
@@ -425,8 +421,9 @@ LRESULT CCanvas::OnCursorOutOfRange(UINT message, WPARAM wParam, LPARAM lParam,
bHandled = TRUE;
if ( m_pDasherInterface->GetBoolParameter(BP_START_MOUSE) )
{
+ //TODO check, does this do something the standard BR_STOP_OUTSIDE in DefaultFilter doesn't?
if (!m_pDasherInterface->GetBoolParameter(BP_DASHER_PAUSED))
- m_pDasherInterface->Pause();
+ m_pDasherInterface->Stop();
}
return 0;
@@ -530,8 +527,8 @@ void CCanvas::DoFrame()
// TODO: Brink this back into core
if (dwTicks - m_dwTicksLastEvent > m_pDasherInterface->GetLongParameter(LP_STOP_IDLETIME) )
{
- // idle time exceeded
- m_pDasherInterface->Pause();
+ // idle time exceeded, so pause (no stop actions)
+ m_pDasherInterface->SetBoolParameter(BP_DASHER_PAUSED, true);
}
}
}
diff --git a/Src/Win32/Widgets/Canvas.h b/Src/Win32/Widgets/Canvas.h
index 1bdd7da..108f309 100644
--- a/Src/Win32/Widgets/Canvas.h
+++ b/Src/Win32/Widgets/Canvas.h
@@ -177,8 +177,6 @@ class CCanvas : public ATL::CWindowImpl<CCanvas>, public Dasher::CDasherComponen
/* bool Running() { */
/* return running; */
/* } */
-
- void SetScreenInterface(Dasher::CDasherInterfaceBase * dasherinterface);
int OnTimer();
diff --git a/Src/Win32/Widgets/Edit.h b/Src/Win32/Widgets/Edit.h
index c780e79..5c75b51 100644
--- a/Src/Win32/Widgets/Edit.h
+++ b/Src/Win32/Widgets/Edit.h
@@ -105,7 +105,6 @@ class CEdit : public ATL::CWindowImpl<CEdit> {
void Cut();
void Copy();
- void CopyAll();
void Paste();
void SelectAll();
void Clear();
diff --git a/Src/Win32/Widgets/Screen.cpp b/Src/Win32/Widgets/Screen.cpp
index 71894df..f3cd6fe 100644
--- a/Src/Win32/Widgets/Screen.cpp
+++ b/Src/Win32/Widgets/Screen.cpp
@@ -51,12 +51,6 @@ CScreen::CScreen(HDC hdc, HWND hWnd, Dasher::screenint iWidth, Dasher::screenint
m_hDCBuffer = m_hDCBufferBackground;
- CodePage = GetUserCodePage();
-
-// m_hDCScreen = ::GetDC(m_hwnd);
-// TCHAR debug[256];
-// _stprintf(debug, TEXT("GetDC: hwnd %x hdc %x\n"), m_hwnd, m_hDCScreen);
-// OutputDebugString(debug);
}
/////////////////////////////////////////////////////////////////////////////
@@ -89,17 +83,7 @@ CScreen::~CScreen() {
/////////////////////////////////////////////////////////////////////////////
-void CScreen::SetInterface(CDasherInterfaceBase *DasherInterface) {
-#ifndef _WIN32_WCE
- DASHER_ASSERT_VALIDPTR_RW(DasherInterface);
-#endif
-
- // CDasherScreen::SetInterface(DasherInterface);
-
-// CodePage = EncodingToCP(m_pDasherInterface->GetAlphabetType());
-}
-
-void CScreen::SetColourScheme(const Dasher::CColourIO::ColourInfo *pColours) {
+void CScreen::SetColourScheme(const CColourIO::ColourInfo *pColours) {
m_cPens.clear();
m_cBrushes.clear();
m_pColours = pColours;
diff --git a/Src/Win32/Widgets/Screen.h b/Src/Win32/Widgets/Screen.h
index 8e7e9a3..14334bf 100644
--- a/Src/Win32/Widgets/Screen.h
+++ b/Src/Win32/Widgets/Screen.h
@@ -25,18 +25,15 @@
#include <cmath>
#endif
-// Should this using-directive really be in a header file?
-using namespace Dasher;
-
/////////////////////////////////////////////////////////////////////////////
class CScreen:public Dasher::CDasherScreen, private NoClones {
public:
-
- CScreen(HDC hdc, HWND hWnd, Dasher::screenint width, Dasher::screenint height);
+ //Saves a lot of typing; typedefs are equal to their declaration & do not create distinct types.
+ typedef Dasher::screenint screenint;
+ CScreen(HDC hdc, HWND hWnd, screenint width, screenint height);
~CScreen();
- void SetInterface(CDasherInterfaceBase * DasherInterface);
void SetColourScheme(const Dasher::CColourIO::ColourInfo *pColours);
void SetFont(const std::string &strFont);
@@ -50,11 +47,8 @@ public:
//void DrawString(const std::string & String, Dasher::screenint x1, Dasher::screenint y1, int Size,int layer=0);
void DrawString(const std::string & String, Dasher::screenint x1, Dasher::screenint y1, int Size, int Colour);
- //void DrawRectangle(Dasher::screenint x1, Dasher::screenint y1, Dasher::screenint x2, Dasher::screenint y2, int Color, int iOutlineColour, Dasher::Opts::ColorSchemes ColorScheme, bool bDrawOutlines, bool bFill, int iThickness,int layer=0);
- void DrawRectangle(Dasher::screenint x1, Dasher::screenint y1, Dasher::screenint x2, Dasher::screenint y2, int Colour, int iOutlineColour, Dasher::Opts::ColorSchemes ColorScheme, int iThickness);
+ void DrawRectangle(Dasher::screenint x1, Dasher::screenint y1, Dasher::screenint x2, Dasher::screenint y2, int Colour, int iOutlineColour, int iThickness);
- ///WHY is this defined like that?
- //void CScreen::DrawCircle(screenint iCX, screenint iCY, screenint iR, int iColour, int iFillColour, int iThickness, bool bFill,int layer=0);
void CScreen::DrawCircle(screenint iCX, screenint iCY, screenint iR, int iFillColour, int iLineColour, int iThickness);
// Draw a line of fixed colour (usually black). Intended for static UI elements such as a cross-hair
@@ -138,17 +132,6 @@ private:
screenint m_iHeight;
};
- struct hash_textsize {
- enum {
- bucket_size = 4, // 0 < bucket_size
- min_buckets = 8 // min_buckets = 2 ^^ N, 0 < N
- };
-
- size_t operator() (const CTextSizeInput & x)const {
- return hash_string(x.m_String.c_str()) ^ x.m_iSize;
- } bool operator() (const CTextSizeInput & x, const CTextSizeInput & y)const {
- return (x != y);
- }};
mutable std::map < CTextSizeInput, CTextSizeOutput > m_mapTextSize;
};
diff --git a/Src/Win32/Widgets/Screen.inl b/Src/Win32/Widgets/Screen.inl
index 1fa2046..85dfffb 100644
--- a/Src/Win32/Widgets/Screen.inl
+++ b/Src/Win32/Widgets/Screen.inl
@@ -20,7 +20,7 @@ inline void CScreen::DrawRectangle(screenint x1, screenint y1, screenint x2, scr
#ifndef DASHER_WINCE
- if(iWidth != -1) {
+ if(m_iWidth != -1) {
point aPoints[5];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]