-
Notifications
You must be signed in to change notification settings - Fork 2
/
tws_popup.i
95 lines (89 loc) · 2.87 KB
/
tws_popup.i
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
/*
* TWS_Button.I Tiny Widget Set Button.
*
* Buttons for the Tiny Widget Set. See tws.i
*
* $Id: tws_popup.i,v 1.1 2008-01-04 15:04:37 frigaut Exp $
*
* This file is part of Yutils
* Copyright (C) 2007 Thibaut Paumard <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* $Log: tws_popup.i,v $
* Revision 1.1 2008-01-04 15:04:37 frigaut
* - added tws*.i from thibaut
*
*
*/
struct TWS_Button
/* DOCUMENT TWS_Popup
*/
{
string type,uname;
pointer root,parent,child; // child is the root widget of the popup window
double position(4);
string label,handler;
long label_id,frame_id;
}
struct TWS_ButtonEvent
{
pointer widget;
double mouse(11);
long button;
}
func tws_button(self,parent=,label=,uname=,action=,position=,mouse=,cild=,handler=)
/* DOCUMENT tws_button,label=label,parent=parent,uname=uname
Creates a TWS popup. It's a button (so see tws_button), that creates a popup
window when clicked. You must give CHILD, a Root widget, and handler, the
corresponding handler
*/
{
if (is_void(self)) action="Create";
if (action=="Create") {
if (is_void(position)) position=parent->position;
if (is_void(uname)) uname="";
if (is_void(label)) label="";
self=&TWS_Button();
self->root=parent->root;
self->parent=parent;
self->type="tws_button";
self->label=label;
self->uname=uname;
self->frame_id=tws_plid(self->root);
self->label_id=tws_plid(self->root);
self->position=tws_action(self->parent)(self->parent,action="GetPosition",position=position);
tws_addtoparent,parent,self;
return self;
} else if (action=="Realize") {
plrect,self->position;
plt,self->label,self->position(1)+(self->position(3)-self->position(1))/10.,self->position(2)+(self->position(4)-self->position(2))/2.,tosys=1,justify="LH";
} else if (action=="GetEvent") {
Event=[];
if (tws_isinrect(self->position,mouse)) {
Event=TWS_ButtonEvent();
Event.widget=self;
Event.mouse=mouse;
Event.button=long(mouse(10));
}
return Event;
} else if (action=="Activate") {
pledit,self->label_id,color="blue";
redraw;
} else if (action=="Deactivate") {
pledit,self->label_id,color="black";
redraw;
}
}