Example #1
0
void main_window::
no_node_selected (
)
{
    // Make it so that no node is selected on the gui.  Do this by disabling things
    // and clearing out text fields and so forth.


    node_is_selected = false;
    tables.disable();
    sel_node_evidence.disable();
    sel_node_is_evidence.disable();
    sel_node_index.disable();
    sel_node_evidence_label.disable();
    sel_node_text_label.disable();
    sel_node_text.disable();
    sel_node_index.set_text("index:");
    sel_node_num_values_label.disable();
    sel_node_num_values.disable();
    cpt_grid.set_grid_size(0,0);
    ppt_grid.set_grid_size(0,0);

    sel_node_is_evidence.set_unchecked();
    sel_node_text.set_text("");
    sel_node_num_values.set_text("");
    sel_node_evidence.set_text("");
    sel_node_num_values.set_background_color(color_default_bg);
    sel_node_evidence.set_background_color(color_default_bg);
}
Example #2
0
	void initialize_widgets()
	{
		static internationalization i18n{};
		auto bg_color = 0xefefef;

		fm.icon(main_icon());
		fm.caption(i18n("form_title"));
		fm.background(bg_color);

		auto width = fm.size().width;
		lst_songs.append_header(i18n("Artist"), width / 6);
		lst_songs.append_header(i18n("Title"), width / 3);
		lst_songs.append_header(i18n("File"), width / 2);

		lbl_songs.caption(i18n("Songs") + L":");
		lbl_songs.background(bg_color);
		lbl_songs.text_align(align::left, align_v::center);

		chk_matched.caption(i18n("Matched only"));
		chk_matched.background(bg_color);

		txt_search.multi_lines(false);

		btn_search.background(bg_color);

		pl.div("margin=10 vertical"
			"<weight=22 <search arrange=[variable, 120, 100, 22]> >"
			"<weight=10>"
			"<lst>"
			);
		pl["lst"] << lst_songs;
		pl["search"] << lbl_songs << chk_matched << txt_search << btn_search;
		pl.collocate();
	}
Example #3
0
// This event is called by the graph_drawer widget when the user selects a node
void main_window::
on_node_selected (unsigned long n)
{
    // make a reference to the selected node
    node_type& node = graph_drawer.graph_node(n);


    // enable all the widgets related to the selected node
    selected_node_index = n;
    node_is_selected = true;
    tables.enable();
    sel_node_is_evidence.enable();
    sel_node_index.enable();
    sel_node_evidence_label.enable();
    sel_node_text_label.enable();
    sel_node_text.enable();
    sel_node_num_values_label.enable();
    sel_node_num_values.enable();

    // make sure the num_values field of the node's cpt is set to something valid. 
    // So default it to 2 if it isn't set already.
    if (node.data.table().num_values() < 2)
    {
        node.data.table().set_num_values(2);
        graph_modified_since_last_recalc = true;
    }

    // setup the evidence check box and input field
    sel_node_index.set_text("index: " + cast_to_string(n));
    if (graph_drawer.graph_node(n).data.is_evidence())
    {
        sel_node_is_evidence.set_checked();
        sel_node_evidence.enable();
        sel_node_evidence.set_text(cast_to_string(graph_drawer.graph_node(n).data.value()));
    }
    else
    {
        sel_node_is_evidence.set_unchecked();
        sel_node_evidence.disable();
        sel_node_evidence.set_text("");
    }

    sel_node_num_values.set_text(cast_to_string(node_num_values(graph_drawer.graph(),n)));

    sel_node_text.set_text(graph_drawer.node_label(n));

    load_selected_node_tables_into_cpt_grid();
    load_selected_node_tables_into_ppt_grid();
}
Example #4
0
	goto_cell_dialog(QWidget *parent = 0) : dialog(parent)
	{
		bind(cell_changed).to <&T::cell_changed_>();

//-----------------------------------------------------------------------------

		QRegExp regExp("[A-Za-z][1-9][0-9]{0,2}");
		cell_edit = new line_edit;
		cell_edit->setValidator(new QRegExpValidator(regExp, this));

		cell_label = new label(tr("&Cell Location:"));
#ifndef QT_NO_SHORTCUT
		cell_label->setBuddy(cell_edit);
#endif

		button_box = new dialog_button_box;
		button_box->setOrientation(Qt::Horizontal);
		button_box->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok);
		button_box->button(QDialogButtonBox::Ok)->setEnabled(false);

		button_box->accepted.connect(accept);
		button_box->rejected.connect(reject);
		cell_edit->text_changed.connect(cell_changed);

