File: miniWindows1.0.tgz Author: Thorsten Seitz (thorsten@itap.physik.uni-stuttgart.de) Release: 1.0 (2/18/97) Compatibility: DR8 Location: contrib/libraries Description: Classes for minimizing windows into icons. Notes: the previous version (miniWindows.tgz) may be removed the ReadMe follows:----------------------------------------------------- GUI classes: ============ This package consists of the following classes which are explained below: - DFApplication : public BApplication - DFWindow : public BWindow Additionally there are some auxiliary classes such as - DFIconButton : public BPictureButton and the global function - get_icon You will find these in their respective files xxx.h and xxx.cpp. Furthermore there is the application MiniWindowDaemon. Last not least I added an adaption of Be«s HelloWorld project to show how it works. DFApplication and DFWindow -------------------------- These classes work together and give the following GUI enhancements: - the main menu is automatically extended by the following menu items: - Lower : this lowers all windows of the app behind all other windows (the app is deactivated and can be activated again by normal means (clicking in a window; selecting it in the application menu)) - Raise : this raises all windows of the app in front of all other windows. - Hide : this hides all windows of the app; selecting the app in the application menu shows them again. - Hide all others : this invokes the Hide command for all other apps which use DFApplication and DFWindow - the app quits automatically when all DFWindows are closed - DFWindows can be lowered by COMMAND-clicking anywhere on them - DFWindows can be minimized in an other way than the usual one (which minimizes them to the title tab): they can be minimized to a mini window representation +---------------+ | +-+ +-------+ | | |C| | | | | +-+ | | | | +-+ | Icon | | | |I| | | | | +-+ +-------+ | | TitleText | +---------------+ where: * 'C' is a close button, * 'Icon' is a large icon (32x32) which can be set by the window (by default it is the application icon), * 'TitleText' is a short text which can be set by the window (by default it is the window title) * 'I' is a small icon (16x16) which can be set by the window (by default it is empty): The icons and text can be changed by the running window to give status informations to the user without him having to restore the window to its normal size. The icons and text can be changed with the following functions: (The bitmaps and text are copied by the functions.) void DFWindow::SetMiniIcon(const BBitmap *bmp = NULL) // the bitmap has to defined as // BBitmap(BRect(0,0,31,31), B_COLOR_8_BIT) // the default argument NULL gives the application icon // (which is the default if SetMiniIcon is never called) void DFWindow::SetSmallMiniIcon(const BBitmap *bmp = NULL) // the bitmap has to defined as // BBitmap(BRect(0,0,15,15), B_COLOR_8_BIT) // the default argument NULL leaves the bitmap empty // (which is the default if SetSmallMiniIcon is never called) void DFWindow::SetMiniTitle(const char *titleText) // this changes the text // (if this function is never called, the text will be // the window title) To use these GUI enhancements, simply derive from DFApplication and DFWindow instead of BApplication and BWindow. That is all -- there are no other changes needed. MiniWindowDaemon ---------------- When a DFApplication is constructed, it tries to start the MiniWindowDaemon application (which is B_EXCLUSIVE_LAUNCH). If succesful or if the daemon is already running, DFWindows will automatically be minimized to mini windows when double clicked on the title tab. The MiniWindowDaemon is needed to arbitrate the positions of minimized windows so that a new mini window is not placed on top of another mini window. The mini windows are arranged at the top of the screen from left to right. You can drag them around (dragging with the secondary mouse button enforces positions on a grid) and they will remember their positions if minimized again (as long as the app is running). If the MiniWindowDaemon cannot be launched you are notified by an alert panel and are asked whether you want mini windows in spite of the missing MiniWindowDaemon. If you choose to have mini windows the only difference will be that when a window is minimized for the first time, the mini window will appear at the top left of the screen (just right to the dock). If another mini window happends to be there, the new one is simply drawn on top of it and must be manually positioned by dragging it. If the last app which uses the MiniWindowDaemon quits, the MiniWindowDaemon is automatically quitted, too. This way you will not have a zombie process on your machine :-) get_icon -------- This function searches an icon with given type/creator in the database and copies it into a bitmap (if one is given as argument). It then returns the record_id of the icon. record_id get_icon(long type, long creator, const char *bits, BBitmap *bmp = NULL) where bits = "smallBits" or "largeBits" for small or large icons, respectively. The icon of your application has type='BAPP', creator=signature. DFIconButton ------------ A simple class based on BPictureButton. Instead of giving two BPictures to the constructor, you give type/creator codes. That allows to simply draw the buttons with Icon World and store them as resources in the application. Their type will be what you typed in below the large icon in Icon World and their creator will be the signature of the app. The HelloWorld example ---------------------- I simply took Be«s HelloWorld project, replaced BApplication with DFApplication, BWindow with DFWindow, removed the HelloWindow::QuitRequested() function, added the necessary #include directives and added a second HelloWindow, so that you can see how the various menu items work and how the MiniWindowDaemon arranges mini windows. Tell me what you think about all this, please! Your opinion is very much appreciated! Have fun Thorsten Seitz --------------------------------------------------------------- thorsten@itap.physik.uni-stuttgart.de http://www.itap.physik.uni-stuttgart.de/~thorsten/Be/index.html --------------------------------------------------------------- PS: you may use and modify this code in your applications freely