Exemplo n.º 1
0
int
tools_init( void )
{
	Ewl_Widget *vbox, *button, *image;

	if( tools_win )
		return -1;

	tools_win = ewl_window_new();
	ewl_window_title_set(EWL_WINDOW(tools_win), "Tools");
	ewl_object_size_request(EWL_OBJECT(tools_win), 200, 320);
	ewl_callback_append(tools_win, EWL_CALLBACK_DELETE_WINDOW,
											tools_toggle, NULL);

	vbox = ewl_vbox_new();
	ewl_container_child_append(EWL_CONTAINER(tools_win), vbox);

	button = ewl_button_new(NULL);
	ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_SHRINK);
	ewl_object_insets_set(EWL_OBJECT(button), 0, 0, 0, 0);
	ewl_callback_append(button, EWL_CALLBACK_CLICKED, tools_click, "Ewl_Text");
	ewl_container_child_append(EWL_CONTAINER(vbox), button);

	image = ewl_image_new(EWLER_IMAGE_DIR"/text-small.png", "text");
	ewl_container_child_append(EWL_CONTAINER(button), image);
	ewl_widget_show(image);

	ewl_widget_show(button);

	button = ewl_button_new(NULL);
	ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_SHRINK);
	ewl_object_insets_set(EWL_OBJECT(button), 0, 0, 0, 0);
	ewl_callback_append(button, EWL_CALLBACK_CLICKED, tools_click, "Ewl_Entry");
	ewl_container_child_append(EWL_CONTAINER(vbox), button);

	image = ewl_image_new(EWLER_IMAGE_DIR"/entry-small.png", "entry");
	ewl_container_child_append(EWL_CONTAINER(button), image);
	ewl_widget_show(image);

	ewl_widget_show(button);

	button = ewl_button_new(NULL);
	ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_SHRINK);
	ewl_object_insets_set(EWL_OBJECT(button), 0, 0, 0, 0);
	ewl_callback_append(button, EWL_CALLBACK_CLICKED, tools_click, "Ewl_Border");
	ewl_container_child_append(EWL_CONTAINER(vbox), button);

	image = ewl_image_new(EWLER_IMAGE_DIR"/border-small.png", "border");
	ewl_container_child_append(EWL_CONTAINER(button), image);
	ewl_widget_show(image);

	ewl_widget_show(button);

	ewl_widget_show(vbox);
	
	ewl_widget_show(tools_win);

	return 0;
}
Exemplo n.º 2
0
static int
test_constructor(char *buf, int len)
{
        Ewl_Widget *o;
        int ret = 0;

        o = ewl_image_new();

        if (!EWL_IMAGE_IS(o))
                LOG_FAILURE(buf, len, "widget is not of the type "
                                EWL_IMAGE_TYPE);
        else if (ewl_object_fill_policy_get(EWL_OBJECT(o))
                        != EWL_FLAG_FILL_NONE)
                LOG_FAILURE(buf, len, "Fill policy is not NONE");
        else if (ewl_image_file_path_get(EWL_IMAGE(o)))
                LOG_FAILURE(buf, len, "path is not NULL");
        else if (ewl_image_file_key_get(EWL_IMAGE(o)))
                LOG_FAILURE(buf, len, "key is not NULL");
        else if (ewl_image_proportional_get(EWL_IMAGE(o)))
                LOG_FAILURE(buf, len, "image is proportional");
        else if (ewl_image_constrain_get(EWL_IMAGE(o)))
                LOG_FAILURE(buf, len, "image has constrain");
        else
                ret = 1;

        ewl_widget_destroy(o);

        return ret;
}
Exemplo n.º 3
0
/**
 * @param sp: The Ewl_Spectrum to init
 * @return Returns TRUE on success or FALSE on failure
 * @brief Initializes an Ewl_Specturm widget to default values
 */
