home *** CD-ROM | disk | FTP | other *** search
/ ftp.funduc.com / 2014.08.ftp.funduc.com.tar / ftp.funduc.com / fshedcode-072212.zip / fshedView.h < prev    next >
C/C++ Source or Header  |  2011-01-14  |  12KB  |  298 lines

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