[Libreoffice-commits] .: Branch 'feature/layout' - vcl/inc vcl/prj vcl/source
Ricardo Cruz
rpmcruz at kemper.freedesktop.org
Thu Dec 16 05:03:00 PST 2010
vcl/inc/vcl/align.hxx | 32 +-
vcl/inc/vcl/box.hxx | 45 ++-
vcl/inc/vcl/buttonbox.hxx | 57 +++++
vcl/inc/vcl/layout.hxx | 118 ++++++++--
vcl/inc/vcl/ldialog.hxx | 27 +-
vcl/inc/vcl/notebook.hxx | 27 +-
vcl/inc/vcl/table.hxx | 50 ++--
vcl/inc/vcl/xmlparser.hxx | 28 ++
vcl/prj/build.lst | 1
vcl/prj/d.lst | 10
vcl/source/control/align.cxx | 82 -------
vcl/source/control/box.cxx | 214 ------------------
vcl/source/control/ldialog.cxx | 321 ----------------------------
vcl/source/control/notebook.cxx | 141 ------------
vcl/source/control/table.cxx | 175 ---------------
vcl/source/layout/align.cxx | 96 ++++++++
vcl/source/layout/box.cxx | 223 +++++++++++++++++++
vcl/source/layout/buttonbox.cxx | 93 ++++++++
vcl/source/layout/layout.cxx | 452 ++++++++++++++++++++++++++++++++++++++++
vcl/source/layout/ldialog.cxx | 133 +++++++++++
vcl/source/layout/makefile.mk | 61 +++++
vcl/source/layout/notebook.cxx | 172 +++++++++++++++
vcl/source/layout/table.cxx | 259 ++++++++++++++++++++++
vcl/source/layout/xmlparser.cxx | 111 +++++++++
24 files changed, 1904 insertions(+), 1024 deletions(-)
New commits:
commit 1d6b3667772601866bf532eacc5bb16b1e3134a1
Author: Ricardo Cruz <rpmcruz at alunos.dcc.fc.up.pt>
Date: Thu Dec 16 11:44:39 2010 +0000
New Layout class; functional QueueResize(); several other layout work.
diff --git a/vcl/inc/vcl/align.hxx b/vcl/inc/vcl/align.hxx
index 998ddb7..b198e64 100644
--- a/vcl/inc/vcl/align.hxx
+++ b/vcl/inc/vcl/align.hxx
@@ -21,35 +21,45 @@
#ifndef VCL_BOX_HXX
#define VCL_BOX_HXX
-#include <vcl/window.hxx>
#include <vcl/layout.hxx>
/* Lays various widgets in a row or column.
*/
-class VCL_DLLPUBLIC Align : public Window, Layout
+class Align : public Layout
{
public:
- Align (Window *parent, float xalign, float yalign, float xscale, float yscale);
+ Align (float xalign, float yalign, float xscale, float yscale);
- virtual void AddChild (Window *child) = 0;
- virtual void RemoveChild (Window *child) = 0;
- virtual std::list <Window *> GetChildren (Window *child) const = 0;
+ void AddChild (Window *child);
+ void AddChild (Layout *child);
+
+ virtual void AddChild (Widget &child);
+ virtual void RemoveChild (Widget &child);
+ virtual std::list <Widget> GetChildren() const;
+
+ virtual void SetParent (Widget &parent) { m_parent = parent; }
+ virtual Widget GetParent() const { return m_parent; }
virtual void SetBorderWidth (int borderWidth);
- virtual Size GetOptimalSize (WindowSizeType type = WINDOWSIZE_PREFERRED) const;
- virtual void SetPosSizePixel (long x, long y, long width, long height,
- USHORT flags = WINDOW_POSSIZE_ALL);
+ virtual void InvalidateSize() { m_requisition = Size (0, 0); }
+ virtual Size SizeRequest();
+ virtual void SizeAllocate (long x, long y, long width, long height);
+ virtual Rectangle GetAllocation() const { return m_allocation; }
protected:
float m_xalign, m_yalign, m_xscale, m_yscale;
+ int m_borderWidth;
+ Size m_requisition;
+ Rectangle m_allocation;
+ Widget m_parent, m_child;
};
-class VCL_DLLPUBLIC AlignCenter : public Align
+class AlignCenter : public Align
{
public:
- AlignCenter (Window *parent) : Align (parent, .5, .5, 0, 0) {}
+ AlignCenter() : Align (.5, .5, 0, 0) {}
};
#endif /* VCL_BOX_HXX */
diff --git a/vcl/inc/vcl/box.hxx b/vcl/inc/vcl/box.hxx
index 34d4800..619d2a2 100644
--- a/vcl/inc/vcl/box.hxx
+++ b/vcl/inc/vcl/box.hxx
@@ -21,39 +21,46 @@
#ifndef VCL_BOX_HXX
#define VCL_BOX_HXX
-#include <vcl/window.hxx>
#include <vcl/layout.hxx>
/* Lays various widgets in a row or column.
*/
-class VCL_DLLPUBLIC Box : public Window, Layout
+class Box : public Layout
{
public:
enum Orientation { HORIZONTAL, VERTICAL };
Orientation GetOrientation() const { return m_orientation; }
void Pack (Window *child, bool expand, bool fill);
+ void Pack (Layout *child, bool expand, bool fill);
+ void Pack (Window *wchild, Layout *lchild, bool expand, bool fill);
- virtual void AddChild (Window *child) = 0;
- virtual void RemoveChild (Window *child) = 0;
- virtual std::list <Window *> GetChildren (Window *child) const = 0;
+ virtual void AddChild (Widget &child);
+ virtual void RemoveChild (Widget &child);
+ virtual std::list <Widget> GetChildren() const;
+
+ virtual void SetParent (Widget &parent) { m_parent = parent; }
+ virtual Widget GetParent() const { return m_parent; }
virtual void SetBorderWidth (int borderWidth);
- virtual Size GetOptimalSize (WindowSizeType type = WINDOWSIZE_PREFERRED) const;
- virtual void SetPosSizePixel (long x, long y, long width, long height,
- USHORT flags = WINDOW_POSSIZE_ALL);
+ virtual void InvalidateSize() { m_requisition = Size (0, 0); }
+ virtual Size SizeRequest();
+ virtual void SizeAllocate (long x, long y, long width, long height);
+ virtual Rectangle GetAllocation() const { return m_allocation; }
protected:
- Box (Window *parent, Orientation orientation, bool homogeneous, int spacing);
+ Box (Orientation orientation, bool homogeneous, int spacing);
+
+ void Pack (Widget &widget, bool expand, bool fill);
struct ChildData {
- ChildData (Window *child, bool expand, bool fill);
+ ChildData (Widget &child, bool expand, bool fill);
- Window *window;
+ Widget widget;
int expand : 2, fill : 2;
- Size requisition; /* cached */
+ Size requisition; // cache
};
friend struct CmpChild;
@@ -61,16 +68,18 @@ protected:
int m_homogeneous : 2, m_spacing, m_borderWidth;
std::list <ChildData> m_children;
Size m_requisition; /* cached */
+ Rectangle m_allocation;
+ Widget m_parent;
};
-struct VCL_DLLPUBLIC HBox : public Box {
- HBox (Window *parent, bool homogeneous, int spacing)
- : Box (parent, HORIZONTAL, homogeneous, spacing) {}
+struct HBox : public Box {
+ HBox (bool homogeneous, int spacing)
+ : Box (HORIZONTAL, homogeneous, spacing) {}
};
-struct VCL_DLLPUBLIC VBox : public Box {
- VBox (Window *parent, bool homogeneous, int spacing)
- : Box (parent, VERTICAL, homogeneous, spacing) {}
+struct VBox : public Box {
+ VBox (bool homogeneous, int spacing)
+ : Box (VERTICAL, homogeneous, spacing) {}
};
#endif /* VCL_BOX_HXX */
diff --git a/vcl/inc/vcl/buttonbox.hxx b/vcl/inc/vcl/buttonbox.hxx
new file mode 100644
index 0000000..9cec0e0
--- /dev/null
+++ b/vcl/inc/vcl/buttonbox.hxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef VCL_BOX_HXX
+#define VCL_BUTTON_BOX_HXX
+
+#include <vcl/box.hxx>
+#include <map>
+
+/* Places buttons according to their "roles" as specified by
+ the user's desktop.
+*/
+
+class Button;
+
+class ButtonBox : public HBox
+{
+public:
+ ButtonBox();
+
+ enum Role {
+ OK_BUTTON, CANCEL_BUTTON, APPLY_BUTTON, HELP_BUTTON, CUSTOM_BUTTON
+ };
+
+ void Pack (Button *button, Role role);
+
+ virtual void RemoveChild (Widget &child);
+
+ virtual void SizeAllocate (long x, long y, long width, long height);
+
+protected:
+ friend struct ChildOrder;
+
+// FIXME: change to list
+// std::map <Widget, Role> m_roles;
+};
+
+#endif /* VCL_BUTTON_BOX_HXX */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/vcl/layout.hxx b/vcl/inc/vcl/layout.hxx
index 89937a9..6dbf708 100644
--- a/vcl/inc/vcl/layout.hxx
+++ b/vcl/inc/vcl/layout.hxx
@@ -21,41 +21,113 @@
#ifndef VCL_LAYOUT_HXX
#define VCL_LAYOUT_HXX
-#include <vcl/window.hxx>
#include <list>
+#include <tools/gen.hxx>
+#include <stdio.h>
+
+class Window;
+class Layout;
+
+/* Container that encapsulates Window and Layout implementations.
+*/
+
+class Widget
+{
+public:
+ Widget (Window *window);
+ Widget (Layout *layout);
+ Widget (Window *window, Layout *layout);
+
+ bool isNull() const;
+
+ std::list <Widget> GetChildren() const;
+ void SetParent (Widget &parent);
+ void SetParent (Layout *layout); // convenience
+ // use when Layout and Window parents must differ:
+ // FIXME: this will break down when introducing a new Window to a Layout direct child
+ void SetParent (Widget &parent, Window *parent_window);
+ Widget GetParent() const;
+ bool IsChild (Widget &parent) const;
+
+ bool IsVisible() const;
+ void ShowAll();
+
+ Size SizeRequest();
+ void SizeAllocate (long x, long y, long width, long height);
+ void SizeAllocate (const Rectangle &rect);
+
+ void InvalidateSize();
+ bool HasSizeChanged();
+ Rectangle GetAllocation() const;
+
+// bool operator == (Widget &other) const;
+ bool operator == (Widget other) const;
+ bool operator != (Widget &other) const;
+
+ static Widget NIL;
+
+private:
+ Window *GetParentWindow() const;
+ void SetParentWindow (Window *parent);
+
+ typedef void (* ForeachCallback) (Widget &widget);
+ void Foreach (ForeachCallback callback);
+ static void ShowWidget (Widget &widget);
+
+ Window *m_window;
+ Layout *m_layout;
+};
/* Interface implemented by containers.
*/
-class VCL_DLLPUBLIC Layout
+class Layout
{
- Layout();
+public:
+ // Common methods to manipulate layout children: containers may
+ // specificy extra methods with extra arguments detailing the
+ // child placement policy.
+
+ virtual void AddChild (Widget &child) = 0;
+ virtual void RemoveChild (Widget &child) = 0;
+ virtual std::list <Widget> GetChildren() const = 0;
- virtual void AddChild (Window *child) = 0;
- virtual void RemoveChild (Window *child) = 0;
- virtual std::list <Window *> GetChildren() const = 0;
+ virtual void SetParent (Widget &parent) = 0;
+ virtual Widget GetParent() const = 0;
+
+ // It's nice to have a common way to add a simple border to all
+ // containers across the board.
virtual void SetBorderWidth (int borderWidth) = 0;
- // TODO: move to Window
- void QueueResize();
- void ShowAll();
+ // Optional optimization method: to speed up the layouting, you can
+ // return a cache for GetOptimalSize(), which you should clear when
+ // this method is called.
- static Size SizeRequest (Window *widget);
- static void SizeAllocate (Window *widget, long x, long y, long width, long height);
+ virtual void InvalidateSize() = 0;
- Size SizeRequest();
- Size SizeAllocate (long x, long y, long width, long height);
+ virtual Size SizeRequest() = 0;
+ virtual void SizeAllocate (long x, long y, long width, long height) = 0;
-protected:
- virtual Size ImplSizeRequest() const = 0;
- virtual Size ImplSizeAllocate (long x, long y, long width, long height) = 0;
- virtual void ImplShow() = 0;
+ virtual Rectangle GetAllocation() const = 0;
- Size m_requisition;
- bool m_reqDirty, m_allocDirty;
+ // Internal method:
+ // Call this method when the size of your widget or container may have
+ // changed, to issue a layout recalculation order.
+ // It is a static method: you don't need to implement the Layout interface
+ // to take advantage of it.
+ static void QueueResize (Layout *layout);
+ static void QueueResize (Window *window);
+ static void QueueResize (Window *window, Layout *layout);
+ static void QueueResize (Widget &widget);
+ // Public method:
+ // Calls Window::Show() for every sub-branch
+
+ static void ShowAll (Layout *layout);
+
+ // TODO:
#if 0
virtual std::list <std::string> ListProperties() const;
@@ -68,14 +140,6 @@ protected:
virtual any GetLayoutProperty (Window *child, const std::string &prop) const;
virtual void SetLayoutProperty (Window *child, const std::string &prop, const any &value);
#endif
-
-#if 0
- // When implementing a container, don't forget to overload Window methods:
-
- virtual Size GetOptimalSize (WindowSizeType type = WINDOWSIZE_PREFERRED) const;
- virtual void SetPosSizePixel (long x, long y, long width, long height,
- USHORT flags = WINDOW_POSSIZE_ALL);
-#endif
};
#endif /* VCL_BOX_HXX */
diff --git a/vcl/inc/vcl/ldialog.hxx b/vcl/inc/vcl/ldialog.hxx
index 30aa569..6a0e572 100644
--- a/vcl/inc/vcl/ldialog.hxx
+++ b/vcl/inc/vcl/ldialog.hxx
@@ -36,19 +36,32 @@ public:
// over-rule layout sizing: pass 0 to disable
void SetDefaultSize (long width, long height);
- virtual void AddChild (Window *child);
- virtual void RemoveChild (Window *child);
- virtual std::list <Window *> GetChildren (Window *child) const;
+ void AddChild (Window *child);
+ void AddChild (Layout *child);
+
+ virtual void AddChild (Widget &child);
+ virtual void RemoveChild (Widget &child);
+ virtual std::list <Widget> GetChildren() const;
+
+ virtual void SetParent (Widget &) {}
+ virtual Widget GetParent() const { return Widget (Window::GetParent()); }
virtual void SetBorderWidth (int borderWidth); // refers to the inner border
- virtual void ShowAll();
+ virtual void InvalidateSize() {}
+ virtual Size SizeRequest();
+ virtual void SizeAllocate (long x, long y, long width, long height);
+ virtual Rectangle GetAllocation() const
+ { return Rectangle (GetPosPixel(), GetSizePixel()); }
+
+ Size SizePreferred();
- virtual Size GetOptimalSize (WindowSizeType type = WINDOWSIZE_PREFERRED) const;
- virtual void SetPosSizePixel (long x, long y, long width, long height,
- USHORT flags = WINDOW_POSSIZE_ALL);
+ virtual void StateChanged (StateChangedType type);
+ virtual void Resize();
protected:
+ Widget m_child;
+ int m_autoResize : 2;
int m_borderWidth;
long m_defaultWidth, m_defaultHeight;
};
diff --git a/vcl/inc/vcl/notebook.hxx b/vcl/inc/vcl/notebook.hxx
index 2f04f37..a22f288 100644
--- a/vcl/inc/vcl/notebook.hxx
+++ b/vcl/inc/vcl/notebook.hxx
@@ -28,30 +28,37 @@
/* Adds dynamic layouting to TabControl.
*/
-class VCL_DLLPUBLIC Notebook : public TabControl, Layout
+class VCL_DLLPUBLIC Notebook : public TabControl, public Layout
{
public:
Notebook (Window *parent);
void AddPage (const String &label, Window *child);
+ void AddPage (const String &label, Layout *child);
- Window *GetCurChild() const;
+ virtual void AddChild (Widget &child);
+ virtual void RemoveChild (Widget &child);
+ virtual std::list <Widget> GetChildren() const;
- virtual void AddChild (Window *child) = 0;
- virtual void RemoveChild (Window *child) = 0;
- virtual std::list <Window *> GetChildren (Window *child) const = 0;
+ virtual void SetParent (Widget &) {}
+ virtual Widget GetParent() const { return Widget (Window::GetParent()); }
virtual void SetBorderWidth (int borderWidth);
- virtual Size GetOptimalSize (WindowSizeType type = WINDOWSIZE_PREFERRED) const;
- virtual void SetPosSizePixel (long x, long y, long width, long height,
- USHORT flags = WINDOW_POSSIZE_ALL);
+ virtual void InvalidateSize() { m_requisition = Size (0, 0); }
+ virtual Size SizeRequest();
+ virtual void SizeAllocate (long x, long y, long width, long height);
+ virtual Rectangle GetAllocation() const
+ { return Rectangle (GetPosPixel(), GetSizePixel()); }
- virtual void ActivatePage();
+ virtual void StateChanged (StateChangedType type);
protected:
+ void AddPage (const String &label, Widget &child);
+
int m_borderWidth;
- std::vector <Window *> m_children;
+ std::vector <Widget> m_children;
+ Size m_requisition;
};
#endif /* VCL_NOTEBOOK_HXX */
diff --git a/vcl/inc/vcl/table.hxx b/vcl/inc/vcl/table.hxx
index af2f28f..edfc516 100644
--- a/vcl/inc/vcl/table.hxx
+++ b/vcl/inc/vcl/table.hxx
@@ -21,48 +21,62 @@
#ifndef VCL_TABLE_HXX
#define VCL_TABLE_HXX
-#include <vcl/window.hxx>
#include <vcl/layout.hxx>
+#include <vector>
/* Lays various widgets in a grid.
*/
-class VCL_DLLPUBLIC Table : public Window, Layout
+class Table : public Layout
{
public:
- Table (Window *parent, int rows, int cols);
- virtual ~Table();
+ Table (int cols);
void PackChild (Window *child, int rowSpan, int colSpan, bool rowExpand, bool colExpand);
- int SetSpacings (int rowSpacing, int colSpacing);
+ void PackChild (Layout *child, int rowSpan, int colSpan, bool rowExpand, bool colExpand);
+ void SetSpacings (int rowSpacing, int colSpacing);
- virtual void AddChild (Window *child) = 0;
- virtual void RemoveChild (Window *child) = 0;
- virtual std::list <Window *> GetChildren (Window *child) const = 0;
+ virtual void AddChild (Widget &child);
+ virtual void RemoveChild (Widget &child);
+ virtual std::list <Widget> GetChildren() const;
+
+ virtual void SetParent (Widget &parent) { m_parent = parent; }
+ virtual Widget GetParent() const { return m_parent; }
virtual void SetBorderWidth (int borderWidth);
- virtual Size GetOptimalSize (WindowSizeType type = WINDOWSIZE_PREFERRED) const;
- virtual void SetPosSizePixel (long x, long y, long width, long height,
- USHORT flags = WINDOW_POSSIZE_ALL);
+ virtual void InvalidateSize() { m_requisition = Size (0, 0); }
+ virtual Size SizeRequest();
+ virtual void SizeAllocate (long x, long y, long width, long height);
+ virtual Rectangle GetAllocation() const { return m_allocation; }
protected:
+ void PackChild (Widget &widget, int rowSpan, int colSpan, bool rowExpand, bool colExpand);
+
struct ChildData {
- ChildData (Window *child, int rowSpan, int colSpan);
+ ChildData (Widget &child, int rowSpan, int colSpan, bool rowExpand, bool colExpand);
- Window *window;
+ Widget widget;
int rowSpan, colSpan;
int rowExpand : 2, colExpand : 2;
- Size requisition; /* cached */
+ int leftCol, rightCol, topRow, bottomRow; // internally calculated:
};
friend struct CmpChild;
+ struct GroupData {
+ int expand : 2, reqSize;
+ GroupData() : expand (false), reqSize (0) {}
+ };
+
std::list <ChildData> m_children;
- int m_borderWidth, m_rowsSpacing, m_colsSpacing;
- int m_rows, m_cols;
- Window **m_table; /* temporary representation of the table */
- int *m_colsWidth, *m_rowsHeight;
+ int m_colsLen, m_rowsSpacing, m_colsSpacing;
+ int m_borderWidth;
+
+ std::vector <GroupData> m_cols, m_rows;
+ int m_colsExpandables, m_rowsExpandables;
Size m_requisition;
+ Rectangle m_allocation;
+ Widget m_parent;
};
#endif /* VCL_TABLE_HXX */
diff --git a/vcl/inc/vcl/xmlparser.hxx b/vcl/inc/vcl/xmlparser.hxx
new file mode 100644
index 0000000..05945bb
--- /dev/null
+++ b/vcl/inc/vcl/xmlparser.hxx
@@ -0,0 +1,28 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef VCL_XML_PARSER_HXX
+#define VCL_XML_PARSER_HXX
+
+// TODO
+
+#endif /* VCL_XML_PARSER_HXX */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/prj/build.lst b/vcl/prj/build.lst
index f64757f..2948138 100644
--- a/vcl/prj/build.lst
+++ b/vcl/prj/build.lst
@@ -6,6 +6,7 @@ vc vcl\source\app nmake - all vc_app vc_inc NULL
vc vcl\source\gdi nmake - all vc_gdi vc_inc NULL
vc vcl\source\window nmake - all vc_win vc_inc NULL
vc vcl\source\control nmake - all vc_ctrl vc_inc NULL
+vc vcl\source\layout nmake - all vc_layout vc_inc NULL
vc vcl\source\src nmake - all vc_src vc_inc NULL
vc vcl\source\helper nmake - all vc_hlp vc_inc NULL
vc vcl\source\fontsubset nmake - all vc_fts vc_inc NULL
diff --git a/vcl/prj/d.lst b/vcl/prj/d.lst
index b0e1aa2..017b6db 100644
--- a/vcl/prj/d.lst
+++ b/vcl/prj/d.lst
@@ -154,3 +154,13 @@ mkdir: %_DEST%\inc%_EXT%\vcl
..\inc\vcl\helper.hxx %_DEST%\inc%_EXT%\vcl\helper.hxx
..\inc\vcl\strhelper.hxx %_DEST%\inc%_EXT%\vcl\strhelper.hxx
..\inc\vcl\lazydelete.hxx %_DEST%\inc%_EXT%\vcl\lazydelete.hxx
+
+..\inc\vcl\layout.hxx %_DEST%\inc%_EXT%\vcl\layout.hxx
+..\inc\vcl\align.hxx %_DEST%\inc%_EXT%\vcl\align.hxx
+..\inc\vcl\box.hxx %_DEST%\inc%_EXT%\vcl\box.hxx
+..\inc\vcl\buttonbox.hxx %_DEST%\inc%_EXT%\vcl\buttonbox.hxx
+..\inc\vcl\ldialog.hxx %_DEST%\inc%_EXT%\vcl\ldialog.hxx
+..\inc\vcl\notebook.hxx %_DEST%\inc%_EXT%\vcl\notebook.hxx
+..\inc\vcl\table.hxx %_DEST%\inc%_EXT%\vcl\table.hxx
+..\inc\vcl\xmlparser.hxx %_DEST%\inc%_EXT%\vcl\uiparser.hxx
+
diff --git a/vcl/source/control/align.cxx b/vcl/source/control/align.cxx
deleted file mode 100644
index f2bbe7f..0000000
--- a/vcl/source/control/align.cxx
+++ /dev/null
@@ -1,82 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_vcl.hxx"
-
-#include <vcl/align.hxx>
-
-Align::Align (Window *parent, float xalign, float yalign, float xscale, float yscale)
-: Window (parent), m_xalign (xalign), m_yalign (yalign), m_xscale (xscale), m_yscale (yscale)
-{}
-
-void Align::AddChild (Window *child)
-{
- child->SetParent (this);
- QueueResize();
-}
-
-void Align::RemoveChild (Window *child)
-{
- QueueResize();
-}
-
-std::list <Window *> Align::GetChildren (Window *child) const
-{
- std::list <Window *> children;
- if (GetChildCount())
- children.push_back (GetChild (0));
- return children;
-}
-
-void Align::SetBorderWidth (int borderWidth)
-{
- m_borderWidth = borderWidth;
- QueueResize();
-}
-
-Size Align::GetOptimalSize (WindowSizeType type) const
-{
- Size req;
- if (GetChildCount()) {
- req = GetChild (0)->GetOptimalSize (type);
- return Size (req.Width() + m_borderWidth*2, req.Height() + m_borderWidth*2);
-}
-
-void Align::SetPosSizePixel (long x, long y, long width, long height, USHORT flags)
-{
- x += m_borderWidth; y += m_borderWidth;
- width -= m_borderWidth*2; height -= m_borderWidth*2;
- Window::SetPosSizePixel (x, y, width, height, flags);
-
- if (GetChildCount()) {
- Window *child = GetChild (0);
- Size childReq = child->GetOptimalSize (WINDOWSIZE_PREFERRED);
-
- long childX, childY, childWidth, childHeight;
- childWidth = (width - childReq.Width())*m_xscale + childReq.Width();
- childHeight = (height - childReq.Height())*m_yscale + childReq.Height();
- childX = (width - childWidth) * m_xalign;
- childY = (height - childHeight) * m_yalign;
- child->SetPosSizePixel (childX, childY, childWidth, childHeight);
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/control/box.cxx b/vcl/source/control/box.cxx
deleted file mode 100644
index b03e50a..0000000
--- a/vcl/source/control/box.cxx
+++ /dev/null
@@ -1,214 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_vcl.hxx"
-
-#include <vcl/box.hxx>
-
-struct CmpChild {
- Window *m_child;
- CmpChild (Window *child) : m_child (child) {}
-
- bool operator() (const Box::ChildData &childData)
- { return childData.window == m_child; }
-};
-
-Box::ChildData::ChildData (Window *window, bool expand, bool fill)
-: m_window (window), m_expand (expand), m_fill (fill)
-{}
-
-Box::Box (Window *parent, Orientation orientation, bool homogeneous, int spacing)
-: Window (parent), m_orientation (orientation), m_homogeneous (homogeneous), m_spacing (spacing), m_borderWidth (0)
-{}
-
-void Pack (Window *child, bool expand, bool fill)
-{
- m_children.push_back (ChildData (child, expand, fill));
- child->SetParent (this);
- QueueResize();
-}
-
-void Box::AddChild (Window *child)
-{
- Pack (child, true, true);
-}
-
-void Box::RemoveChild (Window *child)
-{
- CmpChild isChild (child);
- m_children.remove_if (isChild);
- QueueResize();
-}
-
-std::list <Window *> Box::GetChildren (Window *child) const
-{
- std::list <Window *> children;
- for (std::list <ChildData>::const_iterator it = m_children.begin();
- it != m_children.end(); it++)
- children.push_back (it->window);
- return children;
-}
-
-void Box::SetBorderWidth (int borderWidth)
-{
- m_borderWidth = borderWidth;
- QueueResize();
-}
-
-// GPoint uses primary/secundary axis, rather than X/Y
-struct GVector {
- GVector (const Box *box)
- : m_orientation (box->GetOrientation()), prim (0), secun (0) {}
-
- GVector (const Box *box, long x, long y)
- : m_orientation (box->GetOrientation())
- { Set (x, y); }
-
- GVector (const Box *box, const Size &size)
- : m_orientation (box->GetOrientation())
- { Set (size.getWidth(), size.getHeight()); }
-
- GVector (const GVector &other)
- : m_orientation (other.m_orientation), prim (other.prim), secun (other.secun) {}
-
- GVector & operator = (const GVector &other) {
- m_orientation = other.m_orientation;
- prim = other.prim;
- secun = other.secun;
- return *this;
- }
-
- long GetX() const
- { return m_orientation == Box::HORIZONTAL ? prim : secun; }
- long GetY() const
- { return m_orientation == Box::HORIZONTAL ? secun : prim; }
-
- Size GetSize() const
- { return Size (GetX(), GetY()); }
-
- void Set (long x, long y) {
- prim = m_orientation == Box::HORIZONTAL ? x : y;
- secun = m_orientation == Box::HORIZONTAL ? y : x;
- }
-
- Box::Orientation m_orientation;
- long prim, secun;
-};
-
-
-Size Box::GetOptimalSize (WindowSizeType) const
-{
- GVector reqSize (this);
- int visibleChildren = 0;
-
- Box *pThis = (const_cast <Box *> (this));
- for (std::list <ChildData>::iterator it = pThis->m_children.begin();
- it != pThis->m_children.end(); it++) {
- ChildData &child = *it;
- if (child.window->IsVisible()) {
- child.requisition = child.window->GetOptimalSize (WINDOWSIZE_PREFERRED);
- GVector reqChildSize (this, child.requisition);
-
- if (m_homogeneous)
- reqSize.prim = SAL_MAX (reqSize.prim, reqChildSize.prim);
- else
- reqSize.prim += reqChildSize.prim;
-fprintf (stderr, "\tprim size: %ld\n", reqSize.prim);
- reqSize.secun = SAL_MAX (reqSize.secun, reqChildSize.secun);
- visibleChildren++;
- }
- }
-
- if (m_homogeneous)
- reqSize.prim *= visibleChildren;
- reqSize.prim += (visibleChildren-1) * m_spacing;
- reqSize.prim += m_borderWidth * 2;
- reqSize.secun += m_borderWidth * 2;
-
- pThis->m_requisition = reqSize.GetSize();
- return m_requisition;
-}
-
-void Box::SetPosSizePixel (long x, long y, long width, long height, USHORT flags)
-{
-fprintf (stderr, "%cBox::SetPosSizePixel: %ldx%ld , %ldx%ld\n", m_orientation == HORIZONTAL ? 'H' : 'V', x, y, width, height);
- Window::SetPosSizePixel (x + m_borderWidth, y + m_borderWidth,
- width - m_borderWidth*2, height - m_borderWidth*2, flags);
-
-// FIXME: we cannot yet garantee GetOptimalSize() was called beforehand
-GetOptimalSize (WINDOWSIZE_PREFERRED);
-
- int visibleChildren = 0, expandChildren = 0;
- long sameChildSize = 0;
-
- for (std::list <ChildData>::iterator it = m_children.begin();
- it != m_children.end(); it++) {
- ChildData &child = *it;
- if (child.window->IsVisible()) {
- if (child.expand)
- expandChildren++;
- if (m_homogeneous) {
- GVector childReqSize (this, child.requisition);
- sameChildSize = SAL_MAX (sameChildSize, childReqSize.prim);
- }
- visibleChildren++;
- }
- }
- if (!visibleChildren) return;
-
- long extraSpace = 0;
- GVector allocSize (this, width, height);
- if (expandChildren) {
- GVector reqSize = GVector (this, requisition);
- extraSpace = SAL_MAX (0, (allocSize.prim - reqSize.prim) / expandChildren);
- }
-
- GVector childPoint (this, 0, 0);
- GVector childSize (this);
- childSize.secun = SAL_MAX (1, allocSize.secun);
-
- for (std::list <ChildData>::iterator it = m_children.begin();
- it != m_children.end(); it++) {
- ChildData &child = *it;
-
- GVector childReqSize (this, child.requisition);
- childSize.prim = childReqSize.prim;
- if (m_homogeneous)
- childSize.prim = sameChildSize;
- if (child.expand)
- childSize.prim += extraSpace;
-
- GVector innerChildPoint (childPoint);
- GVector innerChildSize (childSize);
- if (!child.fill) {
- innerChildSize = childReqSize;
- innerChildPoint.prim += (childSize.prim - innerChildSize.prim) / 2;
- innerChildPoint.secun += (childSize.secun - innerChildSize.secun) / 2;
- }
-
- child.window->SetPosSizePixel (
- innerChildPoint.GetX(), innerChildPoint.GetY(),
- innerChildSize.GetX(), innerChildSize.GetY(), WINDOW_POSSIZE_ALL);
- childPoint.prim += childSize.prim + m_spacing;
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/control/ldialog.cxx b/vcl/source/control/ldialog.cxx
deleted file mode 100644
index ac985b3..0000000
--- a/vcl/source/control/ldialog.cxx
+++ /dev/null
@@ -1,321 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_vcl.hxx"
-
-#include <vcl/ldialog.hxx>
-
-LDialog::LDialog (Window *parent_dialog)
-: Dialog (parent_dialog), m_borderWidth (0), m_defaultWidth (0), m_defaultHeight (0), m_proscrastinator (NULL)
-{}
-
-LDialog::LDialog()
-: Dialog (DIALOG_NO_PARENT), m_borderWidth (0), m_defaultWidth (0), m_defaultHeight (0), m_proscrastinator (NULL)
-{}
-
-void LDialog::AddChild (Window *child)
-{
- child->SetParent (this);
- QueueResize();
-}
-
-void LDialog::RemoveChild (Window *child)
-{
- QueueResize();
-}
-
-std::list <Window *> LDialog::GetChildren (Window *child) const
-{
- std::list <Window *> children;
- if (GetChildCount())
- children.push_back (GetChild (0));
- return children;
-}
-
-void LDialog::SetBorderWidth (int borderWidth)
-{
- m_borderWidth = borderWidth;
- QueueResize();
-}
-
-void LDialog::ShowAll()
-{
- if (GetChildCount()) {
- Window *child = GetChild (0);
- Layout *container = dynamic_cast <Layout *> (child);
- container ? container->ShowAll() : child->Show();
- }
-}
-
-Size LDialog::GetOptimalSize (WindowSizeType type) const
-{
- Size req;
- if (GetChildCount()) {
- req = GetChild (0)->GetOptimalSize (type);
-
- return Size (
- SAL_MAX (m_defaultWidth, req.Width() + m_borderWidth*2),
- SAL_MAX (m_defaultHeight, req.Height() + m_borderWidth*2);
-}
-
-void LDialog::SetPosSizePixel (long x, long y, long width, long height, USHORT flags)
-{
- Window::SetPosSizePixel (x, y, width, height, flags);
-
- if (GetChildCount()) {
- Window *child = GetChild (0);
- child->SetPosSizePixel (x + m_borderWidth, y + m_borderWidth,
- width - m_borderWidth*2, height - m_borderWidth*2);
- }
-}
-
-// layout.cxx
-
-struct LayoutProscratinator : public Timer
-{
- std::list <Window *> m_damaged;
-
-public:
- LayoutProscratinator()
- {
- SetTimeout (500);
- }
-
- void Add (Window *dirty)
- {
- if (dirty->IsVisible())
- m_damaged.push_back (dirty);
- }
-
-protected:
- std::list <Window *> FilterAncestors (const std::list <Window *> widgets)
- {
- std::list <Window *> ancestors;
- for (std::list <Window *>::iterator it = m_damaged.begin();
- it != m_damaged.end(); it++) {
- bool isAncestor = true;
- for (std::list <Window *>::iterator jt = it+1;
- jt != m_damaged.end(); jt++)
- if ((*it)->IsWindowOrChild (*jt)) {
- isAncestor = false;
- break;
- }
- if (isAncestor)
- ancestors.push_back (*it);
- }
- }
-
- virtual void Timeout()
- {
- std::list <Window *> ancestors = FilterAncestors (m_damaged);
-
-
-
-
- // 2. check damage extent
- for ( ContainerList::iterator it = mxContainers.begin();
- it != mxContainers.end(); it++ )
- {
- uno::Reference< awt::XLayoutContainer > xContainer = *it;
- while ( xContainer->getParent().is() && isContainerDamaged( xContainer ) )
- {
- xContainer = uno::Reference< awt::XLayoutContainer >(
- xContainer->getParent(), uno::UNO_QUERY );
- }
-
- if ( *it != xContainer )
- {
- // 2.2 replace it with parent
- *it = xContainer;
-
- // 2.3 remove children of new parent
- eraseChildren( it, mxContainers );
- }
- }
-
- // 3. force re-calculations
- for ( ContainerList::iterator it = mxContainers.begin();
- it != mxContainers.end(); it++ )
- (*it)->allocateArea( (*it)->getAllocatedArea() );
-
-
-
-
-
- for (std::list <Window *>::iterator it = m_damaged.begin();
- it != m_damaged.end(); it++)
- for (std::list <Window *>::iterator jt = m_damaged.begin();
- it != m_damaged.end(); jt++)
- if (it != jt && (*it)->IsWindowOrChild (*jt))
- }
-
-
-
-
-
-
-
- static inline bool isParentOf( uno::Reference< awt::XLayoutContainer > xParent,
- uno::Reference< awt::XLayoutContainer > xWidget )
- {
- while ( xWidget.is() )
- {
- if ( xWidget == xParent )
- return true;
- xWidget = uno::Reference< awt::XLayoutContainer >( xWidget->getParent(), uno::UNO_QUERY );
- }
- return false;
- }
-
- static inline void eraseChildren( ContainerList::iterator &it, ContainerList &list )
- {
- ContainerList::iterator jt = list.begin();
- while ( jt != list.end() )
- {
- if ( it != jt && isParentOf( *it, *jt ) )
- jt = list.erase( jt );
- else
- jt++;
- }
- }
-
- static inline bool isContainerDamaged( uno::Reference< awt::XLayoutContainer > xContainer )
- {
- uno::Reference< awt::XLayoutConstrains > xConstrains( xContainer, uno::UNO_QUERY );
- awt::Size lastReq( xContainer->getRequestedSize() );
- awt::Size curReq( xConstrains->getMinimumSize() );
- return lastReq.Width != curReq.Width || lastReq.Height != curReq.Height;
- }
-
- virtual void Timeout()
- {
-
- mxLastAdded = uno::Reference< awt::XLayoutContainer >();
-
- // 1. remove duplications and children
- for ( ContainerList::iterator it = mxContainers.begin();
- it != mxContainers.end(); it++ )
- eraseChildren( it, mxContainers );
-
- // 2. check damage extent
- for ( ContainerList::iterator it = mxContainers.begin();
- it != mxContainers.end(); it++ )
- {
- uno::Reference< awt::XLayoutContainer > xContainer = *it;
- while ( xContainer->getParent().is() && isContainerDamaged( xContainer ) )
- {
- xContainer = uno::Reference< awt::XLayoutContainer >(
- xContainer->getParent(), uno::UNO_QUERY );
- }
-
- if ( *it != xContainer )
- {
- // 2.2 replace it with parent
- *it = xContainer;
-
- // 2.3 remove children of new parent
- eraseChildren( it, mxContainers );
- }
- }
-
- // 3. force re-calculations
- for ( ContainerList::iterator it = mxContainers.begin();
- it != mxContainers.end(); it++ )
- (*it)->allocateArea( (*it)->getAllocatedArea() );
- }
-
- Window *dialog;
-
- LayoutProscratinator (Window *dialog)
- : dialog (dialog)
- {
- SetTimeout (500);
- Start();
- }
-
- virtual void Timeout()
- {
-
- SetPosSizePixel
- }
-};
-
-Size Layout::SizeRequest (Window *widget)
-{
- Layout *container = dynamic_cast <Layout *> (child);
- if (container)
- return container->SizeRequest();
- return widget->GetOptimalSize (WINDOWSIZE_PREFERRED);
-}
-
-void Layout::SizeAllocate (Window *widget, long x, long y, long width, long height)
-{
- Layout *container = dynamic_cast <Layout *> (child);
- if (container)
- container->SizeAllocate (x, y, width, height);
- else
- widget->SetPosPixelSize (x, y, width, height, WINDOW_POSSIZE_ALL);
-}
-
-Layout::Layout()
-: m_reqDirty (true), m_allocDirty (true)
-
-Size Layout::SizeRequest()
-{
- if (m_reqDirty) {
- Size req = ImplSizeRequest();
- m_allocDirty = req != m_requsition;
- m_requisition = ImplSizeRequest();
- m_reqDirty = false;
- }
- return m_requistion;
-}
-
-void Layout::SizeAllocate (long x, long y, long width, long height)
-{
- if (m_allocDirty) {
- ImplSizeAllocate (x, y, width, height);
- m_allocDirty = false;
- }
-}
-
-void Layout::QueueResize()
-{
- m_reqDirty = (m_allocDirty = true);
-
- static LayoutProscratinator proscratinator;
- proscratinator.Add (this);
-}
-
-void Layout::ShowAll()
-{
- ImplShow();
-
- std::list <Window *> children = GetChildren();
- for (std::list <Window *>::iterator it = children.begin();
- it != children.end(); it++) {
- Window *child = *it;
- Layout *container = dynamic_cast <Layout *> (child);
- container ? container->ShowAll() : child->Show();
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/control/notebook.cxx b/vcl/source/control/notebook.cxx
deleted file mode 100644
index c0140dc..0000000
--- a/vcl/source/control/notebook.cxx
+++ /dev/null
@@ -1,141 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_vcl.hxx"
-
-#include <vcl/notebook.hxx>
-
-struct CmpChild {
- Window *m_child;
- CmpChild (Window *child) : m_child (child) {}
-
- bool operator() (const Window *child)
- { return child == m_child; }
-};
-
-Notebook::Notebook (Window *parent)
-: TabControl (parent), m_borderWidth (0)
-{
- m_children.reserve (8);
-}
-
-void Notebook::AddPage (const String &label, Window *child)
-{
-// FIXME: check reference manual if it's possible to retrieve
-// position of the element from its iterator
-// if so, use them
-/* std::vector <Window *>::iterator it;
- for (it = m_children.begin(); it != m_children !=; it++)
-*/
-
- unsigned int i;
- for (i = 0; i < m_children.size(); i++)
- if (m_children[i] == NULL)
- break;
-
- if (i == m_children.size()) // FIXME: check reference manual for vector::insert spec
- m_children.push_back (child);
- else
- m_children[i] = child;
-
- // 'i' is the page identifier: it has no bearing in its position
- InsertPage (i, String::CreateFromAscii (label), TAB_APPEND);
- child->SetParent (GetTabPage (i));
- QueueResize();
-}
-
-void Notebook::AddChild (Window *child)
-{
- USHORT page = GetPageCount();
- char label[16];
- snprintf (label, 16, "Page %d", page+1);
- AddPage (String::CreateFromAscii (label), child);
-}
-
-void Notebook::RemoveChild (Window *child)
-{
- std::vector <Window *> it = m_children.find (child);
- *it = NULL;
- QueueResize();
-}
-
-std::list <Window *> Notebook::GetChildren (Window *child) const
-{ // unfortunate: but this method is rarely called
- std::list <Window *> children;
- for (std::vector <Window *>::iterator it = m_children.begin();
- it != m_children.end(); it++)
- if (*it)
- children.push_back (*it);
- return children;
-}
-
-void Notebook::SetBorderWidth (int borderWidth)
-{
- m_borderWidth = borderWidth;
- QueueResize();
-}
-
-Window *Notebook::GetCurChild() const
-{ // FIXME: get rid of this method?
- int id = GetCurPageId();
- return m_children[id];
-}
-
-void Notebook::ActivatePage()
-{
-int id = GetCurPageId();
- TabControl::ActivatePage();
-fprintf (stderr, "Activate Page: %d -> %d\n", id, GetCurPageId());
-}
-
-
-static long GetHeaderHeight() { return 25; }
-
-Size Notebook::GetOptimalSize (WindowSizeType type) const
-{
- long width = 0, height = 0;
- for (USHORT i = 0; i < GetChildCount(); i++) {
- Window *child = GetChild (i);
- Size childSize (child->GetOptimalSize (type));
- width = SAL_MAX (width, childSize.Width());
- height = SAL_MAX (height, childSize.Height());
- }
- return Size (width + m_borderWidth*2, GetHeaderHeight() + height + m_borderWidth*2);
-}
-
-void Notebook::SetPosSizePixel (long x, long y, long width, long height,
- USHORT flags)
-{
- // FIXME: we probably want to iterate through the Pages, and set
- // pos-size on all of them.
-
- x += m_borderWidth; y += m_borderWidth;
- width -= m_borderWidth*2; height -= m_borderWidth*2;
- TabControl::SetPosSizePixel (x, y, width, height, flags);
-
- long headerHeight = GetHeaderHeight();
- for (USHORT i = 0; i < GetChildCount(); i++) {
- Window *child = GetChild (i);
- child->SetPosSizePixel (0, headerHeight, width, height - headerHeight, flags);
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/control/table.cxx b/vcl/source/control/table.cxx
deleted file mode 100644
index 680b175..0000000
--- a/vcl/source/control/table.cxx
+++ /dev/null
@@ -1,175 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_vcl.hxx"
-
-#include <vcl/table.hxx>
-
-struct CmpChild {
- Window *m_child;
- CmpChild (Window *child) : m_child (child) {}
-
- bool operator() (const Table::ChildData &childData)
- { return childData.window == m_child; }
-};
-
-ChildData::ChildData (Window *child, int rowSpan, int colSpan, bool rowExpand, bool colExpand)
-: window (child), rowSpan (rowSpan), colSpan (colSpan), rowExpand (rowExpand), colExpand (colExpand)
-{}
-
-Table::Table (Window *parent, int rows, int cols)
-: m_borderWidth (0), m_rowsSpacing (0), m_colsSpacing (0), m_rows (rows), m_cols (cols),
-m_table (NULL), m_colsWidth (NULL), m_rowsHeight (NULL)
-{}
-
-void Table::PackChild (Window *child, int rowSpan, int colSpan, bool rowExpand, bool colExpand)
-{
- if (rowSpan <= 0 || colSpan <= 0)
- fprintf (stderr, "Table::PackChild Error: child must be given a "
- "minimum of 1 of row-span and col-span\n");
-
- m_children.push_back (ChildData (child, rowSpan, colSpan, rowExpand, colExpand));
- child->SetParent (this);
- QueueResize();
-}
-
-int Table::SetSpacings (int rowSpacing, int colSpacing)
-{
- m_rowsSpacing = rowSpacing; m_colsSpacing = colSpacing;
- QueueResize();
-}
-
-void Table::AddChild (Window *child)
-{
- PackChild (child, 1, 1, true, true);
-}
-
-void Table::RemoveChild (Window *child)
-{
- CmpChild isChild (child);
- m_children.remove_if (isChild);
- QueueResize();
-}
-
-std::list <Window *> Table::GetChildren (Window *child) const
-{
- std::list <Window *> children;
- for (std::list <ChildData>::const_iterator it = m_children.begin();
- it != m_children.end(); it++)
- children.push_back (it->window);
- return children;
-}
-
-void Table::SetBorderWidth (int borderWidth)
-{
- m_borderWidth = borderWidth;
- QueueResize();
-}
-
-Size Table::GetOptimalSize (WindowSizeType type) const
-{
- if (m_table) delete m_table;
- m_table = new (Window *) [m_rows][m_cols];
- if (m_colsWidth) delete m_colsWidth;
- m_colsWidth = new (int *) [m_cols];
- if (m_rowsHeight) delete m_rowsHeight;
- m_rowsHeight = new (int *) [m_rows];
-
- for (int r = 0; r < m_rows; r++)
- for (int c = 0; c < m_cols; c++)
- m_table[r][c] = NULL;
-
- int i = 0, col = 0, row = 0;
- for (std::list <ChildData>::iterator it = m_children.begin();
- it != m_children.end(); it++) {
- ChildData &child = *it;
-
- bool done = false;
- for (; row < m_rows && !done; row++, col = 0)
- for (; col < m_cols && !done; col++)
- done = m_table[row][col];
-
- if (row == m_rows || col == m_cols) {
- fprintf (stderr, "Table::GetOptimalSize() Error: "
- "not given enough cells to place all children\n");
- break;
- }
-
- Size childSize (child.window->GetOptimalSize (type));
-
- int r, c;
- for (r = row; r < m_rows && r < row + child.rowSpan; r++) {
- for (c = col; c < m_cols && c < col + child.colSpan; c++) {
- m_table[r][c] = child.window;
- m_colsWidth[c] = SAL_MAX (m_colsWidth[c], childSize.Width() / child.colSpan);
- }
- m_rowsHeight[r] = SAL_MAX (m_rowsHeight[r], childSize.Height() / child.rowSpan);
- }
- col = c;
- }
-
- int width = m_borderWidth*2, height = m_borderWidth*2;
- for (int col = 0; col < m_cols; col++)
- width += m_colsWidth[col];
- for (int row = 0; row < m_rows; row++)
- height += m_rowsHeight[row];
-
- Table *pThis = const_cast <Table *> (this);
- pThis->m_requisition = Size (width, height);
- return m_requisition;
-}
-
-void Table::SetPosSizePixel (long x, long y, long width, long height, USHORT flags)
-{
- Window::SetPosSizePixel (x + m_borderWidth, y + m_borderWidth,
- width - m_borderWidth*2, height - m_borderWidth*2, flags);
-
-// FIXME: we cannot yet garantee GetOptimalSize() was called beforehand
-GetOptimalSize (WINDOWSIZE_PREFERRED);
-
- int expandWidth = width - m_requisition.Width();
- int expandHeight = height - m_requisition.Height();
-
- int row = 0, col = 0;
- for (std::list <ChildData>::iterator it = m_children.begin();
- it != m_children.end(); it++) {
- ChildData &child = *it;
- child.
-
- int r, c;
- for (r = 0; r < m_rows; r++)
- for (c = 0; c < m_cols; c++)
- if (m_table[r][c] == child.window)
- break;
- col = c + ;
-
-
- }
-
- for (int row = 0; row < m_rows; row++)
- for (int col = 0; col < m_cols; col++) {
- int w, h;
-
- m_table[row][col]->SetPosSizePixel (
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/layout/align.cxx b/vcl/source/layout/align.cxx
new file mode 100644
index 0000000..7e14103
--- /dev/null
+++ b/vcl/source/layout/align.cxx
@@ -0,0 +1,96 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_vcl.hxx"
+
+#include <vcl/align.hxx>
+
+Align::Align (float xalign, float yalign, float xscale, float yscale)
+: m_xalign (xalign), m_yalign (yalign), m_xscale (xscale), m_yscale (yscale), m_parent (Widget::NIL), m_child (Widget::NIL)
+{}
+
+void Align::AddChild (Widget &child)
+{
+ child.SetParent (this);
+ m_child = child;
+ QueueResize (this);
+}
+
+void Align::AddChild (Window *child)
+{ Widget w (child); AddChild (w); }
+
+void Align::AddChild (Layout *child)
+{ Widget w (child); AddChild (w); }
+
+void Align::RemoveChild (Widget &child)
+{
+ if (child == m_child)
+ m_child = Widget::NIL;
+ QueueResize (this);
+}
+
+std::list <Widget> Align::GetChildren() const
+{
+ std::list <Widget> children;
+ if (m_child != Widget::NIL)
+ children.push_back (m_child);
+ return children;
+}
+
+void Align::SetBorderWidth (int borderWidth)
+{
+ m_borderWidth = borderWidth;
+ QueueResize (this);
+}
+
+Size Align::SizeRequest()
+{
+ if (m_requisition.Width() != 0 && m_requisition.Height() != 0)
+ return m_requisition;
+
+ Size req;
+ if (m_child != Widget::NIL)
+ req = m_child.SizeRequest();
+
+ m_requisition = Size (req.Width() + m_borderWidth*2,
+ req.Height() + m_borderWidth*2);
+ return m_requisition;
+}
+
+void Align::SizeAllocate (long x, long y, long width, long height)
+{
+ x += m_borderWidth; y += m_borderWidth;
+ width -= m_borderWidth*2; height -= m_borderWidth*2;
+ m_allocation = Rectangle (x, y, width, height);
+
+ if (!m_child.isNull()) {
+ Size childReq (m_child.SizeRequest());
+
+ long childX, childY, childWidth, childHeight;
+ childWidth = (width - childReq.Width())*m_xscale + childReq.Width();
+ childHeight = (height - childReq.Height())*m_yscale + childReq.Height();
+ childX = (width - childWidth) * m_xalign;
+ childY = (height - childHeight) * m_yalign;
+ m_child.SizeAllocate (x + childX, y + childY, childWidth, childHeight);
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/layout/box.cxx b/vcl/source/layout/box.cxx
new file mode 100644
index 0000000..d8cec23
--- /dev/null
+++ b/vcl/source/layout/box.cxx
@@ -0,0 +1,223 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_vcl.hxx"
+
+#include <vcl/box.hxx>
+
+struct CmpChild {
+ Widget m_child;
+ CmpChild (Widget &child) : m_child (child) {}
+
+ bool operator() (const Box::ChildData &childData)
+ { return childData.widget == m_child; }
+};
+
+Box::ChildData::ChildData (Widget &w, bool e, bool f)
+: widget (w), expand (e), fill (f)
+{}
+
+Box::Box (Orientation orientation, bool homogeneous, int spacing)
+: m_orientation (orientation), m_homogeneous (homogeneous), m_spacing (spacing), m_borderWidth (0), m_parent (Widget::NIL)
+{}
+
+void Box::Pack (Widget &child, bool expand, bool fill)
+{
+ m_children.push_back (ChildData (child, expand, fill));
+ child.SetParent (this);
+ QueueResize (this);
+}
+
+void Box::Pack (Window *child, bool expand, bool fill)
+{ Widget w (child); Pack (w, expand, fill); }
+
+void Box::Pack (Layout *child, bool expand, bool fill)
+{ Widget w (child); Pack (w, expand, fill); }
+
+void Box::Pack (Window *wchild, Layout *lchild, bool expand, bool fill)
+{ Widget w (wchild, lchild); Pack (w, expand, fill); }
+
+void Box::AddChild (Widget &child)
+{
+ Pack (child, true, true);
+}
+
+void Box::RemoveChild (Widget &child)
+{
+ CmpChild isChild (child);
+ m_children.remove_if (isChild);
+ QueueResize (this);
+}
+
+std::list <Widget> Box::GetChildren() const
+{
+ std::list <Widget> children;
+ for (std::list <ChildData>::const_iterator it = m_children.begin();
+ it != m_children.end(); it++)
+ children.push_back (it->widget);
+ return children;
+}
+
+void Box::SetBorderWidth (int borderWidth)
+{
+ m_borderWidth = borderWidth;
+ QueueResize (this);
+}
+
+// GPoint uses primary/secundary axis, rather than X/Y
+struct GVector {
+ GVector (const Box *box)
+ : m_orientation (box->GetOrientation()), prim (0), secun (0) {}
+
+ GVector (const Box *box, long x, long y)
+ : m_orientation (box->GetOrientation())
+ { Set (x, y); }
+
+ GVector (const Box *box, const Size &size)
+ : m_orientation (box->GetOrientation())
+ { Set (size.getWidth(), size.getHeight()); }
+
+ GVector (const GVector &other)
+ : m_orientation (other.m_orientation), prim (other.prim), secun (other.secun) {}
+
+ GVector & operator = (const GVector &other) {
+ m_orientation = other.m_orientation;
+ prim = other.prim;
+ secun = other.secun;
+ return *this;
+ }
+
+ long GetX() const
+ { return m_orientation == Box::HORIZONTAL ? prim : secun; }
+ long GetY() const
+ { return m_orientation == Box::HORIZONTAL ? secun : prim; }
+
+ Size GetSize() const
+ { return Size (GetX(), GetY()); }
+
+ void Set (long x, long y) {
+ prim = m_orientation == Box::HORIZONTAL ? x : y;
+ secun = m_orientation == Box::HORIZONTAL ? y : x;
+ }
+
+ Box::Orientation m_orientation;
+ long prim, secun;
+};
+
+
+Size Box::SizeRequest()
+{
+ if (m_requisition.Width() != 0 && m_requisition.Height() != 0)
+ return m_requisition;
+
+ GVector reqSize (this);
+ int visibleChildren = 0;
+
+ for (std::list <ChildData>::iterator it = m_children.begin();
+ it != m_children.end(); it++) {
+ ChildData &child = *it;
+ if (child.widget.IsVisible()) {
+ child.requisition = child.widget.SizeRequest();
+ GVector reqChildSize (this, child.requisition);
+
+ if (m_homogeneous)
+ reqSize.prim = SAL_MAX (reqSize.prim, reqChildSize.prim);
+ else
+ reqSize.prim += reqChildSize.prim;
+fprintf (stderr, "\tprim size: %ld\n", reqSize.prim);
+ reqSize.secun = SAL_MAX (reqSize.secun, reqChildSize.secun);
+ visibleChildren++;
+ }
+ }
+
+ if (m_homogeneous)
+ reqSize.prim *= visibleChildren;
+ reqSize.prim += (visibleChildren-1) * m_spacing;
+ reqSize.prim += m_borderWidth * 2;
+ reqSize.secun += m_borderWidth * 2;
+
+ return (m_requisition = reqSize.GetSize());
+}
+
+void Box::SizeAllocate (long x, long y, long width, long height)
+{
+fprintf (stderr, "%cBox::SetPosSizePixel: %ldx%ld , %ldx%ld\n", m_orientation == HORIZONTAL ? 'H' : 'V', x, y, width, height);
+ x += m_borderWidth, y += m_borderWidth;
+ width -= m_borderWidth * 2; height -= m_borderWidth * 2;
+ m_allocation = Rectangle (x, y, width, height);
+ SizeRequest(); // ensure was called beforehand
+
+ int visibleChildren = 0, expandChildren = 0;
+ long sameChildSize = 0;
+
+ for (std::list <ChildData>::iterator it = m_children.begin();
+ it != m_children.end(); it++) {
+ ChildData &child = *it;
+ if (child.widget.IsVisible()) {
+ if (child.expand)
+ expandChildren++;
+ if (m_homogeneous) {
+ GVector childReqSize (this, child.requisition);
+ sameChildSize = SAL_MAX (sameChildSize, childReqSize.prim);
+ }
+ visibleChildren++;
+ }
+ }
+ if (!visibleChildren) return;
+
+ long extraSpace = 0;
+ GVector allocSize (this, width, height);
+ if (expandChildren) {
+ GVector reqSize = GVector (this, m_requisition);
+ extraSpace = SAL_MAX (0, (allocSize.prim - reqSize.prim) / expandChildren);
+ }
+
+ GVector childPoint (this, x, y);
+ GVector childSize (this);
+ childSize.secun = SAL_MAX (1, allocSize.secun);
+
+ for (std::list <ChildData>::iterator it = m_children.begin();
+ it != m_children.end(); it++) {
+ ChildData &child = *it;
+
+ GVector childReqSize (this, child.requisition);
+ childSize.prim = childReqSize.prim;
+ if (m_homogeneous)
+ childSize.prim = sameChildSize;
+ if (child.expand)
+ childSize.prim += extraSpace;
+
+ GVector innerChildPoint (childPoint);
+ GVector innerChildSize (childSize);
+ if (!child.fill) {
+ innerChildSize = childReqSize;
+ innerChildPoint.prim += (childSize.prim - innerChildSize.prim) / 2;
+ innerChildPoint.secun += (childSize.secun - innerChildSize.secun) / 2;
+ }
+
+ child.widget.SizeAllocate (
+ innerChildPoint.GetX(), innerChildPoint.GetY(),
+ innerChildSize.GetX(), innerChildSize.GetY());
+ childPoint.prim += childSize.prim + m_spacing;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/layout/buttonbox.cxx b/vcl/source/layout/buttonbox.cxx
new file mode 100644
index 0000000..e3d0f3b
--- /dev/null
+++ b/vcl/source/layout/buttonbox.cxx
@@ -0,0 +1,93 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_vcl.hxx"
+
+#include <vcl/button.hxx>
+#include <vcl/buttonbox.hxx>
+
+ButtonBox::ButtonBox ()
+: HBox (true, 12)
+{}
+
+void ButtonBox::Pack (Button *button, Role role)
+{
+ Widget widget (button);
+#if 0
+ m_roles[widget] = role;
+#endif
+ Box::Pack (widget, false, true);
+}
+
+void ButtonBox::RemoveChild (Widget &child)
+{
+#if 0
+ m_roles.erase (child);
+#endif
+ Box::RemoveChild (child);
+}
+
+// TODO: order ought dependend on system settings
+// The higher the placement role, the more to the right they are placed.
+// Positive values are aligned to the right, negatives values to the left.
+// TODO: create special flag for the center
+
+static int GetRolePlacement (ButtonBox::Role role)
+{
+ switch (role) {
+ case ButtonBox::OK_BUTTON: return 4;
+ case ButtonBox::CANCEL_BUTTON: return 2;
+ case ButtonBox::APPLY_BUTTON: return 3;
+ case ButtonBox::HELP_BUTTON: return -1;
+ case ButtonBox::CUSTOM_BUTTON: return 0;
+ }
+ return 0;
+}
+
+#if 0
+struct ChildOrder {
+ ButtonBox *box;
+ ChildOrder (ButtonBox *b) : box (b) {}
+
+ bool operator() (Box::ChildData &child1, Box::ChildData &child2) {
+ std::map <Widget, ButtonBox::Role> &m = box->m_roles;
+ std::map <Widget, ButtonBox::Role>::iterator it, jt;
+ it = m.find (child1.widget);
+ jt = m.find (child2.widget);
+
+ int weight1 = it == m.end() ? 0 : GetRolePlacement (it->second);
+ int weight2 = jt == m.end() ? 0 : GetRolePlacement (jt->second);
+ return weight1 < weight2;
+ }
+};
+#endif
+
+void ButtonBox::SizeAllocate (long x, long y, long width, long height)
+{
+#if 0 // FIXME
+ ChildOrder order (this);
+ std::sort (Box::m_children.begin(), Box::m_children.end(), order);
+#endif
+
+ Box::SizeAllocate (x, y, width, height);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/layout/layout.cxx b/vcl/source/layout/layout.cxx
new file mode 100644
index 0000000..d8df330
--- /dev/null
+++ b/vcl/source/layout/layout.cxx
@@ -0,0 +1,452 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_vcl.hxx"
+
+#include <vcl/layout.hxx>
+#include <vcl/window.hxx>
+#include <vcl/timer.hxx>
+
+#if 0
+
+// FIXME: we may want, in the future, to integrate this volatile
+// widget tree with the actual one
+
+struct DirtyWidget
+{
+ Window *window;
+ DirtyWidget *next, *child;
+
+ DirtyWidget (Window *window)
+ : window (window), next (NULL), child (NULL) {}
+
+ ~DirtyWidget()
+ { delete child; delete next; }
+
+ // FIXME: check if this function doesn't check only for parents,
+ // but also for grand-parents and so ...
+ bool IsParent (DirtyWidget *child)
+ { return child->IsChild (parent); }
+};
+
+struct DirtyTree
+{
+ DirtyWidget *root;
+
+ DirtyTree() : root (NULL) {}
+ ~DirtyTree() { delete root; }
+
+ void Add (Window *window)
+ { return Add (NULL, root, new DirtyWidget (window)); }
+
+ void Clear()
+ { delete root; root = NULL; }
+
+ // We pass parent as an argument, since we do not store it in
+ // the DirtyWidget structure
+
+ void Add (DirtyWidget *parent, DirtyWidget *node, DirtyWidget *widget)
+ {
+ if (!root) // first entry
+ { root = widget; return; }
+ if (node->window == widget->window) // already added
+ { delete widget; return; }
+
+ // For each nodes within this breath:
+ // 1. check if child
+ for (DirtyWidget *i = node; i; i = i->next)
+ if (i->IsParent (widget)) {
+ fprintf (stderr, "\tis child\n");
+ if (i->child)
+ Add (i, i->child, widget);
+ else
+ i->child = widget;
+ return; // done: a widget can only be a child within a breath
+ }
+
+ // 2. not child: check if parent
+ for (DirtyWidget *i = node, *prev = 0; i; prev = i, i = i->next)
+ if (widget->IsParent (i)) {
+ fprintf (stderr, "\tis parent\n");
+ if (prev)
+ prev->next = i->next;
+ else
+ parent->child = i->next;
+
+ if (widget->child) {
+ DirtyWidget *n = widget->child->next;
+ i->next = n;
+ widget->child = i;
+ }
+ else
+ widget->child = i;
+ // loop must continue: a wigdet may have multiple children within a breath
+ }
+ if (widget->child) {
+ DirtyWidget *n = parent->child;
+ parent->child = widget;
+ widget->next = n;
+ }
+
+ // 3. not child or parent: must be sibling then
+ if (!widget->child) {
+ fprintf (stderr, "\tadded as sibling\n");
+ widget->next = node->next;
+ node->next = widget; // widget order is irrelevant
+ }
+ }
+};
+
+struct LayoutProscratinator : public Timer
+{
+ DirtyTree *tree;
+
+ LayoutProscratinator() : tree (NULL)
+ {
+ SetTimeout (500);
+ }
+
+ void Add (Window *widget)
+ {
+ if (widget->IsVisible())
+ tree->Add (widget);
+ }
+
+ virtual void Timeout()
+ {
+ // 1. Check damage extent (whether parent size changed as well)
+ for (DirtyWidget *i = tree->root; i; i = i->next)
+ for (Window *p = i->window->GetParent(); p; p = p->GetParent()) {
+ bool sizeChanged = true;
+ Layout *layout = dynamic_cast <Layout *> (parent);
+ if (layout)
+ sizeChanged = layout->HasSizeChanged();
+
+ if (sizeChanged)
+ tree->Add (p);
+ else
+ break;
+ }
+
+ // 2. Force re-allocate
+ for (DirtyWidget *i = tree->root; i; i = i->next) {
+ Point p = i->window->GetPosPixel();
+ Size s = i->window->GetSizePixel();
+ i->window->SetPosSizePixel (p, s);
+ }
+
+ tree->Clear();
+ }
+};
+
+#endif
+
+/*
+struct IsChildOf {
+ Window *m_parent;
+ IsChildOf (Window *parent) : m_parent (parent) {}
+
+ bool operator() (Window *child)
+ { return child->IsChild (m_parent); }
+};
+*/
+
+struct IsChildCmp {
+ Widget m_child;
+ IsChildCmp (Widget &child) : m_child (child) {}
+
+ bool operator() (Widget &parent)
+ { return (parent != m_child) && m_child.IsChild (parent); }
+};
+
+struct LayoutProscratinator : public Timer
+{
+ typedef std::list <Widget> WidgetList;
+ WidgetList m_damaged;
+
+ LayoutProscratinator()
+ {
+ SetTimeout (500);
+ }
+
+ void Add (Widget &widget)
+ {
+ if (!HasWidget (m_damaged, widget)) {
+ m_damaged.push_front (widget);
+ Start();
+ }
+ }
+
+ static bool HasWidget (WidgetList &list, Widget widget)
+ { return std::find (list.begin(), list.end(), widget) != list.end(); }
+
+ static bool HasParent (WidgetList &list, Widget &widget)
+ {
+ IsChildCmp is_child (widget);
+ return std::find_if (list.begin(), list.end(), is_child) != list.end();
+ }
+
+ static WidgetList GetParentWidgets (WidgetList& src)
+ {
+ WidgetList dst;
+ for (WidgetList::iterator it = src.begin(); it != src.end(); it++) {
+ Widget &widget = *it;
+ if (!HasParent (src, widget))
+ dst.push_front (widget);
+ }
+ return dst;
+ }
+
+ static Widget &GetTopWidgetChanged (Widget &w)
+ {
+ for (Widget p = w.GetParent();; w = p, p = p.GetParent())
+ if (!p.HasSizeChanged())
+ break;
+ return w;
+ }
+
+#if 0
+static void PrintList (const char *label, WidgetList &list)
+{
+ fprintf (stderr, "\tPrint %s list:\n", label);
+ for (WidgetList::iterator it = list.begin(); it != list.end(); it++)
+ fprintf (stderr, "\t\t%p\n", *it);
+}
+#endif
+
+ virtual void Timeout()
+ {
+//fprintf (stderr, "** Layout Timer Timeout **\n");
+ WidgetList affected, affected2;
+
+//PrintList ("m_damaged", m_damaged);
+ // cut list to the top damaged widgets
+ affected = GetParentWidgets (m_damaged);
+//PrintList ("affected", affected);
+ for (WidgetList::iterator it = affected.begin(); it != affected.end(); it++)
+ affected2.push_front (GetTopWidgetChanged (*it));
+//PrintList ("affected2", affected2);
+ affected = GetParentWidgets (affected2);
+//PrintList ("affected", affected);
+
+ // issue size re-allocations
+ for (WidgetList::iterator it = affected.begin(); it != affected.end(); it++) {
+ Widget &widget = *it;
+ widget.SizeAllocate (widget.GetAllocation());
+ }
+
+ m_damaged.clear();
+ }
+};
+
+void Layout::QueueResize (Widget &widget)
+{
+ if (widget.IsVisible()) {
+ static LayoutProscratinator timer;
+ timer.Add (widget);
+ }
+ widget.InvalidateSize();
+}
+
+void Layout::QueueResize (Window *window)
+{ Widget w (window, NULL); QueueResize (w); }
+
+void Layout::QueueResize (Layout *layout)
+{ Widget w (NULL, layout); QueueResize (w); }
+
+void Layout::QueueResize (Window *window, Layout *layout)
+{ Widget w (window, layout); QueueResize (w); }
+
+void Layout::ShowAll (Layout *layout)
+{ Widget w (layout); w.ShowAll(); }
+
+//** Widget
+
+Widget Widget::NIL (Widget (NULL, NULL));
+
+Widget::Widget (Window *window)
+: m_window (window), m_layout (dynamic_cast <Layout *> (window))
+{}
+
+Widget::Widget (Layout *layout)
+: m_window (dynamic_cast <Window *> (layout)), m_layout (layout)
+{}
+
+Widget::Widget (Window *window, Layout *layout)
+: m_window (window), m_layout (layout)
+{}
+
+bool Widget::isNull() const
+{ return !m_window && !m_layout; }
+
+std::list <Widget> Widget::GetChildren() const
+{
+ if (m_layout)
+ return m_layout->GetChildren();
+ return std::list <Widget> ();
+}
+
+void Widget::SetParent (Widget &parent)
+{
+ // if parent is layout, it might not have been added to a Window tree yet...
+ Window *parent_window = parent.GetParentWindow();
+ SetParent (parent, parent_window);
+}
+
+void Widget::SetParent (Layout *layout)
+{ Widget w (layout); SetParent (w); }
+
+void Widget::SetParent (Widget &parent, Window *parent_window)
+{
+ // FIXME: see message in layout.hxx
+
+ if (parent_window)
+ SetParentWindow (parent_window);
+ if (m_layout)
+ m_layout->SetParent (parent);
+}
+
+Window *Widget::GetParentWindow() const
+{
+ if (m_window)
+ return m_window;
+
+ for (Widget parent = GetParent(); parent != Widget::NIL; parent = parent.GetParent())
+ if (parent.m_window)
+ return parent.m_window;
+ return NULL;
+}
+
+void Widget::SetParentWindow (Window *parent_window)
+{
+ if (m_window)
+ m_window->SetParent (parent_window);
+ else {
+ // is lonely layout: propagate new parent to children of Window type
+ std::list <Widget> children = m_layout->GetChildren();
+ for (std::list <Widget>::iterator it = children.begin();
+ it != children.end(); it++)
+ it->SetParentWindow (parent_window);
+ }
+}
+
+Widget Widget::GetParent() const
+{
+ if (m_layout)
+ return m_layout->GetParent();
+ return Widget (m_window->GetParent());
+}
+
+bool Widget::IsChild (Widget &parent) const
+{
+ for (Widget p = GetParent(); p != Widget::NIL; p = p.GetParent())
+ if (p == parent)
+ return true;
+ return false;
+}
+
+bool Widget::IsVisible() const
+{
+ if (m_window)
+ return m_window->IsVisible();
+ return true;
+}
+
+void Widget::ShowWidget (Widget &widget)
+{
+ if (widget.m_window)
+ widget.m_window->Show();
+}
+
+void Widget::ShowAll()
+{ Foreach (ShowWidget); }
+
+void Widget::Foreach (Widget::ForeachCallback callback)
+{
+ callback (*this);
+
+ if (m_layout) {
+ std::list <Widget> children (m_layout->GetChildren());
+ for (std::list <Widget>::iterator it = children.begin();
+ it != children.end(); it++)
+ it->Foreach (callback);
+ }
+ else if (m_window) { // also apply to internal windows
+ for (USHORT i = 0; i < m_window->GetChildCount(); i++) {
+ Widget child (m_window->GetChild (i));
+ callback (child);
+ }
+ }
+}
+
+Size Widget::SizeRequest()
+{
+ if (m_layout)
+ return m_layout->SizeRequest();
+ return m_window->GetOptimalSize (WINDOWSIZE_PREFERRED);
+}
+
+void Widget::SizeAllocate (long x, long y, long width, long height)
+{
+ if (m_layout)
+ return m_layout->SizeAllocate (x, y, width, height);
+ return m_window->SetPosSizePixel (x, y, width, height, WINDOW_POSSIZE_ALL);
+}
+
+void Widget::SizeAllocate (const Rectangle &rect)
+{ SizeAllocate (rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight()); }
+
+void Widget::InvalidateSize()
+{
+ if (m_layout)
+ m_layout->InvalidateSize();
+}
+
+bool Widget::HasSizeChanged()
+{
+ if (m_layout) {
+ Size oldSize (m_layout->SizeRequest());
+ m_layout->InvalidateSize();
+ Size newSize (m_layout->SizeRequest());
+ return oldSize != newSize;
+ }
+ return false;
+}
+
+Rectangle Widget::GetAllocation() const
+{
+ if (m_window)
+ return Rectangle (m_window->GetPosPixel(), m_window->GetSizePixel());
+ if (m_layout)
+ return m_layout->GetAllocation();
+ return Rectangle();
+}
+
+/*bool Widget::operator == (Widget &other) const
+{ return this->m_window == other.m_window && this->m_layout == other.m_layout; }
+*/
+bool Widget::operator == (Widget other) const
+{ return this->m_window == other.m_window && this->m_layout == other.m_layout; }
+
+bool Widget::operator != (Widget &other) const
+{ return this->m_window != other.m_window || this->m_layout != other.m_layout; }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/layout/ldialog.cxx b/vcl/source/layout/ldialog.cxx
new file mode 100644
index 0000000..164276b
--- /dev/null
+++ b/vcl/source/layout/ldialog.cxx
@@ -0,0 +1,133 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_vcl.hxx"
+
+#include <vcl/ldialog.hxx>
+
+#define WB_LDIALOG (WB_STDDIALOG | WB_SIZEABLE)
+
+LDialog::LDialog (Window *parent_dialog)
+: Dialog (parent_dialog, WB_LDIALOG), m_child (Widget::NIL), m_autoResize (1), m_borderWidth (0), m_defaultWidth (0), m_defaultHeight (0)
+{}
+
+LDialog::LDialog()
+: Dialog (DIALOG_NO_PARENT, WB_LDIALOG), m_child (Widget::NIL), m_autoResize (1), m_borderWidth (0), m_defaultWidth (0), m_defaultHeight (0)
+{}
+
+void LDialog::AddChild (Widget &child)
+{
+ m_child = child;
+ child.SetParent (this);
+ QueueResize (this, this);
+}
+
+void LDialog::AddChild (Window *child)
+{ Widget w (child); AddChild (w); }
+
+void LDialog::AddChild (Layout *child)
+{ Widget w (child); AddChild (w); }
+
+void LDialog::RemoveChild (Widget &)
+{
+ m_child = Widget::NIL;
+ QueueResize (this, this);
+}
+
+std::list <Widget> LDialog::GetChildren() const
+{
+ std::list <Widget> children;
+ if (GetChildCount())
+ children.push_back (Widget (GetChild (0)));
+ return children;
+}
+
+void LDialog::SetBorderWidth (int borderWidth)
+{
+ m_borderWidth = borderWidth;
+ QueueResize (this, this);
+}
+
+Size LDialog::SizeRequest()
+{
+ Size childReq;
+ if (!m_child.isNull())
+ childReq = m_child.SizeRequest();
+
+ Size req (childReq.Width() + m_borderWidth*2,
+ childReq.Height() + m_borderWidth*2);
+
+ SetMinOutputSizePixel (req);
+ SetMaxOutputSizePixel (Size (LONG_MAX, LONG_MAX));
+ return req;
+}
+
+Size LDialog::SizePreferred()
+{
+ Size minSize (SizeRequest());
+ Size req (SAL_MAX (m_defaultWidth, minSize.Width()),
+ SAL_MAX (m_defaultHeight, minSize.Height()));
+ return req;
+}
+
+void LDialog::SizeAllocate (long, long, long width, long height)
+{
+ if (!m_child.isNull())
+ m_child.SizeAllocate (m_borderWidth, m_borderWidth,
+ width - m_borderWidth*2, height - m_borderWidth*2);
+}
+
+void LDialog::StateChanged (StateChangedType type)
+{
+ Dialog::StateChanged (type);
+
+ if (type == STATE_CHANGE_INITSHOW) {
+fprintf (stderr, "** INITSHOW\n");
+ m_autoResize = true;
+ SetSizePixel (SizePreferred());
+ }
+
+#if 0
+fprintf (stderr, "LDialog::StateChanged: %d\n", type);
+ if (type == STATE_CHANGE_INITSHOW) {
+ // on realize, show window with the desired size
+ m_resizeSafeguard = true;
+ SetSizePixel (GetOptimalSize (WINDOWSIZE_PREFERRED));
+ m_resizeSafeguard = false;
+ }
+#endif
+}
+
+void LDialog::Resize()
+{
+fprintf (stderr, "LDialog::Resize\n");
+ Dialog::Resize();
+
+ if (!m_autoResize) {
+fprintf (stderr, "\tqueue resize\n");
+ QueueResize (this, this);
+ }
+ else
+ fprintf (stderr, "\tignore\n");
+ m_autoResize = false;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/layout/makefile.mk b/vcl/source/layout/makefile.mk
new file mode 100644
index 0000000..c6ee909
--- /dev/null
+++ b/vcl/source/layout/makefile.mk
@@ -0,0 +1,61 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=vcl
+TARGET=layout
+
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile2.pmk
+
+.IF "$(COM)"=="ICC"
+CDEFS+=-D_STD_NO_NAMESPACE -D_VOS_NO_NAMESPACE -D_UNO_NO_NAMESPACE
+.ENDIF
+
+# --- Files --------------------------------------------------------
+
+SLOFILES= $(SLO)$/align.obj \
+ $(SLO)$/box.obj \
+ $(SLO)$/buttonbox.obj \
+ $(SLO)$/layout.obj \
+ $(SLO)$/ldialog.obj \
+ $(SLO)$/notebook.obj \
+ $(SLO)$/table.obj \
+ $(SLO)$/xmlparser.obj
+
+EXCEPTIONSFILES=$(SLOFILES)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+.INCLUDE : $(PRJ)$/util$/target.pmk
diff --git a/vcl/source/layout/notebook.cxx b/vcl/source/layout/notebook.cxx
new file mode 100644
index 0000000..6d982d3
--- /dev/null
+++ b/vcl/source/layout/notebook.cxx
@@ -0,0 +1,172 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_vcl.hxx"
+
+#include <vcl/notebook.hxx>
+#include <vcl/tabpage.hxx>
+
+struct CmpChild {
+ Widget m_child;
+ CmpChild (Widget &child) : m_child (child) {}
+
+ bool operator() (const Widget &child)
+ { return child == m_child; }
+};
+
+Notebook::Notebook (Window *parent)
+: TabControl (parent), m_borderWidth (0)
+{
+ m_children.reserve (8);
+}
+
+void Notebook::AddPage (const String &label, Widget &child)
+{
+ unsigned int i;
+ for (i = 0; i < m_children.size(); i++)
+ if (m_children[i].isNull()) break;
+ if (i == m_children.size())
+ m_children.push_back (child);
+ else
+ m_children[i] = child;
+
+ // 'i' is just an identifier: it has no bearing on its position
+ InsertPage (i, label, TAB_APPEND);
+ TabPage *tab_page = new TabPage (this);
+ SetTabPage (i, tab_page);
+ Widget _this (this, this);
+ child.SetParent (_this, tab_page);
+ if (m_children.size() == 0)
+ SelectTabPage (i);
+ QueueResize (this, this);
+}
+
+void Notebook::AddPage (const String &label, Window *child)
+{ Widget w (child); AddPage (label, w); }
+void Notebook::AddPage (const String &label, Layout *child)
+{ Widget w (child); AddPage (label, w); }
+
+void Notebook::AddChild (Widget &child)
+{
+ USHORT page = GetPageCount();
+ char label[16];
+ snprintf (label, 16, "Page %d", page+1);
+ AddPage (String::CreateFromAscii (label), child);
+}
+
+void Notebook::RemoveChild (Widget &child)
+{
+ std::vector <Widget>::iterator it;
+ it = std::find (m_children.begin(), m_children.end(), child);
+ if (it != m_children.end())
+ *it = Widget::NIL;
+ QueueResize (this, this);
+}
+
+std::list <Widget> Notebook::GetChildren() const
+{ // unfortunate conversion: but this method is rarely called anyway
+ std::list <Widget> children;
+ for (std::vector <Widget>::const_iterator it = m_children.begin();
+ it != m_children.end(); it++)
+ if (!it->isNull())
+ children.push_back (*it);
+ return children;
+}
+
+void Notebook::SetBorderWidth (int borderWidth)
+{
+ m_borderWidth = borderWidth;
+ QueueResize (this, this);
+}
+
+static long GetHeaderHeight() { return 25; }
+
+Size Notebook::SizeRequest()
+{
+ if (m_requisition.Width() != 0 && m_requisition.Height() != 0)
+ return m_requisition;
+
+ long width = 0, height = 0, tab_width = 0, tab_height = 0;
+ for (unsigned int i = 0; i < m_children.size(); i++) {
+ Widget &child = m_children[i];
+ if (!child.isNull()) {
+ Size tab_size (GetTabBounds(i).GetSize());
+ tab_width += tab_size.Width();
+ tab_height = SAL_MAX (tab_height, tab_size.Height());
+
+ Size childSize (child.SizeRequest());
+ width = SAL_MAX (width, childSize.Width());
+ height = SAL_MAX (height, childSize.Height());
+ }
+ }
+ width = SAL_MAX (width, tab_width);
+
+ width += m_borderWidth * 2;
+ height += (m_borderWidth * 2) + tab_height + 4;
+
+ return (m_requisition = Size (width, height));
+}
+
+void Notebook::SizeAllocate (long x, long y, long width, long height)
+{
+ x += m_borderWidth; y += m_borderWidth;
+ width -= m_borderWidth*2; height -= m_borderWidth*2;
+ SetPosSizePixel (x, y, width, height, WINDOW_POSSIZE_ALL);
+
+#if 1
+ long headerHeight = GetHeaderHeight();
+
+ for (unsigned int i = 0; i < m_children.size(); i++) {
+ Widget &child = m_children[i];
+ if (!child.isNull()) {
+ Rectangle tabpage_rect (GetTabPageBounds(i));
+/* TabPage *tab_page = GetTabPage (i);
+ if (tab_page)
+ tab_page->SetPosSizePixel (0, 0, width, height, flags);*/
+
+ Rectangle tab_rect = GetTabBounds (i);
+// headerHeight = tab_rect.GetSize().Height();
+
+fprintf (stderr, "\theaderHeight: %ld\n", headerHeight);
+ child.SizeAllocate (0, headerHeight, width, height - headerHeight);
+ }
+ }
+
+
+
+USHORT id = GetCurPageId();
+Rectangle r;
+r = GetTabPageBounds(id);
+fprintf (stderr, "\tGetTabPageBounds (%d): %ldx%ld , %ldx%ld\n", id, r.TopLeft().X(), r.TopLeft().Y(), r.GetSize().Width(), r.GetSize().Height());
+r = GetTabBounds(id);
+fprintf (stderr, "\tGetTabBounds (%d): %ldx%ld , %ldx%ld\n", id, r.TopLeft().X(), r.TopLeft().Y(), r.GetSize().Width(), r.GetSize().Height());
+#endif
+}
+
+void Notebook::StateChanged (StateChangedType type)
+{
+ TabControl::StateChanged (type);
+
+ if (GetChildCount() > 0)
+ SetCurPageId (0);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/layout/table.cxx b/vcl/source/layout/table.cxx
new file mode 100644
index 0000000..8bd34b3
--- /dev/null
+++ b/vcl/source/layout/table.cxx
@@ -0,0 +1,259 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_vcl.hxx"
+
+#include <vcl/table.hxx>
+
+struct CmpChild {
+ Widget m_child;
+ CmpChild (Widget &child) : m_child (child) {}
+
+ bool operator() (const Table::ChildData &childData)
+ { return childData.widget == m_child; }
+};
+
+Table::ChildData::ChildData (Widget &w, int rs, int cs, bool re, bool ce)
+: widget (w), rowSpan (rs), colSpan (cs), rowExpand (re), colExpand (ce)
+{}
+
+Table::Table (int cols)
+: m_colsLen (cols), m_rowsSpacing (0), m_colsSpacing (0), m_borderWidth (0), m_colsExpandables (0), m_rowsExpandables (0), m_parent (Widget::NIL)
+{}
+
+void Table::PackChild (Widget &child, int rowSpan, int colSpan, bool rowExpand, bool colExpand)
+{
+ if (rowSpan <= 0 || colSpan <= 0)
+ fprintf (stderr, "Table::PackChild Error: child must be given a "
+ "minimum of 1 of row-span and col-span\n");
+
+ m_children.push_back (ChildData (child, rowSpan, colSpan, rowExpand, colExpand));
+ child.SetParent (this);
+ QueueResize (this);
+}
+
+void Table::PackChild (Window *child, int rowSpan, int colSpan, bool rowExpand, bool colExpand)
+{ Widget w (child); PackChild (w, rowSpan, colSpan, rowExpand, colExpand); }
+void Table::PackChild (Layout *child, int rowSpan, int colSpan, bool rowExpand, bool colExpand)
+{ Widget w (child); PackChild (w, rowSpan, colSpan, rowExpand, colExpand); }
+
+void Table::SetSpacings (int rowSpacing, int colSpacing)
+{
+ m_rowsSpacing = rowSpacing; m_colsSpacing = colSpacing;
+ QueueResize (this);
+}
+
+void Table::AddChild (Widget &child)
+{
+ PackChild (child, 1, 1, true, true);
+}
+
+void Table::RemoveChild (Widget &child)
+{
+ CmpChild isChild (child);
+ m_children.remove_if (isChild);
+ QueueResize (this);
+}
+
+std::list <Widget> Table::GetChildren() const
+{
+ std::list <Widget> children;
+ for (std::list <ChildData>::const_iterator it = m_children.begin();
+ it != m_children.end(); it++)
+ children.push_back (it->widget);
+ return children;
+}
+
+void Table::SetBorderWidth (int borderWidth)
+{
+ m_borderWidth = borderWidth;
+ QueueResize (this);
+}
+
+Size Table::SizeRequest()
+{
+ if (m_requisition.Width() != 0 && m_requisition.Height() != 0)
+ return m_requisition;
+
+ Table *pThis = const_cast <Table *> (this);
+ int rowsLen = 0;
+
+ // 1. layout the table -- adjust to cope with row-spans...
+ {
+ // temporary 1D representation of the table
+ std::vector <ChildData *> table;
+
+ int col = 0, row = 0;
+ for (std::list <ChildData>::iterator it = pThis->m_children.begin();
+ it != pThis->m_children.end(); it++) {
+ ChildData *child = &(*it);
+ if (!child->widget.IsVisible()) continue;
+
+ while (col + SAL_MIN (child->colSpan, m_colsLen ) > m_colsLen) {
+ col = 0;
+ row++;
+
+ unsigned int i = col + (row * m_colsLen);
+ while (table.size() > i && !table[i]) i++;
+
+ col = i % m_colsLen; row = i / m_colsLen;
+ }
+
+ child->leftCol = col;
+ child->rightCol = SAL_MIN( col + child->colSpan, m_colsLen );
+ child->topRow = row;
+ child->bottomRow = row + child->rowSpan;
+
+ col += child->colSpan;
+
+ unsigned int start = child->leftCol +(child->topRow * m_colsLen);
+ unsigned int end = (child->rightCol-1) +((child->bottomRow-1) * m_colsLen);
+ if (table.size() < end+1)
+ table.resize( end+1, NULL );
+ for (unsigned int i = start; i < end; i++)
+ table[ i ] = child;
+
+ rowsLen = SAL_MAX (rowsLen, child->bottomRow);
+ }
+ }
+
+ // 2. calculate columns/rows sizes
+ for (int g = 0; g < 2; g++) {
+ std::vector <GroupData> &group = (g == 0) ? pThis->m_cols : pThis->m_rows;
+ group.clear();
+ group.resize (g == 0 ? m_colsLen : rowsLen);
+
+ // 2.1 base sizes on one-column/row children
+ for (std::list <ChildData>::iterator it = m_children.begin();
+ it != m_children.end(); it++) {
+ ChildData *child = &(*it);
+ if (!child->widget.IsVisible()) continue;
+ const int firstAttach = (g == 0) ? child->leftCol : child->topRow;
+ const int lastAttach = (g == 0) ? child->rightCol : child->bottomRow;
+
+ if (firstAttach == lastAttach-1) {
+ Size reqSize (child->widget.SizeRequest());
+ int childSize = (g == 0) ? reqSize.Width() : reqSize.Height();
+ bool childExpand = (g == 0) ? child->colExpand : child->rowExpand;
+ int attach = firstAttach;
+ group[attach].reqSize = SAL_MAX (group[attach].reqSize, childSize);
+ group[attach].expand = childExpand || group[attach].expand;
+ }
+ }
+
+ // 2.2 make sure multiple-columns/rows children fit
+ for (std::list <ChildData>::iterator it = m_children.begin();
+ it != m_children.end(); it++ ) {
+ ChildData *child = &(*it);
+ if (!child->widget.IsVisible()) continue;
+ const int firstAttach = (g == 0) ? child->leftCol : child->topRow;
+ const int lastAttach = (g == 0) ? child->rightCol : child->bottomRow;
+
+ if (firstAttach != lastAttach-1) {
+ Size reqSize (child->widget.SizeRequest());
+ int size = 0;
+ int expandables = 0;
+ for ( int i = firstAttach; i < lastAttach; i++ ) {
+ size += group[i].reqSize;
+ if (group[ i ].expand) expandables++;
+ }
+
+ int childSize = (g == 0) ? reqSize.Width() : reqSize.Height();
+ int extra = childSize - size;
+ if (extra > 0) {
+ if (expandables) extra /= expandables;
+ else extra /= lastAttach - firstAttach;
+
+ for (int i = firstAttach; i < lastAttach; i++)
+ if (expandables == 0 || group[i].expand)
+ group[i].reqSize += extra;
+ }
+ }
+ }
+ }
+
+ // 3. Sum everything up
+ pThis->m_colsExpandables = (pThis->m_rowsExpandables = 0);
+ int width = 0, height = 0;
+ for (std::vector <GroupData>::const_iterator it = m_cols.begin();
+ it != m_cols.end(); it++ ) {
+ width += it->reqSize;
+ if (it->expand)
+ pThis->m_colsExpandables++;
+ }
+ for (std::vector <GroupData>::const_iterator it = m_rows.begin();
+ it != m_rows.end(); it++ ) {
+ height += it->reqSize;
+ if (it->expand)
+ pThis->m_rowsExpandables++;
+ }
+
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list