//-----------------------------------------------------------------------------

		row_layout* cell_layout = new row_layout;
		*cell_layout << cell_label << cell_edit;

		col_layout* goto_layout = new col_layout;
		*goto_layout << cell_layout << button_box;

		setLayout(goto_layout);
		setWindowTitle(tr("Go to Cell"));
	}
Example #5
0
 switch_instruction switch_(value const & cond, label const & default_)
 {
   llvm::IRBuilder<> & bldr = current_builder();
   llvm::SwitchInst * rv = SPRITE_APICALL(
       bldr.CreateSwitch(cond.ptr(), default_.ptr())
     );
   return switch_instruction(rv);
 }
Example #6
0
    escape_catalogue::escape_catalogue(user_interaction & dialog,
				       const pile_descriptor & x_pdesc,
				       const datetime & root_last_modif,
				       const label & data_name) : catalogue(dialog, root_last_modif, data_name)
    {
	set_esc_and_stack(x_pdesc);
	x_reading_ver = macro_tools_supported_version;
	x_default_algo = none;
	x_lax = false;
	corres.clear();
	status = ec_completed; // yes, with that constructor, the catalogue contains all known object and entree do not miss any field
	cat_det = NULL;
	min_read_offset = 0;
	depth = 0; // we start at the root... of course
	wait_parent_depth = 0; // to disable this feature

	    // dropping the data_name in the archive
	pdesc.stack->sync_write_above(pdesc.esc); // esc is now up to date
	pdesc.esc->add_mark_at_current_position(escape::seqt_data_name);
	data_name.dump(*pdesc.esc);
    }
