示例#1
0
static void
gnc_header_init (GncHeader *header)
{
    header->sheet = NULL;
    header->cursor_name = NULL;
    header->in_resize = FALSE;
    header->resize_col = -1;
    header->resize_cursor = gdk_cursor_new_for_display (gdk_display_get_default (), GDK_SB_H_DOUBLE_ARROW);
    header->normal_cursor = NULL;
    header->height = 20;
    header->width = 400;
    header->style = NULL;

    // This sets a style class for when Gtk+ version is less than 3.20
    gnc_widget_set_css_name (GTK_WIDGET(header), "header");

    gtk_widget_add_events(GTK_WIDGET(header), (GDK_EXPOSURE_MASK
                          | GDK_BUTTON_PRESS_MASK
                          | GDK_BUTTON_RELEASE_MASK
                          | GDK_POINTER_MOTION_MASK
                          | GDK_POINTER_MOTION_HINT_MASK));

    g_signal_connect(G_OBJECT(header), "configure_event",
                     G_CALLBACK(gnc_header_reconfigure), NULL);
    gtk_widget_show_all (GTK_WIDGET(header));
}
示例#2
0
static void
gnucash_register_init (GnucashRegister *g_reg)
{
    GtkGrid *table = GTK_GRID(g_reg);

    gtk_widget_set_can_focus (GTK_WIDGET(table), FALSE);
    gtk_widget_set_can_default (GTK_WIDGET(table), FALSE);

    // This sets a style class for when Gtk+ version is less than 3.20
    gnc_widget_set_css_name (GTK_WIDGET(g_reg), "register");

    gtk_grid_set_row_homogeneous (GTK_GRID(table), FALSE);
    gtk_grid_set_column_homogeneous (GTK_GRID(table), FALSE);
}
GtkWidget *
gnc_item_edit_new (GnucashSheet *sheet)
{
    char *hpad_str, *vpad_str, *entry_css;
    GtkStyleContext *stylecontext;
    GtkCssProvider *provider;
    GncItemEdit *item_edit =
            g_object_new (GNC_TYPE_ITEM_EDIT,
                          "sheet", sheet,
                          "spacing",     0,
                          "homogeneous", FALSE,
                           NULL);
    gtk_layout_put (GTK_LAYOUT(sheet), GTK_WIDGET(item_edit), 0, 0);

    // This sets a style class for when Gtk+ version is less than 3.20
    gnc_widget_set_css_name (GTK_WIDGET(item_edit), "cursor");

    /* Create the text entry */
    item_edit->editor = gtk_entry_new();
    sheet->entry = item_edit->editor;
    gtk_entry_set_width_chars (GTK_ENTRY(item_edit->editor), 1);
    gtk_box_pack_start (GTK_BOX(item_edit), item_edit->editor,  TRUE, TRUE, 0);

    // Make sure the Entry can not have focus and no frame
    gtk_widget_set_can_focus (GTK_WIDGET(item_edit->editor), FALSE);
    gtk_entry_set_has_frame (GTK_ENTRY(item_edit->editor), FALSE);

    // Connect to the draw signal so we can draw a cursor
    g_signal_connect_after (item_edit->editor, "draw",
                            G_CALLBACK (draw_text_cursor_cb), NULL);

    // Fill in the background so the underlying sheet cell can not be seen
    g_signal_connect (item_edit, "draw",
                            G_CALLBACK (draw_background_cb), item_edit);

    /* Force padding on the entry to align with the rest of the register this
       is done in the gnucash.css file which should be in line with sheet.h */

    /* Create the popup button
       It will only be displayed when the cell being edited provides
       a popup item (like a calendar or account list) */
    item_edit->popup_toggle.tbutton = gtk_toggle_button_new();
    gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (item_edit->popup_toggle.tbutton), FALSE);

    /* Force padding on the button to keep it small and display as much as
       possible of the arrow which is done in the gnucash.css file */

    /* Wrap the popup button in an event box to give it its own gdkwindow.
     * Without one the button would disappear behind the grid object. */
    item_edit->popup_toggle.ebox = gtk_event_box_new();
    g_object_ref(item_edit->popup_toggle.ebox);
    gtk_container_add(GTK_CONTAINER(item_edit->popup_toggle.ebox),
                      item_edit->popup_toggle.tbutton);

    gtk_box_pack_start (GTK_BOX(item_edit),
                        item_edit->popup_toggle.ebox,
                        FALSE, TRUE, 0);
    gtk_widget_show_all(GTK_WIDGET(item_edit));

    return GTK_WIDGET(item_edit);
}