/*
* Copyright (C) Jcodeer Zhang 2011
*
* This application is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This application is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <
*
* 功能介绍
* 本例演示了控件对其方式和GtkLabel文本对齐方式
* gcc -o 008.exe 008.c `pkg-config --cflags --libs gtk+-2.0`
* ./008.exe
*/
#include
int main(int argc,char** argv)
{
gtk_init(&argc,&argv);
GtkWidget* main_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width(GTK_CONTAINER(main_win),5);
GtkWidget* box = gtk_vbox_new(FALSE,3);
gtk_container_add(GTK_CONTAINER(main_win),box);
//widget left alignment
GtkWidget* b = gtk_label_new("Widget left");
gtk_misc_set_alignment(GTK_MISC(b),0,0);
gtk_box_pack_start(GTK_BOX(box),b,FALSE,FALSE,0);
//widget center alignment
b = gtk_label_new("Widget center");
gtk_misc_set_alignment(GTK_MISC(b),0.5,0);
gtk_box_pack_start(GTK_BOX(box),b,FALSE,FALSE,0);
//widget right alignment
b = gtk_label_new("Widget right");
gtk_misc_set_alignment(GTK_MISC(b),1,0);
gtk_box_pack_start(GTK_BOX(box),b,FALSE,FALSE,0);
//text left alignment
b = gtk_label_new("text left alignment\nI am left alignment now");
gtk_label_set_justify(GTK_LABEL(b),GTK_JUSTIFY_LEFT);
gtk_misc_set_alignment(GTK_MISC(b),0.5,0);
gtk_box_pack_start(GTK_BOX(box),b,FALSE,FALSE,0);
//text center alignment
b = gtk_label_new("text center alignment\nI am center alignment now");
gtk_label_set_justify(GTK_LABEL(b),GTK_JUSTIFY_CENTER);
gtk_misc_set_alignment(GTK_MISC(b),0.5,0);
gtk_box_pack_start(GTK_BOX(box),b,FALSE,FALSE,0);
//text right alignment
b = gtk_label_new("text right alignment\nI am right alignment now");
gtk_label_set_justify(GTK_LABEL(b),GTK_JUSTIFY_RIGHT);
gtk_misc_set_alignment(GTK_MISC(b),0.5,0);
gtk_box_pack_start(GTK_BOX(box),b,FALSE,FALSE,0);
g_signal_connect_swapped(G_OBJECT(main_win),"destroy",G_CALLBACK(gtk_main_quit),NULL);
gtk_widget_show_all(main_win);
gtk_main();
printf("hello world\n");
return 0;
}