[DEV] Add copy and past interface
This commit is contained in:
parent
21ad90fd15
commit
8a073acf76
@ -564,6 +564,15 @@ void ewol::Context::OS_ClipBoardArrive(enum ewol::context::clipBoard::clipboardL
|
||||
m_msgSystem.post(data);
|
||||
}
|
||||
|
||||
void ewol::Context::clipBoardGet(enum ewol::context::clipBoard::clipboardListe _clipboardID) {
|
||||
// just transmit an event , we have the data in the system
|
||||
OS_ClipBoardArrive(_clipboardID);
|
||||
}
|
||||
|
||||
void ewol::Context::clipBoardSet(enum ewol::context::clipBoard::clipboardListe _clipboardID) {
|
||||
// nothing to do, data is already copyed in the EWOL clipborad center
|
||||
}
|
||||
|
||||
bool ewol::Context::OS_Draw(bool _displayEveryTime) {
|
||||
int64_t currentTime = ewol::getTime();
|
||||
// this is to prevent the multiple display at the a high frequency ...
|
||||
|
@ -254,12 +254,12 @@ namespace ewol {
|
||||
* @brief Inform the Gui that we want to have a copy of the clipboard
|
||||
* @param[in] _clipboardID ID of the clipboard (STD/SELECTION) only apear here
|
||||
*/
|
||||
virtual void clipBoardGet(enum ewol::context::clipBoard::clipboardListe _clipboardID) { };
|
||||
virtual void clipBoardGet(enum ewol::context::clipBoard::clipboardListe _clipboardID);
|
||||
/**
|
||||
* @brief Inform the Gui that we are the new owner of the clipboard
|
||||
* @param[in] _clipboardID ID of the clipboard (STD/SELECTION) only apear here
|
||||
*/
|
||||
virtual void clipBoardSet(enum ewol::context::clipBoard::clipboardListe _clipboardID) { };
|
||||
virtual void clipBoardSet(enum ewol::context::clipBoard::clipboardListe _clipboardID);
|
||||
/**
|
||||
* @brief Call by the OS when a clipboard arrive to US (previously requested by a widget)
|
||||
* @param[in] Id of the clipboard
|
||||
|
@ -23,6 +23,7 @@ namespace MacOs {
|
||||
void setMouseMotion(int32_t _id, float _x, float _y);
|
||||
void setKeyboard(ewol::key::Special _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey);
|
||||
void setKeyboardMove(ewol::key::Special& _keyboardMode, enum ewol::key::keyboard _move, bool _isDown, bool _isAReapeateKey);
|
||||
void stopRequested();
|
||||
};
|
||||
|
||||
#endif
|
@ -11,6 +11,7 @@
|
||||
#include <ewol/ewol.h>
|
||||
#include <ewol/key/key.h>
|
||||
#include <ewol/context/commandLine.h>
|
||||
#include <ewol/context/clipBoard.h>
|
||||
#include <etk/types.h>
|
||||
#include <etk/os/FSNode.h>
|
||||
#include <ewol/widget/Manager.h>
|
||||
@ -31,6 +32,7 @@
|
||||
#include <mach/mach.h>
|
||||
#include <etk/etk.h>
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
int64_t ewol::getTime() {
|
||||
struct timespec now;
|
||||
@ -52,7 +54,7 @@ int64_t ewol::getTime() {
|
||||
|
||||
class MacOSInterface : public ewol::Context {
|
||||
private:
|
||||
ewol::key::Special m_guiKeyBoardMode;
|
||||
ewol::key::Special m_guiKeyBoardMode;
|
||||
public:
|
||||
MacOSInterface(ewol::context::Application* _application, int32_t _argc, const char* _argv[]) :
|
||||
ewol::Context(_application, _argc, _argv) {
|
||||
@ -78,12 +80,12 @@ class MacOSInterface : public ewol::Context {
|
||||
OS_SetMouseMotion(_id, vec2(_x, _y));
|
||||
}
|
||||
void MAC_SetKeyboard(ewol::key::Special _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey) {
|
||||
if (_unichar == u32char::Delete) {
|
||||
if (char32_t(_unichar) == u32char::Delete) {
|
||||
_unichar = u32char::Suppress;
|
||||
} else if (_unichar == u32char::Suppress) {
|
||||
} else if (char32_t(_unichar) == u32char::Suppress) {
|
||||
_unichar = u32char::Delete;
|
||||
}
|
||||
if (_unichar == u32char::CarrierReturn) {
|
||||
if (char32_t(_unichar) == u32char::CarrierReturn) {
|
||||
_unichar = u32char::Return;
|
||||
}
|
||||
//EWOL_DEBUG("key: " << _unichar << " up=" << !_isDown);
|
||||
@ -118,6 +120,40 @@ class MacOSInterface : public ewol::Context {
|
||||
std::string req = "open " + _url;
|
||||
system(req.c_str());
|
||||
}
|
||||
void MAC_Stop() {
|
||||
OS_Stop();
|
||||
}
|
||||
void stop() {
|
||||
mm_stopApplication();
|
||||
}
|
||||
void clipBoardGet(enum ewol::context::clipBoard::clipboardListe _clipboardID) {
|
||||
if (_clipboardID == ewol::context::clipBoard::clipboardStd) {
|
||||
NSPasteboard* myPasteboard = [NSPasteboard generalPasteboard];
|
||||
NSString* myString = [myPasteboard stringForType:NSPasteboardTypeString];
|
||||
std::string val([myString UTF8String]);
|
||||
ewol::context::clipBoard::setSystem(_clipboardID, val);
|
||||
if (val.size() != 0) {
|
||||
OS_ClipBoardArrive(_clipboardID);
|
||||
}
|
||||
} else {
|
||||
ewol::Context::clipBoardGet(_clipboardID);
|
||||
}
|
||||
}
|
||||
void clipBoardSet(enum ewol::context::clipBoard::clipboardListe _clipboardID) {
|
||||
if (_clipboardID == ewol::context::clipBoard::clipboardStd) {
|
||||
NSPasteboard* myPasteboard = [NSPasteboard generalPasteboard];
|
||||
[myPasteboard clearContents];
|
||||
//EWOL_ERROR(" copy: " << ewol::context::clipBoard::get(_clipboardID));
|
||||
NSString *text = [[NSString alloc] initWithUTF8String:ewol::context::clipBoard::get(_clipboardID).c_str()];
|
||||
BOOL err = [myPasteboard setString:text forType:NSPasteboardTypeString];
|
||||
if (err == FALSE) {
|
||||
EWOL_ERROR("copy to clipboard can not be done ...");
|
||||
}
|
||||
} else {
|
||||
ewol::Context::clipBoardSet(_clipboardID);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -168,6 +204,12 @@ void MacOs::setKeyboardMove(ewol::key::Special& _keyboardMode, enum ewol::key::k
|
||||
interface->MAC_SetKeyboardMove(_keyboardMode, _move, _isDown, _isAReapeateKey);
|
||||
}
|
||||
|
||||
void MacOs::stopRequested() {
|
||||
if (interface == nullptr) {
|
||||
return;
|
||||
}
|
||||
interface->MAC_Stop();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Main of the program
|
@ -14,7 +14,8 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
int mm_main(int argc, const char *argv[]);
|
||||
int mm_run(void);
|
||||
int mm_run();
|
||||
void mm_stopApplication();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -14,6 +14,8 @@
|
||||
#import <ewol/context/MacOs/AppDelegate.h>
|
||||
#import <ewol/debug.h>
|
||||
|
||||
id window = nil;
|
||||
|
||||
int mm_main(int argc, const char *argv[]) {
|
||||
[NSAutoreleasePool new];
|
||||
|
||||
@ -38,8 +40,13 @@ int mm_main(int argc, const char *argv[]) {
|
||||
// create the label to qui the application :
|
||||
id quitTitle = [@"Quit " stringByAppendingString:appName];
|
||||
// create the item to quit the appllication with META+q at shortCut
|
||||
/*
|
||||
id quitMenuItem = [ [ [NSMenuItem alloc] initWithTitle:quitTitle
|
||||
action:@selector(terminate:) keyEquivalent:@"q"] autorelease];
|
||||
*/
|
||||
id quitMenuItem = [ [ [NSMenuItem alloc] initWithTitle:quitTitle
|
||||
action:@selector(stop:) keyEquivalent:@"q"] autorelease];
|
||||
|
||||
// add the item to the menu:
|
||||
[appMenu addItem:quitMenuItem];
|
||||
// set the application menu to the main app menu ...
|
||||
@ -49,9 +56,9 @@ int mm_main(int argc, const char *argv[]) {
|
||||
// -- basic windows creation :
|
||||
// ----------------------- ----------------------------------------
|
||||
// create a windows of size 800/600
|
||||
id window = [ [ [EwolMainWindows alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
|
||||
styleMask:(NSTitledWindowMask|NSMiniaturizableWindowMask|NSClosableWindowMask) backing:NSBackingStoreBuffered defer:NO]
|
||||
autorelease];
|
||||
window = [ [ [EwolMainWindows alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
|
||||
styleMask:(NSTitledWindowMask|NSMiniaturizableWindowMask|NSClosableWindowMask) backing:NSBackingStoreBuffered defer:NO]
|
||||
autorelease];
|
||||
[window setAcceptsMouseMovedEvents:YES];
|
||||
//id window = [ [MacOsAppDelegate alloc] autorelease];
|
||||
|
||||
@ -93,3 +100,12 @@ int mm_run(void) {
|
||||
// return no error
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mm_stopApplication() {
|
||||
EWOL_INFO("NSApp terminate start.");
|
||||
[window closeRequestEwol];
|
||||
[NSApp stop:nil];
|
||||
//[NSApp terminate:nil];
|
||||
EWOL_INFO("NSApp terminate done");
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
// keyboard eevnts:
|
||||
- (void)keyDown:(NSEvent *)theEvent;
|
||||
- (void)flagsChanged:(NSEvent *)theEvent;
|
||||
|
||||
- (void)closeRequestEwol;
|
||||
@end
|
||||
|
||||
|
||||
|
@ -423,13 +423,21 @@ static ewol::key::Special guiKeyBoardMode;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)closeRequestEwol {
|
||||
EWOL_ERROR("closeRequestEwol: BEGIN");
|
||||
[super close];
|
||||
EWOL_ERROR("closeRequestEwol: END");
|
||||
}
|
||||
|
||||
- (void)close {
|
||||
EWOL_ERROR("close:");
|
||||
MacOs::stopRequested();
|
||||
// TODO: add check of close request ...
|
||||
[super close];
|
||||
[NSApp terminate:self];
|
||||
//[super close];
|
||||
//[NSApp terminate:self];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
|
@ -17,13 +17,13 @@
|
||||
|
||||
|
||||
/*
|
||||
note: la copy dans le :
|
||||
note: copy id data :
|
||||
0 : copy standard
|
||||
[1..9] : copy interne
|
||||
10 : bouton du milieux
|
||||
[1..9] : copy internal
|
||||
10 : middle button
|
||||
*/
|
||||
//!< Local copy of the clipboards
|
||||
static std::string mesCopy[ewol::context::clipBoard::clipboardCount];
|
||||
static std::string myCopy[ewol::context::clipBoard::clipboardCount];
|
||||
|
||||
static const char* clipboardDescriptionString[ewol::context::clipBoard::clipboardCount+1] = {
|
||||
"clipboard0",
|
||||
@ -54,7 +54,7 @@ std::ostream& ewol::operator <<(std::ostream& _os, const enum ewol::context::cli
|
||||
void ewol::context::clipBoard::init() {
|
||||
EWOL_INFO("Initialyse ClipBoards");
|
||||
for(int32_t i=0; i<ewol::context::clipBoard::clipboardCount; i++) {
|
||||
mesCopy[i].clear();
|
||||
myCopy[i].clear();
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ void ewol::context::clipBoard::init() {
|
||||
void ewol::context::clipBoard::unInit() {
|
||||
EWOL_INFO("Initialyse ClipBoards");
|
||||
for(int32_t i=0; i<ewol::context::clipBoard::clipboardCount; i++) {
|
||||
mesCopy[i].clear();
|
||||
myCopy[i].clear();
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,7 +110,7 @@ void ewol::context::clipBoard::setSystem(enum ewol::context::clipBoard::clipboar
|
||||
return;
|
||||
}
|
||||
// Copy datas ...
|
||||
mesCopy[_clipboardID] = _data;
|
||||
myCopy[_clipboardID] = _data;
|
||||
}
|
||||
|
||||
|
||||
@ -121,7 +121,7 @@ const std::string& ewol::context::clipBoard::get(enum ewol::context::clipBoard::
|
||||
return emptyString;
|
||||
}
|
||||
// Copy datas ...
|
||||
return mesCopy[_clipboardID];
|
||||
return myCopy[_clipboardID];
|
||||
}
|
||||
|
||||
|
||||
|
@ -291,4 +291,10 @@ std::shared_ptr<ewol::Object> ewol::widget::Windows::getSubObjectNamed(const std
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ewol::widget::Windows::sysOnKill() {
|
||||
if (onKill() == true) {
|
||||
getContext().stop();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ namespace ewol {
|
||||
void sysDraw();
|
||||
void sysOnShow() {};
|
||||
void sysOnHide() {};
|
||||
void sysOnKill() {};
|
||||
void sysOnKill();
|
||||
public:
|
||||
virtual void onShow() { };
|
||||
virtual void onHide() { };
|
||||
|
@ -59,7 +59,7 @@ def create(target):
|
||||
myModule.add_src_file('ewol/context/Android/Context.cpp')
|
||||
elif target.name=="MacOs":
|
||||
myModule.add_src_file([
|
||||
'ewol/context/MacOs/Context.cpp',
|
||||
'ewol/context/MacOs/Context.mm',
|
||||
'ewol/context/MacOs/Interface.mm',
|
||||
'ewol/context/MacOs/Windows.mm',
|
||||
'ewol/context/MacOs/OpenglView.mm',
|
||||
|
Loading…
x
Reference in New Issue
Block a user