CLogWndView Class Reference

#include <LogWndView.h>

Inheritance diagram for CLogWndView:
Inheritance graph
[legend]
Collaboration diagram for CLogWndView:
Collaboration graph
[legend]

List of all members.

Public Member Functions

CLogWndDocGetDocument () const
void SetTitle (LPCTSTR title)
void lock (void)
void unlock (void)
virtual BOOL PreCreateWindow (CREATESTRUCT &cs)
virtual ~CLogWndView ()
virtual void AssertValid () const
virtual void Dump (CDumpContext &dc) const
void resetScrollSize (void)
void setScrollPosition (CDC *pDC, CLogRingBuffer *pBR)
void clearViewDoc (void)
CString getCopyData (void)
BOOL OnScroll (UINT nScrollCode, UINT nPos, BOOL bDoScroll)

Public Attributes

CLogWndDocpDoc
CLogWndFramepFrame
CString Title
CFont m_ScreenFont
int m_FontSizeX
int m_FontSizeY
int m_ScrollSizeX
int m_ScrollSizeY
int m_DocLastPos
int m_copysy
int m_copyey

Protected Member Functions

 CLogWndView ()
virtual void OnInitialUpdate ()
afx_msg int OnCreate (LPCREATESTRUCT lpcs)
afx_msg void OnDestroy (void)
afx_msg void OnDraw (CDC *pDC)
afx_msg void OnLButtonDown (UINT nFlags, CPoint point)
afx_msg void OnLButtonUp (UINT nFlags, CPoint point)
afx_msg void OnMouseMove (UINT nFlags, CPoint point)
afx_msg BOOL OnEraseBkgnd (CDC *pDC)
afx_msg void OnSize (UINT nType, int cx, int cy)

Protected Attributes

int m_mpress
int m_msx
int m_msy
int m_mex
int m_mey
int m_dragsx
int m_dragsy
int m_dragex
int m_dragey

Private Attributes

BOOL m_locked

Detailed Description

Definition at line 19 of file LogWndView.h.


Constructor & Destructor Documentation

CLogWndView (  )  [protected]

Definition at line 22 of file LogWndView.cpp.

00023 {
00024     //DEBUG_INFO("コンストラクタ:IN  CLogWndView\n");    
00025 
00026     pFrame        = NULL;
00027     pDoc          = NULL;
00028     Title         = _T("");
00029 
00030     m_FontSizeX   = 0;
00031     m_FontSizeY   = 0;
00032     m_DocLastPos  = 0;
00033 
00034     m_msx = m_msy = 0;
00035     m_mex = m_mey = 0;
00036     m_mpress      = FALSE;
00037     m_dragsx      = 0;
00038     m_dragsy      = 0;
00039     m_dragex      = 0;
00040     m_dragey      = 0;
00041 
00042     m_copysy      = -1;
00043     m_copyey      = -1;
00044     m_locked      = FALSE;
00045 
00046     KanjiCode     = CODE_SJIS;
00047 
00048     //DEBUG_INFO("コンストラクタ:OUT CLogWndView\n");    
00049 }

~CLogWndView (  )  [virtual]

Definition at line 53 of file LogWndView.cpp.

References CLogWndView::m_locked.

00054 {   
00055     DEBUG_INFO("DESTRUCTOR: CLogWndView: START\n"); 
00056 
00057     while(m_locked) ::Sleep(10);
00058 
00059     DEBUG_INFO("DESTRUCTOR: CLogWndView: END\n");
00060 }


Member Function Documentation

void AssertValid (  )  const [virtual]

Definition at line 298 of file LogWndView.cpp.

00299 {
00300     CScrollView::AssertValid();
00301 }

void clearViewDoc ( void   ) 

Definition at line 245 of file LogWndView.cpp.

References CLogWndDoc::clear(), CLogWndDoc::criticalKey, DISPLAY_MARGIN, CLogWndView::GetDocument(), LINES_PER_PAGE, CLogWndView::lock(), CLogWndView::m_FontSizeX, CLogWndView::m_FontSizeY, CLogWndView::m_ScrollSizeX, CLogWndView::m_ScrollSizeY, CLogWndView::pDoc, and CLogWndDoc::ringBuffer.

