home *** CD-ROM | disk | FTP | other *** search
- /*** treewindow.c ***/
- /* A (shared) window containing a tree
- * The tree is drawn from the lines in line_store
- * (c) Paul Field 1995
- * v1.00 - 22/11/1995
- * v1.01 - 23/11/1995 : Saves tree as Draw file
- */
-
- #include "treewindow.h"
-
- #include <assert.h>
- #include "toolbox.h"
- #include "wimp.h"
- #include "window.h"
-
- #include "exception.h"
- #include "nev_wimp.h"
- #include "saver.h"
-
- #include "diagram_save.h"
- #include "line_plotter.h"
- #include "line_storer.h"
-
-
- /* The handle of the tree window */
-
- static toolbox_o tree_window_id;
-
-
- static nevent_result tree_window_redraw(wimp_event_no event_code, wimp_block *event, toolbox_block *id_block, void *handle)
- { assert(event_code == wimp_REDRAW_WINDOW_REQUEST);
- NOT_USED(event_code);
- NOT_USED(handle);
-
- try
- { wimp_window_state state;
- bool more;
- wimp_draw block;
- int origin_x;
- int origin_y;
-
- /* Calculate where the work area origin is on screen (or off screen) */
- state.w = event->redraw.w;
- wimp_get_window_state(&state);
-
- origin_x = state.visible.x0 - state.xscroll;
- origin_y = state.visible.y1 - state.yscroll;
- line_plotter_origin(origin_x, origin_y);
-
- /* Repeatedly ask the Wimp for an area of window to redraw and then plot the sprite */
- block.w = event->redraw.w;
- more = wimp_redraw_window(&block);
- while (more)
- { line_storer_process_lines(&line_plotter);
- more = wimp_get_rectangle(&block);
- }
- }
- catch
- { /* If there's an error during redraw then we could run into an infinite loop
- * if the error report window covers up the window and so causes another redraw and another error.
- * To avoid this happening, we hide the window
- */
- toolbox_hide_object(0, id_block->this_obj);
- throw();
- }
- catch_end
-
- return nevent_HANDLED;
- }
-
-
-
-
- static void tree_window_save(toolbox_o save_as_id)
- { NOT_USED(save_as_id);
-
- diagram_save();
- }
-
-
-
-
- void tree_window_initialise(void)
- { tree_window_id = toolbox_create_object(0, (toolbox_id)"TreeWindow");
- nevent_wimp_register_handler(tree_window_id, wimp_REDRAW_WINDOW_REQUEST, tree_window_redraw, NULL);
-
- saver_create(toolbox_create_object(0, (toolbox_id)"SaveTree"), tree_window_save);
- }
-
-
-
-
- void tree_window_update(void)
- { os_box extent;
-
- /* Redraw whole window */
- window_get_extent(0, tree_window_id, &extent);
- window_force_redraw(0, tree_window_id, &extent);
- }
-