int
ewl_spectrum_init(Ewl_Spectrum *sp)
{
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET(sp, FALSE);

        if (!ewl_container_init(EWL_CONTAINER(sp)))
        {
                DRETURN_INT(FALSE, DLEVEL_STABLE);
        }

        ewl_widget_appearance_set(EWL_WIDGET(sp), EWL_SPECTRUM_TYPE);
        ewl_widget_inherit(EWL_WIDGET(sp), EWL_SPECTRUM_TYPE);
        ewl_object_fill_policy_set(EWL_OBJECT(sp), EWL_FLAG_FILL_FILL);
        ewl_container_callback_intercept(EWL_CONTAINER(sp),
                                        EWL_CALLBACK_MOUSE_MOVE);
        ewl_container_callback_intercept(EWL_CONTAINER(sp),
                                        EWL_CALLBACK_MOUSE_DOWN);
        ewl_container_callback_intercept(EWL_CONTAINER(sp),
                                        EWL_CALLBACK_MOUSE_UP);

        ewl_callback_append(EWL_WIDGET(sp), EWL_CALLBACK_MOUSE_DOWN,
                                ewl_spectrum_cb_mouse_down, NULL);
        ewl_callback_append(EWL_WIDGET(sp), EWL_CALLBACK_MOUSE_UP,
                                ewl_spectrum_cb_mouse_up, NULL);

        sp->type = EWL_SPECTRUM_TYPE_SQUARE;

        /* create the canvas */
        sp->canvas = ewl_image_new();
        ewl_container_child_append(EWL_CONTAINER(sp), sp->canvas);
        ewl_object_fill_policy_set(EWL_OBJECT(sp->canvas), EWL_FLAG_FILL_FILL);
        ewl_widget_internal_set(sp->canvas, TRUE);
        ewl_callback_append(EWL_WIDGET(sp->canvas), EWL_CALLBACK_REVEAL,
                                ewl_spectrum_canvas_cb_reveal, sp);
        ewl_widget_show(sp->canvas);

        /* create the cross hairs to draw on the spectrum */
        sp->cross_hairs.horizontal = ewl_hseparator_new();
        ewl_container_child_append(EWL_CONTAINER(sp), sp->cross_hairs.horizontal);
        ewl_widget_internal_set(sp->cross_hairs.horizontal, TRUE);
        ewl_widget_layer_priority_set(sp->cross_hairs.horizontal, 1);

        sp->cross_hairs.vertical = ewl_vseparator_new();
        ewl_container_child_append(EWL_CONTAINER(sp), sp->cross_hairs.vertical);
        ewl_widget_internal_set(sp->cross_hairs.vertical, TRUE);
        ewl_widget_layer_priority_set(sp->cross_hairs.vertical, 1);

        ewl_callback_append(EWL_WIDGET(sp), EWL_CALLBACK_CONFIGURE,
                        ewl_spectrum_cb_configure, NULL);

        ewl_spectrum_rgb_set(sp, 255, 255, 255);

        DRETURN_INT(TRUE, DLEVEL_STABLE);
}
Exemplo n.º 4
0
static int
create_test(Ewl_Container *box)
{
        Ewl_Widget *overlay;
        Ewl_Widget *img;
        Ewl_Widget *hist;

        overlay = ewl_overlay_new();
        ewl_container_child_append(EWL_CONTAINER(box), overlay);
        ewl_object_fill_policy_set(EWL_OBJECT(overlay), EWL_FLAG_FILL_ALL);
         ewl_callback_append(EWL_WIDGET(overlay), EWL_CALLBACK_CONFIGURE,
                        ewl_histogram_test_cb_configure, NULL);
        ewl_widget_show(overlay);

        img = ewl_image_new();
        ewl_image_file_path_set(EWL_IMAGE(img),
                                ewl_test_image_get("entrance.png"));
        ewl_image_proportional_set(EWL_IMAGE(img), TRUE);
        ewl_container_child_append(EWL_CONTAINER(overlay), img);
        ewl_object_fill_policy_set(EWL_OBJECT(img), EWL_FLAG_FILL_ALL);
        ewl_widget_show(img);

        hist = ewl_histogram_new();
        ewl_histogram_channel_set(EWL_HISTOGRAM(hist), EWL_HISTOGRAM_CHANNEL_Y);
        ewl_histogram_image_set(EWL_HISTOGRAM(hist), EWL_IMAGE(img));
        ewl_container_child_append(EWL_CONTAINER(overlay), hist);
        ewl_object_fill_policy_set(EWL_OBJECT(hist), EWL_FLAG_FILL_ALL);
        ewl_widget_show(hist);

        hist = ewl_histogram_new();
        ewl_histogram_channel_set(EWL_HISTOGRAM(hist), EWL_HISTOGRAM_CHANNEL_R);
        ewl_histogram_image_set(EWL_HISTOGRAM(hist), EWL_IMAGE(img));
        ewl_container_child_append(EWL_CONTAINER(overlay), hist);
        ewl_object_fill_policy_set(EWL_OBJECT(hist), EWL_FLAG_FILL_ALL);
        ewl_widget_show(hist);

        hist = ewl_histogram_new();
        ewl_histogram_channel_set(EWL_HISTOGRAM(hist), EWL_HISTOGRAM_CHANNEL_G);
        ewl_histogram_image_set(EWL_HISTOGRAM(hist), EWL_IMAGE(img));
        ewl_container_child_append(EWL_CONTAINER(overlay), hist);
        ewl_object_fill_policy_set(EWL_OBJECT(hist), EWL_FLAG_FILL_ALL);
        ewl_widget_show(hist);

        hist = ewl_histogram_new();
        ewl_histogram_channel_set(EWL_HISTOGRAM(hist), EWL_HISTOGRAM_CHANNEL_B);
        ewl_histogram_image_set(EWL_HISTOGRAM(hist), EWL_IMAGE(img));
        ewl_container_child_append(EWL_CONTAINER(overlay), hist);
        ewl_object_fill_policy_set(EWL_OBJECT(hist), EWL_FLAG_FILL_ALL);
        ewl_widget_show(hist);

        return 1;
}
Exemplo n.º 5
0
/**
 * @param d: dialog to change the icon
 * @param theme_icon: the name of the theme icon
 * @return Returns no value.
 * @brief Changes the icon of the dialog. 
 *
 * Changes the icon to the given string. @p theme_icon can be any icon that
 * is defined in the ewl_theme_icon.h file.  If @p theme_icon is @c NULL
 * no icon will be create or an existing icon will be destroyed.
 */
