source: branches/port5/WINDOW/AW_size.cxx

Last change on this file was 5901, checked in by westram, 16 years ago
  • AW_BOOL → bool
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.1 KB
Line 
1#include <stdio.h>
2#include <stdlib.h>
3#include <X11/X.h>
4#include <X11/Xlib.h>
5
6#include <aw_root.hxx>
7#include "aw_device.hxx"
8#include "aw_commn.hxx"
9#include <aw_size.hxx>
10
11#include <algorithm>
12
13using namespace std;
14
15//*****************************************************************************************
16  //                                    size_device
17  //*****************************************************************************************
18
19  AW_device_size::AW_device_size(AW_common *commoni): AW_device(commoni) {
20      ;
21  }
22
23void AW_device_size::init() {
24    drawn = false;
25
26    size_information.t = 0;
27    size_information.b = 0;
28    size_information.l = 0;
29    size_information.r = 0;
30}
31
32AW_DEVICE_TYPE AW_device_size::type(void) { return AW_DEVICE_SIZE; }
33
34void AW_device_size::privat_reset(void){
35    this->init();
36}
37
38inline void AW_device_size::dot_transformed(AW_pos X, AW_pos Y) {
39    if (drawn) {
40        size_information.l = min(size_information.l, X);
41        size_information.r = max(size_information.r, X);
42        size_information.t = min(size_information.t, Y);
43        size_information.b = max(size_information.b, Y);
44    }
45    else {
46        size_information.l = size_information.r = X;
47        size_information.t = size_information.b = Y;
48        drawn              = true;
49    }
50}
51
52inline void AW_device_size::dot(AW_pos x, AW_pos y) {
53    AW_pos X, Y;
54    transform(x, y, X, Y);
55    dot_transformed(X, Y);
56}
57
58/***********************************************************************************************************************/
59/* line  text  zoomtext  box *******************************************************************************************/
60/***********************************************************************************************************************/
61
62bool AW_device_size::invisible(int gc, AW_pos x, AW_pos y, AW_bitset filteri, AW_CL clientdata1, AW_CL clientdata2) {
63    if (filteri & filter) dot(x, y);
64    return AW_device::invisible(gc,x,y,filteri,clientdata1,clientdata2);
65}
66
67
68int AW_device_size::line(int gc, AW_pos x0, AW_pos y0, AW_pos x1, AW_pos y1, AW_bitset filteri, AW_CL clientdata1, AW_CL clientdata2) {
69    AWUSE(clientdata1);AWUSE(clientdata2);
70    AWUSE(gc);
71
72    if (filteri & filter) {
73        dot(x0, y0);
74        dot(x1, y1);
75        return true;
76    }
77    return false;
78}
79
80int AW_device_size::text(int gc, const char *str, AW_pos x, AW_pos y, AW_pos alignment, AW_bitset filteri, AW_CL clientdata1, AW_CL clientdata2, long opt_strlen) {
81    AWUSE(clientdata1);AWUSE(clientdata2);
82
83    if(filteri & filter) {
84        XFontStruct *xfs = &(common->gcs[gc]->curfont);
85       
86        AW_pos X0,Y0;           // Transformed pos
87        this->transform(x,y,X0,Y0);
88
89        AW_pos l_ascent  = xfs->max_bounds.ascent;
90        AW_pos l_descent = xfs->max_bounds.descent;
91        AW_pos l_width   = get_string_size(gc, str, opt_strlen);
92        X0               = common->x_alignment(X0,l_width,alignment);
93
94        dot_transformed(X0, Y0-l_ascent);
95        dot_transformed(X0+l_width, Y0+l_descent);
96        return 1;
97    }
98    return 0;
99}
100
101
102
103void AW_device_size::get_size_information(AW_world *ptr) {
104    *ptr = size_information;
105}
106
Note: See TracBrowser for help on using the repository browser.