The Layout Library: MWindow

Derived from: public BWindow

Declared in: <MWindow.h>


Overview

An MWindow is really just a BWindow, even the constructor is exactly the same. The only difference between an MWindow and a BWindow is that an MWindow handles the resizing of its content for you, as well as color-drops from roColour and Beatware Painter.
If you derive from MWindow and implement your own MessageReceived, remember to call inherited::MessageReceived().


Data Members

ulong flags


An MWindow will normally determine its size-limits from the limits of its first view. If you unset the M_WIN_AUTORESIZE flag, you must do a number of things yourself:

For example, to use a layoutable view in a document window with scrollbars, you would do something like:

   mwindow->AddChild(mborder);
   mwindow->flags&=(~M_WIN_AUTORESIZE);
   mborder->SetResizingMode(B_FOLLOW_ALL);
   mborder->SetFlags(bview->Flags()|B_FRAME_EVENTS);
   minimax limit=topview->layoutprefs();
   mwindow->SetSizeLimits(limit.mini.x+B_V_SCROLL_BAR_WIDTH,1E6,limit.mini.y+B_H_SCROLL_BAR_HEIGHT,1E6);
   BRect wb=mwindow->Bounds();
   mborder->ResizeTo(wb.Width()-B_V_SCROLL_BAR_WIDTH,wb.Height()-B_H_SCROLL_BAR_HEIGHT);
Note that the same technique can be used to put layoutable views in a plain BWindow, and to have multiple layoutable classes as direct descentdants of a window. You should set the window-limits before calling Show(), so the Show() can validate the current window-size against the imposed limits, and adjust the size if required.

Constructor and Destructor


MWindow()

(I might get around to explaining the constructor here, but until then, use the BeBook: the constructor for an MWindow equals that of a BWindow, and an MWindow is functionally equivalent to a BWindow (except that it knows how to resize its contents, and knows what to do when you drop a color on it from roColour or Beatware Painter).



Copyright © 1997 Marco Nelissen (marcone@xs4all.nl) All rights reserved.

Be, BeOS, BeBox, BeWare, GeekPort, the Be logo, the BeOS logo, roColour, Beatware and Beatware painter are trademarks or registered trademarks of their respective owners.