Mercurial > vim
comparison src/gui_motif.c @ 44:af1bcb9a13c0
updated for version 7.0027
author | vimboss |
---|---|
date | Fri, 31 Dec 2004 20:56:11 +0000 |
parents | 3fc0f57ecb91 |
children | 00c35ea0c2b3 |
comparison
equal
deleted
inserted
replaced
43:f55897d6921d | 44:af1bcb9a13c0 |
---|---|
91 static void attachDump(Widget, char *); | 91 static void attachDump(Widget, char *); |
92 #endif | 92 #endif |
93 | 93 |
94 static void gui_motif_menu_colors __ARGS((Widget id)); | 94 static void gui_motif_menu_colors __ARGS((Widget id)); |
95 static void gui_motif_scroll_colors __ARGS((Widget id)); | 95 static void gui_motif_scroll_colors __ARGS((Widget id)); |
96 #ifdef FEAT_MENU | |
97 static void gui_motif_menu_fontlist __ARGS((Widget id)); | |
98 #endif | |
99 | 96 |
100 #if (XmVersion >= 1002) | 97 #if (XmVersion >= 1002) |
101 # define STRING_TAG XmFONTLIST_DEFAULT_TAG | 98 # define STRING_TAG XmFONTLIST_DEFAULT_TAG |
102 #else | 99 #else |
103 # define STRING_TAG XmSTRING_DEFAULT_CHARSET | 100 # define STRING_TAG XmSTRING_DEFAULT_CHARSET |
123 dragging = (((XmScrollBarCallbackStruct *)call_data)->reason == | 120 dragging = (((XmScrollBarCallbackStruct *)call_data)->reason == |
124 (int)XmCR_DRAG); | 121 (int)XmCR_DRAG); |
125 gui_drag_scrollbar(sb, value, dragging); | 122 gui_drag_scrollbar(sb, value, dragging); |
126 } | 123 } |
127 | 124 |
128 | |
129 /* | 125 /* |
130 * End of call-back routines | 126 * End of call-back routines |
131 */ | 127 */ |
128 | |
129 #ifndef LESSTIF_VERSION | |
130 /* | |
131 * Implement three dimensional shading of insensitive labels. | |
132 * By Martin Dalecki. | |
133 */ | |
134 | |
135 #include <Xm/XmP.h> | |
136 #include <Xm/LabelP.h> | |
137 | |
138 static XtExposeProc old_label_expose = NULL; | |
139 | |
140 static void label_expose __ARGS((Widget _w, XEvent *_event, Region _region)); | |
141 | |
142 static void | |
143 label_expose(_w, _event, _region) | |
144 Widget _w; | |
145 XEvent *_event; | |
146 Region _region; | |
147 { | |
148 GC insensitiveGC; | |
149 XmLabelWidget lw = (XmLabelWidget)_w; | |
150 unsigned char label_type = XmSTRING; | |
151 | |
152 XtVaGetValues(_w, XmNlabelType, &label_type, (XtPointer)0); | |
153 | |
154 if (XtIsSensitive(_w) || label_type != XmSTRING) | |
155 (*old_label_expose)(_w, _event, _region); | |
156 else | |
157 { | |
158 XGCValues values; | |
159 XtGCMask mask; | |
160 XtGCMask dynamic; | |
161 XFontStruct *fs; | |
162 | |
163 _XmFontListGetDefaultFont(lw->label.font, &fs); | |
164 | |
165 /* FIXME: we should be doing the whole drawing ourself here. */ | |
166 insensitiveGC = lw->label.insensitive_GC; | |
167 | |
168 mask = GCForeground | GCBackground | GCGraphicsExposures; | |
169 dynamic = GCClipMask | GCClipXOrigin | GCClipYOrigin; | |
170 values.graphics_exposures = False; | |
171 | |
172 if (fs != 0) | |
173 { | |
174 mask |= GCFont; | |
175 values.font = fs->fid; | |
176 } | |
177 | |
178 if (lw->primitive.top_shadow_pixmap != None | |
179 && lw->primitive.top_shadow_pixmap != XmUNSPECIFIED_PIXMAP) | |
180 { | |
181 mask |= GCFillStyle | GCTile; | |
182 values.fill_style = FillTiled; | |
183 values.tile = lw->primitive.top_shadow_pixmap; | |
184 } | |
185 | |
186 lw->label.TextRect.x += 1; | |
187 lw->label.TextRect.y += 1; | |
188 if (lw->label._acc_text != 0) | |
189 { | |
190 lw->label.acc_TextRect.x += 1; | |
191 lw->label.acc_TextRect.y += 1; | |
192 } | |
193 | |
194 values.foreground = lw->primitive.top_shadow_color; | |
195 values.background = lw->core.background_pixel; | |
196 | |
197 lw->label.insensitive_GC = | |
198 XtAllocateGC((Widget) lw, 0, mask, &values, dynamic, 0); | |
199 (*old_label_expose)(_w, _event, _region); | |
200 XtReleaseGC(_w, lw->label.insensitive_GC); | |
201 | |
202 lw->label.TextRect.x -= 1; | |
203 lw->label.TextRect.y -= 1; | |
204 if (lw->label._acc_text != 0) | |
205 { | |
206 lw->label.acc_TextRect.x -= 1; | |
207 lw->label.acc_TextRect.y -= 1; | |
208 } | |
209 | |
210 values.foreground = lw->primitive.bottom_shadow_color; | |
211 values.background = lw->core.background_pixel; | |
212 | |
213 lw->label.insensitive_GC = | |
214 XtAllocateGC((Widget) lw, 0, mask, &values, dynamic, 0); | |
215 (*old_label_expose)(_w, _event, _region); | |
216 XtReleaseGC(_w, lw->label.insensitive_GC); | |
217 | |
218 lw->label.insensitive_GC = insensitiveGC; | |
219 } | |
220 } | |
221 #endif | |
222 | |
132 | 223 |
133 /* | 224 /* |
134 * Create all the motif widgets necessary. | 225 * Create all the motif widgets necessary. |
135 */ | 226 */ |
136 void | 227 void |
137 gui_x11_create_widgets() | 228 gui_x11_create_widgets() |
138 { | 229 { |
230 #ifndef LESSTIF_VERSION | |
231 /* | |
232 * Install the 3D shade effect drawing routines. | |
233 */ | |
234 if (old_label_expose == NULL) | |
235 { | |
236 old_label_expose = xmLabelWidgetClass->core_class.expose; | |
237 xmLabelWidgetClass->core_class.expose = label_expose; | |
238 } | |
239 #endif | |
240 | |
139 /* | 241 /* |
140 * Start out by adding the configured border width into the border offset | 242 * Start out by adding the configured border width into the border offset |
141 */ | 243 */ |
142 gui.border_offset = gui.border_width; | 244 gui.border_offset = gui.border_width; |
143 | 245 |
327 | 429 |
328 /* | 430 /* |
329 * Manage dialog centered on pointer. This could be used by the Athena code as | 431 * Manage dialog centered on pointer. This could be used by the Athena code as |
330 * well. | 432 * well. |
331 */ | 433 */ |
332 static void manage_centered __ARGS((Widget dialog_child)); | 434 void |
333 | |
334 static void | |
335 manage_centered(dialog_child) | 435 manage_centered(dialog_child) |
336 Widget dialog_child; | 436 Widget dialog_child; |
337 { | 437 { |
338 Widget shell = XtParent(dialog_child); | 438 Widget shell = XtParent(dialog_child); |
339 Window root, child; | 439 Window root, child; |
853 /* Set the label here, so that we can switch between icons/text | 953 /* Set the label here, so that we can switch between icons/text |
854 * by changing the XmNlabelType resource. */ | 954 * by changing the XmNlabelType resource. */ |
855 xms = XmStringCreate((char *)menu->dname, STRING_TAG); | 955 xms = XmStringCreate((char *)menu->dname, STRING_TAG); |
856 XtSetArg(args[n], XmNlabelString, xms); n++; | 956 XtSetArg(args[n], XmNlabelString, xms); n++; |
857 | 957 |
858 #ifndef FEAT_SUN_WORKSHOP | |
859 | |
860 /* Without shadows one can't sense whatever the button has been | 958 /* Without shadows one can't sense whatever the button has been |
861 * pressed or not! However we wan't to save a bit of space... | 959 * pressed or not! However we wan't to save a bit of space... |
960 * Need the highlightThickness to see the focus. | |
862 */ | 961 */ |
863 XtSetArg(args[n], XmNhighlightThickness, 0); n++; | 962 XtSetArg(args[n], XmNhighlightThickness, 1); n++; |
864 XtSetArg(args[n], XmNhighlightOnEnter, True); n++; | 963 XtSetArg(args[n], XmNhighlightOnEnter, True); n++; |
865 XtSetArg(args[n], XmNmarginWidth, 0); n++; | 964 XtSetArg(args[n], XmNmarginWidth, 0); n++; |
866 XtSetArg(args[n], XmNmarginHeight, 0); n++; | 965 XtSetArg(args[n], XmNmarginHeight, 0); n++; |
867 #endif | 966 |
868 if (menu->image == 0) | 967 if (menu->image == 0) |
869 { | 968 { |
870 XtSetArg(args[n], XmNlabelType, XmSTRING); n++; | 969 XtSetArg(args[n], XmNlabelType, XmSTRING); n++; |
871 XtSetArg(args[n], XmNlabelPixmap, 0); n++; | 970 XtSetArg(args[n], XmNlabelPixmap, 0); n++; |
872 XtSetArg(args[n], XmNlabelInsensitivePixmap, 0); n++; | 971 XtSetArg(args[n], XmNlabelInsensitivePixmap, 0); n++; |
1382 { | 1481 { |
1383 Arg args[16]; | 1482 Arg args[16]; |
1384 int n; | 1483 int n; |
1385 | 1484 |
1386 n = 0; | 1485 n = 0; |
1387 XtSetArg(args[n], XmNshadowThickness, 1); n++; | |
1388 XtSetArg(args[n], XmNminimum, 0); n++; | 1486 XtSetArg(args[n], XmNminimum, 0); n++; |
1389 XtSetArg(args[n], XmNorientation, | 1487 XtSetArg(args[n], XmNorientation, |
1390 (orient == SBAR_VERT) ? XmVERTICAL : XmHORIZONTAL); n++; | 1488 (orient == SBAR_VERT) ? XmVERTICAL : XmHORIZONTAL); n++; |
1391 | 1489 |
1392 switch (sb->type) | 1490 switch (sb->type) |
1482 gui_x11_get_wid() | 1580 gui_x11_get_wid() |
1483 { | 1581 { |
1484 return(XtWindow(textArea)); | 1582 return(XtWindow(textArea)); |
1485 } | 1583 } |
1486 | 1584 |
1585 /* | |
1586 * Look for a widget in the widget tree w, with a mnemonic matching keycode. | |
1587 * When one is found, simulate a button press on that widget and give it the | |
1588 * keyboard focus. If the mnemonic is on a label, look in the userData field | |
1589 * of the label to see if it points to another widget, and give that the focus. | |
1590 */ | |
1591 static void | |
1592 do_mnemonic(Widget w, unsigned int keycode) | |
1593 { | |
1594 WidgetList children; | |
1595 int numChildren, i; | |
1596 Boolean isMenu; | |
1597 KeySym mnemonic = '\0'; | |
1598 char mneString[2]; | |
1599 Widget userData; | |
1600 unsigned char rowColType; | |
1601 | |
1602 if (XtIsComposite(w)) | |
1603 { | |
1604 if (XtClass(w) == xmRowColumnWidgetClass) | |
1605 { | |
1606 XtVaGetValues(w, XmNrowColumnType, &rowColType, 0); | |
1607 isMenu = (rowColType != (unsigned char)XmWORK_AREA); | |
1608 } | |
1609 else | |
1610 isMenu = False; | |
1611 if (!isMenu) | |
1612 { | |
1613 XtVaGetValues(w, XmNchildren, &children, XmNnumChildren, | |
1614 &numChildren, 0); | |
1615 for (i = 0; i < numChildren; i++) | |
1616 do_mnemonic(children[i], keycode); | |
1617 } | |
1618 } | |
1619 else | |
1620 { | |
1621 XtVaGetValues(w, XmNmnemonic, &mnemonic, 0); | |
1622 if (mnemonic != '\0') | |
1623 { | |
1624 mneString[0] = mnemonic; | |
1625 mneString[1] = '\0'; | |
1626 if (XKeysymToKeycode(XtDisplay(XtParent(w)), | |
1627 XStringToKeysym(mneString)) == keycode) | |
1628 { | |
1629 if (XtClass(w) == xmLabelWidgetClass | |
1630 || XtClass(w) == xmLabelGadgetClass) | |
1631 { | |
1632 XtVaGetValues(w, XmNuserData, &userData, 0); | |
1633 if (userData != NULL && XtIsWidget(userData)) | |
1634 XmProcessTraversal(userData, XmTRAVERSE_CURRENT); | |
1635 } | |
1636 else | |
1637 { | |
1638 XKeyPressedEvent keyEvent; | |
1639 | |
1640 XmProcessTraversal(w, XmTRAVERSE_CURRENT); | |
1641 | |
1642 memset((char *) &keyEvent, 0, sizeof(XKeyPressedEvent)); | |
1643 keyEvent.type = KeyPress; | |
1644 keyEvent.serial = 1; | |
1645 keyEvent.send_event = True; | |
1646 keyEvent.display = XtDisplay(w); | |
1647 keyEvent.window = XtWindow(w); | |
1648 XtCallActionProc(w, "Activate", (XEvent *) & keyEvent, | |
1649 NULL, 0); | |
1650 } | |
1651 } | |
1652 } | |
1653 } | |
1654 } | |
1655 | |
1656 /* | |
1657 * Callback routine for dialog mnemonic processing. | |
1658 */ | |
1659 /*ARGSUSED*/ | |
1660 static void | |
1661 mnemonic_event(Widget w, XtPointer call_data, XKeyEvent *event) | |
1662 { | |
1663 do_mnemonic(w, event->keycode); | |
1664 } | |
1665 | |
1666 | |
1667 /* | |
1668 * Search the widget tree under w for widgets with mnemonics. When found, add | |
1669 * a passive grab to the dialog widget for the mnemonic character, thus | |
1670 * directing mnemonic events to the dialog widget. | |
1671 */ | |
1672 static void | |
1673 add_mnemonic_grabs(Widget dialog, Widget w) | |
1674 { | |
1675 char mneString[2]; | |
1676 WidgetList children; | |
1677 int numChildren, i; | |
1678 Boolean isMenu; | |
1679 KeySym mnemonic = '\0'; | |
1680 unsigned char rowColType; | |
1681 | |
1682 if (XtIsComposite(w)) | |
1683 { | |
1684 if (XtClass(w) == xmRowColumnWidgetClass) | |
1685 { | |
1686 XtVaGetValues(w, XmNrowColumnType, &rowColType, 0); | |
1687 isMenu = (rowColType != (unsigned char)XmWORK_AREA); | |
1688 } | |
1689 else | |
1690 isMenu = False; | |
1691 if (!isMenu) | |
1692 { | |
1693 XtVaGetValues(w, XmNchildren, &children, XmNnumChildren, | |
1694 &numChildren, 0); | |
1695 for (i = 0; i < numChildren; i++) | |
1696 add_mnemonic_grabs(dialog, children[i]); | |
1697 } | |
1698 } | |
1699 else | |
1700 { | |
1701 XtVaGetValues(w, XmNmnemonic, &mnemonic, 0); | |
1702 if (mnemonic != '\0') | |
1703 { | |
1704 mneString[0] = mnemonic; | |
1705 mneString[1] = '\0'; | |
1706 XtGrabKey(dialog, XKeysymToKeycode(XtDisplay(dialog), | |
1707 XStringToKeysym(mneString)), | |
1708 Mod1Mask, True, GrabModeAsync, GrabModeAsync); | |
1709 } | |
1710 } | |
1711 } | |
1712 | |
1713 /* | |
1714 * Add a handler for mnemonics in a dialog. Motif itself only handles | |
1715 * mnemonics in menus. Mnemonics added or changed after this call will be | |
1716 * ignored. | |
1717 * | |
1718 * To add a mnemonic to a text field or list, set the XmNmnemonic resource on | |
1719 * the appropriate label and set the XmNuserData resource of the label to the | |
1720 * widget to get the focus when the mnemonic is typed. | |
1721 */ | |
1722 static void | |
1723 activate_dialog_mnemonics(Widget dialog) | |
1724 { | |
1725 if (!dialog) | |
1726 return; | |
1727 | |
1728 XtAddEventHandler(dialog, KeyPressMask, False, | |
1729 (XtEventHandler) mnemonic_event, (XtPointer) NULL); | |
1730 add_mnemonic_grabs(dialog, dialog); | |
1731 } | |
1732 | |
1733 /* | |
1734 * Removes the event handler and key-grabs for dialog mnemonic handling. | |
1735 */ | |
1736 static void | |
1737 suppress_dialog_mnemonics(Widget dialog) | |
1738 { | |
1739 if (!dialog) | |
1740 return; | |
1741 | |
1742 XtUngrabKey(dialog, AnyKey, Mod1Mask); | |
1743 XtRemoveEventHandler(dialog, KeyPressMask, False, | |
1744 (XtEventHandler) mnemonic_event, (XtPointer) NULL); | |
1745 } | |
1746 | |
1747 #if defined(FEAT_BROWSE) || defined(FEAT_GUI_DIALOG) | |
1748 static void set_fontlist __ARGS((Widget wg)); | |
1749 | |
1750 /* | |
1751 * Use the 'guifont' or 'guifontset' as a fontlist for a dialog widget. | |
1752 */ | |
1753 static void | |
1754 set_fontlist(id) | |
1755 Widget id; | |
1756 { | |
1757 XmFontList fl; | |
1758 | |
1759 #ifdef FONTSET_ALWAYS | |
1760 if (gui.fontset != NOFONTSET) { | |
1761 fl = gui_motif_fontset2fontlist((XFontSet *)&gui.fontset); | |
1762 if (fl != NULL) | |
1763 { | |
1764 if (XtIsManaged(id)) | |
1765 { | |
1766 XtUnmanageChild(id); | |
1767 XtVaSetValues(id, XmNfontList, fl, NULL); | |
1768 /* We should force the widget to recalculate it's | |
1769 * geometry now. */ | |
1770 XtManageChild(id); | |
1771 } | |
1772 else | |
1773 XtVaSetValues(id, XmNfontList, fl, NULL); | |
1774 XmFontListFree(fl); | |
1775 } | |
1776 } | |
1777 #else | |
1778 if (gui.norm_font != NOFONT) { | |
1779 fl = gui_motif_create_fontlist((XFontStruct *)gui.norm_font); | |
1780 if (fl != NULL) | |
1781 { | |
1782 if (XtIsManaged(id)) | |
1783 { | |
1784 XtUnmanageChild(id); | |
1785 XtVaSetValues(id, XmNfontList, fl, NULL); | |
1786 /* We should force the widget to recalculate it's | |
1787 * geometry now. */ | |
1788 XtManageChild(id); | |
1789 } | |
1790 else | |
1791 XtVaSetValues(id, XmNfontList, fl, NULL); | |
1792 XmFontListFree(fl); | |
1793 } | |
1794 } | |
1795 #endif | |
1796 } | |
1797 #endif | |
1487 | 1798 |
1488 #if defined(FEAT_BROWSE) || defined(PROTO) | 1799 #if defined(FEAT_BROWSE) || defined(PROTO) |
1489 | 1800 |
1490 /* | 1801 /* |
1491 * file selector related stuff | 1802 * file selector related stuff |
1515 * - usage of gettext for translation, as in all the other places. | 1826 * - usage of gettext for translation, as in all the other places. |
1516 * | 1827 * |
1517 * - equalize the messages between different GUI implementations as far as | 1828 * - equalize the messages between different GUI implementations as far as |
1518 * possible. | 1829 * possible. |
1519 */ | 1830 */ |
1520 static void set_predefined_label __ARGS((Widget parent, String name, char * new_label)); | 1831 static void set_predefined_label __ARGS((Widget parent, String name, char *new_label)); |
1521 | 1832 |
1522 static void | 1833 static void |
1523 set_predefined_label(parent, name, new_label) | 1834 set_predefined_label(parent, name, new_label) |
1835 Widget parent; | |
1836 String name; | |
1837 char *new_label; | |
1838 { | |
1839 XmString str; | |
1840 Widget w; | |
1841 char_u *p, *next; | |
1842 KeySym mnemonic = NUL; | |
1843 | |
1844 w = XtNameToWidget(parent, name); | |
1845 | |
1846 if (!w) | |
1847 return; | |
1848 | |
1849 p = vim_strsave((char_u *)new_label); | |
1850 if (p == NULL) | |
1851 return; | |
1852 for (next = p; *next; ++next) | |
1853 { | |
1854 if (*next == DLG_HOTKEY_CHAR) | |
1855 { | |
1856 int len = STRLEN(next); | |
1857 | |
1858 if (len > 0) | |
1859 { | |
1860 mch_memmove(next, next + 1, len); | |
1861 mnemonic = next[0]; | |
1862 } | |
1863 } | |
1864 } | |
1865 | |
1866 str = XmStringCreate((char *)p, STRING_TAG); | |
1867 vim_free(p); | |
1868 | |
1869 if (str != NULL) | |
1870 { | |
1871 XtVaSetValues(w, | |
1872 XmNlabelString, str, | |
1873 XmNmnemonic, mnemonic, | |
1874 NULL); | |
1875 XmStringFree(str); | |
1876 } | |
1877 gui_motif_menu_fontlist(w); | |
1878 } | |
1879 | |
1880 static void | |
1881 set_predefined_fontlist(parent, name) | |
1524 Widget parent; | 1882 Widget parent; |
1525 String name; | 1883 String name; |
1526 char * new_label; | 1884 { |
1527 { | |
1528 XmString str; | |
1529 Widget w; | 1885 Widget w; |
1530 | |
1531 w = XtNameToWidget(parent, name); | 1886 w = XtNameToWidget(parent, name); |
1532 | 1887 |
1533 if (!w) | 1888 if (!w) |
1534 return; | 1889 return; |
1535 | 1890 |
1536 str = XmStringCreate(new_label, STRING_TAG); | 1891 set_fontlist(w); |
1537 | |
1538 if (str) | |
1539 { | |
1540 XtVaSetValues(w, XmNlabelString, str, NULL); | |
1541 XmStringFree(str); | |
1542 } | |
1543 } | 1892 } |
1544 | 1893 |
1545 /* | 1894 /* |
1546 * Put up a file requester. | 1895 * Put up a file requester. |
1547 * Returns the selected name in allocated memory, or NULL for Cancel. | 1896 * Returns the selected name in allocated memory, or NULL for Cancel. |
1559 char_u dirbuf[MAXPATHL]; | 1908 char_u dirbuf[MAXPATHL]; |
1560 char_u dfltbuf[MAXPATHL]; | 1909 char_u dfltbuf[MAXPATHL]; |
1561 char_u *pattern; | 1910 char_u *pattern; |
1562 char_u *tofree = NULL; | 1911 char_u *tofree = NULL; |
1563 | 1912 |
1564 dialog_wgt = XmCreateFileSelectionDialog(vimShell, (char *)title, NULL, 0); | 1913 /* There a difference between the resource name and value, Therefore, we |
1914 * avoid to (ab-)use the (maybe internationalized!) dialog title as a | |
1915 * dialog name. | |
1916 */ | |
1917 | |
1918 dialog_wgt = XmCreateFileSelectionDialog(vimShell, "browseDialog", NULL, 0); | |
1565 | 1919 |
1566 if (initdir == NULL || *initdir == NUL) | 1920 if (initdir == NULL || *initdir == NUL) |
1567 { | 1921 { |
1568 mch_dirname(dirbuf, MAXPATHL); | 1922 mch_dirname(dirbuf, MAXPATHL); |
1569 initdir = dirbuf; | 1923 initdir = dirbuf; |
1612 XmNpattern, XmRString, (char *)pattern, STRLEN(pattern) + 1, | 1966 XmNpattern, XmRString, (char *)pattern, STRLEN(pattern) + 1, |
1613 XtVaTypedArg, | 1967 XtVaTypedArg, |
1614 XmNdialogTitle, XmRString, (char *)title, STRLEN(title) + 1, | 1968 XmNdialogTitle, XmRString, (char *)title, STRLEN(title) + 1, |
1615 NULL); | 1969 NULL); |
1616 | 1970 |
1617 set_predefined_label(dialog_wgt, "Apply", _("Filter")); | 1971 set_predefined_label(dialog_wgt, "Apply", _("&Filter")); |
1618 set_predefined_label(dialog_wgt, "Cancel", _("Cancel")); | 1972 set_predefined_label(dialog_wgt, "Cancel", _("&Cancel")); |
1619 set_predefined_label(dialog_wgt, "Dir", _("Directories")); | 1973 set_predefined_label(dialog_wgt, "Dir", _("Directories")); |
1620 set_predefined_label(dialog_wgt, "FilterLabel", _("Filter")); | 1974 set_predefined_label(dialog_wgt, "FilterLabel", _("Filter")); |
1621 set_predefined_label(dialog_wgt, "Help", _("Help")); | 1975 set_predefined_label(dialog_wgt, "Help", _("&Help")); |
1622 set_predefined_label(dialog_wgt, "Items", _("Files")); | 1976 set_predefined_label(dialog_wgt, "Items", _("Files")); |
1623 set_predefined_label(dialog_wgt, "OK", _("OK")); | 1977 set_predefined_label(dialog_wgt, "OK", _("&OK")); |
1624 set_predefined_label(dialog_wgt, "Selection", _("Selection")); | 1978 set_predefined_label(dialog_wgt, "Selection", _("Selection")); |
1979 | |
1980 /* This is to save us from silly external settings using not fixed with | |
1981 * fonts for file selection. | |
1982 */ | |
1983 set_predefined_fontlist(dialog_wgt, "DirListSW.DirList"); | |
1984 set_predefined_fontlist(dialog_wgt, "ItemsListSW.ItemsList"); | |
1625 | 1985 |
1626 gui_motif_menu_colors(dialog_wgt); | 1986 gui_motif_menu_colors(dialog_wgt); |
1627 if (gui.scroll_bg_pixel != INVALCOLOR) | 1987 if (gui.scroll_bg_pixel != INVALCOLOR) |
1628 XtVaSetValues(dialog_wgt, XmNtroughColor, gui.scroll_bg_pixel, NULL); | 1988 XtVaSetValues(dialog_wgt, XmNtroughColor, gui.scroll_bg_pixel, NULL); |
1629 | 1989 |
1632 /* We have no help in this window, so hide help button */ | 1992 /* We have no help in this window, so hide help button */ |
1633 XtUnmanageChild(XmFileSelectionBoxGetChild(dialog_wgt, | 1993 XtUnmanageChild(XmFileSelectionBoxGetChild(dialog_wgt, |
1634 (unsigned char)XmDIALOG_HELP_BUTTON)); | 1994 (unsigned char)XmDIALOG_HELP_BUTTON)); |
1635 | 1995 |
1636 manage_centered(dialog_wgt); | 1996 manage_centered(dialog_wgt); |
1997 activate_dialog_mnemonics(dialog_wgt); | |
1637 | 1998 |
1638 /* sit in a loop until the dialog box has gone away */ | 1999 /* sit in a loop until the dialog box has gone away */ |
1639 do | 2000 do |
1640 { | 2001 { |
1641 XtAppProcessEvent(XtWidgetToApplicationContext(dialog_wgt), | 2002 XtAppProcessEvent(XtWidgetToApplicationContext(dialog_wgt), |
1642 (XtInputMask)XtIMAll); | 2003 (XtInputMask)XtIMAll); |
1643 } while (XtIsManaged(dialog_wgt)); | 2004 } while (XtIsManaged(dialog_wgt)); |
1644 | 2005 |
2006 suppress_dialog_mnemonics(dialog_wgt); | |
1645 XtDestroyWidget(dialog_wgt); | 2007 XtDestroyWidget(dialog_wgt); |
1646 vim_free(tofree); | 2008 vim_free(tofree); |
1647 | 2009 |
1648 if (browse_fname == NULL) | 2010 if (browse_fname == NULL) |
1649 return NULL; | 2011 return NULL; |
1742 Widget w; | 2104 Widget w; |
1743 XtPointer client_data; | 2105 XtPointer client_data; |
1744 XtPointer call_data; | 2106 XtPointer call_data; |
1745 { | 2107 { |
1746 dialogStatus = (int)(long)client_data + 1; | 2108 dialogStatus = (int)(long)client_data + 1; |
1747 } | |
1748 | |
1749 static void gui_motif_set_fontlist __ARGS((Widget wg)); | |
1750 | |
1751 /* | |
1752 * Use the 'guifont' or 'guifontset' as a fontlist for a dialog widget. | |
1753 */ | |
1754 static void | |
1755 gui_motif_set_fontlist(wg) | |
1756 Widget wg; | |
1757 { | |
1758 XmFontList fl; | |
1759 | |
1760 fl = | |
1761 #ifdef FEAT_XFONTSET | |
1762 gui.fontset != NOFONTSET ? | |
1763 gui_motif_fontset2fontlist((XFontSet *)&gui.fontset) | |
1764 : | |
1765 #endif | |
1766 gui_motif_create_fontlist((XFontStruct *)gui.norm_font); | |
1767 if (fl != NULL) | |
1768 { | |
1769 XtVaSetValues(wg, XmNfontList, fl, NULL); | |
1770 XmFontListFree(fl); | |
1771 } | |
1772 } | 2109 } |
1773 | 2110 |
1774 #ifdef HAVE_XPM | 2111 #ifdef HAVE_XPM |
1775 | 2112 |
1776 static Widget create_pixmap_label(Widget parent, String name, char **data, ArgList args, Cardinal arg); | 2113 static Widget create_pixmap_label(Widget parent, String name, char **data, ArgList args, Cardinal arg); |
1851 char_u *buts; | 2188 char_u *buts; |
1852 char_u *p, *next; | 2189 char_u *p, *next; |
1853 XtAppContext app; | 2190 XtAppContext app; |
1854 XmString label; | 2191 XmString label; |
1855 int butcount; | 2192 int butcount; |
2193 Widget w; | |
1856 Widget dialogform = NULL; | 2194 Widget dialogform = NULL; |
1857 Widget form = NULL; | 2195 Widget form = NULL; |
1858 Widget dialogtextfield = NULL; | 2196 Widget dialogtextfield = NULL; |
1859 Widget *buttons; | 2197 Widget *buttons; |
1860 Widget sep_form = NULL; | 2198 Widget sep_form = NULL; |
1911 */ | 2249 */ |
1912 sep_form = (Widget) 0; | 2250 sep_form = (Widget) 0; |
1913 p = buts; | 2251 p = buts; |
1914 for (butcount = 0; *p; ++butcount) | 2252 for (butcount = 0; *p; ++butcount) |
1915 { | 2253 { |
2254 KeySym mnemonic = NUL; | |
2255 | |
1916 for (next = p; *next; ++next) | 2256 for (next = p; *next; ++next) |
1917 { | 2257 { |
1918 if (*next == DLG_HOTKEY_CHAR) | 2258 if (*next == DLG_HOTKEY_CHAR) |
1919 mch_memmove(next, next + 1, STRLEN(next)); | 2259 { |
2260 int len = STRLEN(next); | |
2261 | |
2262 if (len > 0) | |
2263 { | |
2264 mch_memmove(next, next + 1, len); | |
2265 mnemonic = next[0]; | |
2266 } | |
2267 } | |
1920 if (*next == DLG_BUTTON_SEP) | 2268 if (*next == DLG_BUTTON_SEP) |
1921 { | 2269 { |
1922 *next++ = NUL; | 2270 *next++ = NUL; |
1923 break; | 2271 break; |
1924 } | 2272 } |
1928 break; | 2276 break; |
1929 | 2277 |
1930 buttons[butcount] = XtVaCreateManagedWidget("button", | 2278 buttons[butcount] = XtVaCreateManagedWidget("button", |
1931 xmPushButtonWidgetClass, dialogform, | 2279 xmPushButtonWidgetClass, dialogform, |
1932 XmNlabelString, label, | 2280 XmNlabelString, label, |
2281 XmNmnemonic, mnemonic, | |
1933 XmNbottomAttachment, XmATTACH_FORM, | 2282 XmNbottomAttachment, XmATTACH_FORM, |
1934 XmNbottomOffset, 4, | 2283 XmNbottomOffset, 4, |
1935 XmNshowAsDefault, butcount == dfltbutton - 1, | 2284 XmNshowAsDefault, butcount == dfltbutton - 1, |
1936 XmNdefaultButtonShadowThickness, 1, | 2285 XmNdefaultButtonShadowThickness, 1, |
1937 NULL); | 2286 NULL); |
1938 XmStringFree(label); | 2287 XmStringFree(label); |
2288 gui_motif_menu_fontlist(buttons[butcount]); | |
1939 | 2289 |
1940 /* Layout properly. */ | 2290 /* Layout properly. */ |
1941 | 2291 |
1942 if (butcount > 0) | 2292 if (butcount > 0) |
1943 { | 2293 { |
2039 else | 2389 else |
2040 XtVaSetValues(dialogtextfield, | 2390 XtVaSetValues(dialogtextfield, |
2041 XmNbottomAttachment, XmATTACH_FORM, | 2391 XmNbottomAttachment, XmATTACH_FORM, |
2042 NULL); | 2392 NULL); |
2043 | 2393 |
2044 gui_motif_set_fontlist(dialogtextfield); | 2394 set_fontlist(dialogtextfield); |
2045 XmTextFieldSetString(dialogtextfield, (char *)textfield); | 2395 XmTextFieldSetString(dialogtextfield, (char *)textfield); |
2046 XtManageChild(dialogtextfield); | 2396 XtManageChild(dialogtextfield); |
2047 XtAddEventHandler(dialogtextfield, KeyPressMask, False, | 2397 XtAddEventHandler(dialogtextfield, KeyPressMask, False, |
2048 (XtEventHandler)keyhit_callback, (XtPointer)NULL); | 2398 (XtEventHandler)keyhit_callback, (XtPointer)NULL); |
2049 } | 2399 } |
2091 dialogpixmap = create_pixmap_label(form, "dialogPixmap", | 2441 dialogpixmap = create_pixmap_label(form, "dialogPixmap", |
2092 icon_data, args, n); | 2442 icon_data, args, n); |
2093 XtManageChild(dialogpixmap); | 2443 XtManageChild(dialogpixmap); |
2094 #endif | 2444 #endif |
2095 | 2445 |
2096 /* Create the dialog message. */ | 2446 /* Create the dialog message. |
2097 label = XmStringLtoRCreate((char *)message, STRING_TAG); | 2447 * Since LessTif is apparently having problems with the creation of |
2448 * properly localized string, we use LtoR here. The symptom is that the | |
2449 * string sill not show properly in multiple lines as it does in native | |
2450 * Motif. | |
2451 */ | |
2452 label = XmStringCreateLtoR((char *)message, STRING_TAG); | |
2098 if (label == NULL) | 2453 if (label == NULL) |
2099 return -1; | 2454 return -1; |
2100 (void)XtVaCreateManagedWidget("dialogMessage", | 2455 w = XtVaCreateManagedWidget("dialogMessage", |
2101 xmLabelGadgetClass, form, | 2456 xmLabelGadgetClass, form, |
2102 XmNlabelString, label, | 2457 XmNlabelString, label, |
2458 XmNalignment, XmALIGNMENT_BEGINNING, | |
2103 XmNtopAttachment, XmATTACH_FORM, | 2459 XmNtopAttachment, XmATTACH_FORM, |
2104 XmNtopOffset, 8, | 2460 XmNtopOffset, 8, |
2105 #ifdef HAVE_XPM | 2461 #ifdef HAVE_XPM |
2106 XmNleftAttachment, XmATTACH_WIDGET, | 2462 XmNleftAttachment, XmATTACH_WIDGET, |
2107 XmNleftWidget, dialogpixmap, | 2463 XmNleftWidget, dialogpixmap, |
2113 XmNrightOffset, 8, | 2469 XmNrightOffset, 8, |
2114 XmNbottomAttachment, XmATTACH_FORM, | 2470 XmNbottomAttachment, XmATTACH_FORM, |
2115 XmNbottomOffset, 8, | 2471 XmNbottomOffset, 8, |
2116 NULL); | 2472 NULL); |
2117 XmStringFree(label); | 2473 XmStringFree(label); |
2474 set_fontlist(w); | |
2118 | 2475 |
2119 if (textfield != NULL) | 2476 if (textfield != NULL) |
2120 { | 2477 { |
2121 XtVaSetValues(form, | 2478 XtVaSetValues(form, |
2122 XmNbottomAttachment, XmATTACH_WIDGET, | 2479 XmNbottomAttachment, XmATTACH_WIDGET, |
2147 else | 2504 else |
2148 XtVaSetValues(dialogform, XmNinitialFocus, buttons[dfltbutton - 1], | 2505 XtVaSetValues(dialogform, XmNinitialFocus, buttons[dfltbutton - 1], |
2149 NULL); | 2506 NULL); |
2150 | 2507 |
2151 manage_centered(dialogform); | 2508 manage_centered(dialogform); |
2509 activate_dialog_mnemonics(dialogform); | |
2152 | 2510 |
2153 if (textfield != NULL && *textfield != NUL) | 2511 if (textfield != NULL && *textfield != NUL) |
2154 { | 2512 { |
2155 /* This only works after the textfield has been realised. */ | 2513 /* This only works after the textfield has been realised. */ |
2156 XmTextFieldSetSelection(dialogtextfield, | 2514 XmTextFieldSetSelection(dialogtextfield, |
2183 STRNCPY(textfield, p, IOSIZE); | 2541 STRNCPY(textfield, p, IOSIZE); |
2184 textfield[IOSIZE - 1] = NUL; | 2542 textfield[IOSIZE - 1] = NUL; |
2185 } | 2543 } |
2186 } | 2544 } |
2187 | 2545 |
2546 suppress_dialog_mnemonics(dialogform); | |
2188 XtDestroyWidget(dialogform); | 2547 XtDestroyWidget(dialogform); |
2189 | 2548 |
2190 return dialogStatus; | 2549 return dialogStatus; |
2191 } | 2550 } |
2192 #endif /* FEAT_GUI_DIALOG */ | 2551 #endif /* FEAT_GUI_DIALOG */ |
2244 char_u *s; | 2603 char_u *s; |
2245 { | 2604 { |
2246 XmString xms; | 2605 XmString xms; |
2247 | 2606 |
2248 xms = XmStringCreate((char *)s, STRING_TAG); | 2607 xms = XmStringCreate((char *)s, STRING_TAG); |
2249 XtVaSetValues(footer, XmNlabelString, xms, NULL); | 2608 if (xms != NULL) |
2250 XmStringFree(xms); | 2609 { |
2610 XtVaSetValues(footer, XmNlabelString, xms, NULL); | |
2611 XmStringFree(xms); | |
2612 } | |
2251 } | 2613 } |
2252 | 2614 |
2253 #endif | 2615 #endif |
2254 | 2616 |
2255 | 2617 |
2520 #endif | 2882 #endif |
2521 if (gui.scroll_fg_pixel != INVALCOLOR) | 2883 if (gui.scroll_fg_pixel != INVALCOLOR) |
2522 XtVaSetValues(id, XmNforeground, gui.scroll_fg_pixel, NULL); | 2884 XtVaSetValues(id, XmNforeground, gui.scroll_fg_pixel, NULL); |
2523 } | 2885 } |
2524 | 2886 |
2525 #ifdef FEAT_MENU | |
2526 /* | 2887 /* |
2527 * Set the fontlist for Widget "id" to use gui.menu_fontset or gui.menu_font. | 2888 * Set the fontlist for Widget "id" to use gui.menu_fontset or gui.menu_font. |
2528 */ | 2889 */ |
2529 static void | 2890 /*ARGSUSED*/ |
2891 void | |
2530 gui_motif_menu_fontlist(id) | 2892 gui_motif_menu_fontlist(id) |
2531 Widget id; | 2893 Widget id; |
2532 { | 2894 { |
2895 #ifdef FEAT_MENU | |
2533 #ifdef FONTSET_ALWAYS | 2896 #ifdef FONTSET_ALWAYS |
2534 if (gui.menu_fontset != NOFONTSET) | 2897 if (gui.menu_fontset != NOFONTSET) |
2535 { | 2898 { |
2536 XmFontList fl; | 2899 XmFontList fl; |
2537 | 2900 |
2571 XtVaSetValues(id, XmNfontList, fl, NULL); | 2934 XtVaSetValues(id, XmNfontList, fl, NULL); |
2572 XmFontListFree(fl); | 2935 XmFontListFree(fl); |
2573 } | 2936 } |
2574 } | 2937 } |
2575 #endif | 2938 #endif |
2576 } | 2939 #endif |
2577 | 2940 } |
2578 #endif | 2941 |
2579 | 2942 |
2580 /* | 2943 /* |
2581 * We don't create it twice for the sake of speed. | 2944 * We don't create it twice for the sake of speed. |
2582 */ | 2945 */ |
2583 | 2946 |
2615 XtPointer client_data; | 2978 XtPointer client_data; |
2616 XtPointer call_data; | 2979 XtPointer call_data; |
2617 { | 2980 { |
2618 SharedFindReplace *cd = (SharedFindReplace *)client_data; | 2981 SharedFindReplace *cd = (SharedFindReplace *)client_data; |
2619 | 2982 |
2620 if (cd != NULL) | 2983 if (cd != NULL) { |
2984 /* suppress_dialog_mnemonics(cd->dialog); */ | |
2621 cd->dialog = (Widget)0; | 2985 cd->dialog = (Widget)0; |
2986 } | |
2622 } | 2987 } |
2623 | 2988 |
2624 /*ARGSUSED*/ | 2989 /*ARGSUSED*/ |
2625 static void | 2990 static void |
2626 find_replace_dismiss_callback(w, client_data, call_data) | 2991 find_replace_dismiss_callback(w, client_data, call_data) |
2714 keysym = XLookupKeysym(event, 0); | 3079 keysym = XLookupKeysym(event, 0); |
2715 | 3080 |
2716 /* the scape key pops the whole dialog down */ | 3081 /* the scape key pops the whole dialog down */ |
2717 if (keysym == XK_Escape) | 3082 if (keysym == XK_Escape) |
2718 XtUnmanageChild(frdp->dialog); | 3083 XtUnmanageChild(frdp->dialog); |
3084 } | |
3085 | |
3086 static void | |
3087 set_label(w, label) | |
3088 Widget w; | |
3089 char_u *label; | |
3090 { | |
3091 XmString str; | |
3092 char_u *p, *next; | |
3093 KeySym mnemonic = NUL; | |
3094 | |
3095 if (!w) | |
3096 return; | |
3097 | |
3098 p = vim_strsave(label); | |
3099 if (p == NULL) | |
3100 return; | |
3101 for (next = p; *next; ++next) | |
3102 { | |
3103 if (*next == DLG_HOTKEY_CHAR) | |
3104 { | |
3105 int len = STRLEN(next); | |
3106 | |
3107 if (len > 0) | |
3108 { | |
3109 mch_memmove(next, next + 1, len); | |
3110 mnemonic = next[0]; | |
3111 } | |
3112 } | |
3113 } | |
3114 | |
3115 str = XmStringCreateSimple((char *)p); | |
3116 vim_free(p); | |
3117 if (str) | |
3118 { | |
3119 XtVaSetValues(w, | |
3120 XmNlabelString, str, | |
3121 XmNmnemonic, mnemonic, | |
3122 NULL); | |
3123 XmStringFree(str); | |
3124 } | |
3125 gui_motif_menu_fontlist(w); | |
2719 } | 3126 } |
2720 | 3127 |
2721 static void | 3128 static void |
2722 find_replace_dialog_create(arg, do_replace) | 3129 find_replace_dialog_create(arg, do_replace) |
2723 char_u *arg; | 3130 char_u *arg; |
2744 entry_text = get_find_dialog_text(arg, &wword, &mcase); | 3151 entry_text = get_find_dialog_text(arg, &wword, &mcase); |
2745 | 3152 |
2746 /* If the dialog already exists, just raise it. */ | 3153 /* If the dialog already exists, just raise it. */ |
2747 if (frdp->dialog) | 3154 if (frdp->dialog) |
2748 { | 3155 { |
3156 gui_motif_synch_fonts(); | |
3157 | |
2749 /* If the window is already up, just pop it to the top */ | 3158 /* If the window is already up, just pop it to the top */ |
2750 if (XtIsManaged(frdp->dialog)) | 3159 if (XtIsManaged(frdp->dialog)) |
2751 XMapRaised(XtDisplay(frdp->dialog), | 3160 XMapRaised(XtDisplay(frdp->dialog), |
2752 XtWindow(XtParent(frdp->dialog))); | 3161 XtWindow(XtParent(frdp->dialog))); |
2753 else | 3162 else |
2787 XmNtopOffset, 4, | 3196 XmNtopOffset, 4, |
2788 XmNbottomAttachment, XmATTACH_FORM, | 3197 XmNbottomAttachment, XmATTACH_FORM, |
2789 XmNbottomOffset, 4, | 3198 XmNbottomOffset, 4, |
2790 NULL); | 3199 NULL); |
2791 | 3200 |
2792 str = XmStringCreateSimple(_("Find Next")); | |
2793 frdp->find = XtVaCreateManagedWidget("findButton", | 3201 frdp->find = XtVaCreateManagedWidget("findButton", |
2794 xmPushButtonWidgetClass, button_form, | 3202 xmPushButtonWidgetClass, button_form, |
2795 XmNlabelString, str, | |
2796 XmNsensitive, True, | 3203 XmNsensitive, True, |
2797 XmNtopAttachment, XmATTACH_FORM, | 3204 XmNtopAttachment, XmATTACH_FORM, |
2798 XmNleftAttachment, XmATTACH_FORM, | 3205 XmNleftAttachment, XmATTACH_FORM, |
2799 XmNrightAttachment, XmATTACH_FORM, | 3206 XmNrightAttachment, XmATTACH_FORM, |
2800 NULL); | 3207 NULL); |
2801 XmStringFree(str); | 3208 set_label(frdp->find, _("Find &Next")); |
2802 | 3209 |
2803 XtAddCallback(frdp->find, XmNactivateCallback, | 3210 XtAddCallback(frdp->find, XmNactivateCallback, |
2804 find_replace_callback, | 3211 find_replace_callback, |
2805 (XtPointer) (do_replace ? FRD_R_FINDNEXT : FRD_FINDNEXT)); | 3212 (XtPointer) (do_replace ? FRD_R_FINDNEXT : FRD_FINDNEXT)); |
2806 | 3213 |
2807 if (do_replace) | 3214 if (do_replace) |
2808 { | 3215 { |
2809 str = XmStringCreateSimple(_("Replace")); | |
2810 frdp->replace = XtVaCreateManagedWidget("replaceButton", | 3216 frdp->replace = XtVaCreateManagedWidget("replaceButton", |
2811 xmPushButtonWidgetClass, button_form, | 3217 xmPushButtonWidgetClass, button_form, |
2812 XmNlabelString, str, | |
2813 XmNtopAttachment, XmATTACH_WIDGET, | 3218 XmNtopAttachment, XmATTACH_WIDGET, |
2814 XmNtopWidget, frdp->find, | 3219 XmNtopWidget, frdp->find, |
2815 XmNleftAttachment, XmATTACH_FORM, | 3220 XmNleftAttachment, XmATTACH_FORM, |
2816 XmNrightAttachment, XmATTACH_FORM, | 3221 XmNrightAttachment, XmATTACH_FORM, |
2817 NULL); | 3222 NULL); |
2818 XmStringFree(str); | 3223 set_label(frdp->replace, _("&Replace")); |
2819 XtAddCallback(frdp->replace, XmNactivateCallback, | 3224 XtAddCallback(frdp->replace, XmNactivateCallback, |
2820 find_replace_callback, (XtPointer)FRD_REPLACE); | 3225 find_replace_callback, (XtPointer)FRD_REPLACE); |
2821 | 3226 |
2822 str = XmStringCreateSimple(_("Replace All")); | |
2823 frdp->all = XtVaCreateManagedWidget("replaceAllButton", | 3227 frdp->all = XtVaCreateManagedWidget("replaceAllButton", |
2824 xmPushButtonWidgetClass, button_form, | 3228 xmPushButtonWidgetClass, button_form, |
2825 XmNlabelString, str, | |
2826 XmNtopAttachment, XmATTACH_WIDGET, | 3229 XmNtopAttachment, XmATTACH_WIDGET, |
2827 XmNtopWidget, frdp->replace, | 3230 XmNtopWidget, frdp->replace, |
2828 XmNleftAttachment, XmATTACH_FORM, | 3231 XmNleftAttachment, XmATTACH_FORM, |
2829 XmNrightAttachment, XmATTACH_FORM, | 3232 XmNrightAttachment, XmATTACH_FORM, |
2830 NULL); | 3233 NULL); |
2831 XmStringFree(str); | 3234 set_label(frdp->all, _("Replace &All")); |
2832 XtAddCallback(frdp->all, XmNactivateCallback, | 3235 XtAddCallback(frdp->all, XmNactivateCallback, |
2833 find_replace_callback, (XtPointer)FRD_REPLACEALL); | 3236 find_replace_callback, (XtPointer)FRD_REPLACEALL); |
2834 | 3237 |
2835 str = XmStringCreateSimple(_("Undo")); | |
2836 frdp->undo = XtVaCreateManagedWidget("undoButton", | 3238 frdp->undo = XtVaCreateManagedWidget("undoButton", |
2837 xmPushButtonWidgetClass, button_form, | 3239 xmPushButtonWidgetClass, button_form, |
2838 XmNlabelString, str, | |
2839 XmNtopAttachment, XmATTACH_WIDGET, | 3240 XmNtopAttachment, XmATTACH_WIDGET, |
2840 XmNtopWidget, frdp->all, | 3241 XmNtopWidget, frdp->all, |
2841 XmNleftAttachment, XmATTACH_FORM, | 3242 XmNleftAttachment, XmATTACH_FORM, |
2842 XmNrightAttachment, XmATTACH_FORM, | 3243 XmNrightAttachment, XmATTACH_FORM, |
2843 NULL); | 3244 NULL); |
2844 XmStringFree(str); | 3245 set_label(frdp->undo, _("&Undo")); |
2845 XtAddCallback(frdp->undo, XmNactivateCallback, | 3246 XtAddCallback(frdp->undo, XmNactivateCallback, |
2846 find_replace_callback, (XtPointer)FRD_UNDO); | 3247 find_replace_callback, (XtPointer)FRD_UNDO); |
2847 } | 3248 } |
2848 | 3249 |
2849 str = XmStringCreateSimple(_("Cancel")); | |
2850 frdp->cancel = XtVaCreateManagedWidget("closeButton", | 3250 frdp->cancel = XtVaCreateManagedWidget("closeButton", |
2851 xmPushButtonWidgetClass, button_form, | 3251 xmPushButtonWidgetClass, button_form, |
2852 XmNlabelString, str, | |
2853 XmNleftAttachment, XmATTACH_FORM, | 3252 XmNleftAttachment, XmATTACH_FORM, |
2854 XmNrightAttachment, XmATTACH_FORM, | 3253 XmNrightAttachment, XmATTACH_FORM, |
2855 XmNbottomAttachment, XmATTACH_FORM, | 3254 XmNbottomAttachment, XmATTACH_FORM, |
2856 NULL); | 3255 NULL); |
2857 XmStringFree(str); | 3256 set_label(frdp->cancel, _("&Cancel")); |
2858 XtAddCallback(frdp->cancel, XmNactivateCallback, | 3257 XtAddCallback(frdp->cancel, XmNactivateCallback, |
2859 find_replace_dismiss_callback, frdp); | 3258 find_replace_dismiss_callback, frdp); |
3259 gui_motif_menu_fontlist(frdp->cancel); | |
2860 | 3260 |
2861 XtManageChild(button_form); | 3261 XtManageChild(button_form); |
2862 | 3262 |
2863 n = 0; | 3263 n = 0; |
2864 XtSetArg(args[n], XmNorientation, XmVERTICAL); n++; | 3264 XtSetArg(args[n], XmNorientation, XmVERTICAL); n++; |
2892 XmNleftAttachment, XmATTACH_FORM, | 3292 XmNleftAttachment, XmATTACH_FORM, |
2893 XmNtopAttachment, XmATTACH_FORM, | 3293 XmNtopAttachment, XmATTACH_FORM, |
2894 XmNtopOffset, 4, | 3294 XmNtopOffset, 4, |
2895 NULL); | 3295 NULL); |
2896 XmStringFree(str); | 3296 XmStringFree(str); |
3297 gui_motif_menu_fontlist(label_what); | |
2897 | 3298 |
2898 frdp->what = XtVaCreateManagedWidget("whatText", | 3299 frdp->what = XtVaCreateManagedWidget("whatText", |
2899 xmTextFieldWidgetClass, input_form, | 3300 xmTextFieldWidgetClass, input_form, |
2900 XmNtopAttachment, XmATTACH_FORM, | 3301 XmNtopAttachment, XmATTACH_FORM, |
2901 XmNrightAttachment, XmATTACH_FORM, | 3302 XmNrightAttachment, XmATTACH_FORM, |
2926 XmNtopWidget, frdp->what, | 3327 XmNtopWidget, frdp->what, |
2927 XmNtopOffset, 4, | 3328 XmNtopOffset, 4, |
2928 XmNbottomAttachment, XmATTACH_FORM, | 3329 XmNbottomAttachment, XmATTACH_FORM, |
2929 NULL); | 3330 NULL); |
2930 XmStringFree(str); | 3331 XmStringFree(str); |
3332 gui_motif_menu_fontlist(label_with); | |
2931 | 3333 |
2932 /* | 3334 /* |
2933 * Make the entry activation only change the input focus onto the | 3335 * Make the entry activation only change the input focus onto the |
2934 * with item. | 3336 * with item. |
2935 */ | 3337 */ |
2973 | 3375 |
2974 XtManageChild(input_form); | 3376 XtManageChild(input_form); |
2975 | 3377 |
2976 { | 3378 { |
2977 Widget radio_box; | 3379 Widget radio_box; |
3380 Widget w; | |
2978 | 3381 |
2979 frame = XtVaCreateWidget("directionFrame", | 3382 frame = XtVaCreateWidget("directionFrame", |
2980 xmFrameWidgetClass, frdp->dialog, | 3383 xmFrameWidgetClass, frdp->dialog, |
2981 XmNtopAttachment, XmATTACH_WIDGET, | 3384 XmNtopAttachment, XmATTACH_WIDGET, |
2982 XmNtopWidget, input_form, | 3385 XmNtopWidget, input_form, |
2986 XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET, | 3389 XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET, |
2987 XmNrightWidget, input_form, | 3390 XmNrightWidget, input_form, |
2988 NULL); | 3391 NULL); |
2989 | 3392 |
2990 str = XmStringCreateSimple(_("Direction")); | 3393 str = XmStringCreateSimple(_("Direction")); |
2991 (void)XtVaCreateManagedWidget("directionFrameLabel", | 3394 w = XtVaCreateManagedWidget("directionFrameLabel", |
2992 xmLabelGadgetClass, frame, | 3395 xmLabelGadgetClass, frame, |
2993 XmNlabelString, str, | 3396 XmNlabelString, str, |
2994 XmNchildHorizontalAlignment, XmALIGNMENT_BEGINNING, | 3397 XmNchildHorizontalAlignment, XmALIGNMENT_BEGINNING, |
2995 XmNchildType, XmFRAME_TITLE_CHILD, | 3398 XmNchildType, XmFRAME_TITLE_CHILD, |
2996 NULL); | 3399 NULL); |
2997 XmStringFree(str); | 3400 XmStringFree(str); |
3401 gui_motif_menu_fontlist(w); | |
2998 | 3402 |
2999 radio_box = XmCreateRadioBox(frame, "radioBox", | 3403 radio_box = XmCreateRadioBox(frame, "radioBox", |
3000 (ArgList)NULL, 0); | 3404 (ArgList)NULL, 0); |
3001 | 3405 |
3002 str = XmStringCreateSimple( _("Up")); | 3406 str = XmStringCreateSimple( _("Up")); |
3004 xmToggleButtonGadgetClass, radio_box, | 3408 xmToggleButtonGadgetClass, radio_box, |
3005 XmNlabelString, str, | 3409 XmNlabelString, str, |
3006 XmNset, False, | 3410 XmNset, False, |
3007 NULL); | 3411 NULL); |
3008 XmStringFree(str); | 3412 XmStringFree(str); |
3413 gui_motif_menu_fontlist(frdp->up); | |
3009 | 3414 |
3010 str = XmStringCreateSimple(_("Down")); | 3415 str = XmStringCreateSimple(_("Down")); |
3011 frdp->down = XtVaCreateManagedWidget("downRadioButton", | 3416 frdp->down = XtVaCreateManagedWidget("downRadioButton", |
3012 xmToggleButtonGadgetClass, radio_box, | 3417 xmToggleButtonGadgetClass, radio_box, |
3013 XmNlabelString, str, | 3418 XmNlabelString, str, |
3014 XmNset, True, | 3419 XmNset, True, |
3015 NULL); | 3420 NULL); |
3016 XmStringFree(str); | 3421 XmStringFree(str); |
3422 gui_motif_menu_fontlist(frdp->down); | |
3017 | 3423 |
3018 XtManageChild(radio_box); | 3424 XtManageChild(radio_box); |
3019 XtManageChild(frame); | 3425 XtManageChild(frame); |
3020 } | 3426 } |
3021 | 3427 |
3055 XmNtopWidget, frdp->wword, | 3461 XmNtopWidget, frdp->wword, |
3056 XmNtopOffset, 4, | 3462 XmNtopOffset, 4, |
3057 XmNset, mcase, | 3463 XmNset, mcase, |
3058 NULL); | 3464 NULL); |
3059 XmStringFree(str); | 3465 XmStringFree(str); |
3466 gui_motif_menu_fontlist(frdp->wword); | |
3467 gui_motif_menu_fontlist(frdp->mcase); | |
3060 | 3468 |
3061 XtManageChild(toggle_form); | 3469 XtManageChild(toggle_form); |
3062 | 3470 |
3063 if (entry_text != NULL) | 3471 if (entry_text != NULL) |
3064 XmTextFieldSetString(frdp->what, (char *)entry_text); | 3472 XmTextFieldSetString(frdp->what, (char *)entry_text); |
3065 vim_free(entry_text); | 3473 vim_free(entry_text); |
3066 | 3474 |
3067 XtManageChild(frdp->dialog); | 3475 gui_motif_synch_fonts(); |
3476 | |
3477 manage_centered(frdp->dialog); | |
3478 activate_dialog_mnemonics(frdp->dialog); | |
3068 XmProcessTraversal(frdp->what, XmTRAVERSE_CURRENT); | 3479 XmProcessTraversal(frdp->what, XmTRAVERSE_CURRENT); |
3069 } | 3480 } |
3070 | 3481 |
3071 void | 3482 void |
3072 gui_mch_find_dialog(eap) | 3483 gui_mch_find_dialog(eap) |
3086 if (!gui.in_use) | 3497 if (!gui.in_use) |
3087 return; | 3498 return; |
3088 | 3499 |
3089 find_replace_dialog_create(eap->arg, TRUE); | 3500 find_replace_dialog_create(eap->arg, TRUE); |
3090 } | 3501 } |
3502 | |
3503 /* | |
3504 * Synchronize all gui elements, which are dependant upon the | |
3505 * main text font used. Those are in esp. the find/replace dialogs. | |
3506 * If you don't understand why this should be needed, please try to | |
3507 * search for "pięść" in iso8859-2. | |
3508 */ | |
3509 void | |
3510 gui_motif_synch_fonts(void) | |
3511 { | |
3512 SharedFindReplace *frdp; | |
3513 int do_replace; | |
3514 XFontStruct *font; | |
3515 XmFontList font_list; | |
3516 | |
3517 /* FIXME: Unless we find out how to create a XmFontList from a XFontSet, | |
3518 * we just give up here on font synchronization. */ | |
3519 font = (XFontStruct *)gui.norm_font; | |
3520 if (font == NULL) | |
3521 return; | |
3522 | |
3523 font_list = gui_motif_create_fontlist(font); | |
3524 | |
3525 /* OK this loop is a bit tricky... */ | |
3526 for (do_replace = 0; do_replace <= 1; ++do_replace) | |
3527 { | |
3528 frdp = (do_replace) ? (&repl_widgets) : (&find_widgets); | |
3529 if (frdp->dialog) | |
3530 { | |
3531 XtVaSetValues(frdp->what, XmNfontList, font_list, NULL); | |
3532 if (do_replace) | |
3533 XtVaSetValues(frdp->with, XmNfontList, font_list, NULL); | |
3534 } | |
3535 } | |
3536 | |
3537 XmFontListFree(font_list); | |
3538 } |