void
ewl_icondialog_icon_set(Ewl_Icondialog *d, const char *theme_icon)
{
        const char *image;
        int size;

        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR(d);
        DCHECK_TYPE(d, EWL_ICONDIALOG_TYPE);

        /* 
         * if there is no icon destroy the existing one and we are done
         */
        if (!theme_icon)
        {
                if (d->icon)
                        ewl_widget_destroy(d->icon);
                DRETURN(DLEVEL_STABLE);
        }

        /* get the size from the theme or set a default value */
        size = ewl_theme_data_int_get(EWL_WIDGET(d), "icon_size");
        if (!size) size = 64;

        /* get the file for the image */
        image = ewl_icon_theme_icon_path_get(theme_icon, size);
        if (!image)
                DRETURN(DLEVEL_STABLE);

        /* and finally create the icon */
        d->icon = ewl_image_new();
        ewl_image_file_set(EWL_IMAGE(d->icon), image, NULL);
        ewl_object_minimum_size_set(EWL_OBJECT(d->icon), size, size);
        
        /* we need to reset the container redirect before we can add the icon */
        ewl_container_redirect_set(EWL_CONTAINER(d->dialog.vbox), NULL);
        ewl_container_child_prepend(EWL_CONTAINER(d->dialog.vbox), d->icon);
        ewl_container_redirect_set(EWL_CONTAINER(d->dialog.vbox), 
                                        EWL_CONTAINER(d->vbox));

        ewl_widget_show(d->icon);

        DLEAVE_FUNCTION(DLEVEL_STABLE);
}
Exemplo n.º 6
0
static int
test_scale_set_get(char *buf, int len)
{
        Ewl_Widget *o;
        int ret = 0;
        double sw, sh;

        o = ewl_image_new();
        ewl_image_scale_set(EWL_IMAGE(o), 2.0, 2.0);
        ewl_image_scale_get(EWL_IMAGE(o), &sw, &sh);

        if (sw != 2.0 || sh != 2.0)
                LOG_FAILURE(buf, len, "scale_get did not match scale_set.");
        else
                ret = 1;

        ewl_widget_destroy(o);

        return ret;
}
Exemplo n.º 7
0
static int
test_path_set_get(char *buf, int len)
{
        Ewl_Widget *o;
        const char *t;
        int ret = 0;

        o = ewl_image_new();
        ewl_image_file_path_set(EWL_IMAGE(o), "/invalid/path");
        t = ewl_image_file_path_get(EWL_IMAGE(o));

        if (strcmp(t, "/invalid/path"))
                LOG_FAILURE(buf, len, "path_get did not match path_set.");
        else
                ret = 1;
        
        ewl_widget_destroy(o);

        return ret;
}
Exemplo n.º 8
0
static int
test_proportional_set_get(char *buf, int len)
{
        Ewl_Widget *o;
        unsigned int p;
        int ret = 0;

        o = ewl_image_new();
        ewl_image_proportional_set(EWL_IMAGE(o), TRUE);
        p = ewl_image_proportional_get(EWL_IMAGE(o));

        if (p != TRUE)
                LOG_FAILURE(buf, len, "proportional_get did not match set.");
        else
                ret = 1;

        ewl_widget_destroy(o);

        return ret;
}
Exemplo n.º 9
0
static int
test_constrain_set_get(char *buf, int len)
{
        Ewl_Widget *o;
        int ret = 0;
        int sw;

        o = ewl_image_new();
        ewl_image_constrain_set(EWL_IMAGE(o), 2);
        sw = ewl_image_constrain_get(EWL_IMAGE(o));

        if (sw != 2)
                LOG_FAILURE(buf, len, "scale_get did not match scale_set.");
        else
                ret = 1;

        ewl_widget_destroy(o);

        return ret;
}
Exemplo n.º 10
0
void
_icon_editor_gui_init()
{
  if (!editor) return;

  editor->win = ewl_window_new();
  ewl_window_title_set(EWL_WINDOW(editor->win), "Iconbar Icon Editor");
  ewl_window_name_set(EWL_WINDOW(editor->win), "Iconbar Icon Editor");
  ewl_callback_append(editor->win, EWL_CALLBACK_DELETE_WINDOW,
                      _editor_close_win, NULL);

  /* boxes */
  editor->main_vbox = ewl_vbox_new();
  ewl_container_child_append(EWL_CONTAINER(editor->win), editor->main_vbox);
  ewl_widget_show(editor->main_vbox);
  
  editor->top_hbox = ewl_hbox_new();
  ewl_container_child_append(EWL_CONTAINER(editor->main_vbox), editor->top_hbox);
  ewl_widget_show(editor->top_hbox);

  editor->bot_hbox = ewl_hbox_new();
  ewl_container_child_append(EWL_CONTAINER(editor->main_vbox), editor->bot_hbox);
  ewl_widget_show(editor->bot_hbox);

  /* image */
  editor->icon_image = ewl_image_new("test.png", NULL);
  ewl_container_child_append(EWL_CONTAINER(editor->top_hbox), editor->icon_image);
  ewl_object_padding_set(EWL_OBJECT(editor->icon_image), 5, 5, 5, 5);
  ewl_widget_show(editor->icon_image);
  ewl_callback_append(editor->icon_image, EWL_CALLBACK_REALIZE,
                      _editor_realize, NULL);
  ewl_callback_append(editor->icon_image, EWL_CALLBACK_MOUSE_UP,
                      _editor_icon_image_cb, NULL);

  /* vbox for entry hboxes */
  editor->right_vbox = ewl_vbox_new();
  ewl_container_child_append(EWL_CONTAINER(editor->top_hbox), editor->right_vbox);
  ewl_widget_show(editor->right_vbox);


  /* name */
  editor->name.hbox = ewl_hbox_new();
  ewl_container_child_append(EWL_CONTAINER(editor->right_vbox), editor->name.hbox);
  ewl_widget_show(editor->name.hbox);

  editor->name.label = ewl_text_new("Name: ");
  ewl_container_child_append(EWL_CONTAINER(editor->name.hbox), editor->name.label);
  ewl_widget_show(editor->name.label);

  editor->name.entry = ewl_entry_new("");
  ewl_container_child_append(EWL_CONTAINER(editor->name.hbox), editor->name.entry);
  ewl_widget_show(editor->name.entry);


  /* exec */
  editor->exec.hbox = ewl_hbox_new();
  ewl_container_child_append(EWL_CONTAINER(editor->right_vbox), editor->exec.hbox);
  ewl_widget_show(editor->exec.hbox);

  editor->exec.label = ewl_text_new("Exec:");
  ewl_container_child_append(EWL_CONTAINER(editor->exec.hbox), editor->exec.label);
  ewl_widget_show(editor->exec.label);

  editor->exec.entry = ewl_entry_new("");
  ewl_container_child_append(EWL_CONTAINER(editor->exec.hbox), editor->exec.entry);
  ewl_widget_show(editor->exec.entry);


  /* cancel and save buttons */
  editor->cancel_but = ewl_button_new("Cancel");
  ewl_object_fill_policy_set(EWL_OBJECT(editor->cancel_but), EWL_FLAG_FILL_NONE);
  ewl_object_padding_set(EWL_OBJECT(editor->cancel_but), 5, 5, 5, 5);
  ewl_object_alignment_set(EWL_OBJECT(editor->cancel_but), EWL_FLAG_ALIGN_RIGHT);
  ewl_container_child_append(EWL_CONTAINER(editor->bot_hbox), editor->cancel_but);
  ewl_widget_show(editor->cancel_but);
  ewl_callback_append(editor->cancel_but, EWL_CALLBACK_CLICKED,
                      _editor_button_cb, NULL);

  editor->ok_but = ewl_button_new("Save and Close");
  ewl_object_fill_policy_set(EWL_OBJECT(editor->ok_but), EWL_FLAG_FILL_NONE);
  ewl_object_padding_set(EWL_OBJECT(editor->ok_but), 5, 5, 5, 5);
  ewl_object_alignment_set(EWL_OBJECT(editor->ok_but), EWL_FLAG_ALIGN_RIGHT);
  ewl_container_child_append(EWL_CONTAINER(editor->bot_hbox), editor->ok_but);
  ewl_widget_show(editor->ok_but);
  ewl_callback_append(editor->ok_but, EWL_CALLBACK_CLICKED,
                      _editor_button_cb, NULL);

  editor->filesel.win = ewl_window_new();

  editor->filesel.dialog = ewl_filedialog_new(EWL_FILEDIALOG_TYPE_OPEN);
  ewl_container_child_append(EWL_CONTAINER(editor->filesel.win), editor->filesel.dialog);
  ewl_widget_show(editor->filesel.dialog);
  ewl_callback_append(editor->filesel.dialog, EWL_CALLBACK_VALUE_CHANGED, _editor_filesel_cb, NULL);
}
Exemplo n.º 11
0
void ewl_entropy_tip_window_display()
{
    Ewl_Widget* tip_window = ewl_window_new();
    Ewl_Widget* vbox = ewl_vbox_new();
    Ewl_Widget* hbox = ewl_hbox_new();
    Ewl_Widget* button;
    Ewl_Widget* image = ewl_image_new();

    ewl_entropy_tip_window_create_tips();
    tip_number = 0;

    ewl_object_alignment_set(EWL_OBJECT(hbox), EWL_FLAG_ALIGN_BOTTOM);
    ewl_object_alignment_set(EWL_OBJECT(vbox), EWL_FLAG_ALIGN_BOTTOM);
    ewl_object_alignment_set(EWL_OBJECT(tip_window), EWL_FLAG_ALIGN_BOTTOM);
    ewl_object_fill_policy_set(EWL_OBJECT(tip_window), EWL_FLAG_FILL_FILL);
    ewl_object_fill_policy_set(EWL_OBJECT(vbox), EWL_FLAG_FILL_FILL);

    ewl_container_child_append(EWL_CONTAINER(tip_window), vbox);
    ewl_container_child_append(EWL_CONTAINER(vbox), hbox);

    text_tip = ewl_text_new();
    ewl_object_minimum_h_set(EWL_OBJECT(text_tip), 80);
    ewl_container_child_append(EWL_CONTAINER(hbox), text_tip);

    ewl_image_file_set(EWL_IMAGE(image), PACKAGE_DATA_DIR "/icons/tip.png", NULL);
    ewl_container_child_append(EWL_CONTAINER(hbox), image);
    ewl_widget_show(hbox);

    hbox = ewl_hbox_new();
    ewl_widget_show(hbox);
    ewl_container_child_append(EWL_CONTAINER(vbox), hbox);

    button = ewl_button_new();
    ewl_button_label_set(EWL_BUTTON(button), "Prev Tip");
    ewl_object_custom_h_set(EWL_OBJECT(button), 15);
    ewl_widget_show(button);
    ewl_container_child_append(EWL_CONTAINER(hbox), button);

    button = ewl_button_new();
    ewl_button_label_set(EWL_BUTTON(button), "Next Tip");
    ewl_object_custom_h_set(EWL_OBJECT(button), 15);
    ewl_callback_append(button, EWL_CALLBACK_CLICKED, ewl_entropy_tip_window_tip_next_cb, NULL);
    ewl_widget_show(button);
    ewl_container_child_append(EWL_CONTAINER(hbox), button);

    button = ewl_button_new();
    ewl_button_label_set(EWL_BUTTON(button), "Close");
    ewl_object_custom_h_set(EWL_OBJECT(button), 15);
    ewl_callback_append(button, EWL_CALLBACK_CLICKED, ewl_entropy_tip_window_destroy_cb, tip_window);
    ewl_widget_show(button);
    ewl_container_child_append(EWL_CONTAINER(hbox), button);


    ewl_callback_append(tip_window, EWL_CALLBACK_DELETE_WINDOW, ewl_entropy_tip_window_destroy_cb, tip_window);

    ewl_widget_show(tip_window);
    ewl_widget_show(vbox);
    ewl_widget_show(text_tip);
    ewl_widget_show(image);

    ewl_entropy_tip_window_tip_next_cb(NULL,NULL,NULL);

}