Continue moving to Fl_System_Driver the platform_dependent implementations of member functions of the Fl class.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11614 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
3f64e2b28d
commit
7508a033c5
2
FL/Fl.H
2
FL/Fl.H
@ -663,7 +663,7 @@ int main() {
|
||||
position your first window). If the display is not open, this will
|
||||
open it.
|
||||
*/
|
||||
static void get_mouse(int &,int &); // platform dependent
|
||||
static void get_mouse(int &,int &);
|
||||
/**
|
||||
Returns non zero if we had a double click event.
|
||||
\retval Non-zero if the most recent FL_PUSH or FL_KEYBOARD was a "double click".
|
||||
|
@ -133,6 +133,8 @@ public:
|
||||
// optional platform-specific key handling for Fl_Input widget
|
||||
// the default implementation may be enough
|
||||
virtual int input_widget_handle_key(int key, unsigned mods, unsigned shift, Fl_Input *input);
|
||||
// implement to support Fl::get_mouse()
|
||||
virtual void get_mouse(int &x, int &y) {}
|
||||
};
|
||||
|
||||
|
||||
|
@ -122,6 +122,8 @@ public:
|
||||
virtual int filename_isdir_quick(const char* n);
|
||||
// the default implementation of filename_ext() is in src/filename_ext.cxx and may be enough
|
||||
virtual const char *filename_ext(const char *buf);
|
||||
// implement to support fl_filename_name()
|
||||
virtual const char *filename_name(const char *buf) {return buf;}
|
||||
// whether a platform uses additional code in Fl_Menu::handle(int e)
|
||||
virtual int need_menu_handle_part2() {return 0;}
|
||||
// whether a platform uses additional code in Fl_Menu::handle_part1(int e)
|
||||
@ -191,6 +193,8 @@ public:
|
||||
static const char * const tree_close_xpm[]; // used by tree_closepixmap()
|
||||
// the default implementation of tree_connector_style() is in Fl_Tree_Prefs.cxx and can be enough
|
||||
virtual int tree_connector_style();
|
||||
//implement to support copy-to-clipboard
|
||||
virtual void copy(const char *stuff, int len, int clipboard, const char *type) {}
|
||||
};
|
||||
|
||||
#endif // FL_SYSTEM_DRIVER_H
|
||||
|
1
FL/mac.H
1
FL/mac.H
@ -165,7 +165,6 @@ public:
|
||||
int set_cursor(const Fl_RGB_Image*, int, int);
|
||||
static CGImageRef CGImage_from_window_rect(Fl_Window *win, int x, int y, int w, int h);
|
||||
static unsigned char *bitmap_from_window_rect(Fl_Window *win, int x, int y, int w, int h, int *bytesPerPixel);
|
||||
static void clip_to_rounded_corners(CGContextRef gc, int w, int h);
|
||||
private:
|
||||
CGRect* subRect_; // makes sure subwindow remains inside its parent window
|
||||
// stores 3 binary flags: whether window is mapped to retina display; whether resolution just changed;
|
||||
|
12
src/Fl.cxx
12
src/Fl.cxx
@ -1920,6 +1920,18 @@ int Fl::get_key(int k) {
|
||||
return system_driver()->get_key(k);
|
||||
}
|
||||
|
||||
void Fl::get_mouse(int &x, int &y) {
|
||||
Fl::screen_driver()->get_mouse(x, y);
|
||||
}
|
||||
|
||||
const char * fl_filename_name(const char *name) {
|
||||
return Fl::system_driver()->filename_name(name);
|
||||
}
|
||||
|
||||
void Fl::copy(const char *stuff, int len, int clipboard, const char *type) {
|
||||
Fl::system_driver()->copy(stuff, len, clipboard, type);
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
||||
|
@ -53,7 +53,7 @@ int Fl_Screen_Driver::visual(int) {
|
||||
void Fl_Screen_Driver::screen_xywh(int &X, int &Y, int &W, int &H)
|
||||
{
|
||||
int x, y;
|
||||
Fl::get_mouse(x, y);
|
||||
get_mouse(x, y);
|
||||
screen_xywh(X, Y, W, H, x, y);
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ void Fl_Screen_Driver::screen_xywh(int &X, int &Y, int &W, int &H, int mx, int m
|
||||
void Fl_Screen_Driver::screen_work_area(int &X, int &Y, int &W, int &H)
|
||||
{
|
||||
int x, y;
|
||||
Fl::get_mouse(x, y);
|
||||
get_mouse(x, y);
|
||||
screen_work_area(X, Y, W, H, x, y);
|
||||
}
|
||||
|
||||
|
@ -1920,7 +1920,7 @@ void Fl_Cocoa_Screen_Driver::screen_work_area(int &X, int &Y, int &W, int &H, in
|
||||
/*
|
||||
* get the current mouse pointer world coordinates
|
||||
*/
|
||||
void Fl::get_mouse(int &x, int &y)
|
||||
void Fl_Cocoa_Screen_Driver::get_mouse(int &x, int &y)
|
||||
{
|
||||
fl_open_display();
|
||||
NSPoint pt = [NSEvent mouseLocation];
|
||||
@ -3114,7 +3114,7 @@ void Fl_Cocoa_Window_Driver::wait_for_expose()
|
||||
/*
|
||||
* returns pointer to the filename, or null if name ends with ':'
|
||||
*/
|
||||
const char *fl_filename_name( const char *name )
|
||||
const char *Fl_Darwin_System_Driver::filename_name( const char *name )
|
||||
{
|
||||
const char *p, *q;
|
||||
if (!name) return (0);
|
||||
@ -3379,7 +3379,7 @@ static void resize_selection_buffer(int len, int clipboard) {
|
||||
* len: size of selected data
|
||||
* type: always "plain/text" for now
|
||||
*/
|
||||
void Fl::copy(const char *stuff, int len, int clipboard, const char *type) {
|
||||
void Fl_Darwin_System_Driver::copy(const char *stuff, int len, int clipboard, const char *type) {
|
||||
if (!stuff || len<0) return;
|
||||
if (clipboard >= 2)
|
||||
clipboard = 1; // Only on X11 do multiple clipboards make sense.
|
||||
@ -4268,7 +4268,7 @@ int Fl_Cocoa_Window_Driver::decorated_h()
|
||||
}
|
||||
|
||||
// clip the graphics context to rounded corners
|
||||
void Fl_X::clip_to_rounded_corners(CGContextRef gc, int w, int h) {
|
||||
static void clip_to_rounded_corners(CGContextRef gc, int w, int h) {
|
||||
const CGFloat radius = 5;
|
||||
CGContextMoveToPoint(gc, 0, 0);
|
||||
CGContextAddLineToPoint(gc, 0, h - radius);
|
||||
@ -4294,7 +4294,7 @@ void Fl_Cocoa_Window_Driver::draw_layer_to_context(CALayer *layer, CGContextRef
|
||||
{
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
|
||||
CGContextSaveGState(gc);
|
||||
Fl_X::clip_to_rounded_corners(gc, w, h);
|
||||
clip_to_rounded_corners(gc, w, h);
|
||||
CGContextSetRGBFillColor(gc, .79, .79, .79, 1.); // equiv. to FL_DARK1
|
||||
CGContextFillRect(gc, CGRectMake(0, 0, w, h));
|
||||
CGContextSetShouldAntialias(gc, true);
|
||||
@ -4322,7 +4322,7 @@ void Fl_Cocoa_Window_Driver::capture_titlebar_and_borders(Fl_Shared_Image*& top,
|
||||
} else {
|
||||
CGImageRef img = Fl_X::CGImage_from_window_rect(pWindow, 0, -htop, w(), htop);
|
||||
CGContextSaveGState(auxgc);
|
||||
Fl_X::clip_to_rounded_corners(auxgc, w(), htop);
|
||||
clip_to_rounded_corners(auxgc, w(), htop);
|
||||
CGContextDrawImage(auxgc, CGRectMake(0, 0, w(), htop), img);
|
||||
CGContextRestoreGState(auxgc);
|
||||
CFRelease(img);
|
||||
|
@ -55,6 +55,7 @@ void fl_cleanup_dc_list(void);
|
||||
#include <FL/Fl_Graphics_Driver.H> // for fl_graphics_driver
|
||||
#include "drivers/WinAPI/Fl_WinAPI_Window_Driver.H"
|
||||
#include "drivers/WinAPI/Fl_WinAPI_System_Driver.H"
|
||||
#include "drivers/WinAPI/Fl_WinAPI_Screen_Driver.H"
|
||||
#include <FL/fl_utf8.h>
|
||||
#include <FL/Fl_Window.H>
|
||||
#include <FL/fl_draw.H>
|
||||
@ -573,7 +574,7 @@ void Fl::disable_im() {
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
void Fl::get_mouse(int &x, int &y) {
|
||||
void Fl_WinAPI_Screen_Driver::get_mouse(int &x, int &y) {
|
||||
POINT p;
|
||||
GetCursorPos(&p);
|
||||
x = p.x;
|
||||
@ -666,7 +667,7 @@ void fl_update_clipboard(void) {
|
||||
}
|
||||
|
||||
// call this when you create a selection:
|
||||
void Fl::copy(const char *stuff, int len, int clipboard, const char *type) {
|
||||
void Fl_WinAPI_System_Driver::copy(const char *stuff, int len, int clipboard, const char *type) {
|
||||
if (!stuff || len<0) return;
|
||||
if (clipboard >= 2)
|
||||
clipboard = 1; // Only on X11 do multiple clipboards make sense.
|
||||
@ -1928,12 +1929,11 @@ void Fl_X::set_minmax(LPMINMAXINFO minmax)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <FL/filename.H> // need so FL_EXPORT fl_filename_name works
|
||||
|
||||
// returns pointer to the filename, or null if name ends with '/'
|
||||
const char *fl_filename_name(const char *name) {
|
||||
const char *Fl_WinAPI_System_Driver::filename_name(const char *name) {
|
||||
const char *p,*q;
|
||||
if (!name) return (0);
|
||||
q = name;
|
||||
|
@ -39,6 +39,7 @@
|
||||
# include "flstring.h"
|
||||
# include "drivers/X11/Fl_X11_Screen_Driver.H"
|
||||
# include "drivers/X11/Fl_X11_Window_Driver.H"
|
||||
# include "drivers/X11/Fl_X11_System_Driver.H"
|
||||
# include <unistd.h>
|
||||
# include <time.h>
|
||||
# include <sys/time.h>
|
||||
@ -787,7 +788,7 @@ void fl_close_display() {
|
||||
}
|
||||
|
||||
|
||||
void Fl::get_mouse(int &xx, int &yy) {
|
||||
void Fl_X11_Screen_Driver::get_mouse(int &xx, int &yy) {
|
||||
fl_open_display();
|
||||
Window root = RootWindow(fl_display, fl_screen);
|
||||
Window c; int mx,my,cx,cy; unsigned int mask;
|
||||
@ -940,7 +941,7 @@ static int get_xwinprop(Window wnd, Atom prop, long max_length,
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Code for copying to clipboard and DnD out of the program:
|
||||
|
||||
void Fl::copy(const char *stuff, int len, int clipboard, const char *type) {
|
||||
void Fl_X11_System_Driver::copy(const char *stuff, int len, int clipboard, const char *type) {
|
||||
if (!stuff || len<0) return;
|
||||
|
||||
if (clipboard >= 2) {
|
||||
@ -2844,7 +2845,7 @@ int Fl_X::set_cursor(const Fl_RGB_Image *image, int hotx, int hoty) {
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
// returns pointer to the filename, or null if name ends with '/'
|
||||
const char *fl_filename_name(const char *name) {
|
||||
const char *Fl_X11_System_Driver::filename_name(const char *name) {
|
||||
const char *p,*q;
|
||||
if (!name) return (0);
|
||||
for (p=q=name; *p;) if (*p++ == '/') q = p;
|
||||
|
@ -90,6 +90,7 @@ public:
|
||||
virtual int compose(int &del);
|
||||
virtual uchar *read_image(uchar *p, int x, int y, int w, int h, int alpha);
|
||||
virtual int input_widget_handle_key(int key, unsigned mods, unsigned shift, Fl_Input *input);
|
||||
virtual void get_mouse(int &x, int &y);
|
||||
};
|
||||
|
||||
|
||||
|
@ -68,6 +68,8 @@ public:
|
||||
virtual Fl_Pixmap *tree_closepixmap();
|
||||
static const char * const tree_close_xpm_darwin[]; // used by tree_closepixmap()
|
||||
virtual int tree_connector_style();
|
||||
virtual const char *filename_name(const char *buf);
|
||||
virtual void copy(const char *stuff, int len, int clipboard, const char *type);
|
||||
};
|
||||
|
||||
#endif // FL_DARWIN_SYSTEM_DRIVER_H
|
||||
|
@ -72,6 +72,7 @@ public:
|
||||
virtual int dnd(int unused);
|
||||
virtual int compose(int &del);
|
||||
virtual uchar *read_win_rectangle(uchar *p, int X, int Y, int w, int h, int alpha);
|
||||
virtual void get_mouse(int &x, int &y);
|
||||
};
|
||||
|
||||
|
||||
|
@ -102,6 +102,10 @@ public:
|
||||
virtual int backslash_as_slash() {return 1;}
|
||||
virtual int colon_is_drive() {return 1;}
|
||||
virtual int case_insensitive_filenames() {return 1;}
|
||||
// this one is implemented in Fl_win32.cxx
|
||||
virtual const char *filename_name(const char *buf);
|
||||
// this one is in Fl_win32.cxx
|
||||
virtual void copy(const char *stuff, int len, int clipboard, const char *type);
|
||||
};
|
||||
|
||||
#endif // FL_WINAPI_SYSTEM_DRIVER_H
|
||||
|
@ -78,6 +78,7 @@ public:
|
||||
virtual void compose_reset();
|
||||
virtual int text_display_can_leak();
|
||||
virtual uchar *read_win_rectangle(uchar *p, int X, int Y, int w, int h, int alpha);
|
||||
virtual void get_mouse(int &x, int &y);
|
||||
};
|
||||
|
||||
|
||||
|
@ -45,6 +45,10 @@ public:
|
||||
virtual int utf8locale();
|
||||
// this one is in Fl_own_colormap.cxx
|
||||
virtual void own_colormap();
|
||||
// this one is in Fl_x.cxx
|
||||
virtual const char *filename_name(const char *buf);
|
||||
// this one is in Fl_x.cxx
|
||||
virtual void copy(const char *stuff, int len, int clipboard, const char *type);
|
||||
};
|
||||
|
||||
#endif /* FL_X11_SYSTEM_DRIVER_H */
|
||||
|
Loading…
x
Reference in New Issue
Block a user