comparison gtk3/dw.c @ 1038:2c2fcfeeffcc

Attempt at making dw_window_get_font() return a Dynamic Windows style font name on GTK. Attempt at allowing dw_window_set/get_font() work on groupbox labels on GTK. Moved dwtest MDI notebook page into a DEPRECATED #ifdef to prevent tons of warnings on GTK3.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 26 May 2011 07:57:10 +0000
parents fa1a826348b3
children 80cd7fed4995
comparison
equal deleted inserted replaced
1037:6ad811834512 1038:2c2fcfeeffcc
2520 { 2520 {
2521 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"); 2521 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
2522 if(tmp) 2522 if(tmp)
2523 handle2 = tmp; 2523 handle2 = tmp;
2524 } 2524 }
2525 /* If it is a groupox we want to operate on the frame label */
2526 else if(GTK_IS_FRAME(handle))
2527 {
2528 GtkWidget *tmp = gtk_frame_get_label_widget(GTK_FRAME(handle));
2529 if(tmp)
2530 handle2 = tmp;
2531 }
2525 2532
2526 /* Detect Dynamic Windows style font name... 2533 /* Detect Dynamic Windows style font name...
2527 * Format: ##.Fontname 2534 * Format: ##.Fontname
2528 * and convert to a Pango name 2535 * and convert to a Pango name
2529 */ 2536 */
2571 { 2578 {
2572 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"); 2579 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
2573 if(tmp) 2580 if(tmp)
2574 handle2 = tmp; 2581 handle2 = tmp;
2575 } 2582 }
2583 /* If it is a groupox we want to operate on the frame label */
2584 else if(GTK_IS_FRAME(handle))
2585 {
2586 GtkWidget *tmp = gtk_frame_get_label_widget(GTK_FRAME(handle));
2587 if(tmp)
2588 handle2 = tmp;
2589 }
2576 2590
2577 pcontext = gtk_widget_get_pango_context( handle2 ); 2591 pcontext = gtk_widget_get_pango_context( handle2 );
2578 if ( pcontext ) 2592 if ( pcontext )
2579 { 2593 {
2580 pfont = pango_context_get_font_description( pcontext ); 2594 pfont = pango_context_get_font_description( pcontext );
2581 if ( pfont ) 2595 if ( pfont )
2582 { 2596 {
2597 int len, x;
2598
2583 font = pango_font_description_to_string( pfont ); 2599 font = pango_font_description_to_string( pfont );
2584 retfont = strdup(font); 2600 retfont = strdup(font);
2601 len = strlen(font);
2602 /* Convert to Dynamic Windows format if we can... */
2603 if(len > 0 && isdigit(font[len-1]))
2604 {
2605 int size;
2606
2607 x=len-1;
2608 while(x > 0 && font[x] != ' ')
2609 {
2610 x--;
2611 }
2612 size = atoi(&font[x]);
2613 /* If we were able to find a valid size... */
2614 if(size > 0)
2615 {
2616 /* Null terminate after the name...
2617 * and create the Dynamic Windows style font.
2618 */
2619 font[x] = 0;
2620 snprintf(retfont, len+1, "%d.%s", size, font);
2621 }
2622 }
2585 g_free( font ); 2623 g_free( font );
2586 } 2624 }
2587 } 2625 }
2588 DW_MUTEX_UNLOCK; 2626 DW_MUTEX_UNLOCK;
2589 return retfont; 2627 return retfont;
2960 * pad: Number of pixels to pad around the box. 2998 * pad: Number of pixels to pad around the box.
2961 * title: Text to be displayined in the group outline. 2999 * title: Text to be displayined in the group outline.
2962 */ 3000 */
2963 HWND dw_groupbox_new(int type, int pad, char *title) 3001 HWND dw_groupbox_new(int type, int pad, char *title)
2964 { 3002 {
2965 GtkWidget *tmp, *frame, *label; 3003 GtkWidget *tmp, *frame;
2966 PangoFontDescription *pfont;
2967 PangoContext *pcontext;
2968 int _locked_by_me = FALSE; 3004 int _locked_by_me = FALSE;
2969 3005
2970 DW_MUTEX_LOCK; 3006 DW_MUTEX_LOCK;
2971 frame = gtk_frame_new(NULL); 3007 frame = gtk_frame_new(NULL);
2972 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN); 3008 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
2973 gtk_frame_set_label(GTK_FRAME(frame), title && *title ? title : NULL); 3009 gtk_frame_set_label(GTK_FRAME(frame), title && *title ? title : NULL);
2974 /*
2975 * Get the current font for the frame's label and make it bold
2976 */
2977 label = gtk_frame_get_label_widget(GTK_FRAME(frame));
2978 pcontext = gtk_widget_get_pango_context( label );
2979 if ( pcontext )
2980 {
2981 pfont = pango_context_get_font_description( pcontext );
2982 if ( pfont )
2983 {
2984 pango_font_description_set_weight( pfont, PANGO_WEIGHT_BOLD );
2985 gtk_widget_modify_font( label, pfont );
2986 }
2987 }
2988 3010
2989 tmp = gtk_table_new(1, 1, FALSE); 3011 tmp = gtk_table_new(1, 1, FALSE);
2990 gtk_container_set_border_width(GTK_CONTAINER(tmp), pad); 3012 gtk_container_set_border_width(GTK_CONTAINER(tmp), pad);
2991 g_object_set_data(G_OBJECT(tmp), "_dw_boxtype", GINT_TO_POINTER(type)); 3013 g_object_set_data(G_OBJECT(tmp), "_dw_boxtype", GINT_TO_POINTER(type));
2992 g_object_set_data(G_OBJECT(tmp), "_dw_boxpad", GINT_TO_POINTER(pad)); 3014 g_object_set_data(G_OBJECT(tmp), "_dw_boxpad", GINT_TO_POINTER(pad));