From c9e9ca41a146c31e55a1b3c4ea83c8907e739fc3 Mon Sep 17 00:00:00 2001 From: msharov Date: Sat, 2 Dec 2006 20:23:14 +0000 Subject: [PATCH] Revised file format to conform to standard IFF layout --- frame.cc | 4 ++-- iedit.cc | 6 ------ iedit.h | 1 - tddoc.cc | 24 ++++++++++++++++-------- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/frame.cc b/frame.cc index d300fb6..94af2f2 100644 --- a/frame.cc +++ b/frame.cc @@ -49,7 +49,6 @@ CTodoFrame::CTodoFrame (void) AddChild (new CTodoList); AddChild (new CItemEditDialog); assert (pane_Last == Children().size()); - SetFocus (pane_Entries); CMenuBar::Instance()->Set (VectorBlock (c_TodoMenu)); } @@ -72,7 +71,8 @@ void CTodoFrame::OnChildClose (uoff_t i) void CTodoFrame::OnResize (rcrect_t wr) { CWindow::OnResize (wr); - Rect menuRect (CW(pane_MenuBar).SizeHints (wr)); + Rect menuRect (wr); + CW(pane_MenuBar).SizeHints (menuRect); MenuBar().OnResize (menuRect); TodoList().OnResize (Rect (0, menuRect.Height(), wr.Width(), wr.Height() - 8 - menuRect.Height())); ItemEditor().OnResize (Rect (0, wr.Height() - 8, wr.Width(), 8)); diff --git a/iedit.cc b/iedit.cc index 1053966..58c7e61 100644 --- a/iedit.cc +++ b/iedit.cc @@ -46,12 +46,6 @@ void CItemEditDialog::OnKey (wchar_t key) } } -void CItemEditDialog::OnGainFocus (void) -{ - CDialog::OnGainFocus(); - SetFocus (ctrl_Text); -} - void CItemEditDialog::SetItem (rcentry_t e) { m_Item = e; diff --git a/iedit.h b/iedit.h index 7548e9e..ff93821 100644 --- a/iedit.h +++ b/iedit.h @@ -19,7 +19,6 @@ public: virtual void OnResize (rcrect_t wr); protected: virtual void OnKey (wchar_t key); - virtual void OnGainFocus (void); virtual void OnUpdate (void); private: enum { diff --git a/tddoc.cc b/tddoc.cc index a615b69..b5d3895 100644 --- a/tddoc.cc +++ b/tddoc.cc @@ -43,6 +43,7 @@ inline CTodoDocument::itemid_t CTodoDocument::GetNextItemId (void) const //--{ Serialization }--------------------------------------------------- static const iff::fmt_t fmt_TodoList = IFF_SFMT("TODO"); +static const iff::fmt_t fmt_Options = IFF_SFMT("OPTS"); static const iff::fmt_t fmt_Item = IFF_SFMT("TITM"); static const iff::fmt_t fmt_Dep = IFF_SFMT("TDEP"); @@ -52,13 +53,14 @@ static const uint32_t c_CurrentVersion = 1; class CTodoHeader { public: - inline CTodoHeader (void) : m_Version (c_CurrentVersion), m_Flags (0) { } - inline void read (istream& is) { is >> m_Version >> m_Flags; } - inline void write (ostream& os) const { os << m_Version << m_Flags; } - inline size_t stream_size (void) const { return (stream_size_of (m_Version) + stream_size_of (m_Flags)); } + inline CTodoHeader (void) : m_Version (c_CurrentVersion), m_Flags (0), m_Reserved (0) { } + inline void read (istream& is) { is >> m_Version >> m_Flags >> m_Reserved; } + inline void write (ostream& os) const { os << m_Version << m_Flags << m_Reserved; } + inline size_t stream_size (void) const { return (stream_size_of (m_Version) + stream_size_of (m_Flags) + stream_size_of(m_Reserved)); } public: uint32_t m_Version; ///< File format's version number. bitset<32> m_Flags; ///< Various flags. None for now. + uint32_t m_Reserved; ///< Future functionality. }; STD_STREAMABLE (CTodoHeader) @@ -66,18 +68,23 @@ STD_STREAMABLE (CTodoHeader) /// Reads the object from stream \p is. void CTodoDocument::read (istream& is) { + iff::CGroupHeader fileHeader; + iff::ReadGroupHeader ("TODO file", is, fileHeader, fmt_TodoList, iff::cfmt_FORM); CTodoHeader h; - iff::ReadChunk (is, h, fmt_TodoList); + iff::ReadChunk (is, h, fmt_Options); iff::ReadVector (is, m_Todos, fmt_Item); iff::ReadVector (is, m_Deps, fmt_Dep); + iff::VerifyChunkSize ("TODO file", 0, is.pos(), fileHeader.SizeWithHeader()); VerifyData(); } /// Writes the object to stream \p os. void CTodoDocument::write (ostream& os) const { - CTodoHeader h; - iff::WriteChunk (os, h, fmt_TodoList); + const size_t dataSize = stream_size() - stream_size_of(iff::CGroupHeader()); + iff::CGroupHeader fileHeader (dataSize, fmt_TodoList, iff::cfmt_FORM); + os << fileHeader; + iff::WriteChunk (os, CTodoHeader(), fmt_Options); iff::WriteVector (os, m_Todos, fmt_Item); iff::WriteVector (os, m_Deps, fmt_Dep); } @@ -85,7 +92,8 @@ void CTodoDocument::write (ostream& os) const /// Returns the size of the written object. size_t CTodoDocument::stream_size (void) const { - return (iff::chunk_size_of (CTodoHeader()) + + return (stream_size_of(iff::CGroupHeader()) + + iff::chunk_size_of (CTodoHeader()) + iff::vector_size_of (m_Todos) + iff::vector_size_of (m_Deps)); } -- 2.11.4.GIT