[BeOS] Bug Fix # 739, 2 new Dialogs


Subject: [BeOS] Bug Fix # 739, 2 new Dialogs
From: Christopher Plymire (chrisjp@eudoramail.com)
Date: Mon Jul 24 2000 - 08:53:20 CDT


Created WordCount dialog window and Insert/Date time window resources.
Added modeless word count dialog under Be.
Added insert/date time dialog under Be. (Fixes bug 739)

wordcount.rsrc and DateTime.rsrc should be inserted in /abi/src/wp/main
/beos -- these need to marked as binary.
I've included diffs of the files neccesary to hook up these dialogs.

-Christopher


--- /windisk/abiword/abi/src/wp/ap/beos/ap_BeOSDialog_WordCount.cpp Tue Jul 25 13:20:02 2000
+++ ap_BeOSDialog_WordCount.cpp Mon Jul 24 13:15:53 2000
@@ -33,11 +33,107 @@
 #include "ut_Rehydrate.h"
 
 /*****************************************************************/
+class WordCountWin:public BWindow {
+ public:
+ WordCountWin(BMessage *data);
+ void SetDlg(AP_BeOSDialog_WordCount *brk);
+ virtual void DispatchMessage(BMessage *msg, BHandler *handler);
+ virtual bool QuitRequested(void);
+
+ private:
+ int spin;
+ AP_BeOSDialog_WordCount *m_DlgWordCount;
+};
+
+WordCountWin::WordCountWin(BMessage *data)
+ :BWindow(data) {
+ spin = 1;
+} //BreakWin::BreakWin
+
+#include <ListItem.h>
+#include <ListView.h>
+
+void WordCountWin::SetDlg(AP_BeOSDialog_WordCount *brk)
+{
+// const XAP_StringSet * pSS = brk->m_pApp->getStringSet();
+
+ char numBuf[12];
+ BStringView* pView;
+
+ m_DlgWordCount = brk;
+ pView = (BStringView *)FindView("page");
+ if(pView)
+ {
+ sprintf(numBuf,"%i" , 1);
+ pView->SetText(numBuf);
+ }
+
+ pView = (BStringView *)FindView("word");
+ if(pView)
+ {
+ sprintf(numBuf,"%i" , 0);
+ pView->SetText(numBuf);
+ }
+
+ pView = (BStringView *)FindView("ch_no");
+ if(pView)
+ {
+ sprintf(numBuf,"%i" ,0);
+ pView->SetText(numBuf);
+ }
+
+ pView = (BStringView *)FindView("ch_sp");
+ if(pView)
+ {
+ sprintf(numBuf,"%i" , 0);
+ pView->SetText(numBuf);
+ }
+
+ pView = (BStringView *)FindView("para");
+ if(pView)
+ {
+ sprintf(numBuf,"%i" ,0);
+ pView->SetText(numBuf);
+ }
+
+ pView = (BStringView *)FindView("line");
+ if(pView)
+ {
+ sprintf(numBuf,"%i" , 1);
+ pView->SetText(numBuf);
+ }
+
+ Show();
+}
+
+#include <stdio.h>
+
+void WordCountWin::DispatchMessage(BMessage *msg, BHandler *handler)
+{
+ BListView* pSource = NULL;
+
+ switch(msg->what)
+ {
+ default:
+ BWindow::DispatchMessage(msg, handler);
+ }
+}
+
+bool WordCountWin::QuitRequested()
+{
+ m_DlgWordCount->destroy();
+
+ return(true);
+}
+
+////////////////////////////////////////////////////////////////////////////////
 
 XAP_Dialog * AP_BeOSDialog_WordCount::static_constructor(XAP_DialogFactory * pFactory,
                                                                                                          XAP_Dialog_Id id)
 {
         AP_BeOSDialog_WordCount * p = new AP_BeOSDialog_WordCount(pFactory,id);
+ p->newwin = NULL;
+ p->windowIsValid = false;
         return p;
 }
 
@@ -45,6 +141,8 @@
                                                                                                  XAP_Dialog_Id id)
         : AP_Dialog_WordCount(pDlgFactory,id)
 {
+ newwin = NULL;
+ windowIsValid = false;
 }
 
 AP_BeOSDialog_WordCount::~AP_BeOSDialog_WordCount(void)
