src/window.cpp
changeset 9285 235e5e2d7f55
parent 9275 15aca7aec87f
child 9293 96e818608056
equal deleted inserted replaced
9284:e2987a51f382 9285:235e5e2d7f55
    66 	WindowEvent e;
    66 	WindowEvent e;
    67 	e.event = WE_PAINT;
    67 	e.event = WE_PAINT;
    68 	this->HandleWindowEvent(&e);
    68 	this->HandleWindowEvent(&e);
    69 }
    69 }
    70 
    70 
    71 bool Window::OnKeyPress(uint16 key, uint16 keycode)
    71 Window::EventState Window::OnKeyPress(uint16 key, uint16 keycode)
    72 {
    72 {
    73 	WindowEvent e;
    73 	WindowEvent e;
    74 	e.event = WE_KEYPRESS;
    74 	e.event = WE_KEYPRESS;
    75 	e.we.keypress.key     = key;
    75 	e.we.keypress.key     = key;
    76 	e.we.keypress.keycode = keycode;
    76 	e.we.keypress.keycode = keycode;
    77 	e.we.keypress.cont    = true;
    77 	e.we.keypress.cont    = true;
    78 	this->HandleWindowEvent(&e);
    78 	this->HandleWindowEvent(&e);
    79 
    79 
    80 	return e.we.keypress.cont;
    80 	return e.we.keypress.cont ? ES_NOT_HANDLED : ES_HANDLED;
    81 }
    81 }
    82 
    82 
    83 bool Window::OnCTRLStateChange()
    83 Window::EventState Window::OnCTRLStateChange()
    84 {
    84 {
    85 	WindowEvent e;
    85 	WindowEvent e;
    86 	e.event = WE_CTRL_CHANGED;
    86 	e.event = WE_CTRL_CHANGED;
    87 	e.we.ctrl.cont = true;
    87 	e.we.ctrl.cont = true;
    88 	this->HandleWindowEvent(&e);
    88 	this->HandleWindowEvent(&e);
    89 
    89 
    90 	return e.we.ctrl.cont;
    90 	return e.we.ctrl.cont ? ES_NOT_HANDLED : ES_HANDLED;
    91 }
    91 }
    92 
    92 
    93 void Window::OnClick(Point pt, int widget)
    93 void Window::OnClick(Point pt, int widget)
    94 {
    94 {
    95 	WindowEvent e;
    95 	WindowEvent e;
  1800 				w->window_class != WC_CONSOLE &&
  1800 				w->window_class != WC_CONSOLE &&
  1801 				w->window_class != WC_SAVELOAD &&
  1801 				w->window_class != WC_SAVELOAD &&
  1802 				w->window_class != WC_COMPANY_PASSWORD_WINDOW) {
  1802 				w->window_class != WC_COMPANY_PASSWORD_WINDOW) {
  1803 			continue;
  1803 			continue;
  1804 		}
  1804 		}
  1805 		;
  1805 		if (w->OnKeyPress(key, keycode) == Window::ES_HANDLED) return;
  1806 		if (!w->OnKeyPress(key, keycode)) return;
       
  1807 	}
  1806 	}
  1808 
  1807 
  1809 	Window *w = FindWindowById(WC_MAIN_TOOLBAR, 0);
  1808 	Window *w = FindWindowById(WC_MAIN_TOOLBAR, 0);
  1810 	/* When there is no toolbar w is null, check for that */
  1809 	/* When there is no toolbar w is null, check for that */
  1811 	if (w != NULL) w->OnKeyPress(key, keycode);
  1810 	if (w != NULL) w->OnKeyPress(key, keycode);
  1817 void HandleCtrlChanged()
  1816 void HandleCtrlChanged()
  1818 {
  1817 {
  1819 	/* Call the event, start with the uppermost window. */
  1818 	/* Call the event, start with the uppermost window. */
  1820 	for (Window* const *wz = _last_z_window; wz != _z_windows;) {
  1819 	for (Window* const *wz = _last_z_window; wz != _z_windows;) {
  1821 		Window *w = *--wz;
  1820 		Window *w = *--wz;
  1822 		if (!w->OnCTRLStateChange()) break;
  1821 		if (w->OnCTRLStateChange() == Window::ES_HANDLED) return;
  1823 	}
  1822 	}
  1824 }
  1823 }
  1825 
  1824 
  1826 /**
  1825 /**
  1827  * Local counter that is incremented each time an mouse input event is detected.
  1826  * Local counter that is incremented each time an mouse input event is detected.