|
@@ -305,57 +305,57 @@ static void DispatchLeftClickEvent(Windo
|
|
|
} else if (widget_type == WWT_EDITBOX && !focused_widget_changed) { // Only open the OSK window if clicking on an already focused edit box
|
|
|
/* Open the OSK window if clicked on an edit box */
|
|
|
QueryStringBaseWindow *qs = dynamic_cast<QueryStringBaseWindow *>(w);
|
|
|
if (qs != NULL) {
|
|
|
qs->OnOpenOSKWindow(widget_index);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/* Close any child drop down menus. If the button pressed was the drop down
|
|
|
* list's own button, then we should not process the click any further. */
|
|
|
if (HideDropDownMenu(w) == widget_index) return;
|
|
|
|
|
|
if (w->desc_flags & WDF_STD_BTN) {
|
|
|
if (widget_type == WWT_CLOSEBOX) { // 'X'
|
|
|
delete w;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (widget_type == WWT_CAPTION) { // 'Title bar'
|
|
|
StartWindowDrag(w);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (w->desc_flags & WDF_RESIZABLE && widget_type == WWT_RESIZEBOX) {
|
|
|
if ((w->desc_flags & WDF_RESIZABLE) && widget_type == WWT_RESIZEBOX) {
|
|
|
/* When the resize widget is on the left size of the window
|
|
|
* we assume that that button is used to resize to the left. */
|
|
|
StartWindowSizing(w, wi->left < (w->width / 2));
|
|
|
w->InvalidateWidget(widget_index);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (w->desc_flags & WDF_STICKY_BUTTON && widget_type == WWT_STICKYBOX) {
|
|
|
if ((w->desc_flags & WDF_STICKY_BUTTON) && widget_type == WWT_STICKYBOX) {
|
|
|
w->flags4 ^= WF_STICKY;
|
|
|
w->InvalidateWidget(widget_index);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Point pt = { x, y };
|
|
|
|
|
|
if (double_click) {
|
|
|
w->OnDoubleClick(pt, widget_index);
|
|
|
} else {
|
|
|
w->OnClick(pt, widget_index);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Dispatch right mouse-button click in window.
|
|
|
* @param w Window to dispatch event in
|
|
|
* @param x X coordinate of the click
|
|
|
* @param y Y coordinate of the click
|
|
|
*/
|
|
|
static void DispatchRightClickEvent(Window *w, int x, int y)
|
|
|
{
|
|
|
int widget = 0;
|
|
@@ -1219,49 +1219,49 @@ void UnInitWindowSystem()
|
|
|
*/
|
|
|
void ResetWindowSystem()
|
|
|
{
|
|
|
UnInitWindowSystem();
|
|
|
InitWindowSystem();
|
|
|
_thd.pos.x = 0;
|
|
|
_thd.pos.y = 0;
|
|
|
_thd.new_pos.x = 0;
|
|
|
_thd.new_pos.y = 0;
|
|
|
}
|
|
|
|
|
|
static void DecreaseWindowCounters()
|
|
|
{
|
|
|
Window *w;
|
|
|
FOR_ALL_WINDOWS_FROM_FRONT(w) {
|
|
|
/* Unclick scrollbar buttons if they are pressed. */
|
|
|
if (w->flags4 & (WF_SCROLL_DOWN | WF_SCROLL_UP)) {
|
|
|
w->flags4 &= ~(WF_SCROLL_DOWN | WF_SCROLL_UP);
|
|
|
w->SetDirty();
|
|
|
}
|
|
|
w->OnMouseLoop();
|
|
|
}
|
|
|
|
|
|
FOR_ALL_WINDOWS_FROM_FRONT(w) {
|
|
|
if (w->flags4 & WF_TIMEOUT_MASK && !(--w->flags4 & WF_TIMEOUT_MASK)) {
|
|
|
if ((w->flags4 & WF_TIMEOUT_MASK) && !(--w->flags4 & WF_TIMEOUT_MASK)) {
|
|
|
w->OnTimeout();
|
|
|
if (w->desc_flags & WDF_UNCLICK_BUTTONS) w->RaiseButtons();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Window *GetCallbackWnd()
|
|
|
{
|
|
|
return FindWindowById(_thd.window_class, _thd.window_number);
|
|
|
}
|
|
|
|
|
|
static void HandlePlacePresize()
|
|
|
{
|
|
|
if (_special_mouse_mode != WSM_PRESIZE) return;
|
|
|
|
|
|
Window *w = GetCallbackWnd();
|
|
|
if (w == NULL) return;
|
|
|
|
|
|
Point pt = GetTileBelowCursor();
|
|
|
if (pt.x == -1) {
|
|
|
_thd.selend.x = -1;
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -1530,49 +1530,49 @@ static bool HandleWindowDragging()
|
|
|
} else {
|
|
|
x = _cursor.pos.x - _drag_delta.x;
|
|
|
}
|
|
|
|
|
|
/* X and Y has to go by step.. calculate it.
|
|
|
* The cast to int is necessary else x/y are implicitly casted to
|
|
|
* unsigned int, which won't work. */
|
|
|
if (w->resize.step_width > 1) x -= x % (int)w->resize.step_width;
|
|
|
|
|
|
if (w->resize.step_height > 1) y -= y % (int)w->resize.step_height;
|
|
|
|
|
|
/* Check if we don't go below the minimum set size */
|
|
|
if ((int)w->width + x < (int)w->resize.width) {
|
|
|
x = w->resize.width - w->width;
|
|
|
}
|
|
|
if ((int)w->height + y < (int)w->resize.height) {
|
|
|
y = w->resize.height - w->height;
|
|
|
}
|
|
|
|
|
|
/* Window already on size */
|
|
|
if (x == 0 && y == 0) return false;
|
|
|
|
|
|
/* Now find the new cursor pos.. this is NOT _cursor, because we move in steps. */
|
|
|
_drag_delta.y += y;
|
|
|
if (w->flags4 & WF_SIZING_LEFT && x != 0) {
|
|
|
if ((w->flags4 & WF_SIZING_LEFT) && x != 0) {
|
|
|
_drag_delta.x -= x; // x > 0 -> window gets longer -> left-edge moves to left -> subtract x to get new position.
|
|
|
w->SetDirty();
|
|
|
w->left -= x; // If dragging left edge, move left window edge in opposite direction by the same amount.
|
|
|
/* ResizeWindow() below ensures marking new position as dirty. */
|
|
|
} else {
|
|
|
_drag_delta.x += x;
|
|
|
}
|
|
|
|
|
|
/* ResizeWindow sets both pre- and after-size to dirty for redrawal */
|
|
|
ResizeWindow(w, x, y);
|
|
|
|
|
|
Point diff;
|
|
|
diff.x = x;
|
|
|
diff.y = y;
|
|
|
w->OnResize(diff);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
_dragging_window = false;
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
/**
|