1 /*
2 * FIG : Facility for Interactive Generation of figures
3 * Copyright (c) 1985-1988 by Supoj Sutanthavibul
4 * Parts Copyright (c) 1989-2007 by Brian V. Smith
5 * Parts Copyright (c) 1991 by Paul King
6 *
7 * Any party obtaining a copy of these files is granted, free of charge, a
8 * full and unrestricted irrevocable, world-wide, paid up, royalty-free,
9 * nonexclusive right and license to deal in this software and documentation
10 * files (the "Software"), including without limitation the rights to use,
11 * copy, modify, merge, publish, distribute, sublicense and/or sell copies of
12 * the Software, and to permit persons who receive copies from any such
13 * party to do so, with the only requirement being that the above copyright
14 * and this permission notice remain intact.
15 *
16 */
17
18 #include "fig.h"
19 #include "resources.h"
20 #include "w_cmdpanel.h"
21 #include "w_icons.h"
22 #include "w_indpanel.h"
23 #include "w_setup.h"
24 #include "w_util.h"
25
26 int TOOL_WD, TOOL_HT;
27 int CMDFORM_WD, CMDFORM_HT = CMD_BUT_HT;
28 int NAMEPANEL_WD;
29 int MODEPANEL_WD;
30 int MODEPANEL_SPACE;
31 int MSGPANEL_WD;
32 int MSGPANEL_HT = 24;
33 int MOUSEFUN_HT;
34 int INDPANEL_WD;
35 int CANVAS_WD, CANVAS_HT;
36 int CANVAS_WD_LAND, CANVAS_HT_LAND;
37 int CANVAS_WD_PORT, CANVAS_HT_PORT;
38 int INTERNAL_BW;
39 int TOPRULER_WD, TOPRULER_HT;
40 int SIDERULER_WD, SIDERULER_HT;
41 int SW_PER_ROW, SW_PER_COL;
42
setup_sizes(int new_canv_wd,int new_canv_ht)43 void setup_sizes(int new_canv_wd, int new_canv_ht)
44 {
45 int NUM_CMD_MENUS;
46
47 /*
48 * make the width of the mousefun panel about 1/3 of the size of the
49 * canvas width and the cmdpanel the remaining width. Be sure to set it
50 * up so that cmdpanel buttons can be allocated a size which divides
51 * evenly into the remaining space.
52 */
53 CANVAS_WD = new_canv_wd;
54 if (CANVAS_WD < 10)
55 CANVAS_WD = 10;
56 CANVAS_HT = new_canv_ht;
57 if (CANVAS_HT < 10)
58 CANVAS_HT = 10;
59
60 if (appres.RHS_PANEL) {
61 SIDERULER_WD = UNITBOX_WD - 3; /* must make side ruler wider to show unitbox */
62 TOPRULER_WD = CANVAS_WD-UNITBOX_WD+SIDERULER_WD - 2*INTERNAL_BW + 4;
63 } else {
64 SIDERULER_WD = DEF_RULER_WD + 20; /* allow for 100's and decimals at large zooms */
65 TOPRULER_WD = CANVAS_WD-UNITBOX_WD+SIDERULER_WD - 2*INTERNAL_BW + 2;
66 }
67 TOPRULER_HT = RULER_WD;
68 SIDERULER_HT = CANVAS_HT;
69 if (TOPRULER_WD > MAX_TOPRULER_WD)
70 TOPRULER_WD = MAX_TOPRULER_WD;
71 if (SIDERULER_HT > MAX_SIDERULER_HT)
72 SIDERULER_HT = MAX_SIDERULER_HT;
73
74 /* side mode panel */
75 MODEPANEL_WD = (mode_sw_wd + INTERNAL_BW) * SW_PER_ROW + INTERNAL_BW;
76
77 NUM_CMD_MENUS = num_main_menus(); /* kludge - NUM_CMD_MENUS local to w_cmdpanel.c */
78 /* width of the command menu button form */
79 CMDFORM_WD = NUM_CMD_MENUS*(CMD_BUT_WD+INTERNAL_BW);
80
81 /* filename panel to the right of the command menu buttons */
82 NAMEPANEL_WD = MODEPANEL_WD + CANVAS_WD + SIDERULER_WD - CMDFORM_WD -
83 MOUSEFUN_WD - INTERNAL_BW;
84 if (NAMEPANEL_WD < 75)
85 NAMEPANEL_WD = 75;
86
87 /* message window under command buttons */
88 MSGPANEL_WD = CMDFORM_WD + NAMEPANEL_WD - INTERNAL_BW;
89
90 /* lower indicator panel */
91 INDPANEL_WD = MODEPANEL_WD + CANVAS_WD + SIDERULER_WD;
92
93 /* space for both modepanel titles (Drawing modes and Editing modes) */
94 MODEPANEL_SPACE = 1 + CANVAS_HT + RULER_WD -
95 (mode_sw_ht + INTERNAL_BW) * (ceil((double)NUM_MODE_SW/SW_PER_ROW) + 1);
96 if (MODEPANEL_SPACE < 2)
97 MODEPANEL_SPACE = 2;
98 }
99