2004-05-05 02:23:44 +04:00
|
|
|
/*
|
2005-04-09 17:23:55 +04:00
|
|
|
* Copyright 2004, 2005 Richard Wilson <info@tinct.net>
|
2008-08-05 05:23:04 +04:00
|
|
|
* Copyright 2008 John Tytgat <joty@netsurf-browser.org>
|
2007-08-08 20:16:03 +04:00
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2004-05-05 02:23:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
* General RISC OS WIMP/OS library functions (implementation).
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
The core code has always assumed a locale of "C".
Do not change the locale globally, else things will break in weird and
wonderful ways.
Introduce utils/locale.[ch], which provide locale-specific wrappers for various
functions (currently just the <ctype.h> ones).
Fix up the few places I can see that actually require that the underlying
locale is paid attention to.
Some notes:
1) The GTK frontend code has not been touched. It is possible that reading of
numeric values (e.g. from the preferences dialogue) may break with this
change, particularly in locales that use something other than '.' as their
decimal separator.
2) The search code is left unchanged (i.e. assuming a locale of "C").
This may break case insensitive matching of non-ASCII characters.
I doubt that ever actually worked, anyway. In future, it should use
Unicode case conversion to achieve the same effect.
3) The text input handling in the core makes use of isspace() to detect
word boundaries. This is fine for western languages (even in the C locale,
which it's currently assuming). It will, however, break for CJK et. al.
(this has always been the case, rather than being a new issue)
4) text-transform uses locale-specific variants of to{lower,upper}. In future
this should probably be performing Unicode case conversion. This is the
only part of the core code that makes use of locale information.
In future, if you require locale-specific behaviour, do the following:
setlocale(LC_<whatever>, "");
<your operation(s) here>
setlocale(LC_<whatever>, "C");
The first setlocale will change the current locale to the native environment.
The second setlocale will reset the current locale to "C".
Any value other than "" or "C" is probably a bug, unless there's a really
good reason for it.
In the long term, it is expected that all locale-dependent code will reside in
platform frontends -- the core being wholly locale agnostic (though assuming
"C" for things like decimal separators).
svn path=/trunk/netsurf/; revision=4153
2008-05-13 18:37:44 +04:00
|
|
|
#include <locale.h>
|
2004-07-11 17:05:38 +04:00
|
|
|
#include <stdbool.h>
|
2004-05-05 02:23:44 +04:00
|
|
|
#include <stdlib.h>
|
2004-07-11 17:05:38 +04:00
|
|
|
#include <string.h>
|
2004-05-05 02:23:44 +04:00
|
|
|
#include <stdio.h>
|
2005-03-14 16:58:43 +03:00
|
|
|
#include "oslib/colourtrans.h"
|
2004-05-05 02:23:44 +04:00
|
|
|
#include "oslib/os.h"
|
2004-05-23 03:04:44 +04:00
|
|
|
#include "oslib/osfile.h"
|
2004-05-05 02:23:44 +04:00
|
|
|
#include "oslib/wimp.h"
|
|
|
|
#include "oslib/wimpextend.h"
|
2004-07-11 17:05:38 +04:00
|
|
|
#include "oslib/wimpspriteop.h"
|
2014-10-16 12:50:55 +04:00
|
|
|
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "utils/log.h"
|
|
|
|
#include "utils/utf8.h"
|
2014-10-16 12:50:55 +04:00
|
|
|
|
|
|
|
#include "riscos/gui.h"
|
|
|
|
#include "riscos/oslib_pre7.h"
|
|
|
|
#include "riscos/wimp.h"
|
2014-02-02 02:17:36 +04:00
|
|
|
#include "riscos/ucstables.h"
|
2004-05-05 02:23:44 +04:00
|
|
|
|
2006-07-18 05:51:19 +04:00
|
|
|
|
2005-04-09 18:58:54 +04:00
|
|
|
static void ro_gui_wimp_cache_furniture_sizes(wimp_w w);
|
2007-08-04 15:47:40 +04:00
|
|
|
static size_t ro_gui_strlen(const char *str);
|
2008-08-05 05:23:04 +04:00
|
|
|
static int ro_gui_strncmp(const char *s1, const char *s2, size_t len);
|
2005-04-08 00:46:22 +04:00
|
|
|
|
2004-05-05 02:23:44 +04:00
|
|
|
static wimpextend_furniture_sizes furniture_sizes;
|
2005-04-08 00:46:22 +04:00
|
|
|
static wimp_w furniture_window = NULL;
|
2004-05-23 16:22:05 +04:00
|
|
|
|
2004-05-05 02:23:44 +04:00
|
|
|
/**
|
The core code has always assumed a locale of "C".
Do not change the locale globally, else things will break in weird and
wonderful ways.
Introduce utils/locale.[ch], which provide locale-specific wrappers for various
functions (currently just the <ctype.h> ones).
Fix up the few places I can see that actually require that the underlying
locale is paid attention to.
Some notes:
1) The GTK frontend code has not been touched. It is possible that reading of
numeric values (e.g. from the preferences dialogue) may break with this
change, particularly in locales that use something other than '.' as their
decimal separator.
2) The search code is left unchanged (i.e. assuming a locale of "C").
This may break case insensitive matching of non-ASCII characters.
I doubt that ever actually worked, anyway. In future, it should use
Unicode case conversion to achieve the same effect.
3) The text input handling in the core makes use of isspace() to detect
word boundaries. This is fine for western languages (even in the C locale,
which it's currently assuming). It will, however, break for CJK et. al.
(this has always been the case, rather than being a new issue)
4) text-transform uses locale-specific variants of to{lower,upper}. In future
this should probably be performing Unicode case conversion. This is the
only part of the core code that makes use of locale information.
In future, if you require locale-specific behaviour, do the following:
setlocale(LC_<whatever>, "");
<your operation(s) here>
setlocale(LC_<whatever>, "C");
The first setlocale will change the current locale to the native environment.
The second setlocale will reset the current locale to "C".
Any value other than "" or "C" is probably a bug, unless there's a really
good reason for it.
In the long term, it is expected that all locale-dependent code will reside in
platform frontends -- the core being wholly locale agnostic (though assuming
"C" for things like decimal separators).
svn path=/trunk/netsurf/; revision=4153
2008-05-13 18:37:44 +04:00
|
|
|
* Gets the horizontal scrollbar height
|
2005-04-08 00:46:22 +04:00
|
|
|
*
|
|
|
|
* \param w the window to read (or NULL to read a cached value)
|
2004-05-05 02:23:44 +04:00
|
|
|
*/
|
2008-07-27 02:29:15 +04:00
|
|
|
int ro_get_hscroll_height(wimp_w w)
|
|
|
|
{
|
2005-04-09 17:23:55 +04:00
|
|
|
ro_gui_wimp_cache_furniture_sizes(w);
|
2005-04-09 18:58:54 +04:00
|
|
|
return furniture_sizes.border_widths.y0;
|
2004-05-05 02:23:44 +04:00
|
|
|
}
|
|
|
|
|
2004-05-23 16:22:05 +04:00
|
|
|
|
|
|
|
/**
|
2004-06-28 23:35:04 +04:00
|
|
|
* Gets the vertical scrollbar width
|
2005-04-08 00:46:22 +04:00
|
|
|
*
|
|
|
|
* \param w the window to read (or NULL to read a cached value)
|
2004-05-23 16:22:05 +04:00
|
|
|
*/
|
2008-07-27 02:29:15 +04:00
|
|
|
int ro_get_vscroll_width(wimp_w w)
|
|
|
|
{
|
2005-04-09 17:23:55 +04:00
|
|
|
ro_gui_wimp_cache_furniture_sizes(w);
|
2005-04-09 18:58:54 +04:00
|
|
|
return furniture_sizes.border_widths.x1;
|
2005-04-08 00:46:22 +04:00
|
|
|
}
|
2004-05-23 16:22:05 +04:00
|
|
|
|
2007-03-03 23:49:49 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the title bar height
|
|
|
|
*
|
|
|
|
* \param w the window to read (or NULL to read a cached value)
|
|
|
|
*/
|
2008-07-27 02:29:15 +04:00
|
|
|
int ro_get_title_height(wimp_w w)
|
|
|
|
{
|
2007-03-03 23:49:49 +03:00
|
|
|
ro_gui_wimp_cache_furniture_sizes(w);
|
|
|
|
return furniture_sizes.border_widths.y1;
|
|
|
|
}
|
|
|
|
|
2005-04-08 00:46:22 +04:00
|
|
|
/**
|
|
|
|
* Caches window furniture information
|
|
|
|
*
|
|
|
|
* \param w the window to cache information from
|
2005-04-09 17:23:55 +04:00
|
|
|
* \return true on success, false on error (default values cached)
|
2005-04-08 00:46:22 +04:00
|
|
|
*/
|
2008-07-27 02:29:15 +04:00
|
|
|
void ro_gui_wimp_cache_furniture_sizes(wimp_w w)
|
|
|
|
{
|
2005-04-08 00:46:22 +04:00
|
|
|
os_error *error;
|
2004-05-23 16:22:05 +04:00
|
|
|
|
2005-04-09 17:23:55 +04:00
|
|
|
if (furniture_window == w)
|
2005-04-09 18:58:54 +04:00
|
|
|
return;
|
|
|
|
furniture_window = w;
|
2005-04-08 00:46:22 +04:00
|
|
|
furniture_sizes.w = w;
|
2005-04-09 18:58:54 +04:00
|
|
|
furniture_sizes.border_widths.y0 = 40;
|
|
|
|
furniture_sizes.border_widths.x1 = 40;
|
2005-04-08 00:46:22 +04:00
|
|
|
error = xwimpextend_get_furniture_sizes(&furniture_sizes);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO,
|
|
|
|
"xwimpextend_get_furniture_sizes: 0x%x: %s",
|
|
|
|
error->errnum,
|
|
|
|
error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2005-04-09 17:23:55 +04:00
|
|
|
}
|
2004-05-23 16:22:05 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-05 02:23:44 +04:00
|
|
|
/**
|
|
|
|
* Reads a modes EIG factors.
|
|
|
|
*
|
2014-11-13 02:27:13 +03:00
|
|
|
* \param[in] mode mode to read EIG factors for, or -1 for current
|
|
|
|
* \param[out] xeig The x eig value
|
|
|
|
* \param[out] yeig The y eig value
|
|
|
|
* \return true on success else false.
|
2004-05-05 02:23:44 +04:00
|
|
|
*/
|
2008-07-27 02:29:15 +04:00
|
|
|
bool ro_gui_wimp_read_eig_factors(os_mode mode, int *xeig, int *yeig)
|
|
|
|
{
|
2005-04-08 00:46:22 +04:00
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
error = xos_read_mode_variable(mode, os_MODEVAR_XEIG_FACTOR, xeig, 0);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xos_read_mode_variable: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("MiscError", error->errmess);
|
2005-04-08 00:46:22 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
error = xos_read_mode_variable(mode, os_MODEVAR_YEIG_FACTOR, yeig, 0);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xos_read_mode_variable: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("MiscError", error->errmess);
|
2005-04-08 00:46:22 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2004-05-05 02:23:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts the supplied os_coord from OS units to pixels.
|
|
|
|
*
|
|
|
|
* \param os_units values to convert
|
2005-04-08 00:46:22 +04:00
|
|
|
* \param mode mode to use EIG factors for, or -1 for current
|
2004-05-05 02:23:44 +04:00
|
|
|
*/
|
2008-07-27 02:29:15 +04:00
|
|
|
void ro_convert_os_units_to_pixels(os_coord *os_units, os_mode mode)
|
|
|
|
{
|
2005-04-12 23:09:09 +04:00
|
|
|
int xeig = 1, yeig = 1;
|
2005-04-08 00:46:22 +04:00
|
|
|
|
|
|
|
ro_gui_wimp_read_eig_factors(mode, &xeig, &yeig);
|
2005-04-12 23:09:09 +04:00
|
|
|
os_units->x = ((os_units->x + (1 << xeig) - 1) >> xeig);
|
|
|
|
os_units->y = ((os_units->y + (1 << yeig) - 1) >> yeig);
|
2004-05-05 02:23:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts the supplied os_coord from pixels to OS units.
|
|
|
|
*
|
|
|
|
* \param pixels values to convert
|
2005-04-08 00:46:22 +04:00
|
|
|
* \param mode mode to use EIG factors for, or -1 for current
|
2004-05-05 02:23:44 +04:00
|
|
|
*/
|
2008-07-27 02:29:15 +04:00
|
|
|
void ro_convert_pixels_to_os_units(os_coord *pixels, os_mode mode)
|
|
|
|
{
|
2005-04-12 23:09:09 +04:00
|
|
|
int xeig = 1, yeig = 1;
|
2005-04-08 00:46:22 +04:00
|
|
|
|
|
|
|
ro_gui_wimp_read_eig_factors(mode, &xeig, &yeig);
|
|
|
|
pixels->x = (pixels->x << xeig);
|
|
|
|
pixels->y = (pixels->y << yeig);
|
2004-05-05 02:23:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Redraws an icon
|
|
|
|
*
|
|
|
|
* \param w window handle
|
|
|
|
* \param i icon handle
|
|
|
|
*/
|
2005-07-24 07:13:33 +04:00
|
|
|
|
2004-05-05 02:23:44 +04:00
|
|
|
#define ro_gui_redraw_icon(w, i) xwimp_set_icon_state(w, i, 0, 0)
|
|
|
|
|
|
|
|
|
2005-01-23 19:09:05 +03:00
|
|
|
/**
|
|
|
|
* Forces an icon to be redrawn entirely (ie not just updated).
|
|
|
|
*
|
|
|
|
* \param w window handle
|
|
|
|
* \param i icon handle
|
|
|
|
*/
|
2008-07-27 02:29:15 +04:00
|
|
|
void ro_gui_force_redraw_icon(wimp_w w, wimp_i i)
|
|
|
|
{
|
2005-01-23 19:09:05 +03:00
|
|
|
wimp_icon_state ic;
|
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
/* Get the icon data
|
|
|
|
*/
|
|
|
|
ic.w = w;
|
|
|
|
ic.i = i;
|
|
|
|
error = xwimp_get_icon_state(&ic);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2005-01-23 19:09:05 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
error = xwimp_force_redraw(w, ic.icon.extent.x0, ic.icon.extent.y0,
|
|
|
|
ic.icon.extent.x1, ic.icon.extent.y1);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_force_redraw: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2005-01-23 19:09:05 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-05 02:23:44 +04:00
|
|
|
/**
|
2008-08-05 05:23:04 +04:00
|
|
|
* Read the contents of a text or sprite icon.
|
2004-05-05 02:23:44 +04:00
|
|
|
*
|
|
|
|
* \param w window handle
|
|
|
|
* \param i icon handle
|
2008-08-05 05:23:04 +04:00
|
|
|
* \return NUL terminated string in icon
|
|
|
|
*
|
2009-05-30 04:26:04 +04:00
|
|
|
* If the icon contains direct text then the returned data will
|
|
|
|
* be invalidated by the next call to this function. Therefore,
|
|
|
|
* all client calls to this function must either copy the string or
|
|
|
|
* ensure that this function is not called again until they are
|
|
|
|
* finished with the string data returned.
|
|
|
|
*
|
2008-08-05 05:23:04 +04:00
|
|
|
* \todo this doesn't do local encoding -> UTF-8 to match what is done in
|
|
|
|
* ro_gui_set_icon_string.
|
2004-05-05 02:23:44 +04:00
|
|
|
*/
|
2008-08-05 05:23:04 +04:00
|
|
|
const char *ro_gui_get_icon_string(wimp_w w, wimp_i i)
|
2008-07-27 02:29:15 +04:00
|
|
|
{
|
2009-05-30 04:26:04 +04:00
|
|
|
static wimp_icon_state ic;
|
2005-04-08 00:46:22 +04:00
|
|
|
os_error *error;
|
2008-08-05 05:23:04 +04:00
|
|
|
char *itext;
|
2005-04-08 00:46:22 +04:00
|
|
|
|
2004-05-05 02:23:44 +04:00
|
|
|
ic.w = w;
|
|
|
|
ic.i = i;
|
2005-04-08 00:46:22 +04:00
|
|
|
error = xwimp_get_icon_state(&ic);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2005-04-08 00:46:22 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
2009-05-30 04:26:04 +04:00
|
|
|
itext = (ic.icon.flags & wimp_ICON_INDIRECTED)
|
|
|
|
? ic.icon.data.indirected_text.text : ic.icon.data.text;
|
2009-03-28 22:59:46 +03:00
|
|
|
/* Guarantee NUL termination. */
|
2008-08-05 05:23:04 +04:00
|
|
|
itext[ro_gui_strlen(itext)] = '\0';
|
2009-05-30 04:26:04 +04:00
|
|
|
|
2008-08-05 05:23:04 +04:00
|
|
|
return itext;
|
2004-05-05 02:23:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2008-08-05 05:23:04 +04:00
|
|
|
* Set the contents of a text or sprite icon to a string.
|
2004-05-05 02:23:44 +04:00
|
|
|
*
|
2005-04-08 00:46:22 +04:00
|
|
|
* \param w window handle
|
|
|
|
* \param i icon handle
|
2008-08-05 05:23:04 +04:00
|
|
|
* \param text NUL terminated string (copied)
|
|
|
|
* \param is_utf8 When true, the given string is UTF-8 encoded and will be
|
|
|
|
* converted to local encoding currently used by the Wimp. When false, the
|
|
|
|
* given string is assumed to be in local encoding in use by the Wimp.
|
2004-05-05 02:23:44 +04:00
|
|
|
*/
|
2008-08-05 05:23:04 +04:00
|
|
|
void ro_gui_set_icon_string(wimp_w w, wimp_i i, const char *text, bool is_utf8)
|
2008-07-27 02:29:15 +04:00
|
|
|
{
|
2004-05-07 01:18:26 +04:00
|
|
|
wimp_caret caret;
|
2004-05-05 02:23:44 +04:00
|
|
|
wimp_icon_state ic;
|
2005-04-08 00:46:22 +04:00
|
|
|
os_error *error;
|
2008-08-05 05:23:04 +04:00
|
|
|
size_t old_len, new_len;
|
2006-09-26 02:27:41 +04:00
|
|
|
char *local_text = NULL;
|
2008-08-05 05:23:04 +04:00
|
|
|
const char *text_for_icon;
|
|
|
|
char *dst_text;
|
|
|
|
size_t dst_max_len;
|
2006-06-29 02:58:58 +04:00
|
|
|
unsigned int button_type;
|
2004-05-07 01:18:26 +04:00
|
|
|
|
2008-08-05 05:23:04 +04:00
|
|
|
if (is_utf8) {
|
2014-01-29 01:40:13 +04:00
|
|
|
nserror err;
|
2008-08-05 05:23:04 +04:00
|
|
|
/* convert text to local encoding */
|
|
|
|
err = utf8_to_local_encoding(text, 0, &local_text);
|
2014-01-29 01:40:13 +04:00
|
|
|
if (err != NSERROR_OK) {
|
2008-08-05 05:23:04 +04:00
|
|
|
/* A bad encoding should never happen, so assert this */
|
2014-01-29 01:40:13 +04:00
|
|
|
assert(err != NSERROR_BAD_ENCODING);
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "utf8_to_enc failed");
|
2008-08-05 05:23:04 +04:00
|
|
|
/* Paranoia */
|
|
|
|
local_text = NULL;
|
|
|
|
}
|
|
|
|
text_for_icon = local_text ? local_text : text;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
text_for_icon = text;
|
|
|
|
new_len = strlen(text_for_icon);
|
|
|
|
|
2005-04-08 00:46:22 +04:00
|
|
|
/* get the icon data */
|
2004-05-05 02:23:44 +04:00
|
|
|
ic.w = w;
|
|
|
|
ic.i = i;
|
2005-04-08 00:46:22 +04:00
|
|
|
error = xwimp_get_icon_state(&ic);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2008-08-05 05:23:04 +04:00
|
|
|
goto exit;
|
2005-04-08 00:46:22 +04:00
|
|
|
}
|
2004-05-07 01:18:26 +04:00
|
|
|
|
2008-08-05 05:23:04 +04:00
|
|
|
if (ic.icon.flags & wimp_ICON_INDIRECTED) {
|
|
|
|
dst_text = ic.icon.data.indirected_text.text;
|
|
|
|
dst_max_len = ic.icon.data.indirected_text.size;
|
2005-07-16 18:35:25 +04:00
|
|
|
}
|
2008-08-05 05:23:04 +04:00
|
|
|
else {
|
|
|
|
dst_text = ic.icon.data.text;
|
|
|
|
dst_max_len = sizeof(ic.icon.data.text);
|
|
|
|
}
|
|
|
|
old_len = ro_gui_strlen(dst_text);
|
|
|
|
assert(old_len < dst_max_len);
|
2005-07-16 18:35:25 +04:00
|
|
|
|
2005-04-08 00:46:22 +04:00
|
|
|
/* check that the existing text is not the same as the updated text
|
|
|
|
* to stop flicker */
|
2008-08-05 05:23:04 +04:00
|
|
|
if (dst_max_len) {
|
|
|
|
if (!ro_gui_strncmp(dst_text, text_for_icon, dst_max_len))
|
|
|
|
goto exit;
|
|
|
|
|
|
|
|
/* copy the text across */
|
|
|
|
strncpy(dst_text, text_for_icon, dst_max_len - 1);
|
|
|
|
dst_text[dst_max_len - 1] = '\0';
|
|
|
|
|
|
|
|
/* handle the caret being in the icon */
|
|
|
|
button_type = (ic.icon.flags & wimp_ICON_BUTTON_TYPE)
|
|
|
|
>> wimp_ICON_BUTTON_TYPE_SHIFT;
|
|
|
|
if ((button_type == wimp_BUTTON_WRITABLE) ||
|
|
|
|
(button_type == wimp_BUTTON_WRITE_CLICK_DRAG)) {
|
|
|
|
error = xwimp_get_caret_position(&caret);
|
2006-06-29 02:58:58 +04:00
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO,
|
|
|
|
"xwimp_get_caret_position: 0x%x: %s",
|
|
|
|
error->errnum,
|
|
|
|
error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2008-08-05 05:23:04 +04:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
if ((caret.w == w) && (caret.i == i)) {
|
|
|
|
if ((size_t)caret.index > new_len
|
|
|
|
|| (size_t)caret.index == old_len)
|
|
|
|
caret.index = new_len;
|
|
|
|
error = xwimp_set_caret_position(w, i, caret.pos.x,
|
|
|
|
caret.pos.y, -1, caret.index);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO,
|
|
|
|
"xwimp_set_caret_position: 0x%x: %s",
|
|
|
|
error->errnum,
|
|
|
|
error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2008-08-05 05:23:04 +04:00
|
|
|
}
|
2006-06-29 02:58:58 +04:00
|
|
|
}
|
2004-05-05 02:23:44 +04:00
|
|
|
}
|
2008-08-05 05:23:04 +04:00
|
|
|
ro_gui_redraw_icon(w, i);
|
2004-05-05 02:23:44 +04:00
|
|
|
}
|
2005-07-16 18:35:25 +04:00
|
|
|
|
2008-08-05 05:23:04 +04:00
|
|
|
exit:
|
2005-07-16 18:35:25 +04:00
|
|
|
free(local_text);
|
2004-05-05 02:23:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the contents of an icon to a number.
|
|
|
|
*
|
2005-04-08 00:46:22 +04:00
|
|
|
* \param w window handle
|
|
|
|
* \param i icon handle
|
2004-05-05 02:23:44 +04:00
|
|
|
* \param value value
|
|
|
|
*/
|
2008-07-27 02:29:15 +04:00
|
|
|
void ro_gui_set_icon_integer(wimp_w w, wimp_i i, int value)
|
|
|
|
{
|
2004-05-05 02:23:44 +04:00
|
|
|
char buffer[20]; // Big enough for 64-bit int
|
The core code has always assumed a locale of "C".
Do not change the locale globally, else things will break in weird and
wonderful ways.
Introduce utils/locale.[ch], which provide locale-specific wrappers for various
functions (currently just the <ctype.h> ones).
Fix up the few places I can see that actually require that the underlying
locale is paid attention to.
Some notes:
1) The GTK frontend code has not been touched. It is possible that reading of
numeric values (e.g. from the preferences dialogue) may break with this
change, particularly in locales that use something other than '.' as their
decimal separator.
2) The search code is left unchanged (i.e. assuming a locale of "C").
This may break case insensitive matching of non-ASCII characters.
I doubt that ever actually worked, anyway. In future, it should use
Unicode case conversion to achieve the same effect.
3) The text input handling in the core makes use of isspace() to detect
word boundaries. This is fine for western languages (even in the C locale,
which it's currently assuming). It will, however, break for CJK et. al.
(this has always been the case, rather than being a new issue)
4) text-transform uses locale-specific variants of to{lower,upper}. In future
this should probably be performing Unicode case conversion. This is the
only part of the core code that makes use of locale information.
In future, if you require locale-specific behaviour, do the following:
setlocale(LC_<whatever>, "");
<your operation(s) here>
setlocale(LC_<whatever>, "C");
The first setlocale will change the current locale to the native environment.
The second setlocale will reset the current locale to "C".
Any value other than "" or "C" is probably a bug, unless there's a really
good reason for it.
In the long term, it is expected that all locale-dependent code will reside in
platform frontends -- the core being wholly locale agnostic (though assuming
"C" for things like decimal separators).
svn path=/trunk/netsurf/; revision=4153
2008-05-13 18:37:44 +04:00
|
|
|
|
2004-05-05 02:23:44 +04:00
|
|
|
sprintf(buffer, "%d", value);
|
The core code has always assumed a locale of "C".
Do not change the locale globally, else things will break in weird and
wonderful ways.
Introduce utils/locale.[ch], which provide locale-specific wrappers for various
functions (currently just the <ctype.h> ones).
Fix up the few places I can see that actually require that the underlying
locale is paid attention to.
Some notes:
1) The GTK frontend code has not been touched. It is possible that reading of
numeric values (e.g. from the preferences dialogue) may break with this
change, particularly in locales that use something other than '.' as their
decimal separator.
2) The search code is left unchanged (i.e. assuming a locale of "C").
This may break case insensitive matching of non-ASCII characters.
I doubt that ever actually worked, anyway. In future, it should use
Unicode case conversion to achieve the same effect.
3) The text input handling in the core makes use of isspace() to detect
word boundaries. This is fine for western languages (even in the C locale,
which it's currently assuming). It will, however, break for CJK et. al.
(this has always been the case, rather than being a new issue)
4) text-transform uses locale-specific variants of to{lower,upper}. In future
this should probably be performing Unicode case conversion. This is the
only part of the core code that makes use of locale information.
In future, if you require locale-specific behaviour, do the following:
setlocale(LC_<whatever>, "");
<your operation(s) here>
setlocale(LC_<whatever>, "C");
The first setlocale will change the current locale to the native environment.
The second setlocale will reset the current locale to "C".
Any value other than "" or "C" is probably a bug, unless there's a really
good reason for it.
In the long term, it is expected that all locale-dependent code will reside in
platform frontends -- the core being wholly locale agnostic (though assuming
"C" for things like decimal separators).
svn path=/trunk/netsurf/; revision=4153
2008-05-13 18:37:44 +04:00
|
|
|
|
2008-08-05 05:23:04 +04:00
|
|
|
ro_gui_set_icon_string(w, i, buffer, true);
|
2004-05-05 02:23:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-12-31 07:40:49 +03:00
|
|
|
/**
|
|
|
|
* Set the contents of an icon to a number.
|
|
|
|
*
|
2014-11-13 01:36:11 +03:00
|
|
|
* \param w window handle
|
|
|
|
* \param i icon handle
|
|
|
|
* \param value value to use in icon.
|
|
|
|
* \param decimal_places The number of decimal places to use.
|
2005-12-31 07:40:49 +03:00
|
|
|
*/
|
2008-07-27 02:29:15 +04:00
|
|
|
void ro_gui_set_icon_decimal(wimp_w w, wimp_i i, int value, int decimal_places)
|
|
|
|
{
|
2005-12-31 07:40:49 +03:00
|
|
|
char buffer[20]; // Big enough for 64-bit int
|
|
|
|
|
|
|
|
switch (decimal_places) {
|
|
|
|
case 0:
|
|
|
|
sprintf(buffer, "%d", value);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
sprintf(buffer, "%.1f", (float)value / 10);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
sprintf(buffer, "%.2f", (float)value / 100);
|
|
|
|
break;
|
|
|
|
default:
|
2008-03-24 04:35:13 +03:00
|
|
|
assert(!"Unsupported decimal format");
|
2005-12-31 07:40:49 +03:00
|
|
|
break;
|
|
|
|
}
|
The core code has always assumed a locale of "C".
Do not change the locale globally, else things will break in weird and
wonderful ways.
Introduce utils/locale.[ch], which provide locale-specific wrappers for various
functions (currently just the <ctype.h> ones).
Fix up the few places I can see that actually require that the underlying
locale is paid attention to.
Some notes:
1) The GTK frontend code has not been touched. It is possible that reading of
numeric values (e.g. from the preferences dialogue) may break with this
change, particularly in locales that use something other than '.' as their
decimal separator.
2) The search code is left unchanged (i.e. assuming a locale of "C").
This may break case insensitive matching of non-ASCII characters.
I doubt that ever actually worked, anyway. In future, it should use
Unicode case conversion to achieve the same effect.
3) The text input handling in the core makes use of isspace() to detect
word boundaries. This is fine for western languages (even in the C locale,
which it's currently assuming). It will, however, break for CJK et. al.
(this has always been the case, rather than being a new issue)
4) text-transform uses locale-specific variants of to{lower,upper}. In future
this should probably be performing Unicode case conversion. This is the
only part of the core code that makes use of locale information.
In future, if you require locale-specific behaviour, do the following:
setlocale(LC_<whatever>, "");
<your operation(s) here>
setlocale(LC_<whatever>, "C");
The first setlocale will change the current locale to the native environment.
The second setlocale will reset the current locale to "C".
Any value other than "" or "C" is probably a bug, unless there's a really
good reason for it.
In the long term, it is expected that all locale-dependent code will reside in
platform frontends -- the core being wholly locale agnostic (though assuming
"C" for things like decimal separators).
svn path=/trunk/netsurf/; revision=4153
2008-05-13 18:37:44 +04:00
|
|
|
|
2008-08-05 05:23:04 +04:00
|
|
|
ro_gui_set_icon_string(w, i, buffer, true);
|
2005-12-31 07:40:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2006-04-07 02:39:53 +04:00
|
|
|
* Get the contents of an icon as a number.
|
2005-12-31 07:40:49 +03:00
|
|
|
*
|
2014-11-13 01:36:11 +03:00
|
|
|
* \param w window handle
|
|
|
|
* \param i icon handle
|
|
|
|
* \param decimal_places number of places to show.
|
|
|
|
* \return value used.
|
2005-12-31 07:40:49 +03:00
|
|
|
*/
|
2008-07-27 02:29:15 +04:00
|
|
|
int ro_gui_get_icon_decimal(wimp_w w, wimp_i i, int decimal_places)
|
|
|
|
{
|
2005-12-31 07:40:49 +03:00
|
|
|
double value;
|
|
|
|
int multiple = 1;
|
|
|
|
|
|
|
|
for (; decimal_places > 0; decimal_places--)
|
|
|
|
multiple *= 10;
|
|
|
|
|
|
|
|
value = atof(ro_gui_get_icon_string(w, i)) * multiple;
|
The core code has always assumed a locale of "C".
Do not change the locale globally, else things will break in weird and
wonderful ways.
Introduce utils/locale.[ch], which provide locale-specific wrappers for various
functions (currently just the <ctype.h> ones).
Fix up the few places I can see that actually require that the underlying
locale is paid attention to.
Some notes:
1) The GTK frontend code has not been touched. It is possible that reading of
numeric values (e.g. from the preferences dialogue) may break with this
change, particularly in locales that use something other than '.' as their
decimal separator.
2) The search code is left unchanged (i.e. assuming a locale of "C").
This may break case insensitive matching of non-ASCII characters.
I doubt that ever actually worked, anyway. In future, it should use
Unicode case conversion to achieve the same effect.
3) The text input handling in the core makes use of isspace() to detect
word boundaries. This is fine for western languages (even in the C locale,
which it's currently assuming). It will, however, break for CJK et. al.
(this has always been the case, rather than being a new issue)
4) text-transform uses locale-specific variants of to{lower,upper}. In future
this should probably be performing Unicode case conversion. This is the
only part of the core code that makes use of locale information.
In future, if you require locale-specific behaviour, do the following:
setlocale(LC_<whatever>, "");
<your operation(s) here>
setlocale(LC_<whatever>, "C");
The first setlocale will change the current locale to the native environment.
The second setlocale will reset the current locale to "C".
Any value other than "" or "C" is probably a bug, unless there's a really
good reason for it.
In the long term, it is expected that all locale-dependent code will reside in
platform frontends -- the core being wholly locale agnostic (though assuming
"C" for things like decimal separators).
svn path=/trunk/netsurf/; revision=4153
2008-05-13 18:37:44 +04:00
|
|
|
|
2005-12-31 07:40:49 +03:00
|
|
|
return (int)value;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-05 02:23:44 +04:00
|
|
|
/**
|
|
|
|
* Set the selected state of an icon.
|
|
|
|
*
|
2005-04-08 00:46:22 +04:00
|
|
|
* \param w window handle
|
|
|
|
* \param i icon handle
|
2004-05-05 02:23:44 +04:00
|
|
|
* \param state selected state
|
|
|
|
*/
|
2008-07-27 02:29:15 +04:00
|
|
|
void ro_gui_set_icon_selected_state(wimp_w w, wimp_i i, bool state)
|
|
|
|
{
|
2004-08-31 22:01:22 +04:00
|
|
|
os_error *error;
|
|
|
|
if (ro_gui_get_icon_selected_state(w, i) == state) return;
|
|
|
|
error = xwimp_set_icon_state(w, i,
|
|
|
|
(state ? wimp_ICON_SELECTED : 0), wimp_ICON_SELECTED);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_set_icon_state: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2004-08-31 22:01:22 +04:00
|
|
|
}
|
|
|
|
}
|
2004-05-05 02:23:44 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the selected state of an icon.
|
|
|
|
*
|
2005-04-08 00:46:22 +04:00
|
|
|
* \param w window handle
|
|
|
|
* \param i icon handle
|
2004-05-05 02:23:44 +04:00
|
|
|
*/
|
2008-07-27 02:29:15 +04:00
|
|
|
bool ro_gui_get_icon_selected_state(wimp_w w, wimp_i i)
|
|
|
|
{
|
2004-08-31 22:01:22 +04:00
|
|
|
os_error *error;
|
2004-05-05 02:23:44 +04:00
|
|
|
wimp_icon_state ic;
|
|
|
|
ic.w = w;
|
|
|
|
ic.i = i;
|
2004-08-31 22:01:22 +04:00
|
|
|
error = xwimp_get_icon_state(&ic);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2004-08-31 22:01:22 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return ((ic.icon.flags & wimp_ICON_SELECTED) != 0);
|
2004-05-05 02:23:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2004-08-31 23:51:29 +04:00
|
|
|
* Set the shaded state of an icon.
|
2004-05-05 02:23:44 +04:00
|
|
|
*
|
2005-04-08 00:46:22 +04:00
|
|
|
* \param w window handle
|
|
|
|
* \param i icon handle
|
2006-01-03 04:37:25 +03:00
|
|
|
* \param state shaded state
|
2004-05-05 02:23:44 +04:00
|
|
|
*/
|
2008-07-27 02:29:15 +04:00
|
|
|
void ro_gui_set_icon_shaded_state(wimp_w w, wimp_i i, bool state)
|
|
|
|
{
|
2006-01-03 04:37:25 +03:00
|
|
|
wimp_caret caret;
|
2004-08-31 23:51:29 +04:00
|
|
|
os_error *error;
|
2006-01-03 04:37:25 +03:00
|
|
|
|
|
|
|
/* update the state */
|
|
|
|
if (ro_gui_get_icon_shaded_state(w, i) == state)
|
|
|
|
return;
|
2004-08-31 23:51:29 +04:00
|
|
|
error = xwimp_set_icon_state(w, i,
|
|
|
|
(state ? wimp_ICON_SHADED : 0), wimp_ICON_SHADED);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2004-08-31 23:51:29 +04:00
|
|
|
}
|
2006-06-21 01:35:33 +04:00
|
|
|
if (!state)
|
2006-01-03 04:37:25 +03:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* ensure the caret is not in a shaded icon */
|
|
|
|
error = xwimp_get_caret_position(&caret);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_get_caret_position: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2006-01-03 04:37:25 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ((caret.w != w) || (caret.i != i))
|
|
|
|
return;
|
|
|
|
/* move the caret to the first avaiable writable */
|
|
|
|
if (ro_gui_set_caret_first(w))
|
|
|
|
return;
|
|
|
|
/* lose the caret */
|
|
|
|
error = xwimp_set_caret_position((wimp_w)-1, (wimp_i)-1, -1, -1, -1, -1);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_set_caret_position: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2006-01-03 04:37:25 +03:00
|
|
|
return;
|
|
|
|
}
|
2004-08-31 23:51:29 +04:00
|
|
|
}
|
2004-05-23 03:04:44 +04:00
|
|
|
|
|
|
|
|
2004-07-22 00:02:13 +04:00
|
|
|
/**
|
|
|
|
* Gets the shaded state of an icon.
|
|
|
|
*
|
2005-04-08 00:46:22 +04:00
|
|
|
* \param w window handle
|
|
|
|
* \param i icon handle
|
2004-07-22 00:02:13 +04:00
|
|
|
*/
|
2008-07-27 02:29:15 +04:00
|
|
|
bool ro_gui_get_icon_shaded_state(wimp_w w, wimp_i i)
|
|
|
|
{
|
2004-07-22 00:02:13 +04:00
|
|
|
wimp_icon_state ic;
|
|
|
|
ic.w = w;
|
|
|
|
ic.i = i;
|
|
|
|
xwimp_get_icon_state(&ic);
|
|
|
|
return (ic.icon.flags & wimp_ICON_SHADED) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-21 02:16:33 +03:00
|
|
|
/**
|
|
|
|
* Set the deleted state of an icon.
|
|
|
|
*
|
|
|
|
* \param w window handle
|
|
|
|
* \param i icon handle
|
|
|
|
* \param state shaded state
|
|
|
|
*/
|
|
|
|
void ro_gui_set_icon_deleted_state(wimp_w w, wimp_i i, bool state)
|
|
|
|
{
|
|
|
|
wimp_caret caret;
|
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
/* update the state */
|
|
|
|
if (ro_gui_get_icon_deleted_state(w, i) == state)
|
|
|
|
return;
|
|
|
|
error = xwimp_set_icon_state(w, i,
|
|
|
|
(state ? wimp_ICON_DELETED : 0), wimp_ICON_DELETED);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2011-02-21 02:16:33 +03:00
|
|
|
}
|
|
|
|
if (!state)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* ensure the caret is not in a shaded icon */
|
|
|
|
error = xwimp_get_caret_position(&caret);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_get_caret_position: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2011-02-21 02:16:33 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ((caret.w != w) || (caret.i != i))
|
|
|
|
return;
|
|
|
|
/* move the caret to the first avaiable writable */
|
|
|
|
if (ro_gui_set_caret_first(w))
|
|
|
|
return;
|
|
|
|
/* lose the caret */
|
|
|
|
error = xwimp_set_caret_position((wimp_w)-1, (wimp_i)-1, -1, -1, -1, -1);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_set_caret_position: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2011-02-21 02:16:33 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the deleted state of an icon.
|
|
|
|
*
|
|
|
|
* \param w window handle
|
|
|
|
* \param i icon handle
|
|
|
|
*/
|
|
|
|
bool ro_gui_get_icon_deleted_state(wimp_w w, wimp_i i)
|
|
|
|
{
|
|
|
|
wimp_icon_state ic;
|
|
|
|
ic.w = w;
|
|
|
|
ic.i = i;
|
|
|
|
xwimp_get_icon_state(&ic);
|
|
|
|
return (ic.icon.flags & wimp_ICON_DELETED) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-01-23 19:09:05 +03:00
|
|
|
/**
|
|
|
|
* Set the button type of an icon.
|
|
|
|
*
|
2005-04-08 00:46:22 +04:00
|
|
|
* \param w window handle
|
|
|
|
* \param i icon handle
|
2005-01-23 19:09:05 +03:00
|
|
|
* \param type button type
|
|
|
|
*/
|
2008-07-27 02:29:15 +04:00
|
|
|
void ro_gui_set_icon_button_type(wimp_w w, wimp_i i, int type)
|
|
|
|
{
|
2005-01-23 19:09:05 +03:00
|
|
|
os_error *error;
|
|
|
|
error = xwimp_set_icon_state(w, i, wimp_ICON_BUTTON_TYPE,
|
|
|
|
(type << wimp_ICON_BUTTON_TYPE_SHIFT));
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_set_icon_state: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2005-04-08 00:46:22 +04:00
|
|
|
}
|
2005-01-23 19:09:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-16 18:35:25 +04:00
|
|
|
/**
|
|
|
|
* Set an icon's sprite
|
|
|
|
*
|
|
|
|
* \param w window handle
|
|
|
|
* \param i icon handle
|
|
|
|
* \param area sprite area containing sprite
|
|
|
|
* \param name name of sprite in area (in local encoding)
|
|
|
|
*/
|
|
|
|
void ro_gui_set_icon_sprite(wimp_w w, wimp_i i, osspriteop_area *area,
|
|
|
|
const char *name)
|
|
|
|
{
|
|
|
|
wimp_icon_state ic;
|
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
/* get the icon data */
|
|
|
|
ic.w = w;
|
|
|
|
ic.i = i;
|
|
|
|
error = xwimp_get_icon_state(&ic);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_get_icon_state: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2005-07-16 18:35:25 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* copy the name across */
|
|
|
|
if (ic.icon.data.indirected_text.size) {
|
|
|
|
strncpy(ic.icon.data.indirected_text.text, name,
|
|
|
|
(unsigned int)ic.icon.data.indirected_text.size - 1);
|
|
|
|
ic.icon.data.indirected_text.text[
|
|
|
|
ic.icon.data.indirected_text.size - 1] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
ic.icon.data.indirected_sprite.area = area;
|
|
|
|
|
|
|
|
ro_gui_redraw_icon(w, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-07-09 02:05:35 +04:00
|
|
|
/**
|
2005-07-24 07:13:33 +04:00
|
|
|
* Set a window title
|
2004-07-09 02:05:35 +04:00
|
|
|
*
|
2005-04-08 00:46:22 +04:00
|
|
|
* \param w window handle
|
2004-07-09 02:05:35 +04:00
|
|
|
* \param text new title (copied)
|
|
|
|
*/
|
2008-07-27 02:29:15 +04:00
|
|
|
void ro_gui_set_window_title(wimp_w w, const char *text)
|
|
|
|
{
|
2004-07-09 02:05:35 +04:00
|
|
|
wimp_window_info_base window;
|
|
|
|
os_error *error;
|
2005-07-16 18:35:25 +04:00
|
|
|
char *title_local_enc;
|
2014-01-29 01:40:13 +04:00
|
|
|
nserror err;
|
2004-07-11 17:05:38 +04:00
|
|
|
|
2004-07-09 02:05:35 +04:00
|
|
|
/* Get the window details
|
|
|
|
*/
|
|
|
|
window.w = w;
|
|
|
|
error = xwimp_get_window_info_header_only((wimp_window_info *)&window);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_get_window_info: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2004-07-09 02:05:35 +04:00
|
|
|
return;
|
|
|
|
}
|
2004-07-11 17:05:38 +04:00
|
|
|
|
2005-07-16 18:35:25 +04:00
|
|
|
/* convert text to local encoding */
|
|
|
|
err = utf8_to_local_encoding(text, 0, &title_local_enc);
|
2014-01-29 01:40:13 +04:00
|
|
|
if (err != NSERROR_OK) {
|
2005-07-16 18:35:25 +04:00
|
|
|
/* A bad encoding should never happen,
|
|
|
|
* so assert this */
|
2014-01-29 01:40:13 +04:00
|
|
|
assert(err != NSERROR_BAD_ENCODING);
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "utf8_to_enc failed");
|
2005-07-16 18:35:25 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-07-09 02:05:35 +04:00
|
|
|
/* Set the title string
|
|
|
|
*/
|
2005-07-16 18:35:25 +04:00
|
|
|
strncpy(window.title_data.indirected_text.text, title_local_enc,
|
2005-04-08 00:46:22 +04:00
|
|
|
(unsigned int)window.title_data.indirected_text.size
|
|
|
|
- 1);
|
|
|
|
window.title_data.indirected_text.text[
|
|
|
|
window.title_data.indirected_text.size - 1] = '\0';
|
2004-12-09 13:30:44 +03:00
|
|
|
|
|
|
|
/* Redraw accordingly
|
|
|
|
*/
|
|
|
|
error = xwimp_force_redraw_title(w);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_force_redraw_title: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2004-12-09 13:30:44 +03:00
|
|
|
return;
|
2005-04-08 00:46:22 +04:00
|
|
|
}
|
2005-07-16 18:35:25 +04:00
|
|
|
|
|
|
|
free(title_local_enc);
|
2004-07-09 02:05:35 +04:00
|
|
|
}
|
2004-07-11 17:05:38 +04:00
|
|
|
|
2004-07-09 02:05:35 +04:00
|
|
|
|
2004-07-12 01:45:51 +04:00
|
|
|
/**
|
|
|
|
* Places the caret in the first available icon
|
2006-01-03 04:37:25 +03:00
|
|
|
*
|
2014-11-13 01:36:11 +03:00
|
|
|
* \param w the window to place the caret in
|
2006-01-03 04:37:25 +03:00
|
|
|
* \return true if the caret was placed, false otherwise
|
2004-07-12 01:45:51 +04:00
|
|
|
*/
|
2008-07-27 02:29:15 +04:00
|
|
|
bool ro_gui_set_caret_first(wimp_w w)
|
|
|
|
{
|
2005-04-08 00:46:22 +04:00
|
|
|
int icon, b;
|
2004-08-31 01:57:47 +04:00
|
|
|
wimp_window_state win_state;
|
2004-07-12 01:45:51 +04:00
|
|
|
wimp_window_info_base window;
|
|
|
|
wimp_icon_state state;
|
|
|
|
os_error *error;
|
|
|
|
|
2005-04-08 00:46:22 +04:00
|
|
|
/* check the window is open */
|
2004-08-31 01:57:47 +04:00
|
|
|
win_state.w = w;
|
|
|
|
error = xwimp_get_window_state(&win_state);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2006-01-03 04:37:25 +03:00
|
|
|
return false;
|
2004-08-31 01:57:47 +04:00
|
|
|
}
|
2005-04-08 00:46:22 +04:00
|
|
|
if (!(win_state.flags & wimp_WINDOW_OPEN))
|
2006-01-03 04:37:25 +03:00
|
|
|
return false;
|
2005-04-08 00:46:22 +04:00
|
|
|
|
|
|
|
/* get the window details for the icon count */
|
2004-07-12 01:45:51 +04:00
|
|
|
window.w = w;
|
|
|
|
error = xwimp_get_window_info_header_only((wimp_window_info *)&window);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_get_window_info: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2006-01-03 04:37:25 +03:00
|
|
|
return false;
|
2004-07-12 01:45:51 +04:00
|
|
|
}
|
|
|
|
|
2005-04-08 00:46:22 +04:00
|
|
|
/* work through all the icons */
|
2004-07-12 01:45:51 +04:00
|
|
|
state.w = w;
|
|
|
|
for (icon = 0; icon < window.icon_count; icon++) {
|
|
|
|
state.i = icon;
|
|
|
|
error = xwimp_get_icon_state(&state);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO,
|
|
|
|
"xwimp_get_icon_state: 0x%x: %s",
|
|
|
|
error->errnum,
|
|
|
|
error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2006-01-03 04:37:25 +03:00
|
|
|
return false;
|
2004-07-12 01:45:51 +04:00
|
|
|
}
|
2004-07-27 19:49:28 +04:00
|
|
|
|
2005-04-08 00:46:22 +04:00
|
|
|
/* ignore if it's shaded or not writable */
|
2004-08-09 10:29:46 +04:00
|
|
|
if (state.icon.flags & wimp_ICON_SHADED)
|
|
|
|
continue;
|
2005-04-08 00:46:22 +04:00
|
|
|
b = (state.icon.flags >> wimp_ICON_BUTTON_TYPE_SHIFT) & 0xf;
|
|
|
|
if ((b != wimp_BUTTON_WRITE_CLICK_DRAG) &&
|
|
|
|
(b != wimp_BUTTON_WRITABLE))
|
|
|
|
continue;
|
2004-08-09 10:29:46 +04:00
|
|
|
|
2005-04-08 00:46:22 +04:00
|
|
|
/* move the caret */
|
|
|
|
error = xwimp_set_caret_position(w, icon, 0, 0, -1,
|
|
|
|
strlen(state.icon.data.indirected_text.text));
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO,
|
|
|
|
"xwimp_set_caret_position: 0x%x: %s",
|
|
|
|
error->errnum,
|
|
|
|
error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2004-07-12 01:45:51 +04:00
|
|
|
}
|
2006-01-03 04:37:25 +03:00
|
|
|
return true;
|
2004-07-12 01:45:51 +04:00
|
|
|
}
|
2006-01-03 04:37:25 +03:00
|
|
|
return false;
|
2004-07-12 01:45:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-23 03:04:44 +04:00
|
|
|
/**
|
|
|
|
* Load a sprite file into memory.
|
|
|
|
*
|
|
|
|
* \param pathname file to load
|
|
|
|
* \return sprite area, or 0 on memory exhaustion or error and error reported
|
|
|
|
*/
|
|
|
|
|
|
|
|
osspriteop_area *ro_gui_load_sprite_file(const char *pathname)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
fileswitch_object_type obj_type;
|
|
|
|
osspriteop_area *area;
|
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
error = xosfile_read_stamped_no_path(pathname,
|
|
|
|
&obj_type, 0, 0, &len, 0, 0);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO,
|
|
|
|
"xosfile_read_stamped_no_path: 0x%x: %s",
|
|
|
|
error->errnum,
|
|
|
|
error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("MiscError", error->errmess);
|
2004-05-23 03:04:44 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (obj_type != fileswitch_IS_FILE) {
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("FileError", pathname);
|
2004-05-23 03:04:44 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
area = malloc(len + 4);
|
|
|
|
if (!area) {
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("NoMemory", 0);
|
2004-05-23 03:04:44 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
area->size = len + 4;
|
|
|
|
area->sprite_count = 0;
|
|
|
|
area->first = 16;
|
|
|
|
area->used = 16;
|
|
|
|
|
|
|
|
error = xosspriteop_load_sprite_file(osspriteop_USER_AREA,
|
|
|
|
area, pathname);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO,
|
|
|
|
"xosspriteop_load_sprite_file: 0x%x: %s",
|
|
|
|
error->errnum,
|
|
|
|
error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("MiscError", error->errmess);
|
2004-05-23 03:04:44 +04:00
|
|
|
free(area);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return area;
|
|
|
|
}
|
2004-07-11 17:05:38 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if a sprite is present in the Wimp sprite pool.
|
|
|
|
*
|
|
|
|
* \param sprite name of sprite
|
|
|
|
* \return true if the sprite is present
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool ro_gui_wimp_sprite_exists(const char *sprite)
|
|
|
|
{
|
2009-03-27 04:14:42 +03:00
|
|
|
static char last_sprite_found[16];
|
2004-07-11 17:05:38 +04:00
|
|
|
os_error *error;
|
|
|
|
|
2006-01-04 20:26:43 +03:00
|
|
|
/* make repeated calls fast */
|
2009-03-27 04:14:42 +03:00
|
|
|
if (!strncmp(sprite, last_sprite_found, sizeof(last_sprite_found)))
|
2006-01-04 20:26:43 +03:00
|
|
|
return true;
|
|
|
|
|
|
|
|
/* fallback if not known to exist */
|
2004-07-11 17:05:38 +04:00
|
|
|
error = xwimpspriteop_select_sprite(sprite, 0);
|
|
|
|
if (error) {
|
|
|
|
if (error->errnum != error_SPRITE_OP_DOESNT_EXIST) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO,
|
|
|
|
"xwimpspriteop_select_sprite: 0x%x: %s",
|
|
|
|
error->errnum,
|
|
|
|
error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("MiscError", error->errmess);
|
2004-07-11 17:05:38 +04:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2009-03-27 04:14:42 +03:00
|
|
|
snprintf(last_sprite_found, sizeof(last_sprite_found), sprite);
|
2004-07-11 17:05:38 +04:00
|
|
|
return true;
|
|
|
|
}
|
2004-07-27 19:49:28 +04:00
|
|
|
|
|
|
|
|
2005-07-16 09:54:45 +04:00
|
|
|
/**
|
|
|
|
* Locate a sprite in the Wimp sprite pool, returning a pointer to it.
|
|
|
|
*
|
2005-12-31 07:40:49 +03:00
|
|
|
* \param name sprite name
|
2005-07-16 09:54:45 +04:00
|
|
|
* \param sprite receives pointer to sprite if found
|
|
|
|
* \return error ptr iff not found
|
|
|
|
*/
|
|
|
|
|
|
|
|
os_error *ro_gui_wimp_get_sprite(const char *name, osspriteop_header **sprite)
|
|
|
|
{
|
|
|
|
osspriteop_area *rom_base, *ram_base;
|
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
error = xwimp_base_of_sprites(&rom_base, &ram_base);
|
|
|
|
if (error) return error;
|
|
|
|
|
|
|
|
error = xosspriteop_select_sprite(osspriteop_USER_AREA,
|
2007-10-09 21:49:48 +04:00
|
|
|
ram_base, (osspriteop_id)name, sprite);
|
2005-07-16 09:54:45 +04:00
|
|
|
|
|
|
|
if (error && error->errnum == error_SPRITE_OP_DOESNT_EXIST)
|
|
|
|
error = xosspriteop_select_sprite(osspriteop_USER_AREA,
|
2007-10-09 21:49:48 +04:00
|
|
|
rom_base, (osspriteop_id)name, sprite);
|
2005-07-16 09:54:45 +04:00
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-21 02:16:33 +03:00
|
|
|
/**
|
|
|
|
* Get the dimensions of a sprite
|
|
|
|
*
|
|
|
|
* \param *area The sprite area to use.
|
|
|
|
* \param *sprite Pointer to the sprite name.
|
|
|
|
* \param *width Return the sprite width.
|
|
|
|
* \param *height Return the sprite height.
|
|
|
|
* \return true if successful; else false.
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool ro_gui_wimp_get_sprite_dimensions(osspriteop_area *area, char *sprite,
|
|
|
|
int *width, int *height)
|
|
|
|
{
|
|
|
|
os_error *error = NULL;
|
|
|
|
os_mode mode;
|
|
|
|
os_coord dimensions;
|
|
|
|
|
|
|
|
dimensions.x = 0;
|
|
|
|
dimensions.y = 0;
|
|
|
|
|
|
|
|
if (area != (osspriteop_area *) -1)
|
|
|
|
error = xosspriteop_read_sprite_info(osspriteop_USER_AREA,
|
|
|
|
area, (osspriteop_id) sprite,
|
|
|
|
&dimensions.x, &dimensions.y, 0, &mode);
|
|
|
|
|
|
|
|
if (error != NULL || area == (osspriteop_area *) -1)
|
|
|
|
error = xwimpspriteop_read_sprite_info(sprite,
|
|
|
|
&dimensions.x, &dimensions.y, 0, &mode);
|
|
|
|
|
|
|
|
if (error == NULL) {
|
|
|
|
ro_convert_pixels_to_os_units(&dimensions, mode);
|
|
|
|
if (width != NULL)
|
|
|
|
*width = dimensions.x;
|
|
|
|
if (height != NULL)
|
|
|
|
*height = dimensions.y;
|
|
|
|
} else if (error->errnum != error_SPRITE_OP_DOESNT_EXIST) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO,
|
|
|
|
"xosspriteop_read_sprite_info: 0x%x: %s",
|
|
|
|
error->errnum,
|
|
|
|
error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("MiscError", error->errmess);
|
2011-02-21 02:16:33 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-14 16:58:43 +03:00
|
|
|
/**
|
|
|
|
* Performs simple user redraw for a window.
|
|
|
|
*
|
2014-11-13 02:27:13 +03:00
|
|
|
* \param redraw wimp draw
|
|
|
|
* \param user_fill whether to fill the redraw area
|
|
|
|
* \param user_colour the colour to use when filling
|
2005-03-14 16:58:43 +03:00
|
|
|
*/
|
|
|
|
|
2005-04-08 00:46:22 +04:00
|
|
|
void ro_gui_user_redraw(wimp_draw *redraw, bool user_fill,
|
2008-07-27 02:29:15 +04:00
|
|
|
os_colour user_colour)
|
|
|
|
{
|
2005-03-14 16:58:43 +03:00
|
|
|
os_error *error;
|
|
|
|
osbool more;
|
|
|
|
|
|
|
|
error = xwimp_redraw_window(redraw, &more);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_redraw_window: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2005-03-14 16:58:43 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
while (more) {
|
2005-04-08 00:46:22 +04:00
|
|
|
if (user_fill) {
|
2005-03-14 16:58:43 +03:00
|
|
|
error = xcolourtrans_set_gcol(user_colour,
|
2008-03-10 03:51:51 +03:00
|
|
|
colourtrans_SET_BG_GCOL,
|
2005-03-14 16:58:43 +03:00
|
|
|
os_ACTION_OVERWRITE, 0, 0);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO,
|
|
|
|
"xcolourtrans_set_gcol: 0x%x: %s",
|
|
|
|
error->errnum,
|
|
|
|
error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("MiscError", error->errmess);
|
2005-03-14 16:58:43 +03:00
|
|
|
}
|
|
|
|
os_clg();
|
2005-04-08 00:46:22 +04:00
|
|
|
}
|
2005-03-14 16:58:43 +03:00
|
|
|
error = xwimp_get_rectangle(redraw, &more);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_get_rectangle: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2005-03-14 16:58:43 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-04-08 00:46:22 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets whether a piece of window furniture is present for a window.
|
|
|
|
*
|
|
|
|
* \param w the window to modify
|
|
|
|
* \param bic_mask the furniture flags to clear
|
|
|
|
* \param xor_mask the furniture flags to toggle
|
|
|
|
*/
|
|
|
|
void ro_gui_wimp_update_window_furniture(wimp_w w, wimp_window_flags bic_mask,
|
2008-07-27 02:29:15 +04:00
|
|
|
wimp_window_flags xor_mask)
|
|
|
|
{
|
2005-04-08 00:46:22 +04:00
|
|
|
wimp_window_state state;
|
2006-07-15 19:39:33 +04:00
|
|
|
wimp_w parent;
|
|
|
|
bits linkage;
|
2005-04-08 00:46:22 +04:00
|
|
|
os_error *error;
|
|
|
|
bool open;
|
|
|
|
|
|
|
|
state.w = w;
|
2006-07-15 19:39:33 +04:00
|
|
|
error = xwimp_get_window_state_and_nesting(&state, &parent, &linkage);
|
2005-04-08 00:46:22 +04:00
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2005-04-08 00:46:22 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
open = state.flags & wimp_WINDOW_OPEN;
|
|
|
|
state.flags &= ~(63 << 16); /* clear bits 16-21 */
|
|
|
|
state.flags &= ~bic_mask;
|
|
|
|
state.flags ^= xor_mask;
|
|
|
|
if (!open)
|
|
|
|
state.next = wimp_HIDDEN;
|
2006-07-15 19:39:33 +04:00
|
|
|
error = xwimp_open_window_nested_with_flags(&state, parent, linkage);
|
2005-04-08 00:46:22 +04:00
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2005-04-08 00:46:22 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!open) {
|
|
|
|
error = xwimp_close_window(w);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_close_window: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2005-04-08 00:46:22 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-12-01 04:22:23 +03:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks whether a piece of window furniture is present for a window.
|
|
|
|
*
|
|
|
|
* \param w the window to modify
|
2005-12-31 07:40:49 +03:00
|
|
|
* \param mask the furniture flags to check
|
2005-12-01 04:22:23 +03:00
|
|
|
*/
|
2008-07-27 02:29:15 +04:00
|
|
|
bool ro_gui_wimp_check_window_furniture(wimp_w w, wimp_window_flags mask)
|
|
|
|
{
|
2005-12-01 04:22:23 +03:00
|
|
|
wimp_window_state state;
|
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
state.w = w;
|
|
|
|
error = xwimp_get_window_state(&state);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_get_window_state: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2005-12-01 04:22:23 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return state.flags & mask;
|
|
|
|
}
|
2007-08-04 15:47:40 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* RO GUI-specific strlen, for control character terminated strings
|
|
|
|
*
|
|
|
|
* \param str The string to measure the length of
|
|
|
|
* \return The length of the string
|
|
|
|
*/
|
|
|
|
size_t ro_gui_strlen(const char *str)
|
|
|
|
{
|
2008-08-05 05:23:04 +04:00
|
|
|
const char *str_begin;
|
2007-08-04 15:47:40 +04:00
|
|
|
|
|
|
|
if (str == NULL)
|
|
|
|
return 0;
|
|
|
|
|
2008-08-05 05:23:04 +04:00
|
|
|
for (str_begin = str; *str++ >= ' '; /* */)
|
|
|
|
/* */;
|
|
|
|
|
|
|
|
return str - str_begin - 1;
|
|
|
|
}
|
2007-08-04 15:47:40 +04:00
|
|
|
|
2008-08-05 05:23:04 +04:00
|
|
|
/**
|
|
|
|
* RO GUI-specific strncmp, for control character terminated strings
|
|
|
|
*
|
|
|
|
* \param s1 The first string for comparison
|
|
|
|
* \param s2 The second string for comparison
|
|
|
|
* \param len Maximum number of bytes to be checked
|
|
|
|
* \return 0 for equal strings up to len bytes; pos for s1 being bigger than
|
|
|
|
* s2; neg for s1 being smaller than s2.
|
|
|
|
*/
|
|
|
|
int ro_gui_strncmp(const char *s1, const char *s2, size_t len)
|
|
|
|
{
|
|
|
|
while (len--) {
|
|
|
|
char c1 = *s1++;
|
|
|
|
char c2 = *s2++;
|
|
|
|
if (c1 < ' ' || c2 < ' ')
|
|
|
|
return (c1 < ' ' ? 0 : c1) - (c2 < ' ' ? 0 : c2);
|
|
|
|
int diff = c1 - c2;
|
|
|
|
if (diff)
|
|
|
|
return diff;
|
|
|
|
}
|
|
|
|
return 0;
|
2007-08-04 15:47:40 +04:00
|
|
|
}
|
2011-12-20 03:27:10 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generic window scroll event handler.
|
|
|
|
*
|
|
|
|
* \param *scroll Pointer to Scroll Event block.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_scroll(wimp_scroll *scroll)
|
|
|
|
{
|
|
|
|
os_error *error;
|
|
|
|
int x = scroll->visible.x1 - scroll->visible.x0 - 32;
|
|
|
|
int y = scroll->visible.y1 - scroll->visible.y0 - 32;
|
|
|
|
|
|
|
|
switch (scroll->xmin) {
|
|
|
|
case wimp_SCROLL_PAGE_LEFT:
|
|
|
|
scroll->xscroll -= x;
|
|
|
|
break;
|
|
|
|
case wimp_SCROLL_COLUMN_LEFT:
|
|
|
|
scroll->xscroll -= 100;
|
|
|
|
break;
|
|
|
|
case wimp_SCROLL_COLUMN_RIGHT:
|
|
|
|
scroll->xscroll += 100;
|
|
|
|
break;
|
|
|
|
case wimp_SCROLL_PAGE_RIGHT:
|
|
|
|
scroll->xscroll += x;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
scroll->xscroll += (x * (scroll->xmin>>2)) >> 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (scroll->ymin) {
|
|
|
|
case wimp_SCROLL_PAGE_UP:
|
|
|
|
scroll->yscroll += y;
|
|
|
|
break;
|
|
|
|
case wimp_SCROLL_LINE_UP:
|
|
|
|
scroll->yscroll += 100;
|
|
|
|
break;
|
|
|
|
case wimp_SCROLL_LINE_DOWN:
|
|
|
|
scroll->yscroll -= 100;
|
|
|
|
break;
|
|
|
|
case wimp_SCROLL_PAGE_DOWN:
|
|
|
|
scroll->yscroll -= y;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
scroll->yscroll += (y * (scroll->ymin>>2)) >> 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = xwimp_open_window((wimp_open *) scroll);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2011-12-20 03:27:10 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|