Пример #1
0
int
main (int argc, char *argv[])
{
  Ecore_List     *str_data = NULL;
  Ewl_Widget     *window;
  Ewl_Widget     *hbox;
  Ewl_Widget     *list;
  Ewl_Model      *model;
  Ewl_View       *view;
  Ewl_Widget     *dvi;
  Ewl_Widget     *sp;
  const Edvi_Document  *document;
  int             page_count;
  int             i;

  if (argc == 1) {
    printf ("Usage: %s dvi_file\n", argv[0]);
    return EXIT_FAILURE;
  }

  printf ("[DVI] version       : %s\n", edvi_version_get ());
  if (!edvi_init (300, "cx", 4,
                  1.0, 1.0,
                  0, 255, 255, 255, 0, 0, 0))
    return EXIT_FAILURE;

  ewl_init (&argc, (char **)argv);
  str_data = ecore_list_new();
  ecore_list_free_cb_set (str_data, free);

  /* We open the dvi file */
  dvi = ewl_dvi_new ();
  if (!ewl_dvi_file_set (EWL_DVI (dvi), argv[1])) {
    printf ("Can not load the document %s\nExiting...", argv[1]);
    ecore_list_destroy (str_data);
    ewl_main_quit();
    return EXIT_FAILURE;
  }

  window = ewl_window_new ();
  ewl_window_title_set (EWL_WINDOW (window), "Ewl Dvi Test Application");
  ewl_callback_append (window, EWL_CALLBACK_DELETE_WINDOW,
                       _quit_cb, str_data);

  hbox = ewl_hbox_new ();
  ewl_box_homogeneous_set (EWL_BOX (hbox), FALSE);
  ewl_container_child_append (EWL_CONTAINER (window), hbox);
  ewl_widget_show (hbox);

  sp = ewl_scrollpane_new ();
  ewl_container_child_append (EWL_CONTAINER (hbox), sp);
  ewl_widget_show (sp);

  document = ewl_dvi_dvi_document_get (EWL_DVI (dvi));
  page_count = edvi_document_page_count_get (document);
  for (i = 0; i < page_count; i++) {
    char row_text[64];
    char *txt;

    snprintf (row_text, 64, "%d", i + 1);
    txt = strdup (row_text);
    ecore_list_append(str_data, txt);
  }

  model = ewl_model_ecore_list_instance();
  view = ewl_label_view_get();

  list = ewl_list_new ();
  ewl_mvc_model_set(EWL_MVC(list), model);
  ewl_mvc_view_set(EWL_MVC(list), view);
  ewl_mvc_data_set(EWL_MVC(list), str_data);
  ewl_callback_append (list,
                       EWL_CALLBACK_VALUE_CHANGED,
                       EWL_CALLBACK_FUNCTION (_change_page_cb),
                       dvi);
  ewl_container_child_append (EWL_CONTAINER (sp), list);
  ewl_widget_show (list);

  ewl_dvi_mag_set (EWL_DVI (dvi), 0.5);
  ewl_container_child_append (EWL_CONTAINER (hbox), dvi);
  ewl_widget_show (dvi);

  ewl_widget_show (window);

  ewl_main ();

  edvi_shutdown ();

  return EXIT_SUCCESS;
}
Пример #2
0
static int
create_test(Ewl_Container *box)
{
        Ewl_Widget *tree, *o, *o2, *o3;
        Ewl_Model *model;
        Ewl_View *view;
        void *data;

        o2 = ewl_hbox_new();
        ewl_container_child_append(box, o2);
        ewl_object_fill_policy_set(EWL_OBJECT(o2), EWL_FLAG_FILL_HFILL);
        ewl_widget_show(o2);

        /* create our data */
        data = tree_test_data_setup();

        /* the tree will only use one model. We could use a model per
         * column, but a single model will work fine for this test */
        model = ewl_model_new();
        ewl_model_data_fetch_set(model, tree_test_data_fetch);
        ewl_model_data_header_fetch_set(model,
                                tree_test_cb_header_data_fetch);
        ewl_model_data_sort_set(model, tree_test_data_sort);
        ewl_model_column_sortable_set(model, tree_test_column_sortable);
        ewl_model_data_count_set(model, tree_test_data_count_get);
        ewl_model_data_expandable_set(model, tree_test_data_expandable_get);
        ewl_model_expansion_data_fetch_set(model,
                                tree_test_data_expansion_fetch);

        view = ewl_view_new();
        ewl_view_widget_constructor_set(view, tree_test_cb_widget_fetch);
        ewl_view_widget_assign_set(view, tree_test_cb_widget_assign);
        ewl_view_header_fetch_set(view, tree_test_cb_header_fetch);

        tree = ewl_tree_new();
        ewl_container_child_append(EWL_CONTAINER(box), tree);
        ewl_object_fill_policy_set(EWL_OBJECT(tree), EWL_FLAG_FILL_ALL);
        ewl_callback_append(tree, EWL_CALLBACK_VALUE_CHANGED,
                                        tree_cb_value_changed, NULL);
        ewl_mvc_data_set(EWL_MVC(tree), data);
        ewl_mvc_model_set(EWL_MVC(tree), model);
        ewl_mvc_view_set(EWL_MVC(tree), view);
        ewl_mvc_selection_mode_set(EWL_MVC(tree), EWL_SELECTION_MODE_MULTI);
        ewl_tree_column_count_set(EWL_TREE(tree), 3);
        ewl_tree_row_expand(EWL_TREE(tree), data, 2);
        ewl_widget_name_set(tree, "tree");
        ewl_widget_show(tree);

        o3 = ewl_vbox_new();
        ewl_container_child_append(EWL_CONTAINER(o2), o3);
        ewl_widget_show(o3);

        /* create the checkbuttons for the top box */
        o = ewl_checkbutton_new();
        ewl_object_alignment_set(EWL_OBJECT(o), EWL_FLAG_ALIGN_LEFT);
        ewl_button_label_set(EWL_BUTTON(o), "Scroll headers");
        ewl_container_child_append(EWL_CONTAINER(o3), o);
        ewl_callback_append(o, EWL_CALLBACK_CLICKED,
                                ewl_tree_cb_scroll_headers, tree);
        ewl_widget_show(o);

        o = ewl_checkbutton_new();
        ewl_object_alignment_set(EWL_OBJECT(o), EWL_FLAG_ALIGN_LEFT);
        ewl_button_label_set(EWL_BUTTON(o), "Hide headers");
        ewl_container_child_append(EWL_CONTAINER(o3), o);
        ewl_callback_append(o, EWL_CALLBACK_CLICKED,
                                ewl_tree_cb_hide_headers, tree);
        ewl_widget_show(o);

        o = ewl_checkbutton_new();
        ewl_object_alignment_set(EWL_OBJECT(o), EWL_FLAG_ALIGN_CENTER);
        ewl_button_label_set(EWL_BUTTON(o), "Plain view");
        ewl_container_child_append(EWL_CONTAINER(o2), o);
        ewl_callback_append(o, EWL_CALLBACK_CLICKED,
                                ewl_tree_cb_plain_view, tree);
        ewl_widget_show(o);

        o = ewl_spinner_new();
        ewl_object_alignment_set(EWL_OBJECT(o), EWL_FLAG_ALIGN_CENTER);
        ewl_container_child_append(EWL_CONTAINER(o2), o);
        ewl_spinner_digits_set(EWL_SPINNER(o), 0);
        ewl_range_minimum_value_set(EWL_RANGE(o), 0);
        ewl_range_maximum_value_set(EWL_RANGE(o), 10000);
        ewl_range_value_set(EWL_RANGE(o), 5);
        ewl_range_step_set(EWL_RANGE(o), 1);
        ewl_widget_name_set(o, "rows_spinner");
        ewl_widget_show(o);

        o = ewl_button_new();
        ewl_object_alignment_set(EWL_OBJECT(o), EWL_FLAG_ALIGN_CENTER);
        ewl_button_label_set(EWL_BUTTON(o), "Set number of rows");
        ewl_container_child_append(EWL_CONTAINER(o2), o);
        ewl_callback_append(o, EWL_CALLBACK_CLICKED,
                                ewl_tree_cb_set_rows_clicked, NULL);
        ewl_widget_show(o);

        o = ewl_button_new();
        ewl_object_alignment_set(EWL_OBJECT(o), EWL_FLAG_ALIGN_CENTER);
        ewl_button_label_set(EWL_BUTTON(o), "Row select");
        ewl_container_child_append(EWL_CONTAINER(o2), o);
        ewl_callback_append(o, EWL_CALLBACK_CLICKED,
                                tree_cb_select_mode_change, NULL);
        ewl_widget_show(o);

	o = ewl_button_new();
        ewl_object_alignment_set(EWL_OBJECT(o), EWL_FLAG_ALIGN_CENTER);
        ewl_button_label_set(EWL_BUTTON(o), "Ensure visible");
        ewl_container_child_append(EWL_CONTAINER(o2), o);
        ewl_callback_append(o, EWL_CALLBACK_CLICKED,
                                tree_cb_ensure_visible, NULL);
        ewl_widget_show(o);

        return 1;
}