1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-20 13:09:15 +00:00

(svn r18966) -Codechange: Remove Window::OnDoubleClick() in favour of a parameter for OnClick().

This commit is contained in:
frosch
2010-01-30 18:34:48 +00:00
parent 2f6fe85f23
commit 88019e64e1
46 changed files with 190 additions and 272 deletions

View File

@@ -480,7 +480,7 @@ struct NetworkChatWindow : public QueryStringBaseWindow {
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, this->dest_string, TC_BLACK, SA_RIGHT);
}
virtual void OnClick(Point pt, int widget)
virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
/* Send */

View File

@@ -164,7 +164,7 @@ public:
DrawStringMultiLine(r.left + 2, r.right - 2, y, y + FONT_HEIGHT_NORMAL * 2, str, TC_FROMSTRING, SA_CENTER);
}
virtual void OnClick(Point pt, int widget)
virtual void OnClick(Point pt, int widget, int click_count)
{
if (widget == NCDSWW_CANCELOK) {
if (this->downloaded_bytes != this->total_bytes) _network_content_client.Close();
@@ -583,16 +583,7 @@ public:
}
}
virtual void OnDoubleClick(Point pt, int widget)
{
/* Double clicking on a line in the matrix toggles the state of the checkbox */
if (widget != NCLWW_MATRIX) return;
pt.x = this->GetWidget<NWidgetBase>(NCLWW_CHECKBOX)->pos_x;
this->OnClick(pt, widget);
}
virtual void OnClick(Point pt, int widget)
virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case NCLWW_MATRIX: {
@@ -607,7 +598,7 @@ public:
this->list_pos = id_v;
const NWidgetBase *checkbox = this->GetWidget<NWidgetBase>(NCLWW_CHECKBOX);
if (IsInsideBS(pt.x, checkbox->pos_x, checkbox->current_x)) {
if (click_count > 1 || IsInsideBS(pt.x, checkbox->pos_x, checkbox->current_x)) {
_network_content_client.ToggleSelectedState(this->selected);
this->content.ForceResort();
}

View File

@@ -658,7 +658,7 @@ public:
}
}
virtual void OnClick(Point pt, int widget)
virtual void OnClick(Point pt, int widget, int click_count)
{
this->field = widget;
switch (widget) {
@@ -697,6 +697,9 @@ public:
this->server = (id_v < this->servers.Length()) ? this->servers[id_v] : NULL;
this->list_pos = (server == NULL) ? SLP_INVALID : id_v;
this->SetDirty();
/* FIXME the disabling should go into some InvalidateData, which is called instead of the SetDirty */
if (!this->IsWidgetDisabled(NGWW_JOIN)) this->OnClick(pt, NGWW_JOIN, 1);
} break;
case NGWW_LASTJOINED: {
@@ -713,6 +716,9 @@ public:
}
this->ScrollToSelectedServer();
this->SetDirty();
/* FIXME the disabling should go into some InvalidateData, which is called instead of the SetDirty */
if (!this->IsWidgetDisabled(NGWW_JOIN)) this->OnClick(pt, NGWW_JOIN, 1);
}
} break;
@@ -755,14 +761,6 @@ public:
}
}
virtual void OnDoubleClick(Point pt, int widget)
{
if (widget == NGWW_MATRIX || widget == NGWW_LASTJOINED) {
/* is the Join button enabled? */
if (!this->IsWidgetDisabled(NGWW_JOIN)) this->OnClick(pt, NGWW_JOIN);
}
}
virtual void OnDropdownSelect(int widget, int index)
{
switch (widget) {
@@ -1157,7 +1155,7 @@ struct NetworkStartServerWindow : public QueryStringBaseWindow {
}
}
virtual void OnClick(Point pt, int widget)
virtual void OnClick(Point pt, int widget, int click_count)
{
this->field = widget;
switch (widget) {
@@ -1621,7 +1619,7 @@ struct NetworkLobbyWindow : public Window {
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_GAME_LOBBY_PLAYERS); // players
}
virtual void OnClick(Point pt, int widget)
virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case NLWW_CANCEL: // Cancel button
@@ -1636,6 +1634,9 @@ struct NetworkLobbyWindow : public Window {
id_v += this->vscroll.GetPosition();
this->company = (id_v >= this->server->info.companies_on) ? INVALID_COMPANY : NetworkLobbyFindCompanyIndex(id_v);
this->SetDirty();
/* FIXME the disabling should go into some InvalidateData, which is called instead of the SetDirty */
if (!this->IsWidgetDisabled(NLWW_JOIN)) this->OnClick(pt, NLWW_JOIN, 1);
} break;
case NLWW_JOIN: // Join company
@@ -1660,14 +1661,6 @@ struct NetworkLobbyWindow : public Window {
}
}
virtual void OnDoubleClick(Point pt, int widget)
{
if (widget == NLWW_MATRIX) {
/* is the Join button enabled? */
if (!this->IsWidgetDisabled(NLWW_JOIN)) this->OnClick(pt, NLWW_JOIN);
}
}
virtual void OnResize()
{
this->vscroll.SetCapacityFromWidget(this, NLWW_MATRIX);
@@ -2085,7 +2078,7 @@ struct NetworkClientListWindow : Window {
}
}
virtual void OnClick(Point pt, int widget)
virtual void OnClick(Point pt, int widget, int click_count)
{
/* Show the popup with option */
if (this->selected_item != -1) {
@@ -2218,7 +2211,7 @@ struct NetworkJoinStatusWindow : Window {
size->width = width + WD_FRAMERECT_LEFT + WD_FRAMERECT_BOTTOM + 10;
}
virtual void OnClick(Point pt, int widget)
virtual void OnClick(Point pt, int widget, int click_count)
{
if (widget == NJSW_CANCELOK) { // Disconnect button
NetworkDisconnect();
@@ -2304,7 +2297,7 @@ struct NetworkCompanyPasswordWindow : public QueryStringBaseWindow {
this->DrawEditBox(NCPWW_PASSWORD);
}
virtual void OnClick(Point pt, int widget)
virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case NCPWW_OK: