mirror of
https://github.com/fltk/fltk.git
synced 2026-05-28 11:25:22 +08:00
Doxygen documentation: more paranoid fixes and complements in common dialogs. Added new test cases in the ask demo now featuring fl_message() and fl_password() API, made fl_choice() more specific about its return value tests in caller (also added a third button).
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6369 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
@@ -531,7 +531,7 @@ extern const char* fl_cancel;
|
|||||||
/**
|
/**
|
||||||
\brief Pops up a window to let the user pick an arbitrary RGB color.
|
\brief Pops up a window to let the user pick an arbitrary RGB color.
|
||||||
\image html fl_color_chooser.jpg
|
\image html fl_color_chooser.jpg
|
||||||
\param[in,out] name title label for the window
|
\param[in] name title label for the window
|
||||||
\param[in,out] r, g, b color components in the range 0.0 to 1.0.
|
\param[in,out] r, g, b color components in the range 0.0 to 1.0.
|
||||||
\retval 1 if user confirms the selection
|
\retval 1 if user confirms the selection
|
||||||
\retval 0 if user cancels the dialog
|
\retval 0 if user cancels the dialog
|
||||||
@@ -574,7 +574,7 @@ int fl_color_chooser(const char* name, double& r, double& g, double& b) {
|
|||||||
/**
|
/**
|
||||||
\brief Pops up a window to let the user pick an arbitrary RGB color.
|
\brief Pops up a window to let the user pick an arbitrary RGB color.
|
||||||
\image html fl_color_chooser.jpg
|
\image html fl_color_chooser.jpg
|
||||||
\param[in,out] name title label for the window
|
\param[in] name title label for the window
|
||||||
\param[in,out] r, g, b color components in the range 0 to 255.
|
\param[in,out] r, g, b color components in the range 0 to 255.
|
||||||
\retval 1 if user confirms the selection
|
\retval 1 if user confirms the selection
|
||||||
\retval 0 if user cancels the dialog
|
\retval 0 if user cancels the dialog
|
||||||
|
|||||||
+2
-2
@@ -379,7 +379,7 @@ static const char* input_innards(const char* fmt, va_list ap,
|
|||||||
/** Shows an input dialog displaying the \a fmt message
|
/** Shows an input dialog displaying the \a fmt message
|
||||||
\param[in] fmt can be used as an sprintf-like format and variables for the message text
|
\param[in] fmt can be used as an sprintf-like format and variables for the message text
|
||||||
\param[in] defstr defines the default returned string if no text is entered
|
\param[in] defstr defines the default returned string if no text is entered
|
||||||
\return the user string input
|
\return the user string input if OK was pushed, NULL if Cancel was pushed
|
||||||
*/
|
*/
|
||||||
const char* fl_input(const char *fmt, const char *defstr, ...) {
|
const char* fl_input(const char *fmt, const char *defstr, ...) {
|
||||||
fl_beep(FL_BEEP_QUESTION);
|
fl_beep(FL_BEEP_QUESTION);
|
||||||
@@ -396,7 +396,7 @@ const char* fl_input(const char *fmt, const char *defstr, ...) {
|
|||||||
'*' characters are displayed instead
|
'*' characters are displayed instead
|
||||||
\param[in] fmt can be used as an sprintf-like format and variables for the message text
|
\param[in] fmt can be used as an sprintf-like format and variables for the message text
|
||||||
\param[in] defstr defines the default returned string if no text is entered
|
\param[in] defstr defines the default returned string if no text is entered
|
||||||
\return the user string input
|
\return the user string input if OK was pushed, NULL if Cancel was pushed
|
||||||
*/
|
*/
|
||||||
const char *fl_password(const char *fmt, const char *defstr, ...) {
|
const char *fl_password(const char *fmt, const char *defstr, ...) {
|
||||||
fl_beep(FL_BEEP_PASSWORD);
|
fl_beep(FL_BEEP_PASSWORD);
|
||||||
|
|||||||
+23
-8
@@ -43,28 +43,43 @@
|
|||||||
#include <FL/fl_ask.H>
|
#include <FL/fl_ask.H>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
void rename_me(Fl_Widget*o) {
|
void update_input_text(Fl_Widget* o, const char *input) {
|
||||||
const char *input = fl_input("Input:", o->label());
|
|
||||||
|
|
||||||
if (input) {
|
if (input) {
|
||||||
o->copy_label(input);
|
o->copy_label(input);
|
||||||
o->redraw();
|
o->redraw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rename_me(Fl_Widget*o) {
|
||||||
|
const char *input = fl_input("Input:", o->label());
|
||||||
|
update_input_text(o, input);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rename_me_pwd(Fl_Widget*o) {
|
||||||
|
const char *input = fl_password("Input PWD:", o->label());
|
||||||
|
update_input_text(o, input);
|
||||||
|
}
|
||||||
|
|
||||||
void window_callback(Fl_Widget*, void*) {
|
void window_callback(Fl_Widget*, void*) {
|
||||||
if (!fl_choice("Are you sure you want to quit?", "Cancel", "Quit", 0L)) return;
|
int rep = fl_choice("Are you sure you want to quit?",
|
||||||
exit(0);
|
"Cancel", "Quit", "Dunno");
|
||||||
|
if (rep==1)
|
||||||
|
exit(0);
|
||||||
|
else if (rep==2)
|
||||||
|
fl_message("Well, maybe you should know before we quit.");
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
char buffer[128] = "test text";
|
char buffer[128] = "Test text";
|
||||||
|
char buffer2[128] = "MyPassword";
|
||||||
|
|
||||||
// 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 doesn't crash.
|
||||||
|
// fc: added more fl_ask common dialogs for test cases purposes.
|
||||||
|
|
||||||
Fl_Window window(200, 55);
|
Fl_Window window(200, 105);
|
||||||
Fl_Return_Button b(20, 10, 160, 35, buffer); b.callback(rename_me);
|
Fl_Return_Button b(20, 10, 160, 35, buffer); b.callback(rename_me);
|
||||||
|
Fl_Button b2(20, 50, 160, 35, buffer2); b2.callback(rename_me_pwd);
|
||||||
window.end();
|
window.end();
|
||||||
window.resizable(&b);
|
window.resizable(&b);
|
||||||
window.show(argc, argv);
|
window.show(argc, argv);
|
||||||
|
|||||||
Reference in New Issue
Block a user