Пример #1
0
EDEFont fl_font_dialog(EDEFont current_font) 
{
	EDEFont return_font;

	create_the_forms();
	int numfonts = fl_list_fonts(all_fonts);

	// populate list of fonts
	Fl_String currentname = current_font.font->name();
	for(int i = 0; i < numfonts; i++) {
		Fl_String fontname = all_fonts[i]->name();
		fontobj->add(fontname);
 		if (currentname.lower_case().pos(fontname.lower_case())==0) // it's a substring
			fontobj->value(i);
	}

	// set bold, italic
	if (currentname.pos(" bold italic") == currentname.length()-12) {
		bold_button->value(true);
		italic_button->value(true);
	} else if (currentname.pos(" italic") == currentname.length()-7) {
		italic_button->value(true);
	} else if (currentname.pos(" bold") == currentname.length()-5) {
		bold_button->value(true);
	}

	// populate other lists
	textobj->encoding = current_font.encoding; // TODO: what if we're using XFT?
	font_cb(fontobj,0);
	for (int i=0; i < sizeobj->children(); i++) {
		if (atoi(sizeobj->text(i)) == current_font.size) {
			sizeobj->value(i);
			size_cb(sizeobj,0);
		}
	}

	form->exec();
	form->show();

	// we have to construct a proper EDEFont to return
	return_font.defined = false;
	if (return_value)
	{
		return_font.font = fl_find_font(fontobj->text(fontobj->value()));
		if (bold_button->value()) return_font.font = return_font.font->bold();
		if (italic_button->value()) return_font.font = return_font.font->italic();

		int size = atoi(sizeobj->text(sizeobj->value()));
		return_font.size = find_best_size(return_font.font, size);

		// on XFT encoding is always Unicode, so this field can be blank
		if (encobj->children() > 0) 
			return_font.encoding = encobj->text(encobj->value());
		else
			return_font.encoding = "";
		
		return_font.defined = true;
	}
	return return_font;
}
Пример #2
0
Copyright (C) 1998-2000 Stuart Levy, Tamara Munzner, Mark Phillips";
#endif

#include <stdio.h>
#include "origin.common.h"
#include "forms.h"
#include "xforms-compat.h"
#include "origin.panel.h"

/*
 * This file should contain ONLY the user interface and main()
 * to make splitting off the NeXT version easy
 */

