Make sure all strings can be localized in the dialogs.

Move the "preview" button over so there is room for localization.

Fix the order of buttons in convenience dialogs.

Update "ask" to use the fl_input function.

Fix 4-bit BMP file loading.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2608 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet 2002-08-30 16:58:16 +00:00
parent 047c32c334
commit ec494401c1
9 changed files with 56 additions and 97 deletions

View File

@ -1,5 +1,8 @@
CHANGES IN FLTK 1.1.0 CHANGES IN FLTK 1.1.0
- FLTK convenience dialogs put the buttons in the wrong
order.
- Fl_BMP_Image didn't load 4-bit BMP files properly.
- Minor tweeks to the WIN32 DLL support. - Minor tweeks to the WIN32 DLL support.
- Fl_Text_Display::resize() could go into an infinite - Fl_Text_Display::resize() could go into an infinite
loop if the buffer is emptied. loop if the buffer is emptied.

View File

@ -1,5 +1,5 @@
// //
// "$Id: fl_ask.H,v 1.7.2.4.2.4 2002/03/23 15:35:08 easysw Exp $" // "$Id: fl_ask.H,v 1.7.2.4.2.5 2002/08/30 16:58:16 easysw Exp $"
// //
// Standard dialog header file for the Fast Light Tool Kit (FLTK). // Standard dialog header file for the Fast Light Tool Kit (FLTK).
// //
@ -58,9 +58,10 @@ extern FL_EXPORT const char* fl_no;
extern FL_EXPORT const char* fl_yes; extern FL_EXPORT const char* fl_yes;
extern FL_EXPORT const char* fl_ok; extern FL_EXPORT const char* fl_ok;
extern FL_EXPORT const char* fl_cancel; extern FL_EXPORT const char* fl_cancel;
extern FL_EXPORT const char* fl_close;
#endif #endif
// //
// End of "$Id: fl_ask.H,v 1.7.2.4.2.4 2002/03/23 15:35:08 easysw Exp $". // End of "$Id: fl_ask.H,v 1.7.2.4.2.5 2002/08/30 16:58:16 easysw Exp $".
// //

View File

