TILE STATUS_LINE STATUSLINE_CELL STATUSLINE_CELL_WITH_STRING STATUSLINE_CELL_WITH_PICTURE PROGRESS_INDICATOR_CELL
In modern GUI applications you have one reserved line on the bottom of the application window - the status line. The idea of this line is to provide Users with a standard place for messages, hints and so on. In GRAPE we also support the status line widget . You can see two cells at the status line widget below : the progress line and picture cell:
Figure 11.1 A simple Status line with the progress indicator.
At Microsoft Word's status line you can see a set of cells. Each cell is a rectangle with text or picture. In any product you can see progress bar - the bar with a "sliding thermometer", which shows the proportion of the work done in percents. It is a useful and very easy-to-understand widget.
A Status line is not an interactive control - you cannot click on it. If you wish you can implement such functionality but the basic idea of Status line is only to show the state of the system.
As you can guess the interface of a status line is very simple: you can add new cells, remove them, change their text/pictures and so on. Look at the hierarchy related to the status line control:
TILE STATUS_LINE STATUSLINE_CELL STATUSLINE_CELL_WITH_STRING STATUSLINE_CELL_WITH_PICTURE PROGRESS_INDICATOR_CELL
You probably agree that a status line is a simple tile. So all typical tile features are supported. But in addition you can look at STATUS_LINE as a resizable array of cells. You can use features get_cell (item), put_cell, add, remove. Please do not worry about redrawing this window. It is a job for the class. All you need is only to set desired images inside the cells.
How can you access your status line? Very simple - it is an attribute of the APPLICATION class.
Each status line has two predefined cells - the hint cell and progress cell. The hint cell is added to the status line by default as the status line's item(1), the progress cell can be added by using the predefined features.
class STATUS_LINE creation make feature { ANY } make -- creation feature. Usually you have no need in it -- it is called automatically -- by SDI_APPLICATION, for details look here feature {ANY} -- Features to work with cells: add, remove e.t.a. add( the_cell : STATUSLINE_CELL ) -- add new cell to status line require not_void : the_cell /= Void; remove( the_cell : STATUSLINE_CELL ) -- remove cell from status line require not_void : the_cell /= Void; find_cell( the_cell : STATUSLINE_CELL ) : INTEGER -- return index of cell, 0 if this cell isn't in status line count : INTEGER -- get number of cells get_cell, item( the_index : INTEGER ) : STATUSLINE_CELL -- obtain cell by index require valid_index : the_index > 0 AND THEN the_index <= count() put_cell( the_cell : STATUSLINE_CELL; the_index : INTEGER) -- put cell in index as feature arr.put require valid_index : the_index > 0 AND THEN the_index <= count(); not_void : the_cell /= Void; replace_cell( the_index : INTEGER; the_new_cell : STATUSLINE_CELL) -- replace old cell by index. Works as pu_cell, -- but correctly releases old cell -- if you replace cell use this function! feature {ANY} -- features to work with hint cell set_hint ( s : STRING ) -- This feature is for setting the status line hint -- If s is Void the hint text will be cleared change_hint_cell( the_new_hint : STATUSLINE_CELL ) -- change position of hint cell feature {ANY} -- features to work with progress cell set_progerss_cell(the_cell : PROGRESS_INDICATOR_CELL) -- This function is necessary to set progress cell start_progress(s : STRING; limit : REAL) -- This feature give a simple way to indicate the "in_progress" -- (working) state of -- application. -- After calling it, status line will be set to the single bar -- with string s and percent -- mark "0%" The cursor pointer will be set to the "busy" -- (usually hourglass) shape. -- The second parameter is the maximum value for calculating the -- percentage (see -- "update_indicator") update_indicator(value : REAL) -- While your application is busy, it may show the "is done" -- state by calling this feature -- with the value inside (0 ..limit). The correct value of -- percent will be displayed. If the value exceed the limit -- the "100%" bar will be displayed. stop_progress is -- We may restore the normal status line state The cursor pointer -- will be restored to -- the previous shape. progress_limit : REAL -- return limit of progress line progress_value : REAL -- return current value of progress line hint : STATUSLINE_CELL_WITH_STRING -- return current hint cell end -- STATUS_LINE