[Kst] extragear/graphics/kst/kst

George Staikos staikos at kde.org
Thu Jun 16 19:00:03 CEST 2005


SVN commit 426183 by staikos:

some RTL support and some testcase work


 M  +15 -9     extensions/js/examples/testlabels.js  
 M  +16 -2     kstviewlabel.cpp  


--- trunk/extragear/graphics/kst/kst/extensions/js/examples/testlabels.js #426182:426183
@@ -2,28 +2,34 @@
 
 w = new Window;
 
-la = new Label(w);
+la = new Label(w); // a simple label
 la.text = "My test label";
 la.position = new Point(383, 34);
 
-lb = new Label(w);
+lb = new Label(w);  // Show some kst-latex
 lb.text = "a label with math: \\Sigma^{x+5}_5";
 lb.position = new Point(100, 34);
 
-lc = new Label(w);
+lc = new Label(w); // show scalar substitution works
 lc.text = "A label with a scalar: [CONST_PI]";
 lc.position = new Point(100, 154);
-lc.font = "verdana";
-lc.fontSize = 26;
+lc.font = "verdana"; // show font changing works
+lc.fontSize = 26;  // show font size changing
+lc.color = "red"; // show color changing
+lc.backgroundColor = "#08324b"; // show background color changing
 
 ld = new Label(w);
-ld.text = "[CONST_PI]";
-ld.position = new Point(100, 194);
+ld.text = "[CONST_PI]";  // show scalar substitution works with no text
+ld.position = new Point(100, 204);
 ld.fontSize = 10;
+ld.justification = 2 | (2 << 8); // show justification right+bottom
 
-
 le = new Label(w);
-le.text = "[=2*sqrt(2)/sin(sqrt(2))^2]";
+le.text = "[=2*sqrt(2)/sin(sqrt(2))^2]";  // show equations work
 le.position = new Point(100, 234);
 
+lf = new Label(w);
+lf.text = "[=[CONST_PI]]"; // show nesting works
+lf.position = new Point(100, 274);
 
+
--- trunk/extragear/graphics/kst/kst/kstviewlabel.cpp #426182:426183
@@ -27,8 +27,10 @@
 #include <klocale.h>
 #include <kpopupmenu.h>
 
+#include <qapplication.h>
 #include <qptrstack.h>
 
+#include <stdlib.h>
 
 KstViewLabel::KstViewLabel(const QString& txt, KstLJustifyType justify, float rotation)
 : KstBorderedViewObject("KstViewLabel") {
@@ -165,9 +167,19 @@
   p.rotate(_rotation);
   //double rotationRadians = 3.1415926535897932333796 * _rotation / 180.0;
 
-  // FIXME: text direction support
+  int hJust = KST_JUSTIFY_H(_justify);
+  if (QApplication::reverseLayout()) {
+    if (hJust == KST_JUSTIFY_H_NONE) {
+      hJust = KST_JUSTIFY_H_RIGHT;
+    }
+  } else {
+    if (hJust == KST_JUSTIFY_H_NONE) {
+      hJust = KST_JUSTIFY_H_LEFT;
+    }
+  }
+
   int x, y;
-  switch (KST_JUSTIFY_H(_justify)) {
+  switch (hJust) {
     case KST_JUSTIFY_H_RIGHT:
         x = size().width() - _textWidth;
       break;
@@ -175,6 +187,7 @@
         x = (size().width() - _textWidth) / 2;
       break;
     case KST_JUSTIFY_H_NONE:
+      abort(); // should never be able to happen
     case KST_JUSTIFY_H_LEFT:
     default:
         x = 0;
@@ -203,6 +216,7 @@
   p.setFont(fnt);
   int size = _fontSize;
 
+  // FIXME: RTL support
   while (fi) {
     if (fi->vOffset == Label::Chunk::None) {
       if (!fstack.isEmpty()) {


More information about the Kst mailing list