X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fguicast%2Fbcmenuitem.C;h=f672e77367a2e2d62f57d32c2630ea8d92aff1ae;hb=9ff2bf4dedcb2e3d94e29e121aada715ff30e90e;hp=2c4469e4cf6a9e0a90c6fb7c5ef54b0abd390453;hpb=7fd85fb66168f6b518c5f2d73e04036e87faa0e1;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/guicast/bcmenuitem.C b/cinelerra-5.1/guicast/bcmenuitem.C index 2c4469e4..f672e773 100644 --- a/cinelerra-5.1/guicast/bcmenuitem.C +++ b/cinelerra-5.1/guicast/bcmenuitem.C @@ -29,6 +29,7 @@ #include "bcsignals.h" #include "bcwindowbase.h" #include "bccolors.h" +#include "cstrdup.h" #include @@ -44,6 +45,8 @@ BC_MenuItem::BC_MenuItem(const char *text, const char *hotkey_text, int hotkey) { + this->text = 0; + this->hotkey_text = 0; reset(); if(text) set_text(text); @@ -58,6 +61,7 @@ BC_MenuItem::BC_MenuItem(const char *text, const char *hotkey_text, int hotkey) alt_hotkey = 0; ctrl_hotkey = 0; menu_popup = 0; + enabled = 1; } BC_MenuItem::~BC_MenuItem() @@ -74,10 +78,8 @@ BC_MenuItem::~BC_MenuItem() void BC_MenuItem::reset() { - text = new char[1]; - hotkey_text = new char[1]; - text[0] = 0; - hotkey_text[0] = 0; + set_text(""); + set_hotkey_text(""); icon = 0; } @@ -112,16 +114,14 @@ BC_Pixmap* BC_MenuItem::get_icon() void BC_MenuItem::set_text(const char *text) { - if(this->text) delete [] this->text; - this->text = new char[strlen(text) + 1]; - strcpy(this->text, text); + delete [] this->text; + this->text = cstrdup(text); } void BC_MenuItem::set_hotkey_text(const char *text) { - if(this->hotkey_text) delete [] this->hotkey_text; - this->hotkey_text = new char[strlen(text) + 1]; - strcpy(this->hotkey_text, text); + delete [] this->hotkey_text; + this->hotkey_text = cstrdup(text); } int BC_MenuItem::deactivate_submenus(BC_MenuPopup *exclude) @@ -136,6 +136,16 @@ int BC_MenuItem::deactivate_submenus(BC_MenuPopup *exclude) return 0; } +int BC_MenuItem::get_enabled(int v) +{ + return enabled; +} +void BC_MenuItem::set_enabled(int v) +{ + enabled = v; +} + + int BC_MenuItem::activate_submenu() { int new_x, new_y; @@ -151,7 +161,7 @@ int BC_MenuItem::activate_submenu() &new_y, &tempwin); submenu->popup_menu = menu_popup->popup_menu; - submenu->activate_menu(new_x + 5, new_y, menu_popup->w - 10, h, 0, 0); + submenu->activate_menu(new_x + xS(5), new_y, menu_popup->w - xS(10), h, 0, 0); highlighted = 1; } return 0; @@ -312,13 +322,13 @@ int BC_MenuItem::draw() if(!strcmp(text, "-")) { menu_popup->get_popup()->set_color(DKGREY); - menu_popup->get_popup()->draw_line(5, y + h / 2, menu_popup->get_w() - 5, y + h / 2); + menu_popup->get_popup()->draw_line(xS(5), y + h / 2, menu_popup->get_w() - xS(5), y + h / 2); menu_popup->get_popup()->set_color(LTGREY); - menu_popup->get_popup()->draw_line(5, y + h / 2 + 1, menu_popup->get_w() - 5, y + h / 2 + 1); + menu_popup->get_popup()->draw_line(xS(5), y + h / 2 + 1, menu_popup->get_w() - xS(5), y + h / 2 + 1); } else { - int offset = 0; + int xoffset = 0, yoffset = 0; if(highlighted) { int y = this->y; @@ -352,7 +362,7 @@ int BC_MenuItem::draw() resources->menu_down, resources->menu_light); } - offset = 1; + xoffset = xS(1); yoffset = yS(1); } else // Highlighted @@ -386,23 +396,23 @@ int BC_MenuItem::draw() } if(checked) { -// menu_popup->get_popup()->draw_check(10 + offset, y + 2 + offset); +// menu_popup->get_popup()->draw_check(xS(10) + xoffset, y + 2 + yoffset); menu_popup->get_popup()->draw_pixmap(menu_popup->check, - offset, - y + (this->h - menu_popup->check->get_h()) / 2 + offset); + xoffset, + y + (this->h - menu_popup->check->get_h()) / 2 + yoffset); menu_popup->get_popup()->set_font(MEDIUMFONT); - menu_popup->get_popup()->draw_text(menu_popup->check->get_w() + offset, - y + h - text_line - 2 + offset, + menu_popup->get_popup()->draw_text(menu_popup->check->get_w() + xoffset, + y + h - text_line - 2 + yoffset, text); - menu_popup->get_popup()->draw_text(menu_popup->get_key_x() + offset, - y + h - text_line - 2 + offset, + menu_popup->get_popup()->draw_text(menu_popup->get_key_x() + xoffset, + y + h - text_line - 2 + yoffset, hotkey_text); } else { menu_popup->get_popup()->set_font(MEDIUMFONT); - menu_popup->get_popup()->draw_text(10 + offset, y + h - text_line - 2 + offset, text); - menu_popup->get_popup()->draw_text(menu_popup->get_key_x() + offset, y + h - text_line - 2 + offset, hotkey_text); + menu_popup->get_popup()->draw_text(xS(10) + xoffset, y + h - text_line - 2 + yoffset, text); + menu_popup->get_popup()->draw_text(menu_popup->get_key_x() + xoffset, y + h - text_line - 2 + yoffset, hotkey_text); } } return 0;