int load_host_buttons(topview * t, Agraph_t * g, glCompSet * s) { GtkLayout *layout; int btncount = 0; int i = 0; char *str; char hostbtncaption[50]; char hostbtnregex[50]; char hostbtncolorR[50]; char hostbtncolorG[50]; char hostbtncolorB[50]; char hostbtncolorA[50]; int X = 10; int Y = 25; GdkColor color; glCompPanel *p; glCompButton *b; layout = (GtkLayout *) glade_xml_get_widget(xml, "frmHostSelectionFixed"); str = '\0'; str = agget(g, "hostbtncount"); if (str) btncount = atoi(str); // Graph [hostbtncaption1="AT&T",hostbtnregex1="*.ATT*",hostbtncolorR1="1",hostbtncolorG1="0",hostbtncolorB1="0",hostbtncolorA1="1"]; t->TopviewData->hostregex = N_GNEW(btncount, char *); t->TopviewData->gtkhostbtn = N_GNEW(btncount, GtkButton *); t->TopviewData->gtkhostcolor = N_GNEW(btncount, GtkColorButton *); t->TopviewData->gtkhostbtncount = btncount; if (btncount > 0) { p = glCompPanelNew(25, 75, 165, 400); p->data = 2; //data panel p->color.R = (float) 0.80; p->color.B = (float) 0.2; glCompSetAddPanel(s, p); } else return 0; for (i = 0; i < btncount; i++) { sprintf(hostbtncaption, "hostbtncaption%i", i); sprintf(hostbtnregex, "hostbtnregex%i", i); sprintf(hostbtncolorR, "hostbtncolorR%i", i); sprintf(hostbtncolorG, "hostbtncolorG%i", i); sprintf(hostbtncolorB, "hostbtncolorB%i", i); sprintf(hostbtncolorA, "hostbtncolorA%i", i); agget(g, hostbtncaption), agget(g, hostbtnregex), agget(g, hostbtncolorR), agget(g, hostbtncolorG), agget(g, hostbtncolorB), agget(g, hostbtncolorA); t->TopviewData->hostregex[i] = agget(g, hostbtnregex); b = glCompButtonNew((GLfloat) 5, (GLfloat) 7 + ((GLfloat) i + (GLfloat) 1) * (GLfloat) 36, (GLfloat) 150, (GLfloat) 35, agget(g, hostbtncaption), '\0', 0, 0); b->color.R = (float) atof(agget(g, hostbtncolorR)); b->color.G = (float) atof(agget(g, hostbtncolorG)); b->color.B = (float) atof(agget(g, hostbtncolorB)); b->color.A = (float) 1; b->panel = p; b->groupid = -1; b->callbackfunc = glhost_button_clicked_Slot; b->data = i; glCompSetAddButton(s, b); t->TopviewData->gtkhostbtn[i] = (GtkButton *) gtk_button_new_with_label(agget(g, hostbtncaption)); g_signal_connect((gpointer) t->TopviewData->gtkhostbtn[i], "clicked", G_CALLBACK(host_button_clicked_Slot), (gpointer) i); color.blue = 65535 * atoi(agget(g, hostbtncolorB)); color.red = 65535 * atoi(agget(g, hostbtncolorR)); color.green = 65535 * atoi(agget(g, hostbtncolorG)); t->TopviewData->gtkhostcolor[i] = (GtkColorButton *) gtk_color_button_new_with_color(&color); gtk_color_button_set_alpha((GtkColorButton *) t->TopviewData-> gtkhostbtn[i], 65535 * atoi(agget(g, hostbtncolorA))); gtk_layout_put(layout, (GtkWidget *) t->TopviewData->gtkhostbtn[i], X, Y); gtk_widget_set_size_request((GtkWidget *) t->TopviewData-> gtkhostbtn[i], 200, 35); gtk_layout_put(layout, (GtkWidget *) t->TopviewData->gtkhostcolor[i], X + 225, Y); gtk_widget_set_size_request((GtkWidget *) t->TopviewData-> gtkhostcolor[i], 40, 35); gtk_widget_show((GtkWidget *) t->TopviewData->gtkhostbtn[i]); gtk_widget_show((GtkWidget *) t->TopviewData->gtkhostcolor[i]); Y = Y + 40; t->TopviewData->hostactive[i] = 0; } p->height = (GLfloat) 15 + (GLfloat) (btncount + 1) * (GLfloat) 36; for (i = 0; i < btncount; i++) { prepare_nodes_for_groups(t, t->TopviewData, i); } return 1; }
void attach_camera_widget(ViewInfo * view) { #define PANEL_PADDING 5 #define CAMERA_BUTTON_HEIGHT 25 #define CAMERA_BUTTON_WIDTH 75 int ind, ind2; GLfloat x, y; char buf[256]; glCompPanel *p; glCompButton *b; glCompSet *s = view->widgets; int p_height; /*first we need to get rid of the old menu */ for (ind = 0; ind < s->panelcount; ind++) { if (s->panels[ind]->data == 3) { /*remove buttons in the panel */ for (ind2 = 0; ind2 < s->buttoncount; ind2++) { if (s->buttons[ind2]->panel == s->panels[ind]) { glCompSetRemoveButton(s, s->buttons[ind2]); ind2--; } } /*remove panel itself */ glCompSetRemovePanel(s, s->panels[ind]); break; } } /*calculate height of panel */ p_height = 2 * PANEL_PADDING + view->camera_count * (CAMERA_BUTTON_HEIGHT + PANEL_PADDING) + CAMERA_BUTTON_HEIGHT; /*container for camera buttons */ p = glCompPanelNew((GLfloat) 25, (GLfloat) 75, (GLfloat) 4 * PANEL_PADDING + 3 * CAMERA_BUTTON_WIDTH, (GLfloat) p_height, scientific_y); p->data = 3; glCompSetAddPanel(s, p); b = glCompButtonNew((GLfloat) PANEL_PADDING, (GLfloat) PANEL_PADDING, (GLfloat) CAMERA_BUTTON_WIDTH, (GLfloat) CAMERA_BUTTON_HEIGHT, "ADD", '\0', 0, 0, scientific_y); b->panel = p; b->groupid = 0; b->customptr = view; glCompSetAddButton(s, b); b->callbackfunc = menu_click_add_camera; b = glCompButtonNew((GLfloat) PANEL_PADDING * 2 + (GLfloat) CAMERA_BUTTON_WIDTH, (GLfloat) PANEL_PADDING, (GLfloat) CAMERA_BUTTON_WIDTH, (GLfloat) CAMERA_BUTTON_HEIGHT, "2D", '\0', 0, 0, scientific_y); b->panel = p; b->groupid = 4; //4 is assigned to all camera buttons b->customptr = view; glCompSetAddButton(s, b); b->callbackfunc = menu_click_2d; for (ind = 0; ind < view->camera_count; ind++) { y = p->height - ((GLfloat) PANEL_PADDING + (GLfloat) ind * ((GLfloat) CAMERA_BUTTON_HEIGHT + (GLfloat) PANEL_PADDING)) - (GLfloat) CAMERA_BUTTON_HEIGHT; x = PANEL_PADDING; sprintf(buf, "CAM%i", ind + 1); b = glCompButtonNew((GLfloat) x, (GLfloat) y, (GLfloat) CAMERA_BUTTON_WIDTH, (GLfloat) CAMERA_BUTTON_HEIGHT, buf, '\0', 0, 0, scientific_y); b->panel = p; b->groupid = 4; //4 is assigned to all camera buttons b->data = ind; //assign camera id to custom data to use single call back b->customptr = view; glCompSetAddButton(s, b); b->callbackfunc = menu_click_camera_select; x = PANEL_PADDING * 2 + CAMERA_BUTTON_WIDTH; b = glCompButtonNew((GLfloat) x, (GLfloat) y, (GLfloat) CAMERA_BUTTON_WIDTH, (GLfloat) CAMERA_BUTTON_HEIGHT, "Remove", '\0', 0, 0, scientific_y); b->panel = p; b->groupid = 0; b->data = ind; //assign camera id to custom data to use single call back b->customptr = view; glCompSetAddButton(s, b); b->callbackfunc = menu_click_camera_remove; x = PANEL_PADDING * 3 + CAMERA_BUTTON_WIDTH * 2; b = glCompButtonNew((GLfloat) x, (GLfloat) y, (GLfloat) CAMERA_BUTTON_WIDTH, (GLfloat) CAMERA_BUTTON_HEIGHT, "Edit", '\0', 0, 0, scientific_y); b->panel = p; b->groupid = 0; b->data = ind; //assign camera id to custom data to use single call back b->customptr = view; glCompSetAddButton(s, b); b->callbackfunc = menu_click_camera_edit; } }