? src/WIN32_1.1.2_i386_DBG ? src/WIN32_1.1.2_i386_OBJ ? src/other/spell/make.exe.stackdump Index: src/wp/ap/win/ap_Win32Dialog_WordCount.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/ap/win/ap_Win32Dialog_WordCount.cpp,v retrieving revision 1.4 diff -u -r1.4 ap_Win32Dialog_WordCount.cpp --- src/wp/ap/win/ap_Win32Dialog_WordCount.cpp 2000/03/01 07:03:41 1.4 +++ src/wp/ap/win/ap_Win32Dialog_WordCount.cpp 2000/06/19 23:14:12 @@ -47,6 +47,8 @@ XAP_Dialog_Id id) : AP_Dialog_WordCount(pDlgFactory,id) { + m_bAutoWC = 1; + m_iUpdateRate = 1; } AP_Win32Dialog_WordCount::~AP_Win32Dialog_WordCount(void) @@ -73,6 +75,115 @@ UT_ASSERT((result != -1)); } +void AP_Win32Dialog_WordCount::runModeless(XAP_Frame * pFrame) +{ + // raise the dialog + int iResult; + XAP_Win32App * pWin32App = static_cast(m_pApp); + XAP_Win32Frame * pWin32Frame = static_cast(pFrame); + + LPCTSTR lpTemplate = NULL; + + UT_ASSERT(m_id == AP_DIALOG_ID_WORDCOUNT); + + lpTemplate = MAKEINTRESOURCE(AP_RID_DIALOG_WORDCOUNT); + + HWND hResult = CreateDialogParam(pWin32App->getInstance(),lpTemplate, + pWin32Frame->getTopLevelWindow(), + (DLGPROC)s_dlgProc,(LPARAM)this); + + UT_ASSERT((hResult != NULL)); + + m_hWnd = hResult; + + // Save dialog the ID number and pointer to the widget + UT_sint32 sid =(UT_sint32) getDialogId(); + m_pApp->rememberModelessId( sid, (XAP_Dialog_Modeless *) m_pDialog); + + iResult = ShowWindow( m_hWnd, SW_SHOW ); + + iResult = BringWindowToTop( m_hWnd ); + + UT_ASSERT((iResult != 0)); +} + +void AP_Win32Dialog_WordCount::setUpdateCounter( UT_uint32 iRate ) +{ + UT_uint32 iFactor = 1000; + + m_bDestroy_says_stopupdating = UT_FALSE; + m_bAutoUpdate_happening_now = UT_FALSE; + + // Make a special case for 0 seconds in + // an attempt to reduce screen flicker + if( iRate == 0 ) + iFactor = 100; + + m_pAutoUpdateWC->stop(); + + if(m_bAutoWC == UT_TRUE) + m_pAutoUpdateWC->set(m_iUpdateRate * iFactor); +} + +void AP_Win32Dialog_WordCount::autoupdateWC(UT_Timer * pTimer) +{ + UT_ASSERT(pTimer); + + // this is a static callback method and does not have a 'this' pointer. + + AP_Win32Dialog_WordCount * pDialog = (AP_Win32Dialog_WordCount *) pTimer->getInstanceData(); + + // Handshaking code + + if( pDialog->m_bDestroy_says_stopupdating != UT_TRUE) + { + pDialog->m_bAutoUpdate_happening_now = UT_TRUE; + pDialog->event_Update(); + pDialog->m_bAutoUpdate_happening_now = UT_FALSE; + } +} + +void AP_Win32Dialog_WordCount::event_Update(void) +{ + setCountFromActiveFrame(); + _updateWindowData(); +} + +void AP_Win32Dialog_WordCount::destroy(void) +{ + m_bDestroy_says_stopupdating = UT_TRUE; + while (m_bAutoUpdate_happening_now == UT_TRUE) ; + m_pAutoUpdateWC->stop(); + + int iResult = DestroyWindow( m_hWnd ); + + UT_ASSERT((iResult != 0)); + + modeless_cleanup(); +} + +void AP_Win32Dialog_WordCount::activate(void) +{ + int iResult; + XAP_Frame * pFrame = getActiveFrame(); + XAP_Win32Frame * pWin32Frame = static_cast(pFrame); + + iResult = ShowWindow( m_hWnd, SW_SHOW ); + + iResult = BringWindowToTop( m_hWnd ); + + UT_ASSERT((iResult != 0)); + + iResult = BringWindowToTop( pWin32Frame->getTopLevelWindow() ); + + UT_ASSERT((iResult != 0)); +} + +void AP_Win32Dialog_WordCount::notifyActiveFrame(XAP_Frame *pFrame) +{ + event_Update(); +} + BOOL CALLBACK AP_Win32Dialog_WordCount::s_dlgProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam) { // This is a static function. @@ -88,8 +199,17 @@ case WM_COMMAND: pThis = (AP_Win32Dialog_WordCount *)GetWindowLong(hWnd,DWL_USER); - return pThis->_onCommand(hWnd,wParam,lParam); + if (pThis) + return pThis->_onCommand(hWnd,wParam,lParam); + else + return 0; + case WM_VSCROLL: + pThis = (AP_Win32Dialog_WordCount *)GetWindowLong(hWnd,DWL_USER); + pThis->setUpdateCounter( (UT_uint32)HIWORD(wParam) ); + pThis->event_Update(); + return 1; + default: return 0; } @@ -105,8 +225,26 @@ SetWindowText(hWnd, pSS->getValue(AP_STRING_ID_DLG_WordCount_WordCountTitle)); + // Set the starting rate a 1 update/second + SetDlgItemInt(hWnd, AP_RID_DIALOG_WORDCOUNT_EDIT_RATE, 1, FALSE ); + + // Set the range for auto-updating to 0-10 + SendMessage(GetDlgItem(hWnd,AP_RID_DIALOG_WORDCOUNT_SPIN_RATE),UDM_SETRANGE,(WPARAM)0,(WPARAM)10); + + EnableWindow( GetDlgItem(hWnd,AP_RID_DIALOG_WORDCOUNT_BTN_UPDATE), !m_bAutoWC ); + if( m_bAutoWC ) + CheckDlgButton(hWnd, AP_RID_DIALOG_WORDCOUNT_CHK_AUTOUPDATE, BST_CHECKED); + + GR_Graphics * pG = NULL; + m_pAutoUpdateWC = UT_Timer::static_constructor(autoupdateWC,this,pG); + setUpdateCounter( 1 ); + // localize controls _DSX(WORDCOUNT_BTN_CLOSE, DLG_Close); + _DSX(WORDCOUNT_BTN_UPDATE, DLG_Update); + + _DS(WORDCOUNT_CHK_AUTOUPDATE, DLG_WordCount_Auto_Update); + _DS(WORDCOUNT_TEXT_RATE, DLG_WordCount_Update_Rate); _DS(WORDCOUNT_TEXT_STATS, DLG_WordCount_Statistics); _DS(WORDCOUNT_TEXT_PAGE, DLG_WordCount_Pages); @@ -127,17 +265,42 @@ return 1; // 1 == we did not call SetFocus() } +void AP_Win32Dialog_WordCount::_updateWindowData(void) +{ + HWND hWnd = m_hWnd; + + _DSI(WORDCOUNT_VAL_PAGE, page); + _DSI(WORDCOUNT_VAL_WORD, word); + _DSI(WORDCOUNT_VAL_CH, ch_no); + _DSI(WORDCOUNT_VAL_CHSP, ch_sp); + _DSI(WORDCOUNT_VAL_PARA, para); + _DSI(WORDCOUNT_VAL_LINE, line); +} + BOOL AP_Win32Dialog_WordCount::_onCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) { WORD wNotifyCode = HIWORD(wParam); WORD wId = LOWORD(wParam); HWND hWndCtrl = (HWND)lParam; + XAP_Frame * pFrame = getActiveFrame(); switch (wId) { case IDCANCEL: // also AP_RID_DIALOG_WORDCOUNT_BTN_CLOSE m_answer = a_CANCEL; - EndDialog(hWnd,0); + destroy(); + return 1; + + case AP_RID_DIALOG_WORDCOUNT_BTN_UPDATE: + notifyActiveFrame(pFrame); + return 1; + + case AP_RID_DIALOG_WORDCOUNT_CHK_AUTOUPDATE: + m_bAutoWC = !m_bAutoWC; + EnableWindow( GetDlgItem(m_hWnd,AP_RID_DIALOG_WORDCOUNT_BTN_UPDATE), !m_bAutoWC ); + EnableWindow( GetDlgItem(m_hWnd,AP_RID_DIALOG_WORDCOUNT_EDIT_RATE), m_bAutoWC ); + EnableWindow( GetDlgItem(m_hWnd,AP_RID_DIALOG_WORDCOUNT_SPIN_RATE), m_bAutoWC ); + setUpdateCounter( m_iUpdateRate ); return 1; default: // we did not handle this notification Index: src/wp/ap/win/ap_Win32Dialog_WordCount.h =================================================================== RCS file: /cvsroot/abi/src/wp/ap/win/ap_Win32Dialog_WordCount.h,v retrieving revision 1.4 diff -u -r1.4 ap_Win32Dialog_WordCount.h --- src/wp/ap/win/ap_Win32Dialog_WordCount.h 2000/05/25 09:32:01 1.4 +++ src/wp/ap/win/ap_Win32Dialog_WordCount.h 2000/06/19 23:14:12 @@ -20,7 +20,10 @@ #ifndef AP_WIN32DIALOG_WORDCOUNT_H #define AP_WIN32DIALOG_WORDCOUNT_H +#include #include "ap_Dialog_WordCount.h" +#include "ut_timer.h" + class XAP_Win32Frame; /*****************************************************************/ @@ -33,18 +36,31 @@ virtual void runModal(XAP_Frame * pFrame); - virtual void runModeless(XAP_Frame * pFrame){}; - virtual void destroy(void){}; - virtual void activate(void){}; - virtual void notifyActiveFrame(XAP_Frame *pFrame) {}; + virtual void runModeless(XAP_Frame * pFrame); + virtual void destroy(void); + virtual void activate(void); + virtual void notifyActiveFrame(XAP_Frame *pFrame); virtual void notifyCloseFrame(XAP_Frame *pFrame) {}; static XAP_Dialog * static_constructor(XAP_DialogFactory *, XAP_Dialog_Id id); + static void autoupdateWC(UT_Timer * pTimer); + virtual void setUpdateCounter( UT_uint32 ); + virtual void event_Update(void); static BOOL CALLBACK s_dlgProc(HWND,UINT,WPARAM,LPARAM); protected: BOOL _onInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam); BOOL _onCommand(HWND hWnd, WPARAM wParam, LPARAM lParam); + + void _updateWindowData(void); + + HWND m_hWnd; + UT_Bool m_bAutoWC; + + UT_Timer * m_pAutoUpdateWC; + UT_Bool m_bDestroy_says_stopupdating; + UT_Bool m_bAutoUpdate_happening_now; + UT_uint32 m_iUpdateRate; }; #endif /* AP_WIN32DIALOG_WORDCOUNT_H */ Index: src/wp/ap/win/ap_Win32Res_DlgWordCount.rc2 =================================================================== RCS file: /cvsroot/abi/src/wp/ap/win/ap_Win32Res_DlgWordCount.rc2,v retrieving revision 1.1 diff -u -r1.1 ap_Win32Res_DlgWordCount.rc2 --- src/wp/ap/win/ap_Win32Res_DlgWordCount.rc2 2000/03/01 05:20:50 1.1 +++ src/wp/ap/win/ap_Win32Res_DlgWordCount.rc2 2000/06/19 23:14:12 @@ -40,6 +40,11 @@ #define AP_RID_DIALOG_WORDCOUNT_VAL_CHSP 1015 #define AP_RID_DIALOG_WORDCOUNT_VAL_PARA 1016 #define AP_RID_DIALOG_WORDCOUNT_VAL_LINE 1017 +#define AP_RID_DIALOG_WORDCOUNT_BTN_UPDATE 1018 +#define AP_RID_DIALOG_WORDCOUNT_CHK_AUTOUPDATE 1019 +#define AP_RID_DIALOG_WORDCOUNT_TEXT_RATE 1020 +#define AP_RID_DIALOG_WORDCOUNT_EDIT_RATE 1021 +#define AP_RID_DIALOG_WORDCOUNT_SPIN_RATE 1022 #define AP_RID_DIALOG_WORDCOUNT_BTN_CLOSE IDCANCEL #define AP_RID_DIALOG_WORDCOUNT_BOX -1 @@ -47,28 +52,35 @@ // NOTE -- these placeholder strings get overridden at runtime // NOTE -- they're just here to make sizing easier -AP_RID_DIALOG_WORDCOUNT DIALOG DISCARDABLE 0, 0, 179, 110 +AP_RID_DIALOG_WORDCOUNT DIALOG DISCARDABLE 0, 0, 180, 120 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Word Count" FONT 8, "MS Sans Serif" BEGIN - LTEXT "Statistics:", AP_RID_DIALOG_WORDCOUNT_TEXT_STATS, 7,7,43,8 - GROUPBOX "", AP_RID_DIALOG_WORDCOUNT_BOX, 7,12,109,70 - LTEXT "Pages", AP_RID_DIALOG_WORDCOUNT_TEXT_PAGE, 12,20,99,8 - LTEXT "Words", AP_RID_DIALOG_WORDCOUNT_TEXT_WORD, 12,30,99,8 + LTEXT "Statistics:", AP_RID_DIALOG_WORDCOUNT_TEXT_STATS, 7,19,43,8 + GROUPBOX "", AP_RID_DIALOG_WORDCOUNT_BOX, 7,24,109,70 + LTEXT "Pages", AP_RID_DIALOG_WORDCOUNT_TEXT_PAGE, 12,32,99,8 + LTEXT "Words", AP_RID_DIALOG_WORDCOUNT_TEXT_WORD, 12,42,99,8 LTEXT "Characters (no spaces)", - AP_RID_DIALOG_WORDCOUNT_TEXT_CH, 12,40,99,8 + AP_RID_DIALOG_WORDCOUNT_TEXT_CH, 12,52,99,8 LTEXT "Characters (with spaces)", - AP_RID_DIALOG_WORDCOUNT_TEXT_CHSP, 12,50,99,8 - LTEXT "Paragraphs", AP_RID_DIALOG_WORDCOUNT_TEXT_PARA, 12,60,99,8 - LTEXT "Lines", AP_RID_DIALOG_WORDCOUNT_TEXT_LINE, 12,70,99,8 - GROUPBOX "", AP_RID_DIALOG_WORDCOUNT_BOX, 115,12,57,70 - RTEXT "100,000,000", AP_RID_DIALOG_WORDCOUNT_VAL_PAGE, 126,20,41,8 - RTEXT "100,000,000", AP_RID_DIALOG_WORDCOUNT_VAL_WORD, 126,30,41,8 - RTEXT "100,000,000", AP_RID_DIALOG_WORDCOUNT_VAL_CH, 126,40,41,8 - RTEXT "100,000,000", AP_RID_DIALOG_WORDCOUNT_VAL_CHSP, 126,50,41,8 - RTEXT "100,000,000", AP_RID_DIALOG_WORDCOUNT_VAL_PARA, 126,60,41,8 - RTEXT "100,000,000", AP_RID_DIALOG_WORDCOUNT_VAL_LINE, 126,70,41,8 - DEFPUSHBUTTON "Close", AP_RID_DIALOG_WORDCOUNT_BTN_CLOSE,122,89,50,14 + AP_RID_DIALOG_WORDCOUNT_TEXT_CHSP, 12,62,99,8 + LTEXT "Paragraphs", AP_RID_DIALOG_WORDCOUNT_TEXT_PARA, 12,72,99,8 + LTEXT "Lines", AP_RID_DIALOG_WORDCOUNT_TEXT_LINE, 12,82,99,8 + GROUPBOX "", AP_RID_DIALOG_WORDCOUNT_BOX, 115,24,57,70 + RTEXT "100,000,000", AP_RID_DIALOG_WORDCOUNT_VAL_PAGE, 126,32,41,8 + RTEXT "100,000,000", AP_RID_DIALOG_WORDCOUNT_VAL_WORD, 126,42,41,8 + RTEXT "100,000,000", AP_RID_DIALOG_WORDCOUNT_VAL_CH, 126,52,41,8 + RTEXT "100,000,000", AP_RID_DIALOG_WORDCOUNT_VAL_CHSP, 126,62,41,8 + RTEXT "100,000,000", AP_RID_DIALOG_WORDCOUNT_VAL_PARA, 126,72,41,8 + RTEXT "100,000,000", AP_RID_DIALOG_WORDCOUNT_VAL_LINE, 126,82,41,8 + DEFPUSHBUTTON "&Close", AP_RID_DIALOG_WORDCOUNT_BTN_CLOSE, 110,101,62,14 + PUSHBUTTON "&Update", AP_RID_DIALOG_WORDCOUNT_BTN_UPDATE, 7,101,62,14 + AUTOCHECKBOX "&Auto Update", AP_RID_DIALOG_WORDCOUNT_CHK_AUTOUPDATE,7,7,55,10 + EDITTEXT AP_RID_DIALOG_WORDCOUNT_EDIT_RATE,64,7,23,10 + CONTROL "Spin", AP_RID_DIALOG_WORDCOUNT_SPIN_RATE, + "msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | + UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,89,7,8,8 + LTEXT "Seconds between updates",AP_RID_DIALOG_WORDCOUNT_TEXT_RATE,88,8,99,8 END #endif /* RC_INVOKED */