76gchar *
ptcolo[11] = {
"#8EFF8E",
"#F5FF53",
"#FFB853",
"#FF6C7D",
"#F4A7FF",
"#408538",
"#B15EFF",
"#8EE3FF",
"#505DFD",
"#7EFFEB",
"#5FC0B0"};
89 gchar * prev[10]={
" ",
"He",
"Ne",
"Ar",
"Kr",
"Xe",
"Rn",
" ",
"Xe",
"Rn"};
90 if (r == -1 &&
c == -1)
return g_strdup_printf (
"Electronic structure: [None]");
93 str = g_strdup_printf (
"Electronic structure:\t [%s]", prev[r]);
97 str = g_strdup_printf (
"Electronic structure:\t ");
102 str = g_strdup_printf (
"%s %ds<sup>%d</sup>", str, r+1,
c+1);
108 str = g_strdup_printf (
"%s %ds<sup>%d</sup> %dp<sup>%d</sup>", str, r+1, 2, r+1,
c-11);
112 if (
c == 5 ||
c == 10)
114 str = g_strdup_printf (
"%s %dd<sup>%d</sup> %ds<sup>%d</sup>", str, r,
c, r+1, 1);
116 else if (r == 4 && (
c == 4 ||
c == 7 ||
c == 8))
118 str = g_strdup_printf (
"%s %dd<sup>%d</sup> %ds<sup>%d</sup>", str, r,
c, r+1, 1);
120 else if (r == 4 &&
c == 9)
122 str = g_strdup_printf (
"%s %dd<sup>%d</sup>", str, r, 10);
126 str = g_strdup_printf (
"%s %dd<sup>%d</sup> %ds<sup>%d</sup>", str, r,
c-1, r+1, 2);
130 str = g_strdup_printf (
"%s %dd<sup>%d</sup> %ds<sup>%d</sup> %dp<sup>%d</sup>", str, r, 10, r+1, 2, r+1,
c-11);
135 if (
c == 9 ||
c == 10)
137 str = g_strdup_printf (
"%s %df<sup>%d</sup> %dd<sup>%d</sup> %ds<sup>%d</sup>", str, r-1, 14, r,
c, r+1, 1);
141 str = g_strdup_printf (
"%s %df<sup>%d</sup> %dd<sup>%d</sup> %ds<sup>%d</sup>", str, r-1, 14, r,
c-1, r+1, 2);
145 str = g_strdup_printf (
"%s %df<sup>%d</sup> %dd<sup>%d</sup> %ds<sup>%d</sup> %dp<sup>%d</sup>", str, r-1, 14, r, 10, r+1, 2, r+1,
c-11);
150 str = g_strdup_printf (
"%s %dd<sup>%d</sup> %ds<sup>%d</sup>", str, r-3,
c-2, r-2, 2);
152 else if ((
c > 7 &&
c < 10) || (
c > 10 &&
c < 17))
154 str = g_strdup_printf (
"%s %df<sup>%d</sup> %ds<sup>%d</sup>", str, r-4,
c-2, r-2, 2);
160 str = g_strdup_printf (
"%s %df<sup>%d</sup> %ds<sup>%d</sup>", str, r-4,
c-2, r-2, 2);
164 str = g_strdup_printf (
"%s 4f<sup>%d</sup> 5d<sup>1</sup> 6s<sup>2</sup>", str,
c-3);
171 str = g_strdup_printf (
"%s %dd<sup>%d</sup> %ds<sup>%d</sup>", str, r-3,
c-2, r-2, 2);
175 str = g_strdup_printf (
"%s %df<sup>%d</sup> %ds<sup>%d</sup> %dp<sup>%d</sup>", str, r-4,
c-3, r-2, 2, r-2, 1);
179 str = g_strdup_printf (
"%s %df<sup>%d</sup> %dd<sup>%d</sup> %ds<sup>%d</sup>", str, r-4,
c-3, r-3, 1, r-2, 2);
196 if (i == 7)
return 0;
197 if (i == 0 && (j > 0 && j < 17))
return 0;
198 if ((i == 1 || i == 2) && (j > 1 && j < 12))
return 0;
199 if ((i == 5 || i == 6) && j ==2)
return 0;
200 if (i > 7 && j< 3)
return 0;
201 if (i > 2 && i < 5)
return 19 + (i-3)*18 + j;
213 if (i > 0 && i < 3)
return 2 + j+1 - 10 * (j/11) + 8 * (i/2);
214 if (i == 5 && j < 2)
return 55 + j;
215 if (i == 6 && j < 2)
return 87 + j;
216 if (i == 5 && j > 2)
return 72 + j-3;
217 if (i == 6 && j > 2)
return 104 + j-3;
218 if (i == 8)
return 57 + j-3;
219 if (i == 9)
return 89 + j-3;
239 int size[5] = {125, 30, 15, 15, 15};
253 backcol = g_strdup_printf (
"label#prev-%d-%d-%d {\n"
255 " font-weight: bold;\n"
256 " font-size: %dpx;\n"
257 "}\n", i, p,
a, size[i]);
261 name = g_strdup_printf (
"prev-%d-%d-%d", i, p,
a);
272 lab[i] = gtk_label_new (str);
277 lab[i] = gtk_label_new (str);
285 gtk_widget_set_name (
lab[i], name);
312 gchar * backcol = g_strdup_printf (
"box#preview-%d-%d {\n"
313 "border: 3px solid black;\n"
314 "background-color: white;\n"
315 "border-top-left-radius: 60px 90px;\n"
316 "border-bottom-right-radius: 60px 90px;\n"
318 "box-shadow: 5px 5px 5px 5px rgba(0,0,0,0.4), 2px 2px 0px 1px rgba(0,0,0,0.4) inset;\n"
323 gchar * str = g_strdup_printf (
"preview-%d-%d", p,
a);
324 gtk_widget_set_name (preview, str);
327 gtk_widget_set_size_request (preview, 400, 275);
341G_MODULE_EXPORT
void on_element_focus (GtkEventControllerFocus * focus, gpointer data)
352G_MODULE_EXPORT gboolean
on_element_focus (GtkWidget * widget, GdkEvent * event, gpointer data)
374G_MODULE_EXPORT
void on_element_motion_enter (GtkEventControllerMotion *
motion, gdouble
x, gdouble
y, gpointer data)
407 element = GPOINTER_TO_INT(data);
457 if ((r == 0 &&
c == 0) || (r==1 && (
c > 13 &&
c < 17)) || ((r>1 && r <5) &&
c == 16))
465 else if (
c > 2 &&
c < 8)
469 else if ((
c > 7 &&
c <11) && r < 6)
473 else if (r==6 && ((
c > 7 &&
c < 11) ||
c > 11))
477 else if (
c==13 && (r == 4 || r == 5))
481 else if ((
c == 14 ||
c == 15) && r == 5)
485 else if ((r==1 &&
c==13) || (r==2 && (
c==14||
c==15)) || (r==3 &&
c==15))
496 if (
c == 2 && r == 5) i = 9;
497 if (
c == 2 && r ==6) i = 10;
508 gchar * butcol = g_strdup_printf (
"button#element-%d-%d {\n"
510 " background-color: %s;\n"
511 " border-color: black;\n"
512 " border-width: 1px;\n"
514 " font-weight: bold;\n"
516 "button#element-%d-%d:hover {\n"
517 " background-color: rgba(255,255,255,0.3);\n"
519 " font-weight: bold;\n"
523 gchar * str = g_strdup_printf (
"element-%d-%d", p,
id);
524 gtk_widget_set_name (but, str);
532 gchar * labcol = g_strdup_printf (
"label#mass-%d-%d {\n"
536 lab = gtk_label_new (str);
539 str = g_strdup_printf (
"mass-%d-%d", p,
id);
540 gtk_widget_set_name (
lab, str);
552 lab = gtk_label_new (
" ");
557 GtkEventController * focus = gtk_event_controller_focus_new ();
559 gtk_widget_add_controller (but, GTK_EVENT_CONTROLLER (focus));
560 GtkEventController *
motion = gtk_event_controller_motion_new ();
561 g_signal_connect (
motion,
"enter", G_CALLBACK(on_element_motion_enter), &
table_p[
id-1]);
562 gtk_widget_add_controller (but, GTK_EVENT_CONTROLLER (
motion));
578 gchar * backcol = g_strdup_printf (
"label#group-%d-%d {\n"
579 " border-radius: 25px;\n"
580 " border-color: black;\n"
581 " border-width: 1px;\n"
582 " background-color: %s;\n"
584 " font-weight: bold;\n"
588 GtkWidget *
lab = gtk_label_new (
" ");
589 gtk_widget_set_size_request (
lab, 50, 40);
591 gchar * str = g_strdup_printf (
"group-%d-%d", p, i);
592 gtk_widget_set_name (
lab, str);
614 else if (j == 2 && (i == 5 || i == 6))
620 return gtk_label_new (
" ");
634 GtkWidget * ptable = gtk_grid_new ();
635 gtk_grid_set_row_homogeneous (GTK_GRID (ptable), TRUE);
636 gtk_grid_set_column_homogeneous (GTK_GRID (ptable), TRUE);
637 gtk_grid_set_row_spacing (GTK_GRID (ptable), 2);
638 gtk_grid_set_column_spacing (GTK_GRID (ptable), 2);
642 gtk_grid_attach (GTK_GRID (ptable),
periodic_search -> preview[0], 3, 0, 8, 5);
647 gtk_grid_attach (GTK_GRID (ptable),
css_element(p, i, j), j, i+3, 1, 1);
651 gchar *
groups[11] = {
" <b>Alkali metal</b>",
" <b>Alkaline earth metal</b>",
" <b>Lanthanide</b>",
" <b>Actinide</b>",
652 " <b>Transition metal</b>",
" <b>Post-transition metal</b>",
" <b>Metalloid</b>",
" <b>Polyatomic non-metal</b>",
653 " <b>Diatomic non-metal</b>",
" <b>Noble gas</b>",
" <b>Unknown</b>"};
654 gtk_grid_attach (GTK_GRID (ptable), gtk_label_new (
" "), 18, 0, 1, 1);
655 int colid[11] = {1, 2, 9, 10, 3, 4, 7, 5, 0, 8, 6};
658 gtk_grid_attach (GTK_GRID (ptable),
create_css_group (p, colid[i]), 19, 1+i, 1, 1);
659 gtk_grid_attach (GTK_GRID (ptable),
markup_label(
groups[i], 120, -1, 0.0, 0.5), 20, 1+i, 3, 1);
674 GtkWidget * win = gtk_dialog_new ();
678 str = g_strdup_printf (
"Element selection from the periodic table");
684 gtk_window_set_attached_to (GTK_WINDOW (win),
get_project_by_id (asearch ->
proj) -> modelgl -> win);
688 gtk_window_set_attached_to (GTK_WINDOW (win),
MainWindow);
694 str = g_strdup_printf (
"Periodic table of the elements");
699 gtk_window_set_attached_to (GTK_WINDOW (win),
MainWindow);
702 gtk_window_set_resizable (GTK_WINDOW (win), FALSE);
703 gtk_window_set_title (GTK_WINDOW(win), str);
705 gtk_window_set_modal (GTK_WINDOW (win), TRUE);
Global variable declarations Global convenience function declarations Global data structure defin...
void run_this_gtk_dialog(GtkWidget *dial, GCallback handler, gpointer data)
run a GTK (3 and 4) basic GtkDialog
element_data periodic_table_info[]
GtkWidget * create_button(gchar *text, int image_format, gchar *image, int dimx, int dimy, int relief, GCallback handler, gpointer data)
create a simple button
GtkWidget * get_top_level(GtkWidget *widg)
get the top level container, window, of a widget
GtkWidget * dialog_get_content_area(GtkWidget *widg)
prepare GtkWidget to insert content in a GtkDialog window
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
void add_box_child_start(int orientation, GtkWidget *widg, GtkWidget *child, gboolean expand, gboolean fill, int padding)
Add a GtkWidget in a GtkBox at the initial position.
void destroy_this_dialog(GtkDialog *dialog)
destroy a GtkDialog
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
void gtk_label_align(GtkWidget *lab, float ax, float ay)
set text alignment in a GtkLabel
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
void provide_gtk_css(gchar *css)
create a css provider based on the css data
void add_container_child(int type, GtkWidget *widg, GtkWidget *child)
Add a GtkWidget into another GtkWidget.
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
void show_the_widgets(GtkWidget *widg)
show GtkWidget
project * get_project_by_id(int p)
get project pointer using id number
void motion(glwin *view, gint x, gint y, GdkModifierType state)
mouse motion in the OpenGL window
atom_search * periodic_search
GtkWidget * css_element(int p, int i, int j)
create CSS for the periodic table elements
GtkWidget * create_css_group(int p, int i)
create group CSS
GtkWidget * periodic_table(int p, int a)
create periodic table
G_MODULE_EXPORT gboolean on_element_focus(GtkWidget *widget, GdkEvent *event, gpointer data)
periodic table focus event callback GTK3
int is_in_table(int i, int j)
is this (row,column) combination a chemical element ?
GtkWidget * el_preview(int p, int a)
create element preview CSS widget
gchar * get_electronic_structure(int r, int c)
get electronic structure for this (row,column) combination
GtkWidget * create_css_button(int p, int id, int r, int c)
create CSS periodic table element button
G_MODULE_EXPORT void run_periodic_table(GtkDialog *info, gint response_id, gpointer data)
periodic table - running the dialog
G_MODULE_EXPORT void get_element(GtkButton *but, gpointer data)
get element from periodic table button
int get_atom_id_from_periodic_table(atom_search *asearch)
get atom Z from selection in the periodic table
GtkWidget * create_el_preview(int p, int a, int r, int c)
create element preview