Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.07 KB | None | 0 0
  1.  
  2. /* exported function documented in fbtk.h */
  3. fbtk_widget_t *
  4. fbtk_create_writable_text(fbtk_widget_t *parent,
  5. int x,
  6. int y,
  7. int width,
  8. int height,
  9. colour bg,
  10. colour fg,
  11. bool outline,
  12. fbtk_enter_t enter,
  13. void *pw)
  14. {
  15. fbtk_widget_t *neww;
  16.  
  17. neww = fbtk_widget_new(parent, FB_WIDGET_TYPE_TEXT, x, y, width, height);
  18. neww->fg = fg;
  19. neww->bg = bg;
  20. neww->mapped = true;
  21.  
  22. neww->u.text.outline = outline;
  23. neww->u.text.enter = enter;
  24. neww->u.text.pw = pw;
  25.  
  26. fbtk_set_handler(neww, FBTK_CBT_REDRAW, fb_redraw_text, NULL);
  27. fbtk_set_handler(neww, FBTK_CBT_INPUT, text_input, neww);
  28.  
  29. return neww;
  30. }
  31.  
  32. #include <proto/intuition.h>
  33. #include <proto/gadtools.h>
  34. #include <proto/exec.h>
  35. #include <proto/dos.h>
  36. #include <intuition/intuition.h>
  37. #include <libraries/gadtools.h>
  38.  
  39. /* exported function documented in fbtk.h */
  40. fbtk_widget_t *
  41. fbtk_create_writable_text_ami(fbtk_widget_t *parent,
  42. int x,
  43. int y,
  44. int width,
  45. int height,
  46. colour bg,
  47. colour fg,
  48. bool outline,
  49. fbtk_enter_t enter,
  50. void *pw)
  51. {
  52. APTR visual;
  53.  
  54. /* Type of gadgets to display */
  55. ULONG Gadgetkinds[1] = {STRING_KIND};
  56.  
  57. struct TextAttr topaz8 = {
  58. (STRPTR)"topaz.font", 8, 0, 1
  59. };
  60.  
  61. /* Data for gadget structures */
  62. struct NewGadget Gadgetdata[1] = {
  63. x, y + 60, width, height, (UBYTE *)"Url", &topaz8, 1, PLACETEXT_LEFT, NULL, NULL,
  64. };
  65.  
  66. /* Extra information for gadgets using Tags */
  67. ULONG GadgetTags[] = {
  68. (GTST_MaxChars), 256, (TAG_DONE),
  69. (GTNM_Border), TRUE, (TAG_DONE),
  70. (TAG_DONE)
  71. };
  72.  
  73. struct Screen *pubScreen;
  74. struct Window *myWindow;
  75. struct Gadget *myGadgets[1], *glist=NULL, *gad1;
  76. int closewin = FALSE, i;
  77. struct IntuiMessage *msg;
  78. ULONG msgClass;
  79.  
  80. /* Lock screen and get visual info for gadtools */
  81. if (pubScreen = LockPubScreen(NULL)) {
  82. if (!(visual = GetVisualInfo(pubScreen, TAG_DONE))) {
  83. printf("Failed to get visual info.\n");
  84. Exit(5);
  85. }
  86. }
  87. else {
  88. printf("Failed to lock screen.\n");
  89. Exit(5);
  90. }
  91.  
  92. /* Open window and specify gadget list */
  93. myWindow = OpenWindowTags(NULL,
  94. WA_Left, 10, WA_Top, 50,
  95. WA_Width, option_window_width, WA_Height, option_window_height,
  96. WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_GADGETUP,
  97. WA_Flags, WFLG_SIZEGADGET | WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_CLOSEGADGET | WFLG_ACTIVATE | WFLG_SMART_REFRESH,
  98. WA_Gadgets, glist,
  99. WA_Title, "",
  100. WA_PubScreenName, "Workbench",
  101. TAG_DONE);
  102.  
  103. GT_RefreshWindow(myWindow, NULL); /* Update window */
  104.  
  105. while (closewin == FALSE) {
  106. Wait(1L << myWindow->UserPort->mp_SigBit);
  107. msg = GT_GetIMsg(myWindow->UserPort);
  108. msgClass = msg->Class;
  109. GT_ReplyIMsg(msg);
  110. if (msgClass == IDCMP_CLOSEWINDOW) {
  111. closewin = TRUE;
  112. }
  113. }
  114.  
  115. if (myWindow) CloseWindow(myWindow);
  116.  
  117. /* Free gadgets */
  118. if (glist) FreeGadgets(glist);
  119.  
  120. if (visual) FreeVisualInfo(visual);
  121. if (pubScreen) UnlockPubScreen(NULL, pubScreen);
  122. return(0);
  123. //return 0;
  124. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement