summaryrefslogtreecommitdiff
path: root/src/Xw/Xw_IconBox.cxx
blob: 7795ad988da19156562acaf6b364c0cacfe1176f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#define PURIFY	//GG_180297
//		Liberation memoire allouee par les icones.

// File		Xw_IconBox.cxx
// Created	Mars 1994
// Author	GG

//-Copyright	MatraDatavision 1991,1992,1993

//-Version

//-Design	Creation d'une Icon Box 

//-Warning

//-References

//-Language	C++ 2.0

//-Declarations

// for the class
#include <Xw_IconBox.ixx>

// Routines C a declarer en extern
//extern "C" {
#include <Xw_Cextern.hxx>
//}

//-Static data definitions

static XW_STATUS status ;

//-Aliases

//-Global data definitions

//-Constructors

Xw_IconBox::Xw_IconBox (const Handle(Xw_GraphicDevice)& Device, const Standard_CString Name, const Standard_Real Xc, const Standard_Real Yc, const Quantity_NameOfColor BackColor,const Xw_WindowQuality aQuality) : 
	Xw_Window(Device,Name,Xc,Yc,0.1,0.1,aQuality,BackColor,0) {

	MyNumberOfIcons = Xw_load_icons(MyExtendedWindow,(Standard_PCharacter)Name) ;

	if( !MyNumberOfIcons ) {
	    PrintError() ;
    	}
}

void Xw_IconBox::Destroy () {

	MyNumberOfIcons = 0 ;
#ifdef PURIFY
   	if( MyExtendedWindow ) Xw_clear_icons(MyExtendedWindow,NULL);
#endif
}

Standard_Integer Xw_IconBox::UnloadIcons ( const Standard_CString Name) {
Standard_Integer nicons = 0;

        nicons = Xw_clear_icons (MyExtendedWindow,(Standard_PCharacter)Name);

        if( !nicons ) Xw_print_error() ; 

	MyNumberOfIcons -= nicons ;

	return nicons;
}

void Xw_IconBox::Show () const {

        status = Xw_show_icons (MyExtendedWindow);

        if( !status ) Xw_print_error() ; 
}

Standard_Integer Xw_IconBox::LoadIcons ( const Standard_CString Name ) {
int nicons ;

	nicons = Xw_load_icons(MyExtendedWindow,(Standard_PCharacter)Name) ;

        if( nicons > 0 ) MyNumberOfIcons += nicons ;
	else Xw_print_error() ; 

	return nicons;
}

void Xw_IconBox::AddIcon ( const Handle(Xw_Window)& W,const Standard_CString Name,
		const Standard_Integer aWidth,const Standard_Integer aHeight ) {
	status = Xw_put_window_icon(MyExtendedWindow,W->ExtendedWindow(),
				    (Standard_PCharacter)Name,aWidth,aHeight) ;

        if( status ) MyNumberOfIcons++ ;
	else	Xw_print_error() ; 
}

Standard_Integer Xw_IconBox::SaveIcons () const {
Standard_Integer nicons = 0;

	nicons = Xw_save_icons(MyExtendedWindow) ;

	return nicons;
}

Standard_Integer Xw_IconBox::IconNumber () const {

	return (MyNumberOfIcons);
}

Standard_CString Xw_IconBox::IconName ( const Standard_Integer Index) const {
char *Name = NULL ;

	if( Index < 0 || Index > MyNumberOfIcons ) {
	    PrintError() ;
	}

	Name = Xw_get_icon_name(MyExtendedWindow,(int)Index) ;

	if( !Name ) Xw_print_error() ;

	return (Name);
}

Standard_Boolean Xw_IconBox::IconSize ( const Standard_CString Name, Standard_Integer& Width, Standard_Integer& Height ) const {
int width,height ;

	status = Xw_get_icon_size( MyExtendedWindow,(Standard_PCharacter)Name,&width,&height) ;

	if( status ) {
	    Width = width ;
	    Height = height ;
	} else {
	    Xw_print_error() ;
	}

	return Standard_Boolean(status);
}

Aspect_Handle Xw_IconBox::IconPixmap ( const Standard_CString Name ) const {
Aspect_Handle pixmap = 0 ;

	pixmap = Xw_get_icon_pixmap( MyExtendedWindow,0,0,(Standard_PCharacter)Name) ;

	if( !pixmap ) Xw_print_error() ;

	return (pixmap);
}

Aspect_Handle Xw_IconBox::IconPixmap ( const Standard_CString Name, const Standard_Integer Width,const Standard_Integer Height ) const {
Aspect_Handle pixmap = 0 ;

	pixmap = Xw_get_icon_pixmap( MyExtendedWindow,
				    (int)Width,(int)Height,
				    (Standard_PCharacter)Name) ;

	if( !pixmap ) Xw_print_error() ;

	return (pixmap);
}