GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

colos of progressbar

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
funebre



Joined: 14 Oct 2005
Posts: 1

PostPosted: Fri Oct 14, 2005 4:52 pm    Post subject: colos of progressbar Reply with quote

Hello,
i'am making an application for showing data received from a sensor.
Is a simple gui composed (for now) from many progressbar.
I have tried to change color of statusbar for obtaining somewat like this

but with the code below i obtain this
.
wath is my error?
Thanks for replies :)

Code: (Plaintext)
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

#include <gtk/gtk.h>

GtkWidget *window;
GtkWidget *vbox1,*vbox2,*hbox1,*hbox2,*hbox3;
GtkWidget *pbar_rxacc,*pbar_pxacc,*pbar_rtemp,*pbar_ptemp;
GtkWidget *sep1,*sep2;

static gboolean delete_event( GtkWidget *widget, GdkEvent *event, gpointer data )
{
    gtk_main_quit ();
    return FALSE;
}
int main( int   argc, char *argv[] )
{
    gtk_init (&argc, &argv);
   
    /*colors & styles for progressbars*/
    GdkColor red;
    red.red=65535;
    red.green=0;
    red.blue=0;
   
    GdkColor green;
    green.green=65535;
    green.red=green.blue=0;
   
    GdkColor blue;
    blue.blue=65535;
    blue.red=blue.green=0;
   
    GtkRcStyle *red_st, *blue_st,*green_st;
    red_st=gtk_rc_style_new();
    blue_st=gtk_rc_style_new();
    green_st=gtk_rc_style_new();
    int i;
    for(i=0;i<5;i++)
    {
        /*tryng differents alternatives*/
        red_st->color_flags[i]=GTK_RC_FG; 
        red_st->fg[i]=red;
        blue_st->color_flags[i]=GTK_RC_BG;
        blue_st->bg[i]=blue;
        green_st->color_flags[i]=GTK_RC_BASE;
        green_st->base[i]=green;
    }
   
    /*init all widgets*/
    /*box*/
    vbox1=gtk_vbox_new(FALSE,0);
    vbox2=gtk_vbox_new(FALSE,0);
    hbox1=gtk_hbox_new(FALSE,0);
    hbox2=gtk_hbox_new(FALSE,0);
    hbox3=gtk_hbox_new(FALSE,0);
   
    /*progress bar*/
    pbar_rxacc=gtk_progress_bar_new();
        gtk_progress_bar_set_fraction ((GtkProgressBar*)pbar_rxacc,0.5);
        gtk_progress_bar_set_text((GtkProgressBar*)pbar_rxacc,"Roll x acceleration");
        gtk_widget_modify_style(pbar_rxacc,blue_st);
       
    pbar_rtemp=gtk_progress_bar_new();
         gtk_progress_bar_set_orientation((GtkProgressBar*)pbar_rtemp,GTK_PROGRESS_BOTTOM_TO_TOP);
        gtk_progress_bar_set_text((GtkProgressBar*)pbar_rtemp,"Roll\nsensor\ntemperature");
        gtk_widget_modify_style(pbar_rtemp,red_st);
       
    pbar_pxacc=gtk_progress_bar_new();
        gtk_progress_bar_set_fraction ((GtkProgressBar*)pbar_pxacc,0.5);
        gtk_progress_bar_set_text((GtkProgressBar*)pbar_pxacc,"Pitch x acceleration");
        gtk_widget_modify_style(pbar_pxacc,green_st);
       
    pbar_ptemp=gtk_progress_bar_new();
        gtk_progress_bar_set_orientation((GtkProgressBar*)pbar_ptemp,GTK_PROGRESS_BOTTOM_TO_TOP);
        gtk_progress_bar_set_text((GtkProgressBar*)pbar_ptemp,"Pitch\nsensor\ntemperature");
        gtk_widget_modify_style(pbar_ptemp,red_st);
       
    /*separators*/
    sep1= gtk_hseparator_new ();
    sep2= gtk_vseparator_new ();
   
    /*packing widgets in the boxes*/
    gtk_box_pack_start((GtkBox*)vbox1,hbox1,TRUE,TRUE,5);
    gtk_box_pack_start((GtkBox*)vbox1,sep1,FALSE,TRUE,5);
    gtk_box_pack_start((GtkBox*)vbox1,hbox2,TRUE,TRUE,5);
    gtk_box_pack_start((GtkBox*)hbox2,vbox2,TRUE,TRUE,5);
    gtk_box_pack_start((GtkBox*)vbox2,pbar_rxacc,FALSE,TRUE,5);
    gtk_box_pack_start((GtkBox*)vbox2,pbar_pxacc,FALSE,TRUE,5);
    gtk_box_pack_start((GtkBox*)hbox2,sep2,FALSE,TRUE,5);
    gtk_box_pack_start((GtkBox*)hbox2,hbox3,FALSE,TRUE,5);
    gtk_box_pack_end((GtkBox*)hbox3,pbar_rtemp,FALSE,TRUE,5);
    gtk_box_pack_end((GtkBox*)hbox3,pbar_ptemp,FALSE,TRUE,5);
   
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    g_signal_connect (G_OBJECT (window), "delete_event",G_CALLBACK (delete_event), NULL);
    gtk_container_add (GTK_CONTAINER (window), vbox1);
    gtk_widget_show_all(window);
   
    gtk_main ();
   
    return 0;
}
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP