Info
Get involved
Documentation
00001 // #define SAL_ON 00002 #include "SAL.h" 00003 00004 int buttonId1, buttonId2, buttonId3, inputBoxId1, inputBoxId2; 00005 00006 int action(int action_id) 00007 { 00008 if(action_id == buttonId1) //If buttonId1 has receved an event 00009 { 00010 // delButton(buttonId1); //Delete buttonId1 00011 } 00012 if(action_id == buttonId3) //If buttonId1 has receved an event 00013 { 00014 // printf("Box zegt: %s welkom.\n",readInputBox(inputBoxId1)->c_str()); 00015 } 00016 if(action_id == buttonId2) //If buttonId2 has receved an event 00017 { 00018 salStop(); //Stop sal (and most often also the application) 00019 } 00020 return 0; 00021 } 00022 00023 int mouse(int x, int y, char button, char clicks) 00024 { 00025 salDrawRect(x, y, 100, 20, COLOR_ORANGE); //Draw an rectangle 00026 salDrawText(x, y+1, 100, 18, "Clicked here", COLOR_ORANGE); //Draw some text 00027 salRefresh(); //Update screen 00028 return 0; 00029 } 00030 00031 int keyboard(SDLKey key, SDLMod mod) 00032 { 00033 if(key==SDLK_ESCAPE) //If some one presse the escape key 00034 salStop(); //Stop sal (most of the times also the program) 00035 return 0; 00036 } 00037 00038 int main() 00039 { 00040 SAL("Demo aplication", 600, 460,32,0, false); //Initialise the window and sal 00041 salSetActionHandler(action); //Set the action handler that handles buttons etc 00042 salSetKeyboardHandler(keyboard); //Set action handles that handles key presses 00043 salSetMouseHandler(mouse); //Set action handles that handles mouse events 00044 00045 salDrawRect(50,50,160,80,COLOR_BLUE); //Draw an rectangle 00046 addUdpInputSocket(2345); 00047 addUdpOutputSocket(3456); 00048 IPaddress server[3];// = new IPaddress; 00049 SDLNet_ResolveHost(&server[0], "localhost", 2345); 00050 sendUdpMessage("Hallo!!!",8, server); 00051 00052 // buttonId1 = addButton(60,60,"Button 1"); //Add an button to the inteface 00053 // buttonId2 = addButton(60,90,"Button 2"); //Add another button to the interface 00054 // buttonId3 = addButton(460,130,"Submit"); //Add another button to the interface 00055 // 00056 // inputBoxId2 = addInputBox(160,230,"",400); 00057 // inputBoxId1 = addInputBox(60,130,"",400); 00058 00059 salRefresh(); //Update the interface 00060 }