Mercurial > hg > xemacs-beta
comparison src/glyphs-widget.c @ 5495:1f0b15040456
Merge.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sun, 01 May 2011 18:44:03 +0100 |
parents | 4dee0387b9de |
children | 56144c8593a8 |
comparison
equal
deleted
inserted
replaced
5494:861f2601a38b | 5495:1f0b15040456 |
---|---|
2 Copyright (C) 1998, 1999, 2000, 2002 Andy Piper. | 2 Copyright (C) 1998, 1999, 2000, 2002 Andy Piper. |
3 Copyright (C) 2003 Ben Wing. | 3 Copyright (C) 2003 Ben Wing. |
4 | 4 |
5 This file is part of XEmacs. | 5 This file is part of XEmacs. |
6 | 6 |
7 XEmacs is free software; you can redistribute it and/or modify it | 7 XEmacs is free software: you can redistribute it and/or modify it |
8 under the terms of the GNU General Public License as published by the | 8 under the terms of the GNU General Public License as published by the |
9 Free Software Foundation; either version 2, or (at your option) any | 9 Free Software Foundation, either version 3 of the License, or (at your |
10 later version. | 10 option) any later version. |
11 | 11 |
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT | 12 XEmacs is distributed in the hope that it will be useful, but WITHOUT |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | 13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | 14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
15 for more details. | 15 for more details. |
16 | 16 |
17 You should have received a copy of the GNU General Public License | 17 You should have received a copy of the GNU General Public License |
18 along with XEmacs; see the file COPYING. If not, write to | 18 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
20 Boston, MA 02111-1307, USA. */ | |
21 | 19 |
22 /* Synched up with: Not in FSF. */ | 20 /* Synched up with: Not in FSF. */ |
23 | 21 |
24 /* written by Andy Piper <andy@xemacs.org> */ | 22 /* written by Andy Piper <andy@xemacs.org> */ |
25 | 23 |
33 #include "frame.h" | 31 #include "frame.h" |
34 #include "glyphs.h" | 32 #include "glyphs.h" |
35 #include "gui.h" | 33 #include "gui.h" |
36 #include "insdel.h" | 34 #include "insdel.h" |
37 #include "lstream.h" | 35 #include "lstream.h" |
38 #include "objects.h" | 36 #include "fontcolor.h" |
39 #include "opaque.h" | 37 #include "opaque.h" |
40 #include "window.h" | 38 #include "window.h" |
41 | 39 |
42 DEFINE_IMAGE_INSTANTIATOR_FORMAT (button); | 40 DEFINE_IMAGE_INSTANTIATOR_FORMAT (button); |
43 DEFINE_IMAGE_INSTANTIATOR_FORMAT (combo_box); | 41 DEFINE_IMAGE_INSTANTIATOR_FORMAT (combo_box); |
279 { | 277 { |
280 int charheight = 0; | 278 int charheight = 0; |
281 widget_query_string_geometry (text, face, | 279 widget_query_string_geometry (text, face, |
282 0, &charheight, domain); | 280 0, &charheight, domain); |
283 /* For the returned value to be useful it needs to be big enough to | 281 /* For the returned value to be useful it needs to be big enough to |
284 accomodate the largest single-height widget. This is currently | 282 accommodate the largest single-height widget. This is currently |
285 the edit-field. */ | 283 the edit-field. */ |
286 return charheight + 2 * widget_spacing (domain) | 284 return charheight + 2 * widget_spacing (domain) |
287 + 4 * widget_border_width (domain); | 285 + 4 * widget_border_width (domain); |
288 } | 286 } |
289 | 287 |
809 anyway. :height is measured in logical characters which take into | 807 anyway. :height is measured in logical characters which take into |
810 account the borders and spacing on widgets. */ | 808 account the borders and spacing on widgets. */ |
811 if (tw) | 809 if (tw) |
812 { | 810 { |
813 int charwidth; | 811 int charwidth; |
814 default_face_font_info (domain, 0, 0, 0, &charwidth, 0); | 812 default_face_font_info (domain, 0, 0, &charwidth, 0, 0); |
815 pw = ROUND_UP (charwidth * tw + 4 * widget_instance_border_width (ii), charwidth); | 813 pw = ROUND_UP (charwidth * tw + 4 * widget_instance_border_width (ii), charwidth); |
816 } | 814 } |
817 | 815 |
818 /* For heights the widget face is more appropriate. */ | 816 /* For heights the widget face is more appropriate. */ |
819 if (th == 1) | 817 if (th == 1) |
825 IMAGE_INSTANCE_WIDGET_FACE (ii), | 823 IMAGE_INSTANCE_WIDGET_FACE (ii), |
826 0, &charheight, domain); | 824 0, &charheight, domain); |
827 } | 825 } |
828 else | 826 else |
829 { | 827 { |
830 default_face_font_info (domain, 0, 0, &charheight, 0, 0); | 828 default_face_font_info (domain, 0, 0, 0, &charheight, 0); |
831 } | 829 } |
832 ph = (charheight + 2 * widget_instance_border_width (ii)) * th; | 830 ph = (charheight + 2 * widget_instance_border_width (ii)) * th; |
833 } | 831 } |
834 /* For heights > 1 use logical units. */ | 832 /* For heights > 1 use logical units. */ |
835 else if (th > 1) | 833 else if (th > 1) |
947 } | 945 } |
948 if (*height) | 946 if (*height) |
949 { | 947 { |
950 int len, h; | 948 int len, h; |
951 /* #### widget face would be better here. */ | 949 /* #### widget face would be better here. */ |
952 default_face_font_info (domain, 0, 0, &h, 0, 0); | 950 default_face_font_info (domain, 0, 0, 0, &h, 0); |
953 GET_LIST_LENGTH (items, len); | 951 GET_LIST_LENGTH (items, len); |
954 *height = len * h; | 952 *height = len * h; |
955 } | 953 } |
956 } | 954 } |
957 | 955 |
1301 instance how should the search dialog be organized for alignment? | 1299 instance how should the search dialog be organized for alignment? |
1302 The obvious choice of two vertical columns does not work since the | 1300 The obvious choice of two vertical columns does not work since the |
1303 size of individual widgets will affect where they get placed. The | 1301 size of individual widgets will affect where they get placed. The |
1304 same is true for several rows of widgets. To solve this problem we | 1302 same is true for several rows of widgets. To solve this problem we |
1305 introduce the notion of `logical_unit_height'. This is a size | 1303 introduce the notion of `logical_unit_height'. This is a size |
1306 quantity that is designed to be big enough to accomodate the | 1304 quantity that is designed to be big enough to accommodate the |
1307 largest `single height unit'. The function | 1305 largest `single height unit'. The function |
1308 widget_logical_unit_height() determines the value of this in | 1306 widget_logical_unit_height() determines the value of this in |
1309 pixels. It is dependent on the widget face and some combination of | 1307 pixels. It is dependent on the widget face and some combination of |
1310 spacing and border-width. Thus if users specify left or right | 1308 spacing and border-width. Thus if users specify left or right |
1311 justification in a vertical layout they get something in logical | 1309 justification in a vertical layout they get something in logical |
1657 w = XINT (width); | 1655 w = XINT (width); |
1658 | 1656 |
1659 if (HAS_DEVMETH_P (DOMAIN_XDEVICE (domain), widget_border_width)) | 1657 if (HAS_DEVMETH_P (DOMAIN_XDEVICE (domain), widget_border_width)) |
1660 border_width = DEVMETH (DOMAIN_XDEVICE (domain), widget_border_width, ()); | 1658 border_width = DEVMETH (DOMAIN_XDEVICE (domain), widget_border_width, ()); |
1661 | 1659 |
1662 default_face_font_info (domain, 0, 0, 0, &charwidth, 0); | 1660 default_face_font_info (domain, 0, 0, &charwidth, 0, 0); |
1663 neww = ROUND_UP (charwidth * w + 4 * border_width + 2 * widget_spacing (domain), | 1661 neww = ROUND_UP (charwidth * w + 4 * border_width + 2 * widget_spacing (domain), |
1664 charwidth) / charwidth; | 1662 charwidth) / charwidth; |
1665 | 1663 |
1666 return make_int (neww); | 1664 return make_int (neww); |
1667 } | 1665 } |
1671 Logical widget units do not take into account adjustments made for | 1669 Logical widget units do not take into account adjustments made for |
1672 layout borders, so this adjustment is approximated. | 1670 layout borders, so this adjustment is approximated. |
1673 | 1671 |
1674 If the components of a widget layout are justified to the top or the | 1672 If the components of a widget layout are justified to the top or the |
1675 bottom then they are aligned in terms of `logical units'. This is a | 1673 bottom then they are aligned in terms of `logical units'. This is a |
1676 size quantity that is designed to be big enough to accomodate the | 1674 size quantity that is designed to be big enough to accommodate the |
1677 largest `single height' widget. It is dependent on the widget face and | 1675 largest `single height' widget. It is dependent on the widget face and |
1678 some combination of spacing and border-width. Thus if you specify top | 1676 some combination of spacing and border-width. Thus if you specify top |
1679 or bottom justification in a vertical layout the subcontrols are laid | 1677 or bottom justification in a vertical layout the subcontrols are laid |
1680 out one per logical unit. This allows adjoining layouts to have | 1678 out one per logical unit. This allows adjoining layouts to have |
1681 identical alignment for their subcontrols. | 1679 identical alignment for their subcontrols. |
1691 if (NILP (domain)) | 1689 if (NILP (domain)) |
1692 domain = Fselected_frame (Qnil); | 1690 domain = Fselected_frame (Qnil); |
1693 | 1691 |
1694 h = XINT (height); | 1692 h = XINT (height); |
1695 | 1693 |
1696 default_face_font_info (domain, 0, 0, &charheight, 0, 0); | 1694 default_face_font_info (domain, 0, 0, 0, &charheight, 0); |
1697 newh = ROUND_UP (logical_unit_height (Fsymbol_name (Qwidget), | 1695 newh = ROUND_UP (logical_unit_height (Fsymbol_name (Qwidget), |
1698 Vwidget_face, domain) * h, charheight) | 1696 Vwidget_face, domain) * h, charheight) |
1699 / charheight; | 1697 / charheight; |
1700 | 1698 |
1701 return make_int (newh); | 1699 return make_int (newh); |