File: AWT_modules.cxx

package info (click to toggle)
arb 6.0.6-8
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid, trixie
  • size: 66,204 kB
  • sloc: ansic: 394,911; cpp: 250,290; makefile: 19,644; sh: 15,879; perl: 10,473; fortran: 6,019; ruby: 683; xml: 503; python: 53; awk: 32
file content (75 lines) | stat: -rw-r--r-- 3,326 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// ============================================================= //
//                                                               //
//   File      : AWT_modules.cxx                                 //
//   Purpose   :                                                 //
//                                                               //
//   Coded by Ralf Westram (coder@reallysoft.de) in April 2012   //
//   Institute of Microbiology (Technical University Munich)     //
//   http://www.arb-home.de/                                     //
//                                                               //
// ============================================================= //

#include "awt_modules.hxx"
#include <aw_window.hxx>

#define awt_assert(cond) arb_assert(cond)

void awt_create_order_buttons(AW_window *aws, awt_orderfun reorder_cb, AW_CL cl) {
    // generates order buttons at current pos and binds them to 'reorder_cb'
    // 'cl' is forwarded to reorder_cb

    AW_at_auto auto_at;
    auto_at.store(aws->_at);

    aws->auto_space(1, 1);
    aws->at_newline();

    int x, y; aws->get_at_position(&x, &y);

    aws->callback((AW_CB)reorder_cb, ARM_TOP, cl); aws->create_button("moveTop", "#moveTop.xpm", 0);

    aws->at_newline();
    int yoff = aws->get_at_yposition()-y;
    awt_assert(yoff>0);

    aws->at(x, y+1*yoff); aws->callback((AW_CB)reorder_cb, ARM_UP,     cl); aws->create_button("moveUp",     "#moveUp.xpm",     0);
    aws->at(x, y+2*yoff); aws->callback((AW_CB)reorder_cb, ARM_DOWN,   cl); aws->create_button("moveDown",   "#moveDown.xpm",   0);
    aws->at(x, y+3*yoff); aws->callback((AW_CB)reorder_cb, ARM_BOTTOM, cl); aws->create_button("moveBottom", "#moveBottom.xpm", 0);

    auto_at.restore(aws->_at);
}

inline const char *bitmap_name(bool rightwards, bool all) {
    if (all) return rightwards ? "#moveAllRight.xpm" : "#moveAllLeft.xpm"; // uses_pix_res("moveAllRight.xpm", "moveAllLeft.xpm");
    return rightwards ? "#moveRight.xpm" : "#moveLeft.xpm";                // uses_pix_res("moveRight.xpm", "moveLeft.xpm"); see ../SOURCE_TOOLS/check_ressources.pl@uses_pix_res
}

void awt_create_collect_buttons(AW_window *aws, bool collect_rightwards, awt_collectfun collect_cb, AW_CL cl) {
    // generates collect buttons at current pos and binds them to 'collect_cb'
    // 'cl' is forwarded to 'collect_cb'
    // 'collect_rightwards' affects the direction of the buttons 

    AW_at_auto auto_at;
    auto_at.store(aws->_at);

    aws->auto_space(1, 1);
    aws->button_length(0);
    aws->at_newline();

    int x, y; aws->get_at_position(&x, &y);

    bool       collect = collect_rightwards;
    const bool all     = true;

    aws->callback((AW_CB)collect_cb, ACM_FILL, cl); aws->create_button("ADDALL", bitmap_name(collect, all), 0);

    aws->at_newline();
    int yoff = aws->get_at_yposition()-y;
    awt_assert(yoff>0);

    aws->at(x, y+1*yoff); aws->callback((AW_CB)collect_cb, ACM_ADD,    cl); aws->create_button("ADD",    bitmap_name(collect,  !all), 0);
    aws->at(x, y+2*yoff); aws->callback((AW_CB)collect_cb, ARM_DOWN,   cl); aws->create_button("REMOVE", bitmap_name(!collect, !all), 0);
    aws->at(x, y+3*yoff); aws->callback((AW_CB)collect_cb, ARM_BOTTOM, cl); aws->create_button("CLEAR",  bitmap_name(!collect, all),  0);

    auto_at.restore(aws->_at);
}