Referenced by CLogWndFrame::OnLogClear().

00246 {
00247     if (pDoc==NULL) pDoc = GetDocument();
00248     if (!pDoc || pDoc->ringBuffer==NULL) return;
00249     CLogRingBuffer* pRB = pDoc->ringBuffer;
00250 
00251     CSingleLock lock(&(pDoc->criticalKey));
00252     lock.Lock();
00253     while (!lock.IsLocked()) {
00254         Sleep(100);
00255         lock.Lock();
00256     }
00257 
00258     m_ScrollSizeX = m_FontSizeX + DISPLAY_MARGIN;
00259     m_ScrollSizeY = m_FontSizeY + DISPLAY_MARGIN;
00260     //if (m_ScrollSizeY>SHRT_MAX) m_ScrollSizeY = SHRT_MAX;
00261 
00262     CSize sizeTotal(m_ScrollSizeX+2, m_ScrollSizeY);
00263     CSize sizeLine(m_FontSizeX, m_FontSizeY);
00264     CSize sizePage(m_FontSizeX, m_FontSizeY*LINES_PER_PAGE);
00265 
00266     SetScrollSizes(MM_TEXT, sizeTotal, sizePage, sizeLine);
00267 
00268     POINT  pt;
00269     pt.x = 0;
00270     pt.y = 0;
00271 
00272     ScrollToPosition(pt);
00273 
00274     pDoc->clear();
00275 
00276     InvalidateRect(NULL, TRUE);
00277 
00278     lock.Unlock();
00279 }

Here is the call graph for this function:

Here is the caller graph for this function:

void Dump ( CDumpContext &  dc  )  const [virtual]

Definition at line 305 of file LogWndView.cpp.

00306 {
00307     CScrollView::Dump(dc);
00308 }

CString getCopyData ( void   ) 

Definition at line 413 of file LogWndView.cpp.

References CLogWndView::GetDocument(), CLogWndView::m_copyey, CLogWndView::m_copysy, jbxwl::mbs2ts(), and CLogWndDoc::ringBuffer.

Referenced by CLogWndFrame::OnLogCopy().

00414 {
00415     CString ret = _T("");
00416     if (m_copysy<0 || m_copysy>m_copyey) return ret;
00417 
00418     CLogWndDoc* pdoc = GetDocument();
00419     if (!pdoc || !pdoc->ringBuffer) return ret;
00420     CLogRingBuffer* pRB = pdoc->ringBuffer;
00421 
00422     for (int i=m_copysy; i<=m_copyey; i++) {
00423         Buffer buf = dup_Buffer(pRB->pBuf[i]);
00424         if (pRB->getKindData(i)!=LOG_RB_BINARY_DATA) {
00425             if (buf.buf[buf.vldsz-1]!='\n') cat_s2Buffer("\n", &buf);
00426         }
00427 
00428         ret = ret + mbs2ts((char*)buf.buf);
00429         free_Buffer(&buf);
00430     }
00431 
00432     return ret;
00433 }

Here is the call graph for this function:

Here is the caller graph for this function:

CLogWndDoc * GetDocument (  )  const

Definition at line 312 of file LogWndView.cpp.

Referenced by CLogWndView::clearViewDoc(), CLogWndView::getCopyData(), CLogWndDoc::GetView(), CLogWndView::OnDraw(), CLogWndView::OnInitialUpdate(), and CLogWndView::resetScrollSize().

00313 {
00314     ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CLogWndDoc)));
00315     return (CLogWndDoc*)m_pDocument;
00316 }

Here is the caller graph for this function:

void lock ( void   )  [inline]

Definition at line 36 of file LogWndView.h.

References CLogWndView::m_locked.

Referenced by CLogWndView::clearViewDoc(), CLogWndDoc::lock(), and CLogWndView::OnDraw().

00036 { m_locked = TRUE;}

Here is the caller graph for this function:

int OnCreate ( LPCREATESTRUCT  lpcs  )  [protected]

Definition at line 328 of file LogWndView.cpp.

References IDS_STR_FONT_GOTHIC, IDS_STR_FONT_SIZE, CLogWndView::m_ScreenFont, and CLogWndView::OnInitialUpdate().