Example #7
0
    win (
    ): 
        drawable_window(true),
        lbl_last_keydown(*this),
        lbl_mod_shift(*this),
        lbl_mod_control(*this),
        lbl_mod_alt(*this),
        lbl_mod_meta(*this),
        lbl_mod_caps_lock(*this),
        lbl_mod_num_lock(*this),
        lbl_mod_scroll_lock(*this),
        b(*this),
        btn_count(*this),
        btn_get_clipboard(*this),
        btn_set_clipboard(*this),
        btn_show_message(*this),
        cb1(*this,rectangle(100,100,200,200),255,0,0),
        cb2(*this,rectangle(150,150,250,240),0,255,0),
        cbl(*this),
        cbox(*this),
        group1(*this),
        group2(*this),
        group3(*this),
        keyboard_count(1),
        keydown(*this),
        keyup(*this),
        l1(*this),
        l2(*this),
        l3(*this),
        lb(*this),
        leave_count(*this),
        left_down(*this),
        left_up(*this),
        middle_down(*this),
        middle_up(*this),
        mouse_state(*this),
        mt(*this),
        nrect(*this),
        pos(*this),
        rb(*this),
        right_down(*this),
        right_up(*this),
        sb2(*this,scroll_bar::VERTICAL),
        sb3(*this,scroll_bar::VERTICAL),
        sb_enabled(*this),
        sbl2(*this),
        sbl3(*this),
        sbl(*this),
        sb_shown(*this),
        sb(*this,scroll_bar::HORIZONTAL),
        scroll(*this),
        tab_label(*this),
        tabs(*this),
        tf(*this),
        mbar(*this)
    {
        bool use_bdf_fonts = false;

        
        if (use_bdf_fonts)
        {
            ifstream fin("/home/davis/source/10x20.bdf");
            f.read_bdf_file(fin,0xFFFF);

            mt.set_main_font(&f);
        }
        //mt.hide();
        mt.set_pos(5,200);


        lbl_last_keydown.set_text("?");
        lbl_mod_shift.set_text("?");
        lbl_mod_control.set_text("?");
        lbl_mod_alt.set_text("?");
        lbl_mod_meta.set_text("?");
        lbl_mod_caps_lock.set_text("?");
        lbl_mod_num_lock.set_text("?");
        lbl_mod_scroll_lock.set_text("?");

        lbl_last_keydown.set_pos(20,420);
        lbl_mod_shift.set_pos(20,lbl_last_keydown.bottom()+5);
        lbl_mod_control.set_pos(20,lbl_mod_shift.bottom()+5);
        lbl_mod_alt.set_pos(20,lbl_mod_control.bottom()+5);
        lbl_mod_meta.set_pos(20,lbl_mod_alt.bottom()+5);
        lbl_mod_caps_lock.set_pos(20,lbl_mod_meta.bottom()+5);
        lbl_mod_num_lock.set_pos(20,lbl_mod_caps_lock.bottom()+5);
        lbl_mod_scroll_lock.set_pos(20,lbl_mod_num_lock.bottom()+5);

        lb.set_pos(580,200);
        lb.set_size(200,300);
        if (use_bdf_fonts)
            lb.set_main_font(&f);

        dlib::queue<string>::kernel_2a_c qos;
        string a;
        a = "Davis"; qos.enqueue(a);
        a = "king"; qos.enqueue(a);
        a = "one"; qos.enqueue(a);
        a = "two"; qos.enqueue(a);
        a = "three"; qos.enqueue(a);
        a = "yo yo yo alsdkjf asfj lsa jfsf\n this is a long phrase"; qos.enqueue(a);
        a = "four"; qos.enqueue(a);
        a = "five"; qos.enqueue(a);
        a = "six"; qos.enqueue(a);
        a = "seven"; qos.enqueue(a);
        a = "eight"; qos.enqueue(a);
        a = "nine"; qos.enqueue(a);
        a = "ten"; qos.enqueue(a);
        a = "eleven"; qos.enqueue(a);
        a = "twelve"; qos.enqueue(a);
        for (int i = 0; i < 1000; ++i)
        {
            a = "thirteen"; qos.enqueue(a);
        }
        lb.load(qos);
        lb.select(1);
        lb.select(2);
        lb.select(3);
        lb.select(5);
        lb.enable_multiple_select();
        lb.set_double_click_handler(*this,&win::lb_double_click);
        //        lb.disable_multiple_select();

        btn_show_message.set_pos(50,350);
        btn_show_message.set_name("message_box()");
        mbar.set_number_of_menus(2);
        mbar.set_menu_name(0,"File",'F');
        mbar.set_menu_name(1,"Help",'H');
        mbar.menu(0).add_menu_item(menu_item_text("show msg click",*this,&win::on_show_msg_click,'s'));
        mbar.menu(0).add_menu_item(menu_item_text("get clipboard",*this,&win::on_get_clipboard,'g'));
        mbar.menu(0).add_menu_item(menu_item_text("set clipboard",*this,&win::on_set_clipboard,'c'));
        mbar.menu(0).add_menu_item(menu_item_separator());
        mbar.menu(0).add_submenu(menu_item_submenu("submenu",'m'), submenu);
        submenu.add_menu_item(menu_item_separator());
        submenu.add_menu_item(menu_item_separator());
        submenu.add_menu_item(menu_item_text("show msg click",*this,&win::on_show_msg_click,'s'));
        submenu.add_menu_item(menu_item_text("get clipboard",*this,&win::on_get_clipboard,'g'));
        submenu.add_menu_item(menu_item_text("set clipboard",*this,&win::on_set_clipboard,'c'));
        submenu.add_menu_item(menu_item_separator());
        submenu.add_menu_item(menu_item_separator());
        mbar.menu(1).add_menu_item(menu_item_text("About",*this,&win::on_menu_help,'A'));

        btn_show_message.set_click_handler(*this,&win::on_show_msg_click);
        btn_get_clipboard.set_pos(btn_show_message.right()+5,btn_show_message.top());
        btn_get_clipboard.set_name("get_from_clipboard()");
        btn_get_clipboard.set_click_handler(*this,&win::on_get_clipboard);

        btn_get_clipboard.set_style(button_style_toolbar1());
        btn_set_clipboard.set_pos(btn_get_clipboard.right()+5,btn_get_clipboard.top());
        btn_set_clipboard.set_name("put_on_clipboard()");
        btn_set_clipboard.set_click_handler(*this,&win::on_set_clipboard);

        nrect.set_size(700,500);
        nrect.set_name("test widgets");
        nrect.set_pos(2,mbar.bottom()+2);

        //throw dlib::error("holy crap batman");
        tab_label.set_pos(10,440);

        tabs.set_click_handler(*this,&win::tab_change); 
        tabs.set_pos(5,mbar.bottom()+10);
        tabs.set_size(280,100);
        tabs.set_number_of_tabs(3);
        tabs.set_tab_name(0,"davis");
        tabs.set_tab_name(1,"edward");
        tabs.set_tab_name(2,"king alsklsdkfj asfd");
        tabs.set_tab_group(0,group1);
        tabs.set_tab_group(1,group2);
        tabs.set_tab_group(2,group3);

        l1.set_text("group one");
        l2.set_text("group two");
        l3.set_text("group three");

        group1.add(l1,0,0);
        group2.add(l2,20,10);
        group3.add(l3,0,0);



        sb_enabled.set_name("enabled");
        sb_shown.set_name("shown");
        sb_shown.set_checked();
        sb_enabled.set_checked();
        sb_shown.set_click_handler(*this,&win::cb_sb_shown);
        sb_enabled.set_click_handler(*this,&win::cb_sb_enabled);
        
        sb_shown.set_tooltip_text("I'm a checkbox");

        rb.set_click_handler(*this,&win::rb_click);


        sb3.set_pos(440,mbar.bottom()+10);
        sb3.set_max_slider_pos(300);
        sb3.set_slider_pos(150);
        sb3.set_length(300);
        sb2.set_pos(470,mbar.bottom()+10);
        sb2.set_max_slider_pos(300);
        sb2.set_length(300);
        sb.set_pos(500,mbar.bottom()+10);
        sb.set_max_slider_pos(30);
        sb.set_length(300);


        sb.set_scroll_handler(*this,&win::scroll_handler);
        sb2.set_scroll_handler(*this,&win::scroll2_handler);
        sb3.set_scroll_handler(*this,&win::scroll3_handler);
        sbl.set_pos(540,mbar.bottom()+20);
        sbl2.set_pos(540,mbar.bottom()+40);
        sbl3.set_pos(540,mbar.bottom()+60);

        cbox.set_pos(300,mbar.bottom()+30);
        cbox.set_name("davis king");
        cbox.set_click_handler(*this,&win::cbox_clicked);

        cbl.set_pos(300,cbox.get_rect().bottom()+1);
        cbox.set_checked();
        sb_enabled.set_pos(cbox.get_rect().left(),cbox.get_rect().bottom()+20);
        sb_shown.set_pos(sb_enabled.get_rect().left(),sb_enabled.get_rect().bottom()+2);



        if (use_bdf_fonts)
            rb.set_main_font(&f);
        rb.set_name("radio button");
        rb.set_pos(sb_shown.get_rect().left(),sb_shown.get_rect().bottom()+2);


        cb1.set_z_order(10);
        cb2.set_z_order(20);

        pos.set_pos(50,50);
        left_up.set_pos(50,70);
        left_down.set_pos(50,90);
        middle_up.set_pos(50,110);
        middle_down.set_pos(50,130);
        right_up.set_pos(50,150);
        right_down.set_pos(50,170);

        mouse_state.set_pos(50,190);

        leave_count.set_pos(50,210);

        scroll_count = 0;
        scroll.set_pos(50,230);

        btn_count.set_pos(50,250);


        keydown.set_pos(50,270);
        keyup.set_pos(50,290);

        tf.set_pos(50,310);
        tf.set_text("Davis685g@");
        tf.set_width(500);
        tf.set_text_color(rgb_pixel(255,0,0));
        

        button_count = 0;
        count = 0;
        b.set_name("button");
        b.set_pos(540,100);
        b.set_click_handler(*this,&win::on_click);
        b.set_tooltip_text("hurray i'm a button!");
        if (use_bdf_fonts)
            b.set_main_font(&f);


        set_size(800,500);

        nrect.wrap_around(
            cbox.get_rect() +
            rb.get_rect() + 
            sb_enabled.get_rect() + 
            sb_shown.get_rect());

        flip = 0;
        open_file_box(*this,&win::on_open_file);
        open_existing_file_box(*this,&win::on_open_file);
        save_file_box(*this,&win::on_open_file);

        if (use_bdf_fonts)
            tf.set_main_font(&f);
        if (use_bdf_fonts)
            tabs.set_main_font(&f);

    }
