comparison src/newgrf_gui.cpp @ 17486:e7672bafbe1c draft

(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
author frosch <frosch@openttd.org>
date Sun, 13 Mar 2011 21:31:29 +0000
parents 5a60038ce980
children 105b4e4eb168
comparison
equal deleted inserted replaced
17485:1836bc0ca8eb 17486:e7672bafbe1c
377 NWidgetCore *nwi = this->GetWidget<NWidgetCore>(GRFPAR_WIDGET_BACKGROUND); 377 NWidgetCore *nwi = this->GetWidget<NWidgetCore>(GRFPAR_WIDGET_BACKGROUND);
378 this->vscroll->SetCapacity(nwi->current_y / this->line_height); 378 this->vscroll->SetCapacity(nwi->current_y / this->line_height);
379 nwi->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); 379 nwi->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
380 } 380 }
381 381
382 virtual void OnInvalidateData(int data) 382 /**
383 { 383 * Some data on this window has become invalid.
384 * @param data Information about the changed data.
385 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
386 */
387 virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
388 {
389 if (!gui_scope) return;
384 if (!this->action14present) { 390 if (!this->action14present) {
385 this->SetWidgetDisabledState(GRFPAR_WIDGET_NUMPAR_DEC, this->grf_config->num_params == 0); 391 this->SetWidgetDisabledState(GRFPAR_WIDGET_NUMPAR_DEC, this->grf_config->num_params == 0);
386 this->SetWidgetDisabledState(GRFPAR_WIDGET_NUMPAR_INC, this->grf_config->num_params >= this->grf_config->num_valid_params); 392 this->SetWidgetDisabledState(GRFPAR_WIDGET_NUMPAR_INC, this->grf_config->num_params >= this->grf_config->num_valid_params);
387 } 393 }
388 394
1023 1029
1024 this->InvalidateData(); 1030 this->InvalidateData();
1025 } 1031 }
1026 1032
1027 /** 1033 /**
1028 * Calback to update internal data. 1034 * Some data on this window has become invalid.
1035 * @param data Information about the changed data.
1029 * - 0: (optionally) build availables, update button status. 1036 * - 0: (optionally) build availables, update button status.
1030 * - 1: build availables, Add newly found grfs, update button status. 1037 * - 1: build availables, Add newly found grfs, update button status.
1031 * - 2: (optionally) build availables, Reset preset, + 3 1038 * - 2: (optionally) build availables, Reset preset, + 3
1032 * - 3: (optionally) build availables, Update active scrollbar, update button status. 1039 * - 3: (optionally) build availables, Update active scrollbar, update button status.
1033 * - 4: Force a rebuild of the availables, + 2 1040 * - 4: Force a rebuild of the availables, + 2
1041 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
1034 */ 1042 */
1035 virtual void OnInvalidateData(int data = 0) 1043 virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
1036 { 1044 {
1045 if (!gui_scope) return;
1037 switch (data) { 1046 switch (data) {
1038 default: NOT_REACHED(); 1047 default: NOT_REACHED();
1039 case 0: 1048 case 0:
1040 /* Nothing important to do */ 1049 /* Nothing important to do */
1041 break; 1050 break;