00329 {
00330     if (CScrollView::OnCreate(lpcs)==-1) return -1;
00331 
00332     CString fname, fsize;
00333     fname.LoadString(IDS_STR_FONT_GOTHIC);      // MS ゴシック
00334     fsize.LoadString(IDS_STR_FONT_SIZE);        // 120
00335     int sz = ttoi(fsize);
00336 
00337     CClientDC dc(this);
00338     m_ScreenFont.CreatePointFont(sz, (LPCTSTR)fname, &dc);
00339 
00340     //
00341     OnInitialUpdate();
00342     return 0;
00343 }

Here is the call graph for this function:

void OnDestroy ( void   )  [protected]

Definition at line 347 of file LogWndView.cpp.

References CLogWndView::m_ScreenFont.

00348 {
00349     m_ScreenFont.DeleteObject();
00350     CScrollView::OnDestroy();
00351 }

void OnDraw ( CDC *  pDC  )  [protected, virtual]

Reimplemented from CExTextView.

Definition at line 103 of file LogWndView.cpp.

References CLogWndDoc::criticalKey, DISPLAY_MARGIN, CLogWndView::GetDocument(), CLogWndView::lock(), CLogWndView::m_copyey, CLogWndView::m_copysy, CLogWndView::m_FontSizeY, CLogWndView::m_ScreenFont, jbxwl::mbs2ts(), CLogWndView::pDoc, CLogWndView::resetScrollSize(), CLogWndDoc::ringBuffer, and CLogWndView::setScrollPosition().

00104 {
00105     if (pDoc==NULL) pDoc = GetDocument();
00106     if (!pDoc || pDoc->ringBuffer==NULL) return;
00107 
00108     CLogRingBuffer* pRB = pDoc->ringBuffer;
00109     if (pRB->getMaxLineY()==0) return;
00110 
00111     CSingleLock lock(&(pDoc->criticalKey));
00112     lock.Lock();
00113     while (!lock.IsLocked()) {
00114         Sleep(100);
00115         lock.Lock();
00116     }
00117 
00118     resetScrollSize();
00119 
00120     CFont* pOldFontX = pDC->SelectObject(&m_ScreenFont);
00121     CRect  rc;
00122     pDC->GetClipBox(&rc);
00123 
00124     int nLineBegin = rc.top/m_FontSizeY;
00125     int nLineEnd   = min((rc.bottom+m_FontSizeY-1)/m_FontSizeY, pRB->getMaxLineY());
00126 
00127     for (int i=nLineBegin; i<nLineEnd; i++) {
00128         Buffer buf = pRB->getRingBuffer(i);
00129         if (buf.buf==NULL) break;
00130 
00131         if (i>=m_copysy && i<=m_copyey) {
00132             pDC->SetBkColor(RGB(200,200,200));
00133         }
00134         else {
00135             pDC->SetBkColor(RGB(255,255,255));
00136         }
00137 
00138         if      (buf.state==LOG_RB_WARNING) {
00139             pDC->SetTextColor(RGB(20,20,200));
00140         }
00141         else if (buf.state==LOG_RB_ERROR) {
00142             pDC->SetTextColor(RGB(200,20,20));
00143         }
00144         else if (buf.state==LOG_RB_DEBUG) {
00145             pDC->SetTextColor(RGB(20,150,20));
00146         }
00147         else if (buf.state==LOG_RB_INFO) {
00148             pDC->SetTextColor(RGB(20,150,150));
00149         }
00150         else {
00151             pDC->SetTextColor(RGB(0,0,0));
00152         }
00153 
00154         //if (isText_Buffer(buf)) kanji_convert_Buffer(&buf);
00155         CString outtext = mbs2ts((char*)buf.buf);
00156         pDC->TextOut(DISPLAY_MARGIN, i*m_FontSizeY+DISPLAY_MARGIN, (LPCTSTR)outtext);
00157         free_Buffer(&buf);
00158     }
00159 
00160     setScrollPosition(pDC, pRB);
00161 
00162     lock.Unlock();
00163 
00164     pDC->SelectObject(pOldFontX);
00165 }

Here is the call graph for this function:

BOOL OnEraseBkgnd ( CDC *  pDC  )  [protected]

Reimplemented from CExTextView.

