mirror of
https://github.com/fltk/fltk.git
synced 2026-06-08 10:00:38 +08:00
Moved OS X code base to the more moder Cocoa toolkit thanks to the awesome work of Manolo Gouy (STR #2221). This is a big one! I tested all test applications under 32-bit autoconf and Xcode, and a few apps under 64bit intel. No PPC testing was done. Please verify this patch if you have the machine!
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6951 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
+7
-3
@@ -148,13 +148,17 @@ int main(int argc, char **argv) {
|
||||
#elif defined(USING_XCODE)
|
||||
if ( i == argc )
|
||||
{
|
||||
fname = "../../../../test/browser.cxx";
|
||||
done = browser->load(fname);
|
||||
char buf[2048];
|
||||
strcpy(buf, argv[0]);
|
||||
char *slash = strrchr(buf, '/');
|
||||
if (slash)
|
||||
strcpy(slash, "/../Resources/browser.cxx");
|
||||
done = browser->load(buf);
|
||||
}
|
||||
#endif
|
||||
if ( !done )
|
||||
{
|
||||
printf("Can't load %s, %s\n", fname, strerror(errno));
|
||||
fl_message("Can't load %s, %s\n", fname, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
+22
-20
@@ -63,7 +63,7 @@ class Pens : public Fl_Box {
|
||||
void draw();
|
||||
public:
|
||||
Pens(int X, int Y, int W, int H, const char* L)
|
||||
: Fl_Box(X,Y,W,H,L) {}
|
||||
: Fl_Box(X,Y,W,H,L) {}
|
||||
};
|
||||
void Pens::draw() {
|
||||
// use every color in the gray ramp:
|
||||
@@ -112,11 +112,11 @@ int main(int argc, char ** argv) {
|
||||
Pens p(80,200,3*8,120,"lines");
|
||||
p.align(FL_ALIGN_TOP);
|
||||
int i = 1;
|
||||
if (!Fl::args(argc,argv,i) || i != argc-1) {
|
||||
if (!Fl::args(argc,argv,i) || i < argc-1) {
|
||||
printf("usage: %s <switches> visual-number\n"
|
||||
" - : default visual\n"
|
||||
" r : call Fl::visual(FL_RGB)\n"
|
||||
" c : call Fl::own_colormap()\n",argv[0]);
|
||||
" - : default visual\n"
|
||||
" r : call Fl::visual(FL_RGB)\n"
|
||||
" c : call Fl::own_colormap()\n",argv[0]);
|
||||
#if !defined(WIN32) && !defined(__APPLE__)
|
||||
printf(" # : use this visual with an empty colormap:\n");
|
||||
list_visuals();
|
||||
@@ -124,24 +124,26 @@ int main(int argc, char ** argv) {
|
||||
puts(Fl::help);
|
||||
exit(1);
|
||||
}
|
||||
if (argv[i][0] == 'r') {
|
||||
if (!Fl::visual(FL_RGB)) printf("Fl::visual(FL_RGB) returned false.\n");
|
||||
} else if (argv[i][0] == 'c') {
|
||||
Fl::own_colormap();
|
||||
} else if (argv[i][0] != '-') {
|
||||
if (i!=argc) {
|
||||
if (argv[i][0] == 'r') {
|
||||
if (!Fl::visual(FL_RGB)) printf("Fl::visual(FL_RGB) returned false.\n");
|
||||
} else if (argv[i][0] == 'c') {
|
||||
Fl::own_colormap();
|
||||
} else if (argv[i][0] != '-') {
|
||||
#if !defined(WIN32) && !defined(__APPLE__)
|
||||
int visid = atoi(argv[i]);
|
||||
fl_open_display();
|
||||
XVisualInfo templt; int num;
|
||||
templt.visualid = visid;
|
||||
fl_visual = XGetVisualInfo(fl_display, VisualIDMask, &templt, &num);
|
||||
if (!fl_visual) Fl::fatal("No visual with id %d",visid);
|
||||
fl_colormap = XCreateColormap(fl_display, RootWindow(fl_display,fl_screen),
|
||||
fl_visual->visual, AllocNone);
|
||||
fl_xpixel(FL_BLACK); // make sure black is allocated
|
||||
int visid = atoi(argv[i]);
|
||||
fl_open_display();
|
||||
XVisualInfo templt; int num;
|
||||
templt.visualid = visid;
|
||||
fl_visual = XGetVisualInfo(fl_display, VisualIDMask, &templt, &num);
|
||||
if (!fl_visual) Fl::fatal("No visual with id %d",visid);
|
||||
fl_colormap = XCreateColormap(fl_display, RootWindow(fl_display,fl_screen),
|
||||
fl_visual->visual, AllocNone);
|
||||
fl_xpixel(FL_BLACK); // make sure black is allocated
|
||||
#else
|
||||
Fl::fatal("Visual id's not supported on MSWindows or MacOS.");
|
||||
Fl::fatal("Visual id's not supported on MSWindows or MacOS.");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
window.show(argc,argv);
|
||||
return Fl::run();
|
||||
|
||||
+45
-37
@@ -154,7 +154,7 @@ int b2n[][9] = {
|
||||
{ 0, -1, 1, 2, 3, 4, 5, -1, 6},
|
||||
{ 0, 1, 2, 3, -1, 4, 5, 6, 7},
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8}
|
||||
};
|
||||
};
|
||||
int n2b[][9] = {
|
||||
{ 4, -1, -1, -1, -1, -1, -1, -1, -1},
|
||||
{ 3, 5, -1, -1, -1, -1, -1, -1, -1},
|
||||
@@ -165,17 +165,17 @@ int n2b[][9] = {
|
||||
{ 0, 2, 3, 4, 5, 6, 8, -1, -1},
|
||||
{ 0, 1, 2, 3, 5, 6, 7, 8, -1},
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8}
|
||||
};
|
||||
};
|
||||
|
||||
int but2numb(int bnumb, int maxnumb)
|
||||
/* Transforms a button number to an item number when there are
|
||||
maxnumb items in total. -1 if the button should not exist. */
|
||||
{ return b2n[maxnumb][bnumb]; }
|
||||
maxnumb items in total. -1 if the button should not exist. */
|
||||
{ return b2n[maxnumb][bnumb]; }
|
||||
|
||||
int numb2but(int inumb, int maxnumb)
|
||||
/* Transforms an item number to a button number when there are
|
||||
maxnumb items in total. -1 if the item should not exist. */
|
||||
{ return n2b[maxnumb][inumb]; }
|
||||
maxnumb items in total. -1 if the item should not exist. */
|
||||
{ return n2b[maxnumb][inumb]; }
|
||||
|
||||
/* Pushing and Popping menus */
|
||||
|
||||
@@ -222,33 +222,33 @@ void dobut(Fl_Widget *, long arg)
|
||||
if (menus[men].icommand[bn][0] == '@')
|
||||
push_menu(menus[men].icommand[bn]);
|
||||
else {
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
STARTUPINFO suInfo; // Process startup information
|
||||
PROCESS_INFORMATION prInfo; // Process information
|
||||
|
||||
|
||||
memset(&suInfo, 0, sizeof(suInfo));
|
||||
suInfo.cb = sizeof(suInfo);
|
||||
|
||||
|
||||
int icommand_length = strlen(menus[men].icommand[bn]);
|
||||
|
||||
|
||||
char* copy_of_icommand = new char[icommand_length+1];
|
||||
strcpy(copy_of_icommand,menus[men].icommand[bn]);
|
||||
|
||||
|
||||
// On WIN32 the .exe suffix needs to be appended to the command
|
||||
// whilst leaving any additional parameters unchanged - this
|
||||
// is required to handle the correct conversion of cases such as :
|
||||
// `../fluid/fluid valuators.fl' to '../fluid/fluid.exe valuators.fl'.
|
||||
|
||||
|
||||
// skip leading spaces.
|
||||
char* start_command = copy_of_icommand;
|
||||
while(*start_command == ' ') ++start_command;
|
||||
|
||||
|
||||
// find the space between the command and parameters if one exists.
|
||||
char* start_parameters = strchr(start_command,' ');
|
||||
|
||||
|
||||
char* command = new char[icommand_length+6]; // 6 for extra 'd.exe\0'
|
||||
|
||||
|
||||
if (start_parameters==NULL) { // no parameters required.
|
||||
# ifdef _DEBUG
|
||||
sprintf(command, "%sd.exe", start_command);
|
||||
@@ -261,38 +261,46 @@ void dobut(Fl_Widget *, long arg)
|
||||
*start_parameters = 0;
|
||||
// move start_paremeters to skip over the intermediate space.
|
||||
++start_parameters;
|
||||
|
||||
|
||||
# ifdef _DEBUG
|
||||
sprintf(command, "%sd.exe %s", start_command, start_parameters);
|
||||
# else
|
||||
sprintf(command, "%s.exe %s", start_command, start_parameters);
|
||||
# endif // _DEBUG
|
||||
}
|
||||
|
||||
|
||||
CreateProcess(NULL, command, NULL, NULL, FALSE,
|
||||
NORMAL_PRIORITY_CLASS, NULL, NULL, &suInfo, &prInfo);
|
||||
|
||||
|
||||
delete[] command;
|
||||
delete[] copy_of_icommand;
|
||||
|
||||
#elif defined USING_XCODE
|
||||
|
||||
int icommand_length = strlen(menus[men].icommand[bn]);
|
||||
char* command = new char[icommand_length+24]; // extraspace for 'open ../../(name).app &\0'
|
||||
|
||||
sprintf(command, "open ../../../%s.app &", menus[men].icommand[bn]);
|
||||
#elif defined USING_XCODE
|
||||
char *cmd = strdup(menus[men].icommand[bn]);
|
||||
char *arg = strchr(cmd, ' ');
|
||||
|
||||
char command[2048];
|
||||
if (arg) {
|
||||
*arg = 0;
|
||||
if (strcmp(cmd, "../fluid/fluid")==0)
|
||||
sprintf(command, "open ../../../Fluid.app --args %s", arg+1);
|
||||
else
|
||||
sprintf(command, "open ../../../%s.app --args %s", cmd, arg+1);
|
||||
} else {
|
||||
sprintf(command, "open ../../../%s.app", cmd);
|
||||
}
|
||||
puts(command);
|
||||
system(command);
|
||||
|
||||
delete[] command;
|
||||
|
||||
free(cmd);
|
||||
#else // NON WIN32 systems.
|
||||
|
||||
|
||||
int icommand_length = strlen(menus[men].icommand[bn]);
|
||||
char* command = new char[icommand_length+5]; // 5 for extra './' and ' &\0'
|
||||
|
||||
|
||||
sprintf(command, "./%s &", menus[men].icommand[bn]);
|
||||
system(command);
|
||||
|
||||
|
||||
delete[] command;
|
||||
#endif // WIN32
|
||||
}
|
||||
@@ -312,7 +320,7 @@ int load_the_menu(const char* fname)
|
||||
if (fin == NULL)
|
||||
{
|
||||
#if defined ( __APPLE__ )
|
||||
// mac os bundle menu detection:
|
||||
// mac os bundle menu detection:
|
||||
char* pos = strrchr(fname,'/');
|
||||
if (!pos) return 0;
|
||||
*pos='\0';
|
||||
@@ -322,7 +330,7 @@ int load_the_menu(const char* fname)
|
||||
fin = fopen(fname,"r");
|
||||
if (fin == NULL)
|
||||
#endif
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
for (;;) {
|
||||
if (fgets(line,256,fin) == NULL) break;
|
||||
@@ -345,10 +353,10 @@ int load_the_menu(const char* fname)
|
||||
while (line[i] != ':' && line[i] != '\n')
|
||||
{
|
||||
if (line[i] == '\\') {
|
||||
i++;
|
||||
if (line[i] == 'n') iname[j++] = '\n';
|
||||
else iname[j++] = line[i];
|
||||
i++;
|
||||
i++;
|
||||
if (line[i] == 'n') iname[j++] = '\n';
|
||||
else iname[j++] = line[i];
|
||||
i++;
|
||||
} else
|
||||
iname[j++] = line[i++];
|
||||
}
|
||||
@@ -378,9 +386,9 @@ int main(int argc, char **argv) {
|
||||
if (!Fl::args(argc,argv,i) || i < argc-1)
|
||||
Fl::fatal("Usage: %s <switches> <menufile>\n%s",argv[0],Fl::help);
|
||||
if (i < argc) fname = argv[i];
|
||||
|
||||
|
||||
create_the_forms();
|
||||
|
||||
|
||||
if (!load_the_menu(fname)) Fl::fatal("Can't open %s",fname);
|
||||
if (buf!=fname)
|
||||
strcpy(buf,fname);
|
||||
|
||||
@@ -161,6 +161,10 @@ void fullscreen_cb(Fl_Widget *o, void *p) {
|
||||
py = w->y();
|
||||
pw = w->w();
|
||||
ph = w->h();
|
||||
#ifndef WIN32//necessary because fullscreen removes border
|
||||
border_button->value(0);
|
||||
border_button->do_callback();
|
||||
#endif
|
||||
w->fullscreen();
|
||||
} else {
|
||||
w->fullscreen_off(px,py,pw,ph);
|
||||
|
||||
Reference in New Issue
Block a user