#include "bcresources.h"
#include "bcsignals.h"
#include "bcwindowbase.h"
-#include "colors.h"
+#include "bccolors.h"
#include <string.h>
{
submenu->deactivate_submenus(exclude);
submenu->deactivate_menu();
+ submenu->popup_menu = 0;
highlighted = 0;
}
return 0;
&new_x,
&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);
highlighted = 1;
}
result = submenu->dispatch_button_press();
}
- if(!result && top_level->event_win == menu_popup->get_popup()->win)
+ if(!result && menu_popup->get_popup()->is_event_win())
{
if(top_level->cursor_x >= 0 && top_level->cursor_x < menu_popup->get_w() &&
top_level->cursor_y >= y && top_level->cursor_y < y + h)
int BC_MenuItem::dispatch_button_release(int &redraw)
{
int result = 0;
- int cursor_x, cursor_y;
- Window tempwin;
if(!strcmp(text, "-")) return 0;
result = submenu->dispatch_button_release();
}
- if(!result)
- {
- XTranslateCoordinates(top_level->display,
- top_level->event_win,
- menu_popup->get_popup()->win,
- top_level->cursor_x,
- top_level->cursor_y,
- &cursor_x,
- &cursor_y,
- &tempwin);
-
- if(cursor_x >= 0 && cursor_x < menu_popup->get_w() &&
- cursor_y >= y && cursor_y < y + h)
- {
+ if( !result && menu_popup->cursor_inside() ) {
+ int cursor_x, cursor_y;
+ menu_popup->get_popup()->get_relative_cursor(cursor_x, cursor_y);
+ if( cursor_x >= 0 && cursor_x < menu_popup->get_w() &&
+ cursor_y >= y && cursor_y < y + h ) {
if(menu_bar)
menu_bar->deactivate();
else
int BC_MenuItem::dispatch_motion_event(int &redraw)
{
int result = 0;
- int cursor_x, cursor_y;
if(submenu)
{
result = submenu->dispatch_motion_event();
}
- top_level->translate_coordinates(top_level->event_win,
- menu_popup->get_popup()->win,
- top_level->cursor_x,
- top_level->cursor_y,
- &cursor_x,
- &cursor_y);
-
- if(cursor_x >= 0 && cursor_x < menu_popup->get_w() &&
- cursor_y >= y && cursor_y < y + h)
- {
+ if( !result && menu_popup->cursor_inside() ) {
+ int cursor_x, cursor_y;
+ menu_popup->get_popup()->get_relative_cursor(cursor_x, cursor_y);
+ if( cursor_x >= 0 && cursor_x < menu_popup->get_w() &&
+ cursor_y >= y && cursor_y < y + h) {
// Highlight the item
- if(!highlighted)
- {
+ if(!highlighted)
+ {
// Deactivate submenus in the parent menu excluding this one.
- menu_popup->deactivate_submenus(submenu);
- highlighted = 1;
- if(submenu) activate_submenu();
+ menu_popup->deactivate_submenus(submenu);
+ highlighted = 1;
+ if(submenu) activate_submenu();
+ redraw = 1;
+ }
+ result = 1;
+ }
+ else
+ if(highlighted)
+ {
+ highlighted = 0;
+ result = 1;
redraw = 1;
}
- result = 1;
- }
- else
- if(highlighted)
- {
- highlighted = 0;
- result = 1;
- redraw = 1;
}
return result;
}
result = submenu->dispatch_cursor_leave();
}
- if(!result && highlighted && top_level->event_win == menu_popup->get_popup()->win)
+ if(!result && highlighted && menu_popup->get_popup()->is_event_win())
{
highlighted = 0;
return 1;
{
// menu_popup->get_popup()->draw_check(10 + offset, y + 2 + offset);
menu_popup->get_popup()->draw_pixmap(menu_popup->check,
- offset,
+ offset,
y + (this->h - menu_popup->check->get_h()) / 2 + offset);
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() + 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,
+ menu_popup->get_popup()->draw_text(menu_popup->get_key_x() + offset,
+ y + h - text_line - 2 + offset,
hotkey_text);
}
else
return 0;
}
+BC_SubMenu* BC_MenuItem::get_submenu()
+{
+ return submenu;
+}
+
char* BC_MenuItem::get_text()
{
return text;