@@ -55,5 +153,174 @@
 {
         UT_ASSERT(pFrame);
         
- UT_ASSERT(UT_NOT_IMPLEMENTED);
+ BMessage msg;
+ if (RehydrateWindow("WordCount", &msg))
+ {
+ newwin = new WordCountWin(&msg);
+ newwin->SetDlg(this);
+ //Take the information here ...
+ newwin->Lock();
+ newwin->Close();
+ }
+}
+
+void AP_BeOSDialog_WordCount::runModeless(XAP_Frame * pFrame)
+{
+ UT_ASSERT(pFrame);
+
+ BMessage msg;
+ if(windowIsValid && newwin != NULL)
+ {
+ newwin->Lock();
+ newwin->Activate(true);
+ newwin->Unlock();
+ return;
+ }
+
+ if (RehydrateWindow("WordCount", &msg))
+ {
+ newwin = new WordCountWin(&msg);
+ newwin->SetDlg(this);
+
+ GR_Graphics * pG = NULL;
+ m_pAutoUpdateWC = UT_Timer::static_constructor(autoupdateWC,this,pG);
+ setUpdateCounter( 1 );
+
+ windowIsValid = true;
+ //Take the information here ...
+// newwin->Lock();
+// newwin->Close();
+ }
 }
+
+void AP_BeOSDialog_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();
+
+ m_iUpdateRate = iRate;
+
+// if(m_bAutoWC == UT_TRUE)
+ m_pAutoUpdateWC->set(m_iUpdateRate * iFactor);
+}
+
+void AP_BeOSDialog_WordCount::_updateWindowData(void)
+{
+// SetDlgItemInt(hWnd,AP_RID_DIALOG_WORDCOUNT_VAL_PAGE,m_count.page,FALSE)
+ BStringView* pView;
+ char numBuf[12];
+
+ pView = (BStringView *)newwin->FindView("page");
+ if(pView)
+ {
+ sprintf(numBuf,"%i" , m_count.page);
+ pView->SetText(numBuf);
+ }
+
+ pView = (BStringView *)newwin->FindView("word");
+ if(pView)
+ {
+ sprintf(numBuf,"%i" , m_count.word);
+ pView->SetText(numBuf);
+ }
+
+ pView = (BStringView *)newwin->FindView("ch_no");
+ if(pView)
+ {
+ sprintf(numBuf,"%i" , m_count.ch_no);
+ pView->SetText(numBuf);
+ }
+
+ pView = (BStringView *)newwin->FindView("ch_sp");
+ if(pView)
+ {
+ sprintf(numBuf,"%i" , m_count.ch_sp);
+ pView->SetText(numBuf);
+ }
+
+ pView = (BStringView *)newwin->FindView("para");
+ if(pView)
+ {
+ sprintf(numBuf,"%i" , m_count.para);
+ pView->SetText(numBuf);
+ }
+
+ pView = (BStringView *)newwin->FindView("line");
+ if(pView)
+ {
+ sprintf(numBuf,"%i" , m_count.line);
+ pView->SetText(numBuf);
+ }
+
+ //_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);
+
+ // Update the caption in case the name of the document has changed
+// ConstructWindowName();
+// SetWindowText(hWnd, m_WindowName);
+}
+
+void AP_BeOSDialog_WordCount::event_Update(void)
+{
+ setCountFromActiveFrame();
+ _updateWindowData();
+}
+
+void AP_BeOSDialog_WordCount::autoupdateWC(UT_Timer * pTimer)
+{
+ UT_ASSERT(pTimer);
+
+ // this is a static callback method and does not have a 'this' pointer.
+
+ AP_BeOSDialog_WordCount * pDialog = (AP_BeOSDialog_WordCount *) pTimer->getInstanceData();
+
+ if( pDialog->newwin->LockWithTimeout(1000) == B_OK)
+ {
+ pDialog->event_Update();
+ pDialog->newwin->Unlock();
+ }
+}
+
+void AP_BeOSDialog_WordCount::destroy(void)
+{
+ if(newwin)
+ {
+ m_pAutoUpdateWC->stop();
+ windowIsValid = false;
+ }
+}
+
+void AP_BeOSDialog_WordCount::activate(void)
+{
+#if 0
+ if(newwin && windowIsValid)
+ {
+ newwin->Lock();
+ newwin->Activate();
+ newwin->Unlock();
+ }
+#endif
+}
+
+void AP_BeOSDialog_WordCount::notifyActiveFrame(XAP_Frame *pFrame)
+{
+
+}
+
+void AP_BeOSDialog_WordCount::notifyCloseFrame(XAP_Frame *pFrame)
+{
+
+}
\ No newline at end of file









This archive was generated by hypermail 2b25 : Mon Jul 24 2000 - 12:56:37 CDT