comparison gtk/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
2747 { 2747 {
2748 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); 2748 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
2749 if(tmp) 2749 if(tmp)
2750 handle2 = tmp; 2750 handle2 = tmp;
2751 } 2751 }
2752 /* If it is a groupox we want to operate on the frame label */
2753 else if(GTK_IS_FRAME(handle))
2754 {
2755 GtkWidget *tmp = gtk_frame_get_label_widget(GTK_FRAME(handle));
2756 if(tmp)
2757 handle2 = tmp;
2758 }
2752 2759
2753 #if GTK_MAJOR_VERSION < 2 2760 #if GTK_MAJOR_VERSION < 2
2754 /* Free old font if it exists */ 2761 /* Free old font if it exists */
2755 gdkfont = (GdkFont *)gtk_object_get_data(GTK_OBJECT(handle2), "_dw_gdkfont"); 2762 gdkfont = (GdkFont *)gtk_object_get_data(GTK_OBJECT(handle2), "_dw_gdkfont");
2756 if(gdkfont) 2763 if(gdkfont)
2816 { 2823 {
2817 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); 2824 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
2818 if(tmp) 2825 if(tmp)
2819 handle2 = tmp; 2826 handle2 = tmp;
2820 } 2827 }
2828 /* If it is a groupox we want to operate on the frame label */
2829 else if(GTK_IS_FRAME(handle))
2830 {
2831 GtkWidget *tmp = gtk_frame_get_label_widget(GTK_FRAME(handle));
2832 if(tmp)
2833 handle2 = tmp;
2834 }
2821 2835
2822 #if GTK_MAJOR_VERSION < 2 2836 #if GTK_MAJOR_VERSION < 2
2823 /* Free old font if it exists */ 2837 /* Free old font if it exists */
2824 gdkfont = (GdkFont *)gtk_object_get_data(GTK_OBJECT(handle2), "_dw_gdkfont"); 2838 gdkfont = (GdkFont *)gtk_object_get_data(GTK_OBJECT(handle2), "_dw_gdkfont");
2825 if(gdkfont) 2839 if(gdkfont)
2835 if ( pcontext ) 2849 if ( pcontext )
2836 { 2850 {
2837 pfont = pango_context_get_font_description( pcontext ); 2851 pfont = pango_context_get_font_description( pcontext );
2838 if ( pfont ) 2852 if ( pfont )
2839 { 2853 {
2854 int len, x;
2855
2840 font = pango_font_description_to_string( pfont ); 2856 font = pango_font_description_to_string( pfont );
2841 retfont = strdup(font); 2857 retfont = strdup(font);
2858 len = strlen(font);
2859 /* Convert to Dynamic Windows format if we can... */
2860 if(len > 0 && isdigit(font[len-1]))
2861 {
2862 int size;
2863
2864 x=len-1;
2865 while(x > 0 && font[x] != ' ')
2866 {
2867 x--;
2868 }
2869 size = atoi(&font[x]);
2870 /* If we were able to find a valid size... */
2871 if(size > 0)
2872 {
2873 /* Null terminate after the name...
2874 * and create the Dynamic Windows style font.
2875 */
2876 font[x] = 0;
2877 snprintf(retfont, len+1, "%d.%s", size, font);
2878 }
2879 }
2842 g_free( font ); 2880 g_free( font );
2843 } 2881 }
2844 } 2882 }
2845 #endif 2883 #endif
2846 DW_MUTEX_UNLOCK; 2884 DW_MUTEX_UNLOCK;
3270 * pad: Number of pixels to pad around the box. 3308 * pad: Number of pixels to pad around the box.
3271 * title: Text to be displayined in the group outline. 3309 * title: Text to be displayined in the group outline.
3272 */ 3310 */
3273 HWND dw_groupbox_new(int type, int pad, char *title) 3311 HWND dw_groupbox_new(int type, int pad, char *title)
3274 { 3312 {
3275 GtkWidget *tmp, *frame, *label; 3313 GtkWidget *tmp, *frame;
3276 PangoFontDescription *pfont;
3277 PangoContext *pcontext;
3278 int _locked_by_me = FALSE; 3314 int _locked_by_me = FALSE;
3279 3315
3280 DW_MUTEX_LOCK; 3316 DW_MUTEX_LOCK;
3281 frame = gtk_frame_new(NULL); 3317 frame = gtk_frame_new(NULL);
3282 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN); 3318 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
3283 gtk_frame_set_label(GTK_FRAME(frame), title && *title ? title : NULL); 3319 gtk_frame_set_label(GTK_FRAME(frame), title && *title ? title : NULL);
3284 /*
3285 * Get the current font for the frame's label and make it bold
3286 */
3287 label = gtk_frame_get_label_widget(GTK_FRAME(frame));
3288 pcontext = gtk_widget_get_pango_context( label );
3289 if ( pcontext )
3290 {
3291 pfont = pango_context_get_font_description( pcontext );
3292 if ( pfont )
3293 {
3294 pango_font_description_set_weight( pfont, PANGO_WEIGHT_BOLD );
3295 gtk_widget_modify_font( label, pfont );
3296 }
3297 }
3298
3299 tmp = gtk_table_new(1, 1, FALSE); 3320 tmp = gtk_table_new(1, 1, FALSE);
3300 gtk_container_border_width(GTK_CONTAINER(tmp), pad); 3321 gtk_container_border_width(GTK_CONTAINER(tmp), pad);
3301 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_boxtype", GINT_TO_POINTER(type)); 3322 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_boxtype", GINT_TO_POINTER(type));
3302 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_boxpad", GINT_TO_POINTER(pad)); 3323 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_boxpad", GINT_TO_POINTER(pad));
3303 gtk_object_set_data(GTK_OBJECT(frame), "_dw_boxhandle", (gpointer)tmp); 3324 gtk_object_set_data(GTK_OBJECT(frame), "_dw_boxhandle", (gpointer)tmp);