These have nothing to do with layout, so let's split them to their own file.pull/1529/head
#include "parameters.h" | #include "parameters.h" | ||||
#include "fltk/layout.h" | #include "fltk/layout.h" | ||||
#include "fltk/util.h" | |||||
#include "fltk/MonitorArrangement.h" | #include "fltk/MonitorArrangement.h" | ||||
#include <FL/Fl.H> | #include <FL/Fl.H> |
#include <rfb/Exception.h> | #include <rfb/Exception.h> | ||||
#include "fltk/layout.h" | #include "fltk/layout.h" | ||||
#include "fltk/util.h" | |||||
#include "i18n.h" | #include "i18n.h" | ||||
#include "parameters.h" | #include "parameters.h" | ||||
#include "UserDialog.h" | #include "UserDialog.h" |
#endif | #endif | ||||
#include "fltk/layout.h" | #include "fltk/layout.h" | ||||
#include "fltk/util.h" | |||||
#include "Viewport.h" | #include "Viewport.h" | ||||
#include "CConn.h" | #include "CConn.h" | ||||
#include "OptionsDialog.h" | #include "OptionsDialog.h" |
#define __FLTK_LAYOUT_H__ | #define __FLTK_LAYOUT_H__ | ||||
#include <FL/fl_draw.H> | #include <FL/fl_draw.H> | ||||
#include <FL/Fl_Menu_.H> | |||||
/* Calculates the width of a string as printed by FLTK (pixels) */ | /* Calculates the width of a string as printed by FLTK (pixels) */ | ||||
static inline int gui_str_len(const char *str) | static inline int gui_str_len(const char *str) | ||||
return (int)(len + 0.5f); | return (int)(len + 0.5f); | ||||
} | } | ||||
/* Escapes all @ in text as those have special meaning in labels */ | |||||
static inline size_t fltk_escape(const char *in, char *out, size_t maxlen) | |||||
{ | |||||
size_t len; | |||||
len = 0; | |||||
while (*in != '\0') { | |||||
if (*in == '@') { | |||||
if (maxlen >= 3) { | |||||
*out++ = '@'; | |||||
*out++ = '@'; | |||||
maxlen -= 2; | |||||
} | |||||
len += 2; | |||||
} else { | |||||
if (maxlen >= 2) { | |||||
*out++ = *in; | |||||
maxlen--; | |||||
} | |||||
len += 1; | |||||
} | |||||
in++; | |||||
} | |||||
if (maxlen) | |||||
*out = '\0'; | |||||
return len; | |||||
} | |||||
/* Filter out unsafe characters for menu entries */ | |||||
static inline size_t fltk_menu_escape(const char *in, char *out, size_t maxlen) | |||||
{ | |||||
size_t len; | |||||
len = 0; | |||||
while (*in != '\0') { | |||||
if (*in == '/') { | |||||
if (maxlen >= 3) { | |||||
*out++ = '\\'; | |||||
*out++ = '/'; | |||||
maxlen -= 2; | |||||
} | |||||
len += 2; | |||||
} else { | |||||
if (maxlen >= 2) { | |||||
*out++ = *in; | |||||
maxlen--; | |||||
} | |||||
len += 1; | |||||
} | |||||
in++; | |||||
} | |||||
if (maxlen) | |||||
*out = '\0'; | |||||
return len; | |||||
} | |||||
/* Helper to add menu entries safely */ | |||||
static inline void fltk_menu_add(Fl_Menu_ *menu, const char *text, | |||||
int shortcut, Fl_Callback *cb, | |||||
void *data = 0, int flags = 0) | |||||
{ | |||||
char buffer[1024]; | |||||
if (fltk_menu_escape(text, buffer, sizeof(buffer)) >= sizeof(buffer)) | |||||
return; | |||||
menu->add(buffer, shortcut, cb, data, flags); | |||||
} | |||||
/**** MARGINS ****/ | /**** MARGINS ****/ | ||||
#define OUTER_MARGIN 10 | #define OUTER_MARGIN 10 |
/* Copyright 2011 Pierre Ossman <ossman@cendio.se> for Cendio AB | |||||
* | |||||
* Permission is hereby granted, free of charge, to any person obtaining | |||||
* a copy of this software and associated documentation files (the | |||||
* "Software"), to deal in the Software without restriction, including | |||||
* without limitation the rights to use, copy, modify, merge, publish, | |||||
* distribute, sublicense, and/or sell copies of the Software, and to | |||||
* permit persons to whom the Software is furnished to do so, subject to | |||||
* the following conditions: | |||||
* | |||||
* The above copyright notice and this permission notice shall be | |||||
* included in all copies or substantial portions of the Software. | |||||
* | |||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | |||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | |||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | |||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |||||
* SOFTWARE. | |||||
*/ | |||||
#ifndef __FLTK_UTIL_H__ | |||||
#define __FLTK_UTIL_H__ | |||||
#include <FL/Fl_Menu_.H> | |||||
/* Escapes all @ in text as those have special meaning in labels */ | |||||
static inline size_t fltk_escape(const char *in, char *out, size_t maxlen) | |||||
{ | |||||
size_t len; | |||||
len = 0; | |||||
while (*in != '\0') { | |||||
if (*in == '@') { | |||||
if (maxlen >= 3) { | |||||
*out++ = '@'; | |||||
*out++ = '@'; | |||||
maxlen -= 2; | |||||
} | |||||
len += 2; | |||||
} else { | |||||
if (maxlen >= 2) { | |||||
*out++ = *in; | |||||
maxlen--; | |||||
} | |||||
len += 1; | |||||
} | |||||
in++; | |||||
} | |||||
if (maxlen) | |||||
*out = '\0'; | |||||
return len; | |||||
} | |||||
/* Filter out unsafe characters for menu entries */ | |||||
static inline size_t fltk_menu_escape(const char *in, char *out, size_t maxlen) | |||||
{ | |||||
size_t len; | |||||
len = 0; | |||||
while (*in != '\0') { | |||||
if (*in == '/') { | |||||
if (maxlen >= 3) { | |||||
*out++ = '\\'; | |||||
*out++ = '/'; | |||||
maxlen -= 2; | |||||
} | |||||
len += 2; | |||||
} else { | |||||
if (maxlen >= 2) { | |||||
*out++ = *in; | |||||
maxlen--; | |||||
} | |||||
len += 1; | |||||
} | |||||
in++; | |||||
} | |||||
if (maxlen) | |||||
*out = '\0'; | |||||
return len; | |||||
} | |||||
/* Helper to add menu entries safely */ | |||||
static inline void fltk_menu_add(Fl_Menu_ *menu, const char *text, | |||||
int shortcut, Fl_Callback *cb, | |||||
void *data = 0, int flags = 0) | |||||
{ | |||||
char buffer[1024]; | |||||
if (fltk_menu_escape(text, buffer, sizeof(buffer)) >= sizeof(buffer)) | |||||
return; | |||||
menu->add(buffer, shortcut, cb, data, flags); | |||||
} | |||||
#endif |
#include <FL/fl_ask.H> | #include <FL/fl_ask.H> | ||||
#include <FL/x.H> | #include <FL/x.H> | ||||
#include "fltk/layout.h" | |||||
#include "fltk/util.h" | |||||
#include "i18n.h" | #include "i18n.h" | ||||
#include "parameters.h" | #include "parameters.h" | ||||
#include "CConn.h" | #include "CConn.h" |