Normalisation with etk application
This commit is contained in:
188
jni/appl/Gui/BufferView.cpp
Normal file
188
jni/appl/Gui/BufferView.cpp
Normal file
@@ -0,0 +1,188 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @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 <appl/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"
|
||||
|
||||
|
||||
extern const char * const TYPE_EOBJECT_EDN_BUFFER_VIEW = "BufferView";
|
||||
|
||||
BufferView::BufferView(void)
|
||||
{
|
||||
SetCanHaveFocus(true);
|
||||
RegisterMultiCast(ednMsgBufferListChange);
|
||||
RegisterMultiCast(ednMsgBufferState);
|
||||
RegisterMultiCast(ednMsgBufferId);
|
||||
m_selectedID = -1;
|
||||
}
|
||||
|
||||
BufferView::~BufferView(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if the object has the specific type.
|
||||
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
|
||||
* @param[in] objectType type of the object we want to check
|
||||
* @return true if the object is compatible, otherwise false
|
||||
*/
|
||||
bool BufferView::CheckObjectType(const char * const objectType)
|
||||
{
|
||||
if (NULL == objectType) {
|
||||
EWOL_ERROR("check error : \"" << TYPE_EOBJECT_EDN_BUFFER_VIEW << "\" != NULL(pointer) ");
|
||||
return false;
|
||||
}
|
||||
if (objectType == TYPE_EOBJECT_EDN_BUFFER_VIEW) {
|
||||
return true;
|
||||
} else {
|
||||
if(true == ewol::List::CheckObjectType(objectType)) {
|
||||
return true;
|
||||
}
|
||||
EWOL_ERROR("check error : \"" << TYPE_EOBJECT_EDN_BUFFER_VIEW << "\" != \"" << objectType << "\"");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the current Object type of the EObject
|
||||
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
|
||||
* @param[in] objectType type description
|
||||
* @return true if the object is compatible, otherwise false
|
||||
*/
|
||||
const char * const BufferView::GetObjectType(void)
|
||||
{
|
||||
return TYPE_EOBJECT_EDN_BUFFER_VIEW;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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) {
|
||||
APPL_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;
|
||||
}
|
||||
|
||||
|
82
jni/appl/Gui/BufferView.h
Normal file
82
jni/appl/Gui/BufferView.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file BufferView.h
|
||||
* @brief Editeur De N'ours : main List Buffer Viewer (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 09/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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
#ifndef __BUFFER_VIEW_H__
|
||||
#define __BUFFER_VIEW_H__
|
||||
|
||||
#include <appl/Debug.h>
|
||||
#include <CodeView.h>
|
||||
#include <BufferManager.h>
|
||||
#include <Display.h>
|
||||
#include <MsgBroadcast.h>
|
||||
#include <ewol/widget/List.h>
|
||||
|
||||
//!< EObject name :
|
||||
extern const char * const TYPE_EOBJECT_EDN_BUFFER_VIEW;
|
||||
|
||||
class BufferView : public ewol::List
|
||||
{
|
||||
public:
|
||||
// Constructeur
|
||||
BufferView(void);
|
||||
~BufferView(void);
|
||||
/**
|
||||
* @brief Check if the object has the specific type.
|
||||
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
|
||||
* @param[in] objectType type of the object we want to check
|
||||
* @return true if the object is compatible, otherwise false
|
||||
*/
|
||||
bool CheckObjectType(const char * const objectType);
|
||||
/**
|
||||
* @brief Get the current Object type of the EObject
|
||||
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
|
||||
* @param[in] objectType type description
|
||||
* @return true if the object is compatible, otherwise false
|
||||
*/
|
||||
const char * const GetObjectType(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 ---
|
||||
*/
|
||||
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
|
||||
protected:
|
||||
// function call to display the list :
|
||||
virtual color_ts GetBasicBG(void);
|
||||
virtual uint32_t GetNuberOfColomn(void);
|
||||
virtual bool GetTitle(int32_t colomn, etk::UString &myTitle, color_ts &fg, color_ts &bg);
|
||||
virtual uint32_t GetNuberOfRaw(void);
|
||||
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:
|
||||
int32_t m_selectedID;
|
||||
};
|
||||
|
||||
#define EDN_CAST_BUFFER_VIEW(curentPointer) EWOL_CAST(TYPE_EOBJECT_EDN_BUFFER_VIEW,BufferView,curentPointer)
|
||||
|
||||
#endif
|
||||
|
||||
|
434
jni/appl/Gui/CodeView.cpp
Normal file
434
jni/appl/Gui/CodeView.cpp
Normal file
@@ -0,0 +1,434 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file CodeView.cpp
|
||||
* @brief Editeur De N'ours : Code Viewer Widget
|
||||
* This is an abstraction
|
||||
* @author Edouard DUPIN
|
||||
* @date 05/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 <CodeView.h>
|
||||
|
||||
#include <appl/Debug.h>
|
||||
#include <tools_globals.h>
|
||||
#include <Display.h>
|
||||
#include <CodeView.h>
|
||||
#include <BufferManager.h>
|
||||
#include <ColorizeManager.h>
|
||||
#include <ewol/ClipBoard.h>
|
||||
#include <SearchData.h>
|
||||
|
||||
#include <ewol/WidgetManager.h>
|
||||
#include <ewol/EObject.h>
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "CodeView"
|
||||
|
||||
|
||||
extern const char * const TYPE_EOBJECT_EDN_CODE_VIEW = "CodeView";
|
||||
|
||||
CodeView::CodeView(void)
|
||||
{
|
||||
m_label = "CodeView is disable ...";
|
||||
m_fontNormal = -1;
|
||||
m_fontBold = -1;
|
||||
m_fontItalic = -1;
|
||||
m_fontBoldItalic = -1;
|
||||
m_fontSize = 15;
|
||||
|
||||
m_bufferID = -1;
|
||||
m_buttunOneSelected = false;
|
||||
|
||||
m_textColorFg.red = 0.0;
|
||||
m_textColorFg.green = 0.0;
|
||||
m_textColorFg.blue = 0.0;
|
||||
m_textColorFg.alpha = 1.0;
|
||||
|
||||
m_textColorBg.red = 0.0;
|
||||
m_textColorBg.green = 0.0;
|
||||
m_textColorBg.blue = 0.0;
|
||||
m_textColorBg.alpha = 0.25;
|
||||
SetCanHaveFocus(true);
|
||||
RegisterMultiCast(ednMsgBufferId);
|
||||
RegisterMultiCast(ednMsgGuiCopy);
|
||||
RegisterMultiCast(ednMsgGuiPaste);
|
||||
RegisterMultiCast(ednMsgGuiCut);
|
||||
RegisterMultiCast(ednMsgGuiRedo);
|
||||
RegisterMultiCast(ednMsgGuiUndo);
|
||||
RegisterMultiCast(ednMsgGuiRm);
|
||||
RegisterMultiCast(ednMsgGuiSelect);
|
||||
RegisterMultiCast(ednMsgGuiChangeCharset);
|
||||
}
|
||||
|
||||
CodeView::~CodeView(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if the object has the specific type.
|
||||
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
|
||||
* @param[in] objectType type of the object we want to check
|
||||
* @return true if the object is compatible, otherwise false
|
||||
*/
|
||||
bool CodeView::CheckObjectType(const char * const objectType)
|
||||
{
|
||||
if (NULL == objectType) {
|
||||
EWOL_ERROR("check error : \"" << TYPE_EOBJECT_EDN_CODE_VIEW << "\" != NULL(pointer) ");
|
||||
return false;
|
||||
}
|
||||
if (objectType == TYPE_EOBJECT_EDN_CODE_VIEW) {
|
||||
return true;
|
||||
} else {
|
||||
if(true == ewol::WidgetScrooled::CheckObjectType(objectType)) {
|
||||
return true;
|
||||
}
|
||||
EWOL_ERROR("check error : \"" << TYPE_EOBJECT_EDN_CODE_VIEW << "\" != \"" << objectType << "\"");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the current Object type of the EObject
|
||||
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
|
||||
* @param[in] objectType type description
|
||||
* @return true if the object is compatible, otherwise false
|
||||
*/
|
||||
const char * const CodeView::GetObjectType(void)
|
||||
{
|
||||
return TYPE_EOBJECT_EDN_CODE_VIEW;
|
||||
}
|
||||
|
||||
|
||||
bool CodeView::CalculateMinSize(void)
|
||||
{
|
||||
m_minSize.x = 50;
|
||||
m_minSize.y = 50;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CodeView::CalculateMaxSize(void)
|
||||
{
|
||||
m_maxSize.x = 2048;
|
||||
int32_t letterHeight = ewol::GetHeight(m_fontNormal);
|
||||
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();
|
||||
|
||||
// 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 :
|
||||
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);
|
||||
|
||||
int64_t stopTime = GetCurrentTime();
|
||||
APPL_DEBUG("Display Code Generation = " << stopTime - startTime << " milli-s");
|
||||
|
||||
// call the herited class...
|
||||
WidgetScrooled::OnRegenerateDisplay();
|
||||
m_needFlipFlop = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CodeView::OnEventKb(ewol::eventKbType_te typeEvent, uniChar_t unicodeData)
|
||||
{
|
||||
//APPL_DEBUG("KB EVENT : \"" << UTF8_data << "\" size=" << strlen(UTF8_data) << "type=" << (int32_t)typeEvent);
|
||||
if (typeEvent == ewol::EVENT_KB_TYPE_DOWN) {
|
||||
BufferManager::Get(m_bufferID)->AddChar(unicodeData);
|
||||
MarkToReedraw();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CodeView::OnEventKbMove(ewol::eventKbType_te typeEvent, ewol::eventKbMoveType_te moveTypeEvent)
|
||||
{
|
||||
if (typeEvent == ewol::EVENT_KB_TYPE_DOWN) {
|
||||
BufferManager::Get(m_bufferID)->cursorMove(moveTypeEvent);
|
||||
MarkToReedraw();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
if (1 == IdInput) {
|
||||
#ifndef __MODE__Touch
|
||||
if (ewol::EVENT_INPUT_TYPE_DOWN == typeEvent) {
|
||||
m_buttunOneSelected = true;
|
||||
ewol::widgetManager::FocusKeep(this);
|
||||
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;
|
||||
BufferManager::Get(m_bufferID)->Copy(ewol::clipBoard::CLIPBOARD_SELECTION);
|
||||
MarkToReedraw();
|
||||
} else
|
||||
#endif
|
||||
if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) {
|
||||
#ifdef __MODE__Touch
|
||||
ewol::widgetManager::FocusKeep(this);
|
||||
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) {
|
||||
BufferManager::Get(m_bufferID)->MouseEventDouble();
|
||||
MarkToReedraw();
|
||||
} else if (ewol::EVENT_INPUT_TYPE_TRIPLE == typeEvent) {
|
||||
BufferManager::Get(m_bufferID)->MouseEventTriple();
|
||||
MarkToReedraw();
|
||||
} else if (ewol::EVENT_INPUT_TYPE_MOVE == typeEvent) {
|
||||
if (true == m_buttunOneSelected) {
|
||||
int xxx, yyy;
|
||||
xxx = relativePos.x;
|
||||
yyy = relativePos.y;
|
||||
if (xxx<0) {
|
||||
xxx = 0;
|
||||
}
|
||||
if (yyy<0) {
|
||||
yyy = 0;
|
||||
}
|
||||
//APPL_INFO("mouse-motion BT1 %d, %d", xxx, yyy);
|
||||
BufferManager::Get(m_bufferID)->MouseSelectFromCursorTo(m_fontNormal, xxx+m_originScrooled.x, yyy+m_originScrooled.y);
|
||||
MarkToReedraw();
|
||||
}
|
||||
}
|
||||
} else if (2 == IdInput) {
|
||||
if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) {
|
||||
BufferManager::Get(m_bufferID)->MouseEvent(m_fontNormal, relativePos.x+m_originScrooled.x, relativePos.y+m_originScrooled.y);
|
||||
BufferManager::Get(m_bufferID)->Paste(ewol::clipBoard::CLIPBOARD_SELECTION);
|
||||
MarkToReedraw();
|
||||
ewol::widgetManager::FocusKeep(this);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
ewol::WidgetScrooled::OnReceiveMessage(CallerObject, eventId, data);
|
||||
APPL_DEBUG("Extern Event : " << CallerObject << " type : " << eventId << " data=\"" << data << "\"");
|
||||
|
||||
if(eventId == ednMsgBufferId) {
|
||||
int32_t bufferID = 0;
|
||||
sscanf(data.Utf8Data(), "%d", &bufferID);
|
||||
APPL_INFO("Select a new Buffer ... " << bufferID);
|
||||
m_bufferID = bufferID;
|
||||
// TODO : need to update the state of the file and the filenames ...
|
||||
} else if (eventId == ednMsgGuiCopy) {
|
||||
BufferManager::Get(m_bufferID)->Copy(ewol::clipBoard::CLIPBOARD_STD);
|
||||
} else if (eventId == ednMsgGuiCut) {
|
||||
BufferManager::Get(m_bufferID)->Cut(ewol::clipBoard::CLIPBOARD_STD);
|
||||
} else if (eventId == ednMsgGuiPaste) {
|
||||
BufferManager::Get(m_bufferID)->Paste(ewol::clipBoard::CLIPBOARD_STD);
|
||||
} else if (eventId == ednMsgGuiUndo) {
|
||||
BufferManager::Get(m_bufferID)->Undo();
|
||||
} else if (eventId == ednMsgGuiRedo) {
|
||||
BufferManager::Get(m_bufferID)->Redo();
|
||||
} else if (eventId == ednMsgGuiRm) {
|
||||
// data : "Word" "Line" "Paragraph"
|
||||
if (data == "Word") {
|
||||
APPL_WARNING(" on event " << eventId << " data=\"" << data << "\" ==> not coded" );
|
||||
} else if (data == "Line") {
|
||||
BufferManager::Get(m_bufferID)->RemoveLine();
|
||||
} else if (data == "Paragraph") {
|
||||
APPL_WARNING(" on event " << eventId << " data=\"" << data << "\" ==> not coded" );
|
||||
} else {
|
||||
APPL_ERROR(" on event " << eventId << " unknow data=\"" << data << "\"" );
|
||||
}
|
||||
} else if (eventId == ednMsgGuiSelect) {
|
||||
// data : "ALL" "NONE"
|
||||
if (data == "ALL") {
|
||||
BufferManager::Get(m_bufferID)->SelectAll();
|
||||
} else if (data == "NONE") {
|
||||
BufferManager::Get(m_bufferID)->SelectNone();
|
||||
} else {
|
||||
APPL_ERROR(" on event " << eventId << " unknow data=\"" << data << "\"" );
|
||||
}
|
||||
} else if (eventId == ednMsgGuiChangeCharset) {
|
||||
// data : "UTF-8" "ISO-8859-1" "ISO-8859-15"
|
||||
if (data == "UTF-8") {
|
||||
BufferManager::Get(m_bufferID)->SetCharset(unicode::EDN_CHARSET_UTF8);
|
||||
} else if (data == "ISO-8859-1") {
|
||||
BufferManager::Get(m_bufferID)->SetCharset(unicode::EDN_CHARSET_ISO_8859_1);
|
||||
} else if (data == "ISO-8859-15") {
|
||||
BufferManager::Get(m_bufferID)->SetCharset(unicode::EDN_CHARSET_ISO_8859_15);
|
||||
} else {
|
||||
APPL_ERROR(" on event " << eventId << " unknow data=\"" << data << "\"" );
|
||||
}
|
||||
}
|
||||
/*
|
||||
switch (id)
|
||||
{
|
||||
case APPL_MSG__CURRENT_FIND_PREVIOUS:
|
||||
{
|
||||
etk::UString myDataString;
|
||||
SearchData::GetSearch(myDataString);
|
||||
BufferManager::Get(m_bufferID)->Search(myDataString, true, SearchData::GetCase(), SearchData::GetWrap(), SearchData::GetRegExp() );
|
||||
}
|
||||
break;
|
||||
case APPL_MSG__CURRENT_FIND_NEXT:
|
||||
{
|
||||
etk::UString myDataString;
|
||||
SearchData::GetSearch(myDataString);
|
||||
BufferManager::Get(m_bufferID)->Search(myDataString, false, SearchData::GetCase(), SearchData::GetWrap(), SearchData::GetRegExp() );
|
||||
}
|
||||
break;
|
||||
case APPL_MSG__CURRENT_REPLACE:
|
||||
{
|
||||
etk::UString myDataString;
|
||||
SearchData::GetReplace(myDataString);
|
||||
BufferManager::Get(m_bufferID)->Replace(myDataString);
|
||||
}
|
||||
break;
|
||||
case APPL_MSG__CURRENT_REPLACE_ALL:
|
||||
break;
|
||||
case APPL_MSG__CURRENT_GOTO_LINE:
|
||||
if (dataID<0) {
|
||||
dataID = 0;
|
||||
}
|
||||
BufferManager::Get(m_bufferID)->JumpAtLine(dataID);
|
||||
break;
|
||||
case APPL_MSG__CURRENT_SET_CHARSET:
|
||||
BufferManager::Get(m_bufferID)->SetCharset((unicode::charset_te)dataID);
|
||||
break;
|
||||
}
|
||||
*/
|
||||
// Force redraw of the widget
|
||||
MarkToReedraw();
|
||||
}
|
||||
|
||||
|
||||
void CodeView::OnGetFocus(void)
|
||||
{
|
||||
/*
|
||||
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferId, m_bufferID);
|
||||
*/
|
||||
ewol::KeyboardShow(ewol::KEYBOARD_MODE_CODE);
|
||||
APPL_INFO("Focus - In");
|
||||
}
|
||||
|
||||
|
||||
void CodeView::OnLostFocus(void)
|
||||
{
|
||||
ewol::KeyboardHide();
|
||||
APPL_INFO("Focus - out");
|
||||
}
|
||||
|
||||
void CodeView::SetFontSize(int32_t size)
|
||||
{
|
||||
m_fontSize = size;
|
||||
SetScrollingSize(m_fontSize*3.0*1.46); // 1.46 is a magic nmber ...
|
||||
}
|
||||
|
||||
void CodeView::SetFontNameNormal(etk::UString fontName)
|
||||
{
|
||||
int32_t fontID = ewol::LoadFont(fontName, m_fontSize);
|
||||
if (fontID >= 0) {
|
||||
m_fontNormal = fontID;
|
||||
}
|
||||
}
|
||||
|
||||
void CodeView::SetFontNameBold(etk::UString fontName)
|
||||
{
|
||||
int32_t fontID = ewol::LoadFont(fontName, m_fontSize);
|
||||
if (fontID >= 0) {
|
||||
m_fontBold = fontID;
|
||||
}
|
||||
}
|
||||
|
||||
void CodeView::SetFontNameItalic(etk::UString fontName)
|
||||
{
|
||||
int32_t fontID = ewol::LoadFont(fontName, m_fontSize);
|
||||
if (fontID >= 0) {
|
||||
m_fontItalic = fontID;
|
||||
}
|
||||
}
|
||||
|
||||
void CodeView::SetFontNameBoldItalic(etk::UString fontName)
|
||||
{
|
||||
int32_t fontID = ewol::LoadFont(fontName, m_fontSize);
|
||||
if (fontID >= 0) {
|
||||
m_fontBoldItalic = fontID;
|
||||
}
|
||||
}
|
120
jni/appl/Gui/CodeView.h
Normal file
120
jni/appl/Gui/CodeView.h
Normal file
@@ -0,0 +1,120 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file CodeView.h
|
||||
* @brief Editeur De N'ours : Code Viewer Widget (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 05/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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __CODE_VIEW_H__
|
||||
#define __CODE_VIEW_H__
|
||||
|
||||
#include <appl/Debug.h>
|
||||
#include <CodeView.h>
|
||||
#include <BufferManager.h>
|
||||
#include <Display.h>
|
||||
#include <MsgBroadcast.h>
|
||||
|
||||
#include <etk/Types.h>
|
||||
#include <ewol/widget/WidgetScrolled.h>
|
||||
|
||||
//!< EObject name :
|
||||
extern const char * const TYPE_EOBJECT_EDN_CODE_VIEW;
|
||||
|
||||
class CodeView :public ewol::WidgetScrooled
|
||||
{
|
||||
public:
|
||||
CodeView(void);
|
||||
virtual ~CodeView(void);
|
||||
/**
|
||||
* @brief Check if the object has the specific type.
|
||||
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
|
||||
* @param[in] objectType type of the object we want to check
|
||||
* @return true if the object is compatible, otherwise false
|
||||
*/
|
||||
bool CheckObjectType(const char * const objectType);
|
||||
/**
|
||||
* @brief Get the current Object type of the EObject
|
||||
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
|
||||
* @param[in] objectType type description
|
||||
* @return true if the object is compatible, otherwise false
|
||||
*/
|
||||
const char * const GetObjectType(void);
|
||||
virtual bool CalculateMinSize(void);
|
||||
private:
|
||||
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);
|
||||
/**
|
||||
* @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:
|
||||
/**
|
||||
* @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);
|
||||
virtual void OnLostFocus(void);
|
||||
private:
|
||||
int32_t m_fontSize;
|
||||
int32_t m_fontNormal;
|
||||
int32_t m_fontBold;
|
||||
int32_t m_fontItalic;
|
||||
int32_t m_fontBoldItalic;
|
||||
public:
|
||||
void SetFontSize(int32_t size);
|
||||
void SetFontNameNormal(etk::UString fontName);
|
||||
void SetFontNameBold(etk::UString fontName);
|
||||
void SetFontNameItalic(etk::UString fontName);
|
||||
void SetFontNameBoldItalic(etk::UString fontName);
|
||||
private:
|
||||
void CalculateMaxSize(void);
|
||||
protected:
|
||||
virtual void OnDraw(void);
|
||||
};
|
||||
|
||||
#define EDN_CAST_CODE_VIEW(curentPointer) EWOL_CAST(TYPE_EOBJECT_EDN_CODE_VIEW,CodeView,curentPointer)
|
||||
|
||||
#endif
|
||||
|
335
jni/appl/Gui/MainWindows.cpp
Normal file
335
jni/appl/Gui/MainWindows.cpp
Normal file
@@ -0,0 +1,335 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @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 <appl/Debug.h>
|
||||
#include <tools_globals.h>
|
||||
#include <MainWindows.h>
|
||||
#include <CodeView.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"
|
||||
|
||||
extern const char * const TYPE_EOBJECT_EDN_MAIN_WINDOWS = "MainWindows";
|
||||
|
||||
MainWindows::MainWindows(void)
|
||||
{
|
||||
APPL_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", "iconEdn.bmp", ednMsgGuiNew);
|
||||
(void)myMenu->AddSpacer();
|
||||
(void)myMenu->Add(idMenuFile, "Open", "icon/Load.svg", ednMsgGuiOpen);
|
||||
(void)myMenu->Add(idMenuFile, "Close", "icon/Close.svg", ednMsgGuiClose, "current");
|
||||
(void)myMenu->Add(idMenuFile, "Close (all)", "", ednMsgGuiClose, "All");
|
||||
(void)myMenu->Add(idMenuFile, "Save", "icon/Save.svg", 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", "icon/Undo.svg", ednMsgGuiUndo);
|
||||
(void)myMenu->Add(idMenuEdit, "Redo", "icon/Redo.svg", 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, "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", "icon/Search.svg", 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");
|
||||
int32_t idMenugDisplay = myMenu->AddTitle("Display");
|
||||
(void)myMenu->Add(idMenugDisplay, "Charset UTF-8", "", ednMsgGuiChangeCharset, "UTF-8");
|
||||
(void)myMenu->Add(idMenugDisplay, "Charset ISO-8859-1", "", ednMsgGuiChangeCharset, "ISO-8859-1");
|
||||
(void)myMenu->Add(idMenugDisplay, "Charset ISO-8859-15", "", ednMsgGuiChangeCharset, "ISO-8859-15");
|
||||
(void)myMenu->AddSpacer();
|
||||
(void)myMenu->Add(idMenugDisplay, "Color Black", "", ednMsgGuiChangeColor, "Black");
|
||||
(void)myMenu->Add(idMenugDisplay, "Color White", "", ednMsgGuiChangeColor, "White");
|
||||
(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)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if the object has the specific type.
|
||||
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
|
||||
* @param[in] objectType type of the object we want to check
|
||||
* @return true if the object is compatible, otherwise false
|
||||
*/
|
||||
bool MainWindows::CheckObjectType(const char * const objectType)
|
||||
{
|
||||
if (NULL == objectType) {
|
||||
APPL_ERROR("check error : \"" << TYPE_EOBJECT_EDN_MAIN_WINDOWS << "\" != NULL(pointer) ");
|
||||
return false;
|
||||
}
|
||||
if (objectType == TYPE_EOBJECT_EDN_MAIN_WINDOWS) {
|
||||
return true;
|
||||
} else {
|
||||
if(true == ewol::Windows::CheckObjectType(objectType)) {
|
||||
return true;
|
||||
}
|
||||
APPL_ERROR("check error : \"" << TYPE_EOBJECT_EDN_MAIN_WINDOWS << "\" != \"" << objectType << "\"");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the current Object type of the EObject
|
||||
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
|
||||
* @param[in] objectType type description
|
||||
* @return true if the object is compatible, otherwise false
|
||||
*/
|
||||
const char * const MainWindows::GetObjectType(void)
|
||||
{
|
||||
return TYPE_EOBJECT_EDN_MAIN_WINDOWS;
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
|
||||
//APPL_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 = EWOL_CAST_WIDGET_FILE_CHOOSER(CallerObject);
|
||||
if (NULL == tmpWidget) {
|
||||
APPL_ERROR("impossible to get pop_upWidget " << CallerObject);
|
||||
return;
|
||||
}
|
||||
// get the filename :
|
||||
etk::UString tmpData = tmpWidget->GetCompleateFileName();
|
||||
APPL_DEBUG("Request opening the file : " << tmpData);
|
||||
SendMultiCast(ednMsgOpenFile, tmpData);
|
||||
} else if (eventId == ednMsgGuiSaveAs) {
|
||||
if (data == "") {
|
||||
APPL_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)) {
|
||||
APPL_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 = EWOL_CAST_WIDGET_FILE_CHOOSER(CallerObject);
|
||||
if (NULL == tmpWidget) {
|
||||
APPL_ERROR("impossible to get pop_upWidget " << CallerObject);
|
||||
return;
|
||||
}
|
||||
// get the filename :
|
||||
etk::UString tmpData = tmpWidget->GetCompleateFileName();
|
||||
APPL_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);
|
||||
etk::UString windowsTitle = "edn - ";
|
||||
windowsTitle += directName;
|
||||
ewol::SetTitle(windowsTitle);
|
||||
return;
|
||||
} else {
|
||||
m_widgetLabelFileName->SetLabel("");
|
||||
ewol::SetTitle("edn");
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
75
jni/appl/Gui/MainWindows.h
Normal file
75
jni/appl/Gui/MainWindows.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file MainWindows.h
|
||||
* @brief Editeur De N'ours : main Windows diplayer (header)
|
||||
* @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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
#ifndef __MAIN_WINDOWS_H__
|
||||
#define __MAIN_WINDOWS_H__
|
||||
|
||||
#include <appl/Debug.h>
|
||||
#include <MsgBroadcast.h>
|
||||
|
||||
#include <CodeView.h>
|
||||
#include <BufferView.h>
|
||||
#include <BufferManager.h>
|
||||
#include <ewol/widget/Label.h>
|
||||
|
||||
extern const char * const TYPE_EOBJECT_EDN_MAIN_WINDOWS;
|
||||
|
||||
class MainWindows : public ewol::Windows
|
||||
{
|
||||
private:
|
||||
int32_t m_currentSavingAsIdBuffer;
|
||||
ewol::Label* m_widgetLabelFileName;
|
||||
public:
|
||||
// Constructeur
|
||||
MainWindows(void);
|
||||
~MainWindows(void);
|
||||
/**
|
||||
* @brief Check if the object has the specific type.
|
||||
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
|
||||
* @param[in] objectType type of the object we want to check
|
||||
* @return true if the object is compatible, otherwise false
|
||||
*/
|
||||
bool CheckObjectType(const char * const objectType);
|
||||
/**
|
||||
* @brief Get the current Object type of the EObject
|
||||
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
|
||||
* @param[in] objectType type description
|
||||
* @return true if the object is compatible, otherwise false
|
||||
*/
|
||||
const char * const GetObjectType(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 ---
|
||||
*/
|
||||
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
|
||||
};
|
||||
|
||||
#define EDN_CAST_MAIN_WINDOWS(curentPointer) EWOL_CAST(TYPE_EOBJECT_EDN_MAIN_WINDOWS,MainWindows,curentPointer)
|
||||
|
||||
#endif
|
||||
|
||||
|
366
jni/appl/Gui/Search.cpp
Normal file
366
jni/appl/Gui/Search.cpp
Normal file
@@ -0,0 +1,366 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file Search.cpp
|
||||
* @brief Editeur De N'ours : Search system
|
||||
* @author Edouard DUPIN
|
||||
* @date 03/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_globals.h"
|
||||
#include "Search.h"
|
||||
#include "SearchData.h"
|
||||
#include "BufferManager.h"
|
||||
#include "MainWindows.h"
|
||||
#include "MsgBroadcast.h"
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Search"
|
||||
|
||||
|
||||
Search::Search(void)
|
||||
/*: m_localDialog(NULL),
|
||||
m_searchLabel(NULL),
|
||||
m_searchEntry(NULL),
|
||||
m_replaceLabel(NULL),
|
||||
m_replaceEntry(NULL),
|
||||
m_CkMatchCase(NULL),
|
||||
m_CkWrapAround(NULL) */
|
||||
{
|
||||
// nothing to do ...
|
||||
}
|
||||
|
||||
Search::~Search(void)
|
||||
{
|
||||
/*
|
||||
if (NULL!=m_localDialog) {
|
||||
gtk_widget_hide(m_localDialog);
|
||||
gtk_widget_destroy(m_localDialog);
|
||||
m_localDialog = NULL;
|
||||
}
|
||||
*/
|
||||
}
|
||||
/*
|
||||
void Search::Display(GtkWindow *parent)
|
||||
{
|
||||
if(NULL == m_localDialog) {
|
||||
m_localDialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
// set dialog not resisable
|
||||
gtk_window_set_resizable(GTK_WINDOW(m_localDialog), FALSE);
|
||||
// set the windows alwais on top of every all system windows
|
||||
//gtk_window_set_keep_above(GTK_WINDOW(m_localDialog), TRUE);
|
||||
// Set the dialog on top of the selected windows
|
||||
gtk_window_set_transient_for(GTK_WINDOW(m_localDialog), parent);
|
||||
// set the dialog on the top right
|
||||
gtk_window_set_gravity(GTK_WINDOW(m_localDialog), GDK_GRAVITY_NORTH_EAST);
|
||||
// Remove the dialogue from the task bar
|
||||
gtk_window_set_skip_taskbar_hint(GTK_WINDOW(m_localDialog), TRUE);
|
||||
// this element did not apear in the miniature of the windows
|
||||
gtk_window_set_skip_pager_hint(GTK_WINDOW(m_localDialog), TRUE);
|
||||
// select the program icone
|
||||
//gtk_window_set_default_icon_name("Replace");
|
||||
|
||||
// set default title :
|
||||
gtk_window_set_title(GTK_WINDOW(m_localDialog), "Search / Replace");
|
||||
|
||||
// Default size open windows
|
||||
//gtk_window_set_default_size(GTK_WINDOW(m_localDialog), 300, 400);
|
||||
|
||||
// enable the close signal of the windows
|
||||
g_signal_connect(G_OBJECT(m_localDialog), "destroy", G_CALLBACK(OnButtonQuit), 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_localDialog), vbox);
|
||||
|
||||
// Set key Accelerator :
|
||||
//AccelKey::getInstance()->LinkCommonAccel(GTK_WINDOW(m_localDialog));
|
||||
|
||||
// **********************************************************
|
||||
// * Search Entry
|
||||
// **********************************************************
|
||||
{
|
||||
GtkWidget *hbox = gtk_hbox_new (FALSE, 0);
|
||||
gtk_container_add(GTK_CONTAINER (vbox), hbox);
|
||||
// search label
|
||||
m_searchLabel = gtk_label_new("Search ");
|
||||
gtk_box_pack_start(GTK_BOX(hbox), m_searchLabel, FALSE, TRUE, 0);
|
||||
// Search entry
|
||||
m_searchEntry = gtk_entry_new();
|
||||
gtk_box_pack_start(GTK_BOX(hbox), m_searchEntry, TRUE, TRUE, 0);
|
||||
// Connect signals :
|
||||
g_signal_connect(G_OBJECT(m_searchEntry), "activate", G_CALLBACK(OnButtonNext), this);
|
||||
g_signal_connect(G_OBJECT(m_searchEntry), "changed", G_CALLBACK(OnEntrySearchChange), this);
|
||||
}
|
||||
// **********************************************************
|
||||
// * Replace Entry
|
||||
// **********************************************************
|
||||
{
|
||||
GtkWidget *hbox = gtk_hbox_new (FALSE, 0);
|
||||
gtk_container_add(GTK_CONTAINER (vbox), hbox);
|
||||
// search label
|
||||
m_replaceLabel = gtk_label_new("Replace");
|
||||
gtk_box_pack_start(GTK_BOX(hbox), m_replaceLabel, FALSE, TRUE, 0);
|
||||
// Search entry
|
||||
m_replaceEntry = gtk_entry_new();
|
||||
gtk_box_pack_start(GTK_BOX(hbox), m_replaceEntry, TRUE, TRUE, 0);
|
||||
// Connect signals :
|
||||
g_signal_connect(G_OBJECT(m_replaceEntry), "changed", G_CALLBACK(OnEntryReplaceChange), this);
|
||||
}
|
||||
|
||||
// **********************************************************
|
||||
// * mode Selection
|
||||
// **********************************************************
|
||||
m_CkMatchCase = gtk_check_button_new_with_label("Case Sensitive");
|
||||
gtk_container_add(GTK_CONTAINER (vbox), m_CkMatchCase);
|
||||
m_CkWrapAround = gtk_check_button_new_with_label("Wrap arround");
|
||||
gtk_container_add(GTK_CONTAINER (vbox), m_CkWrapAround);
|
||||
m_CkRegularExpression = gtk_check_button_new_with_label("Regular Expression");
|
||||
gtk_container_add(GTK_CONTAINER (vbox), m_CkRegularExpression);
|
||||
|
||||
// connect signals :
|
||||
g_signal_connect(G_OBJECT(m_CkMatchCase), "activate", G_CALLBACK(OnCheckBoxEventCase), this);
|
||||
g_signal_connect(G_OBJECT(m_CkMatchCase), "clicked", G_CALLBACK(OnCheckBoxEventCase), this);
|
||||
g_signal_connect(G_OBJECT(m_CkWrapAround), "activate", G_CALLBACK(OnCheckBoxEventWrap), this);
|
||||
g_signal_connect(G_OBJECT(m_CkWrapAround), "clicked", G_CALLBACK(OnCheckBoxEventWrap), this);
|
||||
g_signal_connect(G_OBJECT(m_CkRegularExpression), "activate", G_CALLBACK(OnCheckBoxEventRegExp), this);
|
||||
g_signal_connect(G_OBJECT(m_CkRegularExpression), "clicked", G_CALLBACK(OnCheckBoxEventRegExp), this);
|
||||
|
||||
|
||||
// **********************************************************
|
||||
// * Search / Replace button
|
||||
// **********************************************************
|
||||
{
|
||||
GtkWidget *hbox = gtk_hbox_new (FALSE, 0);
|
||||
gtk_container_add(GTK_CONTAINER (vbox), hbox);
|
||||
// Find previous
|
||||
m_BtPrevious = gtk_button_new_with_label("Previous");
|
||||
gtk_container_add(GTK_CONTAINER (hbox), m_BtPrevious);
|
||||
// Find Next
|
||||
m_BtNext = gtk_button_new_with_label("Next");
|
||||
gtk_container_add(GTK_CONTAINER (hbox), m_BtNext);
|
||||
// Replace
|
||||
m_BtReplace = gtk_button_new_with_label("Replace");
|
||||
gtk_container_add(GTK_CONTAINER (hbox), m_BtReplace);
|
||||
// Replace & next
|
||||
m_BtReplaceAndNext = gtk_button_new_with_label("Replace & Find");
|
||||
gtk_container_add(GTK_CONTAINER (hbox), m_BtReplaceAndNext);
|
||||
// Exit
|
||||
m_BtQuit = gtk_button_new_with_label("Close");
|
||||
gtk_container_add(GTK_CONTAINER (hbox), m_BtQuit);
|
||||
|
||||
// Connect signals :
|
||||
g_signal_connect(G_OBJECT(m_BtPrevious), "activate", G_CALLBACK(OnButtonPrevious), this);
|
||||
g_signal_connect(G_OBJECT(m_BtPrevious), "released", G_CALLBACK(OnButtonPrevious), this);
|
||||
g_signal_connect(G_OBJECT(m_BtNext), "activate", G_CALLBACK(OnButtonNext), this);
|
||||
g_signal_connect(G_OBJECT(m_BtNext), "released", G_CALLBACK(OnButtonNext), this);
|
||||
g_signal_connect(G_OBJECT(m_BtReplace), "activate", G_CALLBACK(OnButtonReplace), this);
|
||||
g_signal_connect(G_OBJECT(m_BtReplace), "released", G_CALLBACK(OnButtonReplace), this);
|
||||
g_signal_connect(G_OBJECT(m_BtReplaceAndNext), "activate", G_CALLBACK(OnButtonReplaceAndNext), this);
|
||||
g_signal_connect(G_OBJECT(m_BtReplaceAndNext), "released", G_CALLBACK(OnButtonReplaceAndNext), this);
|
||||
g_signal_connect(G_OBJECT(m_BtQuit), "activate", G_CALLBACK(OnButtonQuit), this);
|
||||
g_signal_connect(G_OBJECT(m_BtQuit), "released", G_CALLBACK(OnButtonQuit), this);
|
||||
}
|
||||
|
||||
// recursive version of gtk_widget_show
|
||||
gtk_widget_show_all(m_localDialog);
|
||||
}
|
||||
if(NULL == m_localDialog) {
|
||||
APPL_ERROR("No search-dialog instance");
|
||||
} else {
|
||||
// update datas :
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_CkWrapAround), SearchData::GetWrap());
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_CkMatchCase), SearchData::GetCase());
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_CkRegularExpression), SearchData::GetRegExp());
|
||||
if (true == SearchData::GetRegExp()) {
|
||||
gtk_widget_set_sensitive(m_CkMatchCase, false);
|
||||
} else {
|
||||
gtk_widget_set_sensitive(m_CkMatchCase, true);
|
||||
}
|
||||
// Remove data form the search
|
||||
etk::UString myDataString = "";
|
||||
SearchData::SetSearch(myDataString);
|
||||
gtk_entry_set_text(GTK_ENTRY(m_searchEntry), myDataString.c_str());
|
||||
if (0 == strlen(myDataString.c_str())) {
|
||||
m_haveSearchData = false;
|
||||
} else {
|
||||
m_haveSearchData = true;
|
||||
}
|
||||
|
||||
SearchData::GetReplace(myDataString);
|
||||
gtk_entry_set_text(GTK_ENTRY(m_replaceEntry), myDataString.c_str());
|
||||
if (0 == strlen(myDataString.c_str())) {
|
||||
m_haveReplaceData = false;
|
||||
} else {
|
||||
m_haveReplaceData = true;
|
||||
}
|
||||
|
||||
gtk_widget_set_sensitive(m_BtPrevious, m_haveSearchData);
|
||||
gtk_widget_set_sensitive(m_BtNext, m_haveSearchData);
|
||||
// basic no search data
|
||||
gtk_widget_set_sensitive(m_BtReplace, false);
|
||||
gtk_widget_set_sensitive(m_BtReplaceAndNext, false);
|
||||
|
||||
|
||||
// set focus on a specific widget :
|
||||
//gtk_window_set_focus(parent, m_searchEntry);
|
||||
gtk_widget_grab_focus(m_searchEntry);
|
||||
|
||||
// display the dialogue box
|
||||
gtk_widget_show_all(m_localDialog);
|
||||
|
||||
// hide regular expression
|
||||
gtk_widget_hide(m_CkRegularExpression);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void Search::Destroy(void)
|
||||
{
|
||||
/*
|
||||
if (NULL!=m_localDialog) {
|
||||
gtk_widget_destroy(m_localDialog);
|
||||
m_localDialog = NULL;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
void Search::Hide(void)
|
||||
{
|
||||
//gtk_widget_hide(m_localDialog);
|
||||
}
|
||||
|
||||
/*
|
||||
void Search::OnButtonPrevious(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
//APPL_INFO("CALLBACK");
|
||||
GeneralSendMessage(APPL_MSG__CURRENT_FIND_PREVIOUS);
|
||||
}
|
||||
|
||||
void Search::OnButtonNext(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
//APPL_INFO("CALLBACK");
|
||||
GeneralSendMessage(APPL_MSG__CURRENT_FIND_NEXT);
|
||||
}
|
||||
|
||||
void Search::OnButtonReplace(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
//APPL_INFO("CALLBACK");
|
||||
GeneralSendMessage(APPL_MSG__CURRENT_REPLACE);
|
||||
}
|
||||
|
||||
void Search::OnButtonReplaceAndNext(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
//APPL_INFO("CALLBACK");
|
||||
GeneralSendMessage(APPL_MSG__CURRENT_REPLACE);
|
||||
GeneralSendMessage(APPL_MSG__CURRENT_FIND_NEXT);
|
||||
}
|
||||
|
||||
void Search::OnButtonQuit(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
//APPL_INFO("CALLBACK");
|
||||
Search * self = static_cast<Search*>(data);
|
||||
self->Destroy();
|
||||
}
|
||||
|
||||
void Search::OnCheckBoxEventWrap(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
//APPL_INFO("CALLBACK");
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
|
||||
SearchData::SetWrap(true);
|
||||
} else {
|
||||
SearchData::SetWrap(false);
|
||||
}
|
||||
}
|
||||
|
||||
void Search::OnCheckBoxEventCase(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
//APPL_INFO("CALLBACK");
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
|
||||
SearchData::SetCase(true);
|
||||
} else {
|
||||
SearchData::SetCase(false);
|
||||
}
|
||||
}
|
||||
|
||||
void Search::OnCheckBoxEventRegExp(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
//APPL_INFO("CALLBACK");
|
||||
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);
|
||||
} else {
|
||||
SearchData::SetRegExp(false);
|
||||
gtk_widget_set_sensitive(self->m_CkMatchCase, true);
|
||||
}
|
||||
}
|
||||
|
||||
void Search::OnEntrySearchChange(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
//APPL_INFO("CALLBACK");
|
||||
Search * self = static_cast<Search*>(data);
|
||||
// update research data
|
||||
const char *testData = gtk_entry_get_text(GTK_ENTRY(widget));
|
||||
if (NULL != testData) {
|
||||
etk::UString myDataString = testData;
|
||||
SearchData::SetSearch(myDataString);
|
||||
if (0 == strlen(testData)) {
|
||||
self->m_haveSearchData = false;
|
||||
} else {
|
||||
self->m_haveSearchData = true;
|
||||
}
|
||||
gtk_widget_set_sensitive(self->m_BtPrevious, self->m_haveSearchData);
|
||||
gtk_widget_set_sensitive(self->m_BtNext, self->m_haveSearchData);
|
||||
if (false == self->m_haveSearchData) {
|
||||
gtk_widget_set_sensitive(self->m_BtReplace, false);
|
||||
gtk_widget_set_sensitive(self->m_BtReplaceAndNext, false);
|
||||
} else {
|
||||
gtk_widget_set_sensitive(self->m_BtReplace, true);
|
||||
gtk_widget_set_sensitive(self->m_BtReplaceAndNext, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Search::OnEntryReplaceChange(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
//APPL_INFO("CALLBACK");
|
||||
Search * self = static_cast<Search*>(data);
|
||||
// update replace data
|
||||
const char *testData = gtk_entry_get_text(GTK_ENTRY(widget));
|
||||
if (NULL != testData) {
|
||||
etk::UString myDataString = testData;
|
||||
SearchData::SetReplace(myDataString);
|
||||
if (0 == strlen(testData)) {
|
||||
self->m_haveReplaceData = false;
|
||||
} else {
|
||||
self->m_haveReplaceData = true;
|
||||
}
|
||||
if (false == self->m_haveSearchData) {
|
||||
gtk_widget_set_sensitive(self->m_BtReplace, false);
|
||||
gtk_widget_set_sensitive(self->m_BtReplaceAndNext, false);
|
||||
} else {
|
||||
gtk_widget_set_sensitive(self->m_BtReplace, true);
|
||||
gtk_widget_set_sensitive(self->m_BtReplaceAndNext, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
81
jni/appl/Gui/Search.h
Normal file
81
jni/appl/Gui/Search.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file Search.h
|
||||
* @brief Editeur De N'ours : Search system (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 03/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.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __SEARCH_H__
|
||||
#define __SEARCH_H__
|
||||
|
||||
#include <appl/Debug.h>
|
||||
|
||||
|
||||
class Search
|
||||
{
|
||||
public:
|
||||
// Constructeur
|
||||
Search(void);
|
||||
~Search(void);
|
||||
|
||||
public:
|
||||
void Destroy(void);
|
||||
//void Display(GtkWindow *parent);
|
||||
void Hide(void);
|
||||
/*
|
||||
private:
|
||||
GtkWidget * m_localDialog; //!< local dialog element
|
||||
// entry
|
||||
GtkWidget * m_searchLabel; //!< gtk label of the search section
|
||||
GtkWidget * m_searchEntry; //!< gtk entry of the search section
|
||||
GtkWidget * m_replaceLabel; //!< gtk label of the replace section
|
||||
GtkWidget * m_replaceEntry; //!< gtk entry of the replace section
|
||||
// checkbox
|
||||
GtkWidget * m_CkMatchCase; //!< tick of the case matching
|
||||
GtkWidget * m_CkWrapAround; //!< tick of the wrap the file
|
||||
GtkWidget * m_CkRegularExpression; //!< the test is a regular expression
|
||||
// button
|
||||
GtkWidget * m_BtPrevious; //!< Button Previous
|
||||
GtkWidget * m_BtNext; //!< Button Next
|
||||
GtkWidget * m_BtReplace; //!< Button Replace
|
||||
GtkWidget * m_BtReplaceAndNext; //!< Button Replace and find next
|
||||
GtkWidget * m_BtQuit; //!< Button Quit
|
||||
bool m_haveSearchData;
|
||||
bool m_haveReplaceData;
|
||||
// CallBack for GTK+ gui
|
||||
private :
|
||||
static void OnButtonPrevious(GtkWidget *widget, gpointer user_data);
|
||||
static void OnButtonNext(GtkWidget *widget, gpointer user_data);
|
||||
static void OnButtonReplace(GtkWidget *widget, gpointer user_data);
|
||||
static void OnButtonReplaceAndNext(GtkWidget *widget, gpointer user_data);
|
||||
static void OnButtonQuit(GtkWidget *widget, gpointer user_data);
|
||||
static void OnCheckBoxEventCase(GtkWidget *widget, gpointer user_data);
|
||||
static void OnCheckBoxEventWrap(GtkWidget *widget, gpointer user_data);
|
||||
static void OnCheckBoxEventRegExp(GtkWidget *widget, gpointer user_data);
|
||||
static void OnEntrySearchChange(GtkWidget *widget, gpointer user_data);
|
||||
static void OnEntryReplaceChange(GtkWidget *widget, gpointer user_data);
|
||||
*/
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
102
jni/appl/Gui/SearchData.cpp
Normal file
102
jni/appl/Gui/SearchData.cpp
Normal file
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file SearchData.cpp
|
||||
* @brief Editeur De N'ours : Search Data element (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 02/02/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_globals.h>
|
||||
#include <SearchData.h>
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "SearchData"
|
||||
|
||||
|
||||
static etk::UString m_findRequest = "";
|
||||
|
||||
void SearchData::SetSearch(etk::UString &myData)
|
||||
{
|
||||
m_findRequest = myData;
|
||||
}
|
||||
void SearchData::GetSearch(etk::UString &myData)
|
||||
{
|
||||
myData = m_findRequest;
|
||||
}
|
||||
bool SearchData::IsSearchEmpty(void)
|
||||
{
|
||||
if(m_findRequest.Size() > 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static etk::UString m_replaceRequest = "";
|
||||
void SearchData::SetReplace(etk::UString &myData)
|
||||
{
|
||||
m_replaceRequest = myData;
|
||||
}
|
||||
void SearchData::GetReplace(etk::UString &myData)
|
||||
{
|
||||
myData = m_replaceRequest;
|
||||
}
|
||||
bool SearchData::IsReplaceEmpty(void)
|
||||
{
|
||||
if(m_replaceRequest.Size() > 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static bool m_case = false;
|
||||
void SearchData::SetCase(bool value)
|
||||
{
|
||||
m_case = value;
|
||||
}
|
||||
bool SearchData::GetCase(void)
|
||||
{
|
||||
return m_case;
|
||||
}
|
||||
|
||||
|
||||
static bool m_wrap = true;
|
||||
void SearchData::SetWrap(bool value)
|
||||
{
|
||||
m_wrap = value;
|
||||
}
|
||||
bool SearchData::GetWrap(void)
|
||||
{
|
||||
return m_wrap;
|
||||
}
|
||||
|
||||
|
||||
static bool m_RegExp = false;
|
||||
void SearchData::SetRegExp(bool value)
|
||||
{
|
||||
m_RegExp = value;
|
||||
}
|
||||
bool SearchData::GetRegExp(void)
|
||||
{
|
||||
return m_RegExp;
|
||||
}
|
||||
|
||||
|
49
jni/appl/Gui/SearchData.h
Normal file
49
jni/appl/Gui/SearchData.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file SearchData.h
|
||||
* @brief Editeur De N'ours : Search Data element (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 02/02/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 __SEARCH_DATA_H__
|
||||
#define __SEARCH_DATA_H__
|
||||
|
||||
#include <etk/UString.h>
|
||||
#include <appl/Debug.h>
|
||||
|
||||
namespace SearchData
|
||||
{
|
||||
void SetSearch(etk::UString &myData);
|
||||
void GetSearch(etk::UString &myData);
|
||||
bool IsSearchEmpty(void);
|
||||
void SetReplace(etk::UString &myData);
|
||||
void GetReplace(etk::UString &myData);
|
||||
bool IsReplaceEmpty(void);
|
||||
void SetCase(bool value);
|
||||
bool GetCase(void);
|
||||
void SetWrap(bool value);
|
||||
bool GetWrap(void);
|
||||
void SetRegExp(bool value);
|
||||
bool GetRegExp(void);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user