Property * property_Window_font;
Method * method_Window_modal;
+Method * method_Window_create;
+
Method * method_Window_onCreate;
Method * method_Window_onRedraw;
DialogResult (* Window_modal)(Window);
+bool (* Window_create)(Window);
+
Class * class_Button;
Method * method_Button_notifyClicked;
method_Window_modal = Class_findMethod(class_Window, "Modal", module);
if(method_Window_modal)
Window_modal = (void *)method_Window_modal->function;
+
+ method_Window_create = Class_findMethod(class_Window, "Create", module);
+ if(method_Window_create)
+ Window_create = (void *)method_Window_create->function;
+
method_Window_onCreate = Class_findMethod(class_Window, "OnCreate", module);
if(method_Window_onCreate)
Window_onCreate_vTblID = method_Window_onCreate->vid;
extern DialogResult (* Window_modal)(Window);
extern Method * method_Window_modal;
+
+extern bool (* Window_create)(Window);
+
+extern Method * method_Window_create;
+
extern Method * method_Window_onCreate;
extern int Window_onCreate_vTblID;
typedef Module Application;
typedef struct Class Class;
typedef uint32_t bool;
+typedef uint32_t Color;
+
+typedef char * String;
+typedef const char * constString;
//struct Class { ...; };
Application eC_init(bool guiApp, int argc, char * argv[]);
Module ecere_init(Module fromModule);
+void Application_main(Application app);
+
extern void (*PrintLn)(Class * class_object, const void * object, ...);
extern Class * class_String;
typedef int64_t DialogResult;
extern DialogResult (* Window_modal)(Window);
+extern bool (* Window_create)(Window);
extern void (* FontResource_set_size)(FontResource f, float v);
extern void (* Window_set_size)(Window w, const Size * v);
extern void (* Window_set_hasClose)(Window w, bool hasClose);
extern bool (* Window_get_hasClose)(Window w);
+
+extern void (* Window_set_caption)(Window w, constString caption);
+extern constString (* Window_get_caption)(Window w);
+
+extern void (* Window_set_background)(Window w, Color background);
+extern Color (* Window_get_background)(Window w);
+
+#define COLOR_r_MASK 0x00FF0000
+#define COLOR_r_SHIFT 16
+#define COLOR_g_MASK 0x0000FF00
+#define COLOR_g_SHIFT 8
+#define COLOR_b_MASK 0x000000FF
+#define COLOR_b_SHIFT 0
"Options" : {
"Warnings" : "All",
"IncludeDirs" : [
- "c"
+ "../c"
],
"TargetType" : "SharedLibrary",
"TargetFileName" : "_pyEcere",
{
"Folder" : "c",
"Files" : [
- "eC.h",
- "ecere.h",
- "ecere.c",
- "eC.c"
+ "../c/eC.c",
+ "../c/eC.h",
+ "../c/ecere.c",
+ "../c/ecere.h"
]
},
{
]
},
"build_ecere.py",
- "ex1.py",
"cffi-ecere.h",
- "pyEcere.py"
+ "pyEcere.py",
+ "samples/sample.py"
],
"ResourcesPath" : "",
"Resources" : [
import sys
from _pyEcere import *
-# lib.PrintLn(lib.class_String, fun.encode('utf8'), ffi.NULL)
+def printLn(args):
+ lib.PrintLn(lib.class_String, args.encode('utf8'), ffi.NULL)
-def app_init():
- app = lib.eC_init(True, len(sys.argv), [ffi.new("char[]", i.encode('utf8')) for i in sys.argv])
- lib.ecere_init(app)
- rApp = ffi.new("Instance *"); rApp[0] = app; lib.Instance_evolve(rApp, lib.class_GuiApplication); app = rApp[0]
+class Color:
+ def __init__(self, r = 0, g = 0, b = 0):
+ self.value = ((((r)) << lib.COLOR_r_SHIFT) | ((g) << lib.COLOR_g_SHIFT) | ((b)) << lib.COLOR_b_SHIFT)
+
+ @property
+ def r(self): return ((((self.value)) & lib.COLOR_r_MASK) >> lib.COLOR_r_SHIFT)
+ @r.setter
+ def r(self, value): self.value = ((self.value) & ~(lib.COLOR_r_MASK)) | (((value)) << lib.COLOR_r_SHIFT)
+
+ @property
+ def g(self): return ((((self.value)) & lib.COLOR_g_MASK) >> lib.COLOR_g_SHIFT)
+ @g.setter
+ def g(self, value): self.value = ((self.value) & ~(lib.COLOR_g_MASK)) | (((value)) << lib.COLOR_g_SHIFT)
+
+ @property
+ def b(self): return ((((self.value)) & lib.COLOR_b_MASK) >> lib.COLOR_r_SHIFT)
+ @b.setter
+ def b(self, value): self.value = ((self.value) & ~(lib.COLOR_b_MASK)) | (((value)) << lib.COLOR_b_SHIFT)
class Size:
def __init__(self, w = 0, h = 0):
class Instance(object):
def __init__(self): self.this = ffi.NULL
+class Application(Instance):
+ def __init__(self):
+ self.this = lib.eC_init(True, len(sys.argv), [ffi.new("char[]", i.encode('utf8')) for i in sys.argv])
+ lib.ecere_init(self.this)
+
+ def main(self):
+ lib.Application_main(self.this)
+
+class GuiApplication(Application):
+ def __init__(self):
+ Application.__init__(self)
+ rApp = ffi.new("Instance *"); rApp[0] = self.this; lib.Instance_evolve(rApp, lib.class_GuiApplication); self.this = rApp[0]
+
class Window(Instance):
- def __init__(self, hasClose = None, clientSize = None):
+ def __init__(self, caption = None, hasClose = None, clientSize = None, background = None):
self.this = lib.Instance_new(lib.class_Window)
+ if caption != None: self.caption = caption
if hasClose != None: self.hasClose = hasClose
if clientSize != None: self.clientSize = clientSize
+ if background != None: self.background = background
def create(self): lib.Window_create(self.this)
def modal(self): lib.Window_modal(self.this)
def hasClose(self): value = ffi.new("bool *"); lib.Window_get_hasClose(self.this, value); return value
@hasClose.setter
def hasClose(self, value): lib.Window_set_hasClose(self.this, value)
+
+ @property
+ def caption(self): value = lib.Window_get_caption(self.this); return ffi.string(value).decode('utf8')
+ @caption.setter
+ def caption(self, value): lib.Window_set_caption(self.this, value.encode('utf8'))
+
+ @property
+ def background(self): value = Color(); lib.Window_get_background(self.this, value.this); return value
+ @background.setter
+ def background(self, value): lib.Window_set_background(self.this, value.value)
+++ /dev/null
-# -*- coding: utf-8 -*-
-from pyEcere import *
-app_init()
-Window(hasClose = True, clientSize = Size(640, 480)).modal()
--- /dev/null
+# -*- coding: utf-8 -*-
+from pyEcere import *
+app = GuiApplication()
+Window(caption = "Hello, Python!!", hasClose = True, clientSize = Size(640, 480), background = Color(b = 255))
+Window(caption = "Bindings are cool", hasClose = True, clientSize = Size(320, 200), background = Color(255))
+app.main()