3 * Handles all those many problems you get with panes
5 * v. 1.100 (25 July 1993)
7 * © 1993-1998 Straylight
10 /*----- Licensing note ----------------------------------------------------*
12 * This file is part of Straylight's Steel library.
14 * Steel is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2, or (at your option)
19 * Steel is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with Steel. If not, write to the Free Software Foundation,
26 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
51 typedef struct pane__paneItem
53 struct pane__paneItem *next;
61 typedef struct pane__panestr
64 pane__paneItem *panes;
69 * pane pane_create(wimp_w tool)
72 * Sets up a structure for a pane, and returns a handle.
75 * wimp_w tool == the window handle of the tool window (the one that isn't
79 * An abstract handle to the pane.
82 pane pane_create(wimp_w tool)
84 pane newPane=(pane)mem_alloc(sizeof(pane__panestr));
91 werr(FALSE,msgs_lookup("paneNEM:Not enough memory to register pane."));
96 * void pane_addPane(pane p,wimp_w w)
99 * Registers a new pane as being associated with the tool window given in
103 * pane p == the pane handle for the tool window
104 * wimp_w w == the window handle of the new pane
107 void pane_addPane(pane p,wimp_w w)
114 if (new=mem_alloc(sizeof(pane__paneItem)),!new)
117 new->type=pane__WINDOW;
118 wimpt_noerr(wimp_get_wind_state(w,&ps));
119 wimpt_noerr(wimp_get_wind_state(p->tool,&ts));
120 new->box.x0=ps.o.box.x0-ts.o.box.x0;
121 new->box.y0=ps.o.box.y0-ts.o.box.y0;
122 new->box.x1=ps.o.box.x1-ts.o.box.x0;
123 new->box.y1=ps.o.box.y1-ts.o.box.y0;
129 * void pane_addListbox(pane p,list l)
132 * Adds a listbox to the tool window. Handles things properly, so that
133 * scroll bars and things appear at the right time.
136 * pane p == the pane to add to
137 * list l == the list to add
140 void pane_addListbox(pane p,list l)
142 wimp_w w=list_syshandle(l);
149 if (new=mem_alloc(sizeof(pane__paneItem)),!new)
152 new->type=pane__LISTBOX;
154 wimpt_noerr(wimp_get_wind_state(w,&ps));
155 wimpt_noerr(wimp_get_wind_state(p->tool,&ts));
156 new->box.x0=ps.o.box.x0-ts.o.box.x0;
157 new->box.y0=ps.o.box.y0-ts.o.box.y0;
158 new->box.x1=ps.o.box.x1-ts.o.box.x0;
159 new->box.y1=ps.o.box.y1-ts.o.box.y0;
165 * void pane_delete(pane p)
168 * Destroys and mem_free()s the memory occupied by a pane structure.
171 * pane p == the pane's handle
174 void pane_delete(pane p)
176 pane__paneItem *itm=p->panes;
185 list_isPane(i->handle.l,0);
194 * void pane_removePane(pane p,wimp_w w)
197 * Removes the specified pane from the structure.
200 * pane p == the pane in question
201 * wimp_w w == the window to remove
204 void pane_removePane(pane p,wimp_w w)
206 pane__paneItem *i=(pane__paneItem *)(&p->panes);
210 if (i->next->pane==w)
217 list_isPane(it->handle.l,0);
228 * void pane__doMove(pane p,wimp_openstr *o)
231 * Moves a set of panes to the place specified.
234 * pane p == the pane handle
235 * wimp_openstr *o == where to put them
238 static void pane__doMove(pane p,wimp_openstr *o)
240 pane__paneItem *i=p->panes;
246 wimpt_noerr(wimp_open_wind(o));
247 wimpt_noerr(wimp_get_wind_state(o->w,&state));
248 behind=state.o.behind;
252 wimpt_noerr(wimp_get_wind_state(i->pane,&state));
253 behind=state.o.behind;
259 wimpt_noerr(wimp_get_wind_state(i->pane,&state));
260 state.o.box.x0=o->box.x0+i->box.x0;
261 state.o.box.y0=o->box.y0+i->box.y0;
262 state.o.box.x1=o->box.x0+i->box.x1;
263 state.o.box.y1=o->box.y0+i->box.y1;
264 state.o.behind=behind;
266 wimpt_noerr(wimp_open_wind(&state.o));
270 wimpt_noerr(wimp_open_wind(o));
274 * void pane_updatePanes(pane p)
277 * Updates position of panes attached to the main window after it has been
281 * pane p == the pane handle
284 void pane_updatePanes(pane p)
287 wimpt_noerr(wimp_get_wind_state(p->tool,&s));
288 pane__doMove(p,&s.o);
292 * void pane_moved(pane p)
295 * Asks the pane segment to reopen a pane in response to an wimp_EOPEN
299 * pane p == the pane handle
302 void pane_moved(pane p)
304 wimp_eventstr *e=wimpt_last_event();
305 if (e->e!=wimp_EOPEN || e->data.o.w!=p->tool)
310 msgs_lookup("paneIPH:(pane_moved, caller fault): "
311 "not a wimp_EOPEN event or with wrong pane handle.")
315 if (wimpt_justChangedMode())
316 win_adjustBox(&e->data.o);
317 pane__doMove(p,&e->data.o);
321 * void pane_front(pane p)
324 * Moves a tool window and associated panes to the front of the screen.
327 * pane p == the pane handle
330 void pane_front(pane p)
333 wimpt_noerr(wimp_get_wind_state(p->tool,&s));
335 pane__doMove(p,&s.o);
339 * void pane_close(pane p)
342 * This routine will close all the windows attached to the pane structure.
345 * pane p == the pane handle
348 void pane_close(pane p)
350 pane__paneItem *i=p->panes;
351 wimpt_noerr(wimp_close_wind(p->tool));
354 wimpt_noerr(wimp_close_wind(i->pane));