int main(int argc, char *argv[]) {

#ifdef XFORMS
  FL_INITIALIZE("Origin");
#else
  fl_init();
  foreground();
#endif
  
  create_the_forms();
 
  internalsInit();

  fl_show_form(MainForm, FL_PLACE_SIZE, TRUE, "Move Origin");
 
  while(1) fl_do_forms();
}
Пример #3
0
int main(int argc, char **argv)
{
    Fl_Button::default_style->box = FL_PLASTIC_BOX;

    create_the_forms();

    // Add tiled image as window background
    Fl_Image *tile = Fl_Image::read_xpm(0, tile_xpm);
    form->image(tile);
    form->align(FL_ALIGN_TILED);

    char buf[256];
    strcpy(buf, argv[0]);
    fl_file_setext(buf,".menu");
    const char *fname = buf;
    int i = 0;
    if (!Fl::args(argc,argv,i) || i < argc-1)
        Fl::fatal("Usage: %s <switches> <menufile>\n%s",Fl::help);
    if (i < argc) fname = argv[i];
    if (!load_the_menu(fname)) Fl::fatal("Can't open %s",fname);
    strcpy(buf,fname);
    const char *c = fl_file_filename(buf);
    if (c > buf) {buf[c-buf] = 0; chdir(buf);}
    push_menu("@main");
    form->show(argc,argv);
    Fl::run();

    return 0;
}
Пример #4
0
int main(int argc, char *argv[])
{
  Int4 entries;
  FL_IOPT opt;

  CheckHost();

  /* There is a conflict between forms and xew about the meaning of
     the arguments: The "-p" option is taken as "-privat" by
     fl_initialize(), forcing a private colourmap.  This is what we
     want anyway, so ok... :-).  We just call GetArgs() first, because
     fl_initialize() removes the "-p" from argv[] ....  */

  GetArgs(argc, argv);

  /* Force private colourmap (why do I need opt?) */
  fl_set_defaults( FL_PDPrivateMap, &opt );

  fl_initialize(&argc, argv, "XEw", NULL, 0);

  /* Set up our signal handlers */
  signal(SIGINT, SigHandler);
  signal(SIGTERM, SigHandler);

  create_the_forms();
  set_object_defaults();
  /* load logo  */
  fl_set_pixmap_data(img_pxm, xew_logo_xpm);

  fl_show_form(xew_mainf,FL_PLACE_MOUSE, FL_FULLBORDER, "xew");

  entries = ReadFiles();
  FillBrowser( entries );

  fl_do_forms();

  return EXIT_FAILURE ;   /* shouldn't be reached */

}
Пример #5
0
int main (int argc, char** argv){
  Fl_scheme(NULL);
  Fl_args(argc,argv);
  Fl_get_system_colors();
  create_the_forms();
  int i = 0;
  int k = Fl_set_fonts("-*");
  sizes = malloc(sizeof(int*) * k);
  numsizes = malloc(sizeof(int) * k);
  i = 0;
  for (; i < k; i++) {
    int t;
    const char *name = Fl_get_font_name_with_attributes((Fl_Font)i,&t);
    char buffer[128];
    if (t) {
      char *p = buffer;
      if (t & FL_BOLD) {*p++ = '@'; *p++ = 'b';}
      if (t & FL_ITALIC) {*p++ = '@'; *p++ = 'i';}
	  *p++ = '@'; *p++ = '.'; // Suppress subsequent formatting - some MS fonts have '@' in their name
      strcpy(p,name);
      name = buffer;
    }
    Fl_Hold_Browser_add(fontobj,name);
    int s;
    int* _s = &s;
    int n = Fl_get_font_sizes((Fl_Font)i, _s);
    numsizes[i] = n;
    if (n) {
      sizes[i] = malloc(sizeof(int) * n);
      int j = 0;
      for (; j<n; j++){sizes[i][j] = _s[j];}
    }
  }
  Fl_Hold_Browser_set_value(fontobj,1);
  font_cb(fontobj,0);
  Fl_Double_Window_show_with_args(form,argc,argv);
  return Fl_run();
}
Пример #6
0
EDEFont font_chooser(EDEFont current_font) 
{
	EDEFont return_font;
	create_the_forms();
	if(!numfonts) numfonts = fltk::list_fonts(all_fonts);

	// populate list of fonts
	fontobj->clear();
	for(int i = 0; i < numfonts; i++) {
		fontobj->add(all_fonts[i]->name());
 		if (current_font.font && (strcasecmp(current_font.font->name(),all_fonts[i]->name())==0)) 
			// it's a substring
			fontobj->value(i);
	}
	/*char* currentname = strdup(current_font.font->name());
	fsor(int i = 0; i < numfonts; i++) {
		char* fontname = strdup(all_fonts[i]->name());
		fontobj->add(fontname);
 		if (currentname.lower_case().pos(fontname.lower_case())==0) // it's a substring
			fontobj->value(i);
	}*/

	// set bold, italic
	/*if (currentname.pos(" bold italic") == currentname.length()-12) {
		bold_button->value(true);
		italic_button->value(true);
	} else if (currentname.pos(" italic") == currentname.length()-7) {
		italic_button->value(true);
	} else if (currentname.pos(" bold") == currentname.length()-5) {
		bold_button->value(true);
	}*/

	// populate other lists
	textobj->encoding = current_font.encoding; // TODO: what if we're using XFT?
	font_cb(fontobj,0);
	for (int i=0; i < sizeobj->children(); i++) {
		if (atoi(sizeobj->child(i)->label()) == current_font.size) {
			sizeobj->value(i);
			size_cb(sizeobj,0);
		}
	}

	//
	form->show();
	form->exec();

	// we have to construct a proper EDEFont to return
	return_font.defined = false;
	if (return_value)
	{
		return_font.font = fltk::font(fontobj->child(fontobj->value())->label()); //Style.h
		if (bold_button->value()) return_font.font = return_font.font->bold();
		if (italic_button->value()) return_font.font = return_font.font->italic();

		int size = atoi(sizeobj->child(sizeobj->value())->label());
		return_font.size = find_best_size(return_font.font, size);

		// on XFT encoding is always Unicode, so this field can be blank
		if (encobj->children() > 1) 
			return_font.encoding = strdup(encobj->child(encobj->value())->label());
		else
			return_font.encoding = 0;
		
		return_font.defined = true;
	}
	return return_font;
}