Add libwx-perl
[pkg-perl] / deb-src / libwx-perl / libwx-perl-0.96 / XS / Menu.xs
1 #############################################################################
2 ## Name:        XS/Menu.xs
3 ## Purpose:     XS for Wx::Menu, Wx::MenuBar, Wx::MenuItem
4 ## Author:      Mattia Barbon
5 ## Modified by:
6 ## Created:     29/10/2000
7 ## RCS-ID:      $Id: Menu.xs 2315 2008-01-18 21:47:17Z mbarbon $
8 ## Copyright:   (c) 2000-2004, 2006-2008 Mattia Barbon
9 ## Licence:     This program is free software; you can redistribute it and/or
10 ##              modify it under the same terms as Perl itself
11 #############################################################################
12
13 #include <wx/menu.h>
14
15 MODULE=Wx PACKAGE=Wx::Menu
16
17 wxMenu*
18 wxMenu::new( title = wxEmptyString, style = 0)
19     wxString title
20     long style
21
22 #if WXPERL_W_VERSION_GE( 2, 7, 0 )
23
24 wxMenuItem*
25 wxMenu::AppendSubMenu( submenu, text, help = wxEmptyString )
26     wxMenu* submenu
27     wxString text
28     wxString help
29
30 #endif
31
32 void
33 wxMenu::AppendString( id, item = wxEmptyString, help = wxEmptyString, kind = wxITEM_NORMAL )
34     int id
35     wxString item
36     wxString help
37     wxItemKind kind
38   PPCODE:
39 #if WXPERL_W_VERSION_GE( 2, 5, 1 )
40     XPUSHs( wxPli_object_2_sv( aTHX_ sv_newmortal(),
41             THIS->Append( id, item, help, kind ) ) );
42 #else
43     THIS->Append( id, item, help, kind );
44 #endif
45
46 void
47 wxMenu::AppendSubMenu_( id, item, subMenu, helpString = wxEmptyString )
48     int id
49     wxString item
50     wxMenu* subMenu
51     wxString helpString
52   PPCODE:
53 #if WXPERL_W_VERSION_GE( 2, 5, 1 )
54     XPUSHs( wxPli_object_2_sv( aTHX_ sv_newmortal(),
55             THIS->Append( id, item, subMenu, helpString ) ) );
56 #else
57     THIS->Append( id, item, subMenu, helpString );
58 #endif
59
60 void
61 wxMenu::AppendItem( menuItem )
62     wxMenuItem* menuItem
63   PPCODE:
64 #if WXPERL_W_VERSION_GE( 2, 5, 1 )
65     XPUSHs( wxPli_object_2_sv( aTHX_ sv_newmortal(),
66             THIS->Append( menuItem ) ) );
67 #else
68     THIS->Append( menuItem );
69 #endif
70
71 void
72 wxMenu::AppendCheckItem( id, item, helpString = wxEmptyString )
73     int id
74     wxString item
75     wxString helpString
76   PPCODE:
77 #if WXPERL_W_VERSION_GE( 2, 5, 1 )
78     XPUSHs( wxPli_object_2_sv( aTHX_ sv_newmortal(),
79             THIS->AppendCheckItem( id, item, helpString ) ) );
80 #else
81     THIS->AppendCheckItem( id, item, helpString );
82 #endif
83
84 void
85 wxMenu::AppendRadioItem( id, item, helpString = wxEmptyString )
86     int id
87     wxString item
88     wxString helpString
89   PPCODE:
90 #if WXPERL_W_VERSION_GE( 2, 5, 1 )
91     XPUSHs( wxPli_object_2_sv( aTHX_ sv_newmortal(),
92             THIS->AppendRadioItem( id, item, helpString ) ) );
93 #else
94     THIS->AppendRadioItem( id, item, helpString );
95 #endif
96
97 void
98 wxMenu::AppendSeparator()
99   PPCODE:
100 #if WXPERL_W_VERSION_GE( 2, 5, 1 )
101     XPUSHs( wxPli_object_2_sv( aTHX_ sv_newmortal(),
102             THIS->AppendSeparator() ) );
103 #else
104     THIS->AppendSeparator();
105 #endif
106
107 void
108 wxMenu::Break()
109
110 void
111 wxMenu::Check( id, check )
112     int id
113     bool check
114
115 void
116 wxMenu::DeleteId( id )
117     int id
118   CODE:
119     THIS->Delete( id );
120
121 void
122 wxMenu::DeleteItem( item )
123     wxMenuItem* item
124   CODE:
125     THIS->Delete( item );
126
127 void
128 wxMenu::DestroyMenu()
129   CODE:
130     delete THIS;
131
132 void
133 wxMenu::DestroyId( id )
134     int id
135   CODE:
136     THIS->Destroy( id );
137
138 void
139 wxMenu::DestroyItem( item )
140     wxMenuItem* item
141   CODE:
142     THIS->Destroy( item );
143
144 void
145 wxMenu::Enable( id, enable )
146     int id
147     bool enable
148
149 #if WXPERL_W_VERSION_GE( 2, 5, 1 )
150
151 wxMenuItem*
152 wxMenu::FindItemByPosition( pos )
153     size_t pos
154
155 #endif
156
157 void
158 wxMenu::FindItem( item )
159     SV* item
160   PPCODE:
161     if( looks_like_number( item ) ) {
162       int id = SvIV( item );
163       wxMenu* submenu;
164       wxMenuItem* ret;
165
166       ret = THIS->FindItem( id, &submenu );
167
168       SV* mi = sv_newmortal();
169
170       if( GIMME_V == G_ARRAY ) {
171         EXTEND( SP, 2 );
172         SV* sm = sv_newmortal();
173
174         PUSHs( wxPli_object_2_sv( aTHX_ mi, ret ) );
175         PUSHs( wxPli_object_2_sv( aTHX_ sm, submenu ) );
176       }
177       else {
178         EXTEND( SP, 1 );
179         PUSHs( wxPli_object_2_sv( aTHX_ mi, ret ) );
180       }
181     }
182     else {
183       wxString string;
184       WXSTRING_INPUT( string, const char*, item );
185       int id = THIS->FindItem( string );
186
187       EXTEND( SP, 1 );
188       PUSHs( sv_2mortal( newSViv( id ) ) );
189     }
190
191 wxString
192 wxMenu::GetHelpString( id )
193     int id
194
195 wxString
196 wxMenu::GetLabel( id )
197     int id
198
199 #if WXPERL_W_VERSION_GE( 2, 8, 5 )
200
201 wxString
202 wxMenu::GetLabelText( id )
203     int id
204
205 #endif
206
207 int
208 wxMenu::GetMenuItemCount()
209
210 void
211 wxMenu::GetMenuItems()
212   PPCODE:
213     wxMenuItemList& data = THIS->GetMenuItems();
214     wxMenuItemList::compatibility_iterator node;
215  
216     EXTEND( SP, (IV) data.GetCount() );
217     for( node = data.GetFirst(); node; node = node->GetNext() )
218     {
219       PUSHs( wxPli_object_2_sv( aTHX_ sv_newmortal(), node->GetData() ) );
220     }
221
222 wxString
223 wxMenu::GetTitle()
224
225 void
226 wxMenu::InsertItem( pos, item )
227     int pos
228     wxMenuItem* item
229   PPCODE:
230 #if WXPERL_W_VERSION_GE( 2, 5, 1 )
231     XPUSHs( wxPli_object_2_sv( aTHX_ sv_newmortal(),
232             THIS->Insert( pos, item ) ) );
233 #else
234     XPUSHs( THIS->Insert( pos, item ) ? &PL_sv_yes : &PL_sv_no );
235 #endif
236
237 void
238 wxMenu::InsertString( pos, id, item = wxEmptyString, helpString = wxEmptyString, kind = wxITEM_NORMAL )
239     int pos
240     int id
241     wxString item
242     wxString helpString
243     wxItemKind kind
244   PPCODE:
245 #if WXPERL_W_VERSION_GE( 2, 5, 1 )
246     XPUSHs( wxPli_object_2_sv( aTHX_ sv_newmortal(),
247             THIS->Insert( pos, id, item, helpString, kind ) ) );
248 #else
249     THIS->Insert( pos, id, item, helpString, kind );
250 #endif
251
252 void
253 wxMenu::InsertSubMenu( pos, id, text, submenu, help = wxEmptyString )
254     int pos
255     int id
256     wxString text
257     wxMenu* submenu
258     wxString help
259   PPCODE:
260 #if WXPERL_W_VERSION_GE( 2, 5, 1 )
261     XPUSHs( wxPli_object_2_sv( aTHX_ sv_newmortal(),
262             THIS->Insert( pos, id, text, submenu, help ) ) );
263 #else
264     THIS->Insert( pos, id, text, submenu, help );
265 #endif
266
267 void
268 wxMenu::InsertCheckItem( pos, id, item, helpString )
269      size_t pos
270      int id
271      wxString item
272      wxString helpString
273   PPCODE:
274 #if WXPERL_W_VERSION_GE( 2, 5, 1 )
275     XPUSHs( wxPli_object_2_sv( aTHX_ sv_newmortal(),
276             THIS->InsertCheckItem( pos, id, item, helpString ) ) );
277 #else
278     THIS->InsertCheckItem( pos, id, item, helpString );
279 #endif
280
281 void
282 wxMenu::InsertRadioItem( pos, id, item, helpString )
283      size_t pos
284      int id
285      wxString item
286      wxString helpString
287   PPCODE:
288 #if WXPERL_W_VERSION_GE( 2, 5, 1 )
289     XPUSHs( wxPli_object_2_sv( aTHX_ sv_newmortal(),
290             THIS->InsertRadioItem( pos, id, item, helpString ) ) );
291 #else
292     THIS->InsertRadioItem( pos, id, item, helpString );
293 #endif
294
295 void
296 wxMenu::InsertSeparator( pos )
297     size_t pos
298   PPCODE:
299 #if WXPERL_W_VERSION_GE( 2, 5, 1 )
300     XPUSHs( wxPli_object_2_sv( aTHX_ sv_newmortal(),
301             THIS->InsertSeparator( pos ) ) );
302 #else
303     THIS->InsertSeparator( pos );
304 #endif
305
306 bool
307 wxMenu::IsChecked( id )
308     int id
309
310 bool
311 wxMenu::IsEnabled( id )
312     int id
313
314 void
315 wxMenu::PrependString( id, item = wxEmptyString, help = wxEmptyString, kind = wxITEM_NORMAL )
316     int id
317     wxString item
318     wxString help
319     wxItemKind kind
320   PPCODE:
321 #if WXPERL_W_VERSION_GE( 2, 5, 1 )
322     XPUSHs( wxPli_object_2_sv( aTHX_ sv_newmortal(),
323             THIS->Prepend( id, item, help, kind ) ) );
324 #else
325     THIS->Prepend( id, item, help, kind );
326 #endif
327
328 void
329 wxMenu::PrependItem( menuItem )
330     wxMenuItem* menuItem
331   CODE:
332 #if WXPERL_W_VERSION_GE( 2, 5, 1 )
333     XPUSHs( wxPli_object_2_sv( aTHX_ sv_newmortal(),
334             THIS->Prepend( menuItem ) ) );
335 #else
336     THIS->Prepend( menuItem );
337 #endif
338
339 void
340 wxMenu::PrependSubMenu( id, item, subMenu, helpString = wxEmptyString )
341     int id
342     wxString item
343     wxMenu* subMenu
344     wxString helpString
345   CODE:
346 #if WXPERL_W_VERSION_GE( 2, 5, 1 )
347     XPUSHs( wxPli_object_2_sv( aTHX_ sv_newmortal(),
348             THIS->Prepend( id, item, subMenu, helpString ) ) );
349 #else
350     THIS->Prepend( id, item, subMenu, helpString );
351 #endif
352
353 void
354 wxMenu::PrependCheckItem( id, item, helpString = wxEmptyString )
355     int id
356     wxString item
357     wxString helpString
358   PPCODE:
359 #if WXPERL_W_VERSION_GE( 2, 5, 1 )
360     XPUSHs( wxPli_object_2_sv( aTHX_ sv_newmortal(),
361             THIS->PrependCheckItem( id, item, helpString ) ) );
362 #else
363    THIS->PrependCheckItem( id, item, helpString );
364 #endif
365
366 void
367 wxMenu::PrependRadioItem( id, item, helpString = wxEmptyString )
368     int id
369     wxString item
370     wxString helpString
371   PPCODE:
372 #if WXPERL_W_VERSION_GE( 2, 5, 1 )
373     XPUSHs( wxPli_object_2_sv( aTHX_ sv_newmortal(),
374             THIS->PrependRadioItem( id, item, helpString ) ) );
375 #else
376     THIS->PrependRadioItem( id, item, helpString );
377 #endif
378
379 void
380 wxMenu::PrependSeparator()
381   PPCODE:
382 #if WXPERL_W_VERSION_GE( 2, 5, 1 )
383     XPUSHs( wxPli_object_2_sv( aTHX_ sv_newmortal(),
384             THIS->PrependSeparator() ) );
385 #else
386     THIS->PrependSeparator();
387 #endif
388
389 wxMenuItem*
390 wxMenu::RemoveId( id )
391     int id
392   CODE:
393     RETVAL = THIS->Remove( id );
394   OUTPUT:
395     RETVAL
396
397 wxMenuItem*
398 wxMenu::RemoveItem( item )
399     wxMenuItem* item
400   CODE:
401     RETVAL = THIS->Remove( item );
402   OUTPUT:
403     RETVAL
404
405 void
406 wxMenu::SetHelpString( id, helpString )
407     int id
408     wxString helpString
409
410 void
411 wxMenu::SetLabel( id, label )
412     int id
413     wxString label
414
415 void
416 wxMenu::SetTitle( title )
417     wxString title
418
419 void
420 wxMenu::UpdateUI( source = 0 )
421     wxEvtHandler* source
422
423 MODULE=Wx PACKAGE=Wx::MenuBar
424
425 wxMenuBar*
426 wxMenuBar::new( style = 0 )
427     long style
428
429 bool
430 wxMenuBar::Append( menu, title )
431     wxMenu* menu
432     wxString title
433
434 void
435 wxMenuBar::Check( id, check )
436     int id
437     bool check
438
439 void
440 wxMenuBar::Enable( id, enable )
441     int id
442     bool enable
443
444 void
445 wxMenuBar::EnableTop( pos, enable )
446     int pos
447     bool enable
448
449 void
450 wxMenuBar::FindItem( id )
451     int id
452   PPCODE:
453     wxMenu* submenu;
454     wxMenuItem* ret;
455
456     ret = THIS->FindItem( id, &submenu );
457
458     SV* mi = sv_newmortal();
459
460     if( GIMME_V == G_ARRAY ) {
461       EXTEND( SP, 2 );
462       SV* sm = sv_newmortal();
463
464       PUSHs( wxPli_object_2_sv( aTHX_ mi, ret ) );
465       PUSHs( wxPli_object_2_sv( aTHX_ sm, submenu ) );
466     }
467     else {
468       EXTEND( SP, 1 );
469       PUSHs( wxPli_object_2_sv( aTHX_ mi, ret ) );
470     }
471
472 int
473 wxMenuBar::FindMenu( title )
474     wxString title
475
476 int
477 wxMenuBar::FindMenuItem( menuString, itemString )
478     wxString menuString
479     wxString itemString
480
481 wxString
482 wxMenuBar::GetHelpString( id )
483     int id
484
485 wxString
486 wxMenuBar::GetLabel( id )
487     int id
488
489 #if !WXPERL_W_VERSION_GE( 2, 9, 0 ) || WXWIN_COMPATIBILITY_2_8
490
491 wxString
492 wxMenuBar::GetLabelTop( id )
493     int id
494
495 #endif
496
497 #if WXPERL_W_VERSION_GE( 2, 8, 5 )
498
499 wxString
500 wxMenuBar::GetMenuLabel( id )
501     int id
502
503 wxString
504 wxMenuBar::GetMenuLabelText( id )
505     int id
506
507 #endif
508
509 wxMenu*
510 wxMenuBar::GetMenu( index )
511     int index
512
513 int
514 wxMenuBar::GetMenuCount()
515
516 bool
517 wxMenuBar::Insert( pos, menu, title )
518     int pos
519     wxMenu* menu
520     wxString title
521
522 bool
523 wxMenuBar::IsChecked( id )
524     int id
525
526 bool
527 wxMenuBar::IsEnabled( id )
528     int id
529
530 void
531 wxMenuBar::Refresh()
532
533 wxMenu*
534 wxMenuBar::Remove( pos )
535     int pos
536
537 wxMenu*
538 wxMenuBar::Replace( pos, menu, title )
539     int pos
540     wxMenu* menu
541     wxString title
542
543 void
544 wxMenuBar::SetHelpString( id, helpString )
545     int id
546     wxString helpString
547
548 void
549 wxMenuBar::SetLabel( id, label )
550     int id
551     wxString label
552
553 #if !WXPERL_W_VERSION_GE( 2, 9, 0 ) || WXWIN_COMPATIBILITY_2_8
554
555 void
556 wxMenuBar::SetLabelTop( pos, label )
557     int pos
558     wxString label
559
560 #endif
561
562 #if WXPERL_W_VERSION_GE( 2, 8, 5 )
563
564 void
565 wxMenuBar::SetMenuLabel( pos, label )
566     int pos
567     wxString label
568
569 #endif
570
571 bool
572 wxMenuBar::IsEnabledTop( id )
573     int id
574
575 MODULE=Wx PACKAGE=Wx::MenuItem
576
577 wxMenuItem*
578 wxMenuItem::new( parentMenu = 0, id = wxID_ANY, text = wxEmptyString, helpString = wxEmptyString, itemType = wxITEM_NORMAL, subMenu = 0 )
579      wxMenu* parentMenu
580      int id
581      wxString text
582      wxString helpString
583      wxItemKind itemType
584      wxMenu* subMenu
585
586 void
587 wxMenuItem::Check( check )
588     bool check
589
590 # void
591 # wxMenuItem::DeleteSubMenu()
592
593 void
594 wxMenuItem::Enable( enable )
595     bool enable
596
597 #if defined( __WXMSW__ ) && !defined( __WXWINCE__ )
598
599 wxColour*
600 wxMenuItem::GetBackgroundColour()
601   CODE:
602     RETVAL = new wxColour( THIS->GetBackgroundColour() );
603   OUTPUT:
604    RETVAL
605
606 wxFont*
607 wxMenuItem::GetFont()
608   CODE:
609     RETVAL = new wxFont( THIS->GetFont() );
610   OUTPUT:
611     RETVAL
612
613 #endif
614
615 #if ( defined( __WXMSW__ ) && !defined( __WXWINCE__ ) ) || \
616     defined( __WXGTK__ )
617
618 wxBitmap*
619 wxMenuItem::GetBitmap()
620   CODE:
621     RETVAL = new wxBitmap( THIS->GetBitmap() );
622   OUTPUT:
623     RETVAL
624
625 #endif
626
627 wxString
628 wxMenuItem::GetHelp()
629
630 #if WXPERL_W_VERSION_LT( 2, 9, 0 ) && !defined(__WXMSW__)
631
632 wxString
633 wxMenuItem::GetName()
634
635 #endif
636
637 int
638 wxMenuItem::GetId()
639
640 wxItemKind
641 wxMenuItem::GetKind()
642
643 #if !WXPERL_W_VERSION_GE( 2, 9, 0 ) || WXWIN_COMPATIBILITY_2_8
644
645 wxString
646 wxMenuItem::GetLabel()
647
648 wxString
649 GetLabelFromText( text )
650     wxString text
651   CODE:
652     RETVAL = wxMenuItem::GetLabelFromText( text );
653   OUTPUT:
654     RETVAL
655
656 #endif
657
658 #if WXPERL_W_VERSION_GE( 2, 9, 0 )
659
660 wxString
661 wxMenuItem::GetItemLabel()
662
663 wxString
664 wxMenuItem::GetItemLabelText()
665
666 wxString
667 GetLabelText( text )
668     wxString text
669   CODE:
670     RETVAL = wxMenuItem::GetLabelText( text );
671   OUTPUT:
672     RETVAL
673
674 #endif
675
676 wxMenu*
677 wxMenuItem::GetMenu()
678
679 #if defined( __WXMSW__ ) && !defined( __WXWINCE__ )
680
681 int
682 wxMenuItem::GetMarginWidth()
683
684 #endif
685
686 #if !WXPERL_W_VERSION_GE( 2, 9, 0 ) || WXWIN_COMPATIBILITY_2_8
687
688 wxString
689 wxMenuItem::GetText()
690
691 #endif
692
693 wxMenu*
694 wxMenuItem::GetSubMenu()
695
696 #if defined( __WXMSW__ ) && !defined( __WXWINCE__ )
697
698 wxColour*
699 wxMenuItem::GetTextColour()
700   CODE:
701     RETVAL = new wxColour( THIS->GetTextColour() );
702   OUTPUT:
703     RETVAL
704
705 #endif 
706
707 bool
708 wxMenuItem::IsCheckable()
709
710 bool
711 wxMenuItem::IsChecked()
712
713 bool
714 wxMenuItem::IsEnabled()
715
716 bool
717 wxMenuItem::IsSeparator()
718
719 bool 
720 wxMenuItem::IsSubMenu()
721
722 #if defined( __WXMSW__ ) && !defined( __WXWINCE__ )
723
724 void
725 wxMenuItem::SetBackgroundColour( colour )
726     wxColour* colour
727   CODE:
728     THIS->SetBackgroundColour( *colour );
729
730 void
731 wxMenuItem::SetFont( font )
732     wxFont* font
733   CODE:
734     THIS->SetFont( *font );
735
736 #endif
737
738 void
739 wxMenuItem::SetHelp( helpString )
740     wxString helpString
741
742 void 
743 wxMenuItem::SetMenu( menu )
744     wxMenu* menu
745
746 void 
747 wxMenuItem::SetSubMenu( menu )
748     wxMenu* menu
749
750 #if !WXPERL_W_VERSION_GE( 2, 9, 0 ) || WXWIN_COMPATIBILITY_2_8
751
752 void
753 wxMenuItem::SetText( text )
754     wxString text
755
756 #endif
757
758 #if WXPERL_W_VERSION_GE( 2, 9, 0 )
759
760 void
761 wxMenuItem::SetItemLabel( label )
762     wxString label
763
764 #endif
765
766 #if defined( __WXMSW__ ) && !defined( __WXWINCE__ )
767
768 void
769 wxMenuItem::SetMarginWidth( width )
770     int width
771
772 # void
773 # wxMenuItem::SetName( text )
774 #     wxString text
775
776 void
777 wxMenuItem::SetTextColour( colour )
778     wxColour* colour
779   CODE:
780     THIS->SetTextColour( *colour );
781
782 void
783 wxMenuItem::SetBitmaps( checked, unchecked = (wxBitmap*)&wxNullBitmap )
784     wxBitmap* checked
785     wxBitmap* unchecked
786   CODE:
787     THIS->SetBitmaps( *checked, *unchecked );
788
789 #endif
790
791 #if ( defined( __WXMSW__ ) && !defined( __WXWINCE__ ) ) || \
792     defined( __WXGTK__ )
793
794 void
795 wxMenuItem::SetBitmap( bitmap )
796     wxBitmap* bitmap
797   CODE:
798     THIS->SetBitmap( *bitmap );
799
800 #endif