Move to gitHub the edn project (remove history keep it on my nas)

This commit is contained in:
2011-07-20 10:33:24 +02:00
parent e777f0ad0f
commit e201a51a38
152 changed files with 31575 additions and 0 deletions

View File

@@ -0,0 +1,159 @@
/**
*******************************************************************************
* @file MainWindows.cpp
* @brief Editeur De N'ours : main Windows diplayer
* @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 "SearchData.h"
//#include "MsgBroadcast.h"
#include "BufferView.h"
#include "AccelKey.h"
#undef __class__
#define __class__ "MainWindows"
MainWindows::MainWindows(void) : MsgBroadcast("Main Windows", EDN_CAT_GUI)
{
m_mainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
// select the program icone
gtk_window_set_default_icon_name("text-editor");
// Default size open windows
gtk_window_set_default_size(GTK_WINDOW(m_mainWindow), 800, 600);
// enable the close signal of the windows
g_signal_connect(G_OBJECT(m_mainWindow), "destroy", G_CALLBACK(gtk_main_quit), NULL);
// 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.
gtk_box_pack_start( GTK_BOX (vbox), m_MenuBar.GetWidget(), 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 :
# if USE_GTK_VERSION_2_0
gtk_box_pack_start(GTK_BOX(hbox), m_ToolBar.GetWidget(), FALSE, FALSE, 0);
# endif
// TreeView :
gtk_box_pack_start(GTK_BOX(hbox), m_BufferView.GetMainWidget(), FALSE, TRUE, 1);
// Tex 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(Edn::String &fileName, bool isModify)
{
Edn::String tmp = "";
if (fileName != "") {
tmp += fileName;
tmp += " - ";
}
tmp += "Edn";
gtk_window_set_title(GTK_WINDOW(m_mainWindow), 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) {
Edn::String plop = "";
SetTitle(plop, false );
} else {
Buffer *mybuf = BufferManager::getInstance()->Get(dataID);
if (NULL != mybuf) {
Edn::String plop = mybuf->GetName();
SetTitle(plop, mybuf->IsModify() );
}
}
break;
}
}
#if 0
void MainWindows::OnMenuAbout(wxCommandEvent & WXUNUSED(event))
{
//EDN_INFO("MainWindows::OnMenuAbout (event)");
wxAboutDialogInfo info;
info.SetName(wxT("edn"));
info.SetVersion(wxT("0.1.0 pre-Beta"));
info.SetDescription(wxT("Editeur De N'ours, l'Editeur Desoxyribo-Nucleique\n"
"Source Code Editor"));
info.SetCopyright(wxT( "Copyright 2010 Edouard DUPIN, all right reserved\n"
"This software is distributed in the hope that it will be useful, but WITHOUT\n"
"ANY WARRANTY\n\n"
"Licence summary : \n"
" You can modify and redistribute the sources code and binaries.\n"
" You can send me the bug-fix\n"
" You can not earn money with this Software (if the source extract from Edn\n"
" represent less than 50% of original Sources)\n"
"Term of the licence in in the file licence.txt"));
wxAboutBox(info);
}
#endif

View File

@@ -0,0 +1,67 @@
/**
*******************************************************************************
* @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.
*
*******************************************************************************
*/
#include "tools_debug.h"
#include "Singleton.h"
#include "MsgBroadcast.h"
#include "CodeView.h"
#include "BufferView.h"
#include "BufferManager.h"
#include "MenuBar.h"
#include "StatusBar.h"
#include "ToolBar.h"
#ifndef __MAIN_WINDOWS_H__
#define __MAIN_WINDOWS_H__
class MainWindows: public Singleton<MainWindows>, public MsgBroadcast
{
friend class 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);
private:
void SetTitle(Edn::String &fileName, bool isModify);
// main windows widget :
GtkWidget * m_mainWindow;
BufferView m_BufferView;
CodeView m_CodeView;
MenuBar m_MenuBar;
StatusBar m_StatusBar;
ToolBar m_ToolBar;
};
#endif

View File

