]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/samples/layout/gnomelayout.cpp
ICU-57132.0.1.tar.gz
[apple/icu.git] / icuSources / samples / layout / gnomelayout.cpp
index ab1dba3757f312b94d72359872cfec7501f2cbb3..31e25871d4525d6d059b313d463c1f9557d8dc90 100644 (file)
@@ -2,7 +2,7 @@
 /*
  ****************************************************************************** *
  *
 /*
  ****************************************************************************** *
  *
- *   Copyright (C) 1999-2003, International Business Machines
+ *   Copyright (C) 1999-2007, International Business Machines
  *   Corporation and others.  All Rights Reserved.
  *
  ****************************************************************************** *
  *   Corporation and others.  All Rights Reserved.
  *
  ****************************************************************************** *
@@ -13,7 +13,8 @@
  */
 
 #include <gnome.h>
  */
 
 #include <gnome.h>
-#include "freetype/freetype.h"
+#include <ft2build.h>
+#include FT_FREETYPE_H
 
 #include "unicode/ustring.h"
 #include "unicode/uscript.h"
 
 #include "unicode/ustring.h"
 #include "unicode/uscript.h"
@@ -36,7 +37,7 @@ struct Context
     Paragraph *paragraph;
 };
 
     Paragraph *paragraph;
 };
 
-static TT_Engine engine;
+static FT_Library engine;
 static GnomeGUISupport *guiSupport;
 static GnomeFontMap *fontMap;
 static ScriptCompositeFontInstance *font;
 static GnomeGUISupport *guiSupport;
 static GnomeFontMap *fontMap;
 static ScriptCompositeFontInstance *font;
@@ -46,9 +47,10 @@ static GSList *appList = NULL;
 GtkWidget *newSample(const gchar *fileName);
 void       closeSample(GtkWidget *sample);
 
 GtkWidget *newSample(const gchar *fileName);
 void       closeSample(GtkWidget *sample);
 
-void showabout(GtkWidget *widget, gpointer data)
+void showabout(GtkWidget */*widget*/, gpointer /*data*/)
 {
     GtkWidget *aboutBox;
 {
     GtkWidget *aboutBox;
+    const gchar *documentedBy[] = {NULL};
     const gchar *writtenBy[] = {
         "Eric Mader",
         NULL
     const gchar *writtenBy[] = {
         "Eric Mader",
         NULL
@@ -56,28 +58,30 @@ void showabout(GtkWidget *widget, gpointer data)
 
     aboutBox = gnome_about_new("Gnome Layout Sample",
                                "0.1",
 
     aboutBox = gnome_about_new("Gnome Layout Sample",
                                "0.1",
-                               "Copyright (C) 1998-2002 By International Business Machines Corporation and others. All Rights Reserved.",
-                               writtenBy,
+                               "Copyright (C) 1998-2006 By International Business Machines Corporation and others. All Rights Reserved.",
                                "A simple demo of the ICU LayoutEngine.",
                                "A simple demo of the ICU LayoutEngine.",
+                               writtenBy,
+                               documentedBy,
+                               "",
                                NULL);
 
     gtk_widget_show(aboutBox);
 }
 
                                NULL);
 
     gtk_widget_show(aboutBox);
 }
 
-void notimpl(GtkObject *object, gpointer data)
+void notimpl(GtkObject */*object*/, gpointer /*data*/)
 {
     gnome_ok_dialog("Not implemented...");
 }
 
 gchar *prettyTitle(const gchar *path)
 {
 {
     gnome_ok_dialog("Not implemented...");
 }
 
 gchar *prettyTitle(const gchar *path)
 {
-  gchar *name  = g_basename(path);
+  const gchar *name  = g_basename(path);
   gchar *title = g_strconcat("Gnome Layout Sample - ", name, NULL);
 
   return title;
 }
 
   gchar *title = g_strconcat("Gnome Layout Sample - ", name, NULL);
 
   return title;
 }
 
-void openOK(GtkObject *object, gpointer data)
+void openOK(GtkObject */*object*/, gpointer data)
 {
   GtkFileSelection *fileselection = GTK_FILE_SELECTION(data);
   GtkWidget *app = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(fileselection), "app"));
 {
   GtkFileSelection *fileselection = GTK_FILE_SELECTION(data);
   GtkWidget *app = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(fileselection), "app"));
@@ -110,7 +114,7 @@ void openOK(GtkObject *object, gpointer data)
   g_free(fileName);
 }
 
   g_free(fileName);
 }
 
-void openfile(GtkObject *object, gpointer data)
+void openfile(GtkObject */*object*/, gpointer data)
 {
   GtkWidget *app = GTK_WIDGET(data);
   GtkWidget *fileselection;
 {
   GtkWidget *app = GTK_WIDGET(data);
   GtkWidget *fileselection;
@@ -142,29 +146,29 @@ void openfile(GtkObject *object, gpointer data)
   gtk_main();
 }
 
   gtk_main();
 }
 
