DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2086
Version: 1.3-current





Link: http://www.fltk.org/str.php?L2086
Version: 1.3-current
/* Greg's chinese text test framework with my Fl_Input view added...

   fltk-config --compile bad-menu-3.cxx

*/
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Multiline_Input.H>
#include <FL/Fl_Menu_Bar.H>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

int main(int argc, char **argv)
{
    // Chinese utf8 text from Qiaogang Chen - with added \n marks (IMM)
    static char *utf8str =
"\x31\x20\xe5\xb9\xbf\xe8\xa5\xbf\xe5\x8c\x97\xe9\x83"
  "\xa8\xe6\xb9\xbe\xe6\xb5\xb7\xe5\x9f\x9f\xe6\xb5\xb7\xe4\xb8\x8a\xe6\xb2"
  "\xbb\xe5\xae\x89\xe5\x9f\xba\xe7\xa1\x80\xe4\xbf\xa1\xe6\x81\xaf\xe7\xb3"
  "\xbb\xe7\xbb\x9f\n"
"\x32\x20\xe7\xae\xa1\xe7\x90\x86\n"
"\x33\x20\xe7\xae\xa1\xe7\x90\x86\xe6\xb8\xaf\xe5\x8f\xa3\xe7\xa0\x81\xe5\xa4\xb4\n"
"\x34\x20\xe7\xae\xa1\xe7\x90\x86\xe5\x85\xbb\xe6\xae\x96\xe5\x9c\xba\n"
"\x35\x20\xe7\xae\xa1\xe7\x90\x86\xe6\xb8\x94\xe8\x88\xb9\n"
"\x36\x20\xe7\xae\xa1\xe7\x90\x86\xe6\xb8\x94\xe6\xb0\x91\n"
"\x37\x20\xe7\xb3\xbb\xe7\xbb\x9f\n"
"\x38\x20\xe5\xb8\xae\xe5\x8a\xa9\n"
"\x39\x20\xe9\x80\x80\xe5\x87\xba\x00";

// As a fltk "menu" (with added / separators)
    static char *utf8strMenu =
"\x31\x20\xe5\xb9\xbf\xe8\xa5\xbf\xe5\x8c\x97\xe9\x83"
  "\xa8\xe6\xb9\xbe\xe6\xb5\xb7\xe5\x9f\x9f\xe6\xb5\xb7\xe4\xb8\x8a\xe6\xb2"
  "\xbb\xe5\xae\x89\xe5\x9f\xba\xe7\xa1\x80\xe4\xbf\xa1\xe6\x81\xaf\xe7\xb3"
  "\xbb\xe7\xbb\x9f/"
"\x32\x20\xe7\xae\xa1\xe7\x90\x86/"
"\x33\x20\xe7\xae\xa1\xe7\x90\x86\xe6\xb8\xaf\xe5\x8f\xa3\xe7\xa0\x81\xe5\xa4\xb4/"
"\x34\x20\xe7\xae\xa1\xe7\x90\x86\xe5\x85\xbb\xe6\xae\x96\xe5\x9c\xba/"
"\x35\x20\xe7\xae\xa1\xe7\x90\x86\xe6\xb8\x94\xe8\x88\xb9/"
"\x36\x20\xe7\xae\xa1\xe7\x90\x86\xe6\xb8\x94\xe6\xb0\x91/"
"\x37\x20\xe7\xb3\xbb\xe7\xbb\x9f/"
"\x38\x20\xe5\xb8\xae\xe5\x8a\xa9/"
"\x39\x20\xe9\x80\x80\xe5\x87\xba\x00";

// As individual strings
    static char *utf8str1 =
  "\x31\x20\xe5\xb9\xbf\xe8\xa5\xbf\xe5\x8c\x97\xe9\x83"
  "\xa8\xe6\xb9\xbe\xe6\xb5\xb7\xe5\x9f\x9f\xe6\xb5\xb7\xe4\xb8\x8a\xe6\xb2"
  "\xbb\xe5\xae\x89\xe5\x9f\xba\xe7\xa1\x80\xe4\xbf\xa1\xe6\x81\xaf\xe7\xb3"
  "\xbb\xe7\xbb\x9f\x00";

    static char *utf8str2 =
"\x32\x20\xe7\xae\xa1\xe7\x90\x86\x00";

    static char *utf8str3 =
"\x33\x20\xe7\xae\xa1\xe7\x90\x86\xe6\xb8\xaf\xe5\x8f\xa3\xe7\xa0\x81\xe5\xa4\xb4\x00";

    static char *utf8str4 =
"\x34\x20\xe7\xae\xa1\xe7\x90\x86\xe5\x85\xbb\xe6\xae\x96\xe5\x9c\xba\x00";

    static char *utf8str5 =
"\x35\x20\xe7\xae\xa1\xe7\x90\x86\xe6\xb8\x94\xe8\x88\xb9\x00";

    static char *utf8str6 =
"\x36\x20\xe7\xae\xa1\xe7\x90\x86\xe6\xb8\x94\xe6\xb0\x91\x00";

    static char *utf8str7 =
"\x37\x20\xe7\xb3\xbb\xe7\xbb\x9f\x00";

    static char *utf8str8 =
"\x38\x20\xe5\xb8\xae\xe5\x8a\xa9\x00";

    static char *utf8str9 =
"\x39\x20\xe9\x80\x80\xe5\x87\xba\x00";


printf("UTF8STR=<%s>\n", utf8str);

          /* setup the font */
  Fl::set_font(FL_HELVETICA,
#ifdef _WIN32
        "Arial Unicode MS"
#elif __APPLE__
        "Monaco"
#else
        " ??PL????Uni" // NOTE: This font name chosen by hand to suit required 
glyphs!
#endif
  );

    // WINDOW
    Fl_Window *window = new Fl_Window(500,700,utf8str1);

    // MENUBAR
    {
      Fl_Menu_Bar *bar = new Fl_Menu_Bar(0,0,700,25);

      char *menuname = (char*)malloc(strlen(utf8strMenu) + strlen("Submenu/") + 
64);
          memset(menuname, 0, sizeof(menuname));
      strcpy(menuname, "Submenu/");
      strcat(menuname, utf8str1);
      bar->add(menuname);

      strcpy(menuname, "Submenu/");
      strcat(menuname, utf8strMenu);
      bar->add(menuname);

          char *menulist = (char*)malloc(strlen(utf8str) + strlen("List/") + 4);
          memset(menulist, 0, sizeof(menulist));
      strcpy(menulist, "List/");
      strcat(menulist, utf8str1);
      bar->add(menulist);
      strcpy(menulist, "List/");
      strcat(menulist, utf8str2);
      bar->add(menulist);
      strcpy(menulist, "List/");
      strcat(menulist, utf8str3);
      bar->add(menulist);
      strcpy(menulist, "List/");
      strcat(menulist, utf8str4);
      bar->add(menulist);
      strcpy(menulist, "List/");
      strcat(menulist, utf8str5);
      bar->add(menulist);
      strcpy(menulist, "List/");
      strcat(menulist, utf8str6);
      bar->add(menulist);
      strcpy(menulist, "List/");
      strcat(menulist, utf8str7);
      bar->add(menulist);
      strcpy(menulist, "List/");
      strcat(menulist, utf8str8);
      bar->add(menulist);
      strcpy(menulist, "List/");
      strcat(menulist, utf8str9);
      bar->add(menulist);
    }

    // BOX
    {
      Fl_Box *box = new Fl_Box(10,35,480,300);
      box->labelsize(20);
          box->labelfont(FL_HELVETICA);
          box->copy_label(utf8str);
    }

        // INPUT
    {
      Fl_Multiline_Input *input = new Fl_Multiline_Input(10,340,480,300);
      input->textsize(20);
          input->textfont(FL_HELVETICA);
          input->value(utf8str);
    }

    window->end();
    window->show(argc, argv);
    return Fl::run();
}
/* end of file */
_______________________________________________
fltk-bugs mailing list
fltk-bugs@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-bugs

Reply via email to