Minor changes (C style comments to C++ style).

This commit is contained in:
David Capello 2011-04-30 15:29:33 -03:00
parent 132e246ebf
commit 0227467da5
3 changed files with 68 additions and 83 deletions

View File

@ -96,10 +96,9 @@ static WidgetsList mouse_widgets_list; // List of widgets to send mouse events
static JList msg_queue; // Messages queue static JList msg_queue; // Messages queue
static JList msg_filters[NFILTERS]; // Filters for every enqueued message static JList msg_filters[NFILTERS]; // Filters for every enqueued message
static JWidget focus_widget; /* the widget with the focus */ static Widget* focus_widget; // The widget with the focus
static JWidget mouse_widget; /* the widget with the mouse */ static Widget* mouse_widget; // The widget with the mouse
static JWidget capture_widget; /* the widget that captures the static Widget* capture_widget; // The widget that captures the mouse
mouse */
static bool first_time_poll; /* true when we don't enter in poll yet */ static bool first_time_poll; /* true when we don't enter in poll yet */
@ -1429,15 +1428,15 @@ static Message* new_mouse_msg(int type, JWidget widget)
static void broadcast_key_msg(JWidget manager, Message* msg) static void broadcast_key_msg(JWidget manager, Message* msg)
{ {
/* send the message to the widget with capture */ // Send the message to the widget with capture
if (capture_widget) { if (capture_widget) {
jmessage_add_dest(msg, capture_widget); jmessage_add_dest(msg, capture_widget);
} }
/* send the msg to the focused widget */ // Send the msg to the focused widget
else if (focus_widget) { else if (focus_widget) {
jmessage_add_dest(msg, focus_widget); jmessage_add_dest(msg, focus_widget);
} }
/* finally, send the message to the manager, it'll know what to do */ // Finally, send the message to the manager, it'll know what to do
else { else {
jmessage_add_dest(msg, manager); jmessage_add_dest(msg, manager);
} }

View File

@ -492,7 +492,7 @@ bool MenuBox::onProcessMessage(Message* msg)
JLink link; JLink link;
bool used = false; bool used = false;
/* search a child with highlight or the submenu opened */ // Search a child with highlight or the submenu opened
JI_LIST_FOR_EACH(menu->children, link) { JI_LIST_FOR_EACH(menu->children, link) {
Widget* child = (Widget*)link->data; Widget* child = (Widget*)link->data;
if (child->type != JI_MENUITEM) if (child->type != JI_MENUITEM)
@ -508,22 +508,22 @@ bool MenuBox::onProcessMessage(Message* msg)
switch (msg->key.scancode) { switch (msg->key.scancode) {
case KEY_ESC: case KEY_ESC:
/* in menu-bar */ // In menu-bar
if (this->type == JI_MENUBAR) { if (this->type == JI_MENUBAR) {
if (highlight) { if (highlight) {
cancelMenuLoop(); cancelMenuLoop();
used = true; used = true;
} }
} }
/* in menu-boxes */ // In menu-boxes
else { else {
if (child_with_submenu_opened) { if (child_with_submenu_opened) {
child_with_submenu_opened->closeSubmenu(true); child_with_submenu_opened->closeSubmenu(true);
used = true; used = true;
} }
/* go to parent */ // Go to parent
else if (menu->m_menuitem) { else if (menu->m_menuitem) {
/* just retrogress one parent-level */ // Just retrogress one parent-level
menu->m_menuitem->closeSubmenu(true); menu->m_menuitem->closeSubmenu(true);
used = true; used = true;
} }
@ -531,14 +531,14 @@ bool MenuBox::onProcessMessage(Message* msg)
break; break;
case KEY_UP: case KEY_UP:
/* in menu-bar */ // In menu-bar
if (this->type == JI_MENUBAR) { if (this->type == JI_MENUBAR) {
if (child_with_submenu_opened) if (child_with_submenu_opened)
child_with_submenu_opened->closeSubmenu(true); child_with_submenu_opened->closeSubmenu(true);
} }
/* in menu-boxes */ // In menu-boxes
else { else {
/* go to previous */ // Go to previous
highlight = find_previtem(menu, highlight); highlight = find_previtem(menu, highlight);
menu->highlightItem(highlight, false, false, false); menu->highlightItem(highlight, false, false, false);
} }
@ -546,14 +546,14 @@ bool MenuBox::onProcessMessage(Message* msg)
break; break;
case KEY_DOWN: case KEY_DOWN:
/* in menu-bar */ // In menu-bar
if (this->type == JI_MENUBAR) { if (this->type == JI_MENUBAR) {
/* select the active menu */ // Select the active menu
menu->highlightItem(highlight, true, true, true); menu->highlightItem(highlight, true, true, true);
} }
/* in menu-boxes */ // In menu-boxes
else { else {
/* go to next */ // Go to next
highlight = find_nextitem(menu, highlight); highlight = find_nextitem(menu, highlight);
menu->highlightItem(highlight, false, false, false); menu->highlightItem(highlight, false, false, false);
} }
@ -561,31 +561,31 @@ bool MenuBox::onProcessMessage(Message* msg)
break; break;
case KEY_LEFT: case KEY_LEFT:
/* in menu-bar */ // In menu-bar
if (this->type == JI_MENUBAR) { if (this->type == JI_MENUBAR) {
/* go to previous */ // Go to previous
highlight = find_previtem(menu, highlight); highlight = find_previtem(menu, highlight);
menu->highlightItem(highlight, false, false, false); menu->highlightItem(highlight, false, false, false);
} }
/* in menu-boxes */ // In menu-boxes
else { else {
/* go to parent */ // Go to parent
if (menu->m_menuitem) { if (menu->m_menuitem) {
Widget* parent = menu->m_menuitem->parent->parent; Widget* parent = menu->m_menuitem->parent->parent;
/* go to the previous item in the parent */ // Go to the previous item in the parent
/* if the parent is the menu-bar */ // If the parent is the menu-bar
if (parent->type == JI_MENUBAR) { if (parent->type == JI_MENUBAR) {
menu = static_cast<MenuBar*>(parent)->getMenu(); menu = static_cast<MenuBar*>(parent)->getMenu();
MenuItem* menuitem = find_previtem(menu, menu->getHighlightedItem()); MenuItem* menuitem = find_previtem(menu, menu->getHighlightedItem());
/* go to previous item in the parent */ // Go to previous item in the parent
menu->highlightItem(menuitem, false, true, true); menu->highlightItem(menuitem, false, true, true);
} }
/* if the parent isn't the menu-bar */ // If the parent isn't the menu-bar
else { else {
/* just retrogress one parent-level */ // Just retrogress one parent-level
menu->m_menuitem->closeSubmenu(true); menu->m_menuitem->closeSubmenu(true);
} }
} }
@ -594,15 +594,15 @@ bool MenuBox::onProcessMessage(Message* msg)
break; break;
case KEY_RIGHT: case KEY_RIGHT:
/* in menu-bar */ // In menu-bar
if (this->type == JI_MENUBAR) { if (this->type == JI_MENUBAR) {
/* go to next */ // Go to next
highlight = find_nextitem(menu, highlight); highlight = find_nextitem(menu, highlight);
menu->highlightItem(highlight, false, false, false); menu->highlightItem(highlight, false, false, false);
} }
/* in menu-boxes */ // In menu-boxes
else { else {
/* enter in sub-menu */ // Enter in sub-menu
if ((highlight) && highlight->hasSubmenu()) { if ((highlight) && highlight->hasSubmenu()) {
menu->highlightItem(highlight, true, true, true); menu->highlightItem(highlight, true, true, true);
} }

View File

@ -159,9 +159,7 @@ static bool manager_msg_proc(JWidget widget, Message* msg);
static void on_palette_change_signal(); static void on_palette_change_signal();
/** // Used by set_display_switch_callback(SWITCH_IN, ...).
* Used by set_display_switch_callback(SWITCH_IN, ...).
*/
static void display_switch_in_callback() static void display_switch_in_callback()
{ {
next_idle_flags |= REFRESH_FULL_SCREEN; next_idle_flags |= REFRESH_FULL_SCREEN;
@ -179,9 +177,7 @@ static void resize_callback(RESIZE_DISPLAY_EVENT *ev)
next_idle_flags |= SYSTEM_WINDOW_RESIZE; next_idle_flags |= SYSTEM_WINDOW_RESIZE;
} }
/** // Initializes GUI.
* Initializes GUI.
*/
int init_module_gui() int init_module_gui()
{ {
int min_possible_dsk_res = 0; int min_possible_dsk_res = 0;
@ -192,38 +188,38 @@ int init_module_gui()
monitors = new MonitorList; monitors = new MonitorList;
shortcuts = new std::vector<Shortcut*>; shortcuts = new std::vector<Shortcut*>;
/* install the mouse */ // Install the mouse
if (install_mouse() < 0) if (install_mouse() < 0)
throw base::Exception("Error installing mouse handler"); throw base::Exception("Error installing mouse handler");
/* install the keyboard */ // Install the keyboard
if (install_keyboard() < 0) if (install_keyboard() < 0)
throw base::Exception("Error installing keyboard handler"); throw base::Exception("Error installing keyboard handler");
/* disable Ctrl+Shift+End in non-DOS */ // Disable Ctrl+Shift+End in non-DOS
#if !defined(ALLEGRO_DOS) #if !defined(ALLEGRO_DOS)
three_finger_flag = false; three_finger_flag = false;
#endif #endif
three_finger_flag = true; /* TODO remove this line */ three_finger_flag = true; // TODO remove this line
/* set the graphics mode... */ // Set the graphics mode...
load_gui_config(w, h, bpp, fullscreen, maximized); load_gui_config(w, h, bpp, fullscreen, maximized);
autodetect = fullscreen ? GFX_AUTODETECT_FULLSCREEN: autodetect = fullscreen ? GFX_AUTODETECT_FULLSCREEN:
GFX_AUTODETECT_WINDOWED; GFX_AUTODETECT_WINDOWED;
/* default resolution */ // Default resolution
if (!w || !h) { if (!w || !h) {
bool has_desktop = false; bool has_desktop = false;
int dsk_w, dsk_h; int dsk_w, dsk_h;
has_desktop = get_desktop_resolution(&dsk_w, &dsk_h) == 0; has_desktop = get_desktop_resolution(&dsk_w, &dsk_h) == 0;
/* we must extract some space for the windows borders */ // We must extract some space for the windows borders
dsk_w -= 16; dsk_w -= 16;
dsk_h -= 32; dsk_h -= 32;
/* try to get desktop resolution */ // Try to get desktop resolution
if (has_desktop) { if (has_desktop) {
for (c=0; try_resolutions[c].width; ++c) { for (c=0; try_resolutions[c].width; ++c) {
if (try_resolutions[c].width <= dsk_w && if (try_resolutions[c].width <= dsk_w &&
@ -237,7 +233,7 @@ int init_module_gui()
} }
} }
} }
/* full screen */ // Full screen
else { else {
fullscreen = true; fullscreen = true;
w = 320; w = 320;
@ -246,7 +242,7 @@ int init_module_gui()
} }
} }
/* default color depth */ // Default color depth
if (!bpp) { if (!bpp) {
bpp = desktop_color_depth(); bpp = desktop_color_depth();
if (!bpp) if (!bpp)
@ -285,7 +281,7 @@ int init_module_gui()
gfx_done:; gfx_done:;
/* create the default-manager */ // Create the default-manager
manager = jmanager_new(); manager = jmanager_new();
jwidget_add_hook(manager, JI_WIDGET, manager_msg_proc, NULL); jwidget_add_hook(manager, JI_WIDGET, manager_msg_proc, NULL);
@ -301,16 +297,16 @@ gfx_done:;
} }
#endif #endif
/* configure ji_screen */ // Configure ji_screen
gui_setup_screen(true); gui_setup_screen(true);
/* add a hook to display-switch so when the user returns to the // Add a hook to display-switch so when the user returns to the
screen it's completelly refreshed/redrawn */ // screen it's completelly refreshed/redrawn.
LOCK_VARIABLE(next_idle_flags); LOCK_VARIABLE(next_idle_flags);
LOCK_FUNCTION(display_switch_in_callback); LOCK_FUNCTION(display_switch_in_callback);
set_display_switch_callback(SWITCH_IN, display_switch_in_callback); set_display_switch_callback(SWITCH_IN, display_switch_in_callback);
/* set graphics options for next time */ // Set graphics options for next time
save_gui_config(); save_gui_config();
// Hook for palette change to regenerate the theme // Hook for palette change to regenerate the theme
@ -470,7 +466,7 @@ void gui_feedback()
jmanager_refresh_screen(); jmanager_refresh_screen();
} }
/* menu stuff */ // Menu stuff
if (next_idle_flags & REBUILD_RECENT_LIST) { if (next_idle_flags & REBUILD_RECENT_LIST) {
if (app_realloc_recent_list()) if (app_realloc_recent_list())
next_idle_flags ^= REBUILD_RECENT_LIST; next_idle_flags ^= REBUILD_RECENT_LIST;
@ -529,12 +525,8 @@ void gui_flip_screen()
lastWorkingGfxMode.updateWithCurrentMode(); lastWorkingGfxMode.updateWithCurrentMode();
} }
/** // Sets the ji_screen variable. This routine should be called
* Sets the ji_screen variable. // everytime you changes the graphics mode.
*
* This routine should be called everytime you changes the graphics
* mode.
*/
void gui_setup_screen(bool reload_font) void gui_setup_screen(bool reload_font)
{ {
bool regen = false; bool regen = false;
@ -672,8 +664,8 @@ void schedule_rebuild_recent_list()
next_idle_flags |= REBUILD_RECENT_LIST; next_idle_flags |= REBUILD_RECENT_LIST;
} }
/**********************************************************************/ //////////////////////////////////////////////////////////////////////
/* hook signals */ // Hook signals
typedef struct HookData { typedef struct HookData {
int signal_num; int signal_num;
@ -712,9 +704,7 @@ static bool hook_msg_proc(JWidget widget, Message* msg)
return false; return false;
} }
/** // @warning You can't use this function for the same widget two times.
* @warning You can't use this function for the same widget two times.
*/
void hook_signal(JWidget widget, void hook_signal(JWidget widget,
int signal_num, int signal_num,
bool (*signal_handler)(JWidget widget, void* data), bool (*signal_handler)(JWidget widget, void* data),
@ -814,9 +804,9 @@ void set_gfxicon_to_button(ButtonBase* button,
button->setIconInterface(buttonIcon); button->setIconInterface(buttonIcon);
} }
/**********************************************************************/ //////////////////////////////////////////////////////////////////////
/* Button style (convert radio or check buttons and draw it like // Button style (convert radio or check buttons and draw it like
normal buttons) */ // normal buttons)
RadioButton* radio_button_new(int radio_group, int b1, int b2, int b3, int b4) RadioButton* radio_button_new(int radio_group, int b1, int b2, int b3, int b4)
{ {
@ -1035,11 +1025,9 @@ static Shortcut* get_keyboard_shortcut_for_quicktool(tools::Tool* tool)
return NULL; return NULL;
} }
/** // Adds a routine to be called each 100 milliseconds to monitor
* Adds a routine to be called each 100 milliseconds to monitor // whatever you want. It's mainly used to monitor the progress of a
* whatever you want. It's mainly used to monitor the progress of a // file-operation (see @ref fop_operate)
* file-operation (see @ref fop_operate)
*/
Monitor* add_gui_monitor(void (*proc)(void *), Monitor* add_gui_monitor(void (*proc)(void *),
void (*free)(void *), void *data) void (*free)(void *), void *data)
{ {
@ -1055,9 +1043,7 @@ Monitor* add_gui_monitor(void (*proc)(void *),
return monitor; return monitor;
} }
/** // Removes and frees a previously added monitor.
* Removes and frees a previously added monitor.
*/
void remove_gui_monitor(Monitor* monitor) void remove_gui_monitor(Monitor* monitor)
{ {
MonitorList::iterator it = MonitorList::iterator it =
@ -1088,7 +1074,7 @@ static bool manager_msg_proc(JWidget widget, Message* msg)
case JM_QUEUEPROCESSING: case JM_QUEUEPROCESSING:
gui_feedback(); gui_feedback();
/* open dropped files */ // Open dropped files
check_for_dropped_files(); check_for_dropped_files();
break; break;
@ -1185,26 +1171,26 @@ static bool manager_msg_proc(JWidget widget, Message* msg)
case Shortcut_ExecuteCommand: { case Shortcut_ExecuteCommand: {
Command* command = shortcut->command; Command* command = shortcut->command;
// the screen shot is available in everywhere // The screen shot is available in everywhere
if (strcmp(command->short_name(), CommandId::ScreenShot) == 0) { if (strcmp(command->short_name(), CommandId::ScreenShot) == 0) {
UIContext::instance()->executeCommand(command, shortcut->params); UIContext::instance()->executeCommand(command, shortcut->params);
return true; return true;
} }
// all other keys are only available in the main-window // All other keys are only available in the main-window
else { else {
JLink link; JLink link;
JI_LIST_FOR_EACH(widget->children, link) { JI_LIST_FOR_EACH(widget->children, link) {
Frame* child = reinterpret_cast<Frame*>(link->data); Frame* child = reinterpret_cast<Frame*>(link->data);
/* there are a foreground window executing? */ // There are a foreground window executing?
if (child->is_foreground()) { if (child->is_foreground()) {
break; break;
} }
/* is it the desktop and the top-window= */ // Is it the desktop and the top-window=
else if (child->is_desktop() && child == app_get_top_window()) { else if (child->is_desktop() && child == app_get_top_window()) {
/* ok, so we can execute the command represented by the // OK, so we can execute the command represented
pressed-key in the message... */ // by the pressed-key in the message...
UIContext::instance()->executeCommand(command, shortcut->params); UIContext::instance()->executeCommand(command, shortcut->params);
return true; return true;
} }