Move the sources to trunk
[opencv] / apps / Hawk / HawkView.h
1 /*M///////////////////////////////////////////////////////////////////////////////////////
2 //
3 //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4 //
5 //  By downloading, copying, installing or using the software you agree to this license.
6 //  If you do not agree to this license, do not download, install,
7 //  copy or use the software.
8 //
9 //
10 //                        Intel License Agreement
11 //                For Open Source Computer Vision Library
12 //
13 // Copyright (C) 2000, Intel Corporation, all rights reserved.
14 // Third party copyrights are property of their respective owners.
15 //
16 // Redistribution and use in source and binary forms, with or without modification,
17 // are permitted provided that the following conditions are met:
18 //
19 //   * Redistribution's of source code must retain the above copyright notice,
20 //     this list of conditions and the following disclaimer.
21 //
22 //   * Redistribution's in binary form must reproduce the above copyright notice,
23 //     this list of conditions and the following disclaimer in the documentation
24 //     and/or other materials provided with the distribution.
25 //
26 //   * The name of Intel Corporation may not be used to endorse or promote products
27 //     derived from this software without specific prior written permission.
28 //
29 // This software is provided by the copyright holders and contributors "as is" and
30 // any express or implied warranties, including, but not limited to, the implied
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
32 // In no event shall the Intel Corporation or contributors be liable for any direct,
33 // indirect, incidental, special, exemplary, or consequential damages
34 // (including, but not limited to, procurement of substitute goods or services;
35 // loss of use, data, or profits; or business interruption) however caused
36 // and on any theory of liability, whether in contract, strict liability,
37 // or tort (including negligence or otherwise) arising in any way out of
38 // the use of this software, even if advised of the possibility of such damage.
39 //
40 //M*/// HawkView.h : interface of the CHawkView class
41 //
42 /////////////////////////////////////////////////////////////////////////////
43
44 #if !defined(AFX_HAWKVIEW_H__6FFD53B1_939A_11D3_AE7E_00A0C9989BC6__INCLUDED_)
45 #define AFX_HAWKVIEW_H__6FFD53B1_939A_11D3_AE7E_00A0C9989BC6__INCLUDED_
46
47 #if _MSC_VER > 1000
48 #pragma once
49 #endif // _MSC_VER > 1000
50
51 #include "lexer.h"
52
53 typedef struct _ColorScheme
54 {
55     HBRUSH  bkBrush;    // brush used for background
56     int     background; // background color
57     int     selbk;      // selection background
58     int     selfk;      // selection foreground
59     int     clr[10];    //  TOKEN_NORMAL  = 0,
60                         //  TOKEN_COMMENT = 1,
61                         //  TOKEN_STRING  = 2,
62                         //  TOKEN_KEYWORD = 3,
63                         //  TOKEN_NUMBER  = 4,
64 } ColorScheme;
65
66 class CHawkView : public CEditView
67 {
68 protected: // create from serialization only
69         CHawkView();
70         DECLARE_DYNCREATE(CHawkView)
71
72 // Attributes
73 public:
74         CHawkDoc* GetDocument();
75     static HFONT     hFont;
76     static HDC       hMemDC;
77     static HGDIOBJ   hOldBmp;
78     int       cTokens;
79     int       maxTokens;
80     Token*    Tokens;
81     char*     TextBuffer;
82     const int MaxTextBuffer;
83     HACCEL    hAccelTable;
84     const int TAB_SIZE;
85     const int LINE_BUF_SIZE;
86     char*      Line;
87     char*      Space;
88     int       Disable_Update;
89     static ColorScheme Scheme;
90
91 // Operations
92 public:
93     BOOL   Customize();
94     int    ScanTextBuffer( char* text, Token* tokens, int max_tokens );
95     void   RenderHighlightedText( BOOL update = FALSE );
96     POINT  GetCoord( HWND hEdit, int pos );
97     POINT  GetCursorPos();
98     void   GoToLine( int line );
99
100 // Overrides
101         // ClassWizard generated virtual function overrides
102         //{{AFX_VIRTUAL(CHawkView)
103         public:
104         virtual void OnDraw(CDC* pDC);  // overridden to draw this view
105         virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
106         protected:
107         virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
108         virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
109         virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
110         virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
111         virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
112         virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint);
113         //}}AFX_VIRTUAL
114
115 // Implementation
116 public:
117         void UpdateTip();
118         void UpdateCursorPos();
119         CString GetText();
120         CEdit& m_edit;
121         virtual ~CHawkView();
122 #ifdef _DEBUG
123         virtual void AssertValid() const;
124         virtual void Dump(CDumpContext& dc) const;
125 #endif
126
127 protected:
128
129 // Generated message map functions
130 protected:
131         //{{AFX_MSG(CHawkView)
132         afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
133         afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
134         afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
135         afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
136         afx_msg void OnChange();
137     afx_msg HBRUSH CtlColor( CDC* pDC, UINT nCtlColor );
138         afx_msg void OnUntab();
139         afx_msg void OnGoHome();
140         afx_msg void OnGotoLine();
141         afx_msg void OnTimer(UINT nIDEvent);
142         //}}AFX_MSG
143         DECLARE_MESSAGE_MAP()
144 private:
145         static int m_instanceCount;
146 };
147
148 #ifndef _DEBUG  // debug version in HawkView.cpp
149 inline CHawkDoc* CHawkView::GetDocument()
150    { return (CHawkDoc*)m_pDocument; }
151 #endif
152
153 /////////////////////////////////////////////////////////////////////////////
154
155 //{{AFX_INSERT_LOCATION}}
156 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
157
158 #endif // !defined(AFX_HAWKVIEW_H__6FFD53B1_939A_11D3_AE7E_00A0C9989BC6__INCLUDED_)