Definition at line 89 of file LogWndView.cpp.

00090 {
00091     return CExTextView::OnEraseBkgnd(pDC);
00092 }

void OnInitialUpdate ( void   )  [protected, virtual]

Reimplemented from CExTextView.

Definition at line 215 of file LogWndView.cpp.

References DISPLAY_MARGIN, CLogWndView::GetDocument(), LINES_PER_PAGE, CLogWndView::m_FontSizeX, CLogWndView::m_FontSizeY, CLogWndView::m_ScrollSizeX, CLogWndView::m_ScrollSizeY, CLogWndView::pDoc, and CLogWndDoc::ringBuffer.

Referenced by CLogWndView::OnCreate().

00216 {
00217     CExTextView::OnInitialUpdate();
00218 
00219     if (pDoc==NULL) pDoc = GetDocument();
00220     if (!pDoc || pDoc->ringBuffer==NULL) return;
00221     CLogRingBuffer* pRB = pDoc->ringBuffer;
00222 
00223     CClientDC dc(this);
00224     TEXTMETRIC tm;
00225     dc.GetTextMetrics(&tm);
00226 
00227     m_FontSizeX   = dc.GetTextExtent(CString('0', 1)).cx;       // フォントの横サイズ
00228     m_FontSizeY   = tm.tmHeight + tm.tmExternalLeading;         // フォント(含行間)の縦サイズ
00229 
00230     m_ScrollSizeX = m_FontSizeX + DISPLAY_MARGIN;
00231     m_ScrollSizeY = m_FontSizeY + DISPLAY_MARGIN;
00232     //if (m_ScrollSizeY>SHRT_MAX) m_ScrollSizeY = SHRT_MAX;
00233 
00234     CSize sizeTotal(m_ScrollSizeX+2, m_ScrollSizeY);
00235     CSize sizeLine(m_FontSizeX, m_FontSizeY);
00236     CSize sizePage(m_FontSizeX, m_FontSizeY*LINES_PER_PAGE);
00237 
00238     SetScrollSizes(MM_TEXT, sizeTotal, sizePage, sizeLine);
00239 
00240     return;
00241 }

Here is the call graph for this function:

Here is the caller graph for this function:

void OnLButtonDown ( UINT  nFlags,
CPoint  point 
) [protected]

Definition at line 359 of file LogWndView.cpp.

References CLogWndView::m_copyey, CLogWndView::m_copysy, CLogWndView::m_dragsx, CLogWndView::m_dragsy, CLogWndView::m_FontSizeX, CLogWndView::m_FontSizeY, CLogWndView::m_mpress, CLogWndView::m_msx, and CLogWndView::m_msy.

00360 {
00361     CPoint scrlpos = GetScrollPosition();
00362     m_msx    = point.x + scrlpos.x;
00363     m_msy    = point.y + scrlpos.y;
00364 
00365     m_dragsx = m_msx/m_FontSizeX;
00366     m_dragsy = m_msy/m_FontSizeY;
00367     m_mpress = TRUE;
00368 
00369     // Window内をクリック
00370     CRect  rc;
00371     GetClientRect(&rc);     
00372     if (point.x>=rc.left && point.x<=rc.right && point.y>rc.top && point.y<=rc.bottom) {
00373         m_copysy = -1;
00374         m_copyey = -1;
00375         InvalidateRect(NULL, FALSE);
00376     }
00377 
00378     CScrollView::OnLButtonDown(nFlags, point);
00379 }

void OnLButtonUp ( UINT  nFlags,
CPoint  point 
) [protected]

Definition at line 383 of file LogWndView.cpp.

References CLogWndView::m_mpress.

00384 {
00385     m_mpress = FALSE;
00386 
00387     CScrollView::OnLButtonUp(nFlags, point);
00388 }

void OnMouseMove ( UINT  nFlags,
CPoint  point 
) [protected]

Definition at line 392 of file LogWndView.cpp.

References CLogWndView::m_copyey, CLogWndView::m_copysy, CLogWndView::m_dragex, CLogWndView::m_dragey, CLogWndView::m_dragsx, CLogWndView::m_dragsy, CLogWndView::m_FontSizeX, CLogWndView::m_FontSizeY, CLogWndView::m_mex, CLogWndView::m_mey, and CLogWndView::m_mpress.

