blob: cabf4d94790c0c224d5f320ef594211859fbb802 (
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
|
#include <kdebug.h>
#include <tqcursor.h>
#include "ppopmenu.h"
PObject *
PPopupMenu::createWidget(CreateArgs &ca)
{
PPopupMenu *pm = new PPopupMenu(ca.parent);
TQPopupMenu *qpm;
if(ca.fetchedObj != 0 && ca.fetchedObj->inherits("TQPopupMenu") == TRUE){
qpm= (TQPopupMenu *) ca.fetchedObj;
pm->setDeleteAble(FALSE);
}
else if(ca.parent != 0 && ca.parent->widget()->isWidgetType() == TRUE)
qpm = new TQPopupMenu((TQWidget *) ca.parent->widget());
else
qpm = new TQPopupMenu();
pm->setWidget(qpm);
pm->setWidgetId(ca.pwI);
return pm;
}
PPopupMenu::PPopupMenu(PObject *parent)
: PFrame(parent)
{
// kdDebug(5008) << "PLineEdit PLineEdit called" << endl;
menu = 0;
setWidget(menu);
pmd = new PMenuData(this);
}
PPopupMenu::~PPopupMenu()
{
// kdDebug(5008) << "PLineEdit: in destructor" << endl;
/* delete widget(); // Delete the frame
menu = 0; // Set it to 0
setWidget(menu); // Now set all widget() calls to 0.
*/
delete pmd;
}
void PPopupMenu::messageHandler(int fd, PukeMessage *pm)
{
PukeMessage pmRet;
switch(pm->iCommand){
/*
case PUKE_LINED_SET_MAXLENGTH:
if(widget() == 0){
kdDebug(5008) << "PLineEdit: No Widget set" << endl;
return;
}
widget()->setMaxLength(pm->iArg);
pmRet.iCommand = - pm->iCommand;
pmRet.iWinId = pm->iWinId;
pmRet.iArg = widget()->maxLength();
emit outputMessage(fd, &pmRet);
break;
*/
case PUKE_POPUPMENU_POPUP_CURRENT:
if(widget() == 0){
kdDebug(5008) << "PPopupMenu: No Widget set" << endl;
return;
}
widget()->popup(TQCursor::pos(), 0);
pmRet.iCommand = - pm->iCommand;
pmRet.iWinId = pm->iWinId;
pmRet.iArg = 1;
pmRet.cArg = 0;
emit outputMessage(fd, &pmRet);
break;
default:
if(pmd->menuMessageHandler(fd, pm) == FALSE) // Call pmd's even filter
PFrame::messageHandler(fd, pm);
}
}
void PPopupMenu::setWidget(TQObject *_menu)
{
if(_menu != 0 && _menu->inherits("TQPopupMenu") == FALSE)
{
errorInvalidSet(_menu);
return;
}
menu = (TQPopupMenu *) _menu;
if(menu != 0x0){
connect(menu, TQT_SIGNAL(activated(int)),
this, TQT_SLOT(got_activated(int)));
}
PFrame::setWidget(menu);
}
TQPopupMenu *PPopupMenu::widget()
{
return menu;
}
void PPopupMenu::got_activated(int itemId){
qWarning("Item got activated: %d", itemId);
widgetId wI;
PukeMessage pmRet;
wI = widgetIden();
pmRet.iCommand = PUKE_POPUPMENU_ACTIVATED_ACK;
pmRet.iWinId = wI.iWinId;
pmRet.iArg = itemId;
pmRet.cArg = 0;
emit outputMessage(wI.fd, &pmRet);
}
#include "ppopmenu.moc"
|