Commit graph

310 commits

Author SHA1 Message Date
Turo Lamminen
569787da58 Make TXT_NewSeparator parameter const 2018-03-13 19:47:59 +02:00
Turo Lamminen
a6fbae76cd Make TXT_SetSeparatorLabel label parameter const 2018-03-13 19:46:36 +02:00
Turo Lamminen
94d85c51b0 Make TXT_SetWindowHelpURL help_url parameter const 2018-03-13 19:44:25 +02:00
Turo Lamminen
232c968ed9 textscreen: Make help_url member const in txt_window_s 2018-03-13 19:33:51 +02:00
Turo Lamminen
592edc0d87 Make TXT_OpenURL parameter const 2018-03-13 19:33:51 +02:00
Turo Lamminen
10fda2ac53 Make TXT_MessageBox title character const 2018-03-13 19:33:51 +02:00
Turo Lamminen
334232d3b4 Make TXT_MessageBox message parameter const 2018-03-13 19:33:51 +02:00
Turo Lamminen
6283e91fbd Make TXT_NewLabel parameter const 2018-03-13 19:33:51 +02:00
Turo Lamminen
50e55526b3 Make TXT_SetLabel value parameter const 2018-03-13 19:33:51 +02:00
Turo Lamminen
aa555a22c1 textscreen: Use more const-correct loop in TXT_SetLabel 2018-03-13 19:33:51 +02:00
Turo Lamminen
19a0939300 Make TXT_NewWindow parameter const 2018-03-13 19:33:51 +02:00
Turo Lamminen
49b5751693 Make TXT_SelectFile window_title parameter const 2018-03-13 19:33:51 +02:00
Turo Lamminen
90ded64b2b textscreen: Make ExpandExtension parameter const 2018-03-13 19:33:51 +02:00
Turo Lamminen
5f82ebd75b Make TXT_NewInvertedCheckBox label parameter const 2018-03-13 19:33:51 +02:00
Turo Lamminen
27a28b8ad9 Make TXT_NewCheckBox label parameter const 2018-03-13 19:33:51 +02:00
Turo Lamminen
898442b101 Make TXT_NewButton2 label parameter const 2018-03-13 19:33:51 +02:00
Turo Lamminen
4b48cd7f9d Make TXT_NewButton parameter const 2018-03-13 19:33:51 +02:00
Turo Lamminen
44b80b2a7a Make TXT_SetButtonLabel label parameter const 2018-03-13 19:33:47 +02:00
Turo Lamminen
1758e89080 textscreen: Make SDLWheelToTXTButton parameter const 2018-03-13 19:33:47 +02:00
Turo Lamminen
10d2130a2a textscreen: Make TranslateKeysym parameter const 2018-03-13 19:33:47 +02:00
Turo Lamminen
fff3741c78 textscreen: Make FontForName parameter const 2018-03-13 19:33:47 +02:00
Turo Lamminen
54a38844f7 textscreen: Make name member const in txt_font_t 2018-03-13 19:33:38 +02:00
Turo Lamminen
83d0f369df Make TXT_SetDesktopTitle parameter const 2018-03-13 12:31:51 +02:00
Turo Lamminen
8ec41dca6c Make TXT_SetWindowTitle parameter const 2018-03-13 12:31:51 +02:00
Turo Lamminen
14e9e56571 Add format string attribute to TXT_snprintf 2018-02-17 16:15:13 +02:00
Turo Lamminen
5e2df0a52e textscreen: Don't ignore return value of system() call 2018-01-27 16:46:04 +02:00
Simon Howard
58006edc22 textscreen: Add extern "C" for C++ imports.
This fixes #941. Thanks to @Altazimuth for the suggestion.
2017-10-22 18:39:22 -04:00
Simon Howard
75bedca7fb textscreen: Check return value from realloc().
This fixes a static analysis warning detected in #939. Thanks to
@turol for finding this.
2017-09-02 19:02:54 -04:00
David Carlier
5409a57f13 Tiny memory leak fix in call error path. 2017-06-20 15:16:11 +01:00
Jonathan Dowland
7f27e795c6 textscreen: zenity chooser file filter tweaks (#909)
Adjust the pattern passed to zenity to be case-insensitive
(e.g., if the input pattern was "wad", generate "[Ww][Aa][Dd]").

This means the chooser will show the following, which would otherwise
be hidden:

 * TEST2.WAD
 * test3.WAD
2017-05-02 13:11:17 -04:00
Simon Howard
c93b2fb4d8 textscreen: Activate window for file select.
This pops up the file select dialog immediately rather than waiting for
the user to activate the application. But really the current file select
code for OS X based on AppleScript is garbage and should just be
replaced.
2017-01-25 22:46:10 +00:00
Simon Howard
1d2fe63a94 textscreen: Add TXT_MakeTable().
When creating a table widget is is often convenient to be able to create
and populate it in a single function call. It's possible to do this with
"horizontal boxes" already but there wasn't a more generic mechanism for
making a table. So add one as TXT_MakeTable().
2017-01-25 21:08:53 +00:00
Simon Howard
2c686fa912 textscreen: Minor cleanups.
Remove Tango colors - this is just a half-baked idea left over from
long ago. Remove some leftover comments and commented-out code, and
add some comments for global tables.
2017-01-21 22:40:36 +00:00
Simon Howard
7ad4a11afa textscreen: Make UTF8 the rule, not the exception.
Rename TXT_DrawString() to TXT_DrawCodePageString() and rename
TXT_DrawUTF8String() to TXT_DrawString(). It's better to just assume
everything is UTF8 and deal with the exceptions, as this is less likely
to cause bugs. There is only a small handful of places where we want to
draw a specific character from the native code page.
2017-01-21 17:15:00 +00:00
Simon Howard
148e9e53aa textscreen: Add Italian window.
Add a window containing one of each type of widget that uses string
labels, and include something in Italian that uses at least one Unicode
character, for testing the UTF8 change.
2017-01-21 16:37:51 +00:00
Simon Howard
06dd832185 textscreen: Change most strings to UTF-8.
If we are to accept arbitrary labels, window names etc., then it makes
sense for these to be in UTF-8 format rather than strings in the code
page extended ASCII format. This should make the API more interoperable
with other data sources.
2017-01-21 16:21:27 +00:00
Simon Howard
8f5a4af761 textscreen: Very minor fix to code page.
0x7f in CP437 is actually Unicode character 0x2302, a symbol that
apparently represents a house.
2017-01-21 15:55:33 +00:00
Simon Howard
40d1ce5541 textscreen: Refactor code page mapping.
We were duplicating the Unicode/code page mapping table between
txt_gui.c and txt_sdl.c, but in an incomplete and inconsistent way. It
makes sense that the code page mapping should be kept with the font
files that represent the code page anyway, as there may be projects like
Julian Nechaevsky's Russian Doom which may want to change the code page.
2017-01-21 15:46:04 +00:00
Simon Howard
0aece203e8 textscreen: Tweak TXT_GetKeyDescription() again.
We use the SDL APIs to get a localized name for keys now. However, we
must consider that SDL's key names are in UTF8 format and can therefore
contain non-ASCII characters which cannot be displayed on the CP437 text
screen. So double-check if key names contain any unprintable characters
and if they do, use a fallback set of default key names instead.

This fixes #840. Thanks to Julian Nechaevsky for the report.
2017-01-21 02:31:45 +00:00
Simon Howard
30f853b658 textscreen: Fix input of Unicode characters.
For non-ASCII characters we map into a higher range to avoid conflict
with special keys. Restore this behavior.
2016-12-21 15:11:22 +00:00
Simon Howard
d3cb02d810 textscreen: Use SDL API for getting key names.
SDL2 has an API for getting a string description of a key. Change the
textscreen API which does the same to use it. This has the added bonus
that the setup tool will now adjust to show key descriptions that match
the system keyboard layout.
2016-12-18 01:41:21 -05:00
Simon Howard
4e3ab57537 textscreen: Decode UTF8 of character from event.
It's not enough to simply return the first byte from the buffer, since
it may be a non-ASCII character. Decode the whole first character using
the UTF8 library.
2016-12-18 01:13:36 -05:00
Simon Howard
afe0c97234 textscreen: Stop tracking modifier state.
SDL2 has an API to read the current modifier state, so we can just
use this and eliminate the code for tracking state based on key
presses.
2016-12-17 21:21:23 -05:00
Simon Howard
c1ff9bfd5b textscreen: Add input mode switching.
This replaces the old control over whether key mapping is enabled. We
have three different modes used in different situations: "normal" (used
when navigating windows, etc.); "raw" (used when configuring a key and
we want something derived from the scancode) and "text" (used when typing
something into an input box widget).
2016-12-17 21:14:13 -05:00
Simon Howard
f5b04622c2 textscreen: Fix rendering when using a tiling WM.
When using a tiling window manager, the window dimensions as passed
to SDL_CreateWindow() can potentially be ignored, and we can end up
with a different window size even though we didn't ask for the window
to be resizeable.

In this situation, we were scaling the textscreen image to always fill
the window, regardless of size or aspect ratio. This led to some nasty
looking, distorted views in some cases. Instead, always render the
textscreen image at the intended size and center the image within the
window if it is not the requested size.
2016-07-23 17:50:56 -04:00
Jonathan Dowland
15b87abac4 Merge pull request #744 from chocolate-doom/sdl2-mousewheel
fix mousewheel for sdl2 by synthesising button events
2016-07-04 21:38:22 +01:00
Jonathan Dowland
35f805c234 Fix mix-up of up/down buttons; ignore OS invert
Don't bother trying to override the OS on the mouse wheel
axis inversion, to be consistent with SDL1.

Fix mixing up the up/down button numbers.

Rename some variables for clarity.
2016-07-04 21:28:48 +01:00
Jonathan Dowland
2435f5bb4d Fix mousewheel for SDL2 by synthesising buttons
SDL2 treats mouse wheel events as different from buttons.

Assuming we want the wheel to emulate buttons as per SDL1,
map the mouse wheel events to buttons. Use the mappings in
textscreen (down = 3, up = 4).

Fixes #722.
2016-07-04 09:10:53 +01:00
Jonathan Dowland
346490a4dd textscreen: fix check for size of screen
SDL_GetCurrentDisplayMode returns 0 on fail.

Fixes #742.
2016-07-04 06:25:21 +01:00
Simon Howard
3626db3888 textscreen: Set parent pointer for conditionals.
We rely on the parent pointer to determine if the widget is being
hovered over. Set the parent pointer so that the background is set
properly for a widget in a conditional container.
2016-06-09 23:10:59 -04:00