summaryrefslogtreecommitdiffstats
path: root/scilab/modules/graphics
diff options
context:
space:
mode:
authorYann Collette <yann.collette@scilab.org>2010-03-12 10:39:30 +0100
committerYann Collette <yann.collette@scilab.org>2010-03-12 10:39:30 +0100
commit90625167fc9ad3f2b43286060d19bcf11306628b (patch)
tree2ea941fa4061541a802b8da090e3e71dfc2cc8ef /scilab/modules/graphics
parent78b890f6cb09263dbfd6a38a3bfee76b9fd7700b (diff)
downloadscilab-90625167fc9ad3f2b43286060d19bcf11306628b.zip
scilab-90625167fc9ad3f2b43286060d19bcf11306628b.tar.gz
allow the user to overload %h_delete
Diffstat (limited to 'scilab/modules/graphics')
-rw-r--r--scilab/modules/graphics/macros/%h_delete.sci10
-rw-r--r--scilab/modules/graphics/sci_gateway/c/sci_delete.c235
2 files changed, 120 insertions, 125 deletions
diff --git a/scilab/modules/graphics/macros/%h_delete.sci b/scilab/modules/graphics/macros/%h_delete.sci
index 6ff3113..1e40356 100644
--- a/scilab/modules/graphics/macros/%h_delete.sci
+++ b/scilab/modules/graphics/macros/%h_delete.sci
@@ -8,12 +8,6 @@
8 8
9 9
10function %h_delete(varargin) 10function %h_delete(varargin)
11 11// No operation overloading function
12 if (length(varargin) == 1) 12// We allow the user to overload the %h_delete function
13 hdl = varargin(1)
14 for i=1:size(hdl,'*')
15 delete(hdl(i))
16 end,
17 end,
18
19endfunction 13endfunction
diff --git a/scilab/modules/graphics/sci_gateway/c/sci_delete.c b/scilab/modules/graphics/sci_gateway/c/sci_delete.c
index f51956e..168d282 100644
--- a/scilab/modules/graphics/sci_gateway/c/sci_delete.c
+++ b/scilab/modules/graphics/sci_gateway/c/sci_delete.c
@@ -39,137 +39,138 @@ int sci_delete(char *fname,unsigned long fname_len)
39{ 39{
40 int m1,n1,l1,m2,n2,l2,num, lw; 40 int m1,n1,l1,m2,n2,l2,num, lw;
41 unsigned long hdl; 41 unsigned long hdl;
42 int nb_handles = 0, i;
42 sciPointObj * pobj; 43 sciPointObj * pobj;
43 sciPointObj * parentFigure; 44 sciPointObj * parentFigure;
44 45
45 CheckRhs(0,1); 46 CheckRhs(0,1);
46 CheckLhs(0,1); 47 CheckLhs(0,1);
47 48
48 lw = 1 + Top - Rhs;
49
50 switch(VarType(1)) 49 switch(VarType(1))
51 {
52 case sci_handles: /* delete Entity given by a handle */
53 GetRhsVar(1,GRAPHICAL_HANDLE_DATATYPE,&m1,&n1,&l1); /* Gets the Handle passed as argument */
54 if (m1!=1||n1!=1) {
55 //lw = 1 + Top - Rhs;
56 C2F(overload)(&lw,"delete",6);
57 return 0;
58 }
59 if (Rhs == 2)
60 {
61 GetRhsVar(2,STRING_DATATYPE,&m2,&n2,&l2); /* Gets the command name */
62 }
63 hdl = (unsigned long)*hstk(l1); /* Puts the value of the Handle to hdl */
64 break;
65 case sci_strings: /* delete("all") */
66 CheckRhs(1,1);
67 GetRhsVar(1,STRING_DATATYPE,&m2,&n2,&l2);
68 if (strcmp(cstk(l2),"all") == 0)
69 {
70 startGraphicDataWriting();
71 sciClearFigure(sciGetCurrentFigure());
72 endGraphicDataWriting();
73 sciDrawObj(sciGetCurrentFigure()); /* redraw the figure to see the change */
74 LhsVar(1) = 0;
75 C2F(putlhsvar)();
76 return 0;
77 }
78 else
79 { 50 {
80 Scierror(999,_("%s: Wrong value for input argument #%d: '%s' expected.\n"),fname,1,"all"); 51 case sci_handles: /* delete Entity given by a handle */
81 return 0; 52 GetRhsVar(1,GRAPHICAL_HANDLE_DATATYPE,&m1,&n1,&l1); /* Gets the Handle passed as argument */
82 } 53 nb_handles = m1*n1;
83 break;
84 default:
85 if (Rhs==0) /* Delete current object */
86 {
87 hdl = (unsigned long) sciGetHandle(sciGetCurrentObj());
88 }
89 else
90 {
91 //lw = 1 + Top - Rhs;
92 C2F(overload)(&lw,"delete",6);
93 return 0;
94
95 /* Scierror(999,_("%s: Wrong type for input argument #%d: '%s' or handle expected.\n"),fname,1,"all"); */
96 /* return 0; */
97 }
98 break;
99 }
100 54
101 pobj = sciGetPointerFromHandle(hdl); 55 if (Rhs == 2)
56 {
57 GetRhsVar(2,STRING_DATATYPE,&m2,&n2,&l2); /* Gets the command name */
58 }
59 hdl = (unsigned long)*hstk(l1); /* Puts the value of the Handle to hdl */
60 break;
61 case sci_strings: /* delete("all") */
62 CheckRhs(1,1);
63 GetRhsVar(1,STRING_DATATYPE,&m2,&n2,&l2);
64 if (strcmp(cstk(l2),"all") == 0)
65 {
66 startGraphicDataWriting();
67 sciClearFigure(sciGetCurrentFigure());
68 endGraphicDataWriting();
69 sciDrawObj(sciGetCurrentFigure()); /* redraw the figure to see the change */
102 70
103 if (pobj == NULL) 71 // Overload
104 { 72 lw = 1 + Top - Rhs;
105 Scierror(999,_("%s: The handle is not valid.\n"),fname); 73 C2F(overload)(&lw,"delete",6);
106 return 0; 74 return 0;
107 } 75 }
76 else
77 {
78 Scierror(999,_("%s: Wrong value for input argument #%d: '%s' expected.\n"),fname,1,"all");
79 return 0;
80 }
81 break;
82 default:
83 if (Rhs==0) /* Delete current object */
84 {
85 hdl = (unsigned long) sciGetHandle(sciGetCurrentObj());
86 }
87 else
88 {
89 // Overload
90 lw = 1 + Top - Rhs;
91 C2F(overload)(&lw,"delete",6);
92 return 0;
93 }
94 break;
95 }
96
97 for(i=0;i<nb_handles; i++)
98 {
99 hdl = (unsigned long)*hstk(l1+i); /* Puts the value of the Handle to hdl */
108 100
109 parentFigure = sciGetParentFigure(pobj); 101 pobj = sciGetPointerFromHandle(hdl);
110 102
111 num = sciGetNumFigure( pobj ) ; 103 if (pobj == NULL)
112 104 {
113 if ((Rhs == 2) && (strcmp(cstk(l2),"callback") == 0)) 105 Scierror(999,_("%s: The handle is not valid.\n"),fname);
114 { 106 return 0;
115 startFigureDataWriting(parentFigure); 107 }
116 sciDelCallback((sciPointObj *)pobj); 108
117 endFigureDataWriting(parentFigure); 109 parentFigure = sciGetParentFigure(pobj);
118 } 110
119 else 111 num = sciGetNumFigure( pobj ) ;
120 { 112
121 113 if ((Rhs == 2) && (strcmp(cstk(l2),"callback") == 0))
122 sciEntityType objType = sciGetEntityType( pobj ) ; 114 {
123 115 startFigureDataWriting(parentFigure);
124 if (objType == SCI_UIMENU) 116 sciDelCallback((sciPointObj *)pobj);
125 { 117 endFigureDataWriting(parentFigure);
126 DestroyUimenu(pobj); 118 }
127 } 119 else
128 else if(objType == SCI_UICONTROL) 120 {
129 { 121
130 DestroyUicontrol(pobj); 122 sciEntityType objType = sciGetEntityType( pobj ) ;
131 } 123
132 else if (objType == SCI_WAITBAR || objType == SCI_PROGRESSIONBAR) 124 if (objType == SCI_UIMENU)
133 { 125 {
134 DestroyWaitBar(pobj); 126 DestroyUimenu(pobj);
135 } 127 }
136 else if ( sciGetParentFigure(pobj) != NULL && objType != SCI_FIGURE) 128 else if(objType == SCI_UICONTROL)
137 { 129 {
138 BOOL selected = sciGetIsSelected( pobj ) ; 130 DestroyUicontrol(pobj);
139 sciPointObj * parentObj = sciGetParent(pobj); 131 }
140 startFigureDataWriting(parentFigure); 132 else if (objType == SCI_WAITBAR || objType == SCI_PROGRESSIONBAR)
141 if (sciIsCurrentObject(pobj)) 133 {
142 { 134 DestroyWaitBar(pobj);
143 /* If the object is the current one, modify the current object pointer */ 135 }
144 sciSetCurrentObj(parentObj) ; /* A LAISSER F.Leray 25.03.04*/ 136 else if ( sciGetParentFigure(pobj) != NULL && objType != SCI_FIGURE)
145 } 137 {
146 sciDelGraphicObj( pobj ) ; /* don't use pobj after this point */ 138 BOOL selected = sciGetIsSelected( pobj ) ;
147 pobj = NULL ; 139 sciPointObj * parentObj = sciGetParent(pobj);
148 140 startFigureDataWriting(parentFigure);
149 /* test here: we could have deleted the selected subwindow, we must choose an other */ 141 if (sciIsCurrentObject(pobj))
150 /* We must always have one selected subwindow (if at least one subwindow exists) */ 142 {
151 if ( objType == SCI_SUBWIN && selected ) 143 /* If the object is the current one, modify the current object pointer */
152 { 144 sciSetCurrentObj(parentObj) ; /* A LAISSER F.Leray 25.03.04*/
153 /* we have to select antoher subwindow if one exists at least */ 145 }
154 sciSelectFirstSubwin( parentFigure ) ; 146 sciDelGraphicObj( pobj ) ; /* don't use pobj after this point */
155 } 147 pobj = NULL ;
156 148
157 endFigureDataWriting(parentFigure); 149 /* test here: we could have deleted the selected subwindow, we must choose an other */
158 150 /* We must always have one selected subwindow (if at least one subwindow exists) */
159 /* redraw the window */ 151 if ( objType == SCI_SUBWIN && selected )
160 sciDrawObj( parentObj ) ; 152 {
161 } 153 /* we have to select antoher subwindow if one exists at least */
162 else if( sciGetEntityType(pobj) == SCI_FIGURE ) /* F.Leray 13.04.04: We delete the special object Figure !!*/ 154 sciSelectFirstSubwin( parentFigure ) ;
163 { 155 }
164 sciDeleteWindow( num ); 156
165 } 157 endFigureDataWriting(parentFigure);
166 158
167 } 159 /* redraw the window */
160 sciDrawObj( parentObj ) ;
161 }
162 else if( sciGetEntityType(pobj) == SCI_FIGURE ) /* F.Leray 13.04.04: We delete the special object Figure !!*/
163 {
164 sciDeleteWindow( num );
165 }
166 }
167 }
168 168
169 // Overload
170 lw = 1 + Top - Rhs;
171 C2F(overload)(&lw,"delete",6);
169 //LhsVar(1) = 0; 172 //LhsVar(1) = 0;
170 //C2F(putlhsvar)(); 173 //C2F(putlhsvar)();
171 174
172 C2F(overload)(&lw,"delete",6);
173
174 return 0; 175 return 0;
175} 176}