summaryrefslogtreecommitdiffstats
path: root/Tests/X11/HelloWorldX11.cxx
diff options
context:
space:
mode:
authorKitware Robot <kwrobot@kitware.com>2016-05-16 14:34:04 (GMT)
committerBrad King <brad.king@kitware.com>2016-05-16 20:05:19 (GMT)
commitd9fd2f5402eeaa345691313658e02b51038f570b (patch)
treedca71b9a7e267f4c6300da3eb770415381726785 /Tests/X11/HelloWorldX11.cxx
parent82df6deaafb36cbbfd450202bb20b320f637751a (diff)
downloadCMake-d9fd2f5402eeaa345691313658e02b51038f570b.zip
CMake-d9fd2f5402eeaa345691313658e02b51038f570b.tar.gz
CMake-d9fd2f5402eeaa345691313658e02b51038f570b.tar.bz2
Revise C++ coding style using clang-format
Run the `Utilities/Scripts/clang-format.bash` script to update all our C++ code to a new style defined by `.clang-format`. Use `clang-format` version 3.8. * If you reached this commit for a line in `git blame`, re-run the blame operation starting at the parent of this commit to see older history for the content. * See the parent commit for instructions to rebase a change across this style transition commit.
Diffstat (limited to 'Tests/X11/HelloWorldX11.cxx')
-rw-r--r--Tests/X11/HelloWorldX11.cxx140
1 files changed, 68 insertions, 72 deletions
diff --git a/Tests/X11/HelloWorldX11.cxx b/Tests/X11/HelloWorldX11.cxx
index 27ab843..0863f7b 100644
--- a/Tests/X11/HelloWorldX11.cxx
+++ b/Tests/X11/HelloWorldX11.cxx
@@ -10,7 +10,6 @@
*
*/
-
#ifndef MAIN_H
#define MAIN_H 1
@@ -22,19 +21,17 @@
#include <X11/Xos.h>
#include <X11/Xutil.h>
-class Main {
+class Main
+{
public:
// constructor
- Main(int argc, char * const argv[]);
- //virtual ~Main();
-
+ Main(int argc, char* const argv[]);
+ // virtual ~Main();
private:
-
-
/* here are our X variables */
- Display *dis;
+ Display* dis;
int screen;
Window win;
GC gc;
@@ -44,7 +41,6 @@ private:
void close_x();
void redraw();
int delay(int i);
-
};
#endif
@@ -57,90 +53,90 @@ private:
// http://www.insanityengine.com/doc/x11/xintro.html
// jeff louie 02.05.2004
-
-
-int main (int argc, char * const argv[]) {
+int main(int argc, char* const argv[])
+{
Main m(argc, argv);
return 0;
}
-//Main::~Main() {;};
-Main::Main (int argc, char * const argv[]) {
- XEvent event; // XEvent declaration
- KeySym key; // KeyPress Events
- char text[255]; // char buffer for KeyPress Events
+// Main::~Main() {;};
+Main::Main(int argc, char* const argv[])
+{
+ XEvent event; // XEvent declaration
+ KeySym key; // KeyPress Events
+ char text[255]; // char buffer for KeyPress Events
init_x();
// event loop
- while(1) {
- // get the next event and stuff it into our event variable.
- // Note: only events we set the mask for are detected!
- XNextEvent(dis, &event);
-
-
- switch (event.type) {
- int x;
- int y;
- case Expose:
- if (event.xexpose.count==0) {
- redraw();
- }
- break;
- case KeyPress:
- if (XLookupString(&event.xkey,text,255,&key,0)==1) {
- // use the XLookupString routine to convert the invent
- // KeyPress data into regular text. Weird but necessary...
- if ((text[0]=='q') || (text[0]=='Q')) {
- close_x();
- }
- else {
- // echo key press
- printf("You pressed the %c key!\n",text[0]);
+ while (1) {
+ // get the next event and stuff it into our event variable.
+ // Note: only events we set the mask for are detected!
+ XNextEvent(dis, &event);
+
+ switch (event.type) {
+ int x;
+ int y;
+ case Expose:
+ if (event.xexpose.count == 0) {
+ redraw();
+ }
+ break;
+ case KeyPress:
+ if (XLookupString(&event.xkey, text, 255, &key, 0) == 1) {
+ // use the XLookupString routine to convert the invent
+ // KeyPress data into regular text. Weird but necessary...
+ if ((text[0] == 'q') || (text[0] == 'Q')) {
+ close_x();
+ } else {
+ // echo key press
+ printf("You pressed the %c key!\n", text[0]);
+ }
+ }
+ break;
+ case ButtonPress:
+ // get cursor position
+ x = event.xbutton.x;
+ y = event.xbutton.y;
+ strcpy(text, "X is FUN!");
+ XSetForeground(dis, gc, rand() % event.xbutton.x % 255);
+ // draw text at cursor
+ XDrawString(dis, win, gc, x, y, text, strlen(text));
+ break;
+ default:
+ printf("Unhandled event.\n");
}
- }
- break;
- case ButtonPress:
- // get cursor position
- x= event.xbutton.x;
- y= event.xbutton.y;
- strcpy(text,"X is FUN!");
- XSetForeground(dis,gc,rand()%event.xbutton.x%255);
- // draw text at cursor
- XDrawString(dis,win,gc,x,y, text, strlen(text));
- break;
- default:
- printf("Unhandled event.\n");
- }
}
}
-void Main::init_x() {
- unsigned long black,white;
-
- dis=XOpenDisplay(NULL);
- screen=DefaultScreen(dis);
- black=BlackPixel(dis,screen),
- white=WhitePixel(dis, screen);
- win=XCreateSimpleWindow(dis,DefaultRootWindow(dis),0,0,
- 300, 300, 5,black, white);
- XSetStandardProperties(dis,win,"Hello World","Hi",None,NULL,0,NULL);
- XSelectInput(dis, win, ExposureMask|ButtonPressMask|KeyPressMask);
+void Main::init_x()
+{
+ unsigned long black, white;
+
+ dis = XOpenDisplay(NULL);
+ screen = DefaultScreen(dis);
+ black = BlackPixel(dis, screen), white = WhitePixel(dis, screen);
+ win = XCreateSimpleWindow(dis, DefaultRootWindow(dis), 0, 0, 300, 300, 5,
+ black, white);
+ XSetStandardProperties(dis, win, "Hello World", "Hi", None, NULL, 0, NULL);
+ XSelectInput(dis, win, ExposureMask | ButtonPressMask | KeyPressMask);
// get Graphics Context
- gc=XCreateGC(dis, win, 0,0);
- XSetBackground(dis,gc,white);
- XSetForeground(dis,gc,black);
+ gc = XCreateGC(dis, win, 0, 0);
+ XSetBackground(dis, gc, white);
+ XSetForeground(dis, gc, black);
XClearWindow(dis, win);
XMapRaised(dis, win);
};
-void Main::close_x() {
+void Main::close_x()
+{
XFreeGC(dis, gc);
- XDestroyWindow(dis,win);
+ XDestroyWindow(dis, win);
XCloseDisplay(dis);
exit(1);
};
-void Main::redraw() {
+void Main::redraw()
+{
XClearWindow(dis, win);
};