mirror of
https://github.com/fltk/fltk.git
synced 2025-12-15 08:55:20 +08:00
Improve clipboard example program, fix compilation warnings.
Use show(argc,argv) to enable command line arguments and colors, fix indentation, Windows compilation warnings, and change tab selection color, which was too dark on my Win7 system (low contrast with tab labels). I also added #define TAB_COLOR to make changing the tab selection colors easier, if needed. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10318 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
@@ -60,6 +60,8 @@ public:
|
|||||||
}
|
}
|
||||||
} *chess_obj;
|
} *chess_obj;
|
||||||
|
|
||||||
|
#define TAB_COLOR FL_DARK3
|
||||||
|
|
||||||
class clipboard_viewer : public Fl_Tabs { // use tabs to display as appropriate the image or textual content of the clipboard
|
class clipboard_viewer : public Fl_Tabs { // use tabs to display as appropriate the image or textual content of the clipboard
|
||||||
public:
|
public:
|
||||||
clipboard_viewer(int x, int y, int w, int h) : Fl_Tabs(x,y,w,h) {};
|
clipboard_viewer(int x, int y, int w, int h) : Fl_Tabs(x,y,w,h) {};
|
||||||
@@ -80,10 +82,10 @@ public:
|
|||||||
if (format && format < CF_MAX) { sprintf(p, " %d",format); p += strlen(p); }
|
if (format && format < CF_MAX) { sprintf(p, " %d",format); p += strlen(p); }
|
||||||
}
|
}
|
||||||
HANDLE h;
|
HANDLE h;
|
||||||
if (h = GetClipboardData(CF_DIB)) {
|
if ((h = GetClipboardData(CF_DIB))) {
|
||||||
LPBITMAPINFO lpBI = (LPBITMAPINFO)GlobalLock(h);
|
LPBITMAPINFO lpBI = (LPBITMAPINFO)GlobalLock(h);
|
||||||
sprintf(p, " biBitCount=%d biCompression=%d biClrUsed=%d",
|
sprintf(p, " biBitCount=%d biCompression=%d biClrUsed=%d",
|
||||||
lpBI->bmiHeader.biBitCount, lpBI->bmiHeader.biCompression, lpBI->bmiHeader.biClrUsed);
|
lpBI->bmiHeader.biBitCount, (int)lpBI->bmiHeader.biCompression, (int)lpBI->bmiHeader.biClrUsed);
|
||||||
}
|
}
|
||||||
CloseClipboard();
|
CloseClipboard();
|
||||||
#endif
|
#endif
|
||||||
@@ -126,7 +128,7 @@ void clip_callback(int source, void *data) { // called after clipboard was chang
|
|||||||
if ( source == 1 ) cb(NULL, (clipboard_viewer *)data);
|
if ( source == 1 ) cb(NULL, (clipboard_viewer *)data);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
#if !(defined(__APPLE__) || defined(WIN32))
|
#if !(defined(__APPLE__) || defined(WIN32))
|
||||||
extern void fl_register_images();
|
extern void fl_register_images();
|
||||||
@@ -139,12 +141,12 @@ int main()
|
|||||||
image_box = new chess(5, 30, 490, 450);
|
image_box = new chess(5, 30, 490, 450);
|
||||||
image_size = new Fl_Box(FL_NO_BOX, 5, 485, 490, 10, 0);
|
image_size = new Fl_Box(FL_NO_BOX, 5, 485, 490, 10, 0);
|
||||||
g->end();
|
g->end();
|
||||||
g->selection_color(FL_INACTIVE_COLOR);
|
g->selection_color(TAB_COLOR);
|
||||||
|
|
||||||
Fl_Text_Buffer *buffer = new Fl_Text_Buffer();
|
Fl_Text_Buffer *buffer = new Fl_Text_Buffer();
|
||||||
display = new Fl_Text_Display(5,30,490, 460, Fl::clipboard_plain_text); // display will display the text form
|
display = new Fl_Text_Display(5,30,490, 460, Fl::clipboard_plain_text); // display will display the text form
|
||||||
display->buffer(buffer);
|
display->buffer(buffer);
|
||||||
display->selection_color(FL_INACTIVE_COLOR);
|
display->selection_color(TAB_COLOR);
|
||||||
tabs->end();
|
tabs->end();
|
||||||
tabs->resizable(display);
|
tabs->resizable(display);
|
||||||
|
|
||||||
@@ -155,7 +157,7 @@ int main()
|
|||||||
g2->resizable(NULL);
|
g2->resizable(NULL);
|
||||||
win->end();
|
win->end();
|
||||||
win->resizable(tabs);
|
win->resizable(tabs);
|
||||||
win->show();
|
win->show(argc,argv);
|
||||||
#if defined(__APPLE__) || defined(WIN32)
|
#if defined(__APPLE__) || defined(WIN32)
|
||||||
clip_callback(1, tabs); // use clipboard content at start
|
clip_callback(1, tabs); // use clipboard content at start
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user