window.c
changeset 1093 4fdc46eaf423
parent 1038 fb62bb1c424f
child 1095 b59632d9df1b
equal deleted inserted replaced
1092:e3b4a131db7c 1093:4fdc46eaf423
   661 
   661 
   662 	return NULL;
   662 	return NULL;
   663 }
   663 }
   664 
   664 
   665 
   665 
   666 void InitWindowSystem()
   666 void InitWindowSystem(void)
   667 {
   667 {
   668 	IConsoleClose();
   668 	IConsoleClose();
   669 	memset(&_windows, 0, sizeof(_windows));
   669 	memset(&_windows, 0, sizeof(_windows));
   670 	_last_window = _windows;
   670 	_last_window = _windows;
   671 	memset(_viewports, 0, sizeof(_viewports));
   671 	memset(_viewports, 0, sizeof(_viewports));
   672 	_active_viewports = 0;
   672 	_active_viewports = 0;
   673 }
   673 }
   674 
   674 
   675 static void DecreaseWindowCounters()
   675 static void DecreaseWindowCounters(void)
   676 {
   676 {
   677 	Window *w;
   677 	Window *w;
   678 
   678 
   679 
   679 
   680 	for(w=_last_window; w != _windows;) {
   680 	for(w=_last_window; w != _windows;) {
   696 				UnclickWindowButtons(w);
   696 				UnclickWindowButtons(w);
   697 		}
   697 		}
   698 	}
   698 	}
   699 }
   699 }
   700 
   700 
   701 Window *GetCallbackWnd()
   701 Window *GetCallbackWnd(void)
   702 {
   702 {
   703 	return FindWindowById(_thd.window_class, _thd.window_number);
   703 	return FindWindowById(_thd.window_class, _thd.window_number);
   704 }
   704 }
   705 
   705 
   706 static void HandlePlacePresize()
   706 static void HandlePlacePresize(void)
   707 {
   707 {
   708 	Window *w;
   708 	Window *w;
   709 	WindowEvent e;
   709 	WindowEvent e;
   710 
   710 
   711 	if (_special_mouse_mode != WSM_PRESIZE)
   711 	if (_special_mouse_mode != WSM_PRESIZE)
   722 	e.place.tile = TILE_FROM_XY(e.place.pt.x, e.place.pt.y);
   722 	e.place.tile = TILE_FROM_XY(e.place.pt.x, e.place.pt.y);
   723 	e.event = WE_PLACE_PRESIZE;
   723 	e.event = WE_PLACE_PRESIZE;
   724 	w->wndproc(w, &e);
   724 	w->wndproc(w, &e);
   725 }
   725 }
   726 
   726 
   727 static bool HandleDragDrop()
   727 static bool HandleDragDrop(void)
   728 {
   728 {
   729 	Window *w;
   729 	Window *w;
   730 	WindowEvent e;
   730 	WindowEvent e;
   731 
   731 
   732 	if (_special_mouse_mode != WSM_DRAGDROP)
   732 	if (_special_mouse_mode != WSM_DRAGDROP)
   748 		w->wndproc(w, &e);
   748 		w->wndproc(w, &e);
   749 	}
   749 	}
   750 	return false;
   750 	return false;
   751 }
   751 }
   752 
   752 
   753 static bool HandlePopupMenu()
   753 static bool HandlePopupMenu(void)
   754 {
   754 {
   755 	Window *w;
   755 	Window *w;
   756 	WindowEvent e;
   756 	WindowEvent e;
   757 
   757 
   758 	if (!_popup_menu_active)
   758 	if (!_popup_menu_active)
   776 	w->wndproc(w, &e);
   776 	w->wndproc(w, &e);
   777 
   777 
   778 	return false;
   778 	return false;
   779 }
   779 }
   780 
   780 
   781 bool HandleMouseOver()
   781 bool HandleMouseOver(void)
   782 {
   782 {
   783 	Window *w;
   783 	Window *w;
   784 	WindowEvent e;
   784 	WindowEvent e;
   785 	static Window *last_w = NULL;
   785 	static Window *last_w = NULL;
   786 
   786 
   809 
   809 
   810 	// Mouseover never stops execution
   810 	// Mouseover never stops execution
   811 	return true;
   811 	return true;
   812 }
   812 }
   813 
   813 
   814 bool HandleWindowDragging()
   814 bool HandleWindowDragging(void)
   815 {
   815 {
   816 	Window *w;
   816 	Window *w;
   817 	// Get out immediately if no window is being dragged at all.
   817 	// Get out immediately if no window is being dragged at all.
   818 	if (!_dragging_window)
   818 	if (!_dragging_window)
   819 		return true;
   819 		return true;
  1067 	DeleteWindowById(WC_DROPDOWN_MENU, 0);
  1067 	DeleteWindowById(WC_DROPDOWN_MENU, 0);
  1068 	return w;
  1068 	return w;
  1069 }
  1069 }
  1070 
  1070 
  1071 
  1071 
  1072 static bool HandleScrollbarScrolling()
  1072 static bool HandleScrollbarScrolling(void)
  1073 {
  1073 {
  1074 	Window *w;
  1074 	Window *w;
  1075 	int i;
  1075 	int i;
  1076 	int pos;
  1076 	int pos;
  1077 	Scrollbar *sb;
  1077 	Scrollbar *sb;
  1113 
  1113 
  1114 	_scrolling_scrollbar = false;
  1114 	_scrolling_scrollbar = false;
  1115 	return false;
  1115 	return false;
  1116 }
  1116 }
  1117 
  1117 
  1118 static bool HandleViewportScroll()
  1118 static bool HandleViewportScroll(void)
  1119 {
  1119 {
  1120 	Window *w;
  1120 	Window *w;
  1121 	ViewPort *vp;
  1121 	ViewPort *vp;
  1122 	int dx,dy, x, y, sub;
  1122 	int dx,dy, x, y, sub;
  1123 
  1123 
  1255 		if (!we.keypress.cont)
  1255 		if (!we.keypress.cont)
  1256 			break;
  1256 			break;
  1257 	}
  1257 	}
  1258 }
  1258 }
  1259 
  1259 
  1260 extern void UpdateTileSelection();
  1260 extern void UpdateTileSelection(void);
  1261 extern bool VpHandlePlaceSizingDrag();
  1261 extern bool VpHandlePlaceSizingDrag(void);
  1262 
  1262 
  1263 void MouseLoop()
  1263 void MouseLoop(void)
  1264 {
  1264 {
  1265 	int x,y;
  1265 	int x,y;
  1266 	Window *w;
  1266 	Window *w;
  1267 	ViewPort *vp;
  1267 	ViewPort *vp;
  1268 	int click;
  1268 	int click;
  1388 
  1388 
  1389 static int _we4_timer;
  1389 static int _we4_timer;
  1390 
  1390 
  1391 extern uint32 _pixels_redrawn;
  1391 extern uint32 _pixels_redrawn;
  1392 
  1392 
  1393 void UpdateWindows()
  1393 void UpdateWindows(void)
  1394 {
  1394 {
  1395 	Window *w;
  1395 	Window *w;
  1396 	int t;
  1396 	int t;
  1397 
  1397 
  1398 
  1398 
  1479 			SetWindowDirty(w);
  1479 			SetWindowDirty(w);
  1480 	}
  1480 	}
  1481 }
  1481 }
  1482 
  1482 
  1483 
  1483 
  1484 void CallWindowTickEvent()
  1484 void CallWindowTickEvent(void)
  1485 {
  1485 {
  1486 	Window *w;
  1486 	Window *w;
  1487 	for(w=_last_window; w != _windows;) {
  1487 	for(w=_last_window; w != _windows;) {
  1488 		--w;
  1488 		--w;
  1489 		CallWindowEventNP(w, WE_TICK);
  1489 		CallWindowEventNP(w, WE_TICK);
  1490 	}
  1490 	}
  1491 }
  1491 }
  1492 
  1492 
  1493 void DeleteNonVitalWindows()
  1493 void DeleteNonVitalWindows(void)
  1494 {
  1494 {
  1495 	Window *w;
  1495 	Window *w;
  1496 	for(w=_windows; w!=_last_window;) {
  1496 	for(w=_windows; w!=_last_window;) {
  1497 		if (w->window_class != WC_MAIN_WINDOW &&
  1497 		if (w->window_class != WC_MAIN_WINDOW &&
  1498 				w->window_class != WC_SELECT_GAME &&
  1498 				w->window_class != WC_SELECT_GAME &&