@ -1,5 +1,5 @@
// //
// "$Id: Fl_BMP_Image.cxx,v 1.1.2.9 2002/08/09 01:09:48 easysw Exp $" // "$Id: Fl_BMP_Image.cxx,v 1.1.2.10 2002/08/30 16:58:16 easysw Exp $"
// //
// Fl_BMP_Image routines. // Fl_BMP_Image routines.
// //
@ -239,24 +239,27 @@ Fl_BMP_Image::Fl_BMP_Image(const char *bmp) // I - File to read
// Get a new color as needed... // Get a new color as needed...
repcount --; repcount --;
// Get the next color byte as needed...
if (color < 0) color = getc(fp);
// Extract the next pixel... // Extract the next pixel...
if (bit == 0xf0) { if (bit == 0xf0) {
temp = (color >> 4) & 15; // Get the next color byte as needed...
if (color < 0) temp = getc(fp);
else temp = color;
// Copy the color value...
*ptr++ = colormap[(temp >> 4) & 15][2];
*ptr++ = colormap[(temp >> 4) & 15][1];
*ptr++ = colormap[(temp >> 4) & 15][0];
bit = 0x0f; bit = 0x0f;
} else { } else {
temp = color & 15;
bit = 0xf0; bit = 0xf0;
// Copy the color value...
*ptr++ = colormap[temp & 15][2];
*ptr++ = colormap[temp & 15][1];
*ptr++ = colormap[temp & 15][0];
} }
// printf("temp = %d\n", temp);
// Copy the color value...
*ptr++ = colormap[temp][2];
*ptr++ = colormap[temp][1];
*ptr++ = colormap[temp][0];
} }
if (!compression) { if (!compression) {
@ -393,5 +396,5 @@ read_long(FILE *fp) { // I - File to read from
// //
// End of "$Id: Fl_BMP_Image.cxx,v 1.1.2.9 2002/08/09 01:09:48 easysw Exp $". // End of "$Id: Fl_BMP_Image.cxx,v 1.1.2.10 2002/08/30 16:58:16 easysw Exp $".
// //

View File

@ -173,7 +173,7 @@ Fl_File_Chooser::Fl_File_Chooser(const char *d, const char *p, int t, const char
} }
{ Fl_Group* o = new Fl_Group(0, 275, 480, 95); { Fl_Group* o = new Fl_Group(0, 275, 480, 95);
{ Fl_Group* o = new Fl_Group(10, 275, 470, 20); { Fl_Group* o = new Fl_Group(10, 275, 470, 20);
{ Fl_Check_Button* o = previewButton = new Fl_Check_Button(405, 275, 75, 20, "Preview"); { Fl_Check_Button* o = previewButton = new Fl_Check_Button(10, 275, 170, 20, "Preview");
o->down_box(FL_DOWN_BOX); o->down_box(FL_DOWN_BOX);
o->value(1); o->value(1);
o->shortcut(0x80070); o->shortcut(0x80070);
@ -246,16 +246,7 @@ Fl_File_Chooser::Fl_File_Chooser(const char *d, const char *p, int t, const char
} }
callback_ = 0; callback_ = 0;
data_ = 0; data_ = 0;
directory_[0] = '\0'; directory_[0] = '
window->size_range(window->w(), window->h(), Fl::w(), Fl::h());
type(t);
filter(p);
update_favorites();
value(d);
type(t);
int e;
prefs_.get("preview", e, 1);
preview(e);
} }
Fl_File_Chooser::~Fl_File_Chooser() { Fl_File_Chooser::~Fl_File_Chooser() {

View File

@ -52,7 +52,7 @@ window->hide();} open
code0 {favoritesButton->label(favorites_label);} code0 {favoritesButton->label(favorites_label);}
} {} } {}
Fl_Button newButton { Fl_Button newButton {
callback {newdir();} selected callback {newdir();}
tooltip {Create a new directory.} image {new.xbm} xywh {455 10 25 25} labelsize 8 tooltip {Create a new directory.} image {new.xbm} xywh {455 10 25 25} labelsize 8
code0 {\#include <FL/Fl_Preferences.H>} code0 {\#include <FL/Fl_Preferences.H>}
} }
@ -79,8 +79,8 @@ window->hide();} open
} { } {
Fl_Check_Button previewButton { Fl_Check_Button previewButton {
label Preview label Preview
callback {preview(previewButton->value());} callback {preview(previewButton->value());} selected
xywh {405 275 75 20} down_box DOWN_BOX shortcut 0x80070 value 1 xywh {10 275 170 20} down_box DOWN_BOX shortcut 0x80070 value 1
code0 {previewButton->label(preview_label);} code0 {previewButton->label(preview_label);}
} }
Fl_Box {} { Fl_Box {} {
@ -166,16 +166,7 @@ window->hide();}
} }
code {callback_ = 0; code {callback_ = 0;
data_ = 0; data_ = 0;
directory_[0] = '\0'; directory_[0] = '} {}
window->size_range(window->w(), window->h(), Fl::w(), Fl::h());
type(t);
filter(p);
update_favorites();
value(d);
type(t);
int e;
prefs_.get("preview", e, 1);
preview(e);} {}
} }
Function {~Fl_File_Chooser()} {open Function {~Fl_File_Chooser()} {open
} { } {

View File

@ -2,6 +2,7 @@
#include "../FL/Fl_Help_Dialog.H" #include "../FL/Fl_Help_Dialog.H"
#include "flstring.h" #include "flstring.h"
#include <FL/fl_ask.H>
inline void Fl_Help_Dialog::cb_view__i(Fl_Help_View*, void*) { inline void Fl_Help_Dialog::cb_view__i(Fl_Help_View*, void*) {
if (view_->changed()) if (view_->changed())
@ -118,6 +119,7 @@ Fl_Help_Dialog::Fl_Help_Dialog() {
} }
{ Fl_Button* o = new Fl_Button(425, 350, 95, 25, "Close"); { Fl_Button* o = new Fl_Button(425, 350, 95, 25, "Close");
o->callback((Fl_Callback*)cb_Close); o->callback((Fl_Callback*)cb_Close);
o->label(fl_close);
} }
{ Fl_Button* o = back_ = new Fl_Button(365, 350, 25, 25, "@<-"); { Fl_Button* o = back_ = new Fl_Button(365, 350, 25, 25, "@<-");
o->tooltip("Show the previous help page."); o->tooltip("Show the previous help page.");

View File

@ -2,7 +2,9 @@
version 1.0100 version 1.0100
header_name {../FL/Fl_Help_Dialog.H} header_name {../FL/Fl_Help_Dialog.H}
code_name {.cxx} code_name {.cxx}
decl {\#include "flstring.h"} {selected decl {\#include "flstring.h"} {}
decl {\#include <FL/fl_ask.H>} {selected
} }
class Fl_Help_Dialog {open class Fl_Help_Dialog {open
@ -15,8 +17,7 @@ class Fl_Help_Dialog {open
} { } {
Fl_Window window_ { Fl_Window window_ {
label {Help Dialog} open label {Help Dialog} open
private xywh {470 380 530 385} type Double resizable private xywh {470 380 530 385} type Double resizable visible
visible
} { } {
Fl_Group view_ { Fl_Group view_ {
callback {if (view_->changed()) callback {if (view_->changed())
@ -56,6 +57,7 @@ else if (view_->filename())
label Close label Close
callback {window_->hide();} callback {window_->hide();}
xywh {425 350 95 25} xywh {425 350 95 25}
code0 {o->label(fl_close);}
} }
Fl_Button back_ { Fl_Button back_ {
label {@<-} label {@<-}

View File

@ -1,5 +1,5 @@
// //
// "$Id: fl_ask.cxx,v 1.8.2.8.2.9 2002/06/06 14:22:05 easysw Exp $" // "$Id: fl_ask.cxx,v 1.8.2.8.2.10 2002/08/30 16:58:16 easysw Exp $"
// //
// Standard dialog functions for the Fast Light Tool Kit (FLTK). // Standard dialog functions for the Fast Light Tool Kit (FLTK).
// //
@ -72,7 +72,8 @@ static Fl_Window *makeform() {
o->color(FL_WHITE); o->color(FL_WHITE);
o->labelcolor(FL_BLUE); o->labelcolor(FL_BLUE);
} }
(button[0] = new Fl_Button(310, 70, 90, 23))->shortcut("^["); button[0] = new Fl_Button(310, 70, 90, 23);
button[0]->shortcut("^[");
button[0]->align(FL_ALIGN_INSIDE|FL_ALIGN_WRAP); button[0]->align(FL_ALIGN_INSIDE|FL_ALIGN_WRAP);
button[1] = new Fl_Return_Button(210, 70, 90, 23); button[1] = new Fl_Return_Button(210, 70, 90, 23);
button[1]->align(FL_ALIGN_INSIDE|FL_ALIGN_WRAP); button[1]->align(FL_ALIGN_INSIDE|FL_ALIGN_WRAP);
@ -149,11 +150,15 @@ void resizeform() {
icon->labelsize(icon_size - 10); icon->labelsize(icon_size - 10);
input->resize(20 + icon_size, 10 + message_h, message_w, 25); input->resize(20 + icon_size, 10 + message_h, message_w, 25);
for (x = w, i = 2; i >= 0; i --) for (x = w, i = 0; i < 3; i ++)
if (button_w[i]) if (button_w[i])
{ {
x -= button_w[i]; x -= button_w[i];
button[i]->resize(x, h - 10 - max_h, button_w[i] - 10, max_h); button[i]->resize(x, h - 10 - max_h, button_w[i] - 10, max_h);
// printf("button %d (%s) is %dx%d+%d,%d\n", i, button[i]->label(),
// button[i]->w(), button[i]->h(),
// button[i]->x(), button[i]->y());
} }
} }
@ -206,6 +211,7 @@ const char* fl_no = "No";
const char* fl_yes= "Yes"; const char* fl_yes= "Yes";
const char* fl_ok = "OK"; const char* fl_ok = "OK";
const char* fl_cancel= "Cancel"; const char* fl_cancel= "Cancel";
const char* fl_close= "Close";
// fltk functions: // fltk functions:
void fl_beep(int type) { void fl_beep(int type) {
@ -311,10 +317,6 @@ static const char* input_innards(const char* fmt, va_list ap,
input->show(); input->show();
input->value(defstr); input->value(defstr);
#ifdef WIN32
MessageBeep(MB_ICONQUESTION);
#endif // WIN32
int r = innards(fmt, ap, fl_cancel, fl_ok, 0); int r = innards(fmt, ap, fl_cancel, fl_ok, 0);
input->hide(); input->hide();
message->position(60,25); message->position(60,25);
@ -342,5 +344,5 @@ const char *fl_password(const char *fmt, const char *defstr, ...) {
} }
// //
// End of "$Id: fl_ask.cxx,v 1.8.2.8.2.9 2002/06/06 14:22:05 easysw Exp $". // End of "$Id: fl_ask.cxx,v 1.8.2.8.2.10 2002/08/30 16:58:16 easysw Exp $".
// //

View File

@ -1,5 +1,5 @@
// //
// "$Id: ask.cxx,v 1.4.2.3.2.1 2002/01/01 15:11:32 easysw Exp $" // "$Id: ask.cxx,v 1.4.2.3.2.2 2002/08/30 16:58:16 easysw Exp $"
// //
// Standard dialog test program for the Fast Light Tool Kit (FLTK). // Standard dialog test program for the Fast Light Tool Kit (FLTK).
// //
@ -38,48 +38,26 @@
#include <FL/Fl_Button.H> #include <FL/Fl_Button.H>
#include <FL/Fl_Return_Button.H> #include <FL/Fl_Return_Button.H>
int get_string(char*buffer) {
Fl_Window window(320,75);
Fl_Input input(60, 10, 250, 25, "Input:");
input.value(buffer);
Fl_Button cancel(60, 40, 80, 25, "cancel");
Fl_Return_Button ok(150, 40, 80, 25, "OK");
window.hotspot(&cancel); // you must position modal windows
window.end();
window.set_modal();
window.show();
for (;;) {
Fl::wait();
Fl_Widget *o;
while ((o = Fl::readqueue())) {
if (o == &ok) {
strcpy(buffer,input.value());
return 1;
} else if (o == &cancel || o == &window) {
return 0;
}
}
}
}
void rename_me(Fl_Widget*o) {
if (get_string((char*)(o->label()))) o->redraw();
}
#if 1
#include <FL/fl_ask.H> #include <FL/fl_ask.H>
#include <stdlib.h> #include <stdlib.h>
void rename_me(Fl_Widget*o) {
const char *input = fl_input("Input:", o->label());
if (input) {
o->label(input);
o->redraw();
}
}
void window_callback(Fl_Widget*, void*) { void window_callback(Fl_Widget*, void*) {
if (!fl_ask("Are you sure you want to quit?")) return; if (!fl_ask("Are you sure you want to quit?")) return;
exit(0); exit(0);
} }
#endif
int main(int argc, char **argv) { int main(int argc, char **argv) {
char buffer[128] = "test text"; char buffer[128] = "test text";
#if 1
// this is a test to make sure automatic destructors work. Pop up // this is a test to make sure automatic destructors work. Pop up
// the question dialog several times and make sure it don't crash. // the question dialog several times and make sure it don't crash.
@ -93,22 +71,8 @@ int main(int argc, char **argv) {
window.callback(window_callback); window.callback(window_callback);
return Fl::run(); return Fl::run();
#else
// This is the demo as written in the documentation, it only creates
// the popup window once:
if (get_string(buffer)) {
puts(buffer);
} else {
puts("cancel");
}
return 0;
#endif
} }
// //
// End of "$Id: ask.cxx,v 1.4.2.3.2.1 2002/01/01 15:11:32 easysw Exp $". // End of "$Id: ask.cxx,v 1.4.2.3.2.2 2002/08/30 16:58:16 easysw Exp $".
// //