display of menu correct

This commit is contained in:
Edouard Dupin 2012-02-17 18:25:38 +01:00
parent dc73285cb7
commit 4e7491e5fc
4 changed files with 47 additions and 324 deletions

View File

@ -20,8 +20,8 @@ LOCAL_CFLAGS := -D__PLATFORM__Android \
-DEWOL_USE_FREE_TYPE \
-DETK_DEBUG_LEVEL=3 \
-DEDN_DEBUG_LEVEL=3 \
-DDATA_IN_APK \
-std=c++0x
-DDATA_IN_APK
include $(BUILD_SHARED_LIBRARY)

View File

@ -16,8 +16,7 @@ LOCAL_SRC_FILES := $(FILE_LIST)
LOCAL_LDLIBS :=
LOCAL_CFLAGS := -DEWOL_USE_FREE_TYPE \
-DEDN_DEBUG_LEVEL=3 \
-std=c++0x
-DEDN_DEBUG_LEVEL=3
include $(BUILD_EXECUTABLE)

View File

@ -50,22 +50,12 @@
#undef __class__
#define __class__ "MainWindows"
const char * const ednEventNewFile = "edn-New-File";
const char * const ednEventOpenFile = "edn-Open-File";
const char * const ednEventCloseFile = "edn-Close-File";
const char * const ednEventSaveFile = "edn-Save-File";
const char * const ednEventSaveAsFile = "edn-SaveAs-File";
const char * const ednEventPopUpFileSelected = "edn-PopUp-FileSelected";
const char * const ednEventPopUpFileSaveAs = "edn-PopUp-FileSaveAs";
const char * const ednEventContextMenuOther = "edn-Other";
MainWindows::MainWindows(void)
{
EDN_DEBUG("CREATE WINDOWS ... ");
ewol::SizerVert * mySizerVert = NULL;
ewol::SizerHori * mySizerHori = NULL;
ewol::Button * myButton = NULL;
//ewol::Button * myButton = NULL;
ewol::Label * myLabel = NULL;
CodeView * myCodeView = NULL;
BufferView * myBufferView = NULL;
@ -80,81 +70,42 @@ MainWindows::MainWindows(void)
myMenu = new ewol::Menu();
mySizerHori->SubWidgetAdd(myMenu);
int32_t idMenuFile = myMenu->AddTitle("File");
myMenu->Add(idMenuFile, "New", "", ednMsgGuiNew);
myMenu->AddSpacer();
myMenu->Add(idMenuFile, "Open", "", ednMsgGuiOpen);
myMenu->Add(idMenuFile, "Close", "", ednMsgGuiClose, "current");
myMenu->Add(idMenuFile, "Close (all)", "", ednMsgGuiClose, "All");
myMenu->Add(idMenuFile, "Save", "", ednMsgGuiSave, "current");
myMenu->Add(idMenuFile, "Save As ...", "", ednMsgGuiSaveAs);
myMenu->AddSpacer();
//myMenu->Add(idMenuFile, "Exit", "", ednMsgGuiExit);
(void)myMenu->Add(idMenuFile, "New", "", ednMsgGuiNew);
(void)myMenu->AddSpacer();
(void)myMenu->Add(idMenuFile, "Open", "", ednMsgGuiOpen);
(void)myMenu->Add(idMenuFile, "Close", "", ednMsgGuiClose, "current");
(void)myMenu->Add(idMenuFile, "Close (all)", "", ednMsgGuiClose, "All");
(void)myMenu->Add(idMenuFile, "Save", "", ednMsgGuiSave, "current");
(void)myMenu->Add(idMenuFile, "Save As ...", "", ednMsgGuiSaveAs);
(void)myMenu->AddSpacer();
//(void)myMenu->Add(idMenuFile, "Exit", "", ednMsgGuiExit);
int32_t idMenuEdit = myMenu->AddTitle("Edit");
myMenu->Add(idMenuEdit, "Undo", "", ednMsgGuiUndo);
myMenu->Add(idMenuEdit, "Redo", "", ednMsgGuiRedo);
myMenu->AddSpacer();
myMenu->Add(idMenuEdit, "Copy", "", ednMsgGuiCopy, "STD");
myMenu->Add(idMenuEdit, "Cut", "", ednMsgGuiCut, "STD");
myMenu->Add(idMenuEdit, "Paste", "", ednMsgGuiPaste, "STD");
myMenu->Add(idMenuEdit, "Redo", "", ednMsgGuiRedo);
myMenu->Add(idMenuEdit, "Remove","", ednMsgGuiRm);
myMenu->AddSpacer();
myMenu->Add(idMenuEdit, "Select All","", ednMsgGuiSelect, "ALL");
myMenu->Add(idMenuEdit, "Un-Select","", ednMsgGuiSelect, "NONE");
myMenu->Add(idMenuEdit, "Goto line ...","", ednMsgGuiGotoLine, "???");
(void)myMenu->Add(idMenuEdit, "Undo", "", ednMsgGuiUndo);
(void)myMenu->Add(idMenuEdit, "Redo", "", ednMsgGuiRedo);
(void)myMenu->AddSpacer();
(void)myMenu->Add(idMenuEdit, "Copy", "", ednMsgGuiCopy, "STD");
(void)myMenu->Add(idMenuEdit, "Cut", "", ednMsgGuiCut, "STD");
(void)myMenu->Add(idMenuEdit, "Paste", "", ednMsgGuiPaste, "STD");
(void)myMenu->Add(idMenuEdit, "Redo", "", ednMsgGuiRedo);
(void)myMenu->Add(idMenuEdit, "Remove","", ednMsgGuiRm);
(void)myMenu->AddSpacer();
(void)myMenu->Add(idMenuEdit, "Select All","", ednMsgGuiSelect, "ALL");
(void)myMenu->Add(idMenuEdit, "Un-Select","", ednMsgGuiSelect, "NONE");
(void)myMenu->Add(idMenuEdit, "Goto line ...","", ednMsgGuiGotoLine, "???");
int32_t idMenuSearch = myMenu->AddTitle("Search");
myMenu->Add(idMenuEdit, "Search", "", ednMsgGuiSearch);
myMenu->Add(idMenuEdit, "Replace", "", ednMsgGuiReplace);
myMenu->AddSpacer();
myMenu->Add(idMenuEdit, "Find (previous)","", ednMsgGuiFind, "Previous");
myMenu->Add(idMenuEdit, "Find (next)", "", ednMsgGuiFind, "Next");
myMenu->Add(idMenuEdit, "Find (all)", "", ednMsgGuiFind, "All");
myMenu->Add(idMenuEdit, "Un-Select", "", ednMsgGuiFind, "None");
(void)myMenu->Add(idMenuSearch, "Search", "", ednMsgGuiSearch);
(void)myMenu->Add(idMenuSearch, "Replace", "", ednMsgGuiReplace);
(void)myMenu->AddSpacer();
(void)myMenu->Add(idMenuSearch, "Find (previous)","", ednMsgGuiFind, "Previous");
(void)myMenu->Add(idMenuSearch, "Find (next)", "", ednMsgGuiFind, "Next");
(void)myMenu->Add(idMenuSearch, "Find (all)", "", ednMsgGuiFind, "All");
(void)myMenu->Add(idMenuSearch, "Un-Select", "", ednMsgGuiFind, "None");
int32_t idMenuCTags = myMenu->AddTitle("C-tags");
myMenu->Add(idMenuEdit, "Load", "", ednMsgGuiCtags, "Load");
myMenu->Add(idMenuEdit, "ReLoad", "", ednMsgGuiCtags, "ReLoad");
myMenu->Add(idMenuEdit, "Jump", "", ednMsgGuiCtags, "Jump");
myMenu->Add(idMenuEdit, "Back", "", ednMsgGuiCtags, "Back");
int32_t idMenuAbout = myMenu->AddTitle("?", "", ednMsgGuiAbout);
/*
myButton = new ewol::Button("New");
mySizerHori->SubWidgetAdd(myButton);
if (false == myButton->ExternLinkOnEvent(ewolEventButtonPressed, GetWidgetId(), ednEventNewFile) ) {
EDN_CRITICAL("link with an entry event");
}
myButton = new ewol::Button("Open");
mySizerHori->SubWidgetAdd(myButton);
if (false == myButton->ExternLinkOnEvent(ewolEventButtonPressed, GetWidgetId(), ednEventOpenFile) ) {
EDN_CRITICAL("link with an entry event");
}
myButton = new ewol::Button("Close");
mySizerHori->SubWidgetAdd(myButton);
if (false == myButton->ExternLinkOnEvent(ewolEventButtonPressed, GetWidgetId(), ednEventCloseFile) ) {
EDN_CRITICAL("link with an entry event");
}
myButton = new ewol::Button("Save");
mySizerHori->SubWidgetAdd(myButton);
if (false == myButton->ExternLinkOnEvent(ewolEventButtonPressed, GetWidgetId(), ednEventSaveFile) ) {
EDN_CRITICAL("link with an entry event");
}
myButton = new ewol::Button("Save As ...");
mySizerHori->SubWidgetAdd(myButton);
if (false == myButton->ExternLinkOnEvent(ewolEventButtonPressed, GetWidgetId(), ednEventSaveAsFile) ) {
EDN_CRITICAL("link with an entry event");
}
*/
myButton = new ewol::Button(" * Other * ");
mySizerHori->SubWidgetAdd(myButton);
if (false == myButton->ExternLinkOnEvent(ewolEventButtonPressed, GetWidgetId(), ednEventContextMenuOther) ) {
EDN_CRITICAL("link with an entry event");
}
(void)myMenu->Add(idMenuCTags, "Load", "", ednMsgGuiCtags, "Load");
(void)myMenu->Add(idMenuCTags, "ReLoad", "", ednMsgGuiCtags, "ReLoad");
(void)myMenu->Add(idMenuCTags, "Jump", "", ednMsgGuiCtags, "Jump");
(void)myMenu->Add(idMenuCTags, "Back", "", ednMsgGuiCtags, "Back");
(void)myMenu->AddTitle("?", "", ednMsgGuiAbout);
myLabel = new ewol::Label("FileName");
myLabel->SetExpendX(true);
@ -191,6 +142,7 @@ MainWindows::MainWindows(void)
// Generic event ...
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgGuiSaveAs);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgGuiOpen);
}
@ -199,7 +151,8 @@ MainWindows::~MainWindows(void)
}
const char *const ednEventPopUpFileSelected = "edn-mainWindows-openSelected";
const char *const ednEventPopUpFileSaveAs = "edn-mainWindows-saveAsSelected";
bool MainWindows::OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * data, etkFloat_t x, etkFloat_t y)
{
@ -207,21 +160,8 @@ bool MainWindows::OnEventAreaExternal(int32_t widgetID, const char * generateEve
return true;
}
//EDN_INFO("Receive Event from the main windows ... : widgetid=" << widgetID << "\"" << generateEventId << "\" ==> data=\"" << data << "\"" );
// newFile section ...
if (generateEventId == ednEventNewFile) {
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgGuiNew);
}
else if (generateEventId == ednEventCloseFile) {
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgGuiClose, "current");
}
else if (generateEventId == ednEventSaveFile) {
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgGuiSave, "current");
}
else if (generateEventId == ednEventSaveAsFile) {
OnEventAreaExternal(GetWidgetId(), ednMsgGuiSaveAs, "current", x, y);
}
// Open file Section ...
else if (generateEventId == ednEventOpenFile) {
if (generateEventId == ednMsgGuiOpen) {
ewol::FileChooser* tmpWidget = new ewol::FileChooser();
tmpWidget->SetTitle("Open Files ...");
tmpWidget->SetValidateLabel("Open");
@ -290,223 +230,8 @@ bool MainWindows::OnEventAreaExternal(int32_t widgetID, const char * generateEve
BufferManager * myMng = BufferManager::getInstance();
myMng->Get(m_currentSavingAsIdBuffer)->SetFileName(tmpData);
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgGuiSave, m_currentSavingAsIdBuffer);
//ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgOpenFile, tmpData);
} else if (generateEventId == ednEventContextMenuOther) {
ewol::ContextMenu * tmpWidget = new ewol::ContextMenu();
if (NULL == tmpWidget) {
return false;
}
tmpWidget->SetPositionMark(ewol::CONTEXT_MENU_MARK_TOP, {x, y} );
ewol::SizerVert * mySizerVert = NULL;
ewol::Button * myButton = NULL;
mySizerVert = new ewol::SizerVert();
mySizerVert->LockExpendContamination(true);
// set it in the pop-up-system :
tmpWidget->SubWidgetSet(mySizerVert);
myButton = new ewol::Button("plop");
//m_widgetValidateId = myButton->GetWidgetId();
//myButton->ExternLinkOnEvent(ewolEventButtonPressed, GetWidgetId(), ewolEventFileChooserValidate);
myButton->SetExpendX(true);
myButton->SetFillX(true);
mySizerVert->SubWidgetAdd(myButton);
myButton = new ewol::Button("plop2");
//m_widgetCancelId = myButton->GetWidgetId();
//myButton->ExternLinkOnEvent(ewolEventButtonPressed, GetWidgetId(), ewolEventFileChooserCancel);
myButton->SetExpendX(true);
myButton->SetFillX(true);
mySizerVert->SubWidgetAdd(myButton);
myButton = new ewol::Button("plop3");
//m_widgetCancelId = myButton->GetWidgetId();
//myButton->ExternLinkOnEvent(ewolEventButtonPressed, GetWidgetId(), ewolEventFileChooserCancel);
myButton->SetExpendX(true);
myButton->SetFillX(true);
mySizerVert->SubWidgetAdd(myButton);
PopUpWidgetPush(tmpWidget);
}
return true;
}
#ifdef SDFGSDFGSDF___SDFGSDFG
MainWindows::MainWindows(void) : MsgBroadcast("Main Windows", EDN_CAT_GUI)
{
m_mainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
// select the program icone
GError *err = NULL;
etk::UString iconeFile;
iconeFile = "/usr/share/edn/images/icone.png";
GdkPixbuf * icone = gdk_pixbuf_new_from_file(iconeFile.c_str(), &err);
if (err != NULL) {
gtk_window_set_default_icon_name("text-editor");
} else {
gtk_window_set_icon(GTK_WINDOW(m_mainWindow), icone);
}
// enable the close signal of the windows
g_signal_connect(G_OBJECT(m_mainWindow), "delete-event", G_CALLBACK(OnQuit), this);
g_signal_connect(G_OBJECT(m_mainWindow), "window-state-event", G_CALLBACK(OnStateChange), this);
// Create a vertical box for stacking the menu and editor widgets in.
GtkWidget *vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add(GTK_CONTAINER(m_mainWindow), vbox);
// Set key Accelerator :
AccelKey::getInstance()->LinkCommonAccel(GTK_WINDOW(m_mainWindow));
// Create the menu bar.
GtkWidget *hboxMenu = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start( GTK_BOX (vbox), hboxMenu, FALSE, FALSE, 0);
// Add Exit boutton
etk::UString ExitIconeFile;
ExitIconeFile = "/usr/share/edn/images/delete-24px.png";
// TODO : find a good way to change the size of an image
GtkWidget *myImageQuit = gtk_image_new_from_file(ExitIconeFile.c_str());
GtkIconSize mySize = GTK_ICON_SIZE_SMALL_TOOLBAR;
//EDN_DEBUG(" plop : " << mySize);
//gtk_image_get_icon_set( GTK_IMAGE(myImageQuit), NULL, &mySize);
//EDN_DEBUG(" plop : " << mySize);
GtkWidget *event_box = gtk_event_box_new();
gtk_container_add(GTK_CONTAINER(event_box),myImageQuit);
gtk_widget_add_events(event_box,GDK_BUTTON_PRESS_MASK);
g_signal_connect(G_OBJECT(event_box), "button_press_event", G_CALLBACK(OnQuit), this);
gtk_box_pack_start( GTK_BOX(hboxMenu), event_box, FALSE, FALSE, 0);
// add the real menu bar
gtk_box_pack_start( GTK_BOX (hboxMenu), m_MenuBar.GetWidget(), FALSE, FALSE, 0);
// Add title
m_internalTitleLabel = gtk_label_new("Edn");
gtk_box_pack_start( GTK_BOX (hboxMenu), m_internalTitleLabel, FALSE, FALSE, 0);
// **********************************************************
// * Horizontal ELEMENTS : *
// **********************************************************
// Create a vertical box for stacking the menu and editor widgets in.
GtkWidget *hbox = gtk_hbox_new (FALSE, 0);
gtk_container_add(GTK_CONTAINER (vbox), hbox);
// create the toolbar :
// TreeView :
gtk_box_pack_start(GTK_BOX(hbox), m_BufferView.GetMainWidget(), FALSE, TRUE, 1);
// Text displayer :
gtk_box_pack_start( GTK_BOX (hbox), m_CodeView.GetMainWidget(), TRUE, TRUE, 0);
// Create the status bar
//gtk_box_pack_end(GTK_BOX(vbox), m_StatusBar.GetWidget(), FALSE, FALSE, 0);
// recursive version of gtk_widget_show
gtk_widget_show_all(m_mainWindow);
MainWindows::~MainWindows(void)
{
/*
if (NULL != m_DlgSearch) {
delete m_DlgSearch;
}
*/
}
void MainWindows::SetTitle(etk::File &fileName, bool isModify)
{
etk::UString tmp = "";
if (fileName.GetShortFilename() != "") {
tmp += fileName.GetShortFilename();
tmp += " - ";
tmp += fileName.GetFolder();
tmp += " - ";
}
tmp += "Edn";
//gtk_window_set_title(GTK_WINDOW(m_mainWindow), tmp.c_str());
tmp = " ";
if (fileName.GetShortFilename() != "") {
tmp += fileName.GetFolder();
tmp += "/";
tmp += fileName.GetShortFilename();
} else {
tmp += "Edn";
}
tmp += " ";
//gtk_label_set_text(GTK_LABEL(m_internalTitleLabel), tmp.c_str());
}
void MainWindows::SetNoTitle(void)
{
etk::UString tmp = "Edn";
//gtk_window_set_title(GTK_WINDOW(m_mainWindow), tmp.c_str());
//gtk_label_set_text(GTK_LABEL(m_internalTitleLabel), tmp.c_str());
}
void MainWindows::OnMessage(int32_t id, int32_t dataID)
{
switch (id)
{
case EDN_MSG__BUFFER_CHANGE_CURRENT:
// change Title :
// TODO : String error when remove the error with -1;
if (-1 == dataID) {
SetNoTitle();
} else {
/*
Buffer *mybuf = BufferManager::getInstance()->Get(dataID);
if (NULL != mybuf) {
etk::File plop = mybuf->GetFileName();
SetTitle(plop, mybuf->IsModify() );
}
*/
}
break;
}
}
bool MainWindows::OnQuit(GtkWidget *widget, gpointer data)
{
//MainWindows * self = reinterpret_cast<MainWindows*>(data);
GeneralSendMessage(EDN_MSG__GUI_SHOW_EXIT_CONFIRMATION);
// Close is not managed here ...
return true;
}
gboolean MainWindows::OnStateChange(GtkWidget *widget, GdkEvent* event, gpointer data)
{
MainWindows * self = reinterpret_cast<MainWindows*>(data);
EDN_DEBUG("State change");
EDN_INFO(" change state mask : " << event->window_state.changed_mask);
EDN_INFO(" change state new val : " << event->window_state.new_window_state);
if (event->window_state.changed_mask == GDK_WINDOW_STATE_MAXIMIZED) {
EDN_INFO(" ==> Maximisation change...");
if (event->window_state.new_window_state == GDK_WINDOW_STATE_MAXIMIZED) {
EDN_INFO(" ==> ENABLE");
gtk_window_set_decorated(GTK_WINDOW(self->m_mainWindow), FALSE);
} else {
EDN_INFO(" ==> DISABLE");
gtk_window_set_decorated(GTK_WINDOW(self->m_mainWindow), TRUE);
}
}
}
#endif

View File

@ -72,13 +72,12 @@ void APP_Init(void)
#endif
ewol::SetFontFolder("Font");
//ewol::SetDefaultFont("freefont/FreeMono.ttf", 12);
ewol::SetDefaultFont("freefont/FreeSerif.ttf", 12);
//ewol::SetDefaultFont("freefont/FreeMonoBold.ttf", 12);
//ewol::SetDefaultFont("ACharmingFont.ttf", 45);
//ewol::SetDefaultFont("Monospace/Monospace", 40);
//ewol::SetDefaultFont("unispace.ttf", 12);
#ifdef __PLATFORM__Android
ewol::SetDefaultFont("freefont/FreeSerif.ttf", 16);
#else
ewol::SetDefaultFont("freefont/FreeSerif.ttf", 12);
#endif
// init internal global value
globals::init();