aboutsummaryrefslogtreecommitdiffstats
path: root/notes/e-bevel-button.c
blob: 03b0edf23d890673b8e50474c39ff5f557ef15f6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */

#include <config.h>
#include <gtk/gtkbutton.h>

#include <gal/util/e-util.h>

#include "e-bevel-button.h"
#include "e-bevel-button-util.h"

#define PARENT_TYPE GTK_TYPE_BUTTON

static GtkButtonClass *parent_class = NULL;

struct _EBevelButtonPrivate {
    GdkColor base_color;
    GdkColor dark_color;
    GdkColor light_color;
    GdkGC *gc;
};

static void
e_bevel_button_paint (GtkWidget *widget, GdkRectangle *area)
{
    EBevelButton *button;

    button = E_BEVEL_BUTTON (widget);
    
    if (GTK_WIDGET_DRAWABLE (widget)) {
        gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
        gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height);

        gdk_gc_set_foreground (button->priv->gc, &button->priv->base_color);
        gdk_draw_rectangle (widget->window,
                    button->priv->gc,
                    TRUE,
                    0, 0,
                    widget->allocation.width, widget->allocation.height);

        if (GTK_BUTTON (button)->in_button) {
            gdk_gc_set_foreground (button->priv->gc,
                           GTK_BUTTON (button)->button_down ?
                           &button->priv->dark_color :
                           &button->priv->light_color);
            gdk_draw_line (widget->window, button->priv->gc,
                       0, 0, 0, widget->allocation.height - 2);
            gdk_draw_line (widget->window, button->priv->gc,
                       0, 0, widget->allocation.width - 2, 0);

            gdk_gc_set_foreground (button->priv->gc,
                           GTK_BUTTON (button)->button_down ?
                           &button->priv->light_color :
                           &button->priv->dark_color);
            gdk_draw_line (widget->window, button->priv->gc,
                       widget->allocation.width - 1 , 1,
                       widget->allocation.width - 1, widget->allocation.height - 1);
            gdk_draw_line (widget->window, button->priv->gc,
                       1, widget->allocation.height - 1,
                       widget->allocation.width - 1, widget->allocation.height - 1);
        }
    }
}

static gint
e_bevel_button_expose (GtkWidget *widget, GdkEventExpose *event)
{
      GtkBin *bin;
      GdkEventExpose child_event;
      
      if (GTK_WIDGET_DRAWABLE (widget)) {
          bin = GTK_BIN (widget);
          
          e_bevel_button_paint (widget, &event->area);
          
          child_event = *event;
          if (bin->child && GTK_WIDGET_NO_WINDOW (bin->child) &&
              gtk_widget_intersect (bin->child, &event->area, &child_event.area))
              gtk_widget_event (bin->child, (GdkEvent*) &child_event);
      }

      return FALSE;
}

static void
e_bevel_button_draw (GtkWidget *widget, GdkRectangle *area)
{
    GdkRectangle child_area;
    GdkRectangle tmp_area;

    g_return_if_fail (widget != NULL);
    g_return_if_fail (E_IS_BEVEL_BUTTON (widget));
    g_return_if_fail (area != NULL);

    if (GTK_WIDGET_DRAWABLE (widget)) {
        tmp_area = *area;
        tmp_area.x -= GTK_CONTAINER (widget)->border_width;
        tmp_area.y -= GTK_CONTAINER (widget)->border_width;

        e_bevel_button_paint (widget, &tmp_area);

        if (GTK_BIN (widget)->child && gtk_widget_intersect (GTK_BIN (widget)->child, &tmp_area, &child_area))
            gtk_widget_draw (GTK_BIN (widget)->child, &child_area);
    }
}

static void
e_bevel_button_realize (GtkWidget *widget)
{
    EBevelButton *button = E_BEVEL_BUTTON (widget);

    GTK_WIDGET_CLASS (parent_class)->realize (widget);

    button->priv->gc = gdk_gc_new (widget->window);

    gdk_color_parse ("#d0d888", &button->priv->base_color);
    e_bevel_button_util_shade (&button->priv->base_color,
                   &button->priv->light_color,
                   LIGHTNESS_MULT);
    e_bevel_button_util_shade (&button->priv->base_color,
                   &button->priv->dark_color,
                   DARKNESS_MULT);
    gdk_colormap_alloc_color (gdk_rgb_get_cmap (), &button->priv->base_color, FALSE, TRUE);
    gdk_colormap_alloc_color (gdk_rgb_get_cmap (), &button->priv->light_color, FALSE, TRUE);
    gdk_colormap_alloc_color (gdk_rgb_get_cmap (), &button->priv->dark_color, FALSE, TRUE);
}

