Source Code for Me (s-c.me)

Allows you to paste souce code to blogs! Adapted for Twitter! Here is Search Form in case you missed your code.
Tags: CSS,#include, Created At: 10/24/2016 8:26:43 PMViews:

HTML view:
Copy Source | Copy HTML
  1. #include "inkview.h"
  2.  
  3. int cindex= 0;
  4. ifont *arialb12;
  5. extern const ibitmap habrahabr;
  6.  
  7. static imenu menu1_submenu1[] = {
  8.     { ITEM_ACTIVE, 103, "Ask about weather", NULL },
  9.     {  0,  0, NULL, NULL }
  10. };
  11.  
  12. static imenu menu1[] = {
  13.     { ITEM_HEADER,  0, "Menu", NULL },
  14.     { ITEM_ACTIVE, 101, "Say 'Hi'", NULL },
  15.     { ITEM_SUBMENU,  0, "Submenu", menu1_submenu1 },
  16.     { ITEM_SEPARATOR,  0, NULL, NULL },
  17.     { ITEM_ACTIVE, 102, "Exit", NULL },
  18.     {  0,  0, NULL, NULL }
  19. };
  20.  
  21. void msg(char *s) {
  22.     FillArea(350, 770, 250, 20, WHITE);
  23.     SetFont(arialb12, BLACK);
  24.     DrawString(350, 770, s);
  25.     PartialUpdate(350, 770, 250, 20);
  26. }
  27.  
  28. void dialog_handler(int button) {
  29.     msg(button == 1 ? "Choosed: yes" : "Choosed: no");
  30. }
  31.  
  32. void menu1_handler(int index) {
  33.     cindex = index;
  34.  
  35.     switch (index) {
  36.         case 101:
  37.             Message(ICON_INFORMATION, "Message", "Hello, Worl!\n"
                    "This message will disappear after 5 seconds, or press any key", 5000);
  38.             break;
  39.  
  40.         case 102:
  41.             CloseApp();
  42.             break;
  43.  
  44.         case 103:
  45.             Dialog(ICON_QUESTION, "Dialog", "It's a nice day today,isn't it?\n", "Yes", "No", dialog_handler);
  46.             break;
  47.     }
  48. }
  49.  
  50. int main_handler(int type, int par1, int par2) {
  51.     if (type == EVT_INIT) {
  52.         arialb12 = OpenFont("LiberationSans", 12, 1);
  53.     }
  54.  
  55.     if (type == EVT_SHOW) {
  56.         DrawBitmap(120, 30, &habrahabr);
  57.         FullUpdate();
  58.     }
  59.  
  60.     if (type == EVT_KEYPRESS) {
  61.         switch (par1) {
  62.             case KEY_OK:
  63.                 OpenMenu(menu1, cindex, 20, 20, menu1_handler);
  64.                 break;
  65.  
  66.             case KEY_BACK:
  67.                 CloseApp();
  68.                 break;
  69.         }
  70.     }
  71.     return  0;
  72. }
  73.  
  74. int main(int argc, char **argv) {
  75.     InkViewMain(main_handler);
  76.     return  0;
  77. }

Based on Manoli.Net's CodeFormatter. Made by Topbot (c) 2008-2017