3 /////////////////////////////////////////////////////////////////////////////
5 // Copyright (c) 2002 Iain Murray, Inference Group, Cavendish, Cambridge.
7 /////////////////////////////////////////////////////////////////////////////
12 // Don't seem to be needed and not in VC8 platform SDK, kdv
13 //#include <Textstor.h>
15 //#include <Msaatext.h>
18 #include "DasherWindow.h"
20 #include "Common/WinMenus.h"
22 #include "../DasherCore/DasherTypes.h"
23 #include "../DasherCore/ControlManager.h"
24 #include "Widgets/AboutBox.h"
25 #include "Widgets/AlphabetBox.h"
26 #include "Widgets/ColourBox.h"
27 #include "Widgets/KeyControl.h"
28 #include "Widgets/SplashScreen.h"
29 #include "Widgets/Prefs.h"
30 #include "Widgets/Toolbar.h"
31 #include "Widgets/Slidebar.h"
33 #include "DasherMouseInput.h"
36 using namespace Dasher
;
40 #define IDT_TIMER1 200
42 #ifdef PJC_EXPERIMENTAL
44 // Bits an pieces from pjc playing with text service framework stuff
46 bool g_bInCallback(false);
48 IAccClientDocMgr
*g_pMgr
;
49 VOID CALLBACK
WinEventProc(HWINEVENTHOOK hWinEventHook
, DWORD event
, HWND hwnd
, LONG idObject
, LONG idChild
, DWORD dwEventThread
, DWORD dwmsEventTime
);
53 CDasherWindow::CDasherWindow()
54 :Splash(0), m_pToolbar(0), m_pEdit(0), m_pSlidebar(0), m_pSplitter(0), m_pDasher(0), m_pCanvas(0)
57 m_hIconSm
= (HICON
) LoadImage(WinHelper::hInstApp
, (LPCTSTR
) IDI_DASHER
, IMAGE_ICON
, GetSystemMetrics(SM_CXSMICON
), GetSystemMetrics(SM_CYSMICON
), LR_DEFAULTCOLOR
);
59 ATL::CWndClassInfo
& wc
= CDasherWindow::GetWndClassInfo();
60 wc
.m_wc
.hIcon
= LoadIcon(WinHelper::hInstApp
, (LPCTSTR
) IDI_DASHER
);
61 wc
.m_wc
.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
62 wc
.m_wc
.hbrBackground
= (HBRUSH
) (COLOR_ACTIVEBORDER
+ 1); // Must add one to the value we want for some unknown reason
63 wc
.m_wc
.lpszMenuName
= (LPCTSTR
) IDC_DASHER
;
64 // wc.m_wc.lpszClassName = WndClassName; // Not in a resource - does not require translation
65 wc
.m_wc
.hIconSm
= m_hIconSm
;
67 #ifdef PJC_EXPERIMENTAL
69 // Create an acc manager foobar
73 MyClsid
.Data1
= 0xFC48CC30;
74 MyClsid
.Data2
= 0x4F3E;
75 MyClsid
.Data3
= 0x4fa1;
76 MyClsid
.Data4
[0] = 0x80;
77 MyClsid
.Data4
[1] = 0x3B;
78 MyClsid
.Data4
[2] = 0xAD;
79 MyClsid
.Data4
[3] = 0x0E;
80 MyClsid
.Data4
[4] = 0x19;
81 MyClsid
.Data4
[5] = 0x6A;
82 MyClsid
.Data4
[6] = 0x83;
83 MyClsid
.Data4
[7] = 0xB1;
87 MyIid
.Data1
= 0x4C896039;
90 MyIid
.Data4
[0] = 0xA8;
91 MyIid
.Data4
[1] = 0xC1;
92 MyIid
.Data4
[2] = 0x45;
93 MyIid
.Data4
[3] = 0x11;
94 MyIid
.Data4
[4] = 0x6A;
95 MyIid
.Data4
[5] = 0x98;
96 MyIid
.Data4
[6] = 0x29;
97 MyIid
.Data4
[7] = 0x2B;
100 HRESULT Foo
= CoCreateInstance(MyClsid
, 0, CLSCTX_ALL
, MyIid
, (void**)&g_pMgr
);
102 // Set up callback for WinEvents
104 HWINEVENTHOOK hEventHook
;
106 hEventHook
= SetWinEventHook(EVENT_OBJECT_FOCUS
, // Get all events.
108 GetModuleHandle(NULL
), // Use this module
112 WINEVENT_OUTOFCONTEXT
);
114 MessageBox(NULL
, L
"Initialisation of WinEvent hook failed");
120 HWND
CDasherWindow::Create()
122 hAccelTable
= LoadAccelerators(WinHelper::hInstApp
, (LPCTSTR
) IDC_DASHER
);
124 // Get window title from resource script
126 WinLocalisation::GetResourceString(IDS_APP_TITLE
, &WindowTitle
);
128 m_pAppSettings
= new CAppSettings(0, 0);
129 int iStyle(m_pAppSettings
->GetLongParameter(APP_LP_STYLE
));
132 if((iStyle
== 1) || (iStyle
== 2))
133 hWnd
= CWindowImpl
<CDasherWindow
>::Create(NULL
, NULL
, WindowTitle
.c_str(), WS_OVERLAPPEDWINDOW
| WS_CLIPCHILDREN
, WS_EX_NOACTIVATE
| WS_EX_APPWINDOW
| WS_EX_TOPMOST
);
135 hWnd
= CWindowImpl
<CDasherWindow
>::Create(NULL
, NULL
, WindowTitle
.c_str(), WS_OVERLAPPEDWINDOW
| WS_CLIPCHILDREN
);
138 m_pDasher
= new CDasher(hWnd
);
140 // Create a CAppSettings
141 m_pAppSettings
->SetHwnd(hWnd
);
142 m_pAppSettings
->SetDasher(m_pDasher
);
144 m_pEdit
= new CEdit(m_pAppSettings
);
145 m_pEdit
->Create(hWnd
, m_pAppSettings
->GetBoolParameter(APP_BP_TIME_STAMP
));
146 m_pEdit
->SetFont(m_pAppSettings
->GetStringParameter(APP_SP_EDIT_FONT
), m_pAppSettings
->GetLongParameter(APP_LP_EDIT_FONT_SIZE
));
148 #ifdef PJC_EXPERIMENTAL
149 g_hWnd
= m_pEdit
->GetHwnd();
152 m_pToolbar
= new CToolbar(hWnd
, m_pAppSettings
->GetBoolParameter(APP_BP_SHOW_TOOLBAR
));
154 // FIXME - the edit box really shouldn't need access to the interface,
155 // but at the moment it does, for training, blanking the display etc
157 m_pEdit
->SetInterface(m_pDasher
);
159 // FIXME - we shouldn't need to know about these outside of CDasher
161 m_pCanvas
= m_pDasher
->GetCanvas();
163 m_pSlidebar
= new CSlidebar(hWnd
, m_pDasher
);
166 m_pSplitter
= new CSplitter(this,100);
168 HWND hSplitter
= m_pSplitter
->Create(hWnd
);
173 // Add extra control nodes
175 m_pDasher
->RegisterNode( Dasher::CControlManager::CTL_USER
, "Speak", -1 );
176 m_pDasher
->RegisterNode( Dasher::CControlManager::CTL_USER
+1, "All", -1 );
177 m_pDasher
->RegisterNode( Dasher::CControlManager::CTL_USER
+2, "New", -1 );
178 m_pDasher
->RegisterNode( Dasher::CControlManager::CTL_USER
+3, "Repeat", -1 );
180 m_pDasher
->ConnectNode(Dasher::CControlManager::CTL_USER
, Dasher::CControlManager::CTL_ROOT
, -2);
182 m_pDasher
->ConnectNode(Dasher::CControlManager::CTL_USER
+1, Dasher::CControlManager::CTL_USER
, -2);
183 m_pDasher
->ConnectNode(Dasher::CControlManager::CTL_USER
+2, Dasher::CControlManager::CTL_USER
, -2);
184 m_pDasher
->ConnectNode(Dasher::CControlManager::CTL_USER
+3, Dasher::CControlManager::CTL_USER
, -2);
186 m_pDasher
->ConnectNode(-1, Dasher::CControlManager::CTL_USER
+1, -2);
187 m_pDasher
->ConnectNode(Dasher::CControlManager::CTL_ROOT
, Dasher::CControlManager::CTL_USER
+1, -2);
189 m_pDasher
->ConnectNode(-1, Dasher::CControlManager::CTL_USER
+2, -2);
190 m_pDasher
->ConnectNode(Dasher::CControlManager::CTL_ROOT
, Dasher::CControlManager::CTL_USER
+2, -2);
192 m_pDasher
->ConnectNode(-1, Dasher::CControlManager::CTL_USER
+3, -2);
193 m_pDasher
->ConnectNode(Dasher::CControlManager::CTL_ROOT
, Dasher::CControlManager::CTL_USER
+3, -2);
195 m_pGameModeHelper
= 0;
200 CDasherWindow::~CDasherWindow() {
201 delete Splash
; // In case Show() was never called.
206 delete m_pAppSettings
;
207 DestroyIcon(m_hIconSm
);
212 void CDasherWindow::Main()
214 DASHER_ASSERT_VALIDPTR_RW(m_pDasher
);
216 Sleep(50); // limits framerate to 50fps
219 int CDasherWindow::MessageLoop()
223 while(GetMessage(&msg
, NULL
, 0, 0)) {
224 if(!TranslateAccelerator(msg
.hwnd
, hAccelTable
, &msg
)) {
225 TranslateMessage(&msg
);
226 DispatchMessage(&msg
);
230 m_pDasher
->StartShutdown();
235 /////////////////////////////////////////////////////////////////////////////
237 void CDasherWindow::Show(int nCmdShow
)
239 // Make sure Dasher has started up.
240 // m_pDasher->Start();
242 // Clear SplashScreen
247 InvalidateRect( NULL
, FALSE
);
248 if(!LoadWindowState())
249 ShowWindow(nCmdShow
); // Now set up. Kill splash screen and display main window
253 void CDasherWindow::SaveWindowState() const
257 wp
.length
= sizeof(WINDOWPLACEMENT
);
259 if(GetWindowPlacement( &wp
)) {//function call succeeds
260 m_pAppSettings
->SaveSetting("WindowState", &wp
);
265 bool CDasherWindow::LoadWindowState() {
269 if(m_pAppSettings
->LoadSetting("WindowState", &wp
))
271 if(SetWindowPlacement(&wp
))
278 void CDasherWindow::HandleParameterChange(int iParameter
) {
280 case APP_BP_SHOW_TOOLBAR
:
281 m_pToolbar
->ShowToolbar(m_pAppSettings
->GetBoolParameter(APP_BP_SHOW_TOOLBAR
));
286 case APP_BP_TIME_STAMP
:
288 // m_pEdit->TimeStampNewFiles(m_pAppSettings->GetBoolParameter(APP_BP_TIME_STAMP));
293 case APP_SP_EDIT_FONT
:
294 case APP_LP_EDIT_FONT_SIZE
:
295 m_pEdit
->SetFont(m_pAppSettings
->GetStringParameter(APP_SP_EDIT_FONT
), m_pAppSettings
->GetLongParameter(APP_LP_EDIT_FONT_SIZE
));
300 void CDasherWindow::HandleControlEvent(int iID
) {
302 case Dasher::CControlManager::CTL_MOVE_FORWARD_CHAR
:
304 m_pEdit
->Move(EDIT_FORWARDS
, EDIT_CHAR
);
306 case Dasher::CControlManager::CTL_MOVE_FORWARD_WORD
:
308 m_pEdit
->Move(EDIT_FORWARDS
, EDIT_WORD
);
310 case Dasher::CControlManager::CTL_MOVE_FORWARD_LINE
:
312 m_pEdit
->Move(EDIT_FORWARDS
, EDIT_LINE
);
314 case Dasher::CControlManager::CTL_MOVE_FORWARD_FILE
:
316 m_pEdit
->Move(EDIT_FORWARDS
, EDIT_FILE
);
318 case Dasher::CControlManager::CTL_MOVE_BACKWARD_CHAR
:
320 m_pEdit
->Move(EDIT_BACKWARDS
, EDIT_CHAR
);
322 case Dasher::CControlManager::CTL_MOVE_BACKWARD_WORD
:
324 m_pEdit
->Move(EDIT_BACKWARDS
, EDIT_WORD
);
326 case Dasher::CControlManager::CTL_MOVE_BACKWARD_LINE
:
328 m_pEdit
->Move(EDIT_BACKWARDS
, EDIT_LINE
);
330 case Dasher::CControlManager::CTL_MOVE_BACKWARD_FILE
:
332 m_pEdit
->Move(EDIT_BACKWARDS
, EDIT_FILE
);
334 case Dasher::CControlManager::CTL_DELETE_FORWARD_CHAR
:
336 m_pEdit
->Delete(EDIT_FORWARDS
, EDIT_CHAR
);
338 case Dasher::CControlManager::CTL_DELETE_FORWARD_WORD
:
340 m_pEdit
->Delete(EDIT_FORWARDS
, EDIT_WORD
);
342 case Dasher::CControlManager::CTL_DELETE_FORWARD_LINE
:
344 m_pEdit
->Delete(EDIT_FORWARDS
, EDIT_LINE
);
346 case Dasher::CControlManager::CTL_DELETE_FORWARD_FILE
:
348 m_pEdit
->Delete(EDIT_FORWARDS
, EDIT_FILE
);
350 case Dasher::CControlManager::CTL_DELETE_BACKWARD_CHAR
:
352 m_pEdit
->Delete(EDIT_BACKWARDS
, EDIT_CHAR
);
354 case Dasher::CControlManager::CTL_DELETE_BACKWARD_WORD
:
356 m_pEdit
->Delete(EDIT_BACKWARDS
, EDIT_WORD
);
358 case Dasher::CControlManager::CTL_DELETE_BACKWARD_LINE
:
360 m_pEdit
->Delete(EDIT_BACKWARDS
, EDIT_LINE
);
362 case Dasher::CControlManager::CTL_DELETE_BACKWARD_FILE
:
364 m_pEdit
->Delete(EDIT_BACKWARDS
, EDIT_FILE
);
366 case Dasher::CControlManager::CTL_USER
+1: // Speak all
370 case Dasher::CControlManager::CTL_USER
+2: // Speak new
374 case Dasher::CControlManager::CTL_USER
+3: // Repeat speech
383 LRESULT
CDasherWindow::OnCommand(UINT message
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
385 const int wmId
= LOWORD(wParam
);
386 const int wmEvent
= HIWORD(wParam
);
388 // Tell edit box if it has changed. It should know itself really, but this is easier
389 if( m_pEdit
&& ((HWND
) lParam
== m_pEdit
->GetHwnd()) && (HIWORD(wParam
) == EN_CHANGE
)) {
396 // Parse the menu selections:
399 case ID_OPTIONS_FONTSIZE_NORMAL
:
400 m_pDasher
->SetLongParameter(LP_DASHER_FONTSIZE
, Dasher::Opts::FontSize(1));
402 case ID_OPTIONS_FONTSIZE_LARGE
:
403 m_pDasher
->SetLongParameter(LP_DASHER_FONTSIZE
, Dasher::Opts::FontSize(2));
405 case ID_OPTIONS_FONTSIZE_VERYLARGE
:
406 m_pDasher
->SetLongParameter(LP_DASHER_FONTSIZE
, Dasher::Opts::FontSize(4));
408 case ID_OPTIONS_EDITFONT
:{
411 HFONT Font
= (HFONT
) GetStockObject(DEFAULT_GUI_FONT
);
412 GetObject(Font
, sizeof(LOGFONT
), &lf
);
413 Tstring tstrFaceName
;
414 WinUTF8::UTF8string_to_wstring(m_pAppSettings
->GetStringParameter(APP_SP_EDIT_FONT
), tstrFaceName
);
415 _tcscpy(lf
.lfFaceName
, tstrFaceName
.c_str());
416 lf
.lfHeight
= m_pAppSettings
->GetLongParameter(APP_LP_EDIT_FONT_SIZE
);
417 Data
.Flags
= CF_INITTOLOGFONTSTRUCT
| CF_SCREENFONTS
;
418 Data
.lStructSize
= sizeof(CHOOSEFONT
);
419 Data
.hwndOwner
= m_hWnd
;
420 Data
.lpLogFont
= &lf
;
421 if(ChooseFont(&Data
)) {
423 WinUTF8::wstring_to_UTF8string(lf
.lfFaceName
, FontName
);
424 m_pAppSettings
->SetStringParameter(APP_SP_EDIT_FONT
, FontName
);
425 m_pAppSettings
->SetLongParameter(APP_LP_EDIT_FONT_SIZE
, lf
.lfHeight
);
429 case ID_OPTIONS_DASHERFONT
:
433 HFONT Font
= (HFONT
) GetStockObject(DEFAULT_GUI_FONT
);
434 GetObject(Font
, sizeof(LOGFONT
), &lf
);
435 Tstring tstrFaceName
;
436 WinUTF8::UTF8string_to_wstring(m_pAppSettings
->GetStringParameter(SP_DASHER_FONT
), tstrFaceName
);
437 _tcscpy(lf
.lfFaceName
, tstrFaceName
.c_str());
438 Data
.Flags
= CF_INITTOLOGFONTSTRUCT
| CF_SCREENFONTS
;
439 Data
.lStructSize
= sizeof(CHOOSEFONT
);
440 Data
.hwndOwner
= m_hWnd
;
441 Data
.lpLogFont
= &lf
;
442 if(ChooseFont(&Data
)) {
444 WinUTF8::wstring_to_UTF8string(lf
.lfFaceName
, FontName
);
445 m_pAppSettings
->SetStringParameter(SP_DASHER_FONT
, FontName
);
449 case ID_OPTIONS_RESETFONT
:
450 m_pAppSettings
->ResetParamater(SP_DASHER_FONT
);
451 m_pAppSettings
->ResetParamater(APP_SP_EDIT_FONT
);
455 Aboutbox
.DoModal(m_hWnd
);
458 case ID_OPTIONS_PREFS
: {
459 CPrefs
Prefs(m_hWnd
, m_pDasher
, m_pAppSettings
);
462 case ID_HELP_CONTENTS
:
463 HtmlHelp(m_hWnd
, L
"Dasher.chm", HH_DISPLAY_INDEX
, NULL
);
465 case ID_HELP_DASHERTUTORIAL
:
466 m_pGameModeHelper
= new CGameModeHelper(m_pDasher
);
471 case ID_EDIT_SELECTALL
:
473 m_pEdit
->SelectAll();
483 case ID_EDIT_COPY_ALL
:
494 // Selecting file->new indicates a new trial to our user logging object
495 if (m_pDasher
!= NULL
) {
496 CUserLogBase
* pUserLog
= m_pDasher
->GetUserLogPtr();
497 if (pUserLog
!= NULL
)
498 pUserLog
->NewTrial();
510 case ID_FILE_SAVE_AS
:
514 case ID_IMPORT_TRAINFILE
:
515 // TODO: Fix dummy arguments
516 m_pDasher
->TrainFile(m_pEdit
->Import(),0,0);
519 return DefWindowProc(message
, wParam
, lParam
);
527 LRESULT
CDasherWindow::OnDasherEvent(UINT message
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
) {
528 // Apparently putting the typecast directly in the switch doesn't work
529 CEvent
*pEvent( (CEvent
*)lParam
);
531 switch(pEvent
->m_iEventType
) {
532 case EV_PARAM_NOTIFY
:
533 HandleParameterChange(((CParameterNotificationEvent
*)pEvent
)->m_iParameter
);
536 HandleControlEvent(((CControlEvent
*)pEvent
)->m_iID
);
539 if(m_pGameModeHelper
) {
540 Dasher::CEditEvent
* pEvt(static_cast< Dasher::CEditEvent
* >(pEvent
));
542 switch (pEvt
->m_iEditType
) {
544 m_pGameModeHelper
->Output(pEvt
->m_sText
);
547 m_pGameModeHelper
->Delete(pEvt
->m_sText
.size());
559 m_pEdit
->HandleEvent(pEvent
);
564 LRESULT
CDasherWindow::OnDasherFocus(UINT message
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
) {
565 ::SetFocus(m_pEdit
->GetHwnd());
567 // TODO: Is this obsolete?
568 HWND
*pHwnd((HWND
*)lParam
);
569 m_pEdit
->SetKeyboardTarget(*pHwnd
);
573 LRESULT
CDasherWindow::OnDestroy(UINT message
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
) {
575 m_pEdit
->write_to_file();
582 LRESULT
CDasherWindow::OnGetMinMaxInfo(UINT message
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
) {
584 if (m_pToolbar
== 0 || m_pSplitter
== 0 || m_pSlidebar
== 0)
589 lppt
= (LPPOINT
) lParam
; // lParam points to array of POINTs
590 lppt
[3].x
= 100; // Set minimum width (arbitrary)
591 // Set minimum height:
592 if(m_pAppSettings
->GetBoolParameter(APP_BP_SHOW_TOOLBAR
))
593 lppt
[3].y
= m_pToolbar
->GetHeight() + m_pSplitter
->GetPos()
594 + m_pSplitter
->GetHeight() + m_pSlidebar
->GetHeight() + GetSystemMetrics(SM_CYEDGE
) * 10;
596 lppt
[3].y
= m_pSplitter
->GetPos()
597 + m_pSplitter
->GetHeight() + m_pSlidebar
->GetHeight() + GetSystemMetrics(SM_CYEDGE
) * 10;
602 LRESULT
CDasherWindow::OnInitMenuPopup(UINT message
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
) {
604 WinMenu
.SortOut((HMENU
) wParam
);
608 LRESULT
CDasherWindow::OnClose(UINT message
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
) {
609 // TODO: Prompt for confirmation here
615 LRESULT
CDasherWindow::OnSize(UINT message
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
) {
616 if(wParam
== SIZE_MINIMIZED
)
619 m_pToolbar
->Resize();
620 m_pSlidebar
->Resize();
628 LRESULT
CDasherWindow::OnSetFocus(UINT message
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
) {
629 ::SetFocus(m_pCanvas
->getwindow());
633 LRESULT
CDasherWindow::OnOther(UINT message
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
) {
634 if (message
== WM_DASHER_EVENT
)
635 return OnDasherEvent( message
, wParam
, lParam
, bHandled
);
636 else if (message
== WM_DASHER_FOCUS
)
637 return OnDasherFocus(message
, wParam
, lParam
, bHandled
);
638 else if (message
== DASHER_SHOW_PREFS
) {
639 CPrefs
Prefs(m_hWnd
, m_pDasher
, m_pAppSettings
);
644 void CDasherWindow::Layout() {
645 int iStyle(m_pAppSettings
->GetLongParameter(APP_LP_STYLE
));
647 // Set up the window properties
649 if((iStyle
== 1) || (iStyle
== 2)) {
650 SetWindowLong(GWL_EXSTYLE
, GetWindowLong(GWL_EXSTYLE
) | WS_EX_NOACTIVATE
| WS_EX_APPWINDOW
);
651 SetWindowPos(HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOMOVE
| SWP_NOSIZE
);
654 SetWindowLong(GWL_EXSTYLE
, GetWindowLong(GWL_EXSTYLE
) & !WS_EX_NOACTIVATE
);
655 SetWindowPos(HWND_NOTOPMOST
, 0, 0, 0, 0, SWP_NOMOVE
| SWP_NOSIZE
);
658 // Now do the actual layout
660 bool bHorizontal(iStyle
== 1);
661 bool bShowEdit(iStyle
!= 2);
664 GetClientRect( &ClientRect
);
665 const int Width
= ClientRect
.right
;
666 const int Height
= ClientRect
.bottom
;
669 if((m_pToolbar
!= 0) && m_pAppSettings
->GetBoolParameter(APP_BP_SHOW_TOOLBAR
))
670 ToolbarHeight
= m_pToolbar
->GetHeight() + 2;
673 int CurY
= ToolbarHeight
;
677 SlidebarHeight
= m_pSlidebar
->GetHeight();
680 int MaxCanvas
= Height
- SlidebarHeight
;
683 int SplitterPos
= m_pSplitter
->GetPos();
684 int SplitterHeight
= m_pSplitter
->GetHeight();
685 SplitterPos
= max(CurY
+ 2 * SplitterHeight
, SplitterPos
);
686 SplitterPos
= min(SplitterPos
, MaxCanvas
- 3 * SplitterHeight
);
687 m_pSplitter
->Move(SplitterPos
, Width
);
691 m_pCanvas
->Move(0, CurY
, Width
/ 2, MaxCanvas
- CurY
);
694 m_pEdit
->Move(Width
/ 2, CurY
, Width
/ 2, MaxCanvas
- CurY
);
698 m_pEdit
->ShowWindow(SW_SHOW
);
699 m_pSplitter
->ShowWindow(SW_SHOW
);
702 m_pEdit
->Move(0, CurY
, Width
, SplitterPos
- CurY
);
704 CurY
= SplitterPos
+ SplitterHeight
;
707 m_pEdit
->ShowWindow(SW_HIDE
);
708 m_pSplitter
->ShowWindow(SW_HIDE
);
711 int CanvasHeight
= Height
- CurY
- SlidebarHeight
- GetSystemMetrics(SM_CYEDGE
);
714 m_pCanvas
->Move(0, CurY
, Width
, CanvasHeight
);
719 void CDasherWindow::PopulateSettings() {
721 WinMenu
.SetStatus(ID_OPTIONS_FONTSIZE_NORMAL
, false, m_pDasher
->GetLongParameter(LP_DASHER_FONTSIZE
)==1);
722 WinMenu
.SetStatus(ID_OPTIONS_FONTSIZE_LARGE
, false, m_pDasher
->GetLongParameter(LP_DASHER_FONTSIZE
)==2);
723 WinMenu
.SetStatus(ID_OPTIONS_FONTSIZE_VERYLARGE
, false, m_pDasher
->GetLongParameter(LP_DASHER_FONTSIZE
)==4);
727 #ifdef PJC_EXPERIMENTAL
729 VOID CALLBACK
WinEventProc(HWINEVENTHOOK hWinEventHook
, DWORD event
, HWND hwnd
, LONG idObject
, LONG idChild
, DWORD dwEventThread
, DWORD dwmsEventTime
) {
735 g_bInCallback
= true;
737 IAccessible
*pMyAccessible
;
740 if( AccessibleObjectFromEvent( hwnd
, idObject
, idChild
, &pMyAccessible
, &MyV
) != S_OK
) {
747 pMyAccessible
->get_accRole(MyV
, &MyV2
);
749 // if(MyV2.iVal == ROLE_SYSTEM_TEXT) {
750 ITextStoreAnchor
*pAnchor(NULL
);
751 HRESULT MyFoo
= g_pMgr
->GetFocused(IID_ITextStoreAnchor
, (IUnknown
**)(&pAnchor
));
753 // pMyAccessible->QueryInterface(IID_ITextStoreAnchor, (void **)(&pAnchor));
754 // MessageBox(NULL, L"Got Text", L"Foo", MB_OK);
765 IEnumUnknown
*pMyEnum
;
767 g_pMgr
->GetDocuments(&pMyEnum
);
773 MyLock
= pAnchor
->RequestLock(TS_LF_READWRITE
, &MyLock2
);
775 MyBar
= pAnchor
->InsertTextAtSelection(TF_IAS_NOQUERY
, L
"Foo", 3, &pStart
, &pEnd
);
776 //MessageBox(NULL, L"Got Text", L"Foo", MB_OK);
783 g_bInCallback
= false;