ARB
AWT_modules.cxx
Go to the documentation of this file.
1 // ============================================================= //
2 // //
3 // File : AWT_modules.cxx //
4 // Purpose : //
5 // //
6 // Coded by Ralf Westram (coder@reallysoft.de) in April 2012 //
7 // Institute of Microbiology (Technical University Munich) //
8 // http://www.arb-home.de/ //
9 // //
10 // ============================================================= //
11 
12 #include "awt_modules.hxx"
13 #include <aw_window.hxx>
14 
15 #define awt_assert(cond) arb_assert(cond)
16 
18  // generates order buttons at current pos and binds them to 'reorder_cb'
19  // 'cl' is forwarded to reorder_cb
20 
22 
23  aws->auto_space(1, 1);
24  aws->at_newline();
25 
26  int x, y; aws->get_at_position(&x, &y);
27 
28  aws->callback(makeWindowCallback(reorder_cb, ARM_TOP, cl)); aws->create_button("moveTop", "#moveTop.xpm");
29 
30  aws->at_newline();
31  int yoff = aws->get_at_yposition()-y;
32  awt_assert(yoff>0);
33 
34  aws->at(x, y+1*yoff); aws->callback(makeWindowCallback(reorder_cb, ARM_UP, cl)); aws->create_button("moveUp", "#moveUp.xpm");
35  aws->at(x, y+2*yoff); aws->callback(makeWindowCallback(reorder_cb, ARM_DOWN, cl)); aws->create_button("moveDown", "#moveDown.xpm");
36  aws->at(x, y+3*yoff); aws->callback(makeWindowCallback(reorder_cb, ARM_BOTTOM, cl)); aws->create_button("moveBottom", "#moveBottom.xpm");
37 
38  aws->restore_at_from(*auto_at);
39 }
40 
41 inline const char *bitmap_name(bool rightwards, bool all) {
42  if (all) return rightwards ? "#moveAllRight.xpm" : "#moveAllLeft.xpm"; // uses_pix_res("moveAllRight.xpm", "moveAllLeft.xpm");
43  return rightwards ? "#moveRight.xpm" : "#moveLeft.xpm"; // uses_pix_res("moveRight.xpm", "moveLeft.xpm"); see ../SOURCE_TOOLS/check_resources.pl@uses_pix_res
44 }
45 
46 void UNTYPED::awt_create_collect_buttons(AW_window *aws, bool collect_rightwards, awt_collectfun collect_cb, AW_CL cl) {
47  // generates collect buttons at current pos and binds them to 'collect_cb'
48  // 'cl' is forwarded to 'collect_cb'
49  // 'collect_rightwards' affects the direction of the buttons
50 
52 
53  aws->auto_space(1, 1);
54  aws->button_length(0);
55  aws->at_newline();
56 
57  int x, y; aws->get_at_position(&x, &y);
58 
59  bool collect = collect_rightwards;
60  const bool all = true;
61 
62  aws->callback(makeWindowCallback(collect_cb, ACM_FILL, cl)); aws->create_button("ADDALL", bitmap_name(collect, all));
63 
64  aws->at_newline();
65  int yoff = aws->get_at_yposition()-y;
66  awt_assert(yoff>0);
67 
68  aws->at(x, y+1*yoff); aws->callback(makeWindowCallback(collect_cb, ACM_ADD, cl)); aws->create_button("ADD", bitmap_name(collect, !all));
69  aws->at(x, y+2*yoff); aws->callback(makeWindowCallback(collect_cb, ACM_REMOVE, cl)); aws->create_button("REMOVE", bitmap_name(!collect, !all));
70  aws->at(x, y+3*yoff); aws->callback(makeWindowCallback(collect_cb, ACM_EMPTY, cl)); aws->create_button("CLEAR", bitmap_name(!collect, all));
71 
72  aws->restore_at_from(*auto_at);
73 }
void get_at_position(int *x, int *y) const
Definition: AW_at.cxx:296
void button_length(int length)
Definition: AW_at.cxx:288
group_matcher all()
Definition: test_unit.h:1011
static char * y[maxsp+1]
void at(int x, int y)
Definition: AW_at.cxx:93
void(* awt_orderfun)(AW_window *aww, awt_reorder_mode pos, AW_CL cl_user)
Definition: awt_modules.hxx:37
void(* awt_collectfun)(AW_window *aww, awt_collect_mode what, AW_CL cl_user)
Definition: awt_modules.hxx:38
#define awt_assert(cond)
Definition: AWT_modules.cxx:15
Generic smart pointer.
Definition: smartptr.h:149
void restore_at_from(const AW_at_storage &stored)
Definition: aw_window.hxx:560
void awt_create_order_buttons(AW_window *aws, awt_orderfun reorder_cb, AW_CL cl_user)
Definition: AWT_modules.cxx:17
static AW_at_storage * make(AW_window *aww, AW_at_storage_type type)
Definition: AW_at.cxx:449
void auto_space(int xspace, int yspace)
Definition: AW_at.cxx:259
long AW_CL
Definition: cb.h:21
void awt_create_collect_buttons(AW_window *aws, bool collect_rightwards, awt_collectfun collect_cb, AW_CL cl_user)
Definition: AWT_modules.cxx:46
void callback(const WindowCallback &cb)
Definition: AW_window.cxx:133
int get_at_yposition() const
Definition: AW_at.cxx:305
void at_newline()
Definition: AW_at.cxx:119
const char * bitmap_name(bool rightwards, bool all)
Definition: AWT_modules.cxx:41
void create_button(const char *macro_name, AW_label label, const char *mnemonic=NULp, const char *color=NULp)
Definition: AW_button.cxx:448