289 if (w == NULL) return; |
289 if (w == NULL) return; |
290 SetDirtyBlocks(w->left, w->top, w->left + w->width, w->top + w->height); |
290 SetDirtyBlocks(w->left, w->top, w->left + w->width, w->top + w->height); |
291 } |
291 } |
292 |
292 |
293 /** Find the Window whose parent pointer points to this window |
293 /** Find the Window whose parent pointer points to this window |
294 * @parent w Window to find child of |
294 * @param w parent Window to find child of |
295 * @return return a Window pointer that is the child of w, or NULL otherwise */ |
295 * @return a Window pointer that is the child of w, or NULL otherwise */ |
296 static Window *FindChildWindow(const Window *w) |
296 static Window *FindChildWindow(const Window *w) |
297 { |
297 { |
298 Window* const *wz; |
298 Window* const *wz; |
299 |
299 |
300 FOR_ALL_WINDOWS(wz) { |
300 FOR_ALL_WINDOWS(wz) { |
304 |
304 |
305 return NULL; |
305 return NULL; |
306 } |
306 } |
307 |
307 |
308 /** Find the z-value of a window. A window must already be open |
308 /** Find the z-value of a window. A window must already be open |
309 * or the behaviour is undefined but function should never fail */ |
309 * or the behaviour is undefined but function should never fail |
|
310 * @param w window to query Z Position |
|
311 * @return the window that matches it */ |
310 Window **FindWindowZPosition(const Window *w) |
312 Window **FindWindowZPosition(const Window *w) |
311 { |
313 { |
312 Window **wz; |
314 Window **wz; |
313 |
315 |
314 for (wz = _z_windows; wz != _last_z_window; wz++) { |
316 for (wz = _z_windows; wz != _last_z_window; wz++) { |
439 } |
441 } |
440 |
442 |
441 static void BringWindowToFront(const Window *w); |
443 static void BringWindowToFront(const Window *w); |
442 |
444 |
443 /** Find a window and make it the top-window on the screen. The window |
445 /** Find a window and make it the top-window on the screen. The window |
444 * gets a white border for a brief period of time to visualize its |
446 * gets a white border for a brief period of time to visualize its "activation" |
445 * "activation" |
447 * @param cls WindowClass of the window to activate |
|
448 * @param number WindowNumber of the window to activate |
446 * @return a pointer to the window thus activated */ |
449 * @return a pointer to the window thus activated */ |
447 Window *BringWindowToFrontById(WindowClass cls, WindowNumber number) |
450 Window *BringWindowToFrontById(WindowClass cls, WindowNumber number) |
448 { |
451 { |
449 Window *w = FindWindowById(cls, number); |
452 Window *w = FindWindowById(cls, number); |
450 |
453 |
533 bool IsWindowOfPrototype(const Window *w, const Widget *widget) |
536 bool IsWindowOfPrototype(const Window *w, const Widget *widget) |
534 { |
537 { |
535 return (w->original_widget == widget); |
538 return (w->original_widget == widget); |
536 } |
539 } |
537 |
540 |
538 /* Copies 'widget' to 'w->widget' to allow for resizable windows */ |
541 /** Copies 'widget' to 'w->widget' to allow for resizable windows |
|
542 * @param w Window on which to attach the widget array |
|
543 * @param widget pointer of widget array to fill the window with */ |
539 void AssignWidgetToWindow(Window *w, const Widget *widget) |
544 void AssignWidgetToWindow(Window *w, const Widget *widget) |
540 { |
545 { |
541 w->original_widget = widget; |
546 w->original_widget = widget; |
542 |
547 |
543 if (widget != NULL) { |
548 if (widget != NULL) { |
575 |
580 |
576 assert(_last_z_window == endof(_z_windows)); |
581 assert(_last_z_window == endof(_z_windows)); |
577 return NULL; |
582 return NULL; |
578 } |
583 } |
579 |
584 |
580 /* Open a new window. |
585 /** Open a new window. |
581 * This function is called from AllocateWindow() or AllocateWindowDesc() |
586 * This function is called from AllocateWindow() or AllocateWindowDesc() |
582 * See descriptions for those functions for usage |
587 * See descriptions for those functions for usage |
583 * See AllocateWindow() for description of arguments. |
588 * See AllocateWindow() for description of arguments. |
584 * Only addition here is window_number, which is the window_number being assigned to the new window |
589 * Only addition here is window_number, which is the window_number being assigned to the new window |
585 */ |
590 * @param x offset in pixels from the left of the screen |
|
591 * @param y offset in pixels from the top of the screen |
|
592 * @param width width in pixels of the window |
|
593 * @param height height in pixels of the window |
|
594 * @param *proc see WindowProc function to call when any messages/updates happen to the window |
|
595 * @param cls see WindowClass class of the window, used for identification and grouping |
|
596 * @param *widget see Widget pointer to the window layout and various elements |
|
597 * @param window_number number being assigned to the new window |
|
598 * @return Window pointer of the newly created window */ |
586 static Window *LocalAllocateWindow( |
599 static Window *LocalAllocateWindow( |
587 int x, int y, int width, int height, |
600 int x, int y, int width, int height, |
588 WindowProc *proc, WindowClass cls, const Widget *widget, int window_number) |
601 WindowProc *proc, WindowClass cls, const Widget *widget, int window_number) |
589 { |
602 { |
590 Window *w = FindFreeWindow(); |
603 Window *w = FindFreeWindow(); |
651 * ones. Finally set all variables and call the WE_CREATE event |
664 * ones. Finally set all variables and call the WE_CREATE event |
652 * @param x offset in pixels from the left of the screen |
665 * @param x offset in pixels from the left of the screen |
653 * @param y offset in pixels from the top of the screen |
666 * @param y offset in pixels from the top of the screen |
654 * @param width width in pixels of the window |
667 * @param width width in pixels of the window |
655 * @param height height in pixels of the window |
668 * @param height height in pixels of the window |
656 * @param *proc @see WindowProc function to call when any messages/updates happen to the window |
669 * @param *proc see WindowProc function to call when any messages/updates happen to the window |
657 * @param cls @see WindowClass class of the window, used for identification and grouping |
670 * @param cls see WindowClass class of the window, used for identification and grouping |
658 * @param *widget @see Widget pointer to the window layout and various elements |
671 * @param *widget see Widget pointer to the window layout and various elements |
659 * @return @see Window pointer of the newly created window |
672 * @return Window pointer of the newly created window */ |
660 */ |
|
661 Window *AllocateWindow( |
673 Window *AllocateWindow( |
662 int x, int y, int width, int height, |
674 int x, int y, int width, int height, |
663 WindowProc *proc, WindowClass cls, const Widget *widget) |
675 WindowProc *proc, WindowClass cls, const Widget *widget) |
664 { |
676 { |
665 return LocalAllocateWindow(x, y, width, height, proc, cls, widget, 0); |
677 return LocalAllocateWindow(x, y, width, height, proc, cls, widget, 0); |
850 } |
862 } |
851 |
863 |
852 /** |
864 /** |
853 * Open a new window. |
865 * Open a new window. |
854 * @param *desc The pointer to the WindowDesc to be created |
866 * @param *desc The pointer to the WindowDesc to be created |
855 * @return @see Window pointer of the newly created window |
867 * @return Window pointer of the newly created window |
856 */ |
868 */ |
857 Window *AllocateWindowDesc(const WindowDesc *desc) |
869 Window *AllocateWindowDesc(const WindowDesc *desc) |
858 { |
870 { |
859 return LocalAllocateWindowDesc(desc, 0); |
871 return LocalAllocateWindowDesc(desc, 0); |
860 } |
872 } |
861 |
873 |
862 /** |
874 /** |
863 * Open a new window. |
875 * Open a new window. |
864 * @param *desc The pointer to the WindowDesc to be created |
876 * @param *desc The pointer to the WindowDesc to be created |
865 * @param window_number the window number of the new window |
877 * @param window_number the window number of the new window |
866 * @return @see Window pointer of the newly created window |
878 * @return see Window pointer of the newly created window |
867 */ |
879 */ |
868 Window *AllocateWindowDescFront(const WindowDesc *desc, int window_number) |
880 Window *AllocateWindowDescFront(const WindowDesc *desc, int window_number) |
869 { |
881 { |
870 Window *w; |
882 Window *w; |
871 |
883 |
874 return w; |
886 return w; |
875 } |
887 } |
876 |
888 |
877 /** Do a search for a window at specific coordinates. For this we start |
889 /** Do a search for a window at specific coordinates. For this we start |
878 * at the topmost window, obviously and work our way down to the bottom |
890 * at the topmost window, obviously and work our way down to the bottom |
|
891 * @param x position x to query |
|
892 * @param y position y to query |
879 * @return a pointer to the found window if any, NULL otherwise */ |
893 * @return a pointer to the found window if any, NULL otherwise */ |
880 Window *FindWindowFromPt(int x, int y) |
894 Window *FindWindowFromPt(int x, int y) |
881 { |
895 { |
882 Window* const *wz; |
896 Window* const *wz; |
883 |
897 |
1480 if (bring_to_front) BringWindowToFront(w); |
1494 if (bring_to_front) BringWindowToFront(w); |
1481 return true; |
1495 return true; |
1482 } |
1496 } |
1483 |
1497 |
1484 /** Send a message from one window to another. The receiving window is found by |
1498 /** Send a message from one window to another. The receiving window is found by |
1485 * @param w see Window pointer pointing to the other window |
1499 * @param w Window pointer pointing to the other window |
1486 * @param msg Specifies the message to be sent |
1500 * @param msg Specifies the message to be sent |
1487 * @param wparam Specifies additional message-specific information |
1501 * @param wparam Specifies additional message-specific information |
1488 * @param lparam Specifies additional message-specific information |
1502 * @param lparam Specifies additional message-specific information |
1489 */ |
1503 */ |
1490 static void SendWindowMessageW(Window *w, uint msg, uint wparam, uint lparam) |
1504 static void SendWindowMessageW(Window *w, uint msg, uint wparam, uint lparam) |
1908 goto restart_search; |
1922 goto restart_search; |
1909 } |
1923 } |
1910 } |
1924 } |
1911 } |
1925 } |
1912 |
1926 |
1913 /* It is possible that a stickied window gets to a position where the |
1927 /** It is possible that a stickied window gets to a position where the |
1914 * 'close' button is outside the gaming area. You cannot close it then; except |
1928 * 'close' button is outside the gaming area. You cannot close it then; except |
1915 * with this function. It closes all windows calling the standard function, |
1929 * with this function. It closes all windows calling the standard function, |
1916 * then, does a little hacked loop of closing all stickied windows. Note |
1930 * then, does a little hacked loop of closing all stickied windows. Note |
1917 * that standard windows (status bar, etc.) are not stickied, so these aren't affected */ |
1931 * that standard windows (status bar, etc.) are not stickied, so these aren't affected */ |
1918 void DeleteAllNonVitalWindows() |
1932 void DeleteAllNonVitalWindows() |
1932 goto restart_search; |
1946 goto restart_search; |
1933 } |
1947 } |
1934 } |
1948 } |
1935 } |
1949 } |
1936 |
1950 |
1937 /* Delete all always on-top windows to get an empty screen */ |
1951 /** Delete all always on-top windows to get an empty screen */ |
1938 void HideVitalWindows() |
1952 void HideVitalWindows() |
1939 { |
1953 { |
1940 DeleteWindowById(WC_TOOLBAR_MENU, 0); |
1954 DeleteWindowById(WC_TOOLBAR_MENU, 0); |
1941 DeleteWindowById(WC_MAIN_TOOLBAR, 0); |
1955 DeleteWindowById(WC_MAIN_TOOLBAR, 0); |
1942 DeleteWindowById(WC_STATUS_BAR, 0); |
1956 DeleteWindowById(WC_STATUS_BAR, 0); |