source: tags/ms_r16q2/WINDOW/AW_font_group.cxx

Last change on this file was 7659, checked in by westram, 13 years ago
  • merge from dev [7494] [7495] [7496] [7497] [7498] [7499] [7500] [7501] [7502] [7503]
    • separated X and ARB a bit
      • added base classes
        • AW_GC (from AW_GC_Xm)
        • AW_common_Xm (from AW_common)
      • the class names are misleading, since they are X- not Motif-dependent
    • refactored
      • AW_device
      • AW_clip (now AW_clipable)
      • AW_matrix (now AW_zoomable)
      • AW_gc (now AW_stylable)
    • bugfixes
      • set_lineattributes() did not set given line style at all. It has been impossible to paint dotted lines
      • leak in AW_common-dtor
    • changes
      • AW_font_limits (tracks min char width)
      • AW (LineVector/Rectangle) ctors
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.0 KB
Line 
1// ==================================================================== //
2//                                                                      //
3//   File      : AW_font_group.cxx                                      //
4//   Purpose   : Bundles a group of fonts and provides overall maximas  //
5//                                                                      //
6//                                                                      //
7// Coded by Ralf Westram (coder@reallysoft.de) in December 2004         //
8// Copyright Department of Microbiology (Technical University Munich)   //
9//                                                                      //
10// Visit our web site at: http://www.arb-home.de/                       //
11//                                                                      //
12// ==================================================================== //
13
14#include "aw_font_group.hxx"
15#include "aw_common.hxx"
16
17AW_font_group::AW_font_group() {
18    unregisterAll();
19}
20
21void AW_font_group::unregisterAll()
22{
23    max_width   = 0;
24    max_ascent  = 0;
25    max_descent = 0;
26    max_height  = 0;
27
28    memset(&max_letter_limits[0], 0, sizeof(max_letter_limits));
29}
30
31inline void set_max(int val, int& max) { if (val>max) max = val; }
32
33void AW_font_group::registerFont(AW_device *device, int gc, const char *chars) {
34    aw_assert(gc <= AW_FONT_GROUP_MAX_GC);
35
36    const AW_GC *gcm = device->get_common()->map_gc(gc);
37
38    if (!chars) {
39        // use complete ASCII-range for limits
40        max_letter_limits[gc] = gcm->get_font_limits();
41    }
42    else {
43        aw_assert(chars[0]);
44        AW_font_limits limits = gcm->get_font_limits(chars[0]);
45        for (int i = 1; chars[i]; ++i) {
46            limits = AW_font_limits(limits, gcm->get_font_limits(chars[i]));
47        }
48        max_letter_limits[gc] = limits;
49    }
50
51    set_max(get_width(gc), max_width);
52    set_max(get_ascent(gc), max_ascent);
53    set_max(get_descent(gc), max_descent);
54    set_max(get_height(gc), max_height);
55}
56
Note: See TracBrowser for help on using the repository browser.