* Add support for drag and drop of a picture into grafx2 windows
WARNING : it will not ask to save changes before. I believe it should work like the fileselector but could not find where to plug it there... git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1548 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
378555d943
commit
aaef37bd40
47
src/input.c
47
src/input.c
@ -21,6 +21,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
#include <SDL_syswm.h>
|
||||||
|
|
||||||
|
#ifdef __WIN32__
|
||||||
|
#include <windows.h>
|
||||||
|
#include <ShellApi.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "keyboard.h"
|
#include "keyboard.h"
|
||||||
@ -29,6 +35,7 @@
|
|||||||
#include "errors.h"
|
#include "errors.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
|
#include "loadsave.h"
|
||||||
|
|
||||||
#ifdef __VBCC__
|
#ifdef __VBCC__
|
||||||
#define __attribute__(x)
|
#define __attribute__(x)
|
||||||
@ -86,6 +93,19 @@ short Joybutton_left_click=0; // Button number that serves as left click
|
|||||||
short Joybutton_right_click=0; // Button number that serves as right-click
|
short Joybutton_right_click=0; // Button number that serves as right-click
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
void AcceptDND(void)
|
||||||
|
{
|
||||||
|
#ifdef __WIN32__
|
||||||
|
SDL_SysWMinfo wminfo;
|
||||||
|
SDL_VERSION(&wminfo.version);
|
||||||
|
SDL_GetWMInfo(&wminfo);
|
||||||
|
HWND hwnd = wminfo.window;
|
||||||
|
DragAcceptFiles(hwnd,TRUE);
|
||||||
|
SDL_EventState (SDL_SYSWMEVENT,SDL_ENABLE );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
int Has_shortcut(word function)
|
int Has_shortcut(word function)
|
||||||
{
|
{
|
||||||
if (function == 0xFFFF)
|
if (function == 0xFFFF)
|
||||||
@ -718,6 +738,33 @@ int Get_input(void)
|
|||||||
#endif
|
#endif
|
||||||
// End of Joystick handling
|
// End of Joystick handling
|
||||||
|
|
||||||
|
case SDL_SYSWMEVENT:
|
||||||
|
#ifdef __WIN32__
|
||||||
|
if(event.syswm.msg->msg == WM_DROPFILES) {
|
||||||
|
int fileCount;
|
||||||
|
HDROP hdrop = (HDROP)(event.syswm.msg->wParam);
|
||||||
|
if((fileCount = DragQueryFile(hdrop,(UINT)-1,(LPTSTR) NULL ,(UINT) 0)) > 0) {
|
||||||
|
char buf[MAX_PATH];
|
||||||
|
T_IO_Context context;
|
||||||
|
char* flimit;
|
||||||
|
|
||||||
|
DragQueryFile(hdrop,0 ,(LPTSTR) buf ,(UINT) MAX_PATH);
|
||||||
|
flimit = Find_last_slash(buf);
|
||||||
|
*(flimit++) = '\0';
|
||||||
|
|
||||||
|
// TODO : check if there are unsaved changes first !
|
||||||
|
|
||||||
|
Init_context_layered_image(&context, flimit, buf);
|
||||||
|
Load_image(&context);
|
||||||
|
Destroy_context(&context);
|
||||||
|
Redraw_layered_image();
|
||||||
|
End_of_modification();
|
||||||
|
Display_all_screen();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// DEBUG("Unhandled SDL event number : ",event.type);
|
// DEBUG("Unhandled SDL event number : ",event.type);
|
||||||
break;
|
break;
|
||||||
|
|||||||
19
src/main.c
19
src/main.c
@ -85,6 +85,15 @@
|
|||||||
extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);
|
extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int test_colorcycling(void* useless)
|
||||||
|
{
|
||||||
|
byte r = 0;
|
||||||
|
while(1) {
|
||||||
|
SDL_Delay(50);
|
||||||
|
Set_color(0,++r,0,0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//--- Affichage de la syntaxe, et de la liste des modes vidéos disponibles ---
|
//--- Affichage de la syntaxe, et de la liste des modes vidéos disponibles ---
|
||||||
void Display_syntax(void)
|
void Display_syntax(void)
|
||||||
{
|
{
|
||||||
@ -818,6 +827,16 @@ int Init_program(int argc,char * argv[])
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
// Color cycling test
|
||||||
|
{
|
||||||
|
SDL_Thread* t = SDL_CreateThread(test_colorcycling, NULL);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
AcceptDND();
|
||||||
|
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user