Project

Profile

Help

HostedRedmine.com has moved to the Planio platform. All logins and passwords remained the same. All users will be able to login and use Redmine just as before. *Read more...*

Feature #898995 ยป 0032-sdl2-Rename-pButton-as-button.patch

Marko Lindqvist, 2020-11-20 03:34 PM

View differences:

client/gui-sdl2/citydlg.c
/**********************************************************************//**
Popdown unit city orders menu.
**************************************************************************/
static int cancel_units_orders_city_dlg_callback(struct widget *pButton)
static int cancel_units_orders_city_dlg_callback(struct widget *button)
{
if (PRESSED_EVENT(main_data.event)) {
popdown_window_group_dialog(pcity_dlg->pBeginCityMenuWidgetList,
......
/**********************************************************************//**
Activate unit and del unit order dlg. widget group.
**************************************************************************/
static int activate_units_orders_city_dlg_callback(struct widget *pButton)
static int activate_units_orders_city_dlg_callback(struct widget *button)
{
if (PRESSED_EVENT(main_data.event)) {
struct unit *punit = pButton->data.unit;
struct unit *punit = button->data.unit;
popdown_city_menu_dlg(TRUE);
if (punit) {
......
/**********************************************************************//**
Activate unit and popdow city dlg. + center on unit.
**************************************************************************/
static int activate_and_exit_units_orders_city_dlg_callback(struct widget *pButton)
static int activate_and_exit_units_orders_city_dlg_callback(struct widget *button)
{
if (PRESSED_EVENT(main_data.event)) {
struct unit *punit = pButton->data.unit;
struct unit *punit = button->data.unit;
if (punit) {
popdown_window_group_dialog(pcity_dlg->pBeginCityMenuWidgetList,
......
/**********************************************************************//**
Sentry unit and del unit order dlg. widget group.
**************************************************************************/
static int sentry_units_orders_city_dlg_callback(struct widget *pButton)
static int sentry_units_orders_city_dlg_callback(struct widget *button)
{
if (PRESSED_EVENT(main_data.event)) {
struct unit *punit = pButton->data.unit;
struct unit *punit = button->data.unit;
popdown_city_menu_dlg(TRUE);
if (punit) {
......
/**********************************************************************//**
Fortify unit and del unit order dlg. widget group.
**************************************************************************/
static int fortify_units_orders_city_dlg_callback(struct widget *pButton)
static int fortify_units_orders_city_dlg_callback(struct widget *button)
{
if (PRESSED_EVENT(main_data.event)) {
struct unit *punit = pButton->data.unit;
struct unit *punit = button->data.unit;
popdown_city_menu_dlg(TRUE);
if (punit) {
......
/**********************************************************************//**
Disband unit and del unit order dlg. widget group.
**************************************************************************/
static int disband_units_orders_city_dlg_callback(struct widget *pButton)
static int disband_units_orders_city_dlg_callback(struct widget *button)
{
if (PRESSED_EVENT(main_data.event)) {
struct unit *punit = pButton->data.unit;
struct unit *punit = button->data.unit;
popdown_city_menu_dlg(TRUE);
popup_unit_disband_dlg(punit, TRUE);
......
/**********************************************************************//**
Homecity unit and del unit order dlg. widget group.
**************************************************************************/
static int homecity_units_orders_city_dlg_callback(struct widget *pButton)
static int homecity_units_orders_city_dlg_callback(struct widget *button)
{
if (PRESSED_EVENT(main_data.event)) {
struct unit *punit = pButton->data.unit;
struct unit *punit = button->data.unit;
popdown_city_menu_dlg(TRUE);
if (punit) {
......
/**********************************************************************//**
Upgrade unit and del unit order dlg. widget group.
**************************************************************************/
static int upgrade_units_orders_city_dlg_callback(struct widget *pButton)
static int upgrade_units_orders_city_dlg_callback(struct widget *button)
{
if (PRESSED_EVENT(main_data.event)) {
struct unit *punit = pButton->data.unit;
struct unit *punit = button->data.unit;
popdown_city_menu_dlg(TRUE);
popup_unit_upgrade_dlg(punit, TRUE);
......
/**********************************************************************//**
Main unit order dlg. callback.
**************************************************************************/
static int units_orders_dlg_callback(struct widget *pButton)
static int units_orders_dlg_callback(struct widget *button)
{
return -1;
}
......
/**********************************************************************//**
Popup units orders menu.
**************************************************************************/
static int units_orders_city_dlg_callback(struct widget *pButton)
static int units_orders_city_dlg_callback(struct widget *button)
{
if (PRESSED_EVENT(main_data.event)) {
utf8_str *pstr;
......
Uint16 i = 0, hh = 0;
SDL_Rect area;
punit = player_unit_by_number(client_player(), MAX_ID - pButton->ID);
punit = player_unit_by_number(client_player(), MAX_ID - button->ID);
if (!punit || !can_client_issue_orders()) {
return -1;
......
area.w = MAX(area.w, pBuf->size.w);
hh = MAX(hh, pBuf->size.h);
pBuf->action = activate_units_orders_city_dlg_callback;
pBuf->data = pButton->data;
pBuf->data = button->data;
set_wstate(pBuf, FC_WS_NORMAL);
add_to_gui_list(pButton->ID, pBuf);
add_to_gui_list(button->ID, pBuf);
/* Activate unit, close dlg. */
pBuf = create_icon_button_from_chars(NULL, pwindow->dst,
......
area.w = MAX(area.w, pBuf->size.w);
hh = MAX(hh, pBuf->size.h);
pBuf->action = activate_and_exit_units_orders_city_dlg_callback;
pBuf->data = pButton->data;
pBuf->data = button->data;
set_wstate(pBuf, FC_WS_NORMAL);
add_to_gui_list(pButton->ID, pBuf);
add_to_gui_list(button->ID, pBuf);
/* ----- */
if (pcity_dlg->page == ARMY_PAGE) {
......
i++;
area.w = MAX(area.w, pBuf->size.w);
hh = MAX(hh, pBuf->size.h);
pBuf->data = pButton->data;
pBuf->data = button->data;
pBuf->action = sentry_units_orders_city_dlg_callback;
if (punit->activity != ACTIVITY_SENTRY
&& can_unit_do_activity(punit, ACTIVITY_SENTRY)) {
set_wstate(pBuf, FC_WS_NORMAL);
}
add_to_gui_list(pButton->ID, pBuf);
add_to_gui_list(button->ID, pBuf);
/* ----- */
/* Fortify unit */
......
i++;
area.w = MAX(area.w, pBuf->size.w);
hh = MAX(hh, pBuf->size.h);
pBuf->data = pButton->data;
pBuf->data = button->data;
pBuf->action = fortify_units_orders_city_dlg_callback;
if (punit->activity != ACTIVITY_FORTIFYING
&& can_unit_do_activity(punit, ACTIVITY_FORTIFYING)) {
set_wstate(pBuf, FC_WS_NORMAL);
}
add_to_gui_list(pButton->ID, pBuf);
add_to_gui_list(button->ID, pBuf);
}
/* ----- */
......
i++;
area.w = MAX(area.w, pBuf->size.w);
hh = MAX(hh, pBuf->size.h);
pBuf->data = pButton->data;
pBuf->data = button->data;
pBuf->action = disband_units_orders_city_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
add_to_gui_list(pButton->ID, pBuf);
add_to_gui_list(button->ID, pBuf);
/* ----- */
if (pcity_dlg->page == ARMY_PAGE) {
......
i++;
area.w = MAX(area.w, pBuf->size.w);
hh = MAX(hh, pBuf->size.h);
pBuf->data = pButton->data;
pBuf->data = button->data;
pBuf->action = homecity_units_orders_city_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
add_to_gui_list(pButton->ID, pBuf);
add_to_gui_list(button->ID, pBuf);
}
/* ----- */
......
i++;
area.w = MAX(area.w, pBuf->size.w);
hh = MAX(hh, pBuf->size.h);
pBuf->data = pButton->data;
pBuf->data = button->data;
pBuf->action = upgrade_units_orders_city_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
add_to_gui_list(pButton->ID, pBuf);
add_to_gui_list(button->ID, pBuf);
}
}
......
pBuf->key = SDLK_ESCAPE;
pBuf->action = cancel_units_orders_city_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
add_to_gui_list(pButton->ID, pBuf);
add_to_gui_list(button->ID, pBuf);
pcity_dlg->pBeginCityMenuWidgetList = pBuf;
/* ================================================== */
......
area = pwindow->area;
widget_set_position(pwindow,
pButton->size.x + adj_size(2),
pwindow->area.y + pButton->size.y + 1);
button->size.x + adj_size(2),
pwindow->area.y + button->size.y + 1);
/* label */
pBuf = pwindow->prev;
......
/**********************************************************************//**
Change to present units panel.
**************************************************************************/
static int army_city_dlg_callback(struct widget *pButton)
static int army_city_dlg_callback(struct widget *button)
{
if (PRESSED_EVENT(main_data.event)) {
if (pcity_dlg->page != ARMY_PAGE) {
......
redraw_city_dialog(pcity_dlg->pCity);
flush_dirty();
} else {
widget_redraw(pButton);
widget_flush(pButton);
widget_redraw(button);
widget_flush(button);
}
}
return -1;
......
/**********************************************************************//**
Change to supported units panel.
**************************************************************************/
static int supported_unit_city_dlg_callback(struct widget *pButton)
static int supported_unit_city_dlg_callback(struct widget *button)
{
if (PRESSED_EVENT(main_data.event)) {
if (pcity_dlg->page != SUPPORTED_UNITS_PAGE) {
......
redraw_city_dialog(pcity_dlg->pCity);
flush_dirty();
} else {
widget_redraw(pButton);
widget_flush(pButton);
widget_redraw(button);
widget_flush(button);
}
}
return -1;
......
/**********************************************************************//**
Change to info panel.
**************************************************************************/
static int info_city_dlg_callback(struct widget *pButton)
static int info_city_dlg_callback(struct widget *button)
{
if (PRESSED_EVENT(main_data.event)) {
if (pcity_dlg->page != INFO_PAGE) {
......
redraw_city_dialog(pcity_dlg->pCity);
flush_dirty();
} else {
widget_redraw(pButton);
widget_flush(pButton);
widget_redraw(button);
widget_flush(button);
}
}
return -1;
......
/**********************************************************************//**
Change to happines panel.
**************************************************************************/
static int happy_city_dlg_callback(struct widget *pButton)
static int happy_city_dlg_callback(struct widget *button)
{
if (PRESSED_EVENT(main_data.event)) {
if (pcity_dlg->page != HAPPINESS_PAGE) {
......
redraw_city_dialog(pcity_dlg->pCity);
flush_dirty();
} else {
widget_redraw(pButton);
widget_flush(pButton);
widget_redraw(button);
widget_flush(button);
}
}
return -1;
......
/**********************************************************************//**
Change to city options panel.
**************************************************************************/
static int options_city_dlg_callback(struct widget *pButton)
static int options_city_dlg_callback(struct widget *button)
{
if (PRESSED_EVENT(main_data.event)) {
if (pcity_dlg->page != MISC_PAGE) {
......
redraw_city_dialog(pcity_dlg->pCity);
flush_dirty();
} else {
widget_redraw(pButton);
widget_flush(pButton);
widget_redraw(button);
widget_flush(button);
}
}
return -1;
......
/**********************************************************************//**
User interacted with Citizen Governor button.
**************************************************************************/
static int cma_city_dlg_callback(struct widget *pButton)
static int cma_city_dlg_callback(struct widget *button)
{
if (PRESSED_EVENT(main_data.event)) {
disable_city_dlg_widgets();
......
/**********************************************************************//**
Exit city dialog.
**************************************************************************/
static int exit_city_dlg_callback(struct widget *pButton)
static int exit_city_dlg_callback(struct widget *button)
{
if (PRESSED_EVENT(main_data.event)) {
popdown_city_dialog(pcity_dlg->pCity);
......
/**********************************************************************//**
Popdown buy productions dlg.
**************************************************************************/
static int cancel_buy_prod_city_dlg_callback(struct widget *pButton)
static int cancel_buy_prod_city_dlg_callback(struct widget *button)
{
if (PRESSED_EVENT(main_data.event)) {
popdown_hurry_production_dialog();
......
/**********************************************************************//**
Buy productions.
**************************************************************************/
static int ok_buy_prod_city_dlg_callback(struct widget *pButton)
static int ok_buy_prod_city_dlg_callback(struct widget *button)
{
if (PRESSED_EVENT(main_data.event)) {
struct city *pCity = pButton->data.city; /* Save it. */
struct city *pCity = button->data.city; /* Save it. */
popdown_hurry_production_dialog();
city_buy_production(pCity);
......
/**********************************************************************//**
Popup buy productions dlg.
**************************************************************************/
static int buy_prod_city_dlg_callback(struct widget *pButton)
static int buy_prod_city_dlg_callback(struct widget *button)
{
if (PRESSED_EVENT(main_data.event)) {
widget_redraw(pButton);
widget_flush(pButton);
widget_redraw(button);
widget_flush(button);
disable_city_dlg_widgets();
popup_hurry_production_dialog(pcity_dlg->pCity, pButton->dst->surface);
popup_hurry_production_dialog(pcity_dlg->pCity, button->dst->surface);
}
return -1;
}
......
/**********************************************************************//**
Popup the change production dialog.
**************************************************************************/
static int change_prod_dlg_callback(struct widget *pButton)
static int change_prod_dlg_callback(struct widget *button)
{
if (PRESSED_EVENT(main_data.event)) {
widget_redraw(pButton);
widget_flush(pButton);
widget_redraw(button);
widget_flush(button);
disable_city_dlg_widgets();
popup_worklist_editor(pcity_dlg->pCity, NULL);
......
/**********************************************************************//**
Callback for next/prev city button
**************************************************************************/
static int next_prev_city_dlg_callback(struct widget *pButton)
static int next_prev_city_dlg_callback(struct widget *button)
{
if (PRESSED_EVENT(main_data.event)) {
struct city **array;
......
}
/* dir = 1 will advance to the city, dir = -1 will get previous */
if (pButton->ID == ID_CITY_DLG_NEXT_BUTTON) {
if (button->ID == ID_CITY_DLG_NEXT_BUTTON) {
dir = 1;
} else {
if (pButton->ID == ID_CITY_DLG_PREV_BUTTON) {
if (button->ID == ID_CITY_DLG_PREV_BUTTON) {
dir = -1;
} else {
/* Always fails. */
fc_assert_ret_val(pButton->ID == ID_CITY_DLG_NEXT_BUTTON
|| pButton->ID != ID_CITY_DLG_PREV_BUTTON, -1);
fc_assert_ret_val(button->ID == ID_CITY_DLG_NEXT_BUTTON
|| button->ID != ID_CITY_DLG_PREV_BUTTON, -1);
dir = 1;
}
}
client/gui-sdl2/cma_fe.c
/**********************************************************************//**
User released mouse button while in scrollbar.
**************************************************************************/
static Uint16 scroll_mouse_button_up(SDL_MouseButtonEvent *pButtonEvent,
static Uint16 scroll_mouse_button_up(SDL_MouseButtonEvent *button_event,
void *pData)
{
return (Uint16)ID_SCROLLBAR;
......
/**********************************************************************//**
User clicked either load or delete preset widget.
**************************************************************************/
static void popup_load_del_presets_dialog(bool load, struct widget *pButton)
static void popup_load_del_presets_dialog(bool load, struct widget *button)
{
int hh, count, i;
struct widget *pBuf, *pwindow;
......
area = pwindow->area;
widget_set_position(pwindow,
pButton->size.x - (pwindow->size.w / 2),
pButton->size.y - pwindow->size.h);
button->size.x - (pwindow->size.w / 2),
button->size.y - pwindow->size.h);
/* exit button */
pBuf = pwindow->prev;
client/gui-sdl2/dialogs.c
/**********************************************************************//**
Popdown terrain information dialog.
**************************************************************************/
static int exit_terrain_info_dialog_callback(struct widget *pButton)
static int exit_terrain_info_dialog_callback(struct widget *button)
{
if (PRESSED_EVENT(main_data.event)) {
popdown_terrain_info_dialog();
......
static int nations_dialog_callback(struct widget *pwindow);
static int nation_button_callback(struct widget *pNation);
static int races_dialog_ok_callback(struct widget *pStart_Button);
static int races_dialog_cancel_callback(struct widget *pButton);
static int races_dialog_cancel_callback(struct widget *button);
static int next_name_callback(struct widget *pNext_Button);
static int prev_name_callback(struct widget *pPrev_Button);
static int change_sex_callback(struct widget *pSex);
......
/**********************************************************************//**
User cancelled nations dialog.
**************************************************************************/
static int races_dialog_cancel_callback(struct widget *pButton)
static int races_dialog_cancel_callback(struct widget *button)
{
if (PRESSED_EVENT(main_data.event)) {
popdown_races_dialog();
client/gui-sdl2/gui_main.c
/**********************************************************************//**
Main mouse click handler.
**************************************************************************/
static Uint16 main_mouse_button_down_handler(SDL_MouseButtonEvent *pButtonEvent,
static Uint16 main_mouse_button_down_handler(SDL_MouseButtonEvent *button_event,
void *pData)
{
struct widget *pwidget;
if ((pwidget = find_next_widget_at_pos(NULL,
pButtonEvent->x,
pButtonEvent->y)) != NULL) {
button_event->x,
button_event->y)) != NULL) {
if (get_wstate(pwidget) != FC_WS_DISABLED) {
return widget_pressed_action(pwidget);
}
} else {
/* no visible widget at this position -> map click */
#ifdef UNDER_CE
if (!check_scroll_area(pButtonEvent->x, pButtonEvent->y)) {
if (!check_scroll_area(button_event->x, button_event->y)) {
#endif
if (!button_behavior.counting) {
/* start counting */
button_behavior.counting = TRUE;
button_behavior.button_down_ticks = SDL_GetTicks();
*button_behavior.event = *pButtonEvent;
*button_behavior.event = *button_event;
button_behavior.hold_state = MB_HOLD_SHORT;
button_behavior.ptile = canvas_pos_to_tile(pButtonEvent->x, pButtonEvent->y);
button_behavior.ptile = canvas_pos_to_tile(button_event->x, button_event->y);
}
#ifdef UNDER_CE
}
......
/**********************************************************************//**
Main mouse button release handler.
**************************************************************************/
static Uint16 main_mouse_button_up_handler(SDL_MouseButtonEvent *pButtonEvent,
static Uint16 main_mouse_button_up_handler(SDL_MouseButtonEvent *button_event,
void *pData)
{
if (button_behavior.button_down_ticks /* button wasn't pressed over a widget */
&& !find_next_widget_at_pos(NULL, pButtonEvent->x, pButtonEvent->y)) {
*button_behavior.event = *pButtonEvent;
&& !find_next_widget_at_pos(NULL, button_event->x, button_event->y)) {
*button_behavior.event = *button_event;
button_up_on_map(&button_behavior);
}
......
Uint16 (*finger_up_handler)(SDL_TouchFingerEvent *pTouchEvent, void *pData),
Uint16 (*finger_motion_handler)(SDL_TouchFingerEvent *pTouchEvent,
void *pData),
Uint16 (*mouse_button_down_handler)(SDL_MouseButtonEvent *pButtonEvent,
Uint16 (*mouse_button_down_handler)(SDL_MouseButtonEvent *button_event,
void *pData),
Uint16 (*mouse_button_up_handler)(SDL_MouseButtonEvent *pButtonEvent,
Uint16 (*mouse_button_up_handler)(SDL_MouseButtonEvent *button_event,
void *pData),
Uint16 (*mouse_motion_handler)(SDL_MouseMotionEvent *pMotionEvent,
void *pData))
client/gui-sdl2/gui_main.h
Uint16 (*finger_up_handler)(SDL_TouchFingerEvent *pTouchEvent, void *pData),
Uint16 (*finger_motion_handler)(SDL_TouchFingerEvent *pTouchEvent,
void *pData),
Uint16 (*mouse_button_down_handler)(SDL_MouseButtonEvent *pButtonEvent,
Uint16 (*mouse_button_down_handler)(SDL_MouseButtonEvent *button_event,
void *pData),
Uint16 (*mouse_button_up_handler)(SDL_MouseButtonEvent *pButtonEvent,
Uint16 (*mouse_button_up_handler)(SDL_MouseButtonEvent *button_event,
void *pData),
Uint16 (*mouse_motion_handler)(SDL_MouseMotionEvent *pMotionEvent,
void *pData));
client/gui-sdl2/mapctrl.c
/**********************************************************************//**
User interacted with cities button.
**************************************************************************/
static int cities_action_callback(struct widget *pButton)
static int cities_action_callback(struct widget *button)
{
set_wstate(pButton, FC_WS_DISABLED);
widget_redraw(pButton);
widget_mark_dirty(pButton);
set_wstate(button, FC_WS_DISABLED);
widget_redraw(button);
widget_mark_dirty(button);
if (main_data.event.type == SDL_KEYDOWN) {
/* Ctrl-F shortcut */
popup_find_dialog();
......
/**********************************************************************//**
User interacted with Turn Done button.
**************************************************************************/
static int end_turn_callback(struct widget *pButton)
static int end_turn_callback(struct widget *button)
{
if (PRESSED_EVENT(main_data.event)) {
widget_redraw(pButton);
widget_flush(pButton);
widget_redraw(button);
widget_flush(button);
disable_focus_animation();
key_end_turn();
}
......
/**********************************************************************//**
User interacted with Revolution button.
**************************************************************************/
static int revolution_callback(struct widget *pButton)
static int revolution_callback(struct widget *button)
{
if (PRESSED_EVENT(main_data.event)) {
set_wstate(pButton, FC_WS_DISABLED);
widget_redraw(pButton);
widget_mark_dirty(pButton);
set_wstate(button, FC_WS_DISABLED);
widget_redraw(button);
widget_mark_dirty(button);
popup_government_dialog();
}
......
/**********************************************************************//**
User interacted with Research button.
**************************************************************************/
static int research_callback(struct widget *pButton)
static int research_callback(struct widget *button)
{
if (PRESSED_EVENT(main_data.event)) {
science_report_dialog_popup(TRUE);
......
/**********************************************************************//**
User interacted with Economy button.
**************************************************************************/
static int economy_callback(struct widget *pButton)
static int economy_callback(struct widget *button)
{
if (PRESSED_EVENT(main_data.event)) {
economy_report_dialog_popup(FALSE);
client/gui-sdl2/optiondlg.h
/**********************************************************************
/***********************************************************************
Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......
void enable_options_button(void);
void disable_options_button(void);
int optiondlg_callback(struct widget *pButton);
int optiondlg_callback(struct widget *button);
#endif /* FC__OPTIONDLG_H */
client/gui-sdl2/repodlgs.c
/**********************************************************************//**
User released mouse button while adjusting rates.
**************************************************************************/
static Uint16 report_scroll_mouse_button_up(SDL_MouseButtonEvent *pButtonEvent,
static Uint16 report_scroll_mouse_button_up(SDL_MouseButtonEvent *button_event,
void *pData)
{
return (Uint16)ID_SCROLLBAR;
......
/**********************************************************************//**
User interacted with Update button of the Rates.
**************************************************************************/
static int apply_taxrates_callback(struct widget *pButton)
static int apply_taxrates_callback(struct widget *button)
{
if (PRESSED_EVENT(main_data.event)) {
struct widget *pBuf;
......
}
/* Science Scrollbar */
pBuf = pButton->next->next;
pBuf = button->next->next;
science = *(int *)pBuf->data.ptr;
/* Luxuries Scrollbar */
......
dsend_packet_player_rates(&client.conn, tax, luxury, science);
}
widget_redraw(pButton);
widget_flush(pButton);
widget_redraw(button);
widget_flush(button);
}
return -1;
client/gui-sdl2/widget_button.c
/**********************************************************************//**
Create Icon Button image with text and Icon then blit to Dest(ination)
on position pIButton->size.x, pIButton->size.y.
on position icon_button->size.x, icon_button->size.y.
WARNING: pdest must exist.
Text with attributes is taken from pIButton->string_utf8 parameter.
Text with attributes is taken from icob_button->string_utf8 parameter.
Graphic for button is taken from pIButton->theme surface
Graphic for button is taken from icon_button->theme surface
and blit to new created image.
Graphic for Icon is taken from pIButton->theme2 surface and blit to new
Graphic for Icon is taken from icon_button->theme2 surface and blit to new
created image.
function return (-1) if there are no Icon nor Text.
Else return 0.
**************************************************************************/
static int redraw_ibutton(struct widget *pIButton)
static int redraw_ibutton(struct widget *icon_button)
{
SDL_Rect dest = { 0, 0, 0, 0 };
utf8_str TMPString;
SDL_Surface *pButton = NULL, *pText = NULL, *icon = pIButton->theme2;
SDL_Surface *button = NULL, *pText = NULL, *icon = icon_button->theme2;
Uint16 Ix, Iy, x;
Uint16 y = 0; /* FIXME: possibly uninitialized */
int ret;
ret = (*baseclass_redraw)(pIButton);
ret = (*baseclass_redraw)(icon_button);
if (ret != 0) {
return ret;
}
if (pIButton->string_utf8 != NULL) {
if (icon_button->string_utf8 != NULL) {
/* make copy of string_utf8 */
TMPString = *pIButton->string_utf8;
TMPString = *icon_button->string_utf8;
if (get_wstate(pIButton) == FC_WS_NORMAL) {
if (get_wstate(icon_button) == FC_WS_NORMAL) {
TMPString.fgcol = *get_theme_color(COLOR_THEME_WIDGET_NORMAL_TEXT);
} else if (get_wstate(pIButton) == FC_WS_SELECTED) {
} else if (get_wstate(icon_button) == FC_WS_SELECTED) {
TMPString.fgcol = *get_theme_color(COLOR_THEME_WIDGET_SELECTED_TEXT);
TMPString.style |= TTF_STYLE_BOLD;
} else if (get_wstate(pIButton) == FC_WS_PRESSED) {
} else if (get_wstate(icon_button) == FC_WS_PRESSED) {
TMPString.fgcol = *get_theme_color(COLOR_THEME_WIDGET_PRESSED_TEXT);
} else if (get_wstate(pIButton) == FC_WS_DISABLED) {
} else if (get_wstate(icon_button) == FC_WS_DISABLED) {
TMPString.fgcol = *get_theme_color(COLOR_THEME_WIDGET_DISABLED_TEXT);
}
......
}
/* create Button graphic */
pButton = create_bcgnd_surf(pIButton->theme, get_wstate(pIButton),
pIButton->size.w, pIButton->size.h);
button = create_bcgnd_surf(icon_button->theme, get_wstate(icon_button),
icon_button->size.w, icon_button->size.h);
clear_surface(pIButton->dst->surface, &pIButton->size);
alphablit(pButton, NULL, pIButton->dst->surface, &pIButton->size, 255);
FREESURFACE(pButton);
clear_surface(icon_button->dst->surface, &icon_button->size);
alphablit(button, NULL, icon_button->dst->surface, &icon_button->size, 255);
FREESURFACE(button);
if (icon) { /* Icon */
if (pText) {
if (get_wflags(pIButton) & WF_ICON_CENTER_RIGHT) {
Ix = pIButton->size.w - icon->w - 5;
if (get_wflags(icon_button) & WF_ICON_CENTER_RIGHT) {
Ix = icon_button->size.w - icon->w - 5;
} else {
if (get_wflags(pIButton) & WF_ICON_CENTER) {
Ix = (pIButton->size.w - icon->w) / 2;
if (get_wflags(icon_button) & WF_ICON_CENTER) {
Ix = (icon_button->size.w - icon->w) / 2;
} else {
Ix = 5;
}
}
if (get_wflags(pIButton) & WF_ICON_ABOVE_TEXT) {
if (get_wflags(icon_button) & WF_ICON_ABOVE_TEXT) {
Iy = 3;
y = 3 + icon->h + 3 + (pIButton->size.h -
y = 3 + icon->h + 3 + (icon_button->size.h -
(icon->h + 6) - pText->h) / 2;
} else {
if (get_wflags(pIButton) & WF_ICON_UNDER_TEXT) {
y = 3 + (pIButton->size.h - (icon->h + 3) - pText->h) / 2;
if (get_wflags(icon_button) & WF_ICON_UNDER_TEXT) {
y = 3 + (icon_button->size.h - (icon->h + 3) - pText->h) / 2;
Iy = y + pText->h + 3;
} else { /* center */
Iy = (pIButton->size.h - icon->h) / 2;
y = (pIButton->size.h - pText->h) / 2;
Iy = (icon_button->size.h - icon->h) / 2;
y = (icon_button->size.h - pText->h) / 2;
}
}
} else { /* no text */
Iy = (pIButton->size.h - icon->h) / 2;
Ix = (pIButton->size.w - icon->w) / 2;
Iy = (icon_button->size.h - icon->h) / 2;
Ix = (icon_button->size.w - icon->w) / 2;
}
if (get_wstate(pIButton) == FC_WS_PRESSED) {
if (get_wstate(icon_button) == FC_WS_PRESSED) {
Ix += 1;
Iy += 1;
}
dest.x = pIButton->size.x + Ix;
dest.y = pIButton->size.y + Iy;
dest.x = icon_button->size.x + Ix;
dest.y = icon_button->size.y + Iy;
ret = alphablit(icon, NULL, pIButton->dst->surface, &dest, 255);
ret = alphablit(icon, NULL, icon_button->dst->surface, &dest, 255);
if (ret) {
FREESURFACE(pText);
return ret - 10;
......
if (pText) {
if (icon) {
if (!(get_wflags(pIButton) & WF_ICON_ABOVE_TEXT)
&& !(get_wflags(pIButton) & WF_ICON_UNDER_TEXT)) {
if (get_wflags(pIButton) & WF_ICON_CENTER_RIGHT) {
if (pIButton->string_utf8->style & SF_CENTER) {
x = (pIButton->size.w - (icon->w + 5) - pText->w) / 2;
if (!(get_wflags(icon_button) & WF_ICON_ABOVE_TEXT)
&& !(get_wflags(icon_button) & WF_ICON_UNDER_TEXT)) {
if (get_wflags(icon_button) & WF_ICON_CENTER_RIGHT) {
if (icon_button->string_utf8->style & SF_CENTER) {
x = (icon_button->size.w - (icon->w + 5) - pText->w) / 2;
} else {
if (pIButton->string_utf8->style & SF_CENTER_RIGHT) {
x = pIButton->size.w - (icon->w + 7) - pText->w;
if (icon_button->string_utf8->style & SF_CENTER_RIGHT) {
x = icon_button->size.w - (icon->w + 7) - pText->w;
} else {
x = 5;
}
}
/* end WF_ICON_CENTER_RIGHT */
} else {
if (get_wflags(pIButton) & WF_ICON_CENTER) {
if (get_wflags(icon_button) & WF_ICON_CENTER) {
/* text is blit on icon */
goto Alone;
/* end WF_ICON_CENTER */
} else { /* icon center left - default */
if (pIButton->string_utf8->style & SF_CENTER) {
x = 5 + icon->w + ((pIButton->size.w -
if (icon_button->string_utf8->style & SF_CENTER) {
x = 5 + icon->w + ((icon_button->size.w -
(icon->w + 5) - pText->w) / 2);
} else {
if (pIButton->string_utf8->style & SF_CENTER_RIGHT) {
x = pIButton->size.w - pText->w - 5;
if (icon_button->string_utf8->style & SF_CENTER_RIGHT) {
x = icon_button->size.w - pText->w - 5;
} else { /* text center left */
x = 5 + icon->w + 3;
}
......
}
} else {
/* !icon */
y = (pIButton->size.h - pText->h) / 2;
y = (icon_button->size.h - pText->h) / 2;
Alone:
if (pIButton->string_utf8->style & SF_CENTER) {
x = (pIButton->size.w - pText->w) / 2;
if (icon_button->string_utf8->style & SF_CENTER) {
x = (icon_button->size.w - pText->w) / 2;
} else {
if (pIButton->string_utf8->style & SF_CENTER_RIGHT) {
x = pIButton->size.w - pText->w - 5;
if (icon_button->string_utf8->style & SF_CENTER_RIGHT) {
x = icon_button->size.w - pText->w - 5;
} else {
x = 5;
}
}
}
if (get_wstate(pIButton) == FC_WS_PRESSED) {
if (get_wstate(icon_button) == FC_WS_PRESSED) {
x += 1;
} else {
y -= 1;
}
dest.x = pIButton->size.x + x;
dest.y = pIButton->size.y + y;
dest.x = icon_button->size.x + x;
dest.y = icon_button->size.y + y;
ret = alphablit(pText, NULL, pIButton->dst->surface, &dest, 255);
ret = alphablit(pText, NULL, icon_button->dst->surface, &dest, 255);
}
FREESURFACE(pText);
......
{
SDL_Rect buf = {0, 0, 0, 0};
int w = 0, h = 0;
struct widget *pButton;
struct widget *button;
if (!icon && !pstr) {
return NULL;
}
pButton = widget_new();
button = widget_new();
pButton->theme = current_theme->Button;
pButton->theme2 = icon;
pButton->string_utf8 = pstr;
set_wflag(pButton, (WF_FREE_STRING | flags));
set_wstate(pButton, FC_WS_DISABLED);
set_wtype(pButton, WT_I_BUTTON);
pButton->mod = KMOD_NONE;
pButton->dst = pdest;
button->theme = current_theme->Button;
button->theme2 = icon;
button->string_utf8 = pstr;
set_wflag(button, (WF_FREE_STRING | flags));
set_wstate(button, FC_WS_DISABLED);
set_wtype(button, WT_I_BUTTON);
button->mod = KMOD_NONE;
button->dst = pdest;
baseclass_redraw = pButton->redraw;
pButton->redraw = redraw_ibutton;
baseclass_redraw = button->redraw;
button->redraw = redraw_ibutton;
if (pstr) {
pButton->string_utf8->style |= SF_CENTER;
button->string_utf8->style |= SF_CENTER;
/* if BOLD == true then longest wight */
if (!(pstr->style & TTF_STYLE_BOLD)) {
pstr->style |= TTF_STYLE_BOLD;
......
correct_size_bcgnd_surf(current_theme->Button, &w, &h);
pButton->size.w = w;
pButton->size.h = h;
button->size.w = w;
button->size.h = h;
return pButton;
return button;
}
/**********************************************************************//**
......
{
/* extract a single icon */
SDL_Surface *icon = create_icon_from_theme(pIcon_theme, 1);
struct widget *pButton = create_icon_button(icon, pdest, pstr, flags);
struct widget *button = create_icon_button(icon, pdest, pstr, flags);
FREESURFACE(pButton->theme2);
pButton->theme2 = pIcon_theme;
set_wtype(pButton, WT_TI_BUTTON);
FREESURFACE(button->theme2);
button->theme2 = pIcon_theme;
set_wtype(button, WT_TI_BUTTON);
pButton->redraw = redraw_tibutton;
button->redraw = redraw_tibutton;
return pButton;
return button;
}
/**********************************************************************//**
Create Button image with text and Icon. Then blit to Main.screen on
position start_x, start_y.
Text with atributes is taken from pButton->string_utf8 parameter.
Text with atributes is taken from button->string_utf8 parameter.
Graphic for button is taken from pButton->theme surface and blit to new
Graphic for button is taken from button->theme surface and blit to new
created image.
Graphic for Icon theme is taken from pButton->theme2 surface and blit to
Graphic for Icon theme is taken from button->theme2 surface and blit to
new created image.
function return (-1) if there are no Icon and Text.
Else return 0.
**************************************************************************/
int draw_tibutton(struct widget *pButton, Sint16 start_x, Sint16 start_y)
int draw_tibutton(struct widget *button, Sint16 start_x, Sint16 start_y)
{
pButton->size.x = start_x;
pButton->size.y = start_y;
button->size.x = start_x;
button->size.y = start_y;
return redraw_tibutton(pButton);
return redraw_tibutton(button);
}
/**********************************************************************//**
Create Button image with text and Icon.
Then blit to Main.screen on positon start_x , start_y.
Text with atributes is taken from pButton->string_utf8 parameter.
Text with atributes is taken from button->string_utf8 parameter.
Graphic for button is taken from pButton->theme surface
Graphic for button is taken from button->theme surface
and blit to new created image.
Graphic for Icon is taken from pButton->theme2 surface
Graphic for Icon is taken from button->theme2 surface
and blit to new created image.
function return (-1) if there are no Icon and Text.
Else return 0.
**************************************************************************/
int draw_ibutton(struct widget *pButton, Sint16 start_x, Sint16 start_y)
int draw_ibutton(struct widget *button, Sint16 start_x, Sint16 start_y)
{
pButton->size.x = start_x;
pButton->size.y = start_y;
button->size.x = start_x;
button->size.y = start_y;
return redraw_ibutton(pButton);
return redraw_ibutton(button);
}
client/gui-sdl2/widget_button.h
#define FC__WIDGET_BUTTON_H
#define create_icon_button_from_chars(icon, pdest, pCharString, iPtsize, flags) \
create_icon_button(icon, pdest, \
create_icon_button(icon, pdest, \
create_utf8_from_char(pCharString, iPtsize), \
flags)
......
struct gui_layer *pdest, utf8_str *pstr,
Uint32 flags);
int draw_tibutton(struct widget *pButton, Sint16 start_x, Sint16 start_y);
int draw_ibutton(struct widget *pButton, Sint16 start_x, Sint16 start_y);
int draw_tibutton(struct widget *button, Sint16 start_x, Sint16 start_y);
int draw_ibutton(struct widget *button, Sint16 start_x, Sint16 start_y);
#endif /* FC__WIDGET_BUTTON_H */
client/gui-sdl2/widget_edit.c
/**********************************************************************//**
Handle mouse down events on edit widget.
**************************************************************************/
static Uint16 edit_mouse_button_down(SDL_MouseButtonEvent *pButtonEvent,
static Uint16 edit_mouse_button_down(SDL_MouseButtonEvent *button_event,
void *pData)
{
struct EDIT *pEdt = (struct EDIT *)pData;
if (pButtonEvent->button == SDL_BUTTON_LEFT) {
if (!(pButtonEvent->x >= pEdt->pwidget->size.x
&& pButtonEvent->x < pEdt->pwidget->size.x + pEdt->pBg->w
&& pButtonEvent->y >= pEdt->pwidget->size.y
&& pButtonEvent->y < pEdt->pwidget->size.y + pEdt->pBg->h)) {
if (button_event->button == SDL_BUTTON_LEFT) {
if (!(button_event->x >= pEdt->pwidget->size.x
&& button_event->x < pEdt->pwidget->size.x + pEdt->pBg->w
&& button_event->y >= pEdt->pwidget->size.y
&& button_event->y < pEdt->pwidget->size.y + pEdt->pBg->h)) {
/* exit from loop */
return (Uint16)ED_MOUSE;
}
client/gui-sdl2/widget_scrollbar.c
/**********************************************************************//**
Callback for scrollbar event loops' mouse up events.
**************************************************************************/
static Uint16 scroll_mouse_button_up(SDL_MouseButtonEvent *pButtonEvent,
static Uint16 scroll_mouse_button_up(SDL_MouseButtonEvent *button_event,
void *pData)
{
return (Uint16)ID_SCROLLBAR;
client/gui-sdl2/widget_window.c
/**********************************************************************//**
Button up event handler for the window moving event loop.
**************************************************************************/
static Uint16 move_window_button_up(SDL_MouseButtonEvent *pButtonEvent,
static Uint16 move_window_button_up(SDL_MouseButtonEvent *button_event,
void *pData)
{
struct MOVE *pMove = (struct MOVE *)pData;
    (1-1/1)