OSDN Git Service

Add GetReadOnly(), SetReadOnly(), IsUndoable(), IsRedoable() to IImgMergeWindow
authorsdottaka <sdottaka@sourceforge.net>
Mon, 22 Sep 2014 07:39:15 +0000 (16:39 +0900)
committersdottaka <sdottaka@sourceforge.net>
Mon, 22 Sep 2014 07:39:15 +0000 (16:39 +0900)
src/CImgMergeWindow.hpp
src/WinIMergeLib.h

index 0082156..b1b7c01 100644 (file)
@@ -191,8 +191,8 @@ struct UndoRecords
        {\r
                if (m_currentUndoBufIndex >= static_cast<int>(m_undoBuf.size()) - 1)\r
                        throw "no redoable";\r
-               const UndoRecord& rec = m_undoBuf[m_currentUndoBufIndex];\r
                ++m_currentUndoBufIndex;\r
+               const UndoRecord& rec = m_undoBuf[m_currentUndoBufIndex];\r
                return rec;\r
        }\r
 \r
@@ -405,8 +405,12 @@ public:
                , m_oldSplitPosX(-4)\r
                , m_oldSplitPosY(-4)\r
        {\r
-               memset(m_ChildWndProc, 0, sizeof(m_ChildWndProc));\r
-               memset(m_currentPage, 0, sizeof(m_currentPage));\r
+               for (int i = 0; i < 3; ++i)\r
+               {\r
+                       m_ChildWndProc[i] = NULL;\r
+                       m_currentPage[i] = 0;\r
+                       m_bRO[i] = false;\r
+               }\r
        }\r
 \r
        ~CImgMergeWindow()\r
@@ -490,6 +494,20 @@ public:
                m_imgWindow[pane].SetFocus();\r
        }\r
 \r
+       bool GetReadOnly(int pane) const\r
+       {\r
+               if (pane < 0 || pane >= m_nImages)\r
+                       return true;\r
+               return m_bRO[pane];\r
+       }\r
+\r
+       void SetReadOnly(int pane, bool readOnly)\r
+       {\r
+               if (pane < 0 || pane >= m_nImages)\r
+                       return;\r
+               m_bRO[pane] = readOnly;\r
+       }\r
+\r
        bool GetHorizontalSplit() const\r
        {\r
                return m_bHorizontalSplit;\r
@@ -839,6 +857,8 @@ public:
                        return;\r
                if (diffIndex < 0 || diffIndex >= m_diffCount)\r
                        return;\r
+               if (m_bRO[dstPane])\r
+                       return;\r
 \r
                FIBITMAP *oldbitmap = FreeImage_Clone(m_imgOrig32[dstPane]);\r
 \r
@@ -903,6 +923,16 @@ public:
                return m_undoRecords.is_modified(pane);\r
        }\r
 \r
+       bool IsUndoable() const\r
+       {\r
+               return m_undoRecords.undoable();\r
+       }\r
+\r
+       bool IsRedoable() const\r
+       {\r
+               return m_undoRecords.redoable();\r
+       }\r
+\r
        bool Undo()\r
        {\r
                if (!m_undoRecords.undoable())\r
@@ -1029,6 +1059,8 @@ public:
        {\r
                if (pane < 0 || pane >= m_nImages)\r
                        return false;\r
+               if (m_bRO[pane])\r
+                       return false;\r
                if (!m_undoRecords.is_modified(pane))\r
                        return true;\r
                m_undoRecords.save(pane);\r
@@ -1783,6 +1815,7 @@ private:
        WNDPROC m_ChildWndProc[3];\r
        std::vector<EventListenerInfo> m_listener;\r
        std::wstring m_filename[3];\r
+       bool m_bRO[3];\r
        int m_nDraggingSplitter;\r
        bool m_bHorizontalSplit;\r
        int m_oldSplitPosX;\r
index 4ce4660..9936c17 100644 (file)
@@ -55,6 +55,8 @@ struct IImgMergeWindow
        virtual bool SetWindowRect(const RECT& rc) = 0;\r
        virtual int  GetActivePane() const = 0;\r
        virtual void SetActivePane(int pane) = 0;\r
+       virtual bool GetReadOnly(int pane) const = 0;\r
+       virtual void SetReadOnly(int pane, bool readOnly) = 0;\r
        virtual bool GetHorizontalSplit() const = 0;\r
        virtual void SetHorizontalSplit(bool horizontalSplit) = 0;\r
        virtual int  GetCurrentPage(int pane) const = 0;\r
@@ -100,6 +102,8 @@ struct IImgMergeWindow
        virtual int  GetNextConflictIndex() const = 0;\r
        virtual int  GetPrevConflictIndex() const = 0;\r
        virtual void CopyDiff(int diffIndex, int srcPane, int dstPane) = 0;\r
+       virtual bool IsUndoable() const = 0;\r
+       virtual bool IsRedoable() const = 0;\r
        virtual bool Undo() = 0;\r
        virtual bool Redo() = 0;\r
        virtual bool IsModified(int pane) const = 0;\r