Example #8
0
    void on_keydown (
        unsigned long key,
        bool is_printable,
        unsigned long state
    )
    {
        if (is_printable)
            lbl_last_keydown.set_text(string("last keydown: ") + (char)key);
        else
            lbl_last_keydown.set_text(string("last keydown: nonprintable"));

        if (state&base_window::KBD_MOD_SHIFT)
            lbl_mod_shift.set_text("shift is on");
        else
            lbl_mod_shift.set_text("shift is off");

        if (state&base_window::KBD_MOD_CONTROL)
            lbl_mod_control.set_text("control is on");
        else
            lbl_mod_control.set_text("control is off");

        if (state&base_window::KBD_MOD_ALT)
            lbl_mod_alt.set_text("alt is on");
        else
            lbl_mod_alt.set_text("alt is off");


        if (state&base_window::KBD_MOD_META)
            lbl_mod_meta.set_text("meta is on");
        else
            lbl_mod_meta.set_text("meta is off");

        if (state&base_window::KBD_MOD_CAPS_LOCK)
            lbl_mod_caps_lock.set_text("caps_lock is on");
        else
            lbl_mod_caps_lock.set_text("caps_lock is off");

        if (state&base_window::KBD_MOD_NUM_LOCK)
            lbl_mod_num_lock.set_text("num_lock is on");
        else
            lbl_mod_num_lock.set_text("num_lock is off");


        if (state&base_window::KBD_MOD_SCROLL_LOCK)
            lbl_mod_scroll_lock.set_text("scroll_lock is on");
        else
            lbl_mod_scroll_lock.set_text("scroll_lock is off");

        drawable_window::on_keydown(key,is_printable,state);
    }
