File: inform_user.c

package info (click to toggle)
garlic 1.5-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 4,324 kB
  • ctags: 1,378
  • sloc: ansic: 50,306; makefile: 1,088
file content (64 lines) | stat: -rw-r--r-- 1,911 bytes parent folder | download | duplicates (5)
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
/* Copyright (C) 2001-2002 Damir Zucic */

/*=============================================================================

				inform_user.c

Purpose:
	Write some message to the main window.

Input:
	(1) Pointer to GUIS structure, with GUI data.
	(2) Pointer to the string which contains the message.

Output:
	(1) Short message written to the main window.

Return value:
	No return value.

========includes:============================================================*/

#include <stdio.h>

#include <string.h>

#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include <X11/Xatom.h>

#include "defines.h"
#include "typedefs.h"

/*======inform user about something:=========================================*/

void InformUser_ (GUIS *guiSP, char *messageP)
{
int		message_length, text_width;
int		frame_width, frame_height;
int		screen_x0, screen_y0;

/* Inform user about something: */
message_length = strlen (messageP);
text_width = XTextWidth (guiSP->main_winS.fontSP, messageP, message_length);
frame_width = text_width + 50;
frame_height = 4 * guiSP->main_winS.text_line_height;
screen_x0 = (guiSP->main_win_free_area_width - frame_width) / 2;
screen_y0 = (guiSP->main_win_free_area_height - frame_height) / 2;
XSetForeground (guiSP->displaySP, guiSP->theGCA[0], guiSP->dark_red_colorID);
XFillRectangle (guiSP->displaySP, guiSP->main_winS.ID, guiSP->theGCA[0],
		screen_x0, screen_y0, frame_width, frame_height);
XSetForeground (guiSP->displaySP, guiSP->theGCA[0], guiSP->yellow_colorID);
screen_x0 = (guiSP->main_win_free_area_width - text_width) / 2;
screen_y0 = (guiSP->main_win_free_area_height +
	     guiSP->main_winS.text_line_height) / 2;
XDrawString (guiSP->displaySP, guiSP->main_winS.ID, guiSP->theGCA[0],
	     screen_x0, screen_y0, messageP, message_length);
XFlush (guiSP->displaySP);

}

/*===========================================================================*/