src/window.cpp
branchcustombridgeheads
changeset 5650 aefc131bf5ce
parent 5649 55c8267c933f
equal deleted inserted replaced
5649:55c8267c933f 5650:aefc131bf5ce
    12 #include "viewport.h"
    12 #include "viewport.h"
    13 #include "console.h"
    13 #include "console.h"
    14 #include "variables.h"
    14 #include "variables.h"
    15 #include "table/sprites.h"
    15 #include "table/sprites.h"
    16 #include "genworld.h"
    16 #include "genworld.h"
       
    17 #include "helpers.hpp"
    17 
    18 
    18 // delta between mouse cursor and upper left corner of dragged window
    19 // delta between mouse cursor and upper left corner of dragged window
    19 static Point _drag_delta;
    20 static Point _drag_delta;
    20 
    21 
    21 static Window _windows[25];
    22 static Window _windows[25];
   310 
   311 
   311 	for (wz = _z_windows; wz != _last_z_window; wz++) {
   312 	for (wz = _z_windows; wz != _last_z_window; wz++) {
   312 		if (*wz == w) return wz;
   313 		if (*wz == w) return wz;
   313 	}
   314 	}
   314 
   315 
   315 	DEBUG(misc, 3, "Window (class %d, number %d) is not open, probably removed by recursive calls",
   316 	DEBUG(misc, 3, "Window (cls %d, number %d) is not open, probably removed by recursive calls",
   316 		w->window_class, w->window_number);
   317 		w->window_class, w->window_number);
   317 	return NULL;
   318 	return NULL;
   318 }
   319 }
   319 
   320 
   320 void DeleteWindow(Window *w)
   321 void DeleteWindow(Window *w)
   541 		uint index = 1;
   542 		uint index = 1;
   542 		const Widget *wi;
   543 		const Widget *wi;
   543 
   544 
   544 		for (wi = widget; wi->type != WWT_LAST; wi++) index++;
   545 		for (wi = widget; wi->type != WWT_LAST; wi++) index++;
   545 
   546 
   546 		w->widget = realloc(w->widget, sizeof(*w->widget) * index);
   547 		ReallocT(&w->widget, index);
   547 		memcpy(w->widget, widget, sizeof(*w->widget) * index);
   548 		memcpy(w->widget, widget, sizeof(*w->widget) * index);
   548 		w->widget_count = index - 1;
   549 		w->widget_count = index - 1;
   549 	} else {
   550 	} else {
   550 		w->widget = NULL;
   551 		w->widget = NULL;
   551 		w->widget_count = 0;
   552 		w->widget_count = 0;
  1486  * @param wnd_num @see WindowNumber number, mostly 0
  1487  * @param wnd_num @see WindowNumber number, mostly 0
  1487  * @param msg Specifies the message to be sent
  1488  * @param msg Specifies the message to be sent
  1488  * @param wparam Specifies additional message-specific information
  1489  * @param wparam Specifies additional message-specific information
  1489  * @param lparam Specifies additional message-specific information
  1490  * @param lparam Specifies additional message-specific information
  1490  */
  1491  */
  1491 void SendWindowMessage(WindowClass wnd_class, WindowNumber wnd_num, uint msg, uint wparam, uint lparam)
  1492 void SendWindowMessage(WindowClass wnd_class, WindowNumber wnd_num, int msg, int wparam, int lparam)
  1492 {
  1493 {
  1493 	Window *w = FindWindowById(wnd_class, wnd_num);
  1494 	Window *w = FindWindowById(wnd_class, wnd_num);
  1494 	if (w != NULL) SendWindowMessageW(w, msg, wparam, lparam);
  1495 	if (w != NULL) SendWindowMessageW(w, msg, wparam, lparam);
  1495 }
  1496 }
  1496 
  1497 
  1499  * @param wnd_class @see WindowClass class
  1500  * @param wnd_class @see WindowClass class
  1500  * @param msg Specifies the message to be sent
  1501  * @param msg Specifies the message to be sent
  1501  * @param wparam Specifies additional message-specific information
  1502  * @param wparam Specifies additional message-specific information
  1502  * @param lparam Specifies additional message-specific information
  1503  * @param lparam Specifies additional message-specific information
  1503  */
  1504  */
  1504 void SendWindowMessageClass(WindowClass wnd_class, uint msg, uint wparam, uint lparam)
  1505 void SendWindowMessageClass(WindowClass wnd_class, int msg, int wparam, int lparam)
  1505 {
  1506 {
  1506 	Window* const *wz;
  1507 	Window* const *wz;
  1507 
  1508 
  1508 	FOR_ALL_WINDOWS(wz) {
  1509 	FOR_ALL_WINDOWS(wz) {
  1509 		if ((*wz)->window_class == wnd_class) SendWindowMessageW(*wz, msg, wparam, lparam);
  1510 		if ((*wz)->window_class == wnd_class) SendWindowMessageW(*wz, msg, wparam, lparam);