summaryrefslogtreecommitdiff
path: root/setup/display.c
blob: f30debd8a8984772a0883e1f3ff07975253a20b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Emacs style mode select   -*- C++ -*- 
//-----------------------------------------------------------------------------
//
// Copyright(C) 2006 Simon Howard
//
// This program 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; either version 2
// of the License, or (at your option) any later version.
//
// This program 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, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
#include "textscreen.h"

typedef struct 
{
        char *description;
        int fullscreen;
        int screenmult;
} vidmode_t;

static vidmode_t modes[] = 
{
        { "320x200",  0, 1 },
        { "640x400",  0, 2 },
        { "960x600",  0, 3 },
        { "1280x800", 0, 4 },
        { "320x200",  1, 1 },
        { "320x240",  2, 1 },
        { "640x400",  1, 2 },
        { "640x480",  2, 2 },
        { "960x600",  1, 3 },
        { "960x720",  2, 3 },
        { "1280x800", 1, 4 },
        { "1280x960", 2, 4 },
        { NULL },
};

static int vidmode = 0;
static int fullscreen = 0;
static int screenmult = 1;
static int grabmouse = 1;

// Given the video settings (fullscreen, screenmult, etc), find the
// current video mode

static void SetCurrentMode(void)
{
        int i;

        vidmode = 0;

        for (i=0; modes[i].description != NULL; ++i)
        {
                if (fullscreen == modes[i].fullscreen
                 && screenmult == modes[i].screenmult)
                {
                        vidmode = i;
                        break;
                }
        }
}

static void ModeSelected(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(mode))
{
        TXT_CAST_ARG(vidmode_t, mode);

        fullscreen = mode->fullscreen;
        screenmult = mode->screenmult;
}

void ConfigDisplay(void)
{
    txt_window_t *window;
    txt_table_t *table;
    txt_radiobutton_t *rbutton;
    int i;

    // Find the current mode

    SetCurrentMode();

    // Open the window
    
    window = TXT_NewWindow("Display Configuration");

    TXT_AddWidget(window, TXT_NewSeparator("Windowed modes"));

    table = TXT_NewTable(2);
    
    for (i=0; modes[i].fullscreen == 0; ++i)
    {
        rbutton = TXT_NewRadioButton(modes[i].description, &vidmode, i);
        TXT_AddWidget(table, rbutton);
        TXT_SignalConnect(rbutton, "selected", ModeSelected, &modes[i]);
    }

    TXT_AddWidget(window, table);

    TXT_AddWidget(window, TXT_NewSeparator("Fullscreen modes"));

    table = TXT_NewTable(2);

    for (; modes[i].description != NULL; ++i)
    {
        rbutton = TXT_NewRadioButton(modes[i].description, &vidmode, i);
        TXT_AddWidget(table, rbutton);
        TXT_SignalConnect(rbutton, "selected", ModeSelected, &modes[i]);
    }

    TXT_AddWidget(window, table);

    TXT_AddWidget(window, TXT_NewSeparator(NULL));
    TXT_AddWidget(window, TXT_NewCheckBox("Grab mouse", &grabmouse));
}