2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
24 * $XConsortium: SearchHistoryListViewMotif.C /main/10 1996/11/14 16:08:06 cde-hal $
26 * Copyright (c) 1993 HAL Computer Systems International, Ltd.
27 * All rights reserved. Unpublished -- rights reserved under
28 * the Copyright Laws of the United States. USE OF A COPYRIGHT
29 * NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
32 * THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
33 * SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
34 * DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
35 * PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
38 * RESTRICTED RIGHTS LEGEND
39 * Use, duplication, or disclosure by the Government is subject
40 * to the restrictions as set forth in subparagraph (c)(l)(ii)
41 * of the Rights in Technical Data and Computer Software clause
42 * at DFARS 252.227-7013.
44 * HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
63 #define C_SearchHistoryListView
68 #include "Other/XmStringLocalized.hh"
69 #include "Managers/CatMgr.hh"
70 #include "Managers/WString.hh"
72 #include "Registration.hh"
74 #include <WWL/WXmString.h>
75 #include <WWL/WXmList.h>
76 #include <WWL/WXmForm.h>
77 #include <WWL/WXmLabel.h>
80 // /////////////////////////////////////////////////////////////////////////
82 // put the list in the Motif List Widget -> f_list
83 // /////////////////////////////////////////////////////////////////////////
86 SearchHistoryListView::display_value(FolioObject *object)
88 ResultID &rid = *(ResultID*)object;
91 sprintf(buf, "%d", rid.ndocs());
92 WXmString matchString = buf;
94 UAS_Pointer<UAS_SearchResults> results = rid.results();
95 WXmString scopeString = (char*)*results->scope_name();
97 WXmString queryString = rid.display_as();
99 XmFontList fontlist = f_list->FontList();
101 int number_width = WXmString("0").Width(fontlist) ;
103 WXmString matchPostfix(
104 window_system().make_space(
105 8 * number_width - matchString.Width(fontlist),
110 int scope_field_width = 22 * number_width;
114 if ((allowance = scope_field_width - scopeString.Width(fontlist)) < 0)
116 char* dots = (char*)"...";
118 // need to free ungenerated at the end
119 char* ungenerated = (char*)(scopeString + WXmString(dots));
121 wchar_t* buf = WString(ungenerated);
122 wchar_t* ptr = buf + wcslen(buf) - (strlen(dots)+1);
132 memcpy(ptr--, (wchar_t*)wdots, (strlen(dots)+1) * sizeof(wchar_t));
134 stake = str = WString(buf).get_mbstr();
135 allowance = scope_field_width - stake.Width(fontlist);
139 while (allowance <= 0 && ptr >= buf);
141 while (*ptr <= (wchar_t)' ' && ptr >= buf)
144 memcpy(ptr--, (wchar_t*)wdots, (strlen(dots)+1) * sizeof(wchar_t));
146 stake = str = WString(buf).get_mbstr();
147 allowance = scope_field_width - stake.Width(fontlist);
155 WXmString scopePostfix(
156 window_system().make_space(allowance, *f_list), False);
158 WXmString entry_string = matchString + matchPostfix +
159 scopeString + scopePostfix +
162 return entry_string.disown();
166 SearchHistoryListView::child_create_ui_pre(WXmForm &form)
168 Widget header = WXmLabel(form, "header", WAutoManage);
170 XmFontList header_font;
173 XtVaGetValues(header, XmNfontList, &font, NULL);
174 header_font = XmFontListCopy(font);
177 if (window_system().dtinfo_space_font())
178 header_font = XmFontListAppendEntry(header_font,
179 window_system().dtinfo_space_font());
181 XtVaSetValues(header, XmNfontList, header_font, NULL);
184 XmFontContext font_context;
186 if (XmFontListInitFontContext(&font_context, header_font))
189 XmFontListEntry fle = NULL;
192 if (fle = XmFontListNextEntry(font_context)) {
193 char* tag = XmFontListEntryGetTag(fle);
195 fprintf(stderr, "(DEBUG) tag=%s\n", tag);
200 XmFontListFreeFontContext(font_context);
204 int number_width = WXmString("0").Width(header_font);
206 WXmString matchString = CATGETS(Set_AgentLabel, 246, "Matches");
207 WXmString scopeString = CATGETS(Set_AgentLabel, 243, "Scope");
208 WXmString queryString = CATGETS(Set_AgentLabel, 230, "Query");
210 int scope_offset = 8 * number_width;
212 if (matchString.Width(header_font) >= scope_offset)
214 char* dots = (char*)"...";
216 char* ungenerated = (char*)(matchString + WXmString(dots));
218 WString anonym_wstring = ungenerated; // important for digital compiler!
219 wchar_t* buf = (wchar_t*)anonym_wstring;
220 wchar_t* ptr = buf + wcslen(buf) - (strlen(dots)+1);
231 memcpy(ptr--, (wchar_t*)wdots, (strlen(dots)+1) * sizeof(wchar_t));
233 stake = str = WString(buf).get_mbstr();
235 allowance = scope_offset - stake.Width(header_font);
239 while (allowance <= 0 && ptr >= buf);
241 while (*ptr <= (wchar_t)' ' && ptr >= buf)
244 memcpy(ptr--, (wchar_t*)wdots, (strlen(dots)+1) * sizeof(wchar_t));
246 stake = str = WString(buf).get_mbstr();
247 allowance = scope_offset - stake.Width(header_font);
255 WXmString matchPostfix(
256 window_system().make_space(
257 scope_offset - matchString.Width(header_font),
261 WXmString scopePostfix(
262 window_system().make_space(
263 22 * number_width - scopeString.Width(header_font),
268 WXmString header_string = matchString + matchPostfix +
269 scopeString + scopePostfix +
272 XtVaSetValues(header, XmNlabelString, (XmString)header_string, NULL);
277 SearchHistoryListView::display()
280 cerr << "ListView::display()...";
284 cerr << "done." << endl;
286 XtVaSetValues(*f_shell, XmNtitle,
287 CATGETS(Set_SearchHistoryList, 1, "Dtinfo: Search History"), NULL);