static void
e_bevel_button_class_init (EBevelButtonClass *klass)
{
    GtkWidgetClass *widget_class;

    widget_class = (GtkWidgetClass *)klass;

    parent_class = g_type_class_ref(PARENT_TYPE);
    
    widget_class->draw = e_bevel_button_draw;
    widget_class->expose_event = e_bevel_button_expose;
    widget_class->realize = e_bevel_button_realize;
}

static void
e_bevel_button_init (EBevelButton *button)
{
    EBevelButtonPrivate *priv;

    GTK_WIDGET_UNSET_FLAGS (button, GTK_CAN_FOCUS);

    priv = g_new (EBevelButtonPrivate, 1);

    button->priv = priv;
}

GtkWidget *
e_bevel_button_new (void)
{
    EBevelButton *button;

    button = gtk_type_new (E_TYPE_BEVEL_BUTTON);

    return GTK_WIDGET (button);
}

E_MAKE_TYPE (e_bevel_button, "EBevelButton", EBevelButton, e_bevel_button_class_init, e_bevel_button_init, PARENT_TYPE);












0800'>2003-04-136-0/+53 * Convert to new GNOME infrastructure.marcus2003-04-081-7/+4 * - Nuke obsolete PREV_I18N_VER from Makefile.kdearved2003-04-086-8/+12 * Rejoice, for the long awaited upgrade to kde 3.1.1 is here!alane2003-04-064-2/+20 * o Fix build on 5 [1]perky2003-03-243-4/+25 * Clear moonlight beckons.ade2003-03-0794-47/+47 * Remove pkg-comment where COMMENT is already defined in the Makefileade2003-03-071-1/+0 * Remove pkg-comment from the remaining special cases.ade2003-03-073-1/+2 * Remove pkg-comment from remaining master/slave port sets.ade2003-03-0714-7/+8 * Destroy pkg-comment for some of the stranger uses in the tree,ade2003-03-072-1/+2 * Make BROKEN: doesn't working at all due to update of the site.perky2003-02-281-0/+2 * Release the maintainershipperky2003-02-281-1/+1 * De-pkg-comment for my ports.perky2003-02-256-3/+3 * Remove RESTRICTED tag for crypto stuff.nork2003-02-232-3/+0 * De-pkg-comment.knu2003-02-218-4/+4 * De-pkg-comment.knu2003-02-214-4/+2 * Update to 2.0.5-173.cjh2003-02-192-3/+3 * Update to 1.2.2cjh2003-02-193-6/+4 * build fix for 5-current.cjh2003-02-181-0/+11 * Update 2.0.4-172 (based on xterm-172)cjh2003-02-186-33/+28 * Upgrade to 1.2.1.perky2003-02-185-25/+60 * Convert COMMENT to COMMENTFILE until these ports can be converted.kris2003-02-102-2/+2 * add Acrobat Reader 5 CJK font packsijliao2003-02-066-7/+7 * Upgrade kde-i18n to 3.1. Note that the following modules did not get awill2003-01-294-2/+4 * New port: korean/netdicedwin2003-01-206-0/+38 * After repo copy from graphics category, update all appropriatelioux2002-11-291-1/+1 * Update to 4.8. Back from hell!cjh2002-11-2712-0/+333 * Add ko-man-doc 021120, Korean online manpage documents.perky2002-11-246-0/+1728 * Remove korean/gaim. Recent version of net/gaim(master ports ofcjh2002-11-233-32/+0 * Unbroken this ports and update to Korean Lanaguage Pack for Mozilla 1.1.cjh2002-11-239-463/+96 * Fix build on -current.cjh2002-11-232-0/+40 * - Fix build on -current(missing perl dependency)cjh2002-11-234-14/+93 * Remove ko-w3m. www/w3m-m17n will be complete and better replacement.cjh2002-11-237-203/+0 * - ak12(Korean CMap) updated(checksum updated)cjh2002-11-233-2/+6 * Fix build on -current.cjh2002-11-232-0/+22 * Add compat3x dependency. htexp binary is built on 3.2-RELEASEcjh2002-11-231-1/+2 * Use a compact tarball that have only subfont-c from MASTER_SITE_LOCALperky2002-11-202-10/+9 * Remove all netscape ports with a vulnerability of JRE.sada2002-11-1745-1333/+0 * 1. change my address.cjh2002-11-164-2/+47 * o Rollback PORTCOMMENT modifications while this feature's implementationlioux2002-11-114-4/+2 * Use PORTCOMMENT in the Makefile, and whack the pkg-comment.adamw2002-11-074-2/+4 * Half of these ones missed yesterday while converting to USE_REINPLACE.edwin2002-11-051-0/+1 * PERL -> REINPLACEedwin2002-11-041-1/+2 * PERL -> REINPLACEedwin2002-11-042-2/+5 * Fix categories to match dir containing port. bsd.port.mk (and portlint)alane2002-10-302-2/+4 * Fix build on -current (cope with removal of union wait, and removekris2002-10-262-0/+34 * Remove obsoleted port.kuriyama2002-10-196-76/+0 * The pine port was marked FORBIDDEN for security reasons 2 years ago.kris2002-10-1331-1456/+0 * 1. Removed comments from pkg-plist files per will's request.alane2002-10-114-2/+4 * BROKEN: Does not compilekris2002-10-061-0/+2 * BROKEN: Broken by master port updatekris2002-10-061-0/+2 * BROKEN: Does not patchkris2002-10-061-0/+2 * texas chainsaw kde2 massacrealane2002-09-111-1/+0 * texas chainsaw kde2 massacrealane2002-09-111-17/+0 * Update to 3.0.3. Not much changed here: [1] i18n PKGNAMEs converted towill2002-08-254-8/+4 * kr -> kombr2002-08-252-2/+2 * Change distname of MPlayer distribution to fetchable one.perky2002-08-162-2/+2 * Use MASTERDIRmbr2002-08-032-4/+4 * 1. Changed the lib depends on gettext to a build depends. This will meanalane2002-08-032-4/+4 * Bump PORTREVISION. KDE is fragile enough in its dependencies; we don'talane2002-08-022-0/+2 * Chase shlib rev of devel/gettextade2002-08-023-3/+3 * Update to 2.0.5perky2002-07-242-3/+4 * Fix MASTER_SITE_SUBDIR.will2002-07-102-2/+2 * update to 0.6.4.cjh2002-07-092-3/+3 * update to 0.59.cjh2002-07-092-6/+3 * Add mplayer-fonts 1.0,perky2002-07-077-0/+230 * Update to 3.0.2 -- full log available in ports/x11/kde3/Makefile,v 1.51.will2002-07-054-10/+10 * Updating my email address.perky2002-06-251-1/+1 * Upgrade to KDE 3.0.1. The delay in this upgrade is mainly due to thewill2002-06-166-4/+8 * Add Korean OpenOffice slave portmbr2002-06-153-0/+31 * Respect PREFIX.cjh2002-06-041-0/+5 * Don't use kldload when installing. It broke bento's packagecjh2002-05-292-5/+1 * add patch site.cjh2002-05-281-1/+2 * -current build fix.cjh2002-05-241-0/+120 * -current build fix.cjh2002-05-241-4/+17 * -current build fix.cjh2002-05-241-0/+13 * Update to 0.58.cjh2002-05-232-4/+4 * upgrade to 2.0.4ijliao2002-05-212-2/+2 * Use new domain name for Tokyo University of Science.trevor2002-05-181-1/+1 * Add ghostscript-gnu-jpnfont ghostscript-gnu-korfont ghostscript-gnu-commfontkris2002-05-151-0/+1 * Obsoleted by japanese/ghostscript-gnu-jpnfont.mita2002-05-155-64/+4 * Temporary patch fix due to BSD iconv.cjh2002-05-031-0/+3 * sync with 0.57.cjh2002-05-022-4/+4 * Update to 2.0.3pat2002-04-303-5/+35 * Please welcome Qt3/KDE3 to our ports tree. This includes work since thewill2002-04-2211-18/+503 * gettext upgrade uber-patch (stage 3)ade2002-04-131-1/+2 * - Update to 0.55-i18ncjh2002-04-083-440/+7 * Sync with 0.55cjh2002-04-082-2/+3 * Remove #include <malloc.h>kris2002-03-312-27/+22 * Remove #include <malloc.h>kris2002-03-311-0/+4 * Remove #include <malloc.h>kris2002-03-312-1/+32 * This port(and accompanied patch) need langinfo.h, and it exists onlycjh2002-03-301-0/+4 * Sync with gaim 0.54.cjh2002-03-243-164/+438 * - Update to 3.1.6cjh2002-03-214-7/+62 * Two colon needed in pre-eveything target.cjh2002-03-201-1/+1 * - remove GNOME applet support by default.cjh2002-03-201-4/+17 * Fix breakage cause by the recent freetype overhaul.sobomax2002-03-181-1/+1 * Bump PORTREVISION to reflect the (lib)iconv upgrade.knu2002-03-181-1/+1 * Iconv cleanup, stage 1b: correct {BUILD,LIB,RUN}_DEPENDS of all ports that needsobomax2002-03-182-4/+4 * Update to 2.0.2pat2002-03-163-2/+7 * Stage 1 of gettext update.ade2002-03-161-1/+1 * Adjust in accordance with the new location of freetype1 includessobomax2002-03-142-2/+2