Compare commits
26 Commits
Author | SHA1 | Date | |
---|---|---|---|
188bd69f06 | |||
0ab5588a93 | |||
df3c97b17e | |||
03cb9d7cbd | |||
c8b9b37c8e | |||
75f56d52d4 | |||
f6f8679b76 | |||
ae113a8a2f | |||
45f37a0c4b | |||
02e7de2397 | |||
ea344225e3 | |||
40d6de087b | |||
7bf7668686 | |||
e2e0fc25d3 | |||
9f2718f97a | |||
a943ddd4f7 | |||
fced6df123 | |||
a4d314723d | |||
f716055c40 | |||
0a11251ccc | |||
0d0afec709 | |||
1894f56217 | |||
4e7491e5fc | |||
dc73285cb7 | |||
5d7870248d | |||
4b16540744 |
@@ -18,4 +18,5 @@
|
||||
</activity>
|
||||
</application>
|
||||
<uses-sdk android:minSdkVersion="4" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
</manifest>
|
||||
|
@@ -1,4 +1,14 @@
|
||||
# action a faire (ordonner par r<>vision) :
|
||||
|
||||
dans la liste des truc important a refaire
|
||||
retirer tout les singleton ==> passer par des namespace ==> fonctionnera mieux ...
|
||||
finir de netoyer la classe widget
|
||||
netoyer les classe text ...
|
||||
mettre en pla ce le repositionnement automatique quand on change de buffer
|
||||
Curseur au bon endroit
|
||||
|
||||
|
||||
|
||||
* 0.2.X :
|
||||
- gui : Amelioration du full-screen et du display de base (sans l'entete de la fenetre)
|
||||
- gui : Mise en place d'un display ligne par ligne
|
||||
|
@@ -20,7 +20,9 @@ LOCAL_CFLAGS := -D__PLATFORM__Android \
|
||||
-DEWOL_USE_FREE_TYPE \
|
||||
-DETK_DEBUG_LEVEL=3 \
|
||||
-DEDN_DEBUG_LEVEL=3 \
|
||||
-DDATA_IN_APK
|
||||
-DDATA_IN_APK \
|
||||
-frtti
|
||||
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
|
@@ -15,7 +15,8 @@ LOCAL_SRC_FILES := $(FILE_LIST)
|
||||
|
||||
LOCAL_LDLIBS :=
|
||||
|
||||
LOCAL_CFLAGS := -DEWOL_USE_FREE_TYPE \
|
||||
LOCAL_CFLAGS := -D__PLATFORM__Linux \
|
||||
-DEWOL_USE_FREE_TYPE \
|
||||
-DEDN_DEBUG_LEVEL=3
|
||||
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
@@ -27,7 +27,7 @@
|
||||
#include <tools_globals.h>
|
||||
#include <Buffer.h>
|
||||
#include <BufferManager.h>
|
||||
#include <ewol/WidgetMessageMultiCast.h>
|
||||
#include <ewol/EObject.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Buffer"
|
||||
@@ -95,7 +95,8 @@ void Buffer::SetModify(bool status)
|
||||
if (status != m_fileModify) {
|
||||
m_fileModify = status;
|
||||
// TODO : Remove from here
|
||||
ewol::widgetMessageMultiCast::Send(-1, ednMsgBufferState, "Modify");
|
||||
etk::UString data = "Modify";
|
||||
ewol::EObjectMessageMultiCast::AnonymousSend(ednMsgBufferState, data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,10 +149,10 @@ void Buffer::SetLineDisplay(uint32_t lineNumber)
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
int32_t Buffer::Display(ewol::OObject2DTextColored* OOTextNormal,
|
||||
ewol::OObject2DTextColored* OOTextBold,
|
||||
ewol::OObject2DTextColored* OOTextItalic,
|
||||
ewol::OObject2DTextColored* OOTextBoldItalic, ewol::OObject2DColored* OOColored,
|
||||
int32_t Buffer::Display(ewol::OObject2DTextColored& OOTextNormal,
|
||||
ewol::OObject2DTextColored& OOTextBold,
|
||||
ewol::OObject2DTextColored& OOTextItalic,
|
||||
ewol::OObject2DTextColored& OOTextBoldItalic, ewol::OObject2DColored& OOColored,
|
||||
int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY)
|
||||
{
|
||||
return ERR_NONE;
|
||||
@@ -167,7 +168,7 @@ int32_t Buffer::Display(ewol::OObject2DTextColored* OOTextNormal,
|
||||
* @todo : Set the move up and DOWN...
|
||||
*
|
||||
*/
|
||||
void Buffer::MouseSelectFromCursorTo(int32_t width, int32_t height)
|
||||
void Buffer::MouseSelectFromCursorTo(int32_t fontId, int32_t width, int32_t height)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
@@ -182,7 +183,7 @@ void Buffer::MouseSelectFromCursorTo(int32_t width, int32_t height)
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void Buffer::MouseEvent(int32_t width, int32_t height)
|
||||
void Buffer::MouseEvent(int32_t fontId, int32_t width, int32_t height)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
@@ -214,49 +215,6 @@ void Buffer::MouseEventTriple(void)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void Buffer::ScrollDown(void)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void Buffer::ScrollUp(void)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void Buffer::ForceReDraw(bool allElement)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Buffer::cursorMove(ewol::eventKbMoveType_te moveTypeEvent)
|
||||
{
|
||||
// nothing to do
|
||||
|
@@ -82,20 +82,17 @@ class Buffer {
|
||||
virtual void GetInfo(infoStatBuffer_ts &infoToUpdate);
|
||||
virtual void SetLineDisplay(uint32_t lineNumber);
|
||||
|
||||
virtual int32_t Display(ewol::OObject2DTextColored* OOTextNormal,
|
||||
ewol::OObject2DTextColored* OOTextBold,
|
||||
ewol::OObject2DTextColored* OOTextItalic,
|
||||
ewol::OObject2DTextColored* OOTextBoldItalic,
|
||||
ewol::OObject2DColored* OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY);
|
||||
virtual void ForceReDraw(bool allElement);
|
||||
virtual int32_t Display(ewol::OObject2DTextColored& OOTextNormal,
|
||||
ewol::OObject2DTextColored& OOTextBold,
|
||||
ewol::OObject2DTextColored& OOTextItalic,
|
||||
ewol::OObject2DTextColored& OOTextBoldItalic,
|
||||
ewol::OObject2DColored& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY);
|
||||
virtual void AddChar(uniChar_t unicodeData);
|
||||
virtual void cursorMove(ewol::eventKbMoveType_te moveTypeEvent);
|
||||
virtual void MouseSelectFromCursorTo(int32_t width, int32_t height);
|
||||
virtual void MouseEvent(int32_t width, int32_t height);
|
||||
virtual void MouseSelectFromCursorTo(int32_t fontId, int32_t width, int32_t height);
|
||||
virtual void MouseEvent(int32_t fontId, int32_t width, int32_t height);
|
||||
virtual void MouseEventDouble(void);
|
||||
virtual void MouseEventTriple(void);
|
||||
virtual void ScrollDown(void);
|
||||
virtual void ScrollUp(void);
|
||||
virtual void RemoveLine(void);
|
||||
virtual void SelectAll(void);
|
||||
virtual void SelectNone(void);
|
||||
|
@@ -67,48 +67,32 @@ BufferEmpty::~BufferEmpty(void)
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
int32_t BufferEmpty::Display(ewol::OObject2DTextColored* OOTextNormal,
|
||||
ewol::OObject2DTextColored* OOTextBold,
|
||||
ewol::OObject2DTextColored* OOTextItalic,
|
||||
ewol::OObject2DTextColored* OOTextBoldItalic,
|
||||
ewol::OObject2DColored* OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY)
|
||||
int32_t BufferEmpty::Display(ewol::OObject2DTextColored& OOTextNormal,
|
||||
ewol::OObject2DTextColored& OOTextBold,
|
||||
ewol::OObject2DTextColored& OOTextItalic,
|
||||
ewol::OObject2DTextColored& OOTextBoldItalic,
|
||||
ewol::OObject2DColored& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY)
|
||||
{
|
||||
ColorizeManager * myColorManager = ColorizeManager::getInstance();
|
||||
// Get color :
|
||||
Colorize *myColor = NULL;
|
||||
//drawer.Flush();
|
||||
|
||||
|
||||
if (NULL == OOTextNormal) {
|
||||
EDN_ERROR("Input VALUE is NULL");
|
||||
return ERR_FAIL;
|
||||
}
|
||||
if (NULL == OOColored) {
|
||||
EDN_ERROR("Input VALUE is NULL");
|
||||
return ERR_FAIL;
|
||||
}
|
||||
int32_t fontId = OOTextNormal->GetFontID();
|
||||
int32_t fontId = OOTextNormal.GetFontID();
|
||||
int32_t letterHeight = ewol::GetHeight(fontId);
|
||||
|
||||
coord2D_ts textPos;
|
||||
textPos.x = 20;
|
||||
textPos.y = 20;
|
||||
clipping_ts drawClipping;
|
||||
drawClipping.x = 0;
|
||||
drawClipping.y = 0;
|
||||
drawClipping.w = sizeX;
|
||||
drawClipping.h = sizeY;
|
||||
|
||||
myColor = myColorManager->Get("normal");
|
||||
OOTextNormal->SetColor(myColor->GetFG());
|
||||
myColor = ColorizeManager::Get("normal");
|
||||
OOTextBold.SetColor(myColor->GetFG());
|
||||
etk::UString tmpDisplay = "edn - Editeur De N'ours";
|
||||
OOTextBold->Text(textPos, drawClipping, tmpDisplay);
|
||||
OOTextBold.Text(textPos, tmpDisplay);
|
||||
|
||||
myColor = myColorManager->Get("commentDoxygen");
|
||||
OOTextNormal->SetColor(myColor->GetFG());
|
||||
myColor = ColorizeManager::Get("commentDoxygen");
|
||||
OOTextNormal.SetColor(myColor->GetFG());
|
||||
textPos.y = (int32_t)(textPos.y + letterHeight*1.30);
|
||||
tmpDisplay = "No Buffer Availlable to display";
|
||||
OOTextNormal->Text(textPos, drawClipping, tmpDisplay);
|
||||
OOTextNormal.Text(textPos, tmpDisplay);
|
||||
|
||||
|
||||
color_ts bgColor; //!< Text color
|
||||
@@ -116,8 +100,8 @@ int32_t BufferEmpty::Display(ewol::OObject2DTextColored* OOTextNormal,
|
||||
bgColor.green = 1.0;
|
||||
bgColor.blue = 1.0;
|
||||
bgColor.alpha = 1.0;
|
||||
OOColored->SetColor(bgColor);
|
||||
OOColored->Rectangle( 0, 0, sizeX, sizeY);
|
||||
OOColored.SetColor(bgColor);
|
||||
OOColored.Rectangle( 0, 0, sizeX, sizeY);
|
||||
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
@@ -32,11 +32,11 @@ class BufferEmpty : public Buffer {
|
||||
public:
|
||||
BufferEmpty(void);
|
||||
virtual ~BufferEmpty(void);
|
||||
int32_t Display(ewol::OObject2DTextColored* OOTextNormal,
|
||||
ewol::OObject2DTextColored* OOTextBold,
|
||||
ewol::OObject2DTextColored* OOTextItalic,
|
||||
ewol::OObject2DTextColored* OOTextBoldItalic,
|
||||
ewol::OObject2DColored* OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY);
|
||||
int32_t Display(ewol::OObject2DTextColored& OOTextNormal,
|
||||
ewol::OObject2DTextColored& OOTextBold,
|
||||
ewol::OObject2DTextColored& OOTextItalic,
|
||||
ewol::OObject2DTextColored& OOTextBoldItalic,
|
||||
ewol::OObject2DColored& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY);
|
||||
|
||||
};
|
||||
|
||||
|
@@ -27,10 +27,58 @@
|
||||
#include <tools_debug.h>
|
||||
#include <tools_globals.h>
|
||||
#include <BufferManager.h>
|
||||
#include <ewol/WidgetMessageMultiCast.h>
|
||||
#include <ewol/EObject.h>
|
||||
#include <ewol/EObjectManager.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "BufferManager"
|
||||
#define __class__ "classBufferManager"
|
||||
|
||||
class classBufferManager: public ewol::EObject
|
||||
{
|
||||
public:
|
||||
// Constructeur
|
||||
classBufferManager(void);
|
||||
~classBufferManager(void);
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Receive a message from an other EObject with a specific eventId and data
|
||||
* @param[in] CallerObject Pointer on the EObject that information came from
|
||||
* @param[in] eventId Message registered by this class
|
||||
* @param[in] data Data registered by this class
|
||||
* @return ---
|
||||
*/
|
||||
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
|
||||
private:
|
||||
// return the ID of the buffer allocated
|
||||
// create a buffer with no element
|
||||
int32_t Create(void);
|
||||
// open curent filename
|
||||
int32_t Open(etk::File &myFile);
|
||||
bool Remove(int32_t BufferID);
|
||||
public:
|
||||
int32_t GetSelected(void) { return m_idSelected;};
|
||||
//void SetSelected(int32_t id) {m_idSelected = id;};
|
||||
Buffer * Get(int32_t BufferID);
|
||||
bool Exist(int32_t BufferID);
|
||||
bool Exist(etk::File &myFile);
|
||||
int32_t GetId(etk::File &myFile);
|
||||
// return the number of buffer (open in the past) if 5 buffer open and 4 close ==> return 5
|
||||
uint32_t Size(void);
|
||||
uint32_t SizeOpen(void);
|
||||
int32_t WitchBuffer(int32_t iEmeElement);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
etk::VectorType<Buffer*> listBuffer; //!< element List of the char Elements
|
||||
|
||||
void RemoveAll(void); //!< remove all buffer
|
||||
int32_t m_idSelected;
|
||||
Buffer * BufferNotExiste; //!< When an error arrive in get buffer we return the Error buffer (not writable)
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Constructeur
|
||||
/**
|
||||
@@ -41,25 +89,17 @@
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
BufferManager::BufferManager(void)
|
||||
classBufferManager::classBufferManager(void)
|
||||
{
|
||||
// nothing to do ...
|
||||
BufferNotExiste = new BufferEmpty();
|
||||
m_idSelected = -1;
|
||||
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgGuiNew);
|
||||
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgOpenFile);
|
||||
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgGuiClose);
|
||||
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgGuiSave);
|
||||
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgCodeViewSelectedId);
|
||||
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgBufferId);
|
||||
|
||||
/*
|
||||
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgBufferManagerNewFile);
|
||||
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgBufferManagerSaveAll);
|
||||
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgBufferManagerCloseAll);
|
||||
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgBufferManagerClose);
|
||||
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgBufferManagerSave);
|
||||
*/
|
||||
RegisterMultiCast(ednMsgGuiNew);
|
||||
RegisterMultiCast(ednMsgOpenFile);
|
||||
RegisterMultiCast(ednMsgGuiClose);
|
||||
RegisterMultiCast(ednMsgGuiSave);
|
||||
RegisterMultiCast(ednMsgCodeViewSelectedId);
|
||||
RegisterMultiCast(ednMsgBufferId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,28 +110,37 @@ BufferManager::BufferManager(void)
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
BufferManager::~BufferManager(void)
|
||||
classBufferManager::~classBufferManager(void)
|
||||
{
|
||||
//clean All Buffer
|
||||
EDN_INFO("~BufferManager::RemoveAll();");
|
||||
EDN_INFO("~classBufferManager::RemoveAll();");
|
||||
RemoveAll();
|
||||
// clear The list of Buffer
|
||||
EDN_INFO("~BufferManager::listBuffer.Clear();");
|
||||
EDN_INFO("~classBufferManager::listBuffer.Clear();");
|
||||
listBuffer.Clear();
|
||||
EDN_INFO("~BufferManager::delete(BufferNotExiste);");
|
||||
EDN_INFO("~classBufferManager::delete(BufferNotExiste);");
|
||||
delete(BufferNotExiste);
|
||||
}
|
||||
|
||||
|
||||
bool BufferManager::OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * data, etkFloat_t x, etkFloat_t y)
|
||||
/**
|
||||
* @brief Receive a message from an other EObject with a specific eventId and data
|
||||
* @param[in] CallerObject Pointer on the EObject that information came from
|
||||
* @param[in] eventId Message registered by this class
|
||||
* @param[in] data Data registered by this class
|
||||
* @return ---
|
||||
*/
|
||||
void classBufferManager::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
|
||||
{
|
||||
if (generateEventId == ednMsgBufferId) {
|
||||
ewol::EObject::OnReceiveMessage(CallerObject, eventId, data);
|
||||
|
||||
if (eventId == ednMsgBufferId) {
|
||||
// select a new buffer ID :
|
||||
if (NULL == data) {
|
||||
EDN_ERROR("Request select buffer ID = NULL ????");
|
||||
if (data == "") {
|
||||
EDN_ERROR("Request select buffer ID = \"\" ");
|
||||
} else {
|
||||
int32_t newID = -1;
|
||||
sscanf(data, "%d", &newID);
|
||||
sscanf(data.Utf8Data(), "%d", &newID);
|
||||
if(true == Exist(newID)) {
|
||||
m_idSelected = newID;
|
||||
} else {
|
||||
@@ -99,67 +148,67 @@ bool BufferManager::OnEventAreaExternal(int32_t widgetID, const char * generateE
|
||||
EDN_ERROR("Request a non existant ID : " << newID << " reset to -1...");
|
||||
}
|
||||
}
|
||||
} else if (generateEventId == ednMsgGuiNew) {
|
||||
} else if (eventId == ednMsgGuiNew) {
|
||||
int32_t newOne = Create();
|
||||
if (-1 != newOne) {
|
||||
m_idSelected = newOne;
|
||||
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferId, m_idSelected);
|
||||
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferListChange);
|
||||
SendMultiCast(ednMsgBufferId, m_idSelected);
|
||||
SendMultiCast(ednMsgBufferListChange);
|
||||
}
|
||||
} else if (generateEventId == ednMsgOpenFile) {
|
||||
if (NULL != data) {
|
||||
} else if (eventId == ednMsgOpenFile) {
|
||||
if (data != "" ) {
|
||||
etk::File myFile(data, etk::FILE_TYPE_DIRECT);
|
||||
int32_t newOne = Open(myFile);
|
||||
if (-1 != newOne) {
|
||||
m_idSelected = newOne;
|
||||
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferId, m_idSelected);
|
||||
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferListChange);
|
||||
SendMultiCast(ednMsgBufferId, m_idSelected);
|
||||
SendMultiCast(ednMsgBufferListChange);
|
||||
}
|
||||
}
|
||||
} else if (generateEventId == ednMsgGuiSave) {
|
||||
if (NULL == data) {
|
||||
} else if (eventId == ednMsgGuiSave) {
|
||||
if (data == "") {
|
||||
EDN_ERROR("Null data for close file ... ");
|
||||
} else {
|
||||
if (0 == strcmp(data , "current")) {
|
||||
if (data == "current") {
|
||||
// Check buffer existence
|
||||
if(true == Exist(m_idSelected)) {
|
||||
// If no name ==> request a Gui display ...
|
||||
if (Get(m_idSelected)->HaveName() == false) {
|
||||
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgGuiSaveAs, "current");
|
||||
SendMultiCast(ednMsgGuiSaveAs, "current");
|
||||
} else {
|
||||
Get(m_idSelected)->Save();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int32_t newId;
|
||||
sscanf(data, "%d", &newId);
|
||||
sscanf(data.Utf8Data(), "%d", &newId);
|
||||
if (false == Exist(newId)) {
|
||||
EDN_ERROR("Request a save As with a non existant ID=" << newId);
|
||||
} else {
|
||||
// If no name ==> request a Gui display ...
|
||||
if (Get(newId)->HaveName() == false) {
|
||||
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgGuiSaveAs, newId);
|
||||
SendMultiCast(ednMsgGuiSaveAs, newId);
|
||||
} else {
|
||||
Get(m_idSelected)->Save();
|
||||
}
|
||||
}
|
||||
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferState, "saved");
|
||||
SendMultiCast(ednMsgBufferState, "saved");
|
||||
}
|
||||
}
|
||||
} else if (generateEventId == ednMsgGuiClose) {
|
||||
if (NULL == data) {
|
||||
} else if (eventId == ednMsgGuiClose) {
|
||||
if (data == "") {
|
||||
EDN_ERROR("Null data for close file ... ");
|
||||
} else {
|
||||
if (0 == strcmp(data , "All")) {
|
||||
if (data == "All") {
|
||||
|
||||
} else {
|
||||
int32_t closeID = -1;
|
||||
if (0 == strcmp(data , "current")) {
|
||||
if (data == "current") {
|
||||
closeID = m_idSelected;
|
||||
EDN_DEBUG("Close specific buffer ID" << closeID);
|
||||
} else {
|
||||
// close specific buffer ...
|
||||
sscanf(data, "%d", &closeID);
|
||||
sscanf(data.Utf8Data(), "%d", &closeID);
|
||||
EDN_DEBUG("Close specific buffer ID="<< closeID);
|
||||
}
|
||||
if(true == Exist(closeID)) {
|
||||
@@ -183,32 +232,32 @@ bool BufferManager::OnEventAreaExternal(int32_t widgetID, const char * generateE
|
||||
}
|
||||
}
|
||||
// set it to the currect display
|
||||
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferId, destBuffer);
|
||||
SendMultiCast(ednMsgBufferId, destBuffer);
|
||||
m_idSelected = destBuffer;
|
||||
}
|
||||
// Remove requested buffer
|
||||
Remove(closeID);
|
||||
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferListChange);
|
||||
SendMultiCast(ednMsgBufferListChange);
|
||||
} else {
|
||||
EDN_ERROR("Request Close of a non existant ID : " << closeID);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (generateEventId == ednMsgCodeViewSelectedId) {
|
||||
} else if (eventId == ednMsgCodeViewSelectedId) {
|
||||
//Change the selected buffer
|
||||
if (NULL == data) {
|
||||
if (data == "") {
|
||||
EDN_ERROR("Null data for changing buffer ID file ... ");
|
||||
} else {
|
||||
int32_t newId;
|
||||
sscanf(data, "%d", &newId);
|
||||
sscanf(data.Utf8Data(), "%d", &newId);
|
||||
if (true == Exist(newId)) {
|
||||
m_idSelected = newId;
|
||||
} else {
|
||||
EDN_ERROR("code biew request the selection of an non -existant buffer ==> reset to -1");
|
||||
m_idSelected = -1;
|
||||
}
|
||||
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferId, m_idSelected);
|
||||
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferListChange);
|
||||
SendMultiCast(ednMsgBufferId, m_idSelected);
|
||||
SendMultiCast(ednMsgBufferListChange);
|
||||
}
|
||||
}
|
||||
/*
|
||||
@@ -226,7 +275,6 @@ bool BufferManager::OnEventAreaExternal(int32_t widgetID, const char * generateE
|
||||
break;
|
||||
}
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -243,13 +291,13 @@ bool BufferManager::OnEventAreaExternal(int32_t widgetID, const char * generateE
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void BufferManager::RemoveAll(void)
|
||||
void classBufferManager::RemoveAll(void)
|
||||
{
|
||||
int32_t i;
|
||||
for (i=0; i<listBuffer.Size(); i++) {
|
||||
Remove(i);
|
||||
}
|
||||
ewol::widgetMessageMultiCast::Send(-1, ednMsgGuiClose, "All");
|
||||
SendMultiCast(ednMsgGuiClose, "All");
|
||||
}
|
||||
|
||||
|
||||
@@ -262,7 +310,7 @@ void BufferManager::RemoveAll(void)
|
||||
* @return The ID of the curent buffer where the file is loaded
|
||||
*
|
||||
*/
|
||||
int32_t BufferManager::Create(void)
|
||||
int32_t classBufferManager::Create(void)
|
||||
{
|
||||
// allocate a new Buffer
|
||||
Buffer *myBuffer = new BufferText();
|
||||
@@ -283,7 +331,7 @@ int32_t BufferManager::Create(void)
|
||||
* @todo : check if this file is not curently open and return the old ID
|
||||
*
|
||||
*/
|
||||
int32_t BufferManager::Open(etk::File &myFile)
|
||||
int32_t classBufferManager::Open(etk::File &myFile)
|
||||
{
|
||||
// TODO : Check here if the file is already open ==> and display it if needed
|
||||
// allocate a new Buffer
|
||||
@@ -295,7 +343,7 @@ int32_t BufferManager::Open(etk::File &myFile)
|
||||
|
||||
|
||||
|
||||
Buffer * BufferManager::Get(int32_t BufferID)
|
||||
Buffer * classBufferManager::Get(int32_t BufferID)
|
||||
{
|
||||
// possible special case : -1;
|
||||
if (-1 >= BufferID) {
|
||||
@@ -316,7 +364,7 @@ Buffer * BufferManager::Get(int32_t BufferID)
|
||||
}
|
||||
|
||||
|
||||
bool BufferManager::Exist(int32_t BufferID)
|
||||
bool classBufferManager::Exist(int32_t BufferID)
|
||||
{
|
||||
if (-1 >= BufferID) {
|
||||
return false;
|
||||
@@ -332,7 +380,7 @@ bool BufferManager::Exist(int32_t BufferID)
|
||||
}
|
||||
|
||||
|
||||
bool BufferManager::Exist(etk::File &myFile )
|
||||
bool classBufferManager::Exist(etk::File &myFile )
|
||||
{
|
||||
if (-1 == GetId(myFile)) {
|
||||
return false;
|
||||
@@ -341,7 +389,7 @@ bool BufferManager::Exist(etk::File &myFile )
|
||||
}
|
||||
|
||||
|
||||
int32_t BufferManager::GetId(etk::File &myFile)
|
||||
int32_t classBufferManager::GetId(etk::File &myFile)
|
||||
{
|
||||
int32_t iii;
|
||||
// check if the Buffer existed
|
||||
@@ -358,13 +406,13 @@ int32_t BufferManager::GetId(etk::File &myFile)
|
||||
|
||||
|
||||
// return the number of buffer (open in the past) if 5 buffer open and 4 close ==> return 5
|
||||
uint32_t BufferManager::Size(void)
|
||||
uint32_t classBufferManager::Size(void)
|
||||
{
|
||||
return listBuffer.Size();
|
||||
}
|
||||
|
||||
// nb of opens file Now ...
|
||||
uint32_t BufferManager::SizeOpen(void)
|
||||
uint32_t classBufferManager::SizeOpen(void)
|
||||
{
|
||||
uint32_t jjj = 0;
|
||||
// check if the Buffer existed
|
||||
@@ -385,7 +433,7 @@ uint32_t BufferManager::SizeOpen(void)
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
bool BufferManager::Remove(int32_t BufferID)
|
||||
bool classBufferManager::Remove(int32_t BufferID)
|
||||
{
|
||||
if (-1 >= BufferID) {
|
||||
return false;
|
||||
@@ -403,7 +451,9 @@ bool BufferManager::Remove(int32_t BufferID)
|
||||
// Delete the Buffer
|
||||
delete( listBuffer[BufferID] );
|
||||
listBuffer[BufferID] = NULL;
|
||||
/*
|
||||
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferListChange);
|
||||
*/
|
||||
return true;
|
||||
} else {
|
||||
EDN_INFO("non existing Buffer " << BufferID);
|
||||
@@ -423,7 +473,7 @@ bool BufferManager::Remove(int32_t BufferID)
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
int32_t BufferManager::WitchBuffer(int32_t iEmeElement)
|
||||
int32_t classBufferManager::WitchBuffer(int32_t iEmeElement)
|
||||
{
|
||||
int32_t i;
|
||||
for (i=0; i<listBuffer.Size(); i++) {
|
||||
@@ -439,7 +489,105 @@ int32_t BufferManager::WitchBuffer(int32_t iEmeElement)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Namespace part :
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static classBufferManager * localManager = NULL;
|
||||
|
||||
void BufferManager::Init(void)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
EWOL_ERROR("classBufferManager ==> already exist, just unlink the previous ...");
|
||||
localManager = NULL;
|
||||
}
|
||||
localManager = new classBufferManager();
|
||||
|
||||
if (NULL == localManager) {
|
||||
EWOL_CRITICAL("Allocation of classBufferManager not done ...");
|
||||
}
|
||||
}
|
||||
|
||||
void BufferManager::UnInit(void)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
|
||||
return;
|
||||
}
|
||||
ewol::EObjectManager::MarkToRemoved(localManager);
|
||||
localManager = NULL;
|
||||
}
|
||||
|
||||
int32_t BufferManager::GetSelected(void)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
|
||||
return -1;
|
||||
}
|
||||
return localManager->GetSelected();
|
||||
}
|
||||
|
||||
Buffer * BufferManager::Get(int32_t BufferID)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
|
||||
return NULL;
|
||||
}
|
||||
return localManager->Get(BufferID);
|
||||
}
|
||||
|
||||
bool BufferManager::Exist(int32_t BufferID)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
|
||||
return false;
|
||||
}
|
||||
return localManager->Exist(BufferID);
|
||||
}
|
||||
|
||||
bool BufferManager::Exist(etk::File &myFile)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
|
||||
return false;
|
||||
}
|
||||
return localManager->Exist(myFile);
|
||||
}
|
||||
|
||||
int32_t BufferManager::GetId(etk::File &myFile)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
|
||||
return -1;
|
||||
}
|
||||
return localManager->GetId(myFile);
|
||||
}
|
||||
|
||||
uint32_t BufferManager::Size(void)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
|
||||
return 0;
|
||||
}
|
||||
return localManager->Size();
|
||||
}
|
||||
|
||||
uint32_t BufferManager::SizeOpen(void)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
|
||||
return 0;
|
||||
}
|
||||
return localManager->SizeOpen();
|
||||
}
|
||||
|
||||
int32_t BufferManager::WitchBuffer(int32_t iEmeElement)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
EWOL_ERROR("classBufferManager ==> request UnInit, but does not exist ...");
|
||||
return -1;
|
||||
}
|
||||
return localManager->WitchBuffer(iEmeElement);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -29,48 +29,22 @@
|
||||
#include <Buffer.h>
|
||||
#include <BufferText.h>
|
||||
#include <BufferEmpty.h>
|
||||
#include <etk/Singleton.h>
|
||||
#include <MsgBroadcast.h>
|
||||
#include <ewol/Widget.h>
|
||||
|
||||
class BufferManager: public etk::Singleton<BufferManager>, public ewol::Widget
|
||||
namespace BufferManager
|
||||
{
|
||||
friend class etk::Singleton<BufferManager>;
|
||||
// specific for sigleton system...
|
||||
private:
|
||||
// Constructeur
|
||||
BufferManager(void);
|
||||
~BufferManager(void);
|
||||
|
||||
public:
|
||||
bool OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, etkFloat_t x, etkFloat_t y);
|
||||
private:
|
||||
// return the ID of the buffer allocated
|
||||
// create a buffer with no element
|
||||
int32_t Create(void);
|
||||
// open curent filename
|
||||
int32_t Open(etk::File &myFile);
|
||||
bool Remove(int32_t BufferID);
|
||||
public:
|
||||
int32_t GetSelected(void) { return m_idSelected;};
|
||||
//void SetSelected(int32_t id) {m_idSelected = id;};
|
||||
Buffer * Get(int32_t BufferID);
|
||||
bool Exist(int32_t BufferID);
|
||||
bool Exist(etk::File &myFile);
|
||||
int32_t GetId(etk::File &myFile);
|
||||
// return the number of buffer (open in the past) if 5 buffer open and 4 close ==> return 5
|
||||
uint32_t Size(void);
|
||||
uint32_t SizeOpen(void);
|
||||
int32_t WitchBuffer(int32_t iEmeElement);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
etk::VectorType<Buffer*> listBuffer; //!< element List of the char Elements
|
||||
|
||||
void RemoveAll(void); //!< remove all buffer
|
||||
int32_t m_idSelected;
|
||||
Buffer * BufferNotExiste; //!< When an error arrive in get buffer we return the Error buffer (not writable)
|
||||
void Init(void);
|
||||
void UnInit(void);
|
||||
int32_t GetSelected(void);
|
||||
Buffer * Get(int32_t BufferID);
|
||||
bool Exist(int32_t BufferID);
|
||||
bool Exist(etk::File &myFile);
|
||||
int32_t GetId(etk::File &myFile);
|
||||
// return the number of buffer (open in the past) if 5 buffer open and 4 close ==> return 5
|
||||
uint32_t Size(void);
|
||||
uint32_t SizeOpen(void);
|
||||
int32_t WitchBuffer(int32_t iEmeElement);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -61,23 +61,10 @@ extern "C"
|
||||
*/
|
||||
void BufferText::BasicInit(void)
|
||||
{
|
||||
NeedToCleanEndPage = true;
|
||||
// set the first element that is displayed
|
||||
m_displayStartBufferPos = 0;
|
||||
|
||||
// set the number of the lineNumber;
|
||||
nbColoneForLineNumber = 1;
|
||||
// init the link with the buffer manager
|
||||
myColorManager = ColorizeManager::getInstance();
|
||||
// Init Selection mode :
|
||||
SelectionEnd();
|
||||
//EDN_INFO("Init");
|
||||
// new mode :
|
||||
// set basic position
|
||||
m_cursorPos = 0;
|
||||
m_cursorPreferredCol = -1;
|
||||
//m_cursorMode = CURSOR_DISPLAY_MODE_NORMAL;
|
||||
m_displayStartPixelX = 0;
|
||||
m_displayStartLineId = 0;
|
||||
m_displaySize.x = 200;
|
||||
m_displaySize.y = 20;
|
||||
}
|
||||
@@ -95,8 +82,8 @@ void BufferText::NameChange(void)
|
||||
{
|
||||
// Find HL system
|
||||
//EDN_DEBUG("check name change");
|
||||
if (true == HighlightManager::getInstance()->Exist(m_fileName)) {
|
||||
Highlight * myHL = HighlightManager::getInstance()->Get(m_fileName);
|
||||
if (true == HighlightManager::Exist(m_fileName)) {
|
||||
Highlight * myHL = HighlightManager::Get(m_fileName);
|
||||
// Set the new HL
|
||||
if (NULL != myHL) {
|
||||
m_EdnBuf.SetHLSystem(myHL);
|
||||
@@ -149,8 +136,7 @@ BufferText::BufferText(etk::File &fileName) : Buffer(fileName)
|
||||
EDN_WARNING("No File ==> created a new one(" << GetFileName() << ")");
|
||||
SetModify(true);
|
||||
}
|
||||
UpdateWindowsPosition();
|
||||
ForceReDraw(true);
|
||||
RequestPositionUpdate();
|
||||
}
|
||||
|
||||
|
||||
@@ -171,6 +157,8 @@ void BufferText::Save(void)
|
||||
m_EdnBuf.DumpIn(myFile);
|
||||
fclose(myFile);
|
||||
SetModify(false);
|
||||
} else {
|
||||
EDN_ERROR("Can not open in writing the specify file");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,28 +178,6 @@ BufferText::~BufferText(void)
|
||||
}
|
||||
|
||||
|
||||
void BufferText::SelectionStart(void)
|
||||
{
|
||||
// start a nex selection
|
||||
SelectionCheckMode();
|
||||
//EDN_DEBUG("SELECT_start");
|
||||
}
|
||||
|
||||
void BufferText::SelectionEnd(void)
|
||||
{
|
||||
//EDN_DEBUG("SELECT_stop");
|
||||
}
|
||||
|
||||
void BufferText::SelectionCheckMode(void)
|
||||
{
|
||||
/*
|
||||
if (true == ewol::IsSetCtrl() ) {
|
||||
} else {
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
@@ -240,33 +206,26 @@ void BufferText::SetLineDisplay(uint32_t lineNumber)
|
||||
|
||||
#define SEPARATION_SIZE_LINE_NUMBER (3)
|
||||
|
||||
void BufferText::DrawLineNumber(ewol::OObject2DTextColored* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY,char *myPrint, int32_t lineNumber, int32_t positionY)
|
||||
void BufferText::DrawLineNumber(ewol::OObject2DTextColored* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY, int32_t nbColomn, int32_t lineNumber, int32_t positionY)
|
||||
{
|
||||
char tmpLineNumber[50];
|
||||
sprintf(tmpLineNumber, myPrint, lineNumber);
|
||||
OOColored->SetColor(myColorManager->Get(COLOR_LIST_BG_2));
|
||||
sprintf(tmpLineNumber, "%*d", nbColomn, lineNumber);
|
||||
OOColored->SetColor(ColorizeManager::Get(COLOR_LIST_BG_2));
|
||||
OOColored->Rectangle( 0, positionY, sizeX+0.5*SEPARATION_SIZE_LINE_NUMBER, sizeY);
|
||||
OOText->SetColor(myColorManager->Get(COLOR_CODE_LINE_NUMBER));
|
||||
|
||||
OOText->SetColor(ColorizeManager::Get(COLOR_CODE_LINE_NUMBER));
|
||||
|
||||
coord2D_ts textPos;
|
||||
textPos.x = 1;
|
||||
textPos.y = positionY;
|
||||
clipping_ts drawClipping;
|
||||
drawClipping.x = 0;
|
||||
drawClipping.y = 0;
|
||||
drawClipping.w = sizeX;
|
||||
drawClipping.h = sizeY;
|
||||
// TODO : Remove this unreallistic leak of time
|
||||
etk::UString tmppp = tmpLineNumber;
|
||||
OOText->Text(textPos, drawClipping, tmppp);
|
||||
OOText->Text(textPos, tmppp);
|
||||
}
|
||||
|
||||
#define CURSOR_WIDTH (5)
|
||||
#define CURSOR_THICKNESS (1.2)
|
||||
void BufferText::CursorDisplay(ewol::OObject2DColored* OOColored, int32_t x, int32_t y, int32_t letterHeight, int32_t letterWidth)
|
||||
void BufferText::DrawCursor(ewol::OObject2DColored* OOColored, int32_t x, int32_t y, int32_t letterHeight, int32_t letterWidth, clipping_ts &clip)
|
||||
{
|
||||
color_ts & tmpppppp = ColorizeManager::getInstance()->Get(COLOR_CODE_CURSOR);
|
||||
color_ts & tmpppppp = ColorizeManager::Get(COLOR_CODE_CURSOR);
|
||||
OOColored->SetColor(tmpppppp);
|
||||
if (true == ewol::IsSetInsert()) {
|
||||
OOColored->Rectangle( x, y, letterWidth, letterHeight);
|
||||
@@ -279,43 +238,37 @@ void BufferText::CursorDisplay(ewol::OObject2DColored* OOColored, int32_t x, int
|
||||
|
||||
|
||||
/**
|
||||
* @brief Update internal data of the pointer to display
|
||||
* @brief get the number of colomn neede to display lineNumber
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
* @return the number of colomn
|
||||
*
|
||||
*/
|
||||
/*
|
||||
void BufferText::UpdatePointerNumber(void)
|
||||
int32_t BufferText::GetLineNumberNumberOfElement(void)
|
||||
{
|
||||
int32_t nbColoneForLineNumber = 1;
|
||||
// get the number of line in the buffer
|
||||
int32_t maxNumberLine = m_EdnBuf.NumberOfLines();
|
||||
//int32_t maxNumberLine = 2096;
|
||||
if (10 > maxNumberLine) { m_nbColoneForLineNumber = 1;
|
||||
} else if (100 > maxNumberLine) { m_nbColoneForLineNumber = 2;
|
||||
} else if (1000 > maxNumberLine) { m_nbColoneForLineNumber = 3;
|
||||
} else if (10000 > maxNumberLine) { m_nbColoneForLineNumber = 4;
|
||||
} else if (100000 > maxNumberLine) { m_nbColoneForLineNumber = 5;
|
||||
} else if (1000000 > maxNumberLine) { m_nbColoneForLineNumber = 6;
|
||||
} else if (1000000 > maxNumberLine) { m_nbColoneForLineNumber = 7;
|
||||
} else if (10000000 > maxNumberLine) { m_nbColoneForLineNumber = 8;
|
||||
} else if (100000000 > maxNumberLine) { m_nbColoneForLineNumber = 9;
|
||||
} else { m_nbColoneForLineNumber = 10;
|
||||
if (10 > maxNumberLine) { nbColoneForLineNumber = 1;
|
||||
} else if (100 > maxNumberLine) { nbColoneForLineNumber = 2;
|
||||
} else if (1000 > maxNumberLine) { nbColoneForLineNumber = 3;
|
||||
} else if (10000 > maxNumberLine) { nbColoneForLineNumber = 4;
|
||||
} else if (100000 > maxNumberLine) { nbColoneForLineNumber = 5;
|
||||
} else if (1000000 > maxNumberLine) { nbColoneForLineNumber = 6;
|
||||
} else if (1000000 > maxNumberLine) { nbColoneForLineNumber = 7;
|
||||
} else if (10000000 > maxNumberLine) { nbColoneForLineNumber = 8;
|
||||
} else if (100000000 > maxNumberLine) { nbColoneForLineNumber = 9;
|
||||
} else { nbColoneForLineNumber = 10;
|
||||
}
|
||||
return nbColoneForLineNumber;
|
||||
}
|
||||
*/
|
||||
|
||||
int32_t BufferText::GetNumberOfLine(void)
|
||||
{
|
||||
return m_EdnBuf.CountLines();
|
||||
}
|
||||
|
||||
|
||||
// TODO : Remove this ... it is really bad...
|
||||
|
||||
static int32_t g_basicfontId = 0;
|
||||
|
||||
/**
|
||||
* @brief Display the curent buffer with all the probematic imposed by the xharset and the user contraint.
|
||||
*
|
||||
@@ -324,33 +277,28 @@ static int32_t g_basicfontId = 0;
|
||||
* @return
|
||||
*
|
||||
*/
|
||||
int32_t BufferText::Display(ewol::OObject2DTextColored* OOTextNormal,
|
||||
ewol::OObject2DTextColored* OOTextBold,
|
||||
ewol::OObject2DTextColored* OOTextItalic,
|
||||
ewol::OObject2DTextColored* OOTextBoldItalic,
|
||||
ewol::OObject2DColored* OOColored,
|
||||
int32_t BufferText::Display(ewol::OObject2DTextColored& OOTextNormal,
|
||||
ewol::OObject2DTextColored& OOTextBold,
|
||||
ewol::OObject2DTextColored& OOTextItalic,
|
||||
ewol::OObject2DTextColored& OOTextBoldItalic,
|
||||
ewol::OObject2DColored& OOColored,
|
||||
int32_t offsetX, int32_t offsetY,
|
||||
int32_t sizeX, int32_t sizeY)
|
||||
{
|
||||
offsetX -= 40;
|
||||
if (offsetX<0) {
|
||||
offsetX = 0;
|
||||
}
|
||||
int32_t selStart, selEnd, selRectStart, selRectEnd;
|
||||
bool selIsRect;
|
||||
int32_t selHave;
|
||||
|
||||
int32_t fontId = OOTextNormal->GetFontID();
|
||||
// TODO : Remove this ...
|
||||
g_basicfontId = fontId;
|
||||
int32_t fontId = OOTextNormal.GetFontID();
|
||||
int32_t letterWidth = ewol::GetWidth(fontId, "A");
|
||||
int32_t letterHeight = ewol::GetHeight(fontId);
|
||||
|
||||
m_displayStartLineId = offsetY / letterHeight;
|
||||
int32_t displayStartLineId = offsetY / letterHeight;
|
||||
|
||||
// update the display position with the scroll ofset :
|
||||
m_displayStartBufferPos = m_EdnBuf.CountForwardNLines(0, m_displayStartLineId);
|
||||
int32_t displayStartBufferPos = m_EdnBuf.CountForwardNLines(0, displayStartLineId);
|
||||
|
||||
int32_t nbColoneForLineNumber = GetLineNumberNumberOfElement();
|
||||
|
||||
// update the number of element that can be displayed
|
||||
m_displaySize.x = (sizeX/letterWidth) + 1 - nbColoneForLineNumber;
|
||||
@@ -361,28 +309,13 @@ int32_t BufferText::Display(ewol::OObject2DTextColored* OOTextNormal,
|
||||
|
||||
colorInformation_ts * HLColor = NULL;
|
||||
|
||||
// get the number of line in the buffer
|
||||
int32_t maxNumberLine = m_EdnBuf.NumberOfLines();
|
||||
char *myPrint = NULL;
|
||||
if (10 > maxNumberLine) { nbColoneForLineNumber = 1; myPrint = (char *)"%1d";
|
||||
} else if (100 > maxNumberLine) { nbColoneForLineNumber = 2; myPrint = (char *)"%2d";
|
||||
} else if (1000 > maxNumberLine) { nbColoneForLineNumber = 3; myPrint = (char *)"%3d";
|
||||
} else if (10000 > maxNumberLine) { nbColoneForLineNumber = 4; myPrint = (char *)"%4d";
|
||||
} else if (100000 > maxNumberLine) { nbColoneForLineNumber = 5; myPrint = (char *)"%5d";
|
||||
} else if (1000000 > maxNumberLine) { nbColoneForLineNumber = 6; myPrint = (char *)"%6d";
|
||||
} else if (1000000 > maxNumberLine) { nbColoneForLineNumber = 7; myPrint = (char *)"%7d";
|
||||
} else if (10000000 > maxNumberLine) { nbColoneForLineNumber = 8; myPrint = (char *)"%8d";
|
||||
} else if (100000000 > maxNumberLine) { nbColoneForLineNumber = 9; myPrint = (char *)"%9d";
|
||||
} else { nbColoneForLineNumber = 10; myPrint = (char *)"%d";
|
||||
}
|
||||
|
||||
uint32_t y = 0;
|
||||
int32_t iii, new_i;
|
||||
// Get color :
|
||||
Colorize * myColor = myColorManager->Get("normal");
|
||||
Colorize * myColorSel = myColorManager->Get("SelectedText");
|
||||
color_ts & myColorSpace = myColorManager->Get(COLOR_CODE_SPACE);
|
||||
color_ts & myColorTab = myColorManager->Get(COLOR_CODE_TAB);
|
||||
Colorize * myColor = ColorizeManager::Get("normal");
|
||||
Colorize * myColorSel = ColorizeManager::Get("SelectedText");
|
||||
color_ts & myColorSpace = ColorizeManager::Get(COLOR_CODE_SPACE);
|
||||
color_ts & myColorTab = ColorizeManager::Get(COLOR_CODE_TAB);
|
||||
Colorize * selectColor = NULL;
|
||||
ewol::OObject2DTextColored* OOTextSelected = NULL;
|
||||
|
||||
@@ -390,27 +323,30 @@ int32_t BufferText::Display(ewol::OObject2DTextColored* OOTextNormal,
|
||||
int32_t x_base=nbColoneForLineNumber*letterWidth;
|
||||
int32_t idX = 0;
|
||||
|
||||
OOColored->SetColor(myColorManager->Get(COLOR_CODE_BASIC_BG));
|
||||
OOColored->Rectangle( 0, 0, sizeX, sizeY);
|
||||
OOColored.SetColor(ColorizeManager::Get(COLOR_CODE_BASIC_BG));
|
||||
OOColored.Rectangle( 0, 0, sizeX, sizeY);
|
||||
|
||||
int64_t startTime = GetCurrentTime();
|
||||
int displayLines = 0;
|
||||
// Regenerate the colorizing if necessary ...
|
||||
displayHLData_ts m_displayLocalSyntax;
|
||||
m_EdnBuf.HightlightGenerateLines(m_displayLocalSyntax, m_displayStartBufferPos, m_displaySize.y);
|
||||
//GTimeVal timeStart;
|
||||
//g_get_current_time(&timeStart);
|
||||
m_EdnBuf.HightlightGenerateLines(m_displayLocalSyntax, displayStartBufferPos, m_displaySize.y);
|
||||
|
||||
int64_t stopTime = GetCurrentTime();
|
||||
EDN_DEBUG("Parsing Highlight = " << stopTime - startTime << " milli-s");
|
||||
|
||||
uniChar_t displayChar[MAX_EXP_CHAR_LEN];
|
||||
memset(displayChar, 0, sizeof(uniChar_t)*MAX_EXP_CHAR_LEN);
|
||||
etk::UString myStringToDisplay;
|
||||
// draw the lineNumber :
|
||||
int32_t currentLineID = m_displayStartLineId+1;
|
||||
EDN_VERBOSE("Start display of text buffer [" << m_displayStartBufferPos<< ".." << mylen << "]");
|
||||
EDN_VERBOSE("cursor Pos : " << m_cursorPos << "start at pos=" << m_displayStartBufferPos);
|
||||
int32_t currentLineID = displayStartLineId+1;
|
||||
EDN_VERBOSE("Start display of text buffer [" << displayStartBufferPos<< ".." << mylen << "]");
|
||||
EDN_VERBOSE("cursor Pos : " << m_cursorPos << "start at pos=" << displayStartBufferPos);
|
||||
|
||||
|
||||
DrawLineNumber(OOTextNormal, OOColored, x_base, sizeY, myPrint, currentLineID, y);
|
||||
OOTextNormal.clippingDisable();
|
||||
OOColored.clippingDisable();
|
||||
DrawLineNumber(&OOTextNormal, &OOColored, x_base, sizeY, nbColoneForLineNumber, currentLineID, y);
|
||||
int32_t pixelX = x_base + SEPARATION_SIZE_LINE_NUMBER;
|
||||
|
||||
clipping_ts drawClipping;
|
||||
@@ -425,7 +361,13 @@ int32_t BufferText::Display(ewol::OObject2DTextColored* OOTextNormal,
|
||||
drawClippingTextArea.w = sizeX - drawClipping.x;
|
||||
drawClippingTextArea.h = sizeY;
|
||||
|
||||
for (iii=m_displayStartBufferPos; iii<mylen && displayLines < m_displaySize.y ; iii = new_i) {
|
||||
OOTextNormal.clippingSet(drawClippingTextArea);
|
||||
OOTextBold.clippingSet(drawClippingTextArea);
|
||||
OOTextItalic.clippingSet(drawClippingTextArea);
|
||||
OOTextBoldItalic.clippingSet(drawClippingTextArea);
|
||||
OOColored.clippingSet(drawClippingTextArea);
|
||||
|
||||
for (iii=displayStartBufferPos; iii<mylen && displayLines < m_displaySize.y ; iii = new_i) {
|
||||
//EDN_DEBUG("diplay element=" << iii);
|
||||
int displaywidth;
|
||||
uint32_t currentChar = '\0';
|
||||
@@ -447,21 +389,21 @@ int32_t BufferText::Display(ewol::OObject2DTextColored* OOTextNormal,
|
||||
&& selEnd > iii)
|
||||
{
|
||||
selectColor = myColorSel;
|
||||
OOColored->SetColor(selectColor->GetBG());
|
||||
OOColored.SetColor(selectColor->GetBG());
|
||||
haveBg = selectColor->HaveBg();
|
||||
} else {
|
||||
if( ' ' == currentChar
|
||||
&& true == globals::IsSetDisplaySpaceChar() )
|
||||
{
|
||||
OOColored->SetColor(myColorSpace);
|
||||
OOColored.SetColor(myColorSpace);
|
||||
haveBg = true;
|
||||
} else if( '\t' == currentChar
|
||||
&& true == globals::IsSetDisplaySpaceChar() )
|
||||
{
|
||||
OOColored->SetColor(myColorTab);
|
||||
OOColored.SetColor(myColorTab);
|
||||
haveBg = true;
|
||||
} else {
|
||||
OOColored->SetColor(selectColor->GetBG());
|
||||
OOColored.SetColor(selectColor->GetBG());
|
||||
haveBg = selectColor->HaveBg();
|
||||
}
|
||||
}
|
||||
@@ -470,30 +412,31 @@ int32_t BufferText::Display(ewol::OObject2DTextColored* OOTextNormal,
|
||||
textPos.y = y;
|
||||
if (true == selectColor->GetItalic() ) {
|
||||
if (true == selectColor->GetBold() ) {
|
||||
OOTextSelected = OOTextBoldItalic;
|
||||
OOTextSelected = &OOTextBoldItalic;
|
||||
} else {
|
||||
OOTextSelected = OOTextItalic;
|
||||
OOTextSelected = &OOTextItalic;
|
||||
}
|
||||
} else {
|
||||
if (true == selectColor->GetBold() ) {
|
||||
OOTextSelected = OOTextBold;
|
||||
OOTextSelected = &OOTextBold;
|
||||
} else {
|
||||
OOTextSelected = OOTextNormal;
|
||||
OOTextSelected = &OOTextNormal;
|
||||
}
|
||||
}
|
||||
OOTextSelected->SetColor(selectColor->GetFG());
|
||||
// TODO : Remove this unreallistic leak of time
|
||||
myStringToDisplay = displayChar;
|
||||
drawSize = OOTextSelected->Text(textPos, drawClippingTextArea, myStringToDisplay);
|
||||
drawSize = OOTextSelected->Text(textPos, myStringToDisplay);
|
||||
|
||||
if (true == haveBg ) {
|
||||
OOColored->Rectangle(textPos.x, y, drawSize, letterHeight, drawClippingTextArea);
|
||||
OOColored.Rectangle(textPos.x, y, drawSize, letterHeight);
|
||||
}
|
||||
}
|
||||
idX += displaywidth;
|
||||
// display cursor :
|
||||
if (m_cursorPos == iii) {
|
||||
// display the cursor:
|
||||
CursorDisplay(OOColored, pixelX, y, letterHeight, letterWidth);
|
||||
DrawCursor(&OOColored, pixelX - offsetX, y, letterHeight, letterWidth, drawClippingTextArea);
|
||||
}
|
||||
pixelX += drawSize;
|
||||
// move to next line ...
|
||||
@@ -503,59 +446,51 @@ int32_t BufferText::Display(ewol::OObject2DTextColored* OOTextNormal,
|
||||
y += letterHeight;
|
||||
displayLines++;
|
||||
currentLineID++;
|
||||
DrawLineNumber(OOTextNormal, OOColored, x_base, sizeY, myPrint, currentLineID, y);
|
||||
OOTextNormal.clippingDisable();
|
||||
OOColored.clippingDisable();
|
||||
DrawLineNumber(&OOTextNormal, &OOColored, x_base, sizeY, nbColoneForLineNumber, currentLineID, y);
|
||||
OOTextNormal.clippingEnable();
|
||||
OOColored.clippingEnable();
|
||||
}
|
||||
}
|
||||
// special case : the cursor is at the end of the buffer...
|
||||
if (m_cursorPos == iii) {
|
||||
CursorDisplay(OOColored, pixelX, y, letterHeight, letterWidth);
|
||||
DrawCursor(&OOColored, pixelX - offsetX, y, letterHeight, letterWidth, drawClippingTextArea);
|
||||
}
|
||||
|
||||
//GTimeVal timeStop;
|
||||
//g_get_current_time(&timeStop);
|
||||
//EDN_DEBUG("Display Generation = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s");
|
||||
int64_t stopTime2 = GetCurrentTime();
|
||||
EDN_DEBUG("DRAW text (brut) = " << stopTime2 - stopTime << " milli-s");
|
||||
|
||||
return ERR_NONE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int32_t BufferText::GetMousePosition(int32_t width, int32_t height)
|
||||
int32_t BufferText::GetMousePosition(int32_t fontId, int32_t width, int32_t height)
|
||||
{
|
||||
int32_t letterWidth = ewol::GetWidth(g_basicfontId, "9");
|
||||
int32_t letterHeight = ewol::GetHeight(g_basicfontId);
|
||||
int32_t letterWidth = ewol::GetWidth(fontId, "9");
|
||||
int32_t letterHeight = ewol::GetHeight(fontId);
|
||||
|
||||
int32_t lineOffset = height / letterHeight;
|
||||
|
||||
//******************************* get the X position : *******************************************
|
||||
|
||||
|
||||
// get the number of line in the buffer
|
||||
int32_t maxNumberLine = m_EdnBuf.NumberOfLines();
|
||||
if (10 > maxNumberLine) { nbColoneForLineNumber = 1;
|
||||
} else if (100 > maxNumberLine) { nbColoneForLineNumber = 2;
|
||||
} else if (1000 > maxNumberLine) { nbColoneForLineNumber = 3;
|
||||
} else if (10000 > maxNumberLine) { nbColoneForLineNumber = 4;
|
||||
} else if (100000 > maxNumberLine) { nbColoneForLineNumber = 5;
|
||||
} else if (1000000 > maxNumberLine) { nbColoneForLineNumber = 6;
|
||||
} else if (1000000 > maxNumberLine) { nbColoneForLineNumber = 7;
|
||||
} else if (10000000 > maxNumberLine) { nbColoneForLineNumber = 8;
|
||||
} else if (100000000 > maxNumberLine) { nbColoneForLineNumber = 9;
|
||||
} else { nbColoneForLineNumber = 10;
|
||||
}
|
||||
|
||||
int32_t iii, new_i;
|
||||
|
||||
int mylen = m_EdnBuf.Size();
|
||||
int32_t x_base=nbColoneForLineNumber*letterWidth + SEPARATION_SIZE_LINE_NUMBER;
|
||||
int32_t x_base=GetLineNumberNumberOfElement()*letterWidth + SEPARATION_SIZE_LINE_NUMBER;
|
||||
width -= x_base;
|
||||
if (width < 0) {
|
||||
width = 0;
|
||||
}
|
||||
int32_t idX = 0;
|
||||
|
||||
uniChar_t displayChar[MAX_EXP_CHAR_LEN];
|
||||
memset(displayChar, 0, sizeof(uniChar_t)*MAX_EXP_CHAR_LEN);
|
||||
|
||||
int32_t pixelX = x_base;
|
||||
int32_t startLinePosition = m_EdnBuf.CountForwardNLines(m_displayStartBufferPos, lineOffset);
|
||||
if (width <= pixelX) {
|
||||
int32_t pixelX = 0;
|
||||
int32_t startLinePosition = m_EdnBuf.CountForwardNLines(0, lineOffset);
|
||||
if (width <= 0) {
|
||||
EDN_DEBUG(" Element : Befor the start of the line ... ==> END");
|
||||
return startLinePosition;
|
||||
}
|
||||
@@ -567,7 +502,7 @@ int32_t BufferText::GetMousePosition(int32_t width, int32_t height)
|
||||
new_i = iii;
|
||||
displaywidth = m_EdnBuf.GetExpandedChar(new_i, idX, displayChar, currentChar);
|
||||
if (currentChar!='\n') {
|
||||
int32_t drawSize = ewol::GetWidth(g_basicfontId, displayChar);
|
||||
int32_t drawSize = ewol::GetWidth(fontId, displayChar);
|
||||
EDN_VERBOSE(" Element : " << currentChar << "=\"" << (char)currentChar << "\" display offset=" << pixelX << "px width=" << drawSize << "px");
|
||||
pixelX += drawSize;
|
||||
if (width <= pixelX) {
|
||||
@@ -596,13 +531,13 @@ int32_t BufferText::GetMousePosition(int32_t width, int32_t height)
|
||||
*
|
||||
*/
|
||||
// TODO : Simplify selection ....
|
||||
void BufferText::MouseEvent(int32_t width, int32_t height)
|
||||
void BufferText::MouseEvent(int32_t fontId, int32_t width, int32_t height)
|
||||
{
|
||||
if (true == ewol::IsSetShift() ) {
|
||||
MouseSelectFromCursorTo(width, height);
|
||||
MouseSelectFromCursorTo(fontId, width, height);
|
||||
} else {
|
||||
// Get the caracter mouse position
|
||||
int32_t newPos = GetMousePosition(width, height);
|
||||
int32_t newPos = GetMousePosition(fontId, width, height);
|
||||
// move the cursor
|
||||
SetInsertPosition(newPos);
|
||||
|
||||
@@ -612,8 +547,7 @@ void BufferText::MouseEvent(int32_t width, int32_t height)
|
||||
}*/
|
||||
m_EdnBuf.Unselect(SELECTION_PRIMARY);
|
||||
|
||||
ForceReDraw(true);
|
||||
UpdateWindowsPosition();
|
||||
RequestPositionUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -628,10 +562,10 @@ void BufferText::MouseEvent(int32_t width, int32_t height)
|
||||
*
|
||||
*/
|
||||
// TODO : Simplify selection ....
|
||||
void BufferText::MouseSelectFromCursorTo(int32_t width, int32_t height)
|
||||
void BufferText::MouseSelectFromCursorTo(int32_t fontId, int32_t width, int32_t height)
|
||||
{
|
||||
// Get the caracter mouse position
|
||||
int32_t newPos = GetMousePosition(width, height);
|
||||
int32_t newPos = GetMousePosition(fontId, width, height);
|
||||
|
||||
int32_t selStart, selEnd, selRectStart, selRectEnd;
|
||||
bool selIsRect;
|
||||
@@ -655,8 +589,7 @@ void BufferText::MouseSelectFromCursorTo(int32_t width, int32_t height)
|
||||
m_EdnBuf.Select(SELECTION_PRIMARY, selStart, m_cursorPos);
|
||||
}
|
||||
}
|
||||
ForceReDraw(true);
|
||||
UpdateWindowsPosition();
|
||||
RequestPositionUpdate();
|
||||
}
|
||||
|
||||
|
||||
@@ -675,7 +608,6 @@ void BufferText::MouseEventDouble(void)
|
||||
if (true == m_EdnBuf.SelectAround(m_cursorPos, beginPos, endPos)) {
|
||||
m_EdnBuf.Select(SELECTION_PRIMARY, beginPos, endPos);
|
||||
m_cursorPos = endPos;
|
||||
ForceReDraw(true);
|
||||
}
|
||||
// no else
|
||||
}
|
||||
@@ -692,7 +624,6 @@ void BufferText::MouseEventTriple(void)
|
||||
{
|
||||
m_EdnBuf.Select(SELECTION_PRIMARY, m_EdnBuf.StartOfLine(m_cursorPos), m_EdnBuf.EndOfLine(m_cursorPos));
|
||||
m_cursorPos = m_EdnBuf.EndOfLine(m_cursorPos);
|
||||
ForceReDraw(true);
|
||||
}
|
||||
|
||||
void BufferText::RemoveLine(void)
|
||||
@@ -708,26 +639,11 @@ void BufferText::SelectAll(void)
|
||||
{
|
||||
m_EdnBuf.Select(SELECTION_PRIMARY, 0, m_EdnBuf.Size());
|
||||
m_cursorPos = m_EdnBuf.Size();
|
||||
ForceReDraw(true);
|
||||
}
|
||||
|
||||
void BufferText::SelectNone(void)
|
||||
{
|
||||
m_EdnBuf.Unselect(SELECTION_PRIMARY);
|
||||
ForceReDraw(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void BufferText::ScrollDown(void)
|
||||
{
|
||||
MoveUpDown(3);
|
||||
}
|
||||
|
||||
|
||||
@@ -739,58 +655,6 @@ void BufferText::ScrollDown(void)
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void BufferText::ScrollUp(void)
|
||||
{
|
||||
MoveUpDown(-3);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void BufferText::MoveUpDown(int32_t ofset)
|
||||
{
|
||||
if (ofset >= 0) {
|
||||
int32_t nbLine = m_EdnBuf.NumberOfLines();
|
||||
if (m_displayStartLineId+ofset+3 > nbLine) {
|
||||
m_displayStartLineId = nbLine-3;
|
||||
} else {
|
||||
m_displayStartLineId += ofset;
|
||||
}
|
||||
m_displayStartBufferPos = m_EdnBuf.CountForwardNLines(0, m_displayStartLineId);
|
||||
} else {
|
||||
ofset *= -1;
|
||||
if (m_displayStartLineId < ofset) {
|
||||
m_displayStartLineId = 0;
|
||||
m_displayStartBufferPos = 0;
|
||||
} else {
|
||||
m_displayStartLineId -= ofset;
|
||||
m_displayStartBufferPos = m_EdnBuf.CountForwardNLines(0, m_displayStartLineId);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void BufferText::ForceReDraw(bool allElement)
|
||||
{
|
||||
NeedToCleanEndPage = true;
|
||||
}
|
||||
|
||||
void BufferText::SetInsertPosition(int32_t newPos, bool insertChar)
|
||||
{
|
||||
int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd;
|
||||
@@ -916,17 +780,6 @@ void BufferText::cursorMove(ewol::eventKbMoveType_te moveTypeEvent)
|
||||
{
|
||||
bool needUpdatePosition = true;
|
||||
// check selection event ...
|
||||
/*
|
||||
if (true == ewol::IsSetShift() ) {
|
||||
if ( CURSOR_MODE_NORMAL == cursorMode) {
|
||||
SelectionStart();
|
||||
} else {
|
||||
SelectionCheckMode();
|
||||
}
|
||||
} else {
|
||||
SelectionEnd();
|
||||
}
|
||||
*/
|
||||
switch(moveTypeEvent) {
|
||||
case ewol::EVENT_KB_MOVE_TYPE_LEFT:
|
||||
//EDN_INFO("keyEvent : <LEFT>");
|
||||
@@ -971,7 +824,7 @@ void BufferText::cursorMove(ewol::eventKbMoveType_te moveTypeEvent)
|
||||
break;
|
||||
}
|
||||
if ( true == needUpdatePosition) {
|
||||
UpdateWindowsPosition();
|
||||
RequestPositionUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -984,27 +837,48 @@ void BufferText::cursorMove(ewol::eventKbMoveType_te moveTypeEvent)
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void BufferText::UpdateWindowsPosition(bool centerPage)
|
||||
bool BufferText::RequestPositionRequest(coord2D_ts& newPos)
|
||||
{
|
||||
if (-1 == m_requestDisplayPos.x || -1 == m_requestDisplayPos.y) {
|
||||
return false;
|
||||
}
|
||||
newPos = m_requestDisplayPos;
|
||||
m_requestDisplayPos.x = -1;
|
||||
m_requestDisplayPos.y = -1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void BufferText::RequestPositionUpdate(bool centerPage)
|
||||
{
|
||||
m_requestDisplayPos.x = -1;
|
||||
m_requestDisplayPos.y = -1;
|
||||
#if 0
|
||||
if (centerPage == false) {
|
||||
/*
|
||||
// Display position (Y mode):
|
||||
//EDN_INFO("BufferText::UpdateWindowsPosition() m_displayStart(" << m_displayStartPixelX << "px," << m_displayStartLineId << "id) m_displaySize(" << m_displaySize.x << "," <<m_displaySize.y << ")");
|
||||
position_ts cursorPosition;
|
||||
//EDN_INFO("BufferText::RequestPositionUpdate() m_displayStart(" << m_displayStartPixelX << "px," << m_displayStartLineId << "id) m_displaySize(" << m_displaySize.x << "," <<m_displaySize.y << ")");
|
||||
coord2D_ts cursorPosition;
|
||||
cursorPosition.y = m_EdnBuf.CountLines(0, m_cursorPos);
|
||||
int32_t lineStartPos = m_EdnBuf.StartOfLine(m_cursorPos);
|
||||
cursorPosition.x = m_EdnBuf.CountDispChars(lineStartPos, m_cursorPos);
|
||||
//EDN_INFO("BufferText::UpdateWindowsPosition() curent cursor position : (" << cursorPosition.x << "," << cursorPosition.y << ")");
|
||||
//EDN_INFO("BufferText::RequestPositionUpdate() curent cursor position : (" << cursorPosition.x << "," << cursorPosition.y << ")");
|
||||
|
||||
if (m_displayStartLineId > (int32_t)cursorPosition.y - globals::getNbLineBorder() ) {
|
||||
m_displayStartLineId = cursorPosition.y - globals::getNbLineBorder();
|
||||
if (m_displayStartLineId < 0) {
|
||||
m_displayStartLineId = 0;
|
||||
ForceReDraw(true);
|
||||
}
|
||||
} else if (m_displayStartLineId + m_displaySize.y <= (int32_t)cursorPosition.y + globals::getNbLineBorder() ) {
|
||||
m_displayStartLineId = cursorPosition.y - m_displaySize.y + globals::getNbLineBorder() + 1;
|
||||
ForceReDraw(true);
|
||||
}
|
||||
// Display position (X mode):
|
||||
//EDN_INFO("cursorPosition X : " << cursorPosition.y << " windows " << m_displayStartLineId << "=>" << m_displayStartPixelX + m_displaySize.x);
|
||||
@@ -1012,11 +886,9 @@ void BufferText::UpdateWindowsPosition(bool centerPage)
|
||||
m_displayStartPixelX = cursorPosition.x - globals::getNbColoneBorder();
|
||||
if (m_displayStartPixelX < 0) {
|
||||
m_displayStartPixelX = 0;
|
||||
ForceReDraw(true);
|
||||
}
|
||||
} else if (m_displayStartPixelX + m_displaySize.x <= cursorPosition.x + globals::getNbColoneBorder() ) {
|
||||
m_displayStartPixelX = cursorPosition.x - m_displaySize.x + globals::getNbColoneBorder() + 1;
|
||||
ForceReDraw(true);
|
||||
}
|
||||
|
||||
//update the buffer position ID :
|
||||
@@ -1024,7 +896,7 @@ void BufferText::UpdateWindowsPosition(bool centerPage)
|
||||
*/
|
||||
} else {
|
||||
// center the line at the middle of the screen :
|
||||
position_ts cursorPosition;
|
||||
coord2D_ts cursorPosition;
|
||||
//EDN_DEBUG(" -------------------------------------------------");
|
||||
cursorPosition.y = m_EdnBuf.CountLines(0, m_cursorPos);
|
||||
//EDN_DEBUG(" cursor position : " << m_cursorPos << " ==> ligne=" << cursorPosition.y);
|
||||
@@ -1036,10 +908,10 @@ void BufferText::UpdateWindowsPosition(bool centerPage)
|
||||
m_displayStartLineId = edn_max(m_displayStartLineId, 0);
|
||||
|
||||
m_displayStartBufferPos = m_EdnBuf.CountForwardNLines(0, m_displayStartLineId);
|
||||
ForceReDraw(true);
|
||||
//EDN_DEBUG(" display start : " << m_displayStartPixelX << "x" << m_displayStartLineId);
|
||||
//EDN_DEBUG(" -------------------------------------------------");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1164,7 +1036,7 @@ void BufferText::AddChar(uniChar_t unicodeData)
|
||||
}
|
||||
|
||||
SetModify(true);
|
||||
UpdateWindowsPosition();
|
||||
RequestPositionUpdate();
|
||||
}
|
||||
|
||||
|
||||
@@ -1198,7 +1070,7 @@ void BufferText::JumpAtLine(int32_t newLine)
|
||||
m_EdnBuf.Unselect(SELECTION_PRIMARY);
|
||||
EDN_DEBUG("jump at the line : " << newLine );
|
||||
SetInsertPosition(positionLine);
|
||||
UpdateWindowsPosition(true);
|
||||
RequestPositionUpdate(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1257,7 +1129,7 @@ void BufferText::Search(etk::UString &data, bool back, bool caseSensitive, bool
|
||||
int32_t endSelectionPos = foundPos+mVectSearch.Size();
|
||||
SetInsertPosition(endSelectionPos);
|
||||
m_EdnBuf.Select(SELECTION_PRIMARY, foundPos, endSelectionPos);
|
||||
UpdateWindowsPosition();
|
||||
RequestPositionUpdate();
|
||||
}
|
||||
} else {
|
||||
//EDN_INFO("search data Backward : " << data.GetDirectPointer() );
|
||||
@@ -1275,7 +1147,7 @@ void BufferText::Search(etk::UString &data, bool back, bool caseSensitive, bool
|
||||
int32_t endSelectionPos = foundPos+mVectSearch.Size();
|
||||
SetInsertPosition(foundPos);
|
||||
m_EdnBuf.Select(SELECTION_PRIMARY, foundPos, endSelectionPos);
|
||||
UpdateWindowsPosition();
|
||||
RequestPositionUpdate();
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1343,8 +1215,7 @@ void BufferText::Cut(int8_t clipboardID)
|
||||
m_EdnBuf.RemoveSelected(SELECTION_PRIMARY);
|
||||
m_cursorPos = SelectionStart;
|
||||
}
|
||||
UpdateWindowsPosition();
|
||||
ForceReDraw(true);
|
||||
RequestPositionUpdate();
|
||||
SetModify(true);
|
||||
}
|
||||
|
||||
@@ -1380,8 +1251,7 @@ void BufferText::Paste(int8_t clipboardID)
|
||||
m_cursorPos += mVect.Size();
|
||||
}
|
||||
*/
|
||||
UpdateWindowsPosition();
|
||||
ForceReDraw(true);
|
||||
RequestPositionUpdate();
|
||||
SetModify(true);
|
||||
}
|
||||
|
||||
@@ -1391,8 +1261,7 @@ void BufferText::Undo(void)
|
||||
int32_t newPos = m_EdnBuf.Undo();
|
||||
if (newPos >= 0) {
|
||||
SetInsertPosition(newPos, true);
|
||||
UpdateWindowsPosition();
|
||||
ForceReDraw(true);
|
||||
RequestPositionUpdate();
|
||||
SetModify(true);
|
||||
}
|
||||
}
|
||||
@@ -1402,8 +1271,7 @@ void BufferText::Redo(void)
|
||||
int32_t newPos = m_EdnBuf.Redo();
|
||||
if (newPos >= 0) {
|
||||
SetInsertPosition(newPos, true);
|
||||
UpdateWindowsPosition();
|
||||
ForceReDraw(true);
|
||||
RequestPositionUpdate();
|
||||
SetModify(true);
|
||||
}
|
||||
}
|
||||
@@ -1412,6 +1280,5 @@ void BufferText::Redo(void)
|
||||
void BufferText::SetCharset(unicode::charset_te newCharset)
|
||||
{
|
||||
m_EdnBuf.SetCharsetType(newCharset);
|
||||
ForceReDraw(true);
|
||||
}
|
||||
|
||||
|
@@ -46,22 +46,19 @@ class BufferText : public Buffer {
|
||||
void GetInfo(infoStatBuffer_ts &infoToUpdate);
|
||||
void SetLineDisplay(uint32_t lineNumber);
|
||||
|
||||
int32_t Display(ewol::OObject2DTextColored* OOTextNormal,
|
||||
ewol::OObject2DTextColored* OOTextBold,
|
||||
ewol::OObject2DTextColored* OOTextItalic,
|
||||
ewol::OObject2DTextColored* OOTextBoldItalic,
|
||||
ewol::OObject2DColored* OOColored,
|
||||
int32_t Display(ewol::OObject2DTextColored& OOTextNormal,
|
||||
ewol::OObject2DTextColored& OOTextBold,
|
||||
ewol::OObject2DTextColored& OOTextItalic,
|
||||
ewol::OObject2DTextColored& OOTextBoldItalic,
|
||||
ewol::OObject2DColored& OOColored,
|
||||
int32_t offsetX, int32_t offsetY,
|
||||
int32_t sizeX, int32_t sizeY);
|
||||
void ForceReDraw(bool allElement);
|
||||
void AddChar(uniChar_t unicodeData);
|
||||
void cursorMove(ewol::eventKbMoveType_te moveTypeEvent);
|
||||
void MouseSelectFromCursorTo(int32_t width, int32_t height);
|
||||
void MouseEvent(int32_t width, int32_t height);
|
||||
void MouseSelectFromCursorTo(int32_t fontId, int32_t width, int32_t height);
|
||||
void MouseEvent(int32_t fontId, int32_t width, int32_t height);
|
||||
void MouseEventDouble(void);
|
||||
void MouseEventTriple(void);
|
||||
void ScrollDown(void);
|
||||
void ScrollUp(void);
|
||||
|
||||
void Copy(int8_t clipboardID);
|
||||
void Cut(int8_t clipboardID);
|
||||
@@ -84,43 +81,34 @@ class BufferText : public Buffer {
|
||||
void NameChange(void);
|
||||
|
||||
private:
|
||||
// Display
|
||||
bool NeedToCleanEndPage; //!< if true, the end of the page need to be clean (arrive after a remove line)
|
||||
uint32_t nbColoneForLineNumber; //!< number of colome used to display the line Number
|
||||
ColorizeManager * myColorManager; //!< for the background color :
|
||||
|
||||
int32_t GetLineNumberNumberOfElement(void);
|
||||
|
||||
// Direct buffer IO
|
||||
EdnBuf m_EdnBuf; //!< buffer associated on this displayer
|
||||
int32_t m_displayStartLineId; //!< Id of the line that the display is starting (in nb line)
|
||||
int32_t m_displayStartPixelX; //!< Pixel of the display starting (in pixel)
|
||||
position_ts m_displaySize; //!< number of char displayable in the screan
|
||||
int32_t m_displayStartBufferPos; //!< position where the buffer start
|
||||
coord2D_ts m_displaySize; //!< number of char displayable in the screan
|
||||
// Cursor :
|
||||
int32_t m_cursorPos; //!< position in the buffer of the cursor
|
||||
int32_t m_cursorPreferredCol; //!< colomn of the last up and down ...
|
||||
cursorDisplayMode_te m_cursorMode; //!< type of cursor Selected
|
||||
|
||||
// internal function
|
||||
void BasicInit(void);
|
||||
void UpdateWindowsPosition(bool centerPage = false);
|
||||
void BasicInit(void);
|
||||
// moving the current position of the display windows ...
|
||||
private:
|
||||
coord2D_ts m_requestDisplayPos; //!< number of char displayable in the screan
|
||||
void RequestPositionUpdate(bool centerPage = false);
|
||||
public:
|
||||
bool RequestPositionRequest(coord2D_ts& newPos);
|
||||
|
||||
void CleanSelectLine(void);
|
||||
|
||||
void SelectionStart(void);
|
||||
void SelectionEnd(void);
|
||||
void SelectionCheckMode(void);
|
||||
|
||||
void CheckAndUpdateLineForModification(uint32_t lineID);
|
||||
private:
|
||||
bool TextDMoveUp(int32_t offset);
|
||||
bool TextDMoveDown(int32_t offset);
|
||||
void SetInsertPosition(int32_t newPosition, bool insertChar = false);
|
||||
|
||||
int32_t GetMousePosition(int32_t width, int32_t height);
|
||||
void MoveUpDown(int32_t ofset);
|
||||
void DrawLineNumber(ewol::OObject2DTextColored* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY,char *myPrint, int32_t lineNumber, int32_t positionY);
|
||||
int32_t GetMousePosition(int32_t fontId, int32_t width, int32_t height);
|
||||
|
||||
void CursorDisplay(ewol::OObject2DColored* OOColored, int32_t x, int32_t y, int32_t letterHeight, int32_t letterWidth);
|
||||
void DrawLineNumber(ewol::OObject2DTextColored* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY, int32_t nbColomn, int32_t lineNumber, int32_t positionY);
|
||||
void DrawCursor(ewol::OObject2DColored* OOColored, int32_t x, int32_t y, int32_t letterHeight, int32_t letterWidth, clipping_ts &clip);
|
||||
|
||||
};
|
||||
|
||||
|
@@ -26,17 +26,52 @@
|
||||
#include <tools_globals.h>
|
||||
#include <ColorizeManager.h>
|
||||
#include <tinyXML/tinyxml.h>
|
||||
#include <ewol/WidgetMessageMultiCast.h>
|
||||
#include <ewol/EObject.h>
|
||||
#include <ewol/EObjectManager.h>
|
||||
|
||||
#define PFX "ColorizeManager "
|
||||
|
||||
|
||||
ColorizeManager::ColorizeManager(void)
|
||||
|
||||
class classColorManager: public ewol::EObject
|
||||
{
|
||||
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgGuiChangeColor);
|
||||
public:
|
||||
// Constructeur
|
||||
classColorManager(void);
|
||||
~classColorManager(void);
|
||||
public:
|
||||
/**
|
||||
* @brief Receive a message from an other EObject with a specific eventId and data
|
||||
* @param[in] CallerObject Pointer on the EObject that information came from
|
||||
* @param[in] eventId Message registered by this class
|
||||
* @param[in] data Data registered by this class
|
||||
* @return ---
|
||||
*/
|
||||
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
|
||||
public:
|
||||
void LoadFile(etk::UString &xmlFilename);
|
||||
void LoadFile(const char * xmlFilename);
|
||||
Colorize * Get(const char *colorName);
|
||||
Colorize * Get(etk::UString &colorName);
|
||||
color_ts & Get(basicColor_te myColor);
|
||||
bool Exist(etk::UString &colorName);
|
||||
bool Exist(const char *colorName);
|
||||
void DisplayListOfColor(void);
|
||||
|
||||
private:
|
||||
etk::UString m_fileColor;
|
||||
etk::VectorType<Colorize*> listMyColor; //!< List of ALL Color
|
||||
Colorize * errorColor;
|
||||
color_ts basicColors[COLOR_NUMBER_MAX];
|
||||
};
|
||||
|
||||
|
||||
classColorManager::classColorManager(void)
|
||||
{
|
||||
//ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgGuiChangeColor);
|
||||
}
|
||||
|
||||
ColorizeManager::~ColorizeManager(void)
|
||||
classColorManager::~classColorManager(void)
|
||||
{
|
||||
delete(errorColor);
|
||||
|
||||
@@ -52,8 +87,7 @@ ColorizeManager::~ColorizeManager(void)
|
||||
listMyColor.Clear();
|
||||
}
|
||||
|
||||
|
||||
bool ColorizeManager::OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, etkFloat_t x, etkFloat_t y)
|
||||
void classColorManager::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
|
||||
{
|
||||
/*
|
||||
switch (id)
|
||||
@@ -68,18 +102,17 @@ bool ColorizeManager::OnEventAreaExternal(int32_t widgetID, const char * generat
|
||||
break;
|
||||
}
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void ColorizeManager::LoadFile(etk::UString &xmlFilename)
|
||||
void classColorManager::LoadFile(etk::UString &xmlFilename)
|
||||
{
|
||||
// TODO : Remove this
|
||||
LoadFile(xmlFilename.Utf8Data());
|
||||
}
|
||||
|
||||
// TODO : Remove this ...
|
||||
void ColorizeManager::LoadFile(const char * xmlFilename)
|
||||
void classColorManager::LoadFile(const char * xmlFilename)
|
||||
{
|
||||
// Remove all old color :
|
||||
int32_t i;
|
||||
@@ -276,7 +309,7 @@ void ColorizeManager::LoadFile(const char * xmlFilename)
|
||||
}
|
||||
|
||||
// TODO : Remove this ...
|
||||
Colorize *ColorizeManager::Get(const char *colorName)
|
||||
Colorize *classColorManager::Get(const char *colorName)
|
||||
{
|
||||
int32_t i;
|
||||
for (i=0; i<listMyColor.Size(); i++) {
|
||||
@@ -290,13 +323,13 @@ Colorize *ColorizeManager::Get(const char *colorName)
|
||||
return errorColor;
|
||||
}
|
||||
|
||||
Colorize *ColorizeManager::Get(etk::UString &colorName)
|
||||
Colorize *classColorManager::Get(etk::UString &colorName)
|
||||
{
|
||||
// TODO : Remove this
|
||||
return Get(colorName.Utf8Data());
|
||||
}
|
||||
|
||||
color_ts & ColorizeManager::Get(basicColor_te myColor)
|
||||
color_ts & classColorManager::Get(basicColor_te myColor)
|
||||
{
|
||||
if (myColor < COLOR_NUMBER_MAX) {
|
||||
return basicColors[myColor];
|
||||
@@ -307,7 +340,7 @@ color_ts & ColorizeManager::Get(basicColor_te myColor)
|
||||
|
||||
|
||||
// TODO : Remove this ...
|
||||
bool ColorizeManager::Exist(const char *colorName)
|
||||
bool classColorManager::Exist(const char *colorName)
|
||||
{
|
||||
int32_t i;
|
||||
for (i=0; i<listMyColor.Size(); i++) {
|
||||
@@ -319,13 +352,13 @@ bool ColorizeManager::Exist(const char *colorName)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ColorizeManager::Exist(etk::UString &colorName)
|
||||
bool classColorManager::Exist(etk::UString &colorName)
|
||||
{
|
||||
// TODO : Remove this
|
||||
return Exist(colorName.Utf8Data());
|
||||
}
|
||||
|
||||
void ColorizeManager::DisplayListOfColor(void)
|
||||
void classColorManager::DisplayListOfColor(void)
|
||||
{
|
||||
int32_t i;
|
||||
EDN_INFO(PFX"List of ALL COLOR : ");
|
||||
@@ -338,3 +371,97 @@ void ColorizeManager::DisplayListOfColor(void)
|
||||
|
||||
|
||||
|
||||
static classColorManager * localManager = NULL;
|
||||
|
||||
|
||||
void ColorizeManager::Init(void)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
EWOL_ERROR("ColorizeManager ==> already exist, just unlink the previous ...");
|
||||
localManager = NULL;
|
||||
}
|
||||
localManager = new classColorManager();
|
||||
|
||||
if (NULL == localManager) {
|
||||
EWOL_CRITICAL("Allocation of HighlightManager not done ...");
|
||||
}
|
||||
}
|
||||
|
||||
void ColorizeManager::UnInit(void)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
EWOL_ERROR("ColorizeManager ==> request UnInit, but does not exist ...");
|
||||
return;
|
||||
}
|
||||
ewol::EObjectManager::MarkToRemoved(localManager);
|
||||
localManager = NULL;
|
||||
}
|
||||
|
||||
void ColorizeManager::LoadFile(etk::UString &xmlFilename)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
return;
|
||||
}
|
||||
localManager->LoadFile(xmlFilename);
|
||||
}
|
||||
|
||||
|
||||
void ColorizeManager::LoadFile(const char * xmlFilename)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
return;
|
||||
}
|
||||
localManager->LoadFile(xmlFilename);
|
||||
}
|
||||
|
||||
Colorize* ColorizeManager::Get(const char *colorName)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
return NULL;
|
||||
}
|
||||
return localManager->Get(colorName);
|
||||
}
|
||||
|
||||
Colorize* ColorizeManager::Get(etk::UString &colorName)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
return NULL;
|
||||
}
|
||||
return localManager->Get(colorName);
|
||||
}
|
||||
|
||||
color_ts errorColor;
|
||||
|
||||
color_ts& ColorizeManager::Get(basicColor_te myColor)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
return errorColor;
|
||||
}
|
||||
return localManager->Get(myColor);
|
||||
}
|
||||
|
||||
bool ColorizeManager::Exist(etk::UString &colorName)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
return false;
|
||||
}
|
||||
return localManager->Exist(colorName);
|
||||
}
|
||||
|
||||
bool ColorizeManager::Exist(const char *colorName)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
return false;
|
||||
}
|
||||
return localManager->Exist(colorName);
|
||||
}
|
||||
|
||||
void ColorizeManager::DisplayListOfColor(void)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
return;
|
||||
}
|
||||
localManager->DisplayListOfColor();
|
||||
}
|
||||
|
||||
|
||||
|
@@ -26,7 +26,6 @@
|
||||
#ifndef __COLORIZE_MANAGER_H__
|
||||
#define __COLORIZE_MANAGER_H__
|
||||
|
||||
#include <etk/Singleton.h>
|
||||
#include <Colorize.h>
|
||||
#include <MsgBroadcast.h>
|
||||
#include <ewol/Widget.h>
|
||||
@@ -50,31 +49,18 @@ typedef enum {
|
||||
|
||||
|
||||
|
||||
class ColorizeManager: public etk::Singleton<ColorizeManager>, public ewol::Widget
|
||||
namespace ColorizeManager
|
||||
{
|
||||
friend class etk::Singleton<ColorizeManager>;
|
||||
// specific for sigleton system...
|
||||
private:
|
||||
// Constructeur
|
||||
ColorizeManager(void);
|
||||
~ColorizeManager(void);
|
||||
public:
|
||||
bool OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, etkFloat_t x, etkFloat_t y);
|
||||
public:
|
||||
void LoadFile(etk::UString &xmlFilename);
|
||||
void LoadFile(const char * xmlFilename);
|
||||
Colorize * Get(const char *colorName);
|
||||
Colorize * Get(etk::UString &colorName);
|
||||
color_ts & Get(basicColor_te myColor);
|
||||
bool Exist(etk::UString &colorName);
|
||||
bool Exist(const char *colorName);
|
||||
void DisplayListOfColor(void);
|
||||
|
||||
private:
|
||||
etk::UString m_fileColor;
|
||||
etk::VectorType<Colorize*> listMyColor; //!< List of ALL Color
|
||||
Colorize * errorColor;
|
||||
color_ts basicColors[COLOR_NUMBER_MAX];
|
||||
void Init(void);
|
||||
void UnInit(void);
|
||||
void LoadFile(etk::UString &xmlFilename);
|
||||
void LoadFile(const char * xmlFilename);
|
||||
Colorize * Get(const char *colorName);
|
||||
Colorize * Get(etk::UString &colorName);
|
||||
color_ts & Get(basicColor_te myColor);
|
||||
bool Exist(etk::UString &colorName);
|
||||
bool Exist(const char *colorName);
|
||||
void DisplayListOfColor(void);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -1,435 +0,0 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file BufferViewer.cpp
|
||||
* @brief Editeur De N'ours : main textViewer diplayer
|
||||
* @author Edouard DUPIN
|
||||
* @date 04/12/2010
|
||||
* @par Project
|
||||
* Edn
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2010 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
* You can not earn money with this Software (if the source extract from Edn
|
||||
* represent less than 50% of original Sources)
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <tools_debug.h>
|
||||
#include <tools_globals.h>
|
||||
#include <Display.h>
|
||||
#include <BufferView.h>
|
||||
#include <BufferManager.h>
|
||||
#include <ColorizeManager.h>
|
||||
#include <MainWindows.h>
|
||||
#include <ewol/WidgetMessageMultiCast.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "BufferView"
|
||||
|
||||
BufferView::BufferView(void)
|
||||
{
|
||||
// Init link with the buffer Manager
|
||||
m_bufferManager = BufferManager::getInstance();
|
||||
m_colorManager = ColorizeManager::getInstance();
|
||||
SetCanHaveFocus(true);
|
||||
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgBufferListChange);
|
||||
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgBufferState);
|
||||
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgBufferId);
|
||||
m_selectedID = -1;
|
||||
|
||||
}
|
||||
|
||||
BufferView::~BufferView(void)
|
||||
{
|
||||
|
||||
}
|
||||
/*
|
||||
GtkWidget * BufferView::GetMainWidget(void)
|
||||
{
|
||||
return m_widget;
|
||||
}
|
||||
*/
|
||||
bool BufferView::OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, etkFloat_t x, etkFloat_t y)
|
||||
{
|
||||
if (generateEventId == ednMsgBufferListChange) {
|
||||
MarkToReedraw();
|
||||
}else if (generateEventId == ednMsgBufferId) {
|
||||
MarkToReedraw();
|
||||
}else if (generateEventId == ednMsgBufferState) {
|
||||
MarkToReedraw();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
color_ts BufferView::GetBasicBG(void)
|
||||
{
|
||||
return m_colorManager->Get(COLOR_LIST_BG_1);
|
||||
}
|
||||
|
||||
uint32_t BufferView::GetNuberOfColomn(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool BufferView::GetTitle(int32_t colomn, etk::UString &myTitle, color_ts &fg, color_ts &bg)
|
||||
{
|
||||
myTitle = "Buffers : ";
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t BufferView::GetNuberOfRaw(void)
|
||||
{
|
||||
if (NULL != m_bufferManager) {
|
||||
return m_bufferManager->SizeOpen();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool BufferView::GetElement(int32_t colomn, int32_t raw, etk::UString &myTextToWrite, color_ts &fg, color_ts &bg)
|
||||
{
|
||||
etk::File name;
|
||||
bool isModify;
|
||||
basicColor_te selectFG = COLOR_LIST_TEXT_NORMAL;
|
||||
basicColor_te selectBG = COLOR_LIST_BG_1;
|
||||
|
||||
// transforme the ID in the real value ...
|
||||
int32_t realID = m_bufferManager->WitchBuffer(raw+1);
|
||||
if (m_bufferManager->Exist(realID)) {
|
||||
isModify = m_bufferManager->Get(realID)->IsModify();
|
||||
name = m_bufferManager->Get(realID)->GetFileName();
|
||||
char *tmpModify = (char*)" ";
|
||||
if (true == isModify) {
|
||||
tmpModify = (char*)"M";
|
||||
}
|
||||
myTextToWrite = "[";
|
||||
myTextToWrite += realID;
|
||||
myTextToWrite += "](";
|
||||
myTextToWrite += tmpModify;
|
||||
myTextToWrite += ") ";
|
||||
myTextToWrite += name.GetShortFilename();
|
||||
|
||||
if (true == isModify) {
|
||||
selectFG = COLOR_LIST_TEXT_MODIFY;
|
||||
} else {
|
||||
selectFG = COLOR_LIST_TEXT_NORMAL;
|
||||
}
|
||||
if (raw%2==0) {
|
||||
selectBG = COLOR_LIST_BG_1;
|
||||
} else {
|
||||
selectBG = COLOR_LIST_BG_2;
|
||||
}
|
||||
if (m_selectedID == raw) {
|
||||
selectBG = COLOR_LIST_BG_SELECTED;
|
||||
}
|
||||
} else {
|
||||
myTextToWrite = "ERROR";
|
||||
}
|
||||
fg = m_colorManager->Get(selectFG);
|
||||
bg = m_colorManager->Get(selectBG);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BufferView::OnItemEvent(int32_t IdInput, ewol::eventInputType_te typeEvent, int32_t colomn, int32_t raw, etkFloat_t x, etkFloat_t y)
|
||||
{
|
||||
if (typeEvent == ewol::EVENT_INPUT_TYPE_SINGLE) {
|
||||
EDN_INFO("Event on List : IdInput=" << IdInput << " colomn=" << colomn << " raw=" << raw );
|
||||
int32_t selectBuf = m_bufferManager->WitchBuffer(raw+1);
|
||||
if ( 0 <= selectBuf) {
|
||||
m_selectedID = raw;
|
||||
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferId, selectBuf);
|
||||
}
|
||||
}
|
||||
MarkToReedraw();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
gboolean BufferView::CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, gpointer data)
|
||||
{
|
||||
BufferView * self = reinterpret_cast<BufferView*>(data);
|
||||
|
||||
# ifdef USE_GTK_VERSION_3_0
|
||||
GtkAllocation allocation;
|
||||
gtk_widget_get_allocation(widget, &allocation);
|
||||
bool needRedrawAll = false;
|
||||
if (self->m_shawableAreaX != allocation.width) {
|
||||
needRedrawAll = true;
|
||||
self->m_shawableAreaX = allocation.width;
|
||||
}
|
||||
if (self->m_shawableAreaY != allocation.height) {
|
||||
needRedrawAll = true;
|
||||
self->m_shawableAreaY = allocation.height;
|
||||
}
|
||||
# elif defined( USE_GTK_VERSION_2_0)
|
||||
bool needRedrawAll = false;
|
||||
if (self->m_shawableAreaX != widget->allocation.width) {
|
||||
needRedrawAll = true;
|
||||
self->m_shawableAreaX = widget->allocation.width;
|
||||
}
|
||||
if (self->m_shawableAreaY != widget->allocation.height) {
|
||||
needRedrawAll = true;
|
||||
self->m_shawableAreaY = widget->allocation.height;
|
||||
}
|
||||
#endif
|
||||
if (true == needRedrawAll) {
|
||||
//myBuffer->ForceReDraw(true);
|
||||
}
|
||||
EDN_INFO("==========================================================================");
|
||||
EDN_INFO("Request a display of : " << self->m_shawableAreaX << "px * "<< self->m_shawableAreaY<<"px");
|
||||
DrawerManager monDrawer(widget, self->m_shawableAreaX, self->m_shawableAreaY);
|
||||
|
||||
// clean buffer
|
||||
monDrawer.Clean(self->m_colorManager->Get(COLOR_LIST_BG_1));
|
||||
|
||||
// get the number of buffer open
|
||||
int32_t nbBufferOpen = self->m_bufferManager->Size();
|
||||
int32_t i;
|
||||
uint32_t lineID = 0;
|
||||
uint32_t fontHeight = Display::GetFontHeight();
|
||||
basicColor_te selectFG = COLOR_LIST_TEXT_NORMAL;
|
||||
basicColor_te selectBG = COLOR_LIST_BG_1;
|
||||
for (i=0; i < nbBufferOpen; i++) {
|
||||
Edn::File name;
|
||||
bool isModify;
|
||||
if (self->m_bufferManager->Exist(i)) {
|
||||
isModify = self->m_bufferManager->Get(i)->IsModify();
|
||||
name = self->m_bufferManager->Get(i)->GetFileName();
|
||||
char *tmpModify = (char*)" ";
|
||||
if (true == isModify) {
|
||||
tmpModify = (char*)"M";
|
||||
}
|
||||
char name2[1024] = "";
|
||||
sprintf(name2, "[%2d](%s) %s", i, tmpModify, name.GetShortFilename().c_str() );
|
||||
|
||||
if (true == isModify) {
|
||||
selectFG = COLOR_LIST_TEXT_MODIFY;
|
||||
} else {
|
||||
selectFG = COLOR_LIST_TEXT_NORMAL;
|
||||
}
|
||||
if (lineID%2==0) {
|
||||
selectBG = COLOR_LIST_BG_1;
|
||||
} else {
|
||||
selectBG = COLOR_LIST_BG_2;
|
||||
}
|
||||
if (self->m_selectedID == i) {
|
||||
selectBG = COLOR_LIST_BG_SELECTED;
|
||||
}
|
||||
EDN_INFO("color fg=" << selectFG << " bg="<< selectBG);
|
||||
monDrawer.Rectangle(self->m_colorManager->Get(selectBG), 0, lineID*fontHeight, self->m_shawableAreaX, Display::GetFontHeight());
|
||||
|
||||
monDrawer.Text(self->m_colorManager->Get(selectFG), 2, lineID*fontHeight, name2);
|
||||
monDrawer.Flush();
|
||||
lineID ++;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// sur : <20>mis lors du premier affichage de la GtkDrawingArea
|
||||
gboolean BufferView::CB_displayInit( GtkWidget *widget, gpointer data)
|
||||
{
|
||||
BufferView * self = reinterpret_cast<BufferView*>(data);
|
||||
|
||||
# ifdef USE_GTK_VERSION_3_0
|
||||
GtkAllocation allocation;
|
||||
gtk_widget_get_allocation(widget, &allocation);
|
||||
int32_t size_x = allocation.width;
|
||||
int32_t size_y = allocation.height;
|
||||
|
||||
self->m_shawableAreaX = allocation.width;
|
||||
self->m_shawableAreaY = allocation.height;
|
||||
# elif defined( USE_GTK_VERSION_2_0)
|
||||
int32_t size_x = widget->allocation.width;
|
||||
int32_t size_y = widget->allocation.height;
|
||||
|
||||
self->m_shawableAreaX = widget->allocation.width;
|
||||
self->m_shawableAreaY = widget->allocation.height;
|
||||
# endif
|
||||
EDN_INFO("Request a diplay of : " << size_x << "px * " << size_y << "px");
|
||||
|
||||
//Display::InitDisplayParam(self->m_displayParameters, widget, 700, 1200);
|
||||
|
||||
gtk_widget_queue_draw( widget );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gint BufferView::CB_focusGet( GtkWidget *widget, GdkEventFocus *event, gpointer data)
|
||||
{
|
||||
//BufferView * self = reinterpret_cast<BufferView*>(data);
|
||||
|
||||
# ifdef USE_GTK_VERSION_2_0
|
||||
GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS);
|
||||
# endif
|
||||
EDN_INFO("Focus - In");
|
||||
gtk_widget_queue_draw( widget );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gint BufferView::CB_focusLost( GtkWidget *widget, GdkEventFocus *event, gpointer data)
|
||||
{
|
||||
//BufferView * self = reinterpret_cast<BufferView*>(data);
|
||||
|
||||
# ifdef USE_GTK_VERSION_2_0
|
||||
GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS);
|
||||
# endif
|
||||
EDN_INFO("Focus - out");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gint BufferView::CB_keyboardEvent( GtkWidget *widget, GdkEventKey *event, gpointer data)
|
||||
{
|
||||
//BufferView * self = reinterpret_cast<BufferView*>(data);
|
||||
|
||||
if(event->type == GDK_KEY_PRESS) {
|
||||
gtk_widget_queue_draw( widget );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void BufferView::OnPopupEventShow(GtkWidget *menuitem, gpointer data)
|
||||
{
|
||||
BufferView * self = reinterpret_cast<BufferView*>(data);
|
||||
self->SendMessage(EDN_MSG__CURRENT_CHANGE_BUFFER_ID, self->m_contectMenuSelectID);
|
||||
self->m_contectMenuSelectID = -1;
|
||||
}
|
||||
|
||||
void BufferView::OnPopupEventClose(GtkWidget *menuitem, gpointer data)
|
||||
{
|
||||
BufferView * self = reinterpret_cast<BufferView*>(data);
|
||||
self->SendMessage(EDN_MSG__BUFF_ID_CLOSE, self->m_contectMenuSelectID);
|
||||
self->m_contectMenuSelectID = -1;
|
||||
}
|
||||
|
||||
void BufferView::OnPopupEventSave(GtkWidget *menuitem, gpointer data)
|
||||
{
|
||||
BufferView * self = reinterpret_cast<BufferView*>(data);
|
||||
self->SendMessage(EDN_MSG__BUFF_ID_SAVE, self->m_contectMenuSelectID);
|
||||
self->m_contectMenuSelectID = -1;
|
||||
}
|
||||
|
||||
void BufferView::OnPopupEventSaveAs(GtkWidget *menuitem, gpointer data)
|
||||
{
|
||||
BufferView * self = reinterpret_cast<BufferView*>(data);
|
||||
self->SendMessage(EDN_MSG__GUI_SHOW_SAVE_AS, self->m_contectMenuSelectID);
|
||||
self->m_contectMenuSelectID = -1;
|
||||
}
|
||||
|
||||
|
||||
void BufferView::ViewPopupMenu(GtkWidget *parrent, GdkEventButton *event, int32_t BufferID)
|
||||
{
|
||||
// Save the slected buffer
|
||||
m_contectMenuSelectID = BufferID;
|
||||
if (m_bufferManager->Exist(m_contectMenuSelectID)) {
|
||||
GtkWidget *menu, *menuitem;
|
||||
menu = gtk_menu_new();
|
||||
menuitem = gtk_menu_item_new_with_label("Show");
|
||||
g_signal_connect( G_OBJECT(menuitem), "activate", G_CALLBACK(OnPopupEventShow), this);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||
if (true == m_bufferManager->Get(m_contectMenuSelectID)->HaveName()) {
|
||||
if (true == m_bufferManager->Get(m_contectMenuSelectID)->IsModify()) {
|
||||
menuitem = gtk_menu_item_new_with_label("Save");
|
||||
} else {
|
||||
menuitem = gtk_menu_item_new_with_label("Force Save");
|
||||
}
|
||||
g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(OnPopupEventSave), this);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||
}
|
||||
menuitem = gtk_menu_item_new_with_label("Save As ...");
|
||||
g_signal_connect( G_OBJECT(menuitem), "activate", G_CALLBACK(OnPopupEventSaveAs), this);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||
menuitem = gtk_menu_item_new_with_label("Close");
|
||||
g_signal_connect( G_OBJECT(menuitem), "activate", G_CALLBACK(OnPopupEventClose), this);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||
gtk_widget_show_all(menu);
|
||||
// Note: event can be NULL here when called from view_onPopupMenu;
|
||||
// gdk_event_get_time() accepts a NULL argument
|
||||
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
|
||||
(event != NULL) ? event->button : 0,
|
||||
gdk_event_get_time((GdkEvent*)event));
|
||||
} else {
|
||||
EDN_ERROR("Buffer does not Exist !!! " << m_contectMenuSelectID);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
gint BufferView::CB_mouseButtonEvent(GtkWidget *widget, GdkEventButton *event, gpointer data)
|
||||
{
|
||||
BufferView * self = reinterpret_cast<BufferView*>(data);
|
||||
// get focus on the widget
|
||||
gtk_widget_grab_focus(widget);
|
||||
if (event->button == 1) {
|
||||
if (event->type == GDK_BUTTON_PRESS) {
|
||||
EDN_INFO("mouse-event BT1 ==> One Clicked");
|
||||
}else if (event->type == GDK_2BUTTON_PRESS) {
|
||||
//EDN_INFO("mouse-event BT1 ==> Double Clicked %d, %d", (uint32_t)event->x, (uint32_t)event->y);
|
||||
uint32_t fontHeight = Display::GetFontHeight();
|
||||
int32_t selectBuf = self->m_bufferManager->WitchBuffer((event->y / fontHeight) + 1);
|
||||
//EDN_INFO(" plop %d / %d = %d ==> %d", (uint32_t)event->y, fontHeight, ((uint32_t)event->y / fontHeight), selectBuf);
|
||||
if ( 0 <= selectBuf) {
|
||||
self->SendMessage(EDN_MSG__CURRENT_CHANGE_BUFFER_ID, selectBuf);
|
||||
}
|
||||
}
|
||||
} else if (event->button == 3) {
|
||||
if (event->type == GDK_BUTTON_PRESS) {
|
||||
EDN_INFO("mouse-event BT3 PRESS");
|
||||
uint32_t fontHeight = Display::GetFontHeight();
|
||||
int32_t selectBuf = self->m_bufferManager->WitchBuffer((event->y / fontHeight) + 1);
|
||||
if ( 0 <= selectBuf) {
|
||||
self->ViewPopupMenu(widget, event, selectBuf);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// not usefull to redraw
|
||||
return true;
|
||||
}
|
||||
gtk_widget_queue_draw( widget );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
gint BufferView::CB_mouseMotionEvent( GtkWidget *widget, GdkEventMotion *event, gpointer data)
|
||||
{
|
||||
//BufferView * self = reinterpret_cast<BufferView*>(data);
|
||||
|
||||
/*
|
||||
if (true == ButtunOneSelected) {
|
||||
int x, y;
|
||||
GdkModifierType state;
|
||||
|
||||
if (event->is_hint) {
|
||||
gdk_window_get_pointer(event->window, &x, &y, &state);
|
||||
} else {
|
||||
x = event->x;
|
||||
y = event->y;
|
||||
state = (GdkModifierType)event->state;
|
||||
}
|
||||
EDN_INFO("mouse-motion BT1 %d, %d", x, y);
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
152
jni/edn/Gui/BufferView.cpp
Normal file
152
jni/edn/Gui/BufferView.cpp
Normal file
@@ -0,0 +1,152 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file BufferViewer.cpp
|
||||
* @brief Editeur De N'ours : main textViewer diplayer
|
||||
* @author Edouard DUPIN
|
||||
* @date 04/12/2010
|
||||
* @par Project
|
||||
* Edn
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2010 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
* You can not earn money with this Software (if the source extract from Edn
|
||||
* represent less than 50% of original Sources)
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <tools_debug.h>
|
||||
#include <tools_globals.h>
|
||||
#include <Display.h>
|
||||
#include <BufferView.h>
|
||||
#include <BufferManager.h>
|
||||
#include <ColorizeManager.h>
|
||||
#include <MainWindows.h>
|
||||
#include <ewol/EObject.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "BufferView"
|
||||
|
||||
BufferView::BufferView(void)
|
||||
{
|
||||
SetCanHaveFocus(true);
|
||||
RegisterMultiCast(ednMsgBufferListChange);
|
||||
RegisterMultiCast(ednMsgBufferState);
|
||||
RegisterMultiCast(ednMsgBufferId);
|
||||
m_selectedID = -1;
|
||||
}
|
||||
|
||||
BufferView::~BufferView(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Receive a message from an other EObject with a specific eventId and data
|
||||
* @param[in] CallerObject Pointer on the EObject that information came from
|
||||
* @param[in] eventId Message registered by this class
|
||||
* @param[in] data Data registered by this class
|
||||
* @return ---
|
||||
*/
|
||||
void BufferView::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
|
||||
{
|
||||
ewol::List::OnReceiveMessage(CallerObject, eventId, data);
|
||||
if (eventId == ednMsgBufferListChange) {
|
||||
MarkToReedraw();
|
||||
}else if (eventId == ednMsgBufferId) {
|
||||
MarkToReedraw();
|
||||
}else if (eventId == ednMsgBufferState) {
|
||||
MarkToReedraw();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
color_ts BufferView::GetBasicBG(void)
|
||||
{
|
||||
return ColorizeManager::Get(COLOR_LIST_BG_1);
|
||||
}
|
||||
|
||||
uint32_t BufferView::GetNuberOfColomn(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool BufferView::GetTitle(int32_t colomn, etk::UString &myTitle, color_ts &fg, color_ts &bg)
|
||||
{
|
||||
myTitle = "Buffers : ";
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t BufferView::GetNuberOfRaw(void)
|
||||
{
|
||||
return BufferManager::SizeOpen();
|
||||
}
|
||||
|
||||
bool BufferView::GetElement(int32_t colomn, int32_t raw, etk::UString &myTextToWrite, color_ts &fg, color_ts &bg)
|
||||
{
|
||||
etk::File name;
|
||||
bool isModify;
|
||||
basicColor_te selectFG = COLOR_LIST_TEXT_NORMAL;
|
||||
basicColor_te selectBG = COLOR_LIST_BG_1;
|
||||
|
||||
// transforme the ID in the real value ...
|
||||
int32_t realID = BufferManager::WitchBuffer(raw+1);
|
||||
if (BufferManager::Exist(realID)) {
|
||||
isModify = BufferManager::Get(realID)->IsModify();
|
||||
name = BufferManager::Get(realID)->GetFileName();
|
||||
char *tmpModify = (char*)" ";
|
||||
if (true == isModify) {
|
||||
tmpModify = (char*)"M";
|
||||
}
|
||||
myTextToWrite = "[";
|
||||
myTextToWrite += realID;
|
||||
myTextToWrite += "](";
|
||||
myTextToWrite += tmpModify;
|
||||
myTextToWrite += ") ";
|
||||
myTextToWrite += name.GetShortFilename();
|
||||
|
||||
if (true == isModify) {
|
||||
selectFG = COLOR_LIST_TEXT_MODIFY;
|
||||
} else {
|
||||
selectFG = COLOR_LIST_TEXT_NORMAL;
|
||||
}
|
||||
if (raw%2==0) {
|
||||
selectBG = COLOR_LIST_BG_1;
|
||||
} else {
|
||||
selectBG = COLOR_LIST_BG_2;
|
||||
}
|
||||
if (m_selectedID == raw) {
|
||||
selectBG = COLOR_LIST_BG_SELECTED;
|
||||
}
|
||||
} else {
|
||||
myTextToWrite = "ERROR";
|
||||
}
|
||||
fg = ColorizeManager::Get(selectFG);
|
||||
bg = ColorizeManager::Get(selectBG);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BufferView::OnItemEvent(int32_t IdInput, ewol::eventInputType_te typeEvent, int32_t colomn, int32_t raw, etkFloat_t x, etkFloat_t y)
|
||||
{
|
||||
if (1 == IdInput && typeEvent == ewol::EVENT_INPUT_TYPE_SINGLE) {
|
||||
EDN_INFO("Event on List : IdInput=" << IdInput << " colomn=" << colomn << " raw=" << raw );
|
||||
int32_t selectBuf = BufferManager::WitchBuffer(raw+1);
|
||||
if ( 0 <= selectBuf) {
|
||||
m_selectedID = raw;
|
||||
SendMultiCast(ednMsgBufferId, selectBuf);
|
||||
}
|
||||
}
|
||||
MarkToReedraw();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -40,7 +40,14 @@ class BufferView : public ewol::List
|
||||
// Constructeur
|
||||
BufferView(void);
|
||||
~BufferView(void);
|
||||
bool OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, etkFloat_t x, etkFloat_t y);
|
||||
/**
|
||||
* @brief Receive a message from an other EObject with a specific eventId and data
|
||||
* @param[in] CallerObject Pointer on the EObject that information came from
|
||||
* @param[in] eventId Message registered by this class
|
||||
* @param[in] data Data registered by this class
|
||||
* @return ---
|
||||
*/
|
||||
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
|
||||
protected:
|
||||
// function call to display the list :
|
||||
virtual color_ts GetBasicBG(void);
|
||||
@@ -50,9 +57,6 @@ class BufferView : public ewol::List
|
||||
virtual bool GetElement(int32_t colomn, int32_t raw, etk::UString &myTextToWrite, color_ts &fg, color_ts &bg);
|
||||
virtual bool OnItemEvent(int32_t IdInput, ewol::eventInputType_te typeEvent, int32_t colomn, int32_t raw, etkFloat_t x, etkFloat_t y);
|
||||
private:
|
||||
// récupération des proprieter général...
|
||||
BufferManager * m_bufferManager;
|
||||
ColorizeManager * m_colorManager;
|
||||
int32_t m_selectedID;
|
||||
};
|
||||
|
@@ -36,7 +36,7 @@
|
||||
#include <SearchData.h>
|
||||
|
||||
#include <ewol/WidgetManager.h>
|
||||
#include <ewol/WidgetMessageMultiCast.h>
|
||||
#include <ewol/EObject.h>
|
||||
|
||||
|
||||
#undef __class__
|
||||
@@ -55,10 +55,6 @@ CodeView::CodeView(void)
|
||||
m_bufferID = -1;
|
||||
m_buttunOneSelected = false;
|
||||
|
||||
// Init link with the buffer Manager
|
||||
m_bufferManager = BufferManager::getInstance();
|
||||
m_colorManager = ColorizeManager::getInstance();
|
||||
|
||||
m_textColorFg.red = 0.0;
|
||||
m_textColorFg.green = 0.0;
|
||||
m_textColorFg.blue = 0.0;
|
||||
@@ -69,7 +65,7 @@ CodeView::CodeView(void)
|
||||
m_textColorBg.blue = 0.0;
|
||||
m_textColorBg.alpha = 0.25;
|
||||
SetCanHaveFocus(true);
|
||||
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgBufferId);
|
||||
RegisterMultiCast(ednMsgBufferId);
|
||||
}
|
||||
|
||||
CodeView::~CodeView(void)
|
||||
@@ -88,40 +84,54 @@ void CodeView::CalculateMaxSize(void)
|
||||
{
|
||||
m_maxSize.x = 2048;
|
||||
int32_t letterHeight = ewol::GetHeight(m_fontNormal);
|
||||
m_maxSize.y = m_bufferManager->Get(m_bufferID)->GetNumberOfLine() * letterHeight;
|
||||
m_maxSize.y = BufferManager::Get(m_bufferID)->GetNumberOfLine() * letterHeight;
|
||||
}
|
||||
|
||||
|
||||
void CodeView::OnDraw(void)
|
||||
{
|
||||
m_OObjectsColored[ m_currentDrawId].Draw();
|
||||
m_OObjectTextNormal[ m_currentDrawId].Draw();
|
||||
m_OObjectTextBold[ m_currentDrawId].Draw();
|
||||
m_OObjectTextItalic[ m_currentDrawId].Draw();
|
||||
m_OObjectTextBoldItalic[m_currentDrawId].Draw();
|
||||
}
|
||||
|
||||
void CodeView::OnRegenerateDisplay(void)
|
||||
{
|
||||
if (true == NeedRedraw()) {
|
||||
int64_t startTime = GetCurrentTime();
|
||||
|
||||
// For the scrooling windows
|
||||
CalculateMaxSize();
|
||||
|
||||
// create tmp object :
|
||||
ewol::OObject2DTextColored* myOObjectTextNormal = new ewol::OObject2DTextColored(m_fontNormal);
|
||||
ewol::OObject2DTextColored* myOObjectTextBold = new ewol::OObject2DTextColored(m_fontBold);
|
||||
ewol::OObject2DTextColored* myOObjectTextItalic = new ewol::OObject2DTextColored(m_fontItalic);
|
||||
ewol::OObject2DTextColored* myOObjectTextBoldItalic = new ewol::OObject2DTextColored(m_fontBoldItalic);
|
||||
ewol::OObject2DColored* myOObjectsColored = new ewol::OObject2DColored();
|
||||
// clean internal elements ...
|
||||
m_OObjectTextNormal[ m_currentCreateId].SetFontID(m_fontNormal);
|
||||
m_OObjectTextBold[ m_currentCreateId].SetFontID(m_fontBold);
|
||||
m_OObjectTextItalic[ m_currentCreateId].SetFontID(m_fontItalic);
|
||||
m_OObjectTextBoldItalic[m_currentCreateId].SetFontID(m_fontBoldItalic);
|
||||
|
||||
m_OObjectTextNormal[ m_currentCreateId].Clear();
|
||||
m_OObjectTextBold[ m_currentCreateId].Clear();
|
||||
m_OObjectTextItalic[ m_currentCreateId].Clear();
|
||||
m_OObjectTextBoldItalic[m_currentCreateId].Clear();
|
||||
m_OObjectsColored[ m_currentCreateId].Clear();
|
||||
|
||||
|
||||
// generate the objects :
|
||||
//m_bufferID = 0;
|
||||
m_bufferManager->Get(m_bufferID)->Display(myOObjectTextNormal, myOObjectTextBold, myOObjectTextItalic, myOObjectTextBoldItalic, myOObjectsColored,
|
||||
m_originScrooled.x, m_originScrooled.y, m_size.x, m_size.y);
|
||||
BufferManager::Get(m_bufferID)->Display(m_OObjectTextNormal[m_currentCreateId],
|
||||
m_OObjectTextBold[m_currentCreateId],
|
||||
m_OObjectTextItalic[m_currentCreateId],
|
||||
m_OObjectTextBoldItalic[m_currentCreateId],
|
||||
m_OObjectsColored[m_currentCreateId],
|
||||
m_originScrooled.x, m_originScrooled.y, m_size.x, m_size.y);
|
||||
|
||||
// clean the object list ...
|
||||
ClearOObjectList();
|
||||
// add generated element
|
||||
AddOObject(myOObjectsColored, "CodeViewBackground");
|
||||
AddOObject(myOObjectTextNormal, "CodeViewTextNormal");
|
||||
AddOObject(myOObjectTextBold, "CodeViewTextBold");
|
||||
AddOObject(myOObjectTextItalic, "CodeViewTextItalic");
|
||||
AddOObject(myOObjectTextBoldItalic, "CodeViewTextBoldItalic");
|
||||
int64_t stopTime = GetCurrentTime();
|
||||
EDN_DEBUG("Display Code Generation = " << stopTime - startTime << " milli-s");
|
||||
|
||||
// call the herited class...
|
||||
WidgetScrooled::OnRegenerateDisplay();
|
||||
m_needFlipFlop = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +140,7 @@ bool CodeView::OnEventKb(ewol::eventKbType_te typeEvent, uniChar_t unicodeData)
|
||||
{
|
||||
//EDN_DEBUG("KB EVENT : \"" << UTF8_data << "\" size=" << strlen(UTF8_data) << "type=" << (int32_t)typeEvent);
|
||||
if (typeEvent == ewol::EVENT_KB_TYPE_DOWN) {
|
||||
m_bufferManager->Get(m_bufferID)->AddChar(unicodeData);
|
||||
BufferManager::Get(m_bufferID)->AddChar(unicodeData);
|
||||
MarkToReedraw();
|
||||
}
|
||||
return true;
|
||||
@@ -140,59 +150,64 @@ bool CodeView::OnEventKb(ewol::eventKbType_te typeEvent, uniChar_t unicodeData)
|
||||
bool CodeView::OnEventKbMove(ewol::eventKbType_te typeEvent, ewol::eventKbMoveType_te moveTypeEvent)
|
||||
{
|
||||
if (typeEvent == ewol::EVENT_KB_TYPE_DOWN) {
|
||||
m_bufferManager->Get(m_bufferID)->cursorMove(moveTypeEvent);
|
||||
BufferManager::Get(m_bufferID)->cursorMove(moveTypeEvent);
|
||||
MarkToReedraw();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool CodeView::OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y)
|
||||
/**
|
||||
* @brief Event on an input of this Widget
|
||||
* @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger))
|
||||
* @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/...
|
||||
* @param[in] pos Absolute position of the event
|
||||
* @return true the event is used
|
||||
* @return false the event is not used
|
||||
*/
|
||||
bool CodeView::OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent, coord2D_ts pos)
|
||||
{
|
||||
if (true == WidgetScrooled::OnEventInput(IdInput, typeEvent, x, y)) {
|
||||
coord2D_ts relativePos = RelativePosition(pos);
|
||||
if (m_bufferID < 0) {
|
||||
return false;
|
||||
}
|
||||
if (true == WidgetScrooled::OnEventInput(IdInput, typeEvent, pos)) {
|
||||
ewol::widgetManager::FocusKeep(this);
|
||||
// nothing to do ... done on upper widet ...
|
||||
return true;
|
||||
}
|
||||
x -= m_origin.x;
|
||||
y -= m_origin.y;
|
||||
if (1 == IdInput) {
|
||||
#ifndef __MODE__Touch
|
||||
if (ewol::EVENT_INPUT_TYPE_DOWN == typeEvent) {
|
||||
m_buttunOneSelected = true;
|
||||
ewol::widgetManager::FocusKeep(this);
|
||||
//EDN_INFO("mouse-event BT1 ==> One Clicked %d, %d", (uint32_t)event->x, (uint32_t)event->y);
|
||||
m_bufferManager->Get(m_bufferID)->MouseEvent(x, y);
|
||||
BufferManager::Get(m_bufferID)->MouseEvent(m_fontNormal, relativePos.x+m_originScrooled.x, relativePos.y+m_originScrooled.y);
|
||||
MarkToReedraw();
|
||||
} else if (ewol::EVENT_INPUT_TYPE_UP == typeEvent) {
|
||||
m_buttunOneSelected = false;
|
||||
m_bufferManager->Get(m_bufferID)->Copy(COPY_MIDDLE_BUTTON);
|
||||
BufferManager::Get(m_bufferID)->Copy(COPY_MIDDLE_BUTTON);
|
||||
MarkToReedraw();
|
||||
} else
|
||||
#endif
|
||||
if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) {
|
||||
#ifdef __MODE__Touch
|
||||
ewol::widgetManager::FocusKeep(this);
|
||||
//EDN_INFO("mouse-event BT1 ==> One Clicked %d, %d", (uint32_t)event->x, (uint32_t)event->y);
|
||||
m_bufferManager->Get(m_bufferID)->MouseEvent(x, y);
|
||||
BufferManager::Get(m_bufferID)->MouseEvent(m_fontNormal, relativePos.x+m_originScrooled.x, relativePos.y+m_originScrooled.y);
|
||||
MarkToReedraw();
|
||||
#else
|
||||
// nothing to do ...
|
||||
#endif
|
||||
} else if (ewol::EVENT_INPUT_TYPE_DOUBLE == typeEvent) {
|
||||
//EDN_INFO("mouse-event BT1 ==> Double Clicked %d, %d", (uint32_t)event->x, (uint32_t)event->y);
|
||||
m_bufferManager->Get(m_bufferID)->MouseEventDouble();
|
||||
BufferManager::Get(m_bufferID)->MouseEventDouble();
|
||||
MarkToReedraw();
|
||||
} else if (ewol::EVENT_INPUT_TYPE_TRIPLE == typeEvent) {
|
||||
//EDN_INFO("mouse-event BT1 ==> Triple Clicked");
|
||||
m_bufferManager->Get(m_bufferID)->MouseEventTriple();
|
||||
BufferManager::Get(m_bufferID)->MouseEventTriple();
|
||||
MarkToReedraw();
|
||||
} else if (ewol::EVENT_INPUT_TYPE_MOVE == typeEvent) {
|
||||
if (true == m_buttunOneSelected) {
|
||||
int xxx, yyy;
|
||||
xxx = x;
|
||||
yyy = y;
|
||||
xxx = relativePos.x;
|
||||
yyy = relativePos.y;
|
||||
if (xxx<0) {
|
||||
xxx = 0;
|
||||
}
|
||||
@@ -200,14 +215,14 @@ bool CodeView::OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent,
|
||||
yyy = 0;
|
||||
}
|
||||
//EDN_INFO("mouse-motion BT1 %d, %d", xxx, yyy);
|
||||
m_bufferManager->Get(m_bufferID)->MouseSelectFromCursorTo(xxx, yyy);
|
||||
BufferManager::Get(m_bufferID)->MouseSelectFromCursorTo(m_fontNormal, xxx, yyy);
|
||||
MarkToReedraw();
|
||||
}
|
||||
}
|
||||
} else if (2 == IdInput) {
|
||||
if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) {
|
||||
m_bufferManager->Get(m_bufferID)->MouseEvent(x, y);
|
||||
m_bufferManager->Get(m_bufferID)->Paste(COPY_MIDDLE_BUTTON);
|
||||
BufferManager::Get(m_bufferID)->MouseEvent(m_fontNormal, relativePos.x+m_originScrooled.x, relativePos.y+m_originScrooled.y);
|
||||
BufferManager::Get(m_bufferID)->Paste(COPY_MIDDLE_BUTTON);
|
||||
MarkToReedraw();
|
||||
ewol::widgetManager::FocusKeep(this);
|
||||
}
|
||||
@@ -217,18 +232,25 @@ bool CodeView::OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent,
|
||||
|
||||
|
||||
|
||||
bool CodeView::OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * data, etkFloat_t x, etkFloat_t y)
|
||||
/**
|
||||
* @brief Receive a message from an other EObject with a specific eventId and data
|
||||
* @param[in] CallerObject Pointer on the EObject that information came from
|
||||
* @param[in] eventId Message registered by this class
|
||||
* @param[in] data Data registered by this class
|
||||
* @return ---
|
||||
*/
|
||||
void CodeView::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
|
||||
{
|
||||
EDN_DEBUG("Extern Event : " << widgetID << " type : " << generateEventId << " position(" << x << "," << y << ")");
|
||||
ewol::WidgetScrooled::OnReceiveMessage(CallerObject, eventId, data);
|
||||
EDN_DEBUG("Extern Event : " << CallerObject << " type : " << eventId << " data=\"" << data << "\"");
|
||||
|
||||
|
||||
|
||||
if( ednMsgBufferId == generateEventId) {
|
||||
if(eventId == ednMsgBufferId) {
|
||||
int32_t bufferID = 0;
|
||||
sscanf(data, "%d", &bufferID);
|
||||
sscanf(data.Utf8Data(), "%d", &bufferID);
|
||||
EDN_INFO("Select a new Buffer ... " << bufferID);
|
||||
m_bufferID = bufferID;
|
||||
m_bufferManager->Get(m_bufferID)->ForceReDraw(true);
|
||||
// TODO : need to update the state of the file and the filenames ...
|
||||
}
|
||||
// old
|
||||
@@ -238,7 +260,7 @@ bool CodeView::OnEventAreaExternal(int32_t widgetID, const char * generateEventI
|
||||
sscanf(data, "%d", &bufferID);
|
||||
EDN_INFO("Select a new Buffer ... " << bufferID);
|
||||
m_bufferID = bufferID;
|
||||
m_bufferManager->Get(m_bufferID)->ForceReDraw(true);
|
||||
BufferManager::Get(m_bufferID)->ForceReDraw(true);
|
||||
// request the display of the curent Editor
|
||||
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferChangeCurrent, (char*)data);
|
||||
|
||||
@@ -293,7 +315,7 @@ bool CodeView::OnEventAreaExternal(int32_t widgetID, const char * generateEventI
|
||||
case EDN_MSG__CURRENT_CHANGE_BUFFER_ID:
|
||||
EDN_INFO("Select a new Buffer ... " << dataID);
|
||||
m_bufferID = dataID;
|
||||
m_bufferManager->Get(m_bufferID)->ForceReDraw(true);
|
||||
BufferManager::Get(m_bufferID)->ForceReDraw(true);
|
||||
// request the display of the curent Editor
|
||||
SendMessage(EDN_MSG__BUFFER_CHANGE_CURRENT, m_bufferID);
|
||||
break;
|
||||
@@ -304,51 +326,51 @@ bool CodeView::OnEventAreaExternal(int32_t widgetID, const char * generateEventI
|
||||
SendMessage(EDN_MSG__GUI_SHOW_SAVE_AS, m_bufferID);
|
||||
break;
|
||||
case EDN_MSG__CURRENT_REMOVE_LINE:
|
||||
m_bufferManager->Get(m_bufferID)->RemoveLine();
|
||||
BufferManager::Get(m_bufferID)->RemoveLine();
|
||||
break;
|
||||
case EDN_MSG__CURRENT_SELECT_ALL:
|
||||
m_bufferManager->Get(m_bufferID)->SelectAll();
|
||||
BufferManager::Get(m_bufferID)->SelectAll();
|
||||
break;
|
||||
case EDN_MSG__CURRENT_UN_SELECT:
|
||||
m_bufferManager->Get(m_bufferID)->SelectNone();
|
||||
BufferManager::Get(m_bufferID)->SelectNone();
|
||||
break;
|
||||
case EDN_MSG__CURRENT_COPY:
|
||||
if (dataID == -1) {
|
||||
dataID = COPY_STD;
|
||||
}
|
||||
m_bufferManager->Get(m_bufferID)->Copy(dataID);
|
||||
BufferManager::Get(m_bufferID)->Copy(dataID);
|
||||
break;
|
||||
case EDN_MSG__CURRENT_CUT:
|
||||
if (dataID == -1) {
|
||||
dataID = COPY_STD;
|
||||
}
|
||||
m_bufferManager->Get(m_bufferID)->Cut(dataID);
|
||||
BufferManager::Get(m_bufferID)->Cut(dataID);
|
||||
break;
|
||||
case EDN_MSG__CURRENT_PASTE:
|
||||
if (dataID == -1) {
|
||||
dataID = COPY_STD;
|
||||
}
|
||||
m_bufferManager->Get(m_bufferID)->Paste(dataID);
|
||||
BufferManager::Get(m_bufferID)->Paste(dataID);
|
||||
break;
|
||||
case EDN_MSG__CURRENT_FIND_PREVIOUS:
|
||||
{
|
||||
etk::UString myDataString;
|
||||
SearchData::GetSearch(myDataString);
|
||||
m_bufferManager->Get(m_bufferID)->Search(myDataString, true, SearchData::GetCase(), SearchData::GetWrap(), SearchData::GetRegExp() );
|
||||
BufferManager::Get(m_bufferID)->Search(myDataString, true, SearchData::GetCase(), SearchData::GetWrap(), SearchData::GetRegExp() );
|
||||
}
|
||||
break;
|
||||
case EDN_MSG__CURRENT_FIND_NEXT:
|
||||
{
|
||||
etk::UString myDataString;
|
||||
SearchData::GetSearch(myDataString);
|
||||
m_bufferManager->Get(m_bufferID)->Search(myDataString, false, SearchData::GetCase(), SearchData::GetWrap(), SearchData::GetRegExp() );
|
||||
BufferManager::Get(m_bufferID)->Search(myDataString, false, SearchData::GetCase(), SearchData::GetWrap(), SearchData::GetRegExp() );
|
||||
}
|
||||
break;
|
||||
case EDN_MSG__CURRENT_REPLACE:
|
||||
{
|
||||
etk::UString myDataString;
|
||||
SearchData::GetReplace(myDataString);
|
||||
m_bufferManager->Get(m_bufferID)->Replace(myDataString);
|
||||
BufferManager::Get(m_bufferID)->Replace(myDataString);
|
||||
}
|
||||
break;
|
||||
case EDN_MSG__CURRENT_REPLACE_ALL:
|
||||
@@ -357,21 +379,21 @@ bool CodeView::OnEventAreaExternal(int32_t widgetID, const char * generateEventI
|
||||
SendMessage(EDN_MSG__BUFF_ID_CLOSE, m_bufferID);
|
||||
break;
|
||||
case EDN_MSG__CURRENT_UNDO:
|
||||
m_bufferManager->Get(m_bufferID)->Undo();
|
||||
BufferManager::Get(m_bufferID)->Undo();
|
||||
break;
|
||||
case EDN_MSG__CURRENT_REDO:
|
||||
m_bufferManager->Get(m_bufferID)->Redo();
|
||||
BufferManager::Get(m_bufferID)->Redo();
|
||||
break;
|
||||
case EDN_MSG__CURRENT_GOTO_LINE:
|
||||
if (dataID<0) {
|
||||
dataID = 0;
|
||||
}
|
||||
m_bufferManager->Get(m_bufferID)->JumpAtLine(dataID);
|
||||
BufferManager::Get(m_bufferID)->JumpAtLine(dataID);
|
||||
break;
|
||||
case EDN_MSG__REFRESH_DISPLAY:
|
||||
break;
|
||||
case EDN_MSG__CURRENT_SET_CHARSET:
|
||||
m_bufferManager->Get(m_bufferID)->SetCharset((unicode::charset_te)dataID);
|
||||
BufferManager::Get(m_bufferID)->SetCharset((unicode::charset_te)dataID);
|
||||
break;
|
||||
case EDN_MSG__USER_DISPLAY_CHANGE:
|
||||
// Redraw all the display ... Done under ...
|
||||
@@ -380,13 +402,14 @@ bool CodeView::OnEventAreaExternal(int32_t widgetID, const char * generateEventI
|
||||
*/
|
||||
// Force redraw of the widget
|
||||
MarkToReedraw();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CodeView::OnGetFocus(void)
|
||||
{
|
||||
/*
|
||||
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferId, m_bufferID);
|
||||
*/
|
||||
ewol::KeyboardShow(ewol::KEYBOARD_MODE_CODE);
|
||||
EDN_INFO("Focus - In");
|
||||
}
|
@@ -42,18 +42,38 @@ class CodeView :public ewol::WidgetScrooled
|
||||
virtual ~CodeView(void);
|
||||
virtual bool CalculateMinSize(void);
|
||||
private:
|
||||
etk::UString m_label;
|
||||
color_ts m_textColorFg; //!< Text color
|
||||
color_ts m_textColorBg; //!< Background color
|
||||
BufferManager * m_bufferManager;
|
||||
ColorizeManager * m_colorManager;
|
||||
int32_t m_bufferID;
|
||||
bool m_buttunOneSelected;
|
||||
etk::UString m_label;
|
||||
color_ts m_textColorFg; //!< Text color
|
||||
color_ts m_textColorBg; //!< Background color
|
||||
int32_t m_bufferID;
|
||||
bool m_buttunOneSelected;
|
||||
// drawing elements :
|
||||
ewol::OObject2DTextColored m_OObjectTextNormal[NB_BOUBLE_BUFFER];
|
||||
ewol::OObject2DTextColored m_OObjectTextBold[NB_BOUBLE_BUFFER];
|
||||
ewol::OObject2DTextColored m_OObjectTextItalic[NB_BOUBLE_BUFFER];
|
||||
ewol::OObject2DTextColored m_OObjectTextBoldItalic[NB_BOUBLE_BUFFER];
|
||||
ewol::OObject2DColored m_OObjectsColored[NB_BOUBLE_BUFFER];
|
||||
|
||||
public:
|
||||
virtual void OnRegenerateDisplay(void);
|
||||
bool OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, etkFloat_t x, etkFloat_t y);
|
||||
/**
|
||||
* @brief Receive a message from an other EObject with a specific eventId and data
|
||||
* @param[in] CallerObject Pointer on the EObject that information came from
|
||||
* @param[in] eventId Message registered by this class
|
||||
* @param[in] data Data registered by this class
|
||||
* @return ---
|
||||
*/
|
||||
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
|
||||
public:
|
||||
virtual bool OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y);
|
||||
/**
|
||||
* @brief Event on an input of this Widget
|
||||
* @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger))
|
||||
* @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/...
|
||||
* @param[in] pos Absolute position of the event
|
||||
* @return true the event is used
|
||||
* @return false the event is not used
|
||||
*/
|
||||
virtual bool OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent, coord2D_ts pos);
|
||||
virtual bool OnEventKb(ewol::eventKbType_te typeEvent, uniChar_t unicodeData);
|
||||
virtual bool OnEventKbMove(ewol::eventKbType_te typeEvent, ewol::eventKbMoveType_te moveTypeEvent);
|
||||
virtual void OnGetFocus(void);
|
||||
@@ -72,6 +92,8 @@ class CodeView :public ewol::WidgetScrooled
|
||||
void SetFontNameBoldItalic(etk::UString fontName);
|
||||
private:
|
||||
void CalculateMaxSize(void);
|
||||
protected:
|
||||
virtual void OnDraw(void);
|
||||
};
|
||||
|
||||
#endif
|
287
jni/edn/Gui/MainWindows.cpp
Normal file
287
jni/edn/Gui/MainWindows.cpp
Normal file
@@ -0,0 +1,287 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file MainWindows.cpp
|
||||
* @brief Editeur De N'ours : main Windows diplayer (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 04/01/2011
|
||||
* @par Project
|
||||
* Edn
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2010 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
* You can not earn money with this Software (if the source extract from Edn
|
||||
* represent less than 50% of original Sources)
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <tools_debug.h>
|
||||
#include <tools_globals.h>
|
||||
#include <MainWindows.h>
|
||||
#include <CodeView.h>
|
||||
#include <ClipBoard.h>
|
||||
#include <BufferView.h>
|
||||
|
||||
#include <ewol/widget/Button.h>
|
||||
#include <ewol/widget/CheckBox.h>
|
||||
#include <ewol/widget/SizerHori.h>
|
||||
#include <ewol/widget/SizerVert.h>
|
||||
#include <ewol/widget/Label.h>
|
||||
#include <ewol/widget/Entry.h>
|
||||
#include <ewol/widget/List.h>
|
||||
#include <ewol/widget/ContextMenu.h>
|
||||
#include <ewol/widget/PopUp.h>
|
||||
#include <ewol/widget/Spacer.h>
|
||||
#include <ewol/widget/Menu.h>
|
||||
#include <ewol/widgetMeta/FileChooser.h>
|
||||
#include <ewol/WidgetManager.h>
|
||||
#include <ewol/EObject.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "MainWindows"
|
||||
|
||||
MainWindows::MainWindows(void)
|
||||
{
|
||||
EDN_DEBUG("CREATE WINDOWS ... ");
|
||||
ewol::SizerVert * mySizerVert = NULL;
|
||||
ewol::SizerHori * mySizerHori = NULL;
|
||||
//ewol::Button * myButton = NULL;
|
||||
CodeView * myCodeView = NULL;
|
||||
BufferView * myBufferView = NULL;
|
||||
ewol::Menu * myMenu = NULL;
|
||||
|
||||
mySizerVert = new ewol::SizerVert();
|
||||
SetSubWidget(mySizerVert);
|
||||
|
||||
mySizerHori = new ewol::SizerHori();
|
||||
mySizerVert->SubWidgetAdd(mySizerHori);
|
||||
|
||||
myMenu = new ewol::Menu();
|
||||
mySizerHori->SubWidgetAdd(myMenu);
|
||||
int32_t idMenuFile = myMenu->AddTitle("File");
|
||||
(void)myMenu->Add(idMenuFile, "New", "", ednMsgGuiNew);
|
||||
(void)myMenu->AddSpacer();
|
||||
(void)myMenu->Add(idMenuFile, "Open", "", ednMsgGuiOpen);
|
||||
(void)myMenu->Add(idMenuFile, "Close", "", ednMsgGuiClose, "current");
|
||||
(void)myMenu->Add(idMenuFile, "Close (all)", "", ednMsgGuiClose, "All");
|
||||
(void)myMenu->Add(idMenuFile, "Save", "", ednMsgGuiSave, "current");
|
||||
(void)myMenu->Add(idMenuFile, "Save As ...", "", ednMsgGuiSaveAs);
|
||||
(void)myMenu->AddSpacer();
|
||||
//(void)myMenu->Add(idMenuFile, "Exit", "", ednMsgGuiExit);
|
||||
int32_t idMenuEdit = myMenu->AddTitle("Edit");
|
||||
(void)myMenu->Add(idMenuEdit, "Undo", "", ednMsgGuiUndo);
|
||||
(void)myMenu->Add(idMenuEdit, "Redo", "", ednMsgGuiRedo);
|
||||
(void)myMenu->AddSpacer();
|
||||
(void)myMenu->Add(idMenuEdit, "Copy", "", ednMsgGuiCopy, "STD");
|
||||
(void)myMenu->Add(idMenuEdit, "Cut", "", ednMsgGuiCut, "STD");
|
||||
(void)myMenu->Add(idMenuEdit, "Paste", "", ednMsgGuiPaste, "STD");
|
||||
(void)myMenu->Add(idMenuEdit, "Redo", "", ednMsgGuiRedo);
|
||||
(void)myMenu->Add(idMenuEdit, "Remove","", ednMsgGuiRm);
|
||||
(void)myMenu->AddSpacer();
|
||||
(void)myMenu->Add(idMenuEdit, "Select All","", ednMsgGuiSelect, "ALL");
|
||||
(void)myMenu->Add(idMenuEdit, "Un-Select","", ednMsgGuiSelect, "NONE");
|
||||
(void)myMenu->Add(idMenuEdit, "Goto line ...","", ednMsgGuiGotoLine, "???");
|
||||
int32_t idMenuSearch = myMenu->AddTitle("Search");
|
||||
(void)myMenu->Add(idMenuSearch, "Search", "", ednMsgGuiSearch);
|
||||
(void)myMenu->Add(idMenuSearch, "Replace", "", ednMsgGuiReplace);
|
||||
(void)myMenu->AddSpacer();
|
||||
(void)myMenu->Add(idMenuSearch, "Find (previous)","", ednMsgGuiFind, "Previous");
|
||||
(void)myMenu->Add(idMenuSearch, "Find (next)", "", ednMsgGuiFind, "Next");
|
||||
(void)myMenu->Add(idMenuSearch, "Find (all)", "", ednMsgGuiFind, "All");
|
||||
(void)myMenu->Add(idMenuSearch, "Un-Select", "", ednMsgGuiFind, "None");
|
||||
int32_t idMenuCTags = myMenu->AddTitle("C-tags");
|
||||
(void)myMenu->Add(idMenuCTags, "Load", "", ednMsgGuiCtags, "Load");
|
||||
(void)myMenu->Add(idMenuCTags, "ReLoad", "", ednMsgGuiCtags, "ReLoad");
|
||||
(void)myMenu->Add(idMenuCTags, "Jump", "", ednMsgGuiCtags, "Jump");
|
||||
(void)myMenu->Add(idMenuCTags, "Back", "", ednMsgGuiCtags, "Back");
|
||||
(void)myMenu->AddTitle("?", "", ednMsgGuiAbout);
|
||||
|
||||
m_widgetLabelFileName = new ewol::Label("FileName");
|
||||
m_widgetLabelFileName->SetExpendX(true);
|
||||
m_widgetLabelFileName->SetFillY(true);
|
||||
mySizerHori->SubWidgetAdd(m_widgetLabelFileName);
|
||||
|
||||
mySizerHori = new ewol::SizerHori();
|
||||
mySizerVert->SubWidgetAdd(mySizerHori);
|
||||
myBufferView = new BufferView();
|
||||
myBufferView->SetExpendX(false);
|
||||
myBufferView->SetExpendY(true);
|
||||
myBufferView->SetFillX(true);
|
||||
myBufferView->SetFillY(true);
|
||||
mySizerHori->SubWidgetAdd(myBufferView);
|
||||
myCodeView = new CodeView();
|
||||
myCodeView->SetExpendX(true);
|
||||
myCodeView->SetExpendY(true);
|
||||
myCodeView->SetFillX(true);
|
||||
myCodeView->SetFillY(true);
|
||||
|
||||
myCodeView->SetFontSize(11);
|
||||
myCodeView->SetFontNameNormal( "freefont/FreeMono.ttf");
|
||||
myCodeView->SetFontNameBold( "freefont/FreeMonoBold.ttf");
|
||||
myCodeView->SetFontNameItalic( "freefont/FreeMonoOblique.ttf");
|
||||
myCodeView->SetFontNameBoldItalic("freefont/FreeMonoBoldOblique.ttf");
|
||||
/*
|
||||
myCodeView->SetFontSize(11);
|
||||
myCodeView->SetFontNameNormal( "ubuntu/UbuntuMono-R.ttf");
|
||||
myCodeView->SetFontNameBold( "ubuntu/UbuntuMono-B.ttf");
|
||||
myCodeView->SetFontNameItalic( "ubuntu/UbuntuMono-RI.ttf");
|
||||
myCodeView->SetFontNameBoldItalic("ubuntu/UbuntuMono-BI.ttf");
|
||||
*/
|
||||
mySizerHori->SubWidgetAdd(myCodeView);
|
||||
|
||||
// Generic event ...
|
||||
RegisterMultiCast(ednMsgGuiSaveAs);
|
||||
RegisterMultiCast(ednMsgGuiOpen);
|
||||
RegisterMultiCast(ednMsgGuiAbout);
|
||||
// to update the title ...
|
||||
RegisterMultiCast(ednMsgBufferState);
|
||||
RegisterMultiCast(ednMsgBufferId);
|
||||
}
|
||||
|
||||
|
||||
MainWindows::~MainWindows(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const char *const ednEventPopUpFileSelected = "edn-mainWindows-openSelected";
|
||||
const char *const ednEventPopUpFileSaveAs = "edn-mainWindows-saveAsSelected";
|
||||
|
||||
/**
|
||||
* @brief Receive a message from an other EObject with a specific eventId and data
|
||||
* @param[in] CallerObject Pointer on the EObject that information came from
|
||||
* @param[in] eventId Message registered by this class
|
||||
* @param[in] data Data registered by this class
|
||||
* @return ---
|
||||
*/
|
||||
void MainWindows::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
|
||||
{
|
||||
ewol::Windows::OnReceiveMessage(CallerObject, eventId, data);
|
||||
|
||||
EDN_INFO("Receive Event from the main windows ... : widgetid=" << CallerObject << "\"" << eventId << "\" ==> data=\"" << data << "\"" );
|
||||
// Open file Section ...
|
||||
if (eventId == ednMsgGuiOpen) {
|
||||
ewol::FileChooser* tmpWidget = new ewol::FileChooser();
|
||||
tmpWidget->SetTitle("Open Files ...");
|
||||
tmpWidget->SetValidateLabel("Open");
|
||||
// TODO : Set the good folder ...
|
||||
//tmpWidget->SetFolder("/");
|
||||
PopUpWidgetPush(tmpWidget);
|
||||
tmpWidget->RegisterOnEvent(this, ewolEventFileChooserValidate, ednEventPopUpFileSelected);
|
||||
} else if (eventId == ednEventPopUpFileSelected) {
|
||||
// get widget:
|
||||
ewol::FileChooser * tmpWidget = static_cast<ewol::FileChooser*>(CallerObject);
|
||||
if (NULL == tmpWidget) {
|
||||
EDN_ERROR("impossible to get pop_upWidget " << CallerObject);
|
||||
return;
|
||||
}
|
||||
// get the filename :
|
||||
etk::UString tmpData = tmpWidget->GetCompleateFileName();
|
||||
EDN_DEBUG("Request opening the file : " << tmpData);
|
||||
SendMultiCast(ednMsgOpenFile, tmpData);
|
||||
} else if (eventId == ednMsgGuiSaveAs) {
|
||||
if (data == "") {
|
||||
EDN_ERROR("Null data for Save As file ... ");
|
||||
} else {
|
||||
m_currentSavingAsIdBuffer = -1;
|
||||
if (data == "current") {
|
||||
m_currentSavingAsIdBuffer = BufferManager::GetSelected();
|
||||
} else {
|
||||
sscanf(data.Utf8Data(), "%d", &m_currentSavingAsIdBuffer);
|
||||
}
|
||||
|
||||
if (false == BufferManager::Exist(m_currentSavingAsIdBuffer)) {
|
||||
EDN_ERROR("Request saveAs on non existant Buffer ID=" << m_currentSavingAsIdBuffer);
|
||||
} else {
|
||||
Buffer * myBuffer = BufferManager::Get(m_currentSavingAsIdBuffer);
|
||||
ewol::FileChooser* tmpWidget = new ewol::FileChooser();
|
||||
tmpWidget->SetTitle("Save Files As...");
|
||||
tmpWidget->SetValidateLabel("Save");
|
||||
etk::UString folder = "/home/";
|
||||
etk::UString fileName = "";
|
||||
if (true == myBuffer->HaveName()) {
|
||||
etk::File tmpName = myBuffer->GetFileName();
|
||||
folder = tmpName.GetFolder();
|
||||
fileName = tmpName.GetShortFilename();
|
||||
}
|
||||
tmpWidget->SetFolder(folder);
|
||||
tmpWidget->SetFileName(fileName);
|
||||
PopUpWidgetPush(tmpWidget);
|
||||
tmpWidget->RegisterOnEvent(this, ewolEventFileChooserValidate, ednEventPopUpFileSaveAs);
|
||||
}
|
||||
}
|
||||
} else if (eventId == ednEventPopUpFileSaveAs) {
|
||||
// get widget:
|
||||
ewol::FileChooser * tmpWidget = static_cast<ewol::FileChooser*>(CallerObject);
|
||||
if (NULL == tmpWidget) {
|
||||
EDN_ERROR("impossible to get pop_upWidget " << CallerObject);
|
||||
return;
|
||||
}
|
||||
// get the filename :
|
||||
etk::UString tmpData = tmpWidget->GetCompleateFileName();
|
||||
EDN_DEBUG("Request Saving As file : " << tmpData);
|
||||
|
||||
BufferManager::Get(m_currentSavingAsIdBuffer)->SetFileName(tmpData);
|
||||
SendMultiCast(ednMsgGuiSave, m_currentSavingAsIdBuffer);
|
||||
} else if( eventId == ednMsgBufferState
|
||||
|| eventId == ednMsgBufferId) {
|
||||
// the buffer change we need to update the widget string
|
||||
Buffer* tmpBuffer = BufferManager::Get(BufferManager::GetSelected());
|
||||
if (NULL != tmpBuffer) {
|
||||
etk::File compleateName = tmpBuffer->GetFileName();
|
||||
bool isModify = tmpBuffer->IsModify();
|
||||
etk::UString directName = compleateName.GetCompleateName();
|
||||
if (true == isModify) {
|
||||
directName += " *";
|
||||
}
|
||||
if (NULL == m_widgetLabelFileName) {
|
||||
return;
|
||||
}
|
||||
m_widgetLabelFileName->SetLabel(directName);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
// TODO : Set the Title ....
|
||||
} else if (eventId == ednMsgGuiAbout) {
|
||||
/*
|
||||
//Title
|
||||
"Edn"
|
||||
// version
|
||||
VERSION_TAG_NAME
|
||||
// comments:
|
||||
"Editeur De N'ours\n"
|
||||
"L'Editeur Desoxyribo-Nucleique.\n"
|
||||
"Source Code Editor\n"
|
||||
"Build Time : " VERSION_BUILD_TIME;
|
||||
// copyright
|
||||
"Copyright 2010 Edouard DUPIN, all right reserved";
|
||||
// licence
|
||||
"This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY\n\n"
|
||||
"You can:\n"
|
||||
" * Redistribute the sources code and binaries.\n"
|
||||
" * Modify the Sources code.\n"
|
||||
" * Use a part of the sources (less than 50%) in an other software, just write somewhere \"Edn is great\" visible by the user (on your product or on your website with a link to my page).\n"
|
||||
" * Redistribute the modification only if you want.\n"
|
||||
" * Send me the bug-fix (it could be great).\n"
|
||||
" * Pay me a beer or some other things.\n"
|
||||
" * Print the source code on WC paper ...\n\n"
|
||||
"You can NOT:\n"
|
||||
" * Earn money with this Software (But I can).\n"
|
||||
" * Add malware in the Sources.\n"
|
||||
" * Do something bad with the sources.\n"
|
||||
" * Use it to travel in the space with a toaster.\n\n"
|
||||
"I reserve the right to change this licence. If it change the version of the copy you have keep its own license."
|
||||
*/
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
@@ -25,58 +25,33 @@
|
||||
|
||||
|
||||
#include <tools_debug.h>
|
||||
#include <etk/Singleton.h>
|
||||
#include <MsgBroadcast.h>
|
||||
|
||||
#include <CodeView.h>
|
||||
#include <BufferView.h>
|
||||
#include <BufferManager.h>
|
||||
#include <MenuBar.h>
|
||||
#include <StatusBar.h>
|
||||
#include <ToolBar.h>
|
||||
#include <ewol/widget/Label.h>
|
||||
|
||||
|
||||
#ifndef __MAIN_WINDOWS_H__
|
||||
#define __MAIN_WINDOWS_H__
|
||||
#if 0
|
||||
class MainWindows: public etk::Singleton<MainWindows>, public MsgBroadcast
|
||||
{
|
||||
friend class etk::Singleton<MainWindows>;
|
||||
// specific for sigleton system...
|
||||
private:
|
||||
// Constructeur
|
||||
MainWindows(void);
|
||||
~MainWindows(void);
|
||||
public:
|
||||
//GtkWidget * GetWidget(void) { return m_mainWindow;};
|
||||
void OnMessage(int32_t id, int32_t dataID);
|
||||
//static bool OnQuit(GtkWidget *widget, gpointer data);
|
||||
//static gboolean OnStateChange(GtkWidget *widget, GdkEvent* event, gpointer data);
|
||||
|
||||
private:
|
||||
void SetTitle(etk::File &fileName, bool isModify);
|
||||
void SetNoTitle(void);
|
||||
// main windows widget :
|
||||
/*
|
||||
GtkWidget * m_mainWindow;
|
||||
GtkWidget * m_internalTitleLabel;
|
||||
BufferView m_BufferView;
|
||||
CodeView m_CodeView;
|
||||
MenuBar m_MenuBar;
|
||||
StatusBar m_StatusBar;
|
||||
ToolBar m_ToolBar;
|
||||
*/
|
||||
};
|
||||
#endif
|
||||
class MainWindows : public ewol::Windows
|
||||
{
|
||||
private:
|
||||
int32_t m_currentSavingAsIdBuffer;
|
||||
ewol::Label* m_widgetLabelFileName;
|
||||
public:
|
||||
// Constructeur
|
||||
MainWindows(void);
|
||||
~MainWindows(void);
|
||||
virtual bool OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * data, etkFloat_t x, etkFloat_t y);
|
||||
/**
|
||||
* @brief Receive a message from an other EObject with a specific eventId and data
|
||||
* @param[in] CallerObject Pointer on the EObject that information came from
|
||||
* @param[in] eventId Message registered by this class
|
||||
* @param[in] data Data registered by this class
|
||||
* @return ---
|
||||
*/
|
||||
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
|
||||
};
|
||||
#endif
|
||||
|
@@ -277,7 +277,7 @@ void Search::OnButtonReplaceAndNext(GtkWidget *widget, gpointer data)
|
||||
void Search::OnButtonQuit(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
//EDN_INFO("CALLBACK");
|
||||
Search * self = reinterpret_cast<Search*>(data);
|
||||
Search * self = static_cast<Search*>(data);
|
||||
self->Destroy();
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ void Search::OnCheckBoxEventCase(GtkWidget *widget, gpointer data)
|
||||
void Search::OnCheckBoxEventRegExp(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
//EDN_INFO("CALLBACK");
|
||||
Search * self = reinterpret_cast<Search*>(data);
|
||||
Search * self = static_cast<Search*>(data);
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
|
||||
SearchData::SetRegExp(true);
|
||||
gtk_widget_set_sensitive(self->m_CkMatchCase, false);
|
||||
@@ -317,7 +317,7 @@ void Search::OnCheckBoxEventRegExp(GtkWidget *widget, gpointer data)
|
||||
void Search::OnEntrySearchChange(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
//EDN_INFO("CALLBACK");
|
||||
Search * self = reinterpret_cast<Search*>(data);
|
||||
Search * self = static_cast<Search*>(data);
|
||||
// update research data
|
||||
const char *testData = gtk_entry_get_text(GTK_ENTRY(widget));
|
||||
if (NULL != testData) {
|
||||
@@ -343,7 +343,7 @@ void Search::OnEntrySearchChange(GtkWidget *widget, gpointer data)
|
||||
void Search::OnEntryReplaceChange(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
//EDN_INFO("CALLBACK");
|
||||
Search * self = reinterpret_cast<Search*>(data);
|
||||
Search * self = static_cast<Search*>(data);
|
||||
// update replace data
|
||||
const char *testData = gtk_entry_get_text(GTK_ENTRY(widget));
|
||||
if (NULL != testData) {
|
@@ -27,14 +27,11 @@
|
||||
#define __SEARCH_H__
|
||||
|
||||
#include <tools_debug.h>
|
||||
#include <etk/Singleton.h>
|
||||
|
||||
|
||||
class Search: public etk::Singleton<Search>
|
||||
class Search
|
||||
{
|
||||
friend class etk::Singleton<Search>;
|
||||
// specific for sigleton system...
|
||||
private:
|
||||
public:
|
||||
// Constructeur
|
||||
Search(void);
|
||||
~Search(void);
|
@@ -1,440 +0,0 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file MainWindows.cpp
|
||||
* @brief Editeur De N'ours : main Windows diplayer (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 04/01/2011
|
||||
* @par Project
|
||||
* Edn
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2010 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
* You can not earn money with this Software (if the source extract from Edn
|
||||
* represent less than 50% of original Sources)
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <tools_debug.h>
|
||||
#include <tools_globals.h>
|
||||
#include <MainWindows.h>
|
||||
#include <CodeView.h>
|
||||
#include <ClipBoard.h>
|
||||
#include <BufferView.h>
|
||||
#include <AccelKey.h>
|
||||
|
||||
#include <ewol/widget/Button.h>
|
||||
#include <ewol/widget/CheckBox.h>
|
||||
#include <ewol/widget/SizerHori.h>
|
||||
#include <ewol/widget/SizerVert.h>
|
||||
#include <ewol/widget/Test.h>
|
||||
#include <ewol/widget/Label.h>
|
||||
#include <ewol/widget/Entry.h>
|
||||
#include <ewol/widget/List.h>
|
||||
#include <ewol/widget/PopUp.h>
|
||||
#include <ewol/widget/Spacer.h>
|
||||
#include <ewol/widgetMeta/FileChooser.h>
|
||||
#include <ewol/WidgetManager.h>
|
||||
#include <ewol/WidgetMessageMultiCast.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "MainWindows"
|
||||
|
||||
|
||||
const char * const ednEventNewFile = "edn-New-File";
|
||||
const char * const ednEventOpenFile = "edn-Open-File";
|
||||
const char * const ednEventCloseFile = "edn-Close-File";
|
||||
const char * const ednEventSaveFile = "edn-Save-File";
|
||||
const char * const ednEventSaveAsFile = "edn-SaveAs-File";
|
||||
const char * const ednEventPopUpClose = "edn-PopUp-Close";
|
||||
const char * const ednEventPopUpFileSelected = "edn-PopUp-FileSelected";
|
||||
const char * const ednEventPopUpFileSaveAs = "edn-PopUp-FileSaveAs";
|
||||
|
||||
MainWindows::MainWindows(void)
|
||||
{
|
||||
EDN_DEBUG("CREATE WINDOWS ... ");
|
||||
ewol::SizerVert * mySizerVert = NULL;
|
||||
ewol::SizerHori * mySizerHori = NULL;
|
||||
ewol::Button * myButton = NULL;
|
||||
ewol::Label * myLabel = NULL;
|
||||
CodeView * myCodeView = NULL;
|
||||
BufferView * myBufferView = NULL;
|
||||
|
||||
mySizerVert = new ewol::SizerVert();
|
||||
SetSubWidget(mySizerVert);
|
||||
|
||||
mySizerHori = new ewol::SizerHori();
|
||||
mySizerVert->SubWidgetAdd(mySizerHori);
|
||||
|
||||
myButton = new ewol::Button("New");
|
||||
mySizerHori->SubWidgetAdd(myButton);
|
||||
if (false == myButton->ExternLinkOnEvent(ewolEventButtonPressed, GetWidgetId(), ednEventNewFile) ) {
|
||||
EDN_CRITICAL("link with an entry event");
|
||||
}
|
||||
|
||||
myButton = new ewol::Button("Open");
|
||||
mySizerHori->SubWidgetAdd(myButton);
|
||||
if (false == myButton->ExternLinkOnEvent(ewolEventButtonPressed, GetWidgetId(), ednEventOpenFile) ) {
|
||||
EDN_CRITICAL("link with an entry event");
|
||||
}
|
||||
|
||||
myButton = new ewol::Button("Close");
|
||||
mySizerHori->SubWidgetAdd(myButton);
|
||||
if (false == myButton->ExternLinkOnEvent(ewolEventButtonPressed, GetWidgetId(), ednEventCloseFile) ) {
|
||||
EDN_CRITICAL("link with an entry event");
|
||||
}
|
||||
|
||||
myButton = new ewol::Button("Save");
|
||||
mySizerHori->SubWidgetAdd(myButton);
|
||||
if (false == myButton->ExternLinkOnEvent(ewolEventButtonPressed, GetWidgetId(), ednEventSaveFile) ) {
|
||||
EDN_CRITICAL("link with an entry event");
|
||||
}
|
||||
|
||||
myButton = new ewol::Button("Save As ...");
|
||||
mySizerHori->SubWidgetAdd(myButton);
|
||||
if (false == myButton->ExternLinkOnEvent(ewolEventButtonPressed, GetWidgetId(), ednEventSaveAsFile) ) {
|
||||
EDN_CRITICAL("link with an entry event");
|
||||
}
|
||||
|
||||
|
||||
myLabel = new ewol::Label("FileName");
|
||||
myLabel->SetExpendX(true);
|
||||
myLabel->SetFillY(true);
|
||||
mySizerHori->SubWidgetAdd(myLabel);
|
||||
|
||||
mySizerHori = new ewol::SizerHori();
|
||||
mySizerVert->SubWidgetAdd(mySizerHori);
|
||||
myBufferView = new BufferView();
|
||||
myBufferView->SetExpendX(false);
|
||||
myBufferView->SetExpendY(true);
|
||||
myBufferView->SetFillX(true);
|
||||
myBufferView->SetFillY(true);
|
||||
mySizerHori->SubWidgetAdd(myBufferView);
|
||||
myCodeView = new CodeView();
|
||||
myCodeView->SetExpendX(true);
|
||||
myCodeView->SetExpendY(true);
|
||||
myCodeView->SetFillX(true);
|
||||
myCodeView->SetFillY(true);
|
||||
|
||||
myCodeView->SetFontSize(11);
|
||||
myCodeView->SetFontNameNormal( "freefont/FreeMono.ttf");
|
||||
myCodeView->SetFontNameBold( "freefont/FreeMonoBold.ttf");
|
||||
myCodeView->SetFontNameItalic( "freefont/FreeMonoOblique.ttf");
|
||||
myCodeView->SetFontNameBoldItalic("freefont/FreeMonoBoldOblique.ttf");
|
||||
/*
|
||||
myCodeView->SetFontSize(11);
|
||||
myCodeView->SetFontNameNormal( "ubuntu/UbuntuMono-R.ttf");
|
||||
myCodeView->SetFontNameBold( "ubuntu/UbuntuMono-B.ttf");
|
||||
myCodeView->SetFontNameItalic( "ubuntu/UbuntuMono-RI.ttf");
|
||||
myCodeView->SetFontNameBoldItalic("ubuntu/UbuntuMono-BI.ttf");
|
||||
*/
|
||||
mySizerHori->SubWidgetAdd(myCodeView);
|
||||
|
||||
// Generic event ...
|
||||
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgGuiSaveAs);
|
||||
}
|
||||
|
||||
|
||||
MainWindows::~MainWindows(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool MainWindows::OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * data, etkFloat_t x, etkFloat_t y)
|
||||
{
|
||||
if (true == ewol::Windows::OnEventAreaExternal(widgetID, generateEventId, data, x, y) ) {
|
||||
return true;
|
||||
}
|
||||
//EDN_INFO("Receive Event from the main windows ... : widgetid=" << widgetID << "\"" << generateEventId << "\" ==> data=\"" << data << "\"" );
|
||||
// newFile section ...
|
||||
if (generateEventId == ednEventNewFile) {
|
||||
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgGuiNew);
|
||||
}
|
||||
else if (generateEventId == ednEventCloseFile) {
|
||||
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgGuiClose, "current");
|
||||
}
|
||||
else if (generateEventId == ednEventSaveFile) {
|
||||
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgGuiSave, "current");
|
||||
}
|
||||
else if (generateEventId == ednEventSaveAsFile) {
|
||||
OnEventAreaExternal(GetWidgetId(), ednMsgGuiSaveAs, "current", x, y);
|
||||
}
|
||||
// Open file Section ...
|
||||
else if (generateEventId == ednEventOpenFile) {
|
||||
ewol::FileChooser* tmpWidget = new ewol::FileChooser();
|
||||
tmpWidget->SetTitle("Open Files ...");
|
||||
tmpWidget->SetValidateLabel("Open");
|
||||
// TODO : Set the good folder ...
|
||||
//tmpWidget->SetFolder("/");
|
||||
PopUpWidgetPush(tmpWidget);
|
||||
if (false == tmpWidget->ExternLinkOnEvent(ewolEventFileChooserCancel, GetWidgetId(), ednEventPopUpClose) ) {
|
||||
EDN_CRITICAL("link with an entry event");
|
||||
}
|
||||
if (false == tmpWidget->ExternLinkOnEvent(ewolEventFileChooserValidate, GetWidgetId(), ednEventPopUpFileSelected) ) {
|
||||
EDN_CRITICAL("link with an entry event");
|
||||
}
|
||||
} else if (generateEventId == ednEventPopUpClose) {
|
||||
// TODO : Set this in the upper windows ...
|
||||
PopUpWidgetPop();
|
||||
} else if (generateEventId == ednEventPopUpFileSelected) {
|
||||
// get widget:
|
||||
ewol::FileChooser * tmpWidget = (ewol::FileChooser*)ewol::widgetManager::Get(widgetID);
|
||||
if (NULL == tmpWidget) {
|
||||
EDN_ERROR("impossible to get pop_upWidget " << widgetID);
|
||||
PopUpWidgetPop();
|
||||
return false;
|
||||
}
|
||||
// get the filename :
|
||||
etk::UString tmpData = tmpWidget->GetCompleateFileName();
|
||||
EDN_DEBUG("Request opening the file : " << tmpData);
|
||||
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgOpenFile, tmpData);
|
||||
PopUpWidgetPop();
|
||||
} else if (generateEventId == ednMsgGuiSaveAs) {
|
||||
if (NULL == data) {
|
||||
EDN_ERROR("Null data for Save As file ... ");
|
||||
} else {
|
||||
BufferManager * myMng = BufferManager::getInstance();
|
||||
m_currentSavingAsIdBuffer = -1;
|
||||
if (0 == strcmp(data , "current")) {
|
||||
m_currentSavingAsIdBuffer = myMng->GetSelected();
|
||||
} else {
|
||||
sscanf(data, "%d", &m_currentSavingAsIdBuffer);
|
||||
}
|
||||
|
||||
if (false == myMng->Exist(m_currentSavingAsIdBuffer)) {
|
||||
EDN_ERROR("Request saveAs on non existant Buffer ID=" << m_currentSavingAsIdBuffer);
|
||||
} else {
|
||||
Buffer * myBuffer = myMng->Get(m_currentSavingAsIdBuffer);
|
||||
ewol::FileChooser* tmpWidget = new ewol::FileChooser();
|
||||
tmpWidget->SetTitle("Save Files As...");
|
||||
tmpWidget->SetValidateLabel("Save");
|
||||
etk::UString folder = "/home/";
|
||||
etk::UString fileName = "";
|
||||
if (true == myBuffer->HaveName()) {
|
||||
etk::File tmpName = myBuffer->GetFileName();
|
||||
folder = tmpName.GetFolder();
|
||||
fileName = tmpName.GetShortFilename();
|
||||
}
|
||||
tmpWidget->SetFolder(folder);
|
||||
tmpWidget->SetFileName(fileName);
|
||||
PopUpWidgetPush(tmpWidget);
|
||||
if (false == tmpWidget->ExternLinkOnEvent(ewolEventFileChooserCancel, GetWidgetId(), ednEventPopUpClose) ) {
|
||||
EDN_CRITICAL("link with an entry event");
|
||||
}
|
||||
if (false == tmpWidget->ExternLinkOnEvent(ewolEventFileChooserValidate, GetWidgetId(), ednEventPopUpFileSaveAs) ) {
|
||||
EDN_CRITICAL("link with an entry event");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (generateEventId == ednEventPopUpFileSaveAs) {
|
||||
// get widget:
|
||||
ewol::FileChooser * tmpWidget = (ewol::FileChooser*)ewol::widgetManager::Get(widgetID);
|
||||
if (NULL == tmpWidget) {
|
||||
EDN_ERROR("impossible to get pop_upWidget " << widgetID);
|
||||
PopUpWidgetPop();
|
||||
return false;
|
||||
}
|
||||
// get the filename :
|
||||
etk::UString tmpData = tmpWidget->GetCompleateFileName();
|
||||
EDN_DEBUG("Request Saving As file : " << tmpData);
|
||||
|
||||
BufferManager * myMng = BufferManager::getInstance();
|
||||
myMng->Get(m_currentSavingAsIdBuffer)->SetFileName(tmpData);
|
||||
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgGuiSave, m_currentSavingAsIdBuffer);
|
||||
|
||||
//ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgOpenFile, tmpData);
|
||||
|
||||
PopUpWidgetPop();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef SDFGSDFGSDF___SDFGSDFG
|
||||
MainWindows::MainWindows(void) : MsgBroadcast("Main Windows", EDN_CAT_GUI)
|
||||
{
|
||||
m_mainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
// select the program icone
|
||||
GError *err = NULL;
|
||||
etk::UString iconeFile;
|
||||
iconeFile = "/usr/share/edn/images/icone.png";
|
||||
|
||||
GdkPixbuf * icone = gdk_pixbuf_new_from_file(iconeFile.c_str(), &err);
|
||||
if (err != NULL) {
|
||||
gtk_window_set_default_icon_name("text-editor");
|
||||
} else {
|
||||
gtk_window_set_icon(GTK_WINDOW(m_mainWindow), icone);
|
||||
}
|
||||
|
||||
// enable the close signal of the windows
|
||||
g_signal_connect(G_OBJECT(m_mainWindow), "delete-event", G_CALLBACK(OnQuit), this);
|
||||
g_signal_connect(G_OBJECT(m_mainWindow), "window-state-event", G_CALLBACK(OnStateChange), this);
|
||||
|
||||
// Create a vertical box for stacking the menu and editor widgets in.
|
||||
GtkWidget *vbox = gtk_vbox_new (FALSE, 0);
|
||||
gtk_container_add(GTK_CONTAINER(m_mainWindow), vbox);
|
||||
|
||||
// Set key Accelerator :
|
||||
AccelKey::getInstance()->LinkCommonAccel(GTK_WINDOW(m_mainWindow));
|
||||
|
||||
// Create the menu bar.
|
||||
GtkWidget *hboxMenu = gtk_hbox_new (FALSE, 0);
|
||||
gtk_box_pack_start( GTK_BOX (vbox), hboxMenu, FALSE, FALSE, 0);
|
||||
// Add Exit boutton
|
||||
etk::UString ExitIconeFile;
|
||||
ExitIconeFile = "/usr/share/edn/images/delete-24px.png";
|
||||
// TODO : find a good way to change the size of an image
|
||||
GtkWidget *myImageQuit = gtk_image_new_from_file(ExitIconeFile.c_str());
|
||||
GtkIconSize mySize = GTK_ICON_SIZE_SMALL_TOOLBAR;
|
||||
//EDN_DEBUG(" plop : " << mySize);
|
||||
//gtk_image_get_icon_set( GTK_IMAGE(myImageQuit), NULL, &mySize);
|
||||
//EDN_DEBUG(" plop : " << mySize);
|
||||
GtkWidget *event_box = gtk_event_box_new();
|
||||
gtk_container_add(GTK_CONTAINER(event_box),myImageQuit);
|
||||
gtk_widget_add_events(event_box,GDK_BUTTON_PRESS_MASK);
|
||||
g_signal_connect(G_OBJECT(event_box), "button_press_event", G_CALLBACK(OnQuit), this);
|
||||
|
||||
gtk_box_pack_start( GTK_BOX(hboxMenu), event_box, FALSE, FALSE, 0);
|
||||
|
||||
// add the real menu bar
|
||||
gtk_box_pack_start( GTK_BOX (hboxMenu), m_MenuBar.GetWidget(), FALSE, FALSE, 0);
|
||||
|
||||
// Add title
|
||||
m_internalTitleLabel = gtk_label_new("Edn");
|
||||
gtk_box_pack_start( GTK_BOX (hboxMenu), m_internalTitleLabel, FALSE, FALSE, 0);
|
||||
// **********************************************************
|
||||
// * Horizontal ELEMENTS : *
|
||||
// **********************************************************
|
||||
// Create a vertical box for stacking the menu and editor widgets in.
|
||||
GtkWidget *hbox = gtk_hbox_new (FALSE, 0);
|
||||
gtk_container_add(GTK_CONTAINER (vbox), hbox);
|
||||
// create the toolbar :
|
||||
// TreeView :
|
||||
gtk_box_pack_start(GTK_BOX(hbox), m_BufferView.GetMainWidget(), FALSE, TRUE, 1);
|
||||
|
||||
// Text displayer :
|
||||
gtk_box_pack_start( GTK_BOX (hbox), m_CodeView.GetMainWidget(), TRUE, TRUE, 0);
|
||||
|
||||
// Create the status bar
|
||||
//gtk_box_pack_end(GTK_BOX(vbox), m_StatusBar.GetWidget(), FALSE, FALSE, 0);
|
||||
|
||||
// recursive version of gtk_widget_show
|
||||
gtk_widget_show_all(m_mainWindow);
|
||||
|
||||
|
||||
MainWindows::~MainWindows(void)
|
||||
{
|
||||
/*
|
||||
if (NULL != m_DlgSearch) {
|
||||
delete m_DlgSearch;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MainWindows::SetTitle(etk::File &fileName, bool isModify)
|
||||
{
|
||||
etk::UString tmp = "";
|
||||
if (fileName.GetShortFilename() != "") {
|
||||
tmp += fileName.GetShortFilename();
|
||||
tmp += " - ";
|
||||
tmp += fileName.GetFolder();
|
||||
tmp += " - ";
|
||||
}
|
||||
tmp += "Edn";
|
||||
//gtk_window_set_title(GTK_WINDOW(m_mainWindow), tmp.c_str());
|
||||
tmp = " ";
|
||||
if (fileName.GetShortFilename() != "") {
|
||||
tmp += fileName.GetFolder();
|
||||
tmp += "/";
|
||||
tmp += fileName.GetShortFilename();
|
||||
} else {
|
||||
tmp += "Edn";
|
||||
}
|
||||
tmp += " ";
|
||||
//gtk_label_set_text(GTK_LABEL(m_internalTitleLabel), tmp.c_str());
|
||||
|
||||
}
|
||||
|
||||
void MainWindows::SetNoTitle(void)
|
||||
{
|
||||
etk::UString tmp = "Edn";
|
||||
//gtk_window_set_title(GTK_WINDOW(m_mainWindow), tmp.c_str());
|
||||
//gtk_label_set_text(GTK_LABEL(m_internalTitleLabel), tmp.c_str());
|
||||
}
|
||||
|
||||
void MainWindows::OnMessage(int32_t id, int32_t dataID)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case EDN_MSG__BUFFER_CHANGE_CURRENT:
|
||||
// change Title :
|
||||
// TODO : String error when remove the error with -1;
|
||||
if (-1 == dataID) {
|
||||
SetNoTitle();
|
||||
} else {
|
||||
/*
|
||||
Buffer *mybuf = BufferManager::getInstance()->Get(dataID);
|
||||
if (NULL != mybuf) {
|
||||
etk::File plop = mybuf->GetFileName();
|
||||
SetTitle(plop, mybuf->IsModify() );
|
||||
}
|
||||
*/
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
bool MainWindows::OnQuit(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
//MainWindows * self = reinterpret_cast<MainWindows*>(data);
|
||||
GeneralSendMessage(EDN_MSG__GUI_SHOW_EXIT_CONFIRMATION);
|
||||
// Close is not managed here ...
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
gboolean MainWindows::OnStateChange(GtkWidget *widget, GdkEvent* event, gpointer data)
|
||||
{
|
||||
MainWindows * self = reinterpret_cast<MainWindows*>(data);
|
||||
EDN_DEBUG("State change");
|
||||
EDN_INFO(" change state mask : " << event->window_state.changed_mask);
|
||||
EDN_INFO(" change state new val : " << event->window_state.new_window_state);
|
||||
if (event->window_state.changed_mask == GDK_WINDOW_STATE_MAXIMIZED) {
|
||||
EDN_INFO(" ==> Maximisation change...");
|
||||
if (event->window_state.new_window_state == GDK_WINDOW_STATE_MAXIMIZED) {
|
||||
EDN_INFO(" ==> ENABLE");
|
||||
gtk_window_set_decorated(GTK_WINDOW(self->m_mainWindow), FALSE);
|
||||
} else {
|
||||
EDN_INFO(" ==> DISABLE");
|
||||
gtk_window_set_decorated(GTK_WINDOW(self->m_mainWindow), TRUE);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
@@ -1,386 +0,0 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file MenuBar.cpp
|
||||
* @brief Editeur De N'ours : abstraction of the menu bar (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 17/06/2011
|
||||
* @par Project
|
||||
* Edn
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2010 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
* You can not earn money with this Software (if the source extract from Edn
|
||||
* represent less than 50% of original Sources)
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#include <tools_debug.h>
|
||||
#include <MenuBar.h>
|
||||
#include <ClipBoard.h>
|
||||
#include <etk/unicode.h>
|
||||
#include <ColorizeManager.h>
|
||||
#if 0
|
||||
#define MENU_MSG
|
||||
const char * MSG_TogleDisplayChar = "Request a Togle of char displaying";
|
||||
const char * MSG_TogleDisplayEOL = "Request a Togle of displaying EndOfLine";
|
||||
const char * MSG_TogleAutoIndent = "Request a Togle of Auto Indent";
|
||||
const char * MSG_SetCharsetIso559_1 = "Set ISO 5589-1";
|
||||
const char * MSG_SetCharsetIso559_15 = "Set ISO 5589-15";
|
||||
const char * MSG_SetCharsetUTF8 = "Set UTF 8";
|
||||
const char * MSG_LoadColorBlack = "Load Color Black";
|
||||
const char * MSG_LoadColorWhite = "Load Color White";
|
||||
#define MSG_LINK(data)
|
||||
|
||||
|
||||
static void CB_menuGenerique(GtkMenuItem *menu_item, gpointer data)
|
||||
{
|
||||
//EDN_INFO("basic menue_event");
|
||||
messageData_ts * msg = (messageData_ts*)data;
|
||||
GeneralSendMessage(msg->msgId, msg->dataId);
|
||||
}
|
||||
|
||||
static void CB_menuInternal(GtkMenuItem *menu_item, gpointer data)
|
||||
{
|
||||
//EDN_INFO("basic menue_event");
|
||||
const char * myPointer = (const char*)data;
|
||||
if (myPointer == MSG_TogleDisplayChar) {
|
||||
if (globals::IsSetDisplaySpaceChar() == true) {
|
||||
globals::SetDisplaySpaceChar(false);
|
||||
} else {
|
||||
globals::SetDisplaySpaceChar(true);
|
||||
}
|
||||
} else if (myPointer == MSG_TogleDisplayEOL) {
|
||||
if (globals::IsSetDisplayEndOfLine() == true) {
|
||||
globals::SetDisplayEndOfLine(false);
|
||||
} else {
|
||||
globals::SetDisplayEndOfLine(true);
|
||||
}
|
||||
} else if (myPointer == MSG_TogleAutoIndent) {
|
||||
if (globals::IsSetAutoIndent() == true) {
|
||||
globals::SetAutoIndent(false);
|
||||
} else {
|
||||
globals::SetAutoIndent(true);
|
||||
}
|
||||
} else if (myPointer == MSG_SetCharsetIso559_1) {
|
||||
GeneralSendMessage(EDN_MSG__CURRENT_SET_CHARSET, EDN_CHARSET_ISO_8859_1);
|
||||
} else if (myPointer == MSG_SetCharsetIso559_15) {
|
||||
GeneralSendMessage(EDN_MSG__CURRENT_SET_CHARSET, EDN_CHARSET_ISO_8859_15);
|
||||
} else if (myPointer == MSG_SetCharsetUTF8) {
|
||||
GeneralSendMessage(EDN_MSG__CURRENT_SET_CHARSET, EDN_CHARSET_UTF8);
|
||||
} else if (myPointer == MSG_LoadColorWhite) {
|
||||
ColorizeManager * myColorSystem = ColorizeManager::getInstance();
|
||||
etk::UString homedir;
|
||||
# ifdef NDEBUG
|
||||
homedir = "/usr/share/edn/";
|
||||
# else
|
||||
homedir = "./data/";
|
||||
# endif
|
||||
homedir += "color_white.xml";
|
||||
myColorSystem->LoadFile(homedir);
|
||||
} else if (myPointer == MSG_LoadColorBlack) {
|
||||
ColorizeManager * myColorSystem = ColorizeManager::getInstance();
|
||||
etk::UString homedir;
|
||||
# ifdef NDEBUG
|
||||
homedir = "/usr/share/edn/";
|
||||
# else
|
||||
homedir = "./data/";
|
||||
# endif
|
||||
homedir += "color_black.xml";
|
||||
myColorSystem->LoadFile(homedir);
|
||||
}
|
||||
}
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "MenuBarMain"
|
||||
|
||||
class MenuBarMain
|
||||
{
|
||||
public:
|
||||
MenuBarMain(const char * title, GtkWidget * parent) : m_parent(NULL), m_menu(NULL), m_menuListe(NULL)
|
||||
{
|
||||
m_parent = parent;
|
||||
m_menu = gtk_menu_item_new_with_mnemonic(title);
|
||||
gtk_menu_shell_append( GTK_MENU_SHELL (parent), m_menu);
|
||||
}
|
||||
|
||||
~MenuBarMain(void)
|
||||
{
|
||||
|
||||
}
|
||||
private:
|
||||
void CheckSubMenu(void)
|
||||
{
|
||||
if (NULL == m_menuListe) {
|
||||
m_menuListe = gtk_menu_new();
|
||||
if (NULL != m_menuListe) {
|
||||
gtk_menu_item_set_submenu( GTK_MENU_ITEM (m_menu), m_menuListe);
|
||||
} else {
|
||||
EDN_ERROR("Can not create sub menu");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
void AddInternal(const char * title, const char * accelKey, const char * msg, bool enable = false)
|
||||
{
|
||||
CheckSubMenu();
|
||||
if (NULL == m_menuListe) {
|
||||
return;
|
||||
}
|
||||
// create ITEM
|
||||
GtkWidget *tmpWidget = gtk_menu_item_new_with_mnemonic(title);
|
||||
// set grisage :
|
||||
gtk_widget_set_sensitive(tmpWidget, enable);
|
||||
// add to the menu :
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(m_menuListe), tmpWidget);
|
||||
// accel KEY :
|
||||
AccelKey::getInstance()->SetAccel(tmpWidget, (char *)accelKey);
|
||||
// set callback
|
||||
g_signal_connect(G_OBJECT(tmpWidget), "activate", G_CALLBACK(CB_menuInternal), (void*)msg);
|
||||
}
|
||||
|
||||
|
||||
void Add(const char * title, const char * accelKey, messageType_te id = EDN_MSG__NONE, bool enable = false, int32_t dataSpecificID = -1)
|
||||
{
|
||||
CheckSubMenu();
|
||||
if (NULL == m_menuListe) {
|
||||
return;
|
||||
}
|
||||
messageData_ts * message = new messageData_ts;
|
||||
message->msgId = id;
|
||||
message->dataId = dataSpecificID;
|
||||
m_message.PushBack(message);
|
||||
// create ITEM
|
||||
GtkWidget *tmpWidget = gtk_menu_item_new_with_mnemonic(title);
|
||||
// set grisage :
|
||||
gtk_widget_set_sensitive(tmpWidget, enable);
|
||||
// add to the menu :
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(m_menuListe), tmpWidget);
|
||||
// accel KEY :
|
||||
AccelKey::getInstance()->SetAccel(tmpWidget, (char *)accelKey);
|
||||
// set callback
|
||||
if(EDN_MSG__NONE!=id) {
|
||||
g_signal_connect(G_OBJECT(tmpWidget), "activate", G_CALLBACK(CB_menuGenerique), message);
|
||||
}
|
||||
}
|
||||
|
||||
void AddGen(const char * title, const char * accelKey, messageType_te id = EDN_MSG__NONE, bool enable = false, int32_t dataSpecificID = -1)
|
||||
{
|
||||
CheckSubMenu();
|
||||
if (NULL == m_menuListe) {
|
||||
return;
|
||||
}
|
||||
messageData_ts * message = new messageData_ts;
|
||||
message->msgId = id;
|
||||
message->dataId = dataSpecificID;
|
||||
m_message.PushBack(message);
|
||||
// create ITEM
|
||||
GtkWidget *tmpWidget = gtk_image_menu_item_new_from_stock( title, AccelKey::getInstance()->GetAccel() );
|
||||
GdkColor color;
|
||||
gdk_color_parse ("red", &color);
|
||||
gtk_widget_modify_fg(tmpWidget, GTK_STATE_NORMAL, &color);
|
||||
gtk_widget_modify_bg(tmpWidget, GTK_STATE_NORMAL, &color);
|
||||
gtk_widget_modify_text(tmpWidget, GTK_STATE_NORMAL, &color);
|
||||
// set grisage :
|
||||
gtk_widget_set_sensitive(tmpWidget, enable);
|
||||
// add to the menu :
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(m_menuListe), tmpWidget);
|
||||
// accel KEY :
|
||||
AccelKey::getInstance()->SetAccel(tmpWidget, (char *)accelKey);
|
||||
// set callback
|
||||
if(EDN_MSG__NONE!=id) {
|
||||
g_signal_connect(G_OBJECT(tmpWidget), "activate", G_CALLBACK(CB_menuGenerique), message);
|
||||
}
|
||||
}
|
||||
|
||||
void AddSeparator(void)
|
||||
{
|
||||
CheckSubMenu();
|
||||
if (NULL == m_menuListe) {
|
||||
return;
|
||||
}
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL (m_menuListe), gtk_separator_menu_item_new() );
|
||||
}
|
||||
|
||||
private:
|
||||
GtkWidget * m_parent;
|
||||
GtkWidget * m_menu;
|
||||
GtkWidget * m_menuListe;
|
||||
etk::VectorType<messageData_ts*> m_message;
|
||||
};
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "MenuBar"
|
||||
|
||||
MenuBar::MenuBar(void) : MsgBroadcast("Menu bar", EDN_CAT_GUI)
|
||||
{
|
||||
m_mainWidget = gtk_menu_bar_new();
|
||||
MenuBarMain *tmp = NULL;
|
||||
|
||||
tmp = new MenuBarMain("_File", m_mainWidget);
|
||||
tmp->AddGen(GTK_STOCK_NEW, "ctrl+n", EDN_MSG__NEW, true);
|
||||
tmp->AddGen(GTK_STOCK_OPEN, "ctrl+o", EDN_MSG__GUI_SHOW_OPEN_FILE, true);
|
||||
tmp->AddSeparator();
|
||||
tmp->AddGen("Close file", "ctrl+q", EDN_MSG__CURRENT_CLOSE, true);
|
||||
tmp->AddSeparator();
|
||||
tmp->AddGen(GTK_STOCK_SAVE, "ctrl+s", EDN_MSG__CURRENT_SAVE, true);
|
||||
tmp->AddGen(GTK_STOCK_SAVE_AS, "ctrl+shift+s", EDN_MSG__CURRENT_SAVE_AS, true);
|
||||
tmp->AddSeparator();
|
||||
tmp->AddGen(GTK_STOCK_QUIT, "ctrl+shift+q", EDN_MSG__GUI_SHOW_EXIT_CONFIRMATION, true);
|
||||
m_listMenu.PushBack(tmp);
|
||||
|
||||
tmp = new MenuBarMain("_Edit", m_mainWidget);
|
||||
tmp->AddGen(GTK_STOCK_UNDO, "ctrl+z", EDN_MSG__CURRENT_UNDO, true);
|
||||
tmp->AddGen(GTK_STOCK_REDO, "ctrl+shift+z", EDN_MSG__CURRENT_REDO, true);
|
||||
tmp->AddSeparator();
|
||||
tmp->AddGen(GTK_STOCK_CUT, "ctrl+x", EDN_MSG__CURRENT_CUT, true, COPY_STD);
|
||||
tmp->AddGen(GTK_STOCK_COPY, "ctrl+c", EDN_MSG__CURRENT_COPY, true, COPY_STD);
|
||||
tmp->AddGen(GTK_STOCK_PASTE, "ctrl+v", EDN_MSG__CURRENT_PASTE, true, COPY_STD);
|
||||
// tmp->AddGen(GTK_STOCK_DELETE, NULL);
|
||||
tmp->AddGen("Remove line", "ctrl+w", EDN_MSG__CURRENT_REMOVE_LINE, true);
|
||||
tmp->AddSeparator();
|
||||
tmp->AddGen(GTK_STOCK_SELECT_ALL, "ctrl+a", EDN_MSG__CURRENT_SELECT_ALL, true);
|
||||
tmp->AddGen("Unselect", "ctrl+shift+a", EDN_MSG__CURRENT_UN_SELECT, true);
|
||||
tmp->AddSeparator();
|
||||
tmp->AddGen("Goto Line number ...", "ctrl+l", EDN_MSG__GUI_SHOW_GOTO_LINE, true);
|
||||
// tmp->AddSeparator();
|
||||
// tmp->AddGen(GTK_STOCK_PREFERENCES, NULL, EDN_MSG__GUI_SHOW_PREFERENCE, true);
|
||||
m_listMenu.PushBack(tmp);
|
||||
|
||||
tmp = new MenuBarMain("_Search", m_mainWidget);
|
||||
tmp->AddGen(GTK_STOCK_FIND, "ctrl+f", EDN_MSG__GUI_SHOW_SEARCH, true);
|
||||
tmp->AddGen(GTK_STOCK_FIND_AND_REPLACE, "ctrl+r", EDN_MSG__GUI_SHOW_REPLACE, true);
|
||||
tmp->AddSeparator();
|
||||
tmp->AddGen("Find next", "ctrl+h", EDN_MSG__CURRENT_FIND_NEXT, true);
|
||||
tmp->AddGen("Find previous", "ctrl+shift+h", EDN_MSG__CURRENT_FIND_PREVIOUS, true);
|
||||
// tmp->AddGen("Find old next", "ctrl+g", EDN_MSG__CURRENT_FIND_OLD_NEXT, true);
|
||||
// tmp->AddGen("Find old previous", "ctrl+shift+g", EDN_MSG__CURRENT_FIND_OLD_PREVIOUS, true);
|
||||
// tmp->AddSeparator();
|
||||
// tmp->AddGen("Suprimer colorisation", NULL);
|
||||
// tmp->AddSeparator();
|
||||
// tmp->AddGen("Goto Line", "ctrl+l", EDN_MSG__CURRENT_GOTO_LINE, true);
|
||||
m_listMenu.PushBack(tmp);
|
||||
|
||||
tmp = new MenuBarMain("Display", m_mainWidget);
|
||||
tmp->AddInternal("Show space & tabs", NULL, MSG_TogleDisplayChar, true);
|
||||
tmp->AddInternal("Show end of lines", NULL, MSG_TogleDisplayEOL, true);
|
||||
tmp->AddInternal("Audo Indent", NULL, MSG_TogleAutoIndent, true);
|
||||
tmp->AddSeparator();
|
||||
tmp->AddInternal("Set charset Occidental (ISO-8859-1)", NULL, MSG_SetCharsetIso559_1, true);
|
||||
tmp->AddInternal("Set charset Occidental (ISO-8859-15)", NULL, MSG_SetCharsetIso559_15, true);
|
||||
tmp->AddInternal("Set charset Internationnal (UTF 8)", NULL, MSG_SetCharsetUTF8, true);
|
||||
tmp->AddSeparator();
|
||||
tmp->AddGen( "Reload Color File", NULL, EDN_MSG__RELOAD_COLOR_FILE, true);
|
||||
tmp->AddSeparator();
|
||||
tmp->AddInternal("Set Color Black", NULL, MSG_LoadColorBlack, true);
|
||||
tmp->AddInternal("Set Color White", NULL, MSG_LoadColorWhite, true);
|
||||
m_listMenu.PushBack(tmp);
|
||||
/*
|
||||
tmp = new MenuBarMain("Project", m_mainWidget);
|
||||
m_listMenu.PushBack(tmp);
|
||||
*/
|
||||
tmp = new MenuBarMain("Ctags", m_mainWidget);
|
||||
tmp->AddGen("load Ctags file", NULL, EDN_MSG__OPEN_CTAGS, true);
|
||||
tmp->AddGen("re-load Ctags file", NULL, EDN_MSG__RELOAD_CTAGS, true);
|
||||
tmp->AddSeparator();
|
||||
tmp->AddGen("Find Definition", "ctrl+d", EDN_MSG__JUMP_TO_CURRENT_SELECTION, true);
|
||||
tmp->AddGen("Back previous", "ctrl+shift+d", EDN_MSG__JUMP_BACK, true);
|
||||
/*
|
||||
tmp->AddGen("Gestion Ctags", NULL);
|
||||
tmp->AddGen("Add Ctags Folder", NULL);
|
||||
tmp->AddSeparator();
|
||||
tmp->AddGen("Trouver la definition", NULL);
|
||||
tmp->AddGen("Trouver la declaration", NULL);
|
||||
tmp->AddGen("Retour...", NULL);
|
||||
tmp->AddSeparator();
|
||||
tmp->AddGen("Tout desactiver", NULL);
|
||||
*/
|
||||
m_listMenu.PushBack(tmp);
|
||||
/*
|
||||
tmp = new MenuBarMain("Macros", m_mainWidget);
|
||||
m_listMenu.PushBack(tmp);
|
||||
*/
|
||||
/*
|
||||
tmp = new MenuBarMain("Tools", m_mainWidget);
|
||||
tmp->AddGen("Execute Commande", "ctrl+e");
|
||||
tmp->AddGen("Set Command", NULL);
|
||||
m_listMenu.PushBack(tmp);
|
||||
*/
|
||||
tmp = new MenuBarMain("Internal ClipBoard", m_mainWidget);
|
||||
// tmp->AddGen("Cut 1", "ctrl+alt+1", EDN_MSG__CURRENT_CUT, true, 1);
|
||||
tmp->AddGen("Copy 1", "ctrl+1", EDN_MSG__CURRENT_COPY, true, 1);
|
||||
tmp->AddGen("Paste 1", "alt+1", EDN_MSG__CURRENT_PASTE, true, 1);
|
||||
tmp->AddSeparator();
|
||||
// tmp->AddGen("Cut 2", "ctrl+alt+2", EDN_MSG__CURRENT_CUT, true, 2);
|
||||
tmp->AddGen("Copy 2", "ctrl+2", EDN_MSG__CURRENT_COPY, true, 2);
|
||||
tmp->AddGen("Paste 2", "alt+2", EDN_MSG__CURRENT_PASTE, true, 2);
|
||||
tmp->AddSeparator();
|
||||
// tmp->AddGen("Cut 3", "ctrl+alt+3", EDN_MSG__CURRENT_CUT, true, 3);
|
||||
tmp->AddGen("Copy 3", "ctrl+3", EDN_MSG__CURRENT_COPY, true, 3);
|
||||
tmp->AddGen("Paste 3", "alt+3", EDN_MSG__CURRENT_PASTE, true, 3);
|
||||
tmp->AddSeparator();
|
||||
// tmp->AddGen("Cut 4", "ctrl+alt+4", EDN_MSG__CURRENT_CUT, true, 4);
|
||||
tmp->AddGen("Copy 4", "ctrl+4", EDN_MSG__CURRENT_COPY, true, 4);
|
||||
tmp->AddGen("Paste 4", "alt+4", EDN_MSG__CURRENT_PASTE, true, 4);
|
||||
tmp->AddSeparator();
|
||||
// tmp->AddGen("Cut 5", "ctrl+alt+5", EDN_MSG__CURRENT_CUT, true, 5);
|
||||
tmp->AddGen("Copy 5", "ctrl+5", EDN_MSG__CURRENT_COPY, true, 5);
|
||||
tmp->AddGen("Paste 5", "alt+5", EDN_MSG__CURRENT_PASTE, true, 5);
|
||||
tmp->AddSeparator();
|
||||
// tmp->AddGen("Cut 6", "ctrl+alt+6", EDN_MSG__CURRENT_CUT, true, 6);
|
||||
tmp->AddGen("Copy 6", "ctrl+6", EDN_MSG__CURRENT_COPY, true, 6);
|
||||
tmp->AddGen("Paste 6", "alt+6", EDN_MSG__CURRENT_PASTE, true, 6);
|
||||
tmp->AddSeparator();
|
||||
// tmp->AddGen("Cut 7", "ctrl+alt+7", EDN_MSG__CURRENT_CUT, true, 7);
|
||||
tmp->AddGen("Copy 7", "ctrl+7", EDN_MSG__CURRENT_COPY, true, 7);
|
||||
tmp->AddGen("Paste 7", "alt+7", EDN_MSG__CURRENT_PASTE, true, 7);
|
||||
tmp->AddSeparator();
|
||||
// tmp->AddGen("Cut 8", "ctrl+alt+8", EDN_MSG__CURRENT_CUT, true, 8);
|
||||
tmp->AddGen("Copy 8", "ctrl+8", EDN_MSG__CURRENT_COPY, true, 8);
|
||||
tmp->AddGen("Paste 8", "alt+8", EDN_MSG__CURRENT_PASTE, true, 8);
|
||||
tmp->AddSeparator();
|
||||
// tmp->AddGen("Cut 9", "ctrl+alt+9", EDN_MSG__CURRENT_CUT, true, 9);
|
||||
tmp->AddGen("Copy 9", "ctrl+9", EDN_MSG__CURRENT_COPY, true, 9);
|
||||
tmp->AddGen("Paste 9", "alt+9", EDN_MSG__CURRENT_PASTE, true, 9);
|
||||
m_listMenu.PushBack(tmp);
|
||||
|
||||
tmp = new MenuBarMain("Help", m_mainWidget);
|
||||
tmp->AddGen("help display", NULL, EDN_MSG__OPEN_CTAGS, false);
|
||||
tmp->AddSeparator();
|
||||
tmp->AddGen("About ...", NULL, EDN_MSG__GUI_SHOW_ABOUT, true);
|
||||
/*
|
||||
tmp->AddGen("Gestion Ctags", NULL);
|
||||
tmp->AddGen("Add Ctags Folder", NULL);
|
||||
tmp->AddSeparator();
|
||||
tmp->AddGen("Trouver la definition", NULL);
|
||||
tmp->AddGen("Trouver la declaration", NULL);
|
||||
tmp->AddGen("Retour...", NULL);
|
||||
tmp->AddSeparator();
|
||||
tmp->AddGen("Tout desactiver", NULL);
|
||||
*/
|
||||
m_listMenu.PushBack(tmp);
|
||||
|
||||
}
|
||||
|
||||
MenuBar::~MenuBar(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MenuBar::OnMessage(int32_t id, int32_t dataID)
|
||||
{
|
||||
//EDN_INFO("ReceiveMessage");
|
||||
}
|
||||
|
||||
#endif
|
@@ -1,55 +0,0 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file MenuBar.h
|
||||
* @brief Editeur De N'ours : abstraction of the menu bar (Header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 17/06/2011
|
||||
* @par Project
|
||||
* Edn
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2010 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
* You can not earn money with this Software (if the source extract from Edn
|
||||
* represent less than 50% of original Sources)
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <tools_debug.h>
|
||||
#include <tools_globals.h>
|
||||
#include <MsgBroadcast.h>
|
||||
#include <etk/VectorType.h>
|
||||
#include <AccelKey.h>
|
||||
|
||||
#ifndef __MENU_BAR_H__
|
||||
#define __MENU_BAR_H__
|
||||
|
||||
//class MenuBarMain;
|
||||
|
||||
class MenuBar
|
||||
{
|
||||
public:
|
||||
// Constructeur
|
||||
MenuBar(void) {};
|
||||
~MenuBar(void) {};
|
||||
//GtkWidget * GetWidget(void) { return m_mainWidget; };
|
||||
void OnMessage(int32_t id, int32_t dataID) {};
|
||||
|
||||
private:
|
||||
/*
|
||||
GtkWidget * m_mainWidget;
|
||||
GtkAccelGroup * m_accelGroup;
|
||||
etk::VectorType<MenuBarMain*> m_listMenu;
|
||||
*/
|
||||
};
|
||||
|
||||
|
||||
#endif
|
@@ -1,54 +0,0 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file StatusBar.cpp
|
||||
* @brief Editeur De N'ours : abstraction of the status bar (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 17/06/2011
|
||||
* @par Project
|
||||
* Edn
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2010 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
* You can not earn money with this Software (if the source extract from Edn
|
||||
* represent less than 50% of original Sources)
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <tools_debug.h>
|
||||
#include <StatusBar.h>
|
||||
|
||||
|
||||
|
||||
StatusBar::StatusBar(void)
|
||||
{
|
||||
/*
|
||||
m_mainWidget = gtk_statusbar_new();
|
||||
// pas tr<74>s bien compris pourquoi mais ca marche...
|
||||
m_iContextId = gtk_statusbar_get_context_id(GTK_STATUSBAR(m_mainWidget), "ExitMsg");
|
||||
// ajout d'un message :
|
||||
gtk_statusbar_push(GTK_STATUSBAR (m_mainWidget), GPOINTER_TO_INT(m_iContextId), "Edn Editeur de n'ours");
|
||||
// Supression du pr<70>c<EFBFBD>dent message :
|
||||
//gtk_statusbar_pop(GTK_STATUSBAR(m_mainWidget), GPOINTER_TO_INT(m_iContextId));
|
||||
*/
|
||||
}
|
||||
|
||||
StatusBar::~StatusBar(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void StatusBar::OnMessage(int32_t id, int32_t dataID)
|
||||
{
|
||||
//EDN_INFO("ReceiveMessage");
|
||||
}
|
||||
|
||||
|
@@ -1,46 +0,0 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file StatusBar.h
|
||||
* @brief Editeur De N'ours : abstraction of the status bar (Header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 17/06/2011
|
||||
* @par Project
|
||||
* Edn
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2010 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
* You can not earn money with this Software (if the source extract from Edn
|
||||
* represent less than 50% of original Sources)
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <MsgBroadcast.h>
|
||||
|
||||
#ifndef __STATUS_BAR_H__
|
||||
#define __STATUS_BAR_H__
|
||||
|
||||
class StatusBar
|
||||
{
|
||||
public:
|
||||
// Constructeur
|
||||
StatusBar(void);
|
||||
~StatusBar(void);
|
||||
//GtkWidget * GetWidget(void) { return m_mainWidget; };
|
||||
void OnMessage(int32_t id, int32_t dataID);
|
||||
|
||||
private:
|
||||
//GtkWidget * m_mainWidget;
|
||||
//guint m_iContextId;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
@@ -1,95 +0,0 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ToolBar.cpp
|
||||
* @brief Editeur De N'ours : abstraction of the tool bar (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 17/06/2011
|
||||
* @par Project
|
||||
* Edn
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2010 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
* You can not earn money with this Software (if the source extract from Edn
|
||||
* represent less than 50% of original Sources)
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <tools_debug.h>
|
||||
#include <ToolBar.h>
|
||||
#include <ClipBoard.h>
|
||||
|
||||
/*
|
||||
static void CB_menuGenerique(GtkMenuItem *menu_item, gpointer data)
|
||||
{
|
||||
//EDN_INFO("basic menue_event");
|
||||
messageData_ts * msg = (messageData_ts*)data;
|
||||
// broacast message :
|
||||
GeneralSendMessage(msg->msgId, msg->dataId);
|
||||
}
|
||||
*/
|
||||
|
||||
ToolBar::ToolBar(void)
|
||||
{
|
||||
/*
|
||||
m_mainWidget = gtk_toolbar_new();
|
||||
# ifdef USE_GTK_VERSION_2_0
|
||||
gtk_toolbar_set_orientation(GTK_TOOLBAR(m_mainWidget), GTK_ORIENTATION_VERTICAL);
|
||||
# endif
|
||||
// Modification de la taille des icones
|
||||
gtk_toolbar_set_icon_size(GTK_TOOLBAR(m_mainWidget), GTK_ICON_SIZE_BUTTON);
|
||||
// Affichage uniquement des icones
|
||||
gtk_toolbar_set_style(GTK_TOOLBAR(m_mainWidget), GTK_TOOLBAR_ICONS);
|
||||
|
||||
Add(GTK_STOCK_NEW, "Nouveau", EDN_MSG__NEW);
|
||||
Add(GTK_STOCK_OPEN, "Ouvrir", EDN_MSG__GUI_SHOW_OPEN_FILE);
|
||||
AddSeparator();
|
||||
Add(GTK_STOCK_SAVE, "Enregistrer", EDN_MSG__CURRENT_SAVE);
|
||||
Add(GTK_STOCK_SAVE_AS, "Enregistrer sous", EDN_MSG__CURRENT_SAVE_AS);
|
||||
AddSeparator();
|
||||
Add(GTK_STOCK_QUIT, "Quitter");
|
||||
*/
|
||||
}
|
||||
|
||||
ToolBar::~ToolBar(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ToolBar::OnMessage(int32_t id, int32_t dataID)
|
||||
{
|
||||
//EDN_INFO("ReceiveMessage");
|
||||
}
|
||||
/*
|
||||
void ToolBar::AddSeparator(void)
|
||||
{
|
||||
# ifdef USE_GTK_VERSION_3_0
|
||||
# elif defined( USE_GTK_VERSION_2_0)
|
||||
gtk_toolbar_append_space(GTK_TOOLBAR(m_mainWidget));
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
void ToolBar::Add(const char * title, const char * labelHelp, messageType_te id, bool enable)
|
||||
{
|
||||
messageData_ts * message = new messageData_ts;
|
||||
message->msgId = id;
|
||||
message->dataId = -1;
|
||||
m_message.PushBack(message);
|
||||
# ifdef USE_GTK_VERSION_3_0
|
||||
# elif defined( USE_GTK_VERSION_2_0)
|
||||
gtk_toolbar_insert_stock(GTK_TOOLBAR(m_mainWidget), title, labelHelp, NULL, G_CALLBACK(CB_menuGenerique), message, -1);
|
||||
# endif
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
@@ -1,49 +0,0 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ToolBar.h
|
||||
* @brief Editeur De N'ours : abstraction of the tool bar (Header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 17/06/2011
|
||||
* @par Project
|
||||
* Edn
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2010 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
* You can not earn money with this Software (if the source extract from Edn
|
||||
* represent less than 50% of original Sources)
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <MsgBroadcast.h>
|
||||
|
||||
#ifndef __TOOL_BAR_H__
|
||||
#define __TOOL_BAR_H__
|
||||
|
||||
|
||||
class ToolBar
|
||||
{
|
||||
public:
|
||||
// Constructeur
|
||||
ToolBar(void);
|
||||
~ToolBar(void);
|
||||
//GtkWidget * GetWidget(void) { return m_mainWidget; };
|
||||
void OnMessage(int32_t id, int32_t dataID);
|
||||
|
||||
private:
|
||||
//void AddSeparator(void);
|
||||
//void Add(const char * title, const char * labelHelp, messageType_te id = EDN_MSG__NONE, bool enable = false);
|
||||
//GtkWidget * m_mainWidget;
|
||||
//etk::VectorType<messageData_ts*> m_message;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
@@ -1,320 +0,0 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file WindowsManager.cpp
|
||||
* @brief Editeur De N'ours : Windows creation, pop up, destruction ... (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/06/2011
|
||||
* @par Project
|
||||
* Edn
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2010 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
* You can not earn money with this Software (if the source extract from Edn
|
||||
* represent less than 50% of original Sources)
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#include <tools_debug.h>
|
||||
#include <tools_globals.h>
|
||||
#include <WindowsManager.h>
|
||||
#include <MainWindows.h>
|
||||
#include <Search.h>
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "WindowsManager"
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
WindowsManager::WindowsManager(void)
|
||||
{
|
||||
m_currentBufferID = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
WindowsManager::~WindowsManager(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void WindowsManager::OnMessage(int32_t id, int32_t dataID)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
/*
|
||||
case EDN_MSG__BUFFER_CHANGE_CURRENT:
|
||||
m_currentBufferID = dataID;
|
||||
break;
|
||||
case EDN_MSG__GUI_SHOW_MAIN_WINDOWS:
|
||||
EDN_INFO("Request opening MAIN_WINDOWS");
|
||||
m_mainWindow = MainWindows::getInstance();
|
||||
break;
|
||||
case EDN_MSG__GUI_SHOW_SEARCH:
|
||||
EDN_INFO("Request opening SEARCH");
|
||||
{
|
||||
Search *myInstance = Search::getInstance();
|
||||
myInstance->Display(GTK_WINDOW(m_mainWindow->GetWidget()));
|
||||
}
|
||||
break;
|
||||
case EDN_MSG__GUI_SHOW_PREFERENCE:
|
||||
EDN_INFO("Request opening PREFERENCE");
|
||||
break;
|
||||
case EDN_MSG__GUI_SHOW_REPLACE:
|
||||
EDN_INFO("Request opening REPLACE");
|
||||
break;
|
||||
case EDN_MSG__GUI_SHOW_OPEN_FILE:
|
||||
EDN_INFO("Request opening OPEN_FILE");
|
||||
{
|
||||
BufferManager *myBufferManager = NULL;
|
||||
myBufferManager = BufferManager::getInstance();
|
||||
|
||||
GtkWidget *dialog = gtk_file_chooser_dialog_new( "Open File", NULL,
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
|
||||
NULL); // end button/response list
|
||||
// this element did not apear in the miniature of the windows
|
||||
gtk_window_set_skip_pager_hint(GTK_WINDOW(dialog), TRUE);
|
||||
if( -1 != m_currentBufferID
|
||||
&& true == myBufferManager->Exist(m_currentBufferID) )
|
||||
{
|
||||
etk::File fileName = myBufferManager->Get(m_currentBufferID)->GetFileName();
|
||||
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), fileName.GetFolder().c_str());
|
||||
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), fileName.GetShortFilename().c_str());
|
||||
}
|
||||
if (gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
|
||||
{
|
||||
etk::File myfilename;
|
||||
myfilename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (dialog));
|
||||
|
||||
if (false == myBufferManager->Exist(myfilename) ) {
|
||||
int32_t openID = myBufferManager->Open(myfilename);
|
||||
SendMessage(EDN_MSG__CURRENT_CHANGE_BUFFER_ID, openID);
|
||||
} else {
|
||||
SendMessage(EDN_MSG__CURRENT_CHANGE_BUFFER_ID, myBufferManager->GetId(myfilename));
|
||||
}
|
||||
}
|
||||
gtk_widget_destroy(dialog);
|
||||
}
|
||||
break;
|
||||
case EDN_MSG__GUI_SHOW_SAVE_AS:
|
||||
EDN_INFO("Request opening SAVE_AS");
|
||||
// save only if one element is selected
|
||||
if (BufferManager::getInstance()->Size() > 0) {
|
||||
int32_t idSelected;
|
||||
if(-1 == dataID) {
|
||||
idSelected = BufferManager::getInstance()->GetSelected();
|
||||
} else {
|
||||
idSelected = dataID;
|
||||
}
|
||||
Buffer *myBuffer = BufferManager::getInstance()->Get(idSelected);
|
||||
etk::UString tmpString = "Save as file : ";
|
||||
tmpString += myBuffer->GetFileName().GetShortFilename().c_str();
|
||||
GtkWidget *dialog = gtk_file_chooser_dialog_new( tmpString.c_str(), NULL,
|
||||
GTK_FILE_CHOOSER_ACTION_SAVE,
|
||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
|
||||
NULL); // end button/response list
|
||||
// this element did not apear in the miniature of the windows
|
||||
gtk_window_set_skip_pager_hint(GTK_WINDOW(dialog), TRUE);
|
||||
if (gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
|
||||
{
|
||||
etk::UString myfilename;
|
||||
myfilename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (dialog));
|
||||
|
||||
myBuffer->SetFileName(myfilename);
|
||||
myBuffer->Save();
|
||||
|
||||
SendMessage(EDN_MSG__CURRENT_CHANGE_BUFFER_ID, idSelected);
|
||||
}
|
||||
gtk_widget_destroy(dialog); // implicitly hides dialog
|
||||
}
|
||||
break;
|
||||
case EDN_MSG__GUI_SHOW_ABOUT:
|
||||
{
|
||||
GtkWidget *myDialog = gtk_about_dialog_new();
|
||||
gtk_about_dialog_set_program_name(GTK_ABOUT_DIALOG(myDialog), "Edn");
|
||||
gtk_about_dialog_set_version( GTK_ABOUT_DIALOG(myDialog), VERSION_TAG_NAME);
|
||||
gtk_about_dialog_set_comments( GTK_ABOUT_DIALOG(myDialog), "Editeur De N'ours\n"
|
||||
"L'Editeur Desoxyribo-Nucleique.\n"
|
||||
"Source Code Editor\n"
|
||||
"Build Time : " VERSION_BUILD_TIME);
|
||||
gtk_about_dialog_set_copyright( GTK_ABOUT_DIALOG(myDialog), "Copyright 2010 Edouard DUPIN, all right reserved");
|
||||
gtk_about_dialog_set_license( GTK_ABOUT_DIALOG(myDialog), "This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY\n\n"
|
||||
"You can:\n"
|
||||
" * Redistribute the sources code and binaries.\n"
|
||||
" * Modify the Sources code.\n"
|
||||
" * Use a part of the sources (less than 50%) in an other software, just write somewhere \"Edn is great\" visible by the user (on your product or on your website with a link to my page).\n"
|
||||
" * Redistribute the modification only if you want.\n"
|
||||
" * Send me the bug-fix (it could be great).\n"
|
||||
" * Pay me a beer or some other things.\n"
|
||||
" * Print the source code on WC paper ...\n\n"
|
||||
"You can NOT:\n"
|
||||
" * Earn money with this Software (But I can).\n"
|
||||
" * Add malware in the Sources.\n"
|
||||
" * Do something bad with the sources.\n"
|
||||
" * Use it to travel in the space with a toaster.\n\n"
|
||||
"I reserve the right to change this licence. If it change the version of the copy you have keep its own license.");
|
||||
gtk_about_dialog_set_wrap_license(GTK_ABOUT_DIALOG(myDialog), true);
|
||||
# if USE_GTK_VERSION_3_0
|
||||
gtk_about_dialog_set_license_type(GTK_ABOUT_DIALOG(myDialog), GTK_LICENSE_CUSTOM);
|
||||
# endif
|
||||
gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(myDialog), "http://HeeroYui.github.com/edn");
|
||||
gtk_about_dialog_set_website_label(GTK_ABOUT_DIALOG(myDialog), "Edn on github");
|
||||
const char * listAutor[] = {"Edouard DUPIN", NULL};
|
||||
gtk_about_dialog_set_authors(GTK_ABOUT_DIALOG(myDialog), listAutor);
|
||||
// Display About
|
||||
gtk_dialog_run(GTK_DIALOG(myDialog));
|
||||
gtk_widget_destroy(myDialog);
|
||||
}
|
||||
break;
|
||||
case EDN_MSG__GUI_SHOW_GOTO_LINE:
|
||||
{
|
||||
// dlg to confirm the quit event :
|
||||
GtkWidget *myDialog = gtk_dialog_new_with_buttons("Goto Line",
|
||||
GTK_WINDOW(m_mainWindow->GetWidget()),
|
||||
GTK_DIALOG_MODAL,
|
||||
"Jump", GTK_RESPONSE_YES,
|
||||
GTK_STOCK_QUIT, GTK_RESPONSE_NO,
|
||||
NULL);
|
||||
// this element did not apear in the miniature of the windows
|
||||
gtk_window_set_skip_pager_hint(GTK_WINDOW(myDialog), TRUE);
|
||||
// Set over main windows
|
||||
gtk_window_set_transient_for(GTK_WINDOW(myDialog), GTK_WINDOW(m_mainWindow->GetWidget()));
|
||||
// add writting area
|
||||
GtkWidget *myContentArea = gtk_dialog_get_content_area( GTK_DIALOG(myDialog));
|
||||
GtkWidget *myEntry = gtk_entry_new();
|
||||
gtk_box_pack_start(GTK_BOX(myContentArea), myEntry, TRUE, TRUE, 0);
|
||||
// Display it
|
||||
gtk_widget_show_all(myContentArea);
|
||||
int32_t result = gtk_dialog_run (GTK_DIALOG (myDialog));
|
||||
// Get data from the gtk entry
|
||||
const char *myData = gtk_entry_get_text(GTK_ENTRY(myEntry));
|
||||
if (NULL != myData) {
|
||||
int32_t lineID=0;
|
||||
if (1==sscanf(myData, "%d",&lineID)) {
|
||||
EDN_DEBUG("find in : \"" << myData << "\" = " << lineID);
|
||||
if(GTK_RESPONSE_YES == result) {
|
||||
SendMessage(EDN_MSG__CURRENT_GOTO_LINE, lineID-1);
|
||||
}
|
||||
} else {
|
||||
if (GTK_RESPONSE_YES == result) {
|
||||
EDN_WARNING("find in : \"" << myData << "\" line Number is not correct ");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
EDN_DEBUG("no line Writen ...");
|
||||
}
|
||||
// Remove dialogue
|
||||
gtk_widget_destroy(myDialog);
|
||||
}
|
||||
break;
|
||||
case EDN_MSG__GUI_SHOW_EXIT_CONFIRMATION:
|
||||
{
|
||||
EDN_INFO("quit requested");
|
||||
// dlg to confirm the quit event :
|
||||
GtkWidget *p_dialog = gtk_dialog_new_with_buttons("Exit",
|
||||
GTK_WINDOW(m_mainWindow->GetWidget()),
|
||||
GTK_DIALOG_MODAL,
|
||||
GTK_STOCK_YES, GTK_RESPONSE_YES,
|
||||
GTK_STOCK_NO, GTK_RESPONSE_NO,
|
||||
NULL);
|
||||
GtkWidget *p_label = gtk_label_new ("Do you want exit Edn ?");
|
||||
gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area( GTK_DIALOG(p_dialog) )), p_label, TRUE, TRUE, 0);
|
||||
gtk_widget_show(p_label);
|
||||
|
||||
switch (gtk_dialog_run (GTK_DIALOG (p_dialog)))
|
||||
{
|
||||
case GTK_RESPONSE_YES:
|
||||
gtk_widget_destroy (p_dialog);
|
||||
p_dialog = NULL;
|
||||
{
|
||||
BufferManager * myBufferMng = BufferManager::getInstance();
|
||||
for (int32_t iii=0 ; iii<myBufferMng->Size() ; iii++) {
|
||||
if (true==myBufferMng->Exist(iii) ) {
|
||||
Buffer * myBuffer = myBufferMng->Get(iii);
|
||||
if (NULL != myBuffer) {
|
||||
if (true == myBuffer->IsModify()) {
|
||||
if (true == myBuffer->HaveName()) {
|
||||
p_dialog = gtk_dialog_new_with_buttons("Save Before Exit",
|
||||
GTK_WINDOW(m_mainWindow->GetWidget()),
|
||||
GTK_DIALOG_MODAL,
|
||||
GTK_STOCK_SAVE, GTK_RESPONSE_YES,
|
||||
GTK_STOCK_SAVE_AS, GTK_RESPONSE_ACCEPT,
|
||||
GTK_STOCK_NO, GTK_RESPONSE_NO,
|
||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||
NULL);
|
||||
} else {
|
||||
p_dialog = gtk_dialog_new_with_buttons("Save Before Exit",
|
||||
GTK_WINDOW(m_mainWindow->GetWidget()),
|
||||
GTK_DIALOG_MODAL,
|
||||
GTK_STOCK_SAVE_AS, GTK_RESPONSE_ACCEPT,
|
||||
GTK_STOCK_NO, GTK_RESPONSE_NO,
|
||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||
NULL);
|
||||
}
|
||||
char tmpName[1024];
|
||||
sprintf(tmpName, "Save file \"%s\" ?", myBuffer->GetFileName().GetCompleateName().c_str());
|
||||
p_label = gtk_label_new(tmpName);
|
||||
gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area( GTK_DIALOG(p_dialog) )), p_label, TRUE, TRUE, 0);
|
||||
gtk_widget_show(p_label);
|
||||
|
||||
switch (gtk_dialog_run (GTK_DIALOG (p_dialog)))
|
||||
{
|
||||
case GTK_RESPONSE_YES:
|
||||
myBuffer->Save();
|
||||
break;
|
||||
case GTK_RESPONSE_ACCEPT:
|
||||
OnMessage(EDN_MSG__GUI_SHOW_SAVE_AS, iii);
|
||||
break;
|
||||
case GTK_RESPONSE_NO:
|
||||
// nothing to do ...
|
||||
break;
|
||||
case GTK_RESPONSE_CANCEL:
|
||||
gtk_widget_destroy (p_dialog);
|
||||
return;
|
||||
break;
|
||||
}
|
||||
gtk_widget_destroy (p_dialog);
|
||||
p_dialog = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
gtk_main_quit();
|
||||
break;
|
||||
case GTK_RESPONSE_NO:
|
||||
gtk_widget_destroy (p_dialog);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
*/
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
@@ -1,50 +0,0 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file WindowsManager.h
|
||||
* @brief Editeur De N'ours : Windows creation, pop up, destruction ... (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/06/2011
|
||||
* @par Project
|
||||
* Edn
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2010 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
* You can not earn money with this Software (if the source extract from Edn
|
||||
* represent less than 50% of original Sources)
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __WINDOWS_MANAGER_H__
|
||||
#define __WINDOWS_MANAGER_H__
|
||||
|
||||
#include <etk/Singleton.h>
|
||||
#include <MsgBroadcast.h>
|
||||
#include <MainWindows.h>
|
||||
|
||||
class WindowsManager: public etk::Singleton<WindowsManager>
|
||||
{
|
||||
friend class etk::Singleton<WindowsManager>;
|
||||
// specific for sigleton system...
|
||||
private:
|
||||
// Constructeur
|
||||
WindowsManager(void);
|
||||
~WindowsManager(void);
|
||||
|
||||
public:
|
||||
void OnMessage(int32_t id, int32_t dataID);
|
||||
private:
|
||||
MainWindows * m_mainWindow;
|
||||
int32_t m_currentBufferID;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -26,107 +26,172 @@
|
||||
#include <tools_debug.h>
|
||||
#include <tools_globals.h>
|
||||
#include <HighlightManager.h>
|
||||
#include <ewol/WidgetMessageMultiCast.h>
|
||||
#include <ewol/EObject.h>
|
||||
#include <ewol/EObjectManager.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "HighlightManager"
|
||||
|
||||
HighlightManager::HighlightManager(void)
|
||||
{
|
||||
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgBufferColor);
|
||||
}
|
||||
|
||||
HighlightManager::~HighlightManager(void)
|
||||
class localClassHighlightManager: public ewol::EObject
|
||||
{
|
||||
int32_t i;
|
||||
// clean all Element
|
||||
for (i=0; i< listHighlight.Size(); i++) {
|
||||
if (NULL != listHighlight[i]) {
|
||||
delete(listHighlight[i]);
|
||||
listHighlight[i] = NULL;
|
||||
}
|
||||
}
|
||||
// clear the compleate list
|
||||
listHighlight.Clear();
|
||||
}
|
||||
|
||||
|
||||
bool HighlightManager::OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, etkFloat_t x, etkFloat_t y)
|
||||
{
|
||||
/*
|
||||
switch (id)
|
||||
{
|
||||
case EDN_MSG__COLOR_HAS_CHANGE:
|
||||
EDN_INFO("UPDATE the color pointer on the HL");
|
||||
for (int32_t i=0; i<listHighlight.Size(); i++) {
|
||||
private:
|
||||
etk::VectorType<Highlight*> listHighlight; //!< List of ALL hightlight modules
|
||||
public:
|
||||
// Constructeur
|
||||
localClassHighlightManager(void) {
|
||||
//ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgBufferColor);
|
||||
};
|
||||
~localClassHighlightManager(void) {
|
||||
int32_t i;
|
||||
// clean all Element
|
||||
for (i=0; i< listHighlight.Size(); i++) {
|
||||
if (NULL != listHighlight[i]) {
|
||||
listHighlight[i]->ReloadColor();
|
||||
delete(listHighlight[i]);
|
||||
listHighlight[i] = NULL;
|
||||
}
|
||||
}
|
||||
break;
|
||||
// clear the compleate list
|
||||
listHighlight.Clear();
|
||||
};
|
||||
/**
|
||||
* @brief Receive a message from an other EObject with a specific eventId and data
|
||||
* @param[in] CallerObject Pointer on the EObject that information came from
|
||||
* @param[in] eventId Message registered by this class
|
||||
* @param[in] data Data registered by this class
|
||||
* @return ---
|
||||
*/
|
||||
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
|
||||
{
|
||||
/*
|
||||
switch (id)
|
||||
{
|
||||
case EDN_MSG__COLOR_HAS_CHANGE:
|
||||
EDN_INFO("UPDATE the color pointer on the HL");
|
||||
for (int32_t i=0; i<listHighlight.Size(); i++) {
|
||||
if (NULL != listHighlight[i]) {
|
||||
listHighlight[i]->ReloadColor();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
Highlight* Get(etk::File &fileName)
|
||||
{
|
||||
int32_t i;
|
||||
for (i=0; i<listHighlight.Size(); i++) {
|
||||
if (true == listHighlight[i]->FileNameCompatible(fileName) ) {
|
||||
return listHighlight[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool Exist(etk::File &fileName)
|
||||
{
|
||||
if (NULL != Get(fileName) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void loadLanguages(void)
|
||||
{
|
||||
etk::UString xmlFilename = "lang_c.xml";
|
||||
Highlight *myHightline = new Highlight(xmlFilename);
|
||||
listHighlight.PushBack(myHightline);
|
||||
|
||||
xmlFilename = "lang_boo.xml";
|
||||
myHightline = new Highlight(xmlFilename);
|
||||
listHighlight.PushBack(myHightline);
|
||||
|
||||
xmlFilename = "lang_Makefile.xml";
|
||||
myHightline = new Highlight(xmlFilename);
|
||||
listHighlight.PushBack(myHightline);
|
||||
|
||||
xmlFilename = "lang_asm.xml";
|
||||
myHightline = new Highlight(xmlFilename);
|
||||
listHighlight.PushBack(myHightline);
|
||||
|
||||
xmlFilename = "lang_xml.xml";
|
||||
myHightline = new Highlight(xmlFilename);
|
||||
listHighlight.PushBack(myHightline);
|
||||
|
||||
xmlFilename = "lang_php.xml";
|
||||
myHightline = new Highlight(xmlFilename);
|
||||
listHighlight.PushBack(myHightline);
|
||||
|
||||
xmlFilename = "lang_bash.xml";
|
||||
myHightline = new Highlight(xmlFilename);
|
||||
listHighlight.PushBack(myHightline);
|
||||
|
||||
xmlFilename = "lang_matlab.xml";
|
||||
myHightline = new Highlight(xmlFilename);
|
||||
listHighlight.PushBack(myHightline);
|
||||
|
||||
xmlFilename = "lang_java.xml";
|
||||
myHightline = new Highlight(xmlFilename);
|
||||
listHighlight.PushBack(myHightline);
|
||||
|
||||
//myHightline->Display();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
static localClassHighlightManager * localManager = NULL;
|
||||
|
||||
|
||||
|
||||
void HighlightManager::Init(void)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
EWOL_ERROR("HighlightManager ==> already exist, just unlink the previous ...");
|
||||
localManager = NULL;
|
||||
}
|
||||
localManager = new localClassHighlightManager();
|
||||
|
||||
if (NULL == localManager) {
|
||||
EWOL_CRITICAL("Allocation of HighlightManager not done ...");
|
||||
}
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
Highlight *HighlightManager::Get(etk::File &fileName)
|
||||
void HighlightManager::UnInit(void)
|
||||
{
|
||||
int32_t i;
|
||||
for (i=0; i<listHighlight.Size(); i++) {
|
||||
if (true == listHighlight[i]->FileNameCompatible(fileName) ) {
|
||||
return listHighlight[i];
|
||||
}
|
||||
if (NULL == localManager) {
|
||||
EWOL_ERROR("HighlightManager ==> request UnInit, but does not exist ...");
|
||||
return;
|
||||
}
|
||||
return NULL;
|
||||
ewol::EObjectManager::MarkToRemoved(localManager);
|
||||
localManager = NULL;
|
||||
}
|
||||
|
||||
void HighlightManager::loadLanguages(void)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
return;
|
||||
}
|
||||
localManager->loadLanguages();
|
||||
}
|
||||
|
||||
Highlight* HighlightManager::Get(etk::File &fileName)
|
||||
{
|
||||
if (NULL == localManager) {
|
||||
return NULL;
|
||||
}
|
||||
return localManager->Get(fileName);
|
||||
}
|
||||
|
||||
bool HighlightManager::Exist(etk::File &fileName)
|
||||
{
|
||||
if (NULL != Get(fileName) ) {
|
||||
return true;
|
||||
if (NULL == localManager) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
return localManager->Exist(fileName);
|
||||
}
|
||||
|
||||
|
||||
void HighlightManager::loadLanguages(void)
|
||||
{
|
||||
etk::UString xmlFilename = "lang_c.xml";
|
||||
Highlight *myHightline = new Highlight(xmlFilename);
|
||||
listHighlight.PushBack(myHightline);
|
||||
|
||||
xmlFilename = "lang_boo.xml";
|
||||
myHightline = new Highlight(xmlFilename);
|
||||
listHighlight.PushBack(myHightline);
|
||||
|
||||
xmlFilename = "lang_Makefile.xml";
|
||||
myHightline = new Highlight(xmlFilename);
|
||||
listHighlight.PushBack(myHightline);
|
||||
|
||||
xmlFilename = "lang_asm.xml";
|
||||
myHightline = new Highlight(xmlFilename);
|
||||
listHighlight.PushBack(myHightline);
|
||||
|
||||
xmlFilename = "lang_xml.xml";
|
||||
myHightline = new Highlight(xmlFilename);
|
||||
listHighlight.PushBack(myHightline);
|
||||
|
||||
xmlFilename = "lang_php.xml";
|
||||
myHightline = new Highlight(xmlFilename);
|
||||
listHighlight.PushBack(myHightline);
|
||||
|
||||
xmlFilename = "lang_bash.xml";
|
||||
myHightline = new Highlight(xmlFilename);
|
||||
listHighlight.PushBack(myHightline);
|
||||
|
||||
xmlFilename = "lang_matlab.xml";
|
||||
myHightline = new Highlight(xmlFilename);
|
||||
listHighlight.PushBack(myHightline);
|
||||
|
||||
xmlFilename = "lang_java.xml";
|
||||
myHightline = new Highlight(xmlFilename);
|
||||
listHighlight.PushBack(myHightline);
|
||||
|
||||
//myHightline->Display();
|
||||
}
|
||||
|
||||
|
@@ -26,34 +26,20 @@
|
||||
#ifndef __HIGHLIGHT_MANAGER_H__
|
||||
#define __HIGHLIGHT_MANAGER_H__
|
||||
|
||||
class HighlightManager;
|
||||
|
||||
#include <etk/Singleton.h>
|
||||
#include <etk/UString.h>
|
||||
#include <MsgBroadcast.h>
|
||||
#include <Highlight.h>
|
||||
#include <ewol/Widget.h>
|
||||
|
||||
|
||||
class HighlightManager: public etk::Singleton<HighlightManager>, public ewol::Widget
|
||||
{
|
||||
friend class etk::Singleton<HighlightManager>;
|
||||
// specific for sigleton system...
|
||||
private:
|
||||
// Constructeur
|
||||
HighlightManager(void);
|
||||
~HighlightManager(void);
|
||||
|
||||
public:
|
||||
bool OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, etkFloat_t x, etkFloat_t y);
|
||||
public:
|
||||
void loadLanguages(void);
|
||||
Highlight * Get(etk::File &fileName);
|
||||
bool Exist(etk::File &fileName);
|
||||
|
||||
private:
|
||||
etk::VectorType<Highlight*> listHighlight; //!< List of ALL hightlight modules
|
||||
namespace HighlightManager{
|
||||
void Init(void);
|
||||
void UnInit(void);
|
||||
void loadLanguages(void);
|
||||
Highlight* Get(etk::File &fileName);
|
||||
bool Exist(etk::File &fileName);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -37,8 +37,7 @@ HighlightPattern::HighlightPattern(void)
|
||||
{
|
||||
m_haveStopPatern = false;
|
||||
m_multiline = false;
|
||||
ColorizeManager *myColorManager = ColorizeManager::getInstance();
|
||||
m_color = myColorManager->Get("normal");
|
||||
m_color = ColorizeManager::Get("normal");
|
||||
m_regExpStart = new etk::RegExp<EdnVectorBuf>();
|
||||
m_regExpStop = new etk::RegExp<EdnVectorBuf>();
|
||||
m_escapeChar = 0;
|
||||
@@ -78,8 +77,7 @@ void HighlightPattern::SetEscapeChar(etk::UString &EscapeChar)
|
||||
void HighlightPattern::SetColor(etk::UString &colorName)
|
||||
{
|
||||
m_colorName = colorName;
|
||||
ColorizeManager *myColorManager = ColorizeManager::getInstance();
|
||||
m_color = myColorManager->Get(m_colorName);
|
||||
m_color = ColorizeManager::Get(m_colorName);
|
||||
}
|
||||
|
||||
bool HighlightPattern::IsEnable(void)
|
||||
@@ -90,8 +88,7 @@ bool HighlightPattern::IsEnable(void)
|
||||
|
||||
void HighlightPattern::ReloadColor(void)
|
||||
{
|
||||
ColorizeManager *myColorManager = ColorizeManager::getInstance();
|
||||
m_color = myColorManager->Get(m_colorName);
|
||||
m_color = ColorizeManager::Get(m_colorName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -28,13 +28,13 @@
|
||||
#include <CTagsManager.h>
|
||||
#include <ClipBoard.h>
|
||||
#include <BufferManager.h>
|
||||
#include <ewol/WidgetMessageMultiCast.h>
|
||||
#include <ewol/EObject.h>
|
||||
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "CTagsManager"
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
@@ -203,7 +203,7 @@ void CTagsManager::cb_row(GtkTreeView *p_treeview,
|
||||
gpointer data)
|
||||
{
|
||||
EDN_DEBUG("event");
|
||||
CTagsManager * self = reinterpret_cast<CTagsManager*>(data);
|
||||
CTagsManager * self = static_cast<CTagsManager*>(data);
|
||||
|
||||
gchar * p_file=NULL;
|
||||
gint lineNumber;
|
||||
@@ -412,4 +412,7 @@ void CTagsManager::PrintTag (const tagEntry *entry, bool small)
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -27,7 +27,6 @@
|
||||
#define __C_TAGS_MANAGER_H__
|
||||
|
||||
|
||||
#include <etk/Singleton.h>
|
||||
#include <ewol/Widget.h>
|
||||
#include "MsgBroadcast.h"
|
||||
#include "readtags.h"
|
||||
@@ -40,7 +39,7 @@ typedef struct{
|
||||
int32_t lineID;
|
||||
} TagListFind_ts;
|
||||
|
||||
|
||||
/*
|
||||
class CTagsManager: public etk::Singleton<CTagsManager>, public ewol::Widget
|
||||
{
|
||||
friend class etk::Singleton<CTagsManager>;
|
||||
@@ -68,16 +67,6 @@ class CTagsManager: public etk::Singleton<CTagsManager>, public ewol::Widget
|
||||
etk::VectorType<etk::File*> m_historyList;
|
||||
etk::VectorType<TagListFind_ts> m_currentList;
|
||||
void JumpAtID(int32_t selectID);
|
||||
/*
|
||||
GtkWidget * CreateViewAndModel(void);
|
||||
static void cb_row (GtkTreeView *p_treeview,
|
||||
GtkTreePath * p_path,
|
||||
GtkTreeViewColumn * p_column,
|
||||
gpointer p_data);
|
||||
// save data in the list :
|
||||
GtkListStore * m_listStore;
|
||||
GtkWidget * m_Dialog;
|
||||
*/
|
||||
};
|
||||
|
||||
*/
|
||||
#endif
|
||||
|
@@ -26,18 +26,20 @@
|
||||
#include <tools_debug.h>
|
||||
#include <tools_globals.h>
|
||||
#include <ewol/ewol.h>
|
||||
#include <Gui/MainWindows.h>
|
||||
#include <Display.h>
|
||||
#include <BufferManager.h>
|
||||
#include <ColorizeManager.h>
|
||||
#include <HighlightManager.h>
|
||||
#include <ClipBoard.h>
|
||||
#include <WindowsManager.h>
|
||||
#include <Search.h>
|
||||
#include <Gui/Search.h>
|
||||
#include <unistd.h>
|
||||
#include <readtags.h>
|
||||
#include <CTagsManager.h>
|
||||
#include <etk/UString.h>
|
||||
#include <ewol/WidgetMessageMultiCast.h>
|
||||
#include <ewol/EObject.h>
|
||||
#include <ewol/WidgetManager.h>
|
||||
#include <tools/MsgBroadcast/MsgBroadcast.h>
|
||||
|
||||
MainWindows * basicWindows = NULL;
|
||||
|
||||
@@ -47,22 +49,6 @@ MainWindows * basicWindows = NULL;
|
||||
*/
|
||||
void APP_Init(void)
|
||||
{
|
||||
etk::UString myTmpString("test <20>l<EFBFBD>mentaire...");
|
||||
|
||||
EDN_CRITICAL("essay de UString : " << myTmpString);
|
||||
|
||||
myTmpString = "TT...SDFSDFSDFQAEZqsdgfqsdfqskdj";
|
||||
|
||||
EDN_CRITICAL("essay de UString : " << myTmpString);
|
||||
|
||||
myTmpString += "19";
|
||||
|
||||
EDN_CRITICAL("essay de UString : " << myTmpString);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
EDN_INFO("==> Init Edn (START)");
|
||||
ewol::ChangeSize(800, 600);
|
||||
|
||||
@@ -88,13 +74,12 @@ void APP_Init(void)
|
||||
#endif
|
||||
|
||||
ewol::SetFontFolder("Font");
|
||||
//ewol::SetDefaultFont("freefont/FreeMono.ttf", 12);
|
||||
ewol::SetDefaultFont("freefont/FreeSerif.ttf", 12);
|
||||
//ewol::SetDefaultFont("freefont/FreeMonoBold.ttf", 12);
|
||||
//ewol::SetDefaultFont("ACharmingFont.ttf", 45);
|
||||
//ewol::SetDefaultFont("Monospace/Monospace", 40);
|
||||
//ewol::SetDefaultFont("unispace.ttf", 12);
|
||||
|
||||
#ifdef __PLATFORM__Android
|
||||
ewol::SetDefaultFont("freefont/FreeSerif.ttf", 16);
|
||||
#else
|
||||
ewol::SetDefaultFont("freefont/FreeSerif.ttf", 12);
|
||||
#endif
|
||||
|
||||
// init internal global value
|
||||
globals::init();
|
||||
@@ -102,20 +87,17 @@ void APP_Init(void)
|
||||
|
||||
|
||||
// init ALL Singleton :
|
||||
(void)WindowsManager::getInstance();
|
||||
(void)CTagsManager::getInstance();
|
||||
(void)BufferManager::getInstance();
|
||||
//(void)CTagsManager::getInstance();
|
||||
BufferManager::Init();
|
||||
|
||||
// set color and other trucs...
|
||||
ColorizeManager *myColorManager = NULL;
|
||||
myColorManager = ColorizeManager::getInstance();
|
||||
ColorizeManager::Init();
|
||||
etk::UString homedir = "color_white.xml";
|
||||
myColorManager->LoadFile( homedir.Utf8Data() );
|
||||
myColorManager->DisplayListOfColor();
|
||||
ColorizeManager::LoadFile( homedir.Utf8Data() );
|
||||
ColorizeManager::DisplayListOfColor();
|
||||
|
||||
HighlightManager *myHighlightManager = NULL;
|
||||
myHighlightManager = HighlightManager::getInstance();
|
||||
myHighlightManager->loadLanguages();
|
||||
HighlightManager::Init();
|
||||
HighlightManager::loadLanguages();
|
||||
|
||||
|
||||
// get the curent program folder
|
||||
@@ -136,14 +118,41 @@ void APP_Init(void)
|
||||
// create the specific windows
|
||||
ewol::DisplayWindows(basicWindows);
|
||||
|
||||
// add generic shortcut ...
|
||||
// (shift, control, alt, meta, uniChar_t unicodeValue, const char * generateEventId, etk::UString& data)
|
||||
ewol::shortCut::Add("ctrl+o", ednMsgGuiOpen, "");
|
||||
ewol::shortCut::Add("ctrl+n", ednMsgGuiNew, "");
|
||||
|
||||
ewol::shortCut::Add("ctrl+s", ednMsgGuiSave, "current");
|
||||
ewol::shortCut::Add("ctrl+shift+s", ednMsgGuiSave, "All");
|
||||
|
||||
ewol::shortCut::Add("ctrl+q", ednMsgGuiClose, "current");
|
||||
ewol::shortCut::Add("ctrl+shift+q", ednMsgGuiClose, "All");
|
||||
|
||||
ewol::shortCut::Add("ctrl+z", ednMsgGuiUndo, "");
|
||||
ewol::shortCut::Add("ctrl+shift+z", ednMsgGuiRedo, "");
|
||||
|
||||
ewol::shortCut::Add("ctrl+w", ednMsgGuiRm, "Line");
|
||||
ewol::shortCut::Add("ctrl+shift+w", ednMsgGuiRm, "Paragraph");
|
||||
ewol::shortCut::Add("ctrl+x", ednMsgGuiCut, "STD");
|
||||
ewol::shortCut::Add("ctrl+c", ednMsgGuiCopy, "STD");
|
||||
ewol::shortCut::Add("ctrl+v", ednMsgGuiPaste, "STD");
|
||||
ewol::shortCut::Add("ctrl+a", ednMsgGuiSelect, "ALL");
|
||||
ewol::shortCut::Add("ctrl+shift+a", ednMsgGuiSelect, "NONE");
|
||||
|
||||
ewol::shortCut::Add("ctrl+l", ednMsgGuiGotoLine, "???");
|
||||
|
||||
|
||||
|
||||
// add files
|
||||
EDN_INFO("show list of files : ");
|
||||
|
||||
for( int32_t iii=0 ; iii<ewol::CmdLineNb(); iii++) {
|
||||
EDN_INFO("need load file : \"" << ewol::CmdLineGet(iii) << "\"" );
|
||||
etk::UString tmpppp = ewol::CmdLineGet(iii);
|
||||
ewol::widgetMessageMultiCast::Send(-1, ednMsgOpenFile, tmpppp);
|
||||
ewol::EObjectMessageMultiCast::AnonymousSend(ednMsgOpenFile, tmpppp);
|
||||
}
|
||||
|
||||
EDN_INFO("==> Init Edn (END)");
|
||||
}
|
||||
|
||||
@@ -157,20 +166,22 @@ void APP_UnInit(void)
|
||||
// Remove windows :
|
||||
ewol::DisplayWindows(NULL);
|
||||
|
||||
EDN_INFO("Stop Hightlight");
|
||||
HighlightManager::UnInit();
|
||||
//Kill all singleton
|
||||
EDN_INFO("Stop BufferManager");
|
||||
BufferManager::Kill();
|
||||
BufferManager::UnInit();
|
||||
EDN_INFO("Stop ColorizeManager");
|
||||
ColorizeManager::Kill();
|
||||
ColorizeManager::UnInit();
|
||||
EDN_INFO("Stop Search");
|
||||
Search::Kill();
|
||||
//Search::Kill();
|
||||
//EDN_INFO("Stop Accel key");
|
||||
//AccelKey::Kill();
|
||||
|
||||
if (NULL != basicWindows) {
|
||||
delete(basicWindows);
|
||||
basicWindows->MarkToRemove();
|
||||
basicWindows = NULL;
|
||||
}
|
||||
basicWindows = NULL;
|
||||
EDN_INFO("==> Un-Init Edn (END)");
|
||||
}
|
||||
|
||||
|
@@ -1,97 +0,0 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file AccelKey.cpp
|
||||
* @brief Editeur De N'ours : Basic Gui Accelerator Key (common for ALL) or nearly (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 17/06/2011
|
||||
* @par Project
|
||||
* Edn
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2010 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
* You can not earn money with this Software (if the source extract from Edn
|
||||
* represent less than 50% of original Sources)
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <tools_debug.h>
|
||||
#include <AccelKey.h>
|
||||
#if 0
|
||||
AccelKey::AccelKey(void)
|
||||
{
|
||||
m_accelGroup = gtk_accel_group_new();
|
||||
}
|
||||
|
||||
AccelKey::~AccelKey(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AccelKey::SetAccel(GtkWidget * widget, char * accelKey)
|
||||
{
|
||||
SetAccel(widget, m_accelGroup, accelKey);
|
||||
}
|
||||
|
||||
void AccelKey::SetAccel(GtkWidget * widget, GtkAccelGroup * accel, char * accelKey)
|
||||
{
|
||||
guint accel_key = 0;
|
||||
int32_t accel_mods = 0;
|
||||
if( NULL==accelKey
|
||||
|| 0==strlen(accelKey))
|
||||
{
|
||||
return;
|
||||
}
|
||||
// parsing of the string :
|
||||
//"ctrl+shift+alt+pomme+s"
|
||||
//EDN_DEBUG("Parse acxel string : \"" << accelKey << "\"");
|
||||
char * tmp = strstr(accelKey, "ctrl");
|
||||
if(NULL != tmp) {
|
||||
accel_mods |= GDK_CONTROL_MASK;
|
||||
//EDN_DEBUG(" => find CTRL");
|
||||
}
|
||||
tmp = strstr(accelKey, "shift");
|
||||
if(NULL != tmp) {
|
||||
accel_mods |= GDK_SHIFT_MASK;
|
||||
//EDN_DEBUG(" => find SHIFT");
|
||||
}
|
||||
tmp = strstr(accelKey, "alt");
|
||||
if(NULL != tmp) {
|
||||
accel_mods |= GDK_MOD1_MASK;
|
||||
//EDN_DEBUG(" => find ALT");
|
||||
}
|
||||
tmp = strstr(accelKey, "pomme");
|
||||
if(NULL != tmp) {
|
||||
accel_mods |= GDK_MOD2_MASK;
|
||||
//EDN_DEBUG(" => find POMME");
|
||||
}
|
||||
accel_key = accelKey[strlen(accelKey) -1];
|
||||
//char plop = accel_key;
|
||||
//EDN_DEBUG(" => find letter : '" << plop << "'");
|
||||
|
||||
// Ajout du racourcis clavier :
|
||||
gtk_widget_add_accelerator( widget, "activate", accel,
|
||||
accel_key, // key
|
||||
(GdkModifierType)accel_mods, // modifier keys
|
||||
GTK_ACCEL_VISIBLE);
|
||||
}
|
||||
|
||||
void AccelKey::LinkCommonAccel(GtkWidget * widget)
|
||||
{
|
||||
gtk_window_add_accel_group(GTK_WINDOW(widget), m_accelGroup);
|
||||
}
|
||||
|
||||
void AccelKey::LinkCommonAccel(GtkWindow * widget)
|
||||
{
|
||||
gtk_window_add_accel_group(GTK_WINDOW(widget), m_accelGroup);
|
||||
}
|
||||
|
||||
#endif
|
@@ -1,56 +0,0 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file AccelKey.h
|
||||
* @brief Editeur De N'ours : Basic Gui Accelerator Key (common for ALL) or nearly (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 17/06/2011
|
||||
* @par Project
|
||||
* Edn
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2010 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
* You can not earn money with this Software (if the source extract from Edn
|
||||
* represent less than 50% of original Sources)
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __ACCEL_KEY_H__
|
||||
#define __ACCEL_KEY_H__
|
||||
|
||||
#include <tools_debug.h>
|
||||
#include <etk/Singleton.h>
|
||||
/*
|
||||
// need to create a syngleton ...
|
||||
class AccelKey: public Singleton<AccelKey>
|
||||
{
|
||||
friend class Singleton<AccelKey>;
|
||||
// specific for sigleton system...
|
||||
private:
|
||||
// Constructeur
|
||||
AccelKey(void);
|
||||
~AccelKey(void);
|
||||
public:
|
||||
// for internal Parsing
|
||||
void SetAccel(GtkWidget * widget, char * accelKey);
|
||||
// For external parsing
|
||||
void SetAccel(GtkWidget * widget, GtkAccelGroup * accel, char * accelKey);
|
||||
void LinkCommonAccel(GtkWidget * widget);
|
||||
void LinkCommonAccel(GtkWindow * widget);
|
||||
GtkAccelGroup * GetAccel(void) { return m_accelGroup; };
|
||||
|
||||
private:
|
||||
GtkAccelGroup * m_accelGroup;
|
||||
};
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
@@ -23,12 +23,9 @@
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <tools_debug.h>
|
||||
#include <tools_globals.h>
|
||||
#include <MsgBroadcast.h>
|
||||
|
||||
|
||||
// new list of edn event generic :
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Event of the gui request something :
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
@@ -26,11 +26,6 @@
|
||||
#ifndef __MSG_BROADCAST_H__
|
||||
#define __MSG_BROADCAST_H__
|
||||
|
||||
#include <tools_debug.h>
|
||||
#include <etk/UString.h>
|
||||
|
||||
|
||||
// new list of edn event generic :
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Event of the gui request something :
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
@@ -51,7 +46,7 @@
|
||||
|
||||
extern const char* const ednMsgGuiSearch; // data : ""
|
||||
extern const char* const ednMsgGuiReplace; // data : ""
|
||||
extern const char* const ednMsgGuiFind; // data : "Next" "Previous"
|
||||
extern const char* const ednMsgGuiFind; // data : "Next" "Previous" "All" "None"
|
||||
|
||||
extern const char* const ednMsgGuiChangeColor; // data : "Black" "White"
|
||||
extern const char* const ednMsgGuiChangeCharset; // data : "UTF-8" "ISO-8859-1" "ISO-8859-15"
|
||||
|
@@ -26,7 +26,7 @@
|
||||
#include <tools_globals.h>
|
||||
#include <ColorizeManager.h>
|
||||
#include <MsgBroadcast.h>
|
||||
#include <ewol/WidgetMessageMultiCast.h>
|
||||
#include <ewol/EObject.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "globals"
|
||||
|
53
jni/file.mk
53
jni/file.mk
@@ -5,50 +5,45 @@
|
||||
###############################################################################
|
||||
|
||||
# ExuberantCtags reading file tools (extern OPEN Sources) :
|
||||
FILE_LIST+= edn/ctags/readtags.cpp \
|
||||
FILE_LIST+= edn/ctags/readtags.cpp \
|
||||
edn/ctags/CTagsManager.cpp
|
||||
|
||||
|
||||
# Globals debug tool:
|
||||
FILE_LIST+= edn/tools/debug/tools_debug.cpp \
|
||||
edn/tools/globals/tools_globals.cpp \
|
||||
FILE_LIST+= edn/tools/debug/tools_debug.cpp \
|
||||
edn/tools/globals/tools_globals.cpp \
|
||||
edn/tools/memory/toolsMemory.cpp
|
||||
|
||||
# Buffers internal:
|
||||
FILE_LIST+= edn/tools/EdnTemplate/EdnVectorBuf.cpp \
|
||||
edn/tools/EdnBuf/EdnBuf.cpp \
|
||||
edn/tools/EdnBuf/EdnBuf_HighLight.cpp \
|
||||
edn/tools/EdnBuf/EdnBuf_History.cpp \
|
||||
edn/tools/EdnBuf/EdnBuf_Selection.cpp \
|
||||
FILE_LIST+= edn/tools/EdnTemplate/EdnVectorBuf.cpp \
|
||||
edn/tools/EdnBuf/EdnBuf.cpp \
|
||||
edn/tools/EdnBuf/EdnBuf_HighLight.cpp \
|
||||
edn/tools/EdnBuf/EdnBuf_History.cpp \
|
||||
edn/tools/EdnBuf/EdnBuf_Selection.cpp \
|
||||
edn/tools/EdnBuf/EdnBufHistory.cpp
|
||||
|
||||
|
||||
# Tools internal:
|
||||
FILE_LIST+= edn/tools/Display/Display.cpp \
|
||||
edn/tools/ClipBoard/ClipBoard.cpp \
|
||||
edn/tools/MsgBroadcast/MsgBroadcast.cpp \
|
||||
edn/tools/MsgBroadcast/AccelKey.cpp
|
||||
FILE_LIST+= edn/tools/Display/Display.cpp \
|
||||
edn/tools/ClipBoard/ClipBoard.cpp \
|
||||
edn/tools/MsgBroadcast/MsgBroadcast.cpp
|
||||
|
||||
# Gui:
|
||||
FILE_LIST+= edn/CustumWidget/BufferView/BufferView.cpp \
|
||||
edn/CustumWidget/CodeView/CodeView.cpp \
|
||||
edn/GuiTools/WindowsManager/WindowsManager.cpp \
|
||||
edn/GuiTools/MainWindows/MainWindows.cpp \
|
||||
edn/GuiTools/MainWindows/StatusBar.cpp \
|
||||
edn/GuiTools/MainWindows/MenuBar.cpp \
|
||||
edn/GuiTools/MainWindows/ToolBar.cpp \
|
||||
edn/GuiTools/Search/Search.cpp \
|
||||
edn/GuiTools/Search/SearchData.cpp
|
||||
FILE_LIST+= edn/Gui/BufferView.cpp \
|
||||
edn/Gui/CodeView.cpp \
|
||||
edn/Gui/MainWindows.cpp \
|
||||
edn/Gui/Search.cpp \
|
||||
edn/Gui/SearchData.cpp
|
||||
|
||||
# Basic Interface :
|
||||
FILE_LIST+= edn/Buffer/Buffer.cpp \
|
||||
edn/Buffer/BufferText.cpp \
|
||||
edn/Buffer/BufferEmpty.cpp \
|
||||
edn/Buffer/BufferManager.cpp \
|
||||
edn/Colorize/Colorize.cpp \
|
||||
edn/Colorize/ColorizeManager.cpp \
|
||||
edn/Highlight/HighlightPattern.cpp \
|
||||
edn/Highlight/Highlight.cpp \
|
||||
FILE_LIST+= edn/Buffer/Buffer.cpp \
|
||||
edn/Buffer/BufferText.cpp \
|
||||
edn/Buffer/BufferEmpty.cpp \
|
||||
edn/Buffer/BufferManager.cpp \
|
||||
edn/Colorize/Colorize.cpp \
|
||||
edn/Colorize/ColorizeManager.cpp \
|
||||
edn/Highlight/HighlightPattern.cpp \
|
||||
edn/Highlight/Highlight.cpp \
|
||||
edn/Highlight/HighlightManager.cpp
|
||||
|
||||
# Main entry file :
|
||||
|
@@ -1,202 +0,0 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file pngToCpp.cpp
|
||||
* @brief convert a binary file into a C source vector
|
||||
* @author Sandro Sigala
|
||||
* @date 26/01/2011
|
||||
* @par Project
|
||||
* ---
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2010 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
* You can not earn money with this Software (if the source extract from Edn
|
||||
* represent less than 50% of original Sources)
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
* @compilation g++ pngToCpp -o pngToCpp
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 1024
|
||||
#endif
|
||||
|
||||
bool zeroTerminated = false;
|
||||
|
||||
int myfgetc(FILE *f)
|
||||
{
|
||||
int c = fgetc(f);
|
||||
if (c == EOF && zeroTerminated)
|
||||
{
|
||||
zeroTerminated = 0;
|
||||
return 0;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
void generateHeader(FILE *file)
|
||||
{
|
||||
fprintf(file, "/**\n");
|
||||
fprintf(file, " ******************************************************************************* \n");
|
||||
fprintf(file, " * \n");
|
||||
fprintf(file, " * @par Project\n");
|
||||
fprintf(file, " * Edn\n");
|
||||
fprintf(file, " * \n");
|
||||
fprintf(file, " * Automatic generated file for Edn Software\n");
|
||||
fprintf(file, " * Please do not save this file on File configuration server\n");
|
||||
fprintf(file, " * \n");
|
||||
fprintf(file, " * @par Copyright\n");
|
||||
fprintf(file, " * \n");
|
||||
fprintf(file, " * Copyright 2010 Edouard DUPIN, all right reserved\n");
|
||||
fprintf(file, " * \n");
|
||||
fprintf(file, " * his software is distributed in the hope that it will be useful, but WITHOUT\n");
|
||||
fprintf(file, " * ANY WARRANTY.\n");
|
||||
fprintf(file, " * \n");
|
||||
fprintf(file, " * Licence summary : \n");
|
||||
fprintf(file, " * You can modify and redistribute the sources code and binaries.\n");
|
||||
fprintf(file, " * You can send me the bug-fix\n");
|
||||
fprintf(file, " * You can not earn money with this Software (if the source extract from Edn\n");
|
||||
fprintf(file, " * represent less than 50/100 of original Sources)\n");
|
||||
fprintf(file, " * Term of the licence in in the file licence.txt.\n");
|
||||
fprintf(file, " * \n");
|
||||
fprintf(file, " ******************************************************************************* \n");
|
||||
fprintf(file, " */\n\n");
|
||||
}
|
||||
|
||||
FILE *ofile=NULL;
|
||||
FILE *ofileH=NULL;
|
||||
|
||||
void process(const char *ifname)
|
||||
{
|
||||
FILE *ifile=NULL;
|
||||
ifile = fopen(ifname, "rb");
|
||||
if (ifile == NULL)
|
||||
{
|
||||
fprintf(stderr, "cannot open %s for reading\n", ifname);
|
||||
exit(1);
|
||||
}
|
||||
char buf[PATH_MAX], *p;
|
||||
const char *cp;
|
||||
if ((cp = strrchr(ifname, '/')) != NULL)
|
||||
{
|
||||
++cp;
|
||||
} else {
|
||||
if ((cp = strrchr(ifname, '\\')) != NULL)
|
||||
++cp;
|
||||
else
|
||||
cp = ifname;
|
||||
}
|
||||
strcpy(buf, cp);
|
||||
for (p = buf; *p != '\0'; ++p)
|
||||
{
|
||||
if (!isalnum(*p))
|
||||
*p = '_';
|
||||
}
|
||||
fprintf(ofile, "unsigned char %s[] = {\n\t\t", buf);
|
||||
int n = 0;
|
||||
unsigned char c = 0;
|
||||
while(fread(&c, 1, 1, ifile) == 1)
|
||||
{
|
||||
if(n%100 == 0) {
|
||||
fprintf(ofile, "\n\t\t");
|
||||
}
|
||||
fprintf(ofile, "0x%02x,", c);
|
||||
n++;
|
||||
}
|
||||
fprintf(ofile, "\n};\n");
|
||||
fprintf(ofile, "unsigned long int %s_size = sizeof(%s);\n\n\n", buf, buf);
|
||||
|
||||
fprintf(ofileH, "extern unsigned char %s[];\n", buf);
|
||||
fprintf(ofileH, "extern unsigned long int %s_size;\n", buf);
|
||||
|
||||
fclose(ifile);
|
||||
}
|
||||
|
||||
void usage(void)
|
||||
{
|
||||
fprintf(stderr, "usage: pngToCpp <output_file>.xxx <input_file>\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
//zeroTerminated = true;
|
||||
if (argc < 3) {
|
||||
usage();
|
||||
}
|
||||
// dynamic output name :
|
||||
char tmpOutput[PATH_MAX*2] = "";
|
||||
strcpy(tmpOutput, argv[1]);
|
||||
int32_t sizeName = strlen(tmpOutput);
|
||||
if (6>=sizeName) {
|
||||
usage();
|
||||
}
|
||||
if (tmpOutput[sizeName-1] == '.') {
|
||||
tmpOutput[sizeName-1] = '\0';
|
||||
} else if (tmpOutput[sizeName-2] == '.') {
|
||||
tmpOutput[sizeName-2] = '\0';
|
||||
} else if (tmpOutput[sizeName-3] == '.') {
|
||||
tmpOutput[sizeName-3] = '\0';
|
||||
} else if (tmpOutput[sizeName-4] == '.') {
|
||||
tmpOutput[sizeName-4] = '\0';
|
||||
} else if (tmpOutput[sizeName-5] == '.') {
|
||||
tmpOutput[sizeName-5] = '\0';
|
||||
} else if (tmpOutput[sizeName-6] == '.') {
|
||||
tmpOutput[sizeName-6] = '\0';
|
||||
}
|
||||
//fprintf(stderr, "writing to %s\n", tmpOutput);
|
||||
|
||||
char tmpOutputCPP[PATH_MAX*2] = "";
|
||||
char tmpOutputH[PATH_MAX*2] = "";
|
||||
// Generate the output filename
|
||||
sprintf(tmpOutputCPP,"%s.cpp", tmpOutput);
|
||||
sprintf(tmpOutputH,"%s.h", tmpOutput);
|
||||
// open destination name :
|
||||
ofile = fopen(tmpOutputCPP, "wb");
|
||||
if (ofile == NULL)
|
||||
{
|
||||
fprintf(stderr, "cannot open %s for writing\n", tmpOutputCPP);
|
||||
exit(1);
|
||||
}
|
||||
generateHeader(ofile);
|
||||
ofileH = fopen(tmpOutputH, "wb");
|
||||
if (ofileH == NULL)
|
||||
{
|
||||
fprintf(stderr, "cannot open %s for writing\n", tmpOutputH);
|
||||
exit(1);
|
||||
}
|
||||
generateHeader(ofileH);
|
||||
fprintf(ofileH, "#ifndef __INPUT_PNG_FILE_GENERATED_H__\n");
|
||||
fprintf(ofileH, "#define __INPUT_PNG_FILE_GENERATED_H__\n");
|
||||
//fprintf(ofileH, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n");
|
||||
//fprintf(ofile, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n");
|
||||
|
||||
// Generate the output
|
||||
int32_t i;
|
||||
for(i=2; i<argc; i++) {
|
||||
process(argv[i]);
|
||||
}
|
||||
|
||||
//fprintf(ofile, "#ifdef __cplusplus\n}\n#endif\n");
|
||||
//fprintf(ofileH, "#ifdef __cplusplus\n}\n#endif\n");
|
||||
|
||||
fprintf(ofileH, "#endif\n\n");
|
||||
// Close destination files
|
||||
fclose(ofile);
|
||||
fclose(ofileH);
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user