home *** CD-ROM | disk | FTP | other *** search
/ ftp.funduc.com / 2014.08.ftp.funduc.com.tar / ftp.funduc.com / fshedcode102502.zip / fshedView.h < prev    next >
C/C++ Source or Header  |  2002-10-25  |  10KB  |  279 lines

  1. // fshedView.h : interface of the CFshedView class
  2. //
  3. /////////////////////////////////////////////////////////////////////////////
  4.  
  5. #if !defined(AFX_FSHEDVIEW_H__BD87E553_34CD_11D5_B4F0_00B0D0719D70__INCLUDED_)
  6. #define AFX_FSHEDVIEW_H__BD87E553_34CD_11D5_B4F0_00B0D0719D70__INCLUDED_
  7.  
  8. #if _MSC_VER > 1000
  9. #pragma once
  10. #endif // _MSC_VER > 1000
  11.  
  12. #include "fshedDoc.h"
  13. #include "FindDlg.h"
  14.  
  15. //--------------------------------------------------------------------------------------------
  16. // MAKROS
  17. #define CHARSTART (App->m_iOffsetLen + m_stScreenSettings.iByteSpace + App->m_iBytesPerLine * 3 + m_stScreenSettings.iCharSpace)
  18. #define BYTEPOS (m_stScreenSettings.iCurByte % App->m_iBytesPerLine)
  19. #define BYTELINE (m_stScreenSettings.iCurByte / App->m_iBytesPerLine)
  20. #define BYTES_LOGICAL_COLUMN (App->m_iOffsetLen + m_stScreenSettings.iByteSpace + BYTEPOS * 3 + m_stScreenSettings.iCurNibble)
  21. #define CHARS_LOGICAL_COLUMN (CHARSTART + BYTEPOS)
  22. #define LAST_LOG_COLUMN (m_stScreenSettings.iHscrollPos + m_stScreenSettings.cxBuffer - 1) // Last visible logical column.
  23. #define CURSOR_TOO_HIGH (m_stScreenSettings.iCurLine > BYTELINE)
  24. #define CURSOR_TOO_LOW (m_stScreenSettings.iCurLine + m_stScreenSettings.cyBuffer - 1 < BYTELINE)
  25. #define LAST_VISIBLE_LINE (m_stScreenSettings.iCurLine + m_stScreenSettings.cyBuffer - 1)
  26. #define LASTLINE (m_stScreenSettings.iNumlines - 1)
  27. #define STARTSELECTION_LINE (iStartOfSelection / App->m_iBytesPerLine)
  28. #define ENDSELECTION_LINE (iEndOfSelection / App->m_iBytesPerLine)
  29. #define IN_BOUNDS( i, a, b ) ( ( i >= a && i <= b ) || ( i >= b && i <= a ) )
  30. #define BYTES 0 // for EnteringMode
  31. #define CHARS 1
  32. #define WM_F1DOWN (WM_USER+1)
  33.  
  34. class CScreenSettings
  35. {
  36. public:
  37.     int cxChar, cxCaps, cyChar, cxClient, cyClient, cxBuffer, cyBuffer, iNumlines,
  38.         iVscrollMax, iVscrollPos, iVscrollInc,
  39.         iHscrollMax, iHscrollPos, iHscrollInc,
  40.         iCurLine, iCurByte, iCurNibble;
  41.     int iByteSpace,    iCharSpace, iCharsPerLine;
  42.    int iToolbarHeight;
  43.  
  44.    CScreenSettings()
  45.    {
  46.       memset(this, 0, sizeof(CScreenSettings));
  47.    }
  48.    void CopySettings(CScreenSettings &rSettings)
  49.    {
  50.       memcpy(this, &rSettings, sizeof(CScreenSettings));
  51.    }
  52. };
  53.  
  54. class CFshedView : public CView
  55. {
  56. protected: // create from serialization only
  57.     CFshedView();
  58.     DECLARE_DYNCREATE(CFshedView)
  59.  
  60. // Attributes
  61. public:
  62.     CFshedDoc* GetDocument();
  63.  
  64. // Operations
  65. public:
  66.  
  67.     CScreenSettings m_stScreenSettings;
  68. // Overrides
  69.     // ClassWizard generated virtual function overrides
  70.     //{{AFX_VIRTUAL(CFshedView)
  71.     public:
  72.     virtual void OnDraw(CDC* pDC);  // overridden to draw this view
  73.     virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  74.     protected:
  75.     virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
  76.     virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
  77.     virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
  78.     virtual void OnPrint(CDC* pDC, CPrintInfo* pInfo);
  79.     virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint);
  80.     //}}AFX_VIRTUAL
  81.  
  82.    int update_MRU ();
  83.    int make_MRU_list (HMENU menu);
  84.    int find_byte_pos (const char* src, char c);
  85.    int create_bc_translation (char* dest, const char* src, int srclen, int charmode, int binmode);
  86.    int translate_bytecode (char* dest, const char* src, int srclen, int binmode);
  87.    int calc_bctrans_destlen (const char* src, int srclen);
  88.    int is_bytecode (const char* src, int len);
  89.    int create_bc_translation (char** ppd, const char* src, int srclen, int charmode, int binmode);
  90.    int translate_bytes_to_BC (CString &strTranslated, unsigned char* src, int srclen);
  91.    int byte_to_BC_destlen (char* src, int srclen);
  92.    void update_for_new_datasize ();
  93.    char TranslateAnsiToOem (char c);
  94.    int resize_window (int cx, int cy);
  95.    void set_wnd_title();
  96.    void set_caret_pos ();
  97.    int repaint( int line =-1);
  98.    void clear_all ();
  99.    void adjust_vscrollbar ();
  100.    void adjust_hscrollbar ();
  101.    int  make_font ();
  102.    void print_line (HDC hdc, int line, char* linbuf, HBRUSH hbr );
  103.    void mark_char (HDC hdc);
  104.    void draw_client_border (HDC hdc);
  105.    int  character (char ch);
  106.    int  keydown (int key);
  107.    void adjust_view_for_caret ();
  108.    int  timer ();
  109.    void adjust_view_for_selection ();
  110.    int  transl_binary_to_text( SimpleString& dest, char* src, int len );
  111.    int  findnext();
  112.    int  findprev();
  113.    int  GotoBookmark( int cmd );
  114.  
  115.    CFont *m_cfPrintFont;
  116.    BOOL   m_bPrinting;
  117.    CScreenSettings m_saveSettings;
  118.  
  119. // Implementation
  120. public:
  121.     virtual ~CFshedView();
  122. #ifdef _DEBUG
  123.     virtual void AssertValid() const;
  124.     virtual void Dump(CDumpContext& dc) const;
  125. #endif
  126.  
  127.    // String containing data to replace.
  128.    CString strToReplaceData;
  129.    // String containing data to replace with.
  130.    SimpleString strReplaceWithData;
  131.  
  132.    CFindDlg m_dlgFind;
  133.    BOOL m_bFirstSearch;
  134.     CFindReplaceDialog* m_pFindReplaceDlg; // find or replace dialog
  135.     BOOL m_bFindOnly; // Is pFindReplace the find or replace?
  136.     CString m_strFind;    // last find string
  137.     CString m_strReplace; // last replace string
  138.     BOOL m_bCase; // TRUE==case sensitive, FALSE==not
  139.     int m_bNext;  // TRUE==search down, FALSE== search up
  140.     BOOL m_bWord; // TRUE==match whole word, FALSE==not
  141.    long m_lInitialSearchPos; 
  142.  
  143.    char *pcGotoDlgBuffer;
  144.    int iGotoDlgBufLen;
  145.    int bOpenReadOnlySetting;
  146.    unsigned int iStartPL, iNumBytesPl, iPLFileLen;
  147.    bookmark *pbmkRemove;
  148.    int iDecValDlgOffset, iDecValDlgValue, iDecValDlgSize, iDecValDlgTimes;
  149.    int iCutMode;
  150.    int iManipPos;
  151.    char szFileName[_MAX_PATH];
  152.    int iDestFileLen, iSrcFileLen;
  153.    intpair* pdiffChoice;
  154.    int iDiffNum;
  155.    char* pcTmplText;
  156.  
  157.    public:
  158.     int iWindowShowCmd, iWindowX, iWindowY, iWindowWidth, iWindowHeight;
  159.  
  160. private:
  161.     int bDontMarkCurrentPos;
  162.     int bInsertingHex;
  163.     SimpleArray<char> Linebuffer;
  164.     int iHexWidth;
  165.     int iBmkCount;
  166.     bookmark pbmkList[BMKMAX];
  167.     int iUpdateLine;
  168.     int bTimerSet;
  169.     int iMouseX, iMouseY;
  170.     HFONT hFont;
  171.     int iInsertMode;
  172.     int iTextColor, iBkColor, iSelBkColor, iSelTextColor;
  173. //    COLORREF iTextColorValue, iBkColorValue, iSepColorValue;
  174. //    COLORREF iSelBkColorValue, iSelTextColorValue;
  175. //    COLORREF iBmkColor;
  176.     int bSelected;
  177.     int bLButtonIsDown, iLBDownX, iLBDownY;
  178.     int iStartOfSelection, iEndOfSelection;
  179.     int m_iEnteringMode;
  180.     HWND hwndStatusBar, hwndToolBar, hwndHBar, hwndVBar;
  181.  
  182. public:
  183.    void HideSelection( BOOL bHide, BOOL bPerm );
  184.    CString GetSelText( );
  185.    void GetSel( CHARRANGE& cr ) const;
  186.    void GetSel( long& nStartChar, long& nEndChar ) const;
  187.    long GetTextLength( );
  188.    void SetSel( CHARRANGE& cr );
  189.    void SetSel( long nStartChar, long nEndChar );
  190.    void ReplaceSel( LPCTSTR lpszNewText, BOOL bCanUndo = FALSE );
  191.    long FindText( DWORD dwFlags, BOOL m_bNext, FINDTEXTEX* pFindText );
  192.    CPoint GetCharPos( long lChar ) const;
  193.  
  194. protected:
  195.     int save_ini_data ();
  196.     int read_ini_data ();
  197.  
  198.    void AdjustDialogPosition(CDialog* pDlg);
  199.    void OnReplaceSel(LPCTSTR lpszFind, BOOL bNext, BOOL bCase,
  200.                    BOOL bWord, LPCTSTR lpszReplace);
  201.    void OnReplaceAll(LPCTSTR lpszFind, LPCTSTR lpszReplace, BOOL bCase, BOOL bWord);
  202.    BOOL SameAsSelected(LPCTSTR lpszCompare, BOOL bCase, BOOL bWord);
  203.    long FindAndSelect(DWORD dwFlags, FINDTEXTEX& ft, BOOL m_bNext);
  204.    void TextNotFound(LPCTSTR lpszFind);
  205.    void OnTextNotFound(LPCTSTR);
  206.     BOOL FindText(LPCTSTR lpszFind, BOOL bCase = TRUE, BOOL bWord = TRUE, BOOL m_bNext = TRUE);
  207.     BOOL FindTextSimple(LPCTSTR lpszFind, BOOL bCase = TRUE,
  208.         BOOL bWord = TRUE, BOOL m_bNext = TRUE);
  209.    void OnEditFindReplace(BOOL bFindOnly = TRUE);
  210.    afx_msg LRESULT OnFindReplaceCmd(WPARAM, LPARAM lParam);
  211.    void OnFindNext(LPCTSTR lpszFind, BOOL bNext, BOOL bCase, BOOL bWord);
  212.  
  213.    // Generated message map functions
  214. protected:
  215.     //{{AFX_MSG(CFshedView)
  216.     afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  217.     afx_msg void OnPaint();
  218.     afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  219.     afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  220.     afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  221.     afx_msg void OnSize(UINT nType, int cx, int cy);
  222.     afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  223.     afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
  224.     afx_msg void OnTimer(UINT nIDEvent);
  225.     afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
  226.     afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
  227.     afx_msg void OnKillFocus(CWnd* pNewWnd);
  228.     afx_msg void OnSetFocus(CWnd* pOldWnd);
  229.     afx_msg void OnEditFind();
  230.     afx_msg void OnEditCut();
  231.     afx_msg void OnEditCopy();
  232.     afx_msg void OnEditPaste();
  233.     afx_msg void OnEditRepeat();
  234.     afx_msg void OnEditReplace();
  235.     afx_msg void OnBookmark(UINT nId);
  236.     afx_msg void OnRemoveBkm();
  237.     afx_msg void OnClearallBmk();
  238.     afx_msg void OnAddbookmark();
  239.     afx_msg void OnCopyHexdump();
  240.     afx_msg void OnInsertfile();
  241.     afx_msg void OnSaveselas();
  242.     afx_msg void OnEditClear();
  243.     afx_msg void OnEditSelectAll();
  244.     afx_msg void OnInsertmodetoggle();
  245.     afx_msg void OnChangeMode();
  246.     afx_msg void OnEditReadonlymode();
  247.     afx_msg void OnEditAppend();
  248.     afx_msg void OnEditManipulatebits();
  249.     afx_msg void OnViewOptions();
  250.     afx_msg void OnSelectBlock();
  251.     afx_msg void OnReadfloat();
  252.     afx_msg void OnProperties();
  253.     afx_msg void OnRevert();
  254.     afx_msg void OnBookmarksGotobookmark();
  255.     afx_msg void OnUpdateBookmarksGotobookmark(CCmdUI* pCmdUI);
  256.     afx_msg void OnEditPasteSpecial();
  257.     //}}AFX_MSG
  258.     DECLARE_MESSAGE_MAP()
  259. };
  260.  
  261. #ifndef _DEBUG  // debug version in fshedView.cpp
  262. inline CFshedDoc* CFshedView::GetDocument()
  263.    { return (CFshedDoc*)m_pDocument; }
  264. #endif
  265.  
  266. #define Doc (GetDocument())
  267.  
  268. void count_instances();
  269. int find_bytes (char* ps, int ls, char* pb, int lb, int mode, char (*cmp) (char));
  270. int find_bytes (char* ps, int ls, char* pb, int lb, long lStartSel, long lEndSel, 
  271.                 int mode, BOOL bCaseSensitive, BOOL bWholeWord);
  272.  
  273. /////////////////////////////////////////////////////////////////////////////
  274.  
  275. //{{AFX_INSERT_LOCATION}}
  276. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  277.  
  278. #endif // !defined(AFX_FSHEDVIEW_H__BD87E553_34CD_11D5_B4F0_00B0D0719D70__INCLUDED_)
  279.