Mercurial > vim
comparison src/gui_beval.c @ 18781:79e10adc821d v8.1.2380
patch 8.1.2380: using old C style comments
Commit: https://github.com/vim/vim/commit/306139005c31ea7e6f892dd119beba3c94dcb982
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Dec 1 22:11:18 2019 +0100
patch 8.1.2380: using old C style comments
Problem: Using old C style comments.
Solution: Use // comments where appropriate.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 01 Dec 2019 22:15:03 +0100 |
parents | 041156ce1d22 |
children | c4bce986c31a |
comparison
equal
deleted
inserted
replaced
18780:04ce3b8a50ed | 18781:79e10adc821d |
---|---|
10 | 10 |
11 #include "vim.h" | 11 #include "vim.h" |
12 | 12 |
13 #if defined(FEAT_BEVAL_GUI) || defined(PROTO) | 13 #if defined(FEAT_BEVAL_GUI) || defined(PROTO) |
14 | 14 |
15 /* on Win32 only get_beval_info() is required */ | 15 // on Win32 only get_beval_info() is required |
16 #if !defined(FEAT_GUI_MSWIN) || defined(PROTO) | 16 #if !defined(FEAT_GUI_MSWIN) || defined(PROTO) |
17 | 17 |
18 #ifdef FEAT_GUI_GTK | 18 #ifdef FEAT_GUI_GTK |
19 # if GTK_CHECK_VERSION(3,0,0) | 19 # if GTK_CHECK_VERSION(3,0,0) |
20 # include <gdk/gdkkeysyms-compat.h> | 20 # include <gdk/gdkkeysyms-compat.h> |
30 # include <Xm/List.h> | 30 # include <Xm/List.h> |
31 # include <Xm/Label.h> | 31 # include <Xm/Label.h> |
32 # include <Xm/AtomMgr.h> | 32 # include <Xm/AtomMgr.h> |
33 # include <Xm/Protocols.h> | 33 # include <Xm/Protocols.h> |
34 # else | 34 # else |
35 /* Assume Athena */ | 35 // Assume Athena |
36 # include <X11/Shell.h> | 36 # include <X11/Shell.h> |
37 # ifdef FEAT_GUI_NEXTAW | 37 # ifdef FEAT_GUI_NEXTAW |
38 # include <X11/neXtaw/Label.h> | 38 # include <X11/neXtaw/Label.h> |
39 # else | 39 # else |
40 # include <X11/Xaw/Label.h> | 40 # include <X11/Xaw/Label.h> |
93 char_u *mesg, | 93 char_u *mesg, |
94 void (*mesgCB)(BalloonEval *, int), | 94 void (*mesgCB)(BalloonEval *, int), |
95 void *clientData) | 95 void *clientData) |
96 { | 96 { |
97 #ifndef FEAT_GUI_GTK | 97 #ifndef FEAT_GUI_GTK |
98 char *display_name; /* get from gui.dpy */ | 98 char *display_name; // get from gui.dpy |
99 int screen_num; | 99 int screen_num; |
100 char *p; | 100 char *p; |
101 #endif | 101 #endif |
102 BalloonEval *beval; | 102 BalloonEval *beval; |
103 | 103 |
155 void | 155 void |
156 gui_mch_destroy_beval_area(BalloonEval *beval) | 156 gui_mch_destroy_beval_area(BalloonEval *beval) |
157 { | 157 { |
158 cancelBalloon(beval); | 158 cancelBalloon(beval); |
159 removeEventHandler(beval); | 159 removeEventHandler(beval); |
160 /* Children will automatically be destroyed */ | 160 // Children will automatically be destroyed |
161 # ifdef FEAT_GUI_GTK | 161 # ifdef FEAT_GUI_GTK |
162 gtk_widget_destroy(beval->balloonShell); | 162 gtk_widget_destroy(beval->balloonShell); |
163 # else | 163 # else |
164 XtDestroyWidget(beval->balloonShell); | 164 XtDestroyWidget(beval->balloonShell); |
165 # endif | 165 # endif |
196 gui_mch_currently_showing_beval(void) | 196 gui_mch_currently_showing_beval(void) |
197 { | 197 { |
198 return current_beval; | 198 return current_beval; |
199 } | 199 } |
200 #endif | 200 #endif |
201 #endif /* !FEAT_GUI_MSWIN */ | 201 #endif // !FEAT_GUI_MSWIN |
202 | 202 |
203 #if defined(FEAT_NETBEANS_INTG) || defined(FEAT_EVAL) || defined(PROTO) | 203 #if defined(FEAT_NETBEANS_INTG) || defined(FEAT_EVAL) || defined(PROTO) |
204 # if !defined(FEAT_GUI_MSWIN) || defined(PROTO) | 204 # if !defined(FEAT_GUI_MSWIN) || defined(PROTO) |
205 | 205 |
206 /* | 206 /* |
214 if (beval->msg != NULL) | 214 if (beval->msg != NULL) |
215 drawBalloon(beval); | 215 drawBalloon(beval); |
216 else | 216 else |
217 undrawBalloon(beval); | 217 undrawBalloon(beval); |
218 } | 218 } |
219 # endif /* !FEAT_GUI_MSWIN */ | 219 # endif // !FEAT_GUI_MSWIN |
220 #endif /* FEAT_NETBEANS_INTG || PROTO */ | 220 #endif // FEAT_NETBEANS_INTG || PROTO |
221 | 221 |
222 #if !defined(FEAT_GUI_MSWIN) || defined(PROTO) | 222 #if !defined(FEAT_GUI_MSWIN) || defined(PROTO) |
223 #if defined(FEAT_BEVAL_TIP) || defined(PROTO) | 223 #if defined(FEAT_BEVAL_TIP) || defined(PROTO) |
224 /* | 224 /* |
225 * Hide the given balloon. | 225 * Hide the given balloon. |
342 break; | 342 break; |
343 default: | 343 default: |
344 break; | 344 break; |
345 } | 345 } |
346 | 346 |
347 return FALSE; /* continue emission */ | 347 return FALSE; // continue emission |
348 } | 348 } |
349 | 349 |
350 static gint | 350 static gint |
351 mainwin_event_cb(GtkWidget *widget UNUSED, GdkEvent *event, gpointer data) | 351 mainwin_event_cb(GtkWidget *widget UNUSED, GdkEvent *event, gpointer data) |
352 { | 352 { |
362 break; | 362 break; |
363 default: | 363 default: |
364 break; | 364 break; |
365 } | 365 } |
366 | 366 |
367 return FALSE; /* continue emission */ | 367 return FALSE; // continue emission |
368 } | 368 } |
369 | 369 |
370 static void | 370 static void |
371 pointer_event(BalloonEval *beval, int x, int y, unsigned state) | 371 pointer_event(BalloonEval *beval, int x, int y, unsigned state) |
372 { | 372 { |
381 * Remember button state | 381 * Remember button state |
382 */ | 382 */ |
383 beval->state = state; | 383 beval->state = state; |
384 cancelBalloon(beval); | 384 cancelBalloon(beval); |
385 | 385 |
386 /* Mouse buttons are pressed - no balloon now */ | 386 // Mouse buttons are pressed - no balloon now |
387 if (!(state & ((int)GDK_BUTTON1_MASK | (int)GDK_BUTTON2_MASK | 387 if (!(state & ((int)GDK_BUTTON1_MASK | (int)GDK_BUTTON2_MASK |
388 | (int)GDK_BUTTON3_MASK))) | 388 | (int)GDK_BUTTON3_MASK))) |
389 { | 389 { |
390 beval->x = x; | 390 beval->x = x; |
391 beval->y = y; | 391 beval->y = y; |
429 beval->showState = ShS_UPDATE_PENDING; | 429 beval->showState = ShS_UPDATE_PENDING; |
430 (*beval->msgCB)(beval, (is_keypress) | 430 (*beval->msgCB)(beval, (is_keypress) |
431 ? (int)GDK_CONTROL_MASK : 0); | 431 ? (int)GDK_CONTROL_MASK : 0); |
432 break; | 432 break; |
433 default: | 433 default: |
434 /* Don't do this for key release, we apparently get these with | 434 // Don't do this for key release, we apparently get these with |
435 * focus changes in some GTK version. */ | 435 // focus changes in some GTK version. |
436 if (is_keypress) | 436 if (is_keypress) |
437 cancelBalloon(beval); | 437 cancelBalloon(beval); |
438 break; | 438 break; |
439 } | 439 } |
440 } | 440 } |
453 * a request to be started. The request will only send to the debugger if | 453 * a request to be started. The request will only send to the debugger if |
454 * there the mouse is pointing at real data. | 454 * there the mouse is pointing at real data. |
455 */ | 455 */ |
456 requestBalloon(beval); | 456 requestBalloon(beval); |
457 | 457 |
458 return FALSE; /* don't call me again */ | 458 return FALSE; // don't call me again |
459 } | 459 } |
460 | 460 |
461 # if GTK_CHECK_VERSION(3,0,0) | 461 # if GTK_CHECK_VERSION(3,0,0) |
462 static gboolean | 462 static gboolean |
463 balloon_draw_event_cb(GtkWidget *widget, | 463 balloon_draw_event_cb(GtkWidget *widget, |
497 gtk_paint_flat_box(widget->style, widget->window, | 497 gtk_paint_flat_box(widget->style, widget->window, |
498 GTK_STATE_NORMAL, GTK_SHADOW_OUT, | 498 GTK_STATE_NORMAL, GTK_SHADOW_OUT, |
499 &event->area, widget, "tooltip", | 499 &event->area, widget, "tooltip", |
500 0, 0, -1, -1); | 500 0, 0, -1, -1); |
501 | 501 |
502 return FALSE; /* continue emission */ | 502 return FALSE; // continue emission |
503 } | 503 } |
504 # endif /* !GTK_CHECK_VERSION(3,0,0) */ | 504 # endif // !GTK_CHECK_VERSION(3,0,0) |
505 | 505 |
506 #else /* !FEAT_GUI_GTK */ | 506 #else // !FEAT_GUI_GTK |
507 | 507 |
508 static void | 508 static void |
509 addEventHandler(Widget target, BalloonEval *beval) | 509 addEventHandler(Widget target, BalloonEval *beval) |
510 { | 510 { |
511 XtAddEventHandler(target, | 511 XtAddEventHandler(target, |
549 */ | 549 */ |
550 | 550 |
551 static void | 551 static void |
552 pointerEvent(BalloonEval *beval, XEvent *event) | 552 pointerEvent(BalloonEval *beval, XEvent *event) |
553 { | 553 { |
554 Position distance; /* a measure of how much the pointer moved */ | 554 Position distance; // a measure of how much the pointer moved |
555 Position delta; /* used to compute distance */ | 555 Position delta; // used to compute distance |
556 | 556 |
557 switch (event->type) | 557 switch (event->type) |
558 { | 558 { |
559 case EnterNotify: | 559 case EnterNotify: |
560 case MotionNotify: | 560 case MotionNotify: |
573 * Remember button state | 573 * Remember button state |
574 */ | 574 */ |
575 beval->state = event->xmotion.state; | 575 beval->state = event->xmotion.state; |
576 if (beval->state & (Button1Mask|Button2Mask|Button3Mask)) | 576 if (beval->state & (Button1Mask|Button2Mask|Button3Mask)) |
577 { | 577 { |
578 /* Mouse buttons are pressed - no balloon now */ | 578 // Mouse buttons are pressed - no balloon now |
579 cancelBalloon(beval); | 579 cancelBalloon(beval); |
580 } | 580 } |
581 else if (beval->state & (Mod1Mask|Mod2Mask|Mod3Mask)) | 581 else if (beval->state & (Mod1Mask|Mod2Mask|Mod3Mask)) |
582 { | 582 { |
583 /* | 583 /* |
661 else | 661 else |
662 cancelBalloon(beval); | 662 cancelBalloon(beval); |
663 break; | 663 break; |
664 | 664 |
665 case LeaveNotify: | 665 case LeaveNotify: |
666 /* Ignore LeaveNotify events that are not "normal". | 666 // Ignore LeaveNotify events that are not "normal". |
667 * Apparently we also get it when somebody else grabs focus. | 667 // Apparently we also get it when somebody else grabs focus. |
668 * Happens for me every two seconds (some clipboard tool?) */ | 668 // Happens for me every two seconds (some clipboard tool?) |
669 if (event->xcrossing.mode == NotifyNormal) | 669 if (event->xcrossing.mode == NotifyNormal) |
670 cancelBalloon(beval); | 670 cancelBalloon(beval); |
671 break; | 671 break; |
672 | 672 |
673 case ButtonPress: | 673 case ButtonPress: |
692 * there the mouse is pointing at real data. | 692 * there the mouse is pointing at real data. |
693 */ | 693 */ |
694 requestBalloon(beval); | 694 requestBalloon(beval); |
695 } | 695 } |
696 | 696 |
697 #endif /* !FEAT_GUI_GTK */ | 697 #endif // !FEAT_GUI_GTK |
698 | 698 |
699 static void | 699 static void |
700 requestBalloon(BalloonEval *beval) | 700 requestBalloon(BalloonEval *beval) |
701 { | 701 { |
702 if (beval->showState != ShS_PENDING) | 702 if (beval->showState != ShS_PENDING) |
703 { | 703 { |
704 /* Determine the beval to display */ | 704 // Determine the beval to display |
705 if (beval->msgCB != NULL) | 705 if (beval->msgCB != NULL) |
706 { | 706 { |
707 beval->showState = ShS_PENDING; | 707 beval->showState = ShS_PENDING; |
708 (*beval->msgCB)(beval, beval->state); | 708 (*beval->msgCB)(beval, beval->state); |
709 } | 709 } |
731 unsigned int len; | 731 unsigned int len; |
732 int charlen; | 732 int charlen; |
733 int uc; | 733 int uc; |
734 PangoAttrList *attr_list; | 734 PangoAttrList *attr_list; |
735 | 735 |
736 /* Convert to UTF-8 if it isn't already */ | 736 // Convert to UTF-8 if it isn't already |
737 if (output_conv.vc_type != CONV_NONE) | 737 if (output_conv.vc_type != CONV_NONE) |
738 { | 738 { |
739 convbuf = string_convert(&output_conv, text, NULL); | 739 convbuf = string_convert(&output_conv, text, NULL); |
740 if (convbuf != NULL) | 740 if (convbuf != NULL) |
741 text = convbuf; | 741 text = convbuf; |
742 } | 742 } |
743 | 743 |
744 /* First let's see how much we need to allocate */ | 744 // First let's see how much we need to allocate |
745 len = 0; | 745 len = 0; |
746 for (p = text; *p != NUL; p += charlen) | 746 for (p = text; *p != NUL; p += charlen) |
747 { | 747 { |
748 if ((*p & 0x80) == 0) /* be quick for ASCII */ | 748 if ((*p & 0x80) == 0) // be quick for ASCII |
749 { | 749 { |
750 charlen = 1; | 750 charlen = 1; |
751 len += IS_NONPRINTABLE(*p) ? 2 : 1; /* nonprintable: ^X */ | 751 len += IS_NONPRINTABLE(*p) ? 2 : 1; // nonprintable: ^X |
752 } | 752 } |
753 else | 753 else |
754 { | 754 { |
755 charlen = utf_ptr2len(p); | 755 charlen = utf_ptr2len(p); |
756 uc = utf_ptr2char(p); | 756 uc = utf_ptr2char(p); |
757 | 757 |
758 if (charlen != utf_char2len(uc)) | 758 if (charlen != utf_char2len(uc)) |
759 charlen = 1; /* reject overlong sequences */ | 759 charlen = 1; // reject overlong sequences |
760 | 760 |
761 if (charlen == 1 || uc < 0xa0) /* illegal byte or */ | 761 if (charlen == 1 || uc < 0xa0) // illegal byte or |
762 len += 4; /* control char: <xx> */ | 762 len += 4; // control char: <xx> |
763 else if (!utf_printable(uc)) | 763 else if (!utf_printable(uc)) |
764 /* Note: we assume here that utf_printable() doesn't | 764 // Note: we assume here that utf_printable() doesn't |
765 * care about characters outside the BMP. */ | 765 // care about characters outside the BMP. |
766 len += 6; /* nonprintable: <xxxx> */ | 766 len += 6; // nonprintable: <xxxx> |
767 else | 767 else |
768 len += charlen; | 768 len += charlen; |
769 } | 769 } |
770 } | 770 } |
771 | 771 |
772 attr_list = pango_attr_list_new(); | 772 attr_list = pango_attr_list_new(); |
773 buf = alloc(len + 1); | 773 buf = alloc(len + 1); |
774 | 774 |
775 /* Now go for the real work */ | 775 // Now go for the real work |
776 if (buf != NULL) | 776 if (buf != NULL) |
777 { | 777 { |
778 attrentry_T *aep; | 778 attrentry_T *aep; |
779 PangoAttribute *attr; | 779 PangoAttribute *attr; |
780 guicolor_T pixel; | 780 guicolor_T pixel; |
785 # endif | 785 # endif |
786 #else | 786 #else |
787 GdkColor color = { 0, 0, 0, 0 }; | 787 GdkColor color = { 0, 0, 0, 0 }; |
788 #endif | 788 #endif |
789 | 789 |
790 /* Look up the RGB values of the SpecialKey foreground color. */ | 790 // Look up the RGB values of the SpecialKey foreground color. |
791 aep = syn_gui_attr2entry(HL_ATTR(HLF_8)); | 791 aep = syn_gui_attr2entry(HL_ATTR(HLF_8)); |
792 pixel = (aep != NULL) ? aep->ae_u.gui.fg_color : INVALCOLOR; | 792 pixel = (aep != NULL) ? aep->ae_u.gui.fg_color : INVALCOLOR; |
793 if (pixel != INVALCOLOR) | 793 if (pixel != INVALCOLOR) |
794 # if GTK_CHECK_VERSION(3,0,0) | 794 # if GTK_CHECK_VERSION(3,0,0) |
795 { | 795 { |
805 | 805 |
806 pdest = buf; | 806 pdest = buf; |
807 p = text; | 807 p = text; |
808 while (*p != NUL) | 808 while (*p != NUL) |
809 { | 809 { |
810 /* Be quick for ASCII */ | 810 // Be quick for ASCII |
811 if ((*p & 0x80) == 0 && !IS_NONPRINTABLE(*p)) | 811 if ((*p & 0x80) == 0 && !IS_NONPRINTABLE(*p)) |
812 { | 812 { |
813 *pdest++ = *p++; | 813 *pdest++ = *p++; |
814 } | 814 } |
815 else | 815 else |
816 { | 816 { |
817 charlen = utf_ptr2len(p); | 817 charlen = utf_ptr2len(p); |
818 uc = utf_ptr2char(p); | 818 uc = utf_ptr2char(p); |
819 | 819 |
820 if (charlen != utf_char2len(uc)) | 820 if (charlen != utf_char2len(uc)) |
821 charlen = 1; /* reject overlong sequences */ | 821 charlen = 1; // reject overlong sequences |
822 | 822 |
823 if (charlen == 1 || uc < 0xa0 || !utf_printable(uc)) | 823 if (charlen == 1 || uc < 0xa0 || !utf_printable(uc)) |
824 { | 824 { |
825 int outlen; | 825 int outlen; |
826 | 826 |
827 /* Careful: we can't just use transchar_byte() here, | 827 // Careful: we can't just use transchar_byte() here, |
828 * since 'encoding' is not necessarily set to "utf-8". */ | 828 // since 'encoding' is not necessarily set to "utf-8". |
829 if (*p & 0x80 && charlen == 1) | 829 if (*p & 0x80 && charlen == 1) |
830 { | 830 { |
831 transchar_hex(pdest, *p); /* <xx> */ | 831 transchar_hex(pdest, *p); // <xx> |
832 outlen = 4; | 832 outlen = 4; |
833 } | 833 } |
834 else if (uc >= 0x80) | 834 else if (uc >= 0x80) |
835 { | 835 { |
836 /* Note: we assume here that utf_printable() doesn't | 836 // Note: we assume here that utf_printable() doesn't |
837 * care about characters outside the BMP. */ | 837 // care about characters outside the BMP. |
838 transchar_hex(pdest, uc); /* <xx> or <xxxx> */ | 838 transchar_hex(pdest, uc); // <xx> or <xxxx> |
839 outlen = (uc < 0x100) ? 4 : 6; | 839 outlen = (uc < 0x100) ? 4 : 6; |
840 } | 840 } |
841 else | 841 else |
842 { | 842 { |
843 transchar_nonprint(pdest, *p); /* ^X */ | 843 transchar_nonprint(pdest, *p); // ^X |
844 outlen = 2; | 844 outlen = 2; |
845 } | 845 } |
846 if (pixel != INVALCOLOR) | 846 if (pixel != INVALCOLOR) |
847 { | 847 { |
848 #if GTK_CHECK_VERSION(3,0,0) | 848 #if GTK_CHECK_VERSION(3,0,0) |
938 pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); | 938 pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); |
939 # else | 939 # else |
940 pango_layout_set_wrap(layout, PANGO_WRAP_WORD); | 940 pango_layout_set_wrap(layout, PANGO_WRAP_WORD); |
941 # endif | 941 # endif |
942 pango_layout_set_width(layout, | 942 pango_layout_set_width(layout, |
943 /* try to come up with some reasonable width */ | 943 // try to come up with some reasonable width |
944 PANGO_SCALE * CLAMP(gui.num_cols * gui.char_width, | 944 PANGO_SCALE * CLAMP(gui.num_cols * gui.char_width, |
945 screen_w / 2, | 945 screen_w / 2, |
946 MAX(20, screen_w - 20))); | 946 MAX(20, screen_w - 20))); |
947 | 947 |
948 /* Calculate the balloon's width and height. */ | 948 // Calculate the balloon's width and height. |
949 # if GTK_CHECK_VERSION(3,0,0) | 949 # if GTK_CHECK_VERSION(3,0,0) |
950 gtk_widget_get_preferred_size(beval->balloonShell, &requisition, NULL); | 950 gtk_widget_get_preferred_size(beval->balloonShell, &requisition, NULL); |
951 # else | 951 # else |
952 gtk_widget_size_request(beval->balloonShell, &requisition); | 952 gtk_widget_size_request(beval->balloonShell, &requisition); |
953 # endif | 953 # endif |
954 | 954 |
955 /* Compute position of the balloon area */ | 955 // Compute position of the balloon area |
956 gdk_window_get_origin(gtk_widget_get_window(beval->target), &x, &y); | 956 gdk_window_get_origin(gtk_widget_get_window(beval->target), &x, &y); |
957 x += beval->x; | 957 x += beval->x; |
958 y += beval->y; | 958 y += beval->y; |
959 | 959 |
960 /* Get out of the way of the mouse pointer */ | 960 // Get out of the way of the mouse pointer |
961 if (x + x_offset + requisition.width > screen_x + screen_w) | 961 if (x + x_offset + requisition.width > screen_x + screen_w) |
962 y_offset += 15; | 962 y_offset += 15; |
963 if (y + y_offset + requisition.height > screen_y + screen_h) | 963 if (y + y_offset + requisition.height > screen_y + screen_h) |
964 y_offset = -requisition.height - EVAL_OFFSET_Y; | 964 y_offset = -requisition.height - EVAL_OFFSET_Y; |
965 | 965 |
966 /* Sanitize values */ | 966 // Sanitize values |
967 x = CLAMP(x + x_offset, 0, | 967 x = CLAMP(x + x_offset, 0, |
968 MAX(0, screen_x + screen_w - requisition.width)); | 968 MAX(0, screen_x + screen_w - requisition.width)); |
969 y = CLAMP(y + y_offset, 0, | 969 y = CLAMP(y + y_offset, 0, |
970 MAX(0, screen_y + screen_h - requisition.height)); | 970 MAX(0, screen_y + screen_h - requisition.height)); |
971 | 971 |
972 /* Show the balloon */ | 972 // Show the balloon |
973 # if GTK_CHECK_VERSION(3,0,0) | 973 # if GTK_CHECK_VERSION(3,0,0) |
974 gtk_window_move(GTK_WINDOW(beval->balloonShell), x, y); | 974 gtk_window_move(GTK_WINDOW(beval->balloonShell), x, y); |
975 # else | 975 # else |
976 gtk_widget_set_uposition(beval->balloonShell, x, y); | 976 gtk_widget_set_uposition(beval->balloonShell, x, y); |
977 # endif | 977 # endif |
1046 gtk_widget_show(beval->balloonLabel); | 1046 gtk_widget_show(beval->balloonLabel); |
1047 | 1047 |
1048 gtk_container_add(GTK_CONTAINER(beval->balloonShell), beval->balloonLabel); | 1048 gtk_container_add(GTK_CONTAINER(beval->balloonShell), beval->balloonLabel); |
1049 } | 1049 } |
1050 | 1050 |
1051 #else /* !FEAT_GUI_GTK */ | 1051 #else // !FEAT_GUI_GTK |
1052 | 1052 |
1053 /* | 1053 /* |
1054 * Draw a balloon. | 1054 * Draw a balloon. |
1055 */ | 1055 */ |
1056 static void | 1056 static void |
1061 Position tx; | 1061 Position tx; |
1062 Position ty; | 1062 Position ty; |
1063 | 1063 |
1064 if (beval->msg != NULL) | 1064 if (beval->msg != NULL) |
1065 { | 1065 { |
1066 /* Show the Balloon */ | 1066 // Show the Balloon |
1067 | 1067 |
1068 /* Calculate the label's width and height */ | 1068 // Calculate the label's width and height |
1069 #ifdef FEAT_GUI_MOTIF | 1069 #ifdef FEAT_GUI_MOTIF |
1070 XmString s; | 1070 XmString s; |
1071 | 1071 |
1072 /* For the callback function we parse NL characters to create a | 1072 // For the callback function we parse NL characters to create a |
1073 * multi-line label. This doesn't work for all languages, but | 1073 // multi-line label. This doesn't work for all languages, but |
1074 * XmStringCreateLocalized() doesn't do multi-line labels... */ | 1074 // XmStringCreateLocalized() doesn't do multi-line labels... |
1075 if (beval->msgCB != NULL) | 1075 if (beval->msgCB != NULL) |
1076 s = XmStringCreateLtoR((char *)beval->msg, XmFONTLIST_DEFAULT_TAG); | 1076 s = XmStringCreateLtoR((char *)beval->msg, XmFONTLIST_DEFAULT_TAG); |
1077 else | 1077 else |
1078 s = XmStringCreateLocalized((char *)beval->msg); | 1078 s = XmStringCreateLocalized((char *)beval->msg); |
1079 { | 1079 { |
1090 } | 1090 } |
1091 w += gui.border_offset << 1; | 1091 w += gui.border_offset << 1; |
1092 h += gui.border_offset << 1; | 1092 h += gui.border_offset << 1; |
1093 XtVaSetValues(beval->balloonLabel, XmNlabelString, s, NULL); | 1093 XtVaSetValues(beval->balloonLabel, XmNlabelString, s, NULL); |
1094 XmStringFree(s); | 1094 XmStringFree(s); |
1095 #else /* Athena */ | 1095 #else // Athena |
1096 /* Assume XtNinternational == True */ | 1096 // Assume XtNinternational == True |
1097 XFontSet fset; | 1097 XFontSet fset; |
1098 XFontSetExtents *ext; | 1098 XFontSetExtents *ext; |
1099 | 1099 |
1100 XtVaGetValues(beval->balloonLabel, XtNfontSet, &fset, NULL); | 1100 XtVaGetValues(beval->balloonLabel, XtNfontSet, &fset, NULL); |
1101 ext = XExtentsOfFontSet(fset); | 1101 ext = XExtentsOfFontSet(fset); |
1106 w += gui.border_offset << 1; | 1106 w += gui.border_offset << 1; |
1107 h += gui.border_offset << 1; | 1107 h += gui.border_offset << 1; |
1108 XtVaSetValues(beval->balloonLabel, XtNlabel, beval->msg, NULL); | 1108 XtVaSetValues(beval->balloonLabel, XtNlabel, beval->msg, NULL); |
1109 #endif | 1109 #endif |
1110 | 1110 |
1111 /* Compute position of the balloon area */ | 1111 // Compute position of the balloon area |
1112 tx = beval->x_root + EVAL_OFFSET_X; | 1112 tx = beval->x_root + EVAL_OFFSET_X; |
1113 ty = beval->y_root + EVAL_OFFSET_Y; | 1113 ty = beval->y_root + EVAL_OFFSET_Y; |
1114 if ((tx + w) > beval->screen_width) | 1114 if ((tx + w) > beval->screen_width) |
1115 tx = beval->screen_width - w; | 1115 tx = beval->screen_width - w; |
1116 if ((ty + h) > beval->screen_height) | 1116 if ((ty + h) > beval->screen_height) |
1119 XtVaSetValues(beval->balloonShell, | 1119 XtVaSetValues(beval->balloonShell, |
1120 XmNx, tx, | 1120 XmNx, tx, |
1121 XmNy, ty, | 1121 XmNy, ty, |
1122 NULL); | 1122 NULL); |
1123 #else | 1123 #else |
1124 /* Athena */ | 1124 // Athena |
1125 XtVaSetValues(beval->balloonShell, | 1125 XtVaSetValues(beval->balloonShell, |
1126 XtNx, tx, | 1126 XtNx, tx, |
1127 XtNy, ty, | 1127 XtNy, ty, |
1128 NULL); | 1128 NULL); |
1129 #endif | 1129 #endif |
1130 /* Set tooltip colors */ | 1130 // Set tooltip colors |
1131 { | 1131 { |
1132 Arg args[2]; | 1132 Arg args[2]; |
1133 | 1133 |
1134 #ifdef FEAT_GUI_MOTIF | 1134 #ifdef FEAT_GUI_MOTIF |
1135 args[0].name = XmNbackground; | 1135 args[0].name = XmNbackground; |
1136 args[0].value = gui.tooltip_bg_pixel; | 1136 args[0].value = gui.tooltip_bg_pixel; |
1137 args[1].name = XmNforeground; | 1137 args[1].name = XmNforeground; |
1138 args[1].value = gui.tooltip_fg_pixel; | 1138 args[1].value = gui.tooltip_fg_pixel; |
1139 #else /* Athena */ | 1139 #else // Athena |
1140 args[0].name = XtNbackground; | 1140 args[0].name = XtNbackground; |
1141 args[0].value = gui.tooltip_bg_pixel; | 1141 args[0].value = gui.tooltip_bg_pixel; |
1142 args[1].name = XtNforeground; | 1142 args[1].name = XtNforeground; |
1143 args[1].value = gui.tooltip_fg_pixel; | 1143 args[1].value = gui.tooltip_fg_pixel; |
1144 #endif | 1144 #endif |
1192 #ifdef FEAT_GUI_MOTIF | 1192 #ifdef FEAT_GUI_MOTIF |
1193 XtSetArg(args[n], XmNallowShellResize, True); n++; | 1193 XtSetArg(args[n], XmNallowShellResize, True); n++; |
1194 beval->balloonShell = XtAppCreateShell("balloonEval", "BalloonEval", | 1194 beval->balloonShell = XtAppCreateShell("balloonEval", "BalloonEval", |
1195 overrideShellWidgetClass, gui.dpy, args, n); | 1195 overrideShellWidgetClass, gui.dpy, args, n); |
1196 #else | 1196 #else |
1197 /* Athena */ | 1197 // Athena |
1198 XtSetArg(args[n], XtNallowShellResize, True); n++; | 1198 XtSetArg(args[n], XtNallowShellResize, True); n++; |
1199 beval->balloonShell = XtAppCreateShell("balloonEval", "BalloonEval", | 1199 beval->balloonShell = XtAppCreateShell("balloonEval", "BalloonEval", |
1200 overrideShellWidgetClass, gui.dpy, args, n); | 1200 overrideShellWidgetClass, gui.dpy, args, n); |
1201 #endif | 1201 #endif |
1202 | 1202 |
1211 XtSetArg(args[n], XmNfontList, fl); n++; | 1211 XtSetArg(args[n], XmNfontList, fl); n++; |
1212 XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++; | 1212 XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++; |
1213 beval->balloonLabel = XtCreateManagedWidget("balloonLabel", | 1213 beval->balloonLabel = XtCreateManagedWidget("balloonLabel", |
1214 xmLabelWidgetClass, beval->balloonShell, args, n); | 1214 xmLabelWidgetClass, beval->balloonShell, args, n); |
1215 } | 1215 } |
1216 #else /* FEAT_GUI_ATHENA */ | 1216 #else // FEAT_GUI_ATHENA |
1217 XtSetArg(args[n], XtNforeground, gui.tooltip_fg_pixel); n++; | 1217 XtSetArg(args[n], XtNforeground, gui.tooltip_fg_pixel); n++; |
1218 XtSetArg(args[n], XtNbackground, gui.tooltip_bg_pixel); n++; | 1218 XtSetArg(args[n], XtNbackground, gui.tooltip_bg_pixel); n++; |
1219 XtSetArg(args[n], XtNinternational, True); n++; | 1219 XtSetArg(args[n], XtNinternational, True); n++; |
1220 XtSetArg(args[n], XtNfontSet, gui.tooltip_fontset); n++; | 1220 XtSetArg(args[n], XtNfontSet, gui.tooltip_fontset); n++; |
1221 beval->balloonLabel = XtCreateManagedWidget("balloonLabel", | 1221 beval->balloonLabel = XtCreateManagedWidget("balloonLabel", |
1222 labelWidgetClass, beval->balloonShell, args, n); | 1222 labelWidgetClass, beval->balloonShell, args, n); |
1223 #endif | 1223 #endif |
1224 } | 1224 } |
1225 | 1225 |
1226 #endif /* !FEAT_GUI_GTK */ | 1226 #endif // !FEAT_GUI_GTK |
1227 #endif /* !FEAT_GUI_MSWIN */ | 1227 #endif // !FEAT_GUI_MSWIN |
1228 | 1228 |
1229 #endif /* FEAT_BEVAL_GUI */ | 1229 #endif // FEAT_BEVAL_GUI |