window.c
changeset 2596 07cecb439908
parent 2549 5587f9a38563
child 2630 7206058a7e82
equal deleted inserted replaced
2595:1c5db200577c 2596:07cecb439908
    21 	w->click_state |= (1 << widget);
    21 	w->click_state |= (1 << widget);
    22 	w->flags4 |= 5 << WF_TIMEOUT_SHL;
    22 	w->flags4 |= 5 << WF_TIMEOUT_SHL;
    23 	InvalidateWidget(w, widget);
    23 	InvalidateWidget(w, widget);
    24 }
    24 }
    25 
    25 
    26 void DispatchLeftClickEvent(Window *w, int x, int y) {
    26 static void DispatchLeftClickEvent(Window* w, int x, int y)
       
    27 {
    27 	WindowEvent e;
    28 	WindowEvent e;
    28 	const Widget *wi;
    29 	const Widget *wi;
    29 
    30 
    30 	e.click.pt.x = x;
    31 	e.click.pt.x = x;
    31 	e.click.pt.y = y;
    32 	e.click.pt.y = y;
    81 	}
    82 	}
    82 
    83 
    83 	w->wndproc(w, &e);
    84 	w->wndproc(w, &e);
    84 }
    85 }
    85 
    86 
    86 void DispatchRightClickEvent(Window *w, int x, int y) {
    87 static void DispatchRightClickEvent(Window* w, int x, int y)
       
    88 {
    87 	WindowEvent e;
    89 	WindowEvent e;
    88 
    90 
    89 	/* default tooltips handler? */
    91 	/* default tooltips handler? */
    90 	if (w->desc_flags & WDF_STD_TOOLTIPS) {
    92 	if (w->desc_flags & WDF_STD_TOOLTIPS) {
    91 		e.click.widget = GetWidgetFromPos(w, x, y);
    93 		e.click.widget = GetWidgetFromPos(w, x, y);
   108  * compatible scrollbars if the mouse is pointed over the bar or its contents
   110  * compatible scrollbars if the mouse is pointed over the bar or its contents
   109  * @param *w Window
   111  * @param *w Window
   110  * @param widget the widget where the scrollwheel was used
   112  * @param widget the widget where the scrollwheel was used
   111  * @param wheel scroll up or down
   113  * @param wheel scroll up or down
   112  */
   114  */
   113 void DispatchMouseWheelEvent(Window *w, int widget, int wheel)
   115 static void DispatchMouseWheelEvent(Window* w, int widget, int wheel)
   114 {
   116 {
   115 	const Widget *wi1, *wi2;
   117 	const Widget *wi1, *wi2;
   116 	Scrollbar *sb;
   118 	Scrollbar *sb;
   117 
   119 
   118 	if (widget < 0) return;
   120 	if (widget < 0) return;
   371 		if (w->window_class != WC_MAIN_WINDOW && !IsVitalWindow(w))
   373 		if (w->window_class != WC_MAIN_WINDOW && !IsVitalWindow(w))
   372 				return w;
   374 				return w;
   373 	}
   375 	}
   374 }
   376 }
   375 
   377 
   376 bool IsWindowOfPrototype(Window *w, const Widget *widget)
   378 bool IsWindowOfPrototype(const Window* w, const Widget* widget)
   377 {
   379 {
   378 	return (w->original_widget == widget);
   380 	return (w->original_widget == widget);
   379 }
   381 }
   380 
   382 
   381 /* Copies 'widget' to 'w->widget' to allow for resizable windows */
   383 /* Copies 'widget' to 'w->widget' to allow for resizable windows */
   869 	}
   871 	}
   870 
   872 
   871 	// Mouseover never stops execution
   873 	// Mouseover never stops execution
   872 	return true;
   874 	return true;
   873 }
   875 }
       
   876 
       
   877 
       
   878 static bool _dragging_window;
   874 
   879 
   875 static bool HandleWindowDragging(void)
   880 static bool HandleWindowDragging(void)
   876 {
   881 {
   877 	Window *w;
   882 	Window *w;
   878 	// Get out immediately if no window is being dragged at all.
   883 	// Get out immediately if no window is being dragged at all.
  1289  * @param w @see Window pointer pointing to the other window
  1294  * @param w @see Window pointer pointing to the other window
  1290  * @param msg Specifies the message to be sent
  1295  * @param msg Specifies the message to be sent
  1291  * @param wparam Specifies additional message-specific information
  1296  * @param wparam Specifies additional message-specific information
  1292  * @param lparam Specifies additional message-specific information
  1297  * @param lparam Specifies additional message-specific information
  1293  */
  1298  */
  1294 void SendWindowMessageW(Window *w, uint msg, uint wparam, uint lparam)
  1299 static void SendWindowMessageW(Window* w, uint msg, uint wparam, uint lparam)
  1295 {
  1300 {
  1296 	WindowEvent e;
  1301 	WindowEvent e;
  1297 
  1302 
  1298 	e.message.event  = WE_MESSAGE;
  1303 	e.message.event  = WE_MESSAGE;
  1299 	e.message.msg    = msg;
  1304 	e.message.msg    = msg;
  1555 		if (w->window_class==cls && w->window_number==number)
  1560 		if (w->window_class==cls && w->window_number==number)
  1556 			SetWindowDirty(w);
  1561 			SetWindowDirty(w);
  1557 	}
  1562 	}
  1558 }
  1563 }
  1559 
  1564 
  1560 void InvalidateWidget(Window *w, byte widget_index)
  1565 void InvalidateWidget(const Window* w, byte widget_index)
  1561 {
  1566 {
  1562 	const Widget *wi = &w->widget[widget_index];
  1567 	const Widget *wi = &w->widget[widget_index];
  1563 
  1568 
  1564 	/* Don't redraw the window if the widget is invisible or of no-type */
  1569 	/* Don't redraw the window if the widget is invisible or of no-type */
  1565 	if (wi->type == WWT_EMPTY || HASBIT(w->hidden_state, widget_index)) return;
  1570 	if (wi->type == WWT_EMPTY || HASBIT(w->hidden_state, widget_index)) return;