Merge pull request #557 from TommyX12/master

Added window flashing alert function under window class
This commit is contained in:
Joshua Granick
2015-09-02 08:42:37 -07:00
9 changed files with 87 additions and 9 deletions

View File

@@ -1,4 +1,8 @@
#include <hx/CFFI.h>
#ifdef HX_WINDOWS
#include <SDL_syswm.h>
#include <Windows.h>
#endif
// Custom DEFINE_PRIM macro when calls are the same as NME
@@ -562,6 +566,29 @@ namespace nme {
DEFINE_LIME_LEGACY_PRIM_1(gl_s3d_set_focal_length);
#endif
value lime_window_alert (value count, value speed, value stop_on_forground) {
#ifdef HX_WINDOWS
SDL_SysWMinfo info;
SDL_VERSION (&info.version);
SDL_GetWindowWMInfo(SDL_GL_GetCurrentWindow(), &info);
FLASHWINFO fi;
fi.cbSize = sizeof(FLASHWINFO);
fi.hwnd = info.info.win.window;
fi.dwFlags = val_bool (stop_on_forground) ? FLASHW_ALL | FLASHW_TIMERNOFG : FLASHW_ALL | FLASHW_TIMER;
fi.uCount = val_int (count);
fi.dwTimeout = val_int (speed);
FlashWindowEx(&fi);
#endif
return alloc_null ();
}
DEFINE_PRIM (lime_window_alert, 3);
}

View File

@@ -114,5 +114,9 @@ class FlashWindow {
}
public function alert (count:Int, speed:Int, stopOnForeground:Bool):Void {
}
}

View File

@@ -626,5 +626,9 @@ class HTML5Window {
}
public function alert (count:Int, speed:Int, stopOnForeground:Bool):Void {
}
}

View File

@@ -233,6 +233,16 @@ class NativeWindow {
}
public function alert (count:Int, speed:Int, stopOnForeground:Bool):Void {
if (handle != null) {
lime_window_alert (handle, count, speed, stopOnForeground);
}
}
@:cffi private static function lime_window_close (handle:Float):Void;
@:cffi private static function lime_window_create (application:Float, width:Int, height:Int, flags:Int, title:String):Float;
@@ -250,6 +260,7 @@ class NativeWindow {
@:cffi private static function lime_window_set_icon (handle:Float, buffer:Dynamic):Void;
@:cffi private static function lime_window_set_minimized (handle:Float, minimized:Bool):Bool;
@:cffi private static function lime_window_set_title (handle:Float, title:String):String;
@:cffi private static function lime_window_alert (handle:Float, count:Int, speed:Int, stopOnForeground:Bool):Void;
}

View File

@@ -269,6 +269,12 @@ class Window {
}
public function alert (count:Int, speed:Int, stopOnForeground:Bool):Void {
backend.alert (count, speed, stopOnForeground);
}
public function toString ():String {

View File

@@ -34,6 +34,7 @@ namespace lime {
virtual void SetIcon (ImageBuffer *imageBuffer) = 0;
virtual bool SetMinimized (bool minimized) = 0;
virtual const char* SetTitle (const char* title) = 0;
virtual void Alert (int count, int speed, bool stop_on_foreground) = 0;
Application* currentApplication;
int flags;

View File

@@ -1211,6 +1211,13 @@ namespace lime {
}
void lime_window_alert (double window, int count, int speed, bool stop_on_forground) {
Window* targetWindow = (Window*)(intptr_t)window;
targetWindow->Alert (count, speed, stop_on_forground);
}
DEFINE_PRIME1 (lime_application_create);
DEFINE_PRIME2v (lime_application_event_manager_register);
@@ -1313,6 +1320,7 @@ namespace lime {
DEFINE_PRIME2v (lime_window_set_icon);
DEFINE_PRIME2 (lime_window_set_minimized);
DEFINE_PRIME2 (lime_window_set_title);
DEFINE_PRIME4 (lime_window_alert);
}

View File

@@ -270,6 +270,22 @@ namespace lime {
}
void SDLWindow::Alert (int count, int speed, bool stop_on_foreground) {
SDL_SysWMinfo info;
SDL_VERSION (&info.version);
SDL_GetWindowWMInfo(sdlWindow, &info);
FLASHWINFO fi;
fi.cbSize = sizeof(FLASHWINFO);
fi.hwnd = info.info.win.window;
fi.dwFlags = stop_on_foreground ? FLASHW_ALL | FLASHW_TIMERNOFG : FLASHW_ALL | FLASHW_TIMER;
fi.uCount = count;
fi.dwTimeout = speed;
FlashWindowEx(&fi);
}
Window* CreateWindow (Application* application, int width, int height, int flags, const char* title) {

View File

@@ -32,6 +32,7 @@ namespace lime {
virtual void SetIcon (ImageBuffer *imageBuffer);
virtual bool SetMinimized (bool minimized);
virtual const char* SetTitle (const char* title);
virtual void Alert (int count, int speed, bool stop_on_foreground);
SDL_Window* sdlWindow;