Like the AUTORADIOBUTTON, the parent of a RADIOBUTTON style button
[wine] / dlls / ttydrv / ttydrv_main.c
1 /*
2  * TTYDRV initialization code
3  */
4
5 #include "config.h"
6
7 #include <stdio.h>
8
9 #include "winbase.h"
10 #include "clipboard.h"
11 #include "gdi.h"
12 #include "message.h"
13 #include "monitor.h"
14 #include "mouse.h"
15 #include "user.h"
16 #include "win.h"
17 #include "debugtools.h"
18 #include "ttydrv.h"
19
20 DEFAULT_DEBUG_CHANNEL(ttydrv);
21
22 static USER_DRIVER user_driver =
23 {
24     /* event functions */
25     TTYDRV_EVENT_Synchronize,
26     TTYDRV_EVENT_CheckFocus,
27     TTYDRV_EVENT_UserRepaintDisable,
28     /* keyboard functions */
29     TTYDRV_KEYBOARD_Init,
30     TTYDRV_KEYBOARD_VkKeyScan,
31     TTYDRV_KEYBOARD_MapVirtualKey,
32     TTYDRV_KEYBOARD_GetKeyNameText,
33     TTYDRV_KEYBOARD_ToAscii,
34     TTYDRV_KEYBOARD_GetBeepActive,
35     TTYDRV_KEYBOARD_SetBeepActive,
36     TTYDRV_KEYBOARD_Beep,
37     TTYDRV_KEYBOARD_GetDIState,
38     TTYDRV_KEYBOARD_GetDIData,
39     TTYDRV_KEYBOARD_GetKeyboardConfig,
40     TTYDRV_KEYBOARD_SetKeyboardConfig,
41     /* mouse functions */
42     TTYDRV_MOUSE_Init,
43     TTYDRV_MOUSE_SetCursor,
44     TTYDRV_MOUSE_MoveCursor,
45     TTYDRV_MOUSE_EnableWarpPointer,
46     /* screen saver functions */
47     TTYDRV_GetScreenSaveActive,
48     TTYDRV_SetScreenSaveActive,
49     TTYDRV_GetScreenSaveTimeout,
50     TTYDRV_SetScreenSaveTimeout,
51     /* windowing functions */
52     TTYDRV_IsSingleWindow
53 };
54
55 int cell_width = 8;
56 int cell_height = 8;
57 WINDOW *root_window;
58
59
60 /***********************************************************************
61  *           TTYDRV process initialisation routine
62  */
63 static void process_attach(void)
64 {
65     int rows, cols;
66
67     USER_Driver      = &user_driver;
68     CLIPBOARD_Driver = &TTYDRV_CLIPBOARD_Driver;
69     WND_Driver       = &TTYDRV_WND_Driver;
70
71 #ifdef WINE_CURSES
72     if ((root_window = initscr()))
73     {
74         werase(root_window);
75         wrefresh(root_window);
76     }
77     getmaxyx(root_window, rows, cols);
78 #else  /* WINE_CURSES */
79     rows = 60; /* FIXME: Hardcoded */
80     cols = 80; /* FIXME: Hardcoded */
81 #endif  /* WINE_CURSES */
82
83     MONITOR_PrimaryMonitor.rect.left   = 0;
84     MONITOR_PrimaryMonitor.rect.top    = 0;
85     MONITOR_PrimaryMonitor.rect.right  = cell_width * cols;
86     MONITOR_PrimaryMonitor.rect.bottom = cell_height * rows;
87     MONITOR_PrimaryMonitor.depth       = 1;
88
89     TTYDRV_GDI_Initialize();
90 }
91
92
93 /***********************************************************************
94  *           TTYDRV process termination routine
95  */
96 static void process_detach(void)
97 {
98     TTYDRV_GDI_Finalize();
99
100 #ifdef WINE_CURSES
101     if (root_window) endwin();
102 #endif  /* WINE_CURSES */
103
104     USER_Driver      = NULL;
105     CLIPBOARD_Driver = NULL;
106     WND_Driver       = NULL;
107 }
108
109
110 /***********************************************************************
111  *           TTYDRV initialisation routine
112  */
113 BOOL WINAPI TTYDRV_Init( HINSTANCE hinst, DWORD reason, LPVOID reserved )
114 {
115     static int process_count;
116
117     switch(reason)
118     {
119     case DLL_PROCESS_ATTACH:
120         if (!process_count++) process_attach();
121         break;
122
123     case DLL_PROCESS_DETACH:
124         if (!--process_count) process_detach();
125         break;
126     }
127     return TRUE;
128 }
129
130
131 /***********************************************************************
132  *              TTYDRV_GetScreenSaveActive
133  *
134  * Returns the active status of the screen saver
135  */
136 BOOL TTYDRV_GetScreenSaveActive(void)
137 {
138     return FALSE;
139 }
140
141 /***********************************************************************
142  *              TTYDRV_SetScreenSaveActive
143  *
144  * Activate/Deactivate the screen saver
145  */
146 void TTYDRV_SetScreenSaveActive(BOOL bActivate)
147 {
148     FIXME("(%d): stub\n", bActivate);
149 }
150
151 /***********************************************************************
152  *              TTYDRV_GetScreenSaveTimeout
153  *
154  * Return the screen saver timeout
155  */
156 int TTYDRV_GetScreenSaveTimeout(void)
157 {
158     return 0;
159 }
160
161 /***********************************************************************
162  *              TTYDRV_SetScreenSaveTimeout
163  *
164  * Set the screen saver timeout
165  */
166 void TTYDRV_SetScreenSaveTimeout(int nTimeout)
167 {
168     FIXME("(%d): stub\n", nTimeout);
169 }
170
171 /***********************************************************************
172  *              TTYDRV_IsSingleWindow
173  */
174 BOOL TTYDRV_IsSingleWindow(void)
175 {
176     return TRUE;
177 }