00393 {
00394     if (m_mpress) {
00395         CPoint scrlpos = GetScrollPosition();
00396         m_mex = point.x + scrlpos.x;
00397         m_mey = point.y + scrlpos.y;
00398         m_dragex = m_mex/m_FontSizeX;
00399         m_dragey = m_mey/m_FontSizeY;
00400 
00401         if (m_dragsx!=m_dragex || m_dragsy!=m_dragey) {
00402             m_copysy = m_dragsy;
00403             m_copyey = m_dragey;
00404             InvalidateRect(NULL, FALSE);
00405         }
00406     }
00407 
00408     CScrollView::OnMouseMove(nFlags, point);
00409 }

BOOL OnScroll ( UINT  nScrollCode,
UINT  nPos,
BOOL  bDoScroll 
)

Definition at line 440 of file LogWndView.cpp.

00441 {
00442     SCROLLINFO info;
00443     info.cbSize = sizeof(SCROLLINFO);
00444     info.fMask  = SIF_TRACKPOS;
00445 
00446     if (LOBYTE(nScrollCode)==SB_THUMBTRACK)
00447     {
00448         GetScrollInfo(SB_HORZ, &info);
00449         nPos = info.nTrackPos;
00450     }
00451 
00452     if (HIBYTE(nScrollCode)==SB_THUMBTRACK)
00453     {
00454         GetScrollInfo(SB_VERT, &info);
00455         nPos = info.nTrackPos;
00456     }
00457 
00458     return CScrollView::OnScroll(nScrollCode, nPos, bDoScroll);
00459 }

void OnSize ( UINT  nType,
int  cx,
int  cy 
) [protected]

Reimplemented from CExTextView.

Definition at line 96 of file LogWndView.cpp.

00097 {
00098     CExTextView::OnSize(nType, cx, cy);
00099 }

BOOL PreCreateWindow ( CREATESTRUCT &  cs  )  [virtual]

Definition at line 76 of file LogWndView.cpp.

References LINES_PER_PAGE.

00077 {
00078     CSize sizeTotal(100, 100);
00079     CSize sizeLine(m_FontSizeX, m_FontSizeY);
00080     CSize sizePage(m_FontSizeX, m_FontSizeY*LINES_PER_PAGE);
00081     SetScrollSizes(MM_TEXT, sizeTotal, sizePage, sizeLine);
00082     
00083     BOOL ret = CScrollView::PreCreateWindow(cs);
00084     return ret;
00085 }

void resetScrollSize ( void   ) 

Definition at line 188 of file LogWndView.cpp.

References DISPLAY_MARGIN, CLogWndView::GetDocument(), LINES_PER_PAGE, CLogWndView::m_FontSizeX, CLogWndView::m_FontSizeY, CLogWndView::m_ScrollSizeX, CLogWndView::m_ScrollSizeY, CLogWndView::pDoc, and CLogWndDoc::ringBuffer.

Referenced by CLogWndView::OnDraw().

00189 {
00190     if (pDoc==NULL) pDoc = GetDocument();
00191     if (!pDoc || !pDoc->ringBuffer) return;
00192     CLogRingBuffer* pRB = pDoc->ringBuffer;
00193     if (pRB->getMaxLineY()==0 || pRB->getMaxLineX()==0) return;
00194     
00195     int scrollSizeX = m_FontSizeX*pRB->getMaxLineX() + DISPLAY_MARGIN;
00196     int scrollSizeY = m_FontSizeY*pRB->getMaxLineY() + DISPLAY_MARGIN;
00197     //if (scrollSizeY>SHRT_MAX) scrollSizeY = SHRT_MAX;
00198 
00199     if (scrollSizeX!=m_ScrollSizeX || scrollSizeY!=m_ScrollSizeY) {
00200         m_ScrollSizeX = scrollSizeX;
00201         m_ScrollSizeY = scrollSizeY;
00202 
00203         CSize sizeTotal(m_ScrollSizeX, m_ScrollSizeY);
00204         CSize sizeLine(m_FontSizeX, m_FontSizeY);
00205         CSize sizePage(m_FontSizeX, m_FontSizeY*LINES_PER_PAGE);
00206 
00207         SetScrollSizes(MM_TEXT, sizeTotal, sizePage, sizeLine);
00208     }
00209 
00210     return;
00211 }