Example #9
0
 instruction goto_(label const & target)
 {
   llvm::IRBuilder<> & bldr = current_builder();
   return instruction(SPRITE_APICALL(bldr.CreateBr(target.ptr())));
 }
Example #10
0
// This event is called when the user resizes the main_window.  Note that unlike the other
// events, this event is part of the drawable_window base class that main_window inherits from.
// So you won't see any statements in the constructor that say "register the main_window::on_window_resized function"
void main_window::
on_window_resized ()
{
    // when you override any of the drawable_window events you have to make sure you 
    // call the drawable_window's version of them because it needs to process
    // the events as well.  So we do that here.
    drawable_window::on_window_resized();

    // The rest of this function positions the widgets on the window 
    unsigned long width,height;
    get_size(width,height);

    // Don't do anything if the user just made the window too small.  That is, leave
    // the widgets where they are.
    if (width < 500 || height < 350)
        return;

    // Set the size of the probability tables and the drawing area for the graph
    graph_drawer.set_size(width-370,height-10-mbar.height());
    cpt_grid.set_size((width-graph_drawer.width())-35,height-237);
    ppt_grid.set_size((width-graph_drawer.width())-35,height-237);
    // tell the tabbed display to make itself just the right size to contain
    // the two probability tables.
    tables.fit_to_contents();


    // Now position all the widgets in the window.  Note that much of the positioning
    // is relative to other widgets.  This part of the code I just figured out by
    // trying stuff and rerunning the program to see if it looked nice. 
    sel_node_index.set_pos(graph_drawer.right()+14,graph_drawer.top()+18);
    sel_node_text_label.set_pos(sel_node_index.left(),sel_node_index.bottom()+5);
    sel_node_text.set_pos(sel_node_text_label.right()+5,sel_node_index.bottom());
    sel_node_num_values_label.set_pos(sel_node_index.left(), sel_node_text.bottom()+5);
    sel_node_num_values.set_pos(sel_node_num_values_label.right(), sel_node_text.bottom()+5);
    sel_node_is_evidence.set_pos(sel_node_index.left(),sel_node_num_values.bottom()+5);
    sel_node_evidence_label.set_pos(sel_node_index.left(),sel_node_is_evidence.bottom()+5);
    sel_node_evidence.set_pos(sel_node_evidence_label.right()+5,sel_node_is_evidence.bottom());
    tables.set_pos(sel_node_index.left(),sel_node_evidence.bottom()+5);
    sel_node_evidence.set_width(tables.right()-sel_node_evidence.left()+1);
    sel_node_text.set_width(tables.right()-sel_node_text.left()+1);
    sel_node_num_values.set_width(tables.right()-sel_node_num_values.left()+1);



    // Tell the named rectangle to position itself such that it fits around the 
    // tabbed display that contains the probability tables and the label at the top of the
    // screen.
    selected_node_rect.wrap_around(sel_node_index.get_rect()+
                                   tables.get_rect());

    // finally set the button to be at the bottom of the named rectangle 
    btn_calculate.set_pos(selected_node_rect.left(), selected_node_rect.bottom()+5);
}
Example #11
0
void assembler::_label(label& l, const std::string& globalname)
{
	l.set(data.size());
	globals[globalname] = &l;
}
Example #12
0
void assembler::_label(label& l)
{
	l.set(data.size());
}