Revision: 2463
http://sourceforge.net/p/swingme/code/2463
Author: yuranet
Date: 2021-06-22 18:54:03 +0000 (Tue, 22 Jun 2021)
Log Message:
-----------
getColor works
Modified Paths:
--------------
iOSME/src/javax/microedition/lcdui/Graphics.java
iOSME/src/net/yura/ios/SwingMEiOSApplication.java
Modified: iOSME/src/javax/microedition/lcdui/Graphics.java
===================================================================
--- iOSME/src/javax/microedition/lcdui/Graphics.java 2021-06-22 16:17:29 UTC (rev 2462)
+++ iOSME/src/javax/microedition/lcdui/Graphics.java 2021-06-22 18:54:03 UTC (rev 2463)
@@ -6,7 +6,6 @@
import apple.coregraphics.opaque.CGColorRef;
import apple.coregraphics.opaque.CGContextRef;
import apple.coregraphics.opaque.CGFontRef;
-import apple.coregraphics.struct.CGAffineTransform;
import apple.coregraphics.struct.CGPoint;
import apple.coregraphics.struct.CGRect;
import apple.coregraphics.struct.CGSize;
@@ -13,7 +12,7 @@
import apple.coretext.c.CoreText;
import apple.coretext.opaque.CTLineRef;
import apple.foundation.NSAttributedString;
-import apple.foundation.NSString;
+import apple.foundation.NSMutableDictionary;
import apple.uikit.UIBezierPath;
import apple.uikit.UIColor;
import apple.uikit.c.UIKit;
@@ -20,6 +19,8 @@
import apple.uikit.enums.UIRectCorner;
import javax.microedition.lcdui.game.Sprite;
import android.graphics.ColorMatrix;
+import org.moe.natj.general.ptr.NFloatPtr;
+import org.moe.natj.general.ptr.impl.PtrFactory;
import org.moe.natj.objc.ObjCRuntime;
public class Graphics {
@@ -35,6 +36,7 @@
private CGContextRef context;
private Font font = Font.getDefaultFont();
+ private UIColor color;
private int tx, ty;
private int stroke;
@@ -83,9 +85,18 @@
}
public int getColor() {
- //return paint.getColor();
- // TODO keep local var
- throw new UnsupportedOperationException();
+ NFloatPtr alpha = PtrFactory.newNFloatReference();
+ NFloatPtr red = PtrFactory.newNFloatReference();
+ NFloatPtr green = PtrFactory.newNFloatReference();
+ NFloatPtr blue = PtrFactory.newNFloatReference();
+ if (color.getRedGreenBlueAlpha(red, green, blue, alpha)) {
+ int r = (int)Math.round(255 * red.getValue());
+ int g = (int)Math.round(255 * green.getValue());
+ int b = (int)Math.round(255 * blue.getValue());
+ int a = (int)Math.round(255 * alpha.getValue());
+ return ((a << 24) & 0xFF000000) | ((r << 16) & 0x00FF0000) | ((g << 8) & 0x0000FF00) | (b & 0x000000FF);
+ }
+ throw new IllegalStateException("color not in RGB format");
}
public static UIColor getColor(int argb) {
@@ -97,10 +108,10 @@
}
public void setColor(int color) {
- CGColorRef cgColorRef = getColor(color).CGColor();
+ this.color = getColor(color);
+ CGColorRef cgColorRef = this.color.CGColor();
CoreGraphics.CGContextSetStrokeColorWithColor(context, cgColorRef);
CoreGraphics.CGContextSetFillColorWithColor(context, cgColorRef);
-
}
public void drawImage(javax.microedition.lcdui.Image image, int x, int y, int anchor) {
@@ -236,7 +247,12 @@
//string.drawAtPointWithAttributes(new CGPoint(tx + newx, ty + newy), font.getAsNSDictionary());
//UIKit.UIGraphicsPopContext();
- NSAttributedString attributedString = NSAttributedString.alloc().initWithStringAttributes(str, font.getAsNSDictionary());
+
+ NSMutableDictionary attributes = NSMutableDictionary.dictionaryWithCapacity(2);
+ attributes.put(UIKit.NSFontAttributeName(), font.font);
+ attributes.put(UIKit.NSForegroundColorAttributeName(), color);
+
+ NSAttributedString attributedString = NSAttributedString.alloc().initWithStringAttributes(str, attributes);
CTLineRef line = CoreText.CTLineCreateWithAttributedString(ObjCRuntime.cast(attributedString, CFAttributedStringRef.class));
CoreGraphics.CGContextSetTextPosition(context, tx + newx, ty + newy);
Modified: iOSME/src/net/yura/ios/SwingMEiOSApplication.java
===================================================================
--- iOSME/src/net/yura/ios/SwingMEiOSApplication.java 2021-06-22 16:17:29 UTC (rev 2462)
+++ iOSME/src/net/yura/ios/SwingMEiOSApplication.java 2021-06-22 18:54:03 UTC (rev 2463)
@@ -71,6 +71,7 @@
UIScreen screen = UIScreen.mainScreen();
+ //CGRect statusBar = application.statusBarFrame();
CGRect bounds = screen.bounds();
window = UIWindow.alloc().initWithFrame(bounds);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|