diff options
author | Sebastian Geerken <devnull@localhost> | 2015-06-09 23:15:39 +0200 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2015-06-09 23:15:39 +0200 |
commit | c1489885decc91520542f54da489af5290e8a98c (patch) | |
tree | e757da14394cb2f3032c993acec6a6eec221a5f0 /dw/tools.hh | |
parent | 7c8f69de8bc95c6078ee5fc0b63d263a80f31b44 (diff) |
SRDOP: Some refactoring.
Diffstat (limited to 'dw/tools.hh')
-rw-r--r-- | dw/tools.hh | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/dw/tools.hh b/dw/tools.hh new file mode 100644 index 00000000..04084a60 --- /dev/null +++ b/dw/tools.hh @@ -0,0 +1,59 @@ +#ifndef __DW_TOOLS_HH__ +#define __DW_TOOLS_HH__ + +#include "core.hh" +#include "../lout/debug.hh" + +namespace dw { +namespace core { + +/** + * \brief Hold arguments passed to dw::core::Widget::sizeRequest and + * dw::core::Widget::getExtremes, as described in \ref dw-size-request-pos. + */ +class SizeParams +{ +private: + int numPos; + Widget **references; + int *x, *y; + + void init (); + void cleanup (); + +public: + SizeParams (); + ~SizeParams (); + + void fill (int numPos, Widget **references, int *x, int *y); + void forChild (Widget *parent, Widget *child, int xRel, int yRel, + SizeParams *childParams); + bool findReference (Widget *reference, int *x, int *y); + + inline int getNumPos () { return numPos; } + inline Widget **getReferences () { return references; } + inline int *getX () { return x; } + inline int *getY () { return y; } + inline Widget *getReference (int i) { return references[i]; } + inline int getX (int i) { return x[i]; } + inline int getY (int i) { return y[i]; } +}; + +#define DBG_SET_SIZE_PARAMS(prefix, params) \ + D_STMT_START { \ + DBG_IF_RTFL { \ + DBG_OBJ_SET_NUM (prefix ".numPos", params.getNumPos ()); \ + for (int i = 0; i < params.getNumPos (); i++) { \ + DBG_OBJ_ARRSET_PTR (prefix ".references", i, \ + params.getReference (i)); \ + DBG_OBJ_ARRSET_NUM (prefix ".x", i, params.getX (i)); \ + DBG_OBJ_ARRSET_NUM (prefix ".y", i, params.getY (i)); \ + } \ + } \ + } D_STMT_END + + +} // namespace core +} // namespace dw + +#endif // __DW_TOOLS_HH__ |