Mercurial > hg > openttd
changeset 13819:9bacb227909a draft
(svn r18345) -Codechange: Warn the window that it gets initialized, so it can do some work ahead.
author | alberth <alberth@openttd.org> |
---|---|
date | Sun, 29 Nov 2009 21:14:34 +0000 |
parents | 3dfc2fa19752 |
children | 0e36ac197b16 |
files | src/window.cpp src/window_gui.h |
diffstat | 2 files changed, 9 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/window.cpp +++ b/src/window.cpp @@ -491,6 +491,7 @@ int window_width = this->width; int window_height = this->height; + this->OnInit(); /* Re-initialize the window from the ground up. No need to change the nested_array, as all widgets stay where they are. */ this->nested_root->SetupSmallestSize(this, false); this->nested_root->AssignSizePosition(ST_SMALLEST, 0, 0, this->nested_root->smallest_x, this->nested_root->smallest_y, _dynlang.text_dir == TD_RTL); @@ -786,7 +787,8 @@ this->window_number = window_number; this->desc_flags = desc_flags; - /* If available, initialize nested widget tree. */ + this->OnInit(); + /* Initialize nested widget tree. */ if (this->nested_array == NULL) { this->nested_array = CallocT<NWidgetBase *>(this->nested_array_size); this->nested_root->SetupSmallestSize(this, true);
--- a/src/window_gui.h +++ b/src/window_gui.h @@ -535,6 +535,12 @@ /*** Event handling ***/ /** + * Notification that the nested widget tree gets initialized. The event can be used to perform general computations. + * @note #nested_root and/or #nested_array (normally accessed via #GetWidget()) may not exist during this call. + */ + virtual void OnInit() { } + + /** * Compute the initial position of the window. * @param *desc The pointer to the WindowDesc of the window to create. * @param sm_width Smallest width of the window.