Here is the call graph for this function:

Here is the caller graph for this function:

void setScrollPosition ( CDC *  pDC,
CLogRingBuffer *  pBR 
)

Definition at line 169 of file LogWndView.cpp.

References CLogWndView::m_DocLastPos, and CLogWndView::m_FontSizeY.

Referenced by CLogWndView::OnDraw().

00170 {
00171     int lastPos = pRB->getLastPosition();
00172     if (m_DocLastPos==lastPos) return;
00173     m_DocLastPos = lastPos;
00174 
00175     CRect  rc;
00176     GetClientRect(&rc);     
00177 
00178     POINT  pt;
00179     pt.x = 0;
00180     pt.y = (lastPos+1)*m_FontSizeY - rc.bottom + rc.top;
00181     if (pt.y<0) pt.y = 0;
00182 
00183     ScrollToPosition(pt);
00184 }

Here is the caller graph for this function:

void SetTitle ( LPCTSTR  title  ) 

Reimplemented from CExTextView.

Definition at line 283 of file LogWndView.cpp.

References CLogWndView::pDoc, CLogWndView::pFrame, CExTextFrame::Title, and CLogWndView::Title.

Referenced by jbxwl::ExecLogWnd().

00284 {
00285     this->Title   = title;
00286     pFrame->Title = title;
00287     pFrame->SetTitle(title);        // ルート&カレントウィンドウ
00288     pFrame->SetWindowText(title);   // カレントウィンドウ
00289     pDoc->SetTitle(title);          // ?
00290 
00291     return;
00292 }

Here is the caller graph for this function:

void unlock ( void   )  [inline]

Definition at line 37 of file LogWndView.h.

References CLogWndView::m_locked.

Referenced by CLogWndDoc::unlock(), and CLogWndDoc::~CLogWndDoc().

00037 { m_locked = FALSE;}

Here is the caller graph for this function:


Member Data Documentation

int m_copyey
int m_copysy

Definition at line 73 of file LogWndView.h.

Referenced by CLogWndView::setScrollPosition().

int m_dragex [protected]

Definition at line 63 of file LogWndView.h.

Referenced by CLogWndView::OnMouseMove().

int m_dragey [protected]

Definition at line 64 of file LogWndView.h.

Referenced by CLogWndView::OnMouseMove().

int m_dragsx [protected]

Definition at line 61 of file LogWndView.h.

Referenced by CLogWndView::OnLButtonDown(), and CLogWndView::OnMouseMove().

int m_dragsy [protected]

Definition at line 62 of file LogWndView.h.

Referenced by CLogWndView::OnLButtonDown(), and CLogWndView::OnMouseMove().

BOOL m_locked [private]

Definition at line 26 of file LogWndView.h.

Referenced by CLogWndView::lock(), CLogWndView::unlock(), and CLogWndView::~CLogWndView().

int m_mex [protected]

Definition at line 59 of file LogWndView.h.

Referenced by CLogWndView::OnMouseMove().

int m_mey [protected]

Definition at line 60 of file LogWndView.h.

Referenced by CLogWndView::OnMouseMove().

int m_mpress [protected]
int m_msx [protected]

Definition at line 57 of file LogWndView.h.

Referenced by CLogWndView::OnLButtonDown().

int m_msy [protected]

Definition at line 58 of file LogWndView.h.

Referenced by CLogWndView::OnLButtonDown().

CFont m_ScreenFont

Definition at line 67 of file LogWndView.h.

Referenced by CLogWndView::OnCreate(), CLogWndView::OnDestroy(), and CLogWndView::OnDraw().

Reimplemented from CExTextView.

Definition at line 31 of file LogWndView.h.

Referenced by jbxwl::ExecLogWnd(), and CLogWndView::SetTitle().

CString Title

Reimplemented from CExTextView.

Definition at line 33 of file LogWndView.h.

Referenced by CLogWndView::SetTitle().


The documentation for this class was generated from the following files:

Generated on 15 Nov 2023 for JunkBox_Win_Lib by  doxygen 1.6.1