gcompris r3709 - in trunk: . src/boards



Author: bcoudoin
Date: Fri Jan 30 23:31:55 2009
New Revision: 3709
URL: http://svn.gnome.org/viewvc/gcompris?rev=3709&view=rev

Log:
	Added RTL support.


Modified:
   trunk/ChangeLog
   trunk/src/boards/reading.c

Modified: trunk/src/boards/reading.c
==============================================================================
--- trunk/src/boards/reading.c	(original)
+++ trunk/src/boards/reading.c	Fri Jan 30 23:31:55 2009
@@ -46,7 +46,8 @@
 typedef enum
 {
   MODE_HORIZONTAL		= 0,
-  MODE_VERTICAL			= 1
+  MODE_VERTICAL			= 1,
+  MODE_HORIZONTAL_RTL		= 2
 } Mode;
 static Mode currentMode = MODE_VERTICAL;
 
@@ -210,10 +211,9 @@
 
       g_warning ("Font to display words have size %d  ascent : %d, descent : %d.\n Set inerline to %d", font_size, ascent, descent, interline);
 
-      /* Default mode */
-      currentMode=MODE_VERTICAL;
-      if(gcomprisBoard->mode && g_strcasecmp(gcomprisBoard->mode, "horizontal")==0)
-	currentMode=MODE_HORIZONTAL;
+
+
+      
 
       gc_wordlist = gc_wordlist_get_from_file("wordsgame/default-$LOCALE.xml");
 
@@ -230,7 +230,17 @@
 	    }
 	}
 
-      reading_next_level();
+      
+      currentMode=MODE_VERTICAL; // Default mode 
+      if(gcomprisBoard->mode && g_strcasecmp(gcomprisBoard->mode, "horizontal")==0)
+        {
+          if (pango_unichar_direction(g_utf8_get_char(gc_wordlist_random_word_get(gc_wordlist, gcomprisBoard->level))) == PANGO_DIRECTION_RTL)	
+              currentMode=MODE_HORIZONTAL_RTL;
+          else
+               currentMode=MODE_HORIZONTAL;
+        }
+   
+       reading_next_level();
     }
 }
 
@@ -314,7 +324,7 @@
     }
   else
     {
-      current_x = BASE_X1;
+      current_x = BASE_X2;
       numberOfLine=2+gcomprisBoard->level;
     }
 
@@ -461,6 +471,8 @@
 
   if(currentMode==MODE_HORIZONTAL)
     anchor=GTK_ANCHOR_WEST;
+  else if (currentMode==MODE_HORIZONTAL_RTL)
+    anchor=GTK_ANCHOR_EAST;
 
   previousFocus.item = \
     gnome_canvas_item_new (GNOME_CANVAS_GROUP(previousFocus.rootItem),
@@ -497,6 +509,24 @@
       current_y += interline;
       numberOfLine--;
     }
+  else if (currentMode==MODE_HORIZONTAL_RTL)
+    {
+      double x1, y1, x2, y2;
+
+      gnome_canvas_item_get_bounds(GNOME_CANVAS_ITEM(previousFocus.rootItem), &x1, &y1, &x2, &y2);
+
+      // Are we out of bound
+      if(x1<BASE_X1)
+	{
+	  // Do the line Wrapping
+	  gnome_canvas_item_move(GNOME_CANVAS_ITEM(previousFocus.rootItem), BASE_X2-x2, interline);
+	  current_y += interline;
+	  current_x = BASE_X2;
+	  numberOfLine--;
+	}
+      current_x -= x2-x1 + font_size;
+     }
+
   else
     {
       double x1, y1, x2, y2;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]