@@ -0,0 +1,333 @@
/**
*******************************************************************************
* @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 "charset.h"
#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";
#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);
}
}
#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() );
// 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;
EdnVectorBin<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", NULL, 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+q", EDN_MSG__QUIT, 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+d", 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(GTK_STOCK_PREFERENCES, NULL, EDN_MSG__GUI_SHOW_PREFERENCE, 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->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);
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("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+u", EDN_MSG__JUMP_TO_CURRENT_SELECTION, true);
tmp->AddGen("Back previous", "ctrl+y", 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);
}
MenuBar::~MenuBar(void)
{
}
void MenuBar::OnMessage(int32_t id, int32_t dataID)
{
//EDN_INFO("ReceiveMessage");
}

View File

@@ -0,0 +1,53 @@
/**
*******************************************************************************
* @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 "EdnVectorBin.h"
#include "AccelKey.h"
#ifndef __MENU_BAR_H__
#define __MENU_BAR_H__
class MenuBarMain;
class MenuBar: public MsgBroadcast
{
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;
EdnVectorBin<MenuBarMain*> m_listMenu;
};
#endif

View File

@@ -0,0 +1,52 @@
/**
*******************************************************************************
* @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) : MsgBroadcast("Status bar", EDN_CAT_GUI)
{
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");
}

View File

@@ -0,0 +1,46 @@
/**
*******************************************************************************
* @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 MsgBroadcast
{
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

View File

@@ -0,0 +1,93 @@
/**
*******************************************************************************
* @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) : MsgBroadcast("Tool bar", EDN_CAT_GUI)
{
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
}

View File

@@ -0,0 +1,49 @@
/**
*******************************************************************************
* @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 MsgBroadcast
{
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;
EdnVectorBin<messageData_ts*> m_message;
};
#endif

View File

@@ -0,0 +1,344 @@
/**
*******************************************************************************
* @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(void)
{
if(NULL == m_localDialog) {
m_localDialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_resizable(GTK_WINDOW(m_localDialog), FALSE);
gtk_window_set_keep_above(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("Quit");
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) {
EDN_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);
}
Edn::String myDataString;
SearchData::GetSearch(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);
if (false == m_haveSearchData) {
gtk_widget_set_sensitive(m_BtReplace, false);
gtk_widget_set_sensitive(m_BtReplaceAndNext, false);
} else {
gtk_widget_set_sensitive(m_BtReplace, m_haveReplaceData);
gtk_widget_set_sensitive(m_BtReplaceAndNext, m_haveReplaceData);
}
// 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)
{
//EDN_INFO("CALLBACK");
GeneralSendMessage(EDN_MSG__CURRENT_FIND_PREVIOUS);
}
void Search::OnButtonNext(GtkWidget *widget, gpointer data)
{
//EDN_INFO("CALLBACK");
GeneralSendMessage(EDN_MSG__CURRENT_FIND_NEXT);
}
void Search::OnButtonReplace(GtkWidget *widget, gpointer data)
{
//EDN_INFO("CALLBACK");
GeneralSendMessage(EDN_MSG__CURRENT_REPLACE);
}
void Search::OnButtonReplaceAndNext(GtkWidget *widget, gpointer data)
{
//EDN_INFO("CALLBACK");
GeneralSendMessage(EDN_MSG__CURRENT_REPLACE);
GeneralSendMessage(EDN_MSG__CURRENT_FIND_NEXT);
}
void Search::OnButtonQuit(GtkWidget *widget, gpointer data)
{
//EDN_INFO("CALLBACK");
Search * self = reinterpret_cast<Search*>(data);
self->Destroy();
}
void Search::OnCheckBoxEventWrap(GtkWidget *widget, gpointer data)
{
//EDN_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)
{
//EDN_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)
{
//EDN_INFO("CALLBACK");
Search * self = reinterpret_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)
{
//EDN_INFO("CALLBACK");
Search * self = reinterpret_cast<Search*>(data);
// update research data
const char *testData = gtk_entry_get_text(GTK_ENTRY(widget));
if (NULL != testData) {
Edn::String 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, self->m_haveReplaceData);
gtk_widget_set_sensitive(self->m_BtReplaceAndNext, self->m_haveReplaceData);
}
}
}
void Search::OnEntryReplaceChange(GtkWidget *widget, gpointer data)
{
//EDN_INFO("CALLBACK");
Search * self = reinterpret_cast<Search*>(data);
// update replace data
const char *testData = gtk_entry_get_text(GTK_ENTRY(widget));
if (NULL != testData) {
Edn::String myDataString = testData;
SearchData::SetReplace(myDataString);
if (0 == strlen(testData)) {
self->m_haveReplaceData = false;
} else {
self->m_haveReplaceData = true;
}
gtk_widget_set_sensitive(self->m_BtReplace, self->m_haveReplaceData);
gtk_widget_set_sensitive(self->m_BtReplaceAndNext, self->m_haveReplaceData);
}
}

View File

@@ -0,0 +1,86 @@
/**
*******************************************************************************
* @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 "tools_debug.h"
#include "Singleton.h"
#include <string>
#include <vector>
class Search: public Singleton<Search>
{
friend class Singleton<Search>;
// specific for sigleton system...
private:
// Constructeur
Search(void);
~Search(void);
public:
void Destroy(void);
void Display(void);
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

View File

@@ -0,0 +1,103 @@
/**
*******************************************************************************
* @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"
#include "Edn.h"
#undef __class__
#define __class__ "SearchData"
static Edn::String m_findRequest = "";
void SearchData::SetSearch(Edn::String &myData)
{
m_findRequest = myData;
}
void SearchData::GetSearch(Edn::String &myData)
{
myData = m_findRequest;
}
bool SearchData::IsSearchEmpty(void)
{
if(m_findRequest.Size() > 0) {
return false;
}
return true;
}
static Edn::String m_replaceRequest = "";
void SearchData::SetReplace(Edn::String &myData)
{
m_replaceRequest = myData;
}
void SearchData::GetReplace(Edn::String &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;
}

View 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 "tools_debug.h"
#include "Edn.h"
namespace SearchData
{
void SetSearch(Edn::String &myData);
void GetSearch(Edn::String &myData);
bool IsSearchEmpty(void);
void SetReplace(Edn::String &myData);
void GetReplace(Edn::String &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

View File

@@ -0,0 +1,157 @@
/**
*******************************************************************************
* @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 "Edn.h"
#include "Search.h"
#undef __class__
#define __class__ "WindowsManager"
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
WindowsManager::WindowsManager(void) : MsgBroadcast("Windows Manager", EDN_CAT_GUI_MANAGER)
{
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();
}
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, // button text
GTK_RESPONSE_CANCEL, // response id
GTK_STOCK_OPEN, // button text
GTK_RESPONSE_ACCEPT, // response id
NULL); // end button/response list
if( -1 != m_currentBufferID
&& true == myBufferManager->Exist(m_currentBufferID) )
{
Edn::String fileFolder = myBufferManager->Get(m_currentBufferID)->GetFolder();
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER(dialog), fileFolder.c_str());
//gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER(dialog), "Untitled document");
}
if (gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
{
Edn::String 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);
Edn::String tmpString = "Save as file : ";
tmpString += myBuffer->GetShortName().c_str();
GtkWidget *dialog = gtk_file_chooser_dialog_new( tmpString.c_str(), NULL,
GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, // button text
GTK_RESPONSE_CANCEL, // response id
GTK_STOCK_SAVE, // button text
GTK_RESPONSE_ACCEPT, // response id
NULL); // end button/response list
if (gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
{
Edn::String myfilename;
myfilename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (dialog));
myBuffer->SetName(myfilename);
myBuffer->Save();
SendMessage(EDN_MSG__CURRENT_CHANGE_BUFFER_ID, idSelected);
}
gtk_widget_destroy(dialog); // implicitly hides dialog
}
break;
}
}

View File

@@ -0,0 +1,50 @@
/**
*******************************************************************************
* @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 "Singleton.h"
#include "MsgBroadcast.h"
#include "MainWindows.h"
class WindowsManager: public Singleton<WindowsManager>, public MsgBroadcast
{
friend class 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