Ejemplo n.º 1
0
Widget createView (String fileName,
	Widget parent,
	Arg args[],
	int nargs)
{
  Widget result;
  char   widgetName[255];
  Arg    list[32];
  int    err, loop, nlist;
  char   msg[256];

  /* Read in grid to be viewed */
  strcpy(theView.fileName, fileName);
  theView.grid = CreateGMTGrid();
  Trace("Reading grid file...");
  ReadGridFromFile((Grid *)theView.grid, fileName, &err);
  if (err) {
    sprintf(msg, "Unable to read file %s: C error code %d", fileName, err);
    XtError(msg);
  }
  
  /* Create scrolling view widget */
  /* Copy supplied resources */
  for (loop = 0; loop < nargs; loop ++)
    list[loop] = args[loop];
  nlist = nargs;
  XtSetArg(list[nlist], XtNwidth, 640); nlist ++;
  XtSetArg(list[nlist], XtNheight, 480); nlist ++;
  result = XtCreateManagedWidget("view", pannerWidgetClass, parent, list, nlist);

  /* Derive widget name from grid file */
  getBaseName(fileName, widgetName);
  nlist = 0;
  XtSetArg(list[nlist], XtNgrid, theView.grid); nlist ++;
  /* Purists avert eyes...hardcoded dimensions follow */
  XtSetArg(list[nlist], XtNwidth, 640); nlist ++;
  XtSetArg(list[nlist], XtNheight, 480); nlist ++;
  theView.canvas = createTextView(widgetName, result, list, nlist);
  XtSetPannerCanvas(result, theView.canvas);

  /* Register exit action */
  addQuitCallback(saveChanges, &theView);
  
  return result;
}
Ejemplo n.º 2
0
int main(int argc,char *argv[])
{

	GtkWidget *mainWindow;
	GtkWidget *mainVBox;
	GtkWidget *menuBar;
	GtkWidget *scrolledWindow;
	GtkWidget *textView;
	GtkWidget *toolBar;
	GtkWidget *statusBar;
	GtkTextBuffer *buf;


	gtk_init (&argc,&argv);

	mainWindow		= createWindow ("SimpleEditor",800,500,GTK_WIN_POS_CENTER);
	mainVBox		= gtk_vbox_new (FALSE,0);
	statusBar		= createStatusBar ();
	textView		= createTextView (statusBar);
	scrolledWindow  = gtk_scrolled_window_new (NULL,NULL);
	menuBar			= createMenuBar (textView,mainWindow);
	buf				= gtk_text_view_get_buffer(GTK_TEXT_VIEW(textView));
	toolBar			= createToolBar (textView);

	g_signal_connect(buf,"changed",G_CALLBACK(buffer_text_changed),NULL);
	g_signal_connect(G_OBJECT(mainWindow),"delete-event",G_CALLBACK(mainWindowDeleteEvent),(gpointer)textView);

	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(scrolledWindow),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);

	gtk_container_add (GTK_CONTAINER(mainWindow),mainVBox);
	gtk_box_pack_start (GTK_BOX(mainVBox),menuBar,FALSE,FALSE,0);
	gtk_box_pack_start (GTK_BOX(mainVBox),toolBar,FALSE,FALSE,0);
	gtk_box_pack_start (GTK_BOX(mainVBox),scrolledWindow,TRUE,TRUE,0);
	gtk_box_pack_start (GTK_BOX(mainVBox),statusBar,FALSE,FALSE,0);
	gtk_container_add (GTK_CONTAINER(scrolledWindow),textView);
	
	gtk_widget_show_all(mainWindow);
		
	gtk_main ();
	return 0;
}
Ejemplo n.º 3
0
void DropDownMenu::init_menu_view(int text_size_) {
    
    
    // Init main view
    resize(get_w(), text_size_ + vertical_padding*2);
    text_size = text_size_;
    selected_entry_idx = 0;
    menu = 0; clicked = false;
    
    set_clear_color(green_color_c);
    fill_with_color(get_clear_color());
    

    // Init menu view
    
    int row_size = (text_size + vertical_padding*2);
    menu = new View(get_w(), (int)(entries.size() ? entries.size() : 1) * row_size);
    
    // always display at least one entry
    menu->draw_onto_self(GUIImage("GUIImages/dropdown_row.bmp"), DispPoint());

    // display full menu
    int i = 0;
    for (list<string>::iterator it = entries.begin(); it != entries.end(); ++it, ++i) {
        
//        menu->attach_subview(new MenuEntry(*it, text_size, *this, i),
//                                                    DispPoint(0, i * row_size));
        
        menu->draw_onto_self(GUIImage("GUIImages/dropdown_row.bmp"),
                             DispPoint(0, i * row_size));

        menu->attach_subview(createTextView(*it, text_size),
                                                    DispPoint(0, i * row_size));

    }
    
    attach_subview(menu, DispPoint());
    
}