-void newapp(GtkObject *object, gpointer data)
+void newapp(GtkObject */*object*/, gpointer /*data*/)
 {
   GtkWidget *app = newSample("Sample.txt");
 
   gtk_widget_show_all(app);
 }
 
 {
   GtkWidget *app = newSample("Sample.txt");
 
   gtk_widget_show_all(app);
 }
 
-void closeapp(GtkWidget *widget, gpointer data)
+void closeapp(GtkWidget */*widget*/, gpointer data)
 {
   GtkWidget *app = GTK_WIDGET(data);
 
   closeSample(app);
 }
 
 {
   GtkWidget *app = GTK_WIDGET(data);
 
   closeSample(app);
 }
 
-void shutdown(GtkObject *object, gpointer data)
+void shutdown(GtkObject */*object*/, gpointer /*data*/)
 {
     gtk_main_quit();
 }
 
 GnomeUIInfo fileMenu[] =
 {
 {
     gtk_main_quit();
 }
 
 GnomeUIInfo fileMenu[] =
 {
-  GNOMEUIINFO_MENU_NEW_ITEM("_New Sample",
-                           "Create a new Gnome Layout Sample",
+  GNOMEUIINFO_MENU_NEW_ITEM((gchar *) "_New Sample",
+                           (gchar *) "Create a new Gnome Layout Sample",
                            newapp, NULL),
 
   GNOMEUIINFO_MENU_OPEN_ITEM(openfile, NULL),
                            newapp, NULL),
 
   GNOMEUIINFO_MENU_OPEN_ITEM(openfile, NULL),
@@ -183,12 +187,12 @@ GnomeUIInfo helpMenu[] =
 
 GnomeUIInfo mainMenu[] =
 {
 
 GnomeUIInfo mainMenu[] =
 {
-    GNOMEUIINFO_SUBTREE(N_("File"), fileMenu),
-    GNOMEUIINFO_SUBTREE(N_("Help"), helpMenu),
+    GNOMEUIINFO_SUBTREE(N_((gchar *) "File"), fileMenu),
+    GNOMEUIINFO_SUBTREE(N_((gchar *) "Help"), helpMenu),
     GNOMEUIINFO_END
 };
 
     GNOMEUIINFO_END
 };
 
-gint eventDelete(GtkWidget *widget, GdkEvent *event, gpointer data)
+gint eventDelete(GtkWidget *widget, GdkEvent */*event*/, gpointer /*data*/)
 {
   closeSample(widget);
 
 {
   closeSample(widget);
 
@@ -196,7 +200,7 @@ gint eventDelete(GtkWidget *widget, GdkEvent *event, gpointer data)
   return TRUE;
 }
 
   return TRUE;
 }
 
-gint eventConfigure(GtkWidget *widget, GdkEventConfigure *event, Context *context)
+gint eventConfigure(GtkWidget */*widget*/, GdkEventConfigure *event, Context *context)
 {
   if (context->paragraph != NULL) {
     context->width  = event->width;
 {
   if (context->paragraph != NULL) {
     context->width  = event->width;
@@ -210,7 +214,7 @@ gint eventConfigure(GtkWidget *widget, GdkEventConfigure *event, Context *contex
   return TRUE;
 }
 
   return TRUE;
 }
 
-gint eventExpose(GtkWidget *widget, GdkEvent *event, Context *context)
+gint eventExpose(GtkWidget *widget, GdkEvent */*event*/, Context *context)
 {
   if (context->paragraph != NULL) {
     gint maxLines = context->paragraph->getLineCount() - 1;
 {
   if (context->paragraph != NULL) {
     gint maxLines = context->paragraph->getLineCount() - 1;
@@ -225,57 +229,48 @@ gint eventExpose(GtkWidget *widget, GdkEvent *event, Context *context)
 
 GtkWidget *newSample(const gchar *fileName)
 {
 
 GtkWidget *newSample(const gchar *fileName)
 {
-  gchar     *title   = NULL;
-  GtkWidget *app     = NULL;
-  GtkWidget *area    = NULL;
   Context   *context = new Context();
 
   context->width  = 600;
   context->height = 400;
   context->paragraph = Paragraph::paragraphFactory(fileName, font, guiSupport);
 
   Context   *context = new Context();
 
   context->width  = 600;
   context->height = 400;
   context->paragraph = Paragraph::paragraphFactory(fileName, font, guiSupport);
 
-  if (context->paragraph != NULL) {
-    GtkStyle *style;
-    gchar *title = prettyTitle(fileName);
-
-    app = gnome_app_new("gnomeLayout", title);
+  gchar *title = prettyTitle(fileName);
+  GtkWidget *app = gnome_app_new("gnomeLayout", title);
 
 
-    gtk_object_set_data(GTK_OBJECT(app), "context", context);
+  gtk_object_set_data(GTK_OBJECT(app), "context", context);
 
 
-    gtk_window_set_default_size(GTK_WINDOW(app), 600 - 24, 400);
+  gtk_window_set_default_size(GTK_WINDOW(app), 600 - 24, 400);
 
 
-    gnome_app_create_menus_with_data(GNOME_APP(app), mainMenu, app);
+  gnome_app_create_menus_with_data(GNOME_APP(app), mainMenu, app);
 
 
-    gtk_signal_connect(GTK_OBJECT(app), "delete_event",
-                      GTK_SIGNAL_FUNC(eventDelete), NULL);
+  gtk_signal_connect(GTK_OBJECT(app), "delete_event",
+                    GTK_SIGNAL_FUNC(eventDelete), NULL);
 
 
-    area = gtk_drawing_area_new();
-    gtk_object_set_data(GTK_OBJECT(app), "area", area);
+  GtkWidget *area = gtk_drawing_area_new();
+  gtk_object_set_data(GTK_OBJECT(app), "area", area);
 
 
-#if 1
-    style = gtk_style_copy(gtk_widget_get_style(area));
+  GtkStyle *style = gtk_style_copy(gtk_widget_get_style(area));
 
 
-    for (int i = 0; i < 5; i += 1) {
-      style->fg[i] = style->white;
-    }
+  for (int i = 0; i < 5; i += 1) {
+    style->fg[i] = style->white;
+  }
     
     
-    gtk_widget_set_style(area, style);
-#endif
+  gtk_widget_set_style(area, style);
 
 
-    gnome_app_set_contents(GNOME_APP(app), area);
+  gnome_app_set_contents(GNOME_APP(app), area);
 
 
-    gtk_signal_connect(GTK_OBJECT(area),
-                       "expose_event",
-                       GTK_SIGNAL_FUNC(eventExpose),
-                       context);
+  gtk_signal_connect(GTK_OBJECT(area),
+                    "expose_event",
+                    GTK_SIGNAL_FUNC(eventExpose),
+                    context);
 
 
-    gtk_signal_connect(GTK_OBJECT(area),
-                       "configure_event",
-                       GTK_SIGNAL_FUNC(eventConfigure),
-                       context);
+  gtk_signal_connect(GTK_OBJECT(area),
+                    "configure_event",
+                    GTK_SIGNAL_FUNC(eventConfigure),
+                    context);
 
 
-    appList = g_slist_prepend(appList, app);
-  }
+  appList = g_slist_prepend(appList, app);
 
   g_free(title);
 
 
   g_free(title);
 
@@ -304,37 +299,43 @@ void closeSample(GtkWidget *app)
 int main (int argc, char *argv[])
 {
     LEErrorCode   fontStatus = LE_NO_ERROR;
 int main (int argc, char *argv[])
 {
     LEErrorCode   fontStatus = LE_NO_ERROR;
-    GtkWidget     *app;
+    poptContext   ptctx;
+    GtkWidget    *app;
 
 
-    TT_Init_FreeType(&engine);
+    FT_Init_FreeType(&engine);
 
 
-    gnome_init("gnomelayout", "0.1", argc, argv);
+    gnome_init_with_popt_table("gnomelayout", "0.1", argc, argv, NULL, 0, &ptctx);
 
     guiSupport = new GnomeGUISupport();
     fontMap    = new GnomeFontMap(engine, "FontMap.Gnome", 24, guiSupport, fontStatus);
     font       = new ScriptCompositeFontInstance(fontMap);
 
     if (LE_FAILURE(fontStatus)) {
 
     guiSupport = new GnomeGUISupport();
     fontMap    = new GnomeFontMap(engine, "FontMap.Gnome", 24, guiSupport, fontStatus);
     font       = new ScriptCompositeFontInstance(fontMap);
 
     if (LE_FAILURE(fontStatus)) {
-        TT_Done_FreeType(engine);
+        FT_Done_FreeType(engine);
         return 1;
     }
 
         return 1;
     }
 
-    if (argc <= 1) {
-      app = newSample("Sample.txt");
-      gtk_widget_show_all(app);
-    } else {
-      for (int i = 1; i < argc; i += 1) {
-       app = newSample(argv[i]);
-       gtk_widget_show_all(app);
-      }
+    const char  *defaultArgs[] = {"Sample.txt", NULL};
+    const char **args = poptGetArgs(ptctx);
+    
+    if (args == NULL) {
+        args = defaultArgs;
     }
 
     }
 
+    for (int i = 0; args[i] != NULL; i += 1) {
+       app = newSample(args[i]);
+           
+       gtk_widget_show_all(app);
+    }
+    
+    poptFreeContext(ptctx);
+    
     gtk_main();
 
     delete font;
     delete guiSupport;
 
     gtk_main();
 
     delete font;
     delete guiSupport;
 
-    TT_Done_FreeType(engine);
+    FT_Done_FreeType(engine);
 
     exit(0);
 }
 
     exit(0);
 }