コード例 #1
0
ファイル: project_ui.c プロジェクト: armando-2011/grace
ProjectUI *create_project_ui(ExplorerUI *eui)
{
    ProjectUI *ui;
    Widget form, fr, rc, rc1;

    form = CreateVContainer(eui->scrolled_window);
    AddHelpCB(form, "doc/UsersGuide.html#project-properties");
    
    ui = xmalloc(sizeof(ProjectUI));
    ui->current_page_units = PAGE_UNITS_PP;

    fr = CreateFrame(form, "Project description");
    ui->description  = CreateScrolledText(fr, "", 5);
    AddTextActivateCB(ui->description, text_explorer_cb, eui);

    fr = CreateFrame(form, "Page dimensions");
    rc1 = CreateVContainer(fr);

    rc = CreateHContainer(rc1);
    ui->page_orient = CreatePaperOrientationChoice(rc, "Orientation:");
    AddOptionChoiceCB(ui->page_orient, do_orient_toggle, ui);
    AddOptionChoiceCB(ui->page_orient, oc_explorer_cb, eui);

    ui->page_format = CreatePaperFormatChoice(rc, "Size:");
    AddOptionChoiceCB(ui->page_format, do_format_toggle, ui);
    AddOptionChoiceCB(ui->page_format, oc_explorer_cb, eui);

    rc = CreateHContainer(rc1);
    ui->page_x = CreateText2(rc, "Dimensions:", 7);
    AddTextActivateCB(ui->page_x, text_explorer_cb, eui);
    ui->page_y = CreateText2(rc, "x ", 7);
    AddTextActivateCB(ui->page_y, text_explorer_cb, eui);
    ui->page_size_unit = CreateOptionChoiceVA(rc, " ",
        "pp", PAGE_UNITS_PP,
        "in", PAGE_UNITS_IN,
        "cm", PAGE_UNITS_CM,
        NULL);
    SetOptionChoice(ui->page_size_unit, ui->current_page_units);
    AddOptionChoiceCB(ui->page_size_unit, do_units_toggle, ui);

    
    fr = CreateFrame(form, "Page background");
    FormAddVChild(form, fr);
    rc = CreateHContainer(fr);
    ui->bg_color = CreateColorChoice(rc, "Color:");
    AddOptionChoiceCB(ui->bg_color, oc_explorer_cb, eui);
    ui->bg_fill = CreateToggleButton(rc, "Fill");
    AddToggleButtonCB(ui->bg_fill, tb_explorer_cb, eui);

    fr = CreateFrame(form, "Scaling factors");
    FormAddVChild(form, fr);
    rc = CreateVContainer(fr);
    ui->fsize_scale = CreateSpinChoice(rc, "Font size:", 5,
        SPIN_TYPE_FLOAT, 0.0, 1.0, 0.005);
    AddSpinChoiceCB(ui->fsize_scale, sp_explorer_cb, eui);
    ui->lwidth_scale = CreateSpinChoice(rc, "Line width:", 6,
        SPIN_TYPE_FLOAT, 0.0, 1.0, 0.0005);
    AddSpinChoiceCB(ui->lwidth_scale, sp_explorer_cb, eui);

    fr = CreateFrame(form, "Data & Dates");
    rc1 = CreateVContainer(fr);
    ui->prec = CreateSpinChoice(rc1, "Data precision:", 3,
        SPIN_TYPE_INT, DATA_PREC_MIN, DATA_PREC_MAX, 1);
    AddSpinChoiceCB(ui->prec, sp_explorer_cb, eui);
    ui->refdate = CreateText2(rc1, "Reference date:", 20);
    AddTextActivateCB(ui->refdate, text_explorer_cb, eui);
    rc = CreateHContainer(rc1);
    ui->two_digits_years = CreateToggleButton(rc, "Two-digit year span");
    AddToggleButtonCB(ui->two_digits_years, tb_explorer_cb, eui);
    ui->wrap_year = CreateText2(rc, "Wrap year:", 4);
    AddTextActivateCB(ui->wrap_year, text_explorer_cb, eui);
    AddToggleButtonCB(ui->two_digits_years, wrap_year_cb, ui->wrap_year);
    
    ui->top = form;
    
    return ui;
}
コード例 #2
0
ファイル: explorer.c プロジェクト: mariusal/grace
void raise_explorer(GUI *gui, Quark *q)
{
    GraceApp *gapp = gui->P;

    set_wait_cursor();
    
    if (!gui->eui) {
        ExplorerUI *eui;
        Widget menubar, menupane, panel, form, fr;

        eui = xmalloc(sizeof(ExplorerUI));
        gui->eui = eui;

        eui->a_icon = XpmToPixmap(active_xpm);
        eui->h_icon = XpmToPixmap(hidden_xpm);

        eui->top = CreateDialog(app_shell, "Explorer");
        menubar = CreateMenuBar(eui->top);
        WidgetManage(menubar);
        FormAddVChild(eui->top, menubar);

        menupane = CreateMenu(menubar, "File", 'F', FALSE);
        CreateMenuButtonA(menupane, "Close", 'C', "<Key>Escape", "Esc", destroy_dialog_cb, eui->top);

        menupane = CreateMenu(menubar, "Edit", 'E', FALSE);
        eui->edit_undo_bt = CreateMenuButtonA(menupane, "Undo", 'U', "Ctrl<Key>z", "Ctrl+Z",
            undo_cb, gapp);
        eui->edit_redo_bt = CreateMenuButtonA(menupane, "Redo", 'R', "Ctrl Shift<Key>z", "Ctrl+Shift+Z",
            redo_cb, gapp);

        menupane = CreateMenu(menubar, "Insert", 'I', FALSE);
        eui->insert_frame_bt = CreateMenuButton(menupane,
            "Frame", '\0', add_frame_cb, eui);
        WidgetSetSensitive(eui->insert_frame_bt,  FALSE);
        eui->insert_graph_bt = CreateMenuButton(menupane,
            "Graph", '\0', add_graph_cb, eui);
        WidgetSetSensitive(eui->insert_graph_bt,  FALSE);
        eui->insert_ssd_bt = CreateMenuButton(menupane,
            "SSData", '\0', add_ssd_cb, eui);
        WidgetSetSensitive(eui->insert_ssd_bt,    FALSE);
        eui->insert_set_bt = CreateMenuButton(menupane,
            "Set", '\0', add_set_cb, eui);
        WidgetSetSensitive(eui->insert_set_bt,    FALSE);
        eui->insert_axisgrid_bt = CreateMenuButton(menupane,
            "Axis grid", '\0', add_axisgrid_cb, eui);
        WidgetSetSensitive(eui->insert_axisgrid_bt,   FALSE);
        eui->insert_axis_bt = CreateMenuButton(menupane,
            "Axis", '\0', add_axis_cb, eui);
        WidgetSetSensitive(eui->insert_axis_bt,   FALSE);
        eui->insert_object_pane = CreateMenu(menupane, "Annotating objects", 'o', FALSE);
        WidgetSetSensitive(eui->insert_object_pane, FALSE);
        eui->insert_text_bt = CreateMenuButton(eui->insert_object_pane,
            "Text", '\0', add_object_cb, eui);
        eui->insert_line_bt = CreateMenuButton(eui->insert_object_pane,
            "Line", '\0', add_object_cb, eui);
        eui->insert_box_bt = CreateMenuButton(eui->insert_object_pane,
            "Box", '\0', add_object_cb, eui);
        eui->insert_arc_bt = CreateMenuButton(eui->insert_object_pane,
            "Arc", '\0', add_object_cb, eui);

        menupane = CreateMenu(menubar, "Options", 'O', FALSE);
        eui->instantupdate = CreateMenuToggle(menupane, "Instantaneous update",
                            'u', NULL, NULL);
        ToggleButtonSetState(eui->instantupdate, gui->instant_update);

        menupane = CreateMenu(menubar, "Help", 'H', TRUE);
        CreateMenuHelpButton(menupane, "On explorer", 'e',
            eui->top, "doc/UsersGuide.html#explorer");

        panel = CreatePanedWindow(eui->top);

        form = CreateForm(panel);
        PlaceGridChild(panel, form, 0, 0); /* in case if CreatePanedWindow creates a grid */

        eui->tree = CreateTree(form);
        AddTreeHighlightItemsCB(eui->tree, highlight_cb, eui);
        AddTreeContextMenuCB(eui->tree, menu_cb, eui);
        AddTreeDropItemsCB(eui->tree, drop_cb, eui);
        FormAddVChild(form, eui->tree);

        fr = CreateFrame(form, NULL);
        eui->idstr = CreateText(fr, "ID string:");
        AddTextActivateCB(eui->idstr, text_explorer_cb, eui);
        FormAddVChild(form, fr);
        FormFixateVChild(fr);
        
        eui->scrolled_window = CreateScrolledWindow(panel);
        PlaceGridChild(panel, eui->scrolled_window, 1, 0); /* in case if CreatePanedWindow creates a grid */

        PanedWindowSetMinWidth(form, 150);
        WidgetSetWidth(form, 250);

        WidgetManage(form);

#ifdef HAVE_LESSTIF
# if !defined(SF_BUG_993209_FIXED) && !defined(SF_BUG_993209_NOT_FIXED)
#  error "You should check whether SF bug #993209 is fixed in your version of LessTif."
#  error "Then define either SF_BUG_993209_FIXED or SF_BUG_993209_NOT_FIXED, accordingly."
#  error "See http://sourceforge.net/tracker/index.php?func=detail&aid=993209&group_id=8596&atid=108596."
# endif
# ifdef SF_BUG_993209_NOT_FIXED
        /* A dirty workaround */
        eui->scrolled_window = CreateVContainer(eui->scrolled_window);
# endif
#endif

        eui->project_ui = create_project_ui(eui);
        WidgetUnmanage(eui->project_ui->top);

	eui->ssd_ui = create_ssd_ui(eui);
        WidgetUnmanage(eui->ssd_ui->top);

	eui->frame_ui = create_frame_ui(eui);
        WidgetUnmanage(eui->frame_ui->top);

	eui->graph_ui = create_graph_ui(eui);
        WidgetUnmanage(eui->graph_ui->top);

	eui->set_ui = create_set_ui(eui);
        WidgetUnmanage(eui->set_ui->top);

	eui->axisgrid_ui = create_axisgrid_ui(eui);
        WidgetUnmanage(eui->axisgrid_ui->top);

	eui->axis_ui = create_axis_ui(eui);
        WidgetUnmanage(eui->axis_ui->top);

	eui->object_ui = create_object_ui(eui);
        WidgetUnmanage(eui->object_ui->top);

	eui->atext_ui = create_atext_ui(eui);
        WidgetUnmanage(eui->atext_ui->top);

	eui->region_ui = create_region_ui(eui);
        WidgetUnmanage(eui->region_ui->top);

        eui->aacbuts = CreateAACDialog(eui->top, panel, explorer_aac, eui);

        WidgetManage(eui->tree);

        /* Menu popup */
        eui->popup = CreatePopupMenu(eui->tree);
        eui->popup_hide_bt = CreateMenuButton(eui->popup,
            "Hide", '\0', hide_cb, eui);
        eui->popup_show_bt = CreateMenuButton(eui->popup,
            "Show", '\0', show_cb, eui);

        CreateMenuSeparator(eui->popup);

        eui->popup_delete_bt = CreateMenuButton(eui->popup,
            "Delete", '\0', delete_cb, eui);
        eui->popup_duplicate_bt = CreateMenuButton(eui->popup,
            "Duplicate", '\0', duplicate_cb, eui);

        /* Project menu popup */
        eui->project_popup = CreatePopupMenu(eui->tree);
        eui->project_popup_show_bt = CreateMenuButton(eui->project_popup,
            "Show", '\0', project_show_cb, eui);

        CreateMenuSeparator(eui->project_popup);

        eui->project_popup_save_bt = CreateMenuButton(eui->project_popup,
            "Save", '\0', project_save_cb, eui);
        eui->project_popup_save_as_bt = CreateMenuButton(eui->project_popup,
            "Save as...", '\0', project_save_as_cb, eui);
        eui->project_popup_revert_to_saved_bt = CreateMenuButton(eui->project_popup,
            "Revert to saved", '\0', project_revert_to_saved_cb, eui);

        CreateMenuSeparator(eui->project_popup);

        eui->project_popup_close_bt = CreateMenuButton(eui->project_popup,
            "Close", '\0', project_close_cb, eui);

        init_quark_tree(eui);

        if (!q && gapp->gp) {
            select_quark_explorer(gproject_get_top(gapp->gp));
        }
    }
#ifdef QT_GUI
    /* TODO: use resources */
    WidgetSetSize(gui->eui->top, 650, 600);
#endif
    DialogRaise(gui->eui->top);
    
    if (q) {
        select_quark_explorer(q);
    }

    update_undo_buttons(gapp->gp);

    unset_wait_cursor();
}
コード例 #3
0
ファイル: fontwin.c プロジェクト: armando-2011/grace
void create_fonttool(TextStructure *cstext_parent)
{
    static fonttool_ui *ui = NULL;
    
    if (ui == NULL) {
        ui = xmalloc(sizeof(fonttool_ui));
        memset(ui, 0, sizeof(fonttool_ui));
	
        ui->fonttool_panel = CreateDialog(app_shell, "Font tool");

        ui->font_select = CreateFontChoice(ui->fonttool_panel, "Font:");
        FormAddVChild(ui->fonttool_panel, ui->font_select->menu);
        
        ui->font_table = CreateTable("fontTable", ui->fonttool_panel,
                                     FONT_TOOL_ROWS, FONT_TOOL_COLS,
                                     8, 16);
        TableFontInit(ui->font_table);
        TableSetDefaultColWidth(ui->font_table, 2);
        TableSetDefaultColAlignment(ui->font_table, ALIGN_BEGINNING);
        TableUpdateVisibleRowsCols(ui->font_table);

        AddTableDrawCellCB(ui->font_table, DrawCB, ui);
        AddTableEnterCellCB(ui->font_table, EnterCB, ui);
        AddOptionChoiceCB(ui->font_select, update_fonttool_cb, ui);

        FormAddVChild(ui->fonttool_panel, ui->font_table);

        ui->cstext = CreateCSText(ui->fonttool_panel, "CString:");

        AddTextValidateCB(ui->cstext, EditStringCB, ui);
        
        ui->aac_buts = CreateAACDialog(ui->fonttool_panel,
            ui->cstext->form, fonttool_aac_cb, ui);

        FormFixateVChild(ui->cstext->form);
        
        update_fonttool_cb(NULL, 0, ui);
    }

    if (cstext_parent == ui->cstext) {
        /* avoid recursion */
        return;
    }
    
    ui->cstext_parent = cstext_parent;
    
    if (ui->cstext_parent == NULL) {
        TextSetString(ui->cstext, "");
        WidgetSetSensitive(ui->aac_buts[0], FALSE);
        WidgetSetSensitive(ui->aac_buts[1], FALSE);
    } else {
        char *s = TextGetString(ui->cstext_parent);
        int pos = TextGetCursorPos(ui->cstext_parent);
        TextSetString(ui->cstext, s);
        TextSetCursorPos(ui->cstext, pos);
        xfree(s);
        WidgetSetSensitive(ui->aac_buts[0], TRUE);
        WidgetSetSensitive(ui->aac_buts[1], TRUE);
    }
    
    DialogRaise(ui->fonttool_panel);
}