~ubuntu-branches/ubuntu/breezy/tiemu/breezy

« back to all changes in this revision

Viewing changes to src/gui/gtk/main_wnd.c

  • Committer: Bazaar Package Importer
  • Author(s): Julien BLACHE
  • Date: 2005-06-02 16:50:15 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050602165015-59ab24414tl2wzol
Tags: 1.99+svn1460-1
* New snapshot.
* debian/control:
  + Updated build-depends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*  gtktiemu - a TI89/92/92+ emulator
2
 
 *  (c) Copyright 2000-2001, Romain Lievin and Thomas Corvazier
3
 
 *
4
 
 *  This program is free software; you can redistribute it and/or modify
5
 
 *  it under the terms of the GNU General Public License as published by
6
 
 *  the Free Software Foundation; either version 2 of the License, or
7
 
 *  (at your option) any later version.
8
 
 *
9
 
 *  This program is distributed in the hope that it will be useful,
10
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
 *  GNU General Public License for more details.
13
 
 *
14
 
 *  You should have received a copy of the GNU General Public License
15
 
 *  along with this program; if not, write to the Free Software
16
 
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
 
 */
18
 
 
19
 
#ifdef HAVE_CONFIG_H
20
 
#include <config.h>
21
 
#endif
22
 
 
23
 
#include <gtk/gtk.h>
24
 
 
25
 
#ifndef __WIN32__
26
 
# include <SDL/SDL.h>
27
 
#else
28
 
# include "D:\devel\tiemu_project\SDL-1.2.4\include\SDL.h"
29
 
#endif
30
 
 
31
 
#include "../gtk/tiemu_cb.h"
32
 
#include "../gtk/refresh.h"
33
 
 
34
 
int halt(void);
35
 
 
36
 
static GtkWidget *window;
37
 
 
38
 
/* 
39
 
   Display a popup menu: entry point used by ticalc.c (SDL)
40
 
*/
41
 
void hid_popup_menu(SDL_MouseButtonEvent event)
42
 
{
43
 
  halt();
44
 
  gtk_menu_popup(GTK_MENU(display_popup_menu()),
45
 
                 NULL, NULL, NULL, NULL,
46
 
                 event.button,
47
 
                 -897199374); // cannot pass time
48
 
}
49
 
 
50
 
 
51
 
/* 
52
 
   GTK callback: displays a popup menu if the auxiliary 
53
 
   window has been enabled (#define EXT_WIN). Used by GTK.
54
 
*/
55
 
gboolean
56
 
button_press_event        (GtkWidget       *widget,
57
 
                           GdkEventButton  *event,
58
 
                           gpointer         user_data)
59
 
{
60
 
  GtkWidget *menu;
61
 
 
62
 
  if(event->button == 3)
63
 
    {
64
 
      halt();
65
 
      menu = display_popup_menu();
66
 
      gtk_widget_grab_focus(menu);
67
 
      gdk_event_get();
68
 
      gtk_menu_popup(GTK_MENU(menu), 
69
 
                     NULL, NULL, NULL, NULL, 
70
 
                     event->button, event->time);
71
 
    }
72
 
  
73
 
  return FALSE;
74
 
}
75
 
 
76
 
/* 
77
 
   The GTK auxiliary window: may not be shown but used for 
78
 
   using GTK with SDL.
79
 
   A better way should be to use a GtkSDL plugin...
80
 
*/
81
 
int gtk_main_window(void)
82
 
{
83
 
  GtkWidget *eventbox;
84
 
  GtkWidget *label;
85
 
  
86
 
  /* The main window */
87
 
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
88
 
  gtk_window_set_title (GTK_WINDOW (window), "GtkTiEmu");
89
 
  gtk_widget_set_usize(window, 250, 50);
90
 
 
91
 
  /* The event box */
92
 
  eventbox = gtk_event_box_new ();
93
 
  gtk_container_add (GTK_CONTAINER (window), eventbox);
94
 
  GTK_WIDGET_SET_FLAGS (eventbox, GTK_CAN_FOCUS);
95
 
  GTK_WIDGET_SET_FLAGS (eventbox, GTK_CAN_DEFAULT);
96
 
  gtk_widget_set_events (eventbox, GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK);
97
 
  gtk_widget_show (eventbox);
98
 
 
99
 
  label = gtk_label_new ("Click here to display a menu");
100
 
  gtk_container_add (GTK_CONTAINER (eventbox), label);
101
 
  gtk_widget_show (label);
102
 
  
103
 
  gtk_signal_connect (GTK_OBJECT (window), "destroy",
104
 
                      GTK_SIGNAL_FUNC (gtk_main_quit),
105
 
                      NULL);
106
 
  gtk_signal_connect (GTK_OBJECT (eventbox), "button_press_event",
107
 
                      GTK_SIGNAL_FUNC (button_press_event),
108
 
                      NULL);
109
 
 
110
 
  //gtk_widget_grab_focus (eventbox);
111
 
  gtk_widget_grab_default (eventbox);
112
 
 
113
 
#ifdef EXT_WIN  
114
 
  gtk_widget_show_all(window);
115
 
#endif
116
 
 
117
 
  return 0;
118
 
}