]> git.saurik.com Git - wxWidgets.git/blob - src/motif/listbox.cpp
Added dummy DeleteChildren so the sample will at least link.
[wxWidgets.git] / src / motif / listbox.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: listbox.cpp
3 // Purpose: wxListBox
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 17/09/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "listbox.h"
14 #endif
15
16 #include "wx/listbox.h"
17 #include "wx/settings.h"
18 #include "wx/dynarray.h"
19 #include "wx/log.h"
20 #include "wx/utils.h"
21
22 #include <Xm/List.h>
23 #include "wx/motif/private.h"
24
25 #if !USE_SHARED_LIBRARY
26 IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl)
27 #endif
28
29 void wxListBoxCallback (Widget w, XtPointer clientData,
30 XmListCallbackStruct * cbs);
31
32 void wxListBoxDefaultActionProc (Widget list_w, XtPointer client_data, XmListCallbackStruct * cbs);
33
34 // ============================================================================
35 // list box control implementation
36 // ============================================================================
37
38 // Listbox item
39 wxListBox::wxListBox(): m_clientDataList(wxKEY_INTEGER)
40 {
41 m_noItems = 0;
42 m_selected = 0;
43 }
44
45 bool wxListBox::Create(wxWindow *parent, wxWindowID id,
46 const wxPoint& pos,
47 const wxSize& size,
48 int n, const wxString choices[],
49 long style,
50 const wxValidator& validator,
51 const wxString& name)
52 {
53 m_windowStyle = style;
54 m_noItems = n;
55 m_selected = 0;
56 // m_backgroundColour = parent->GetBackgroundColour();
57 m_backgroundColour = * wxWHITE;
58 m_foregroundColour = parent->GetForegroundColour();
59
60 SetName(name);
61 SetValidator(validator);
62
63 if (parent) parent->AddChild(this);
64
65 m_windowId = ( id == -1 ) ? (int)NewControlId() : id;
66
67 Widget parentWidget = (Widget) parent->GetClientWidget();
68
69 Arg args[3];
70 int count;
71 XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT);
72 if (m_windowStyle & wxLB_MULTIPLE)
73 XtSetArg (args[1], XmNselectionPolicy, XmMULTIPLE_SELECT);
74 else if (m_windowStyle & wxLB_EXTENDED)
75 XtSetArg (args[1], XmNselectionPolicy, XmEXTENDED_SELECT);
76 else
77 XtSetArg (args[1], XmNselectionPolicy, XmBROWSE_SELECT);
78 if (m_windowStyle & wxLB_ALWAYS_SB)
79 {
80 XtSetArg (args[2], XmNscrollBarDisplayPolicy, XmSTATIC);
81 count = 3;
82 }
83 else
84 count = 2;
85
86 Widget listWidget = XmCreateScrolledList (parentWidget, (char*) (const char*) name, args, count);
87
88 m_mainWidget = (WXWidget) listWidget;
89
90 Set(n, choices);
91
92 XtManageChild (listWidget);
93
94 long width = size.x;
95 long height = size.y;
96 if (width == -1)
97 width = 150;
98 if (height == -1)
99 height = 80;
100
101 XtAddCallback (listWidget, XmNbrowseSelectionCallback, (XtCallbackProc) wxListBoxCallback,
102 (XtPointer) this);
103 XtAddCallback (listWidget, XmNextendedSelectionCallback, (XtCallbackProc) wxListBoxCallback,
104 (XtPointer) this);
105 XtAddCallback (listWidget, XmNmultipleSelectionCallback, (XtCallbackProc) wxListBoxCallback,
106 (XtPointer) this);
107
108 XtAddCallback (listWidget, XmNdefaultActionCallback, (XtCallbackProc) wxListBoxDefaultActionProc,
109 (XtPointer) this);
110
111 m_windowFont = parent->GetFont();
112 ChangeFont(FALSE);
113
114 AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, width, height);
115
116 ChangeBackgroundColour();
117
118 return TRUE;
119 }
120
121 wxListBox::~wxListBox()
122 {
123 }
124
125 void wxListBox::SetFirstItem(int N)
126 {
127 int count, length;
128
129 if (N < 0)
130 return;
131 XtVaGetValues ((Widget) m_mainWidget,
132 XmNvisibleItemCount, &count,
133 XmNitemCount, &length,
134 NULL);
135 if ((N + count) >= length)
136 N = length - count;
137 XmListSetPos ((Widget) m_mainWidget, N + 1);
138 }
139
140 void wxListBox::SetFirstItem(const wxString& s)
141 {
142 int N = FindString (s);
143
144 if (N >= 0)
145 SetFirstItem (N);
146 }
147
148 void wxListBox::Delete(int N)
149 {
150 int width1, height1;
151 int width2, height2;
152 Widget listBox = (Widget) m_mainWidget;
153 GetSize (&width1, &height1);
154
155 bool managed = XtIsManaged(listBox);
156
157 if (managed)
158 XtUnmanageChild (listBox);
159
160 XmListDeletePos (listBox, N + 1);
161
162 if (managed)
163 XtManageChild (listBox);
164
165 GetSize (&width2, &height2);
166 // Correct for randomly resized listbox - bad boy, Motif!
167 if (width1 != width2 || height1 != height2)
168 SetSize (-1, -1, width1, height1);
169
170 // (JDH) need to add code here to take care of clientDataList
171 wxNode *node = m_clientDataList.Find((long)N); // get item from list
172 if (node) m_clientDataList.DeleteNode(node); // if existed then delete from list
173 node = m_clientDataList.First(); // we now have to adjust all keys that
174 while (node) // are >=N+1
175 { if (node->GetKeyInteger() >= (long)(N+1))
176 node->SetKeyInteger(node->GetKeyInteger() - 1);
177 node = node->Next();
178 }
179
180 m_noItems --;
181 }
182
183 void wxListBox::Append(const wxString& item)
184 {
185 int width1, height1;
186 int width2, height2;
187
188 Widget listBox = (Widget) m_mainWidget;
189 GetSize (&width1, &height1);
190
191 bool managed = XtIsManaged(listBox);
192
193 if (managed)
194 XtUnmanageChild (listBox);
195 int n;
196 XtVaGetValues (listBox, XmNitemCount, &n, NULL);
197 XmString text = XmStringCreateSimple ((char*) (const char*) item);
198 // XmListAddItem(listBox, text, n + 1);
199 XmListAddItemUnselected (listBox, text, 0);
200 XmStringFree (text);
201
202 // It seems that if the list is cleared, we must re-ask for
203 // selection policy!!
204 Arg args[3];
205 XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT);
206 if (m_windowStyle & wxLB_MULTIPLE)
207 XtSetArg (args[1], XmNselectionPolicy, XmMULTIPLE_SELECT);
208 else if (m_windowStyle & wxLB_EXTENDED)
209 XtSetArg (args[1], XmNselectionPolicy, XmEXTENDED_SELECT);
210 else
211 XtSetArg (args[1], XmNselectionPolicy, XmBROWSE_SELECT);
212 XtSetValues (listBox, args, 2);
213
214 if (managed)
215 XtManageChild (listBox);
216
217 GetSize (&width2, &height2);
218 // Correct for randomly resized listbox - bad boy, Motif!
219 if (width1 != width2 || height1 != height2)
220 SetSize (-1, -1, width1, height1);
221 m_noItems ++;
222 }
223
224 void wxListBox::Append(const wxString& item, char *clientData)
225 {
226 int width1, height1;
227 int width2, height2;
228
229 Widget listBox = (Widget) m_mainWidget;
230
231 GetSize (&width1, &height1);
232 Bool managed = XtIsManaged(listBox);
233
234 if (managed)
235 XtUnmanageChild (listBox);
236
237 int n;
238 XtVaGetValues (listBox, XmNitemCount, &n, NULL);
239 XmString text = XmStringCreateSimple ((char*) (const char*) item);
240 // XmListAddItem(listBox, text, n + 1);
241 XmListAddItemUnselected (listBox, text, 0);
242 XmStringFree (text);
243
244 // It seems that if the list is cleared, we must re-ask for
245 // selection policy!!
246 Arg args[3];
247 XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT);
248 if (m_windowStyle & wxLB_MULTIPLE)
249 XtSetArg (args[1], XmNselectionPolicy, XmMULTIPLE_SELECT);
250 else if (m_windowStyle & wxLB_EXTENDED)
251 XtSetArg (args[1], XmNselectionPolicy, XmEXTENDED_SELECT);
252 else
253 XtSetArg (args[1], XmNselectionPolicy, XmBROWSE_SELECT);
254 XtSetValues (listBox, args, 2);
255
256 m_clientDataList.Append ((long) n, (wxObject *) clientData);
257
258 if (managed)
259 XtManageChild (listBox);
260
261 GetSize (&width2, &height2);
262
263 // Correct for randomly resized listbox - bad boy, Motif!
264 if (width1 != width2 || height1 != height2)
265 SetSize (-1, -1, width1, height1);
266
267 m_noItems ++;
268 }
269
270 void wxListBox::Set(int n, const wxString *choices, char** clientData)
271 {
272 m_clientDataList.Clear();
273 int width1, height1;
274 int width2, height2;
275
276 Widget listBox = (Widget) m_mainWidget;
277 GetSize (&width1, &height1);
278
279 bool managed = XtIsManaged(listBox);
280
281 if (managed)
282 XtUnmanageChild (listBox);
283 /***
284 for (int i=0; i<n; i++)
285 {
286 XmString text = XmStringCreateSimple(choices[i]);
287 XmListAddItemUnselected(listBox, text, 0);
288 XmStringFree(text);
289 }
290 ***/
291 XmString *text = new XmString[n];
292 int i;
293 for (i = 0; i < n; i++)
294 text[i] = XmStringCreateSimple ((char*) (const char*) choices[i]);
295
296 if ( clientData )
297 for (i = 0; i < n; i++)
298 m_clientDataList.Append ((long) i, (wxObject *) clientData[i]);
299
300 XmListAddItems (listBox, text, n, 0);
301 for (i = 0; i < n; i++)
302 XmStringFree (text[i]);
303 delete[]text;
304
305 // It seems that if the list is cleared, we must re-ask for
306 // selection policy!!
307 Arg args[3];
308 XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT);
309 if (m_windowStyle & wxLB_MULTIPLE)
310 XtSetArg (args[1], XmNselectionPolicy, XmMULTIPLE_SELECT);
311 else if (m_windowStyle & wxLB_EXTENDED)
312 XtSetArg (args[1], XmNselectionPolicy, XmEXTENDED_SELECT);
313 else
314 XtSetArg (args[1], XmNselectionPolicy, XmBROWSE_SELECT);
315 XtSetValues (listBox, args, 2);
316
317 if (managed)
318 XtManageChild (listBox);
319
320 GetSize (&width2, &height2);
321 // Correct for randomly resized listbox - bad boy, Motif!
322 if (width1 != width2 || height1 != height2)
323 SetSize (-1, -1, width1, height1);
324
325 m_noItems = n;
326 }
327
328 int wxListBox::FindString(const wxString& s) const
329 {
330 XmString str = XmStringCreateSimple ((char*) (const char*) s);
331 int *positions = NULL;
332 int no_positions = 0;
333 bool success = XmListGetMatchPos ((Widget) m_mainWidget, str, &positions, &no_positions);
334 XmStringFree (str);
335 if (success)
336 {
337 int pos = positions[0];
338 if (positions)
339 XtFree ((char *) positions);
340 return pos - 1;
341 }
342 else
343 return -1;
344 }
345
346 void wxListBox::Clear()
347 {
348 if (m_noItems <= 0)
349 return;
350
351 int width1, height1;
352 int width2, height2;
353
354 Widget listBox = (Widget) m_mainWidget;
355 GetSize (&width1, &height1);
356
357 XmListDeleteAllItems (listBox);
358 m_clientDataList.Clear ();
359 GetSize (&width2, &height2);
360
361 // Correct for randomly resized listbox - bad boy, Motif!
362 if (width1 != width2 || height1 != height2)
363 SetSize (-1, -1, width1, height1);
364
365 m_noItems = 0;
366 }
367
368 void wxListBox::SetSelection(int N, bool select)
369 {
370 m_inSetValue = TRUE;
371 if (select)
372 {
373 /*
374 if (m_windowStyle & wxLB_MULTIPLE)
375 {
376 int *selections = NULL;
377 int n = GetSelections (&selections);
378
379 // This hack is supposed to work, to make it possible to select more
380 // than one item, but it DOESN'T under Motif 1.1.
381
382 XtVaSetValues ((Widget) m_mainWidget, XmNselectionPolicy, XmMULTIPLE_SELECT, NULL);
383
384 int i;
385 for (i = 0; i < n; i++)
386 XmListSelectPos ((Widget) m_mainWidget, selections[i] + 1, FALSE);
387
388 XmListSelectPos ((Widget) m_mainWidget, N + 1, FALSE);
389
390 XtVaSetValues ((Widget) m_mainWidget, XmNselectionPolicy, XmEXTENDED_SELECT, NULL);
391 }
392 else
393 */
394 XmListSelectPos ((Widget) m_mainWidget, N + 1, FALSE);
395
396 }
397 else
398 XmListDeselectPos ((Widget) m_mainWidget, N + 1);
399
400 m_inSetValue = FALSE;
401 }
402
403 bool wxListBox::Selected(int N) const
404 {
405 // In Motif, no simple way to determine if the item is selected.
406 wxArrayInt theSelections;
407 int count = GetSelections (theSelections);
408 if (count == 0)
409 return FALSE;
410 else
411 {
412 int j;
413 for (j = 0; j < count; j++)
414 if (theSelections[j] == N)
415 return TRUE;
416 }
417 return FALSE;
418 }
419
420 void wxListBox::Deselect(int N)
421 {
422 XmListDeselectPos ((Widget) m_mainWidget, N + 1);
423 }
424
425 char *wxListBox::GetClientData(int N) const
426 {
427 wxNode *node = m_clientDataList.Find ((long) N);
428 if (node)
429 return (char *) node->Data ();
430 else
431 return NULL;
432 }
433
434 void wxListBox::SetClientData(int N, char *Client_data)
435 {
436 wxNode *node = m_clientDataList.Find ((long) N);
437 if (node)
438 node->SetData ((wxObject *)Client_data);
439 else
440 node = m_clientDataList.Append((long) N, (wxObject*) Client_data);
441 }
442
443 // Return number of selections and an array of selected integers
444 int wxListBox::GetSelections(wxArrayInt& aSelections) const
445 {
446 aSelections.Empty();
447
448 Widget listBox = (Widget) m_mainWidget;
449 int *posList = NULL;
450 int posCnt = 0;
451 bool flag = XmListGetSelectedPos (listBox, &posList, &posCnt);
452 if (flag)
453 {
454 if (posCnt > 0)
455 {
456 aSelections.Alloc(posCnt);
457
458 int i;
459 for (i = 0; i < posCnt; i++)
460 aSelections.Add(posList[i] - 1);
461
462 XtFree ((char *) posList);
463 return posCnt;
464 }
465 else
466 return 0;
467 }
468 else
469 return 0;
470 }
471
472 // Get single selection, for single choice list items
473 int wxListBox::GetSelection() const
474 {
475 Widget listBox = (Widget) m_mainWidget;
476 int *posList = NULL;
477 int posCnt = 0;
478 bool flag = XmListGetSelectedPos (listBox, &posList, &posCnt);
479 if (flag)
480 {
481 int id = -1;
482 if (posCnt > 0)
483 id = posList[0] - 1;
484 XtFree ((char *) posList);
485 return id;
486 }
487 else
488 return -1;
489 }
490
491 // Find string for position
492 wxString wxListBox::GetString(int N) const
493 {
494 Widget listBox = (Widget) m_mainWidget;
495 XmString *strlist;
496 int n;
497 XtVaGetValues (listBox, XmNitemCount, &n, XmNitems, &strlist, NULL);
498 if (N <= n && N >= 0)
499 {
500 char *txt;
501 if (XmStringGetLtoR (strlist[N], XmSTRING_DEFAULT_CHARSET, &txt))
502 {
503 wxString str(txt);
504 XtFree (txt);
505 return str;
506 }
507 else
508 return wxEmptyString;
509 }
510 else
511 return wxEmptyString;
512 }
513
514 void wxListBox::SetSize(int x, int y, int width, int height, int sizeFlags)
515 {
516 wxWindow::SetSize(x, y, width, height, sizeFlags);
517
518 // Check resulting size is correct
519 int tempW, tempH;
520 GetSize (&tempW, &tempH);
521
522 /*
523 if (tempW != width || tempH != height)
524 {
525 cout << "wxListBox::SetSize sizes not set correctly.");
526 }
527 */
528 }
529
530 void wxListBox::InsertItems(int nItems, const wxString items[], int pos)
531 {
532 int width1, height1;
533 int width2, height2;
534
535 Widget listBox = (Widget) m_mainWidget;
536
537 GetSize(&width1, &height1);
538
539 bool managed = XtIsManaged(listBox);
540
541 if (managed)
542 XtUnmanageChild(listBox);
543
544 XmString *text = new XmString[nItems];
545 int i;
546 // Steve Hammes: Motif 1.1 compatibility
547 // #if XmVersion > 1100
548 // Corrected by Sergey Krasnov from Steve Hammes' code
549 #if XmVersion > 1001
550 for (i = 0; i < nItems; i++)
551 text[i] = XmStringCreateSimple((char*) (const char*) items[i]);
552 XmListAddItemsUnselected(listBox, text, nItems, pos+1);
553 #else
554 for (i = 0; i < nItems; i++)
555 {
556 text[i] = XmStringCreateSimple((char*) (const char*) items[i]);
557 // XmListAddItemUnselected(listBox, text[i], i);
558 XmListAddItemUnselected(listBox, text[i], pos+i+1); // Another Sergey correction
559 }
560 #endif
561 for (i = 0; i < nItems; i++)
562 XmStringFree(text[i]);
563
564 delete[] text;
565
566 // It seems that if the list is cleared, we must re-ask for
567 // selection policy!!
568 Arg args[3];
569 XtSetArg(args[0], XmNlistSizePolicy, XmCONSTANT);
570 if (m_windowStyle & wxLB_MULTIPLE)
571 XtSetArg(args[1], XmNselectionPolicy, XmMULTIPLE_SELECT);
572 else if (m_windowStyle & wxLB_EXTENDED)
573 XtSetArg(args[1], XmNselectionPolicy, XmEXTENDED_SELECT);
574 else XtSetArg(args[1], XmNselectionPolicy, XmBROWSE_SELECT);
575 XtSetValues(listBox,args,2) ;
576
577 if (managed)
578 XtManageChild(listBox);
579
580 GetSize(&width2, &height2);
581 // Correct for randomly resized listbox - bad boy, Motif!
582 if (width1 != width2 /*|| height1 != height2*/)
583 SetSize(-1, -1, width1, height1);
584
585 m_noItems += nItems;
586 }
587
588 void wxListBox::SetString(int N, const wxString& s)
589 {
590 int width1, height1;
591 int width2, height2;
592
593 Widget listBox = (Widget) m_mainWidget;
594 GetSize (&width1, &height1);
595
596 XmString text = XmStringCreateSimple ((char*) (const char*) s);
597
598 // WHAT'S THE MOTIF CALL TO SET THE TEXT OF AN EXISTING
599 // ITEM???
600 // There isn't one, so delete the item and add it again.
601 XmListDeletePos (listBox, N+1);
602 XmListAddItem (listBox, text, N+1);
603
604 XmStringFree(text);
605
606 /*
607 // It seems that if the list is cleared, we must re-ask for
608 // selection policy!!
609 Arg args[3];
610 XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT);
611 if (m_windowStyle & wxLB_MULTIPLE)
612 XtSetArg (args[1], XmNselectionPolicy, XmMULTIPLE_SELECT);
613 else if (m_windowStyle & wxLB_EXTENDED)
614 XtSetArg (args[1], XmNselectionPolicy, XmEXTENDED_SELECT);
615 else
616 XtSetArg (args[1], XmNselectionPolicy, XmBROWSE_SELECT);
617 XtSetValues (listBox, args, 2);
618 */
619
620 GetSize (&width2, &height2);
621 // Correct for randomly resized listbox - bad boy, Motif!
622 if (width1 != width2 || height1 != height2)
623 SetSize (-1, -1, width1, height1);
624 }
625
626 int wxListBox::Number () const
627 {
628 return m_noItems;
629 }
630
631 // For single selection items only
632 wxString wxListBox::GetStringSelection () const
633 {
634 int sel = GetSelection ();
635 if (sel > -1)
636 return this->GetString (sel);
637 else
638 return wxString("");
639 }
640
641 bool wxListBox::SetStringSelection (const wxString& s, bool flag)
642 {
643 int sel = FindString (s);
644 if (sel > -1)
645 {
646 SetSelection (sel, flag);
647 return TRUE;
648 }
649 else
650 return FALSE;
651 }
652
653 void wxListBox::Command (wxCommandEvent & event)
654 {
655 if (event.m_extraLong)
656 SetSelection (event.m_commandInt);
657 else
658 {
659 Deselect (event.m_commandInt);
660 return;
661 }
662 ProcessCommand (event);
663 }
664
665 void wxListBoxCallback (Widget w, XtPointer clientData,
666 XmListCallbackStruct * cbs)
667 {
668 /*
669 if (cbs->reason == XmCR_EXTENDED_SELECT)
670 cout << "*** Extend select\n";
671 else if (cbs->reason == XmCR_SINGLE_SELECT)
672 cout << "*** Single select\n";
673 else if (cbs->reason == XmCR_MULTIPLE_SELECT)
674 cout << "*** Multiple select\n";
675 else if (cbs->reason == XmCR_BROWSE_SELECT)
676 cout << "*** Browse select\n";
677
678 if (cbs->selection_type == XmMODIFICATION)
679 cout << "*** Modification\n";
680 else if (cbs->selection_type == XmINITIAL)
681 cout << "*** Initial\n";
682 else if (cbs->selection_type == XmADDITION)
683 cout << "*** Addition\n";
684 */
685
686 wxListBox *item = (wxListBox *) clientData;
687
688 if (item->InSetValue())
689 return;
690
691 wxCommandEvent event (wxEVT_COMMAND_LISTBOX_SELECTED);
692 switch (cbs->reason)
693 {
694 case XmCR_MULTIPLE_SELECT:
695 case XmCR_BROWSE_SELECT:
696 {
697 event.m_clientData = item->GetClientData (cbs->item_position - 1);
698 //event.commandString = item->GetStringSelection();
699 event.m_commandInt = cbs->item_position - 1;
700 event.m_extraLong = TRUE;
701 event.SetEventObject(item);
702 item->ProcessCommand (event);
703 //delete[] event.commandString; // Let's not store the command string any more
704 break;
705 }
706 case XmCR_EXTENDED_SELECT:
707 {
708 switch (cbs->selection_type)
709 {
710 case XmINITIAL:
711 case XmADDITION:
712 case XmMODIFICATION:
713 {
714 event.m_clientData = item->GetClientData (cbs->item_position - 1);
715 event.m_commandInt = cbs->item_position - 1;
716 event.m_extraLong = TRUE;
717 event.SetEventObject(item);
718 item->ProcessCommand (event);
719 break;
720 }
721 }
722 break;
723 }
724 }
725 }
726
727 /* Respond by getting the
728 * designated "default button" in the action area and activate it
729 * as if the user had selected it.
730 */
731 void wxListBoxDefaultActionProc (Widget list_w, XtPointer client_data, XmListCallbackStruct * cbs)
732 {
733 wxListBox *lbox = (wxListBox *) client_data;
734
735 wxCommandEvent event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, lbox->GetId());
736 event.SetEventObject( lbox );
737 lbox->GetEventHandler()->ProcessEvent(event) ;
738 }
739
740 WXWidget wxListBox::GetTopWidget() const
741 {
742 return (WXWidget) XtParent( (Widget) m_mainWidget );
743 }
744
745 void wxListBox::ChangeFont(bool keepOriginalSize)
746 {
747 wxWindow::ChangeFont(keepOriginalSize);
748 }
749
750 void wxListBox::ChangeBackgroundColour()
751 {
752 wxWindow::ChangeBackgroundColour();
753
754 Widget parent = XtParent ((Widget) m_mainWidget);
755 Widget hsb, vsb;
756
757 XtVaGetValues (parent,
758 XmNhorizontalScrollBar, &hsb,
759 XmNverticalScrollBar, &vsb,
760 NULL);
761
762 /* TODO: should scrollbars be affected? Should probably have separate
763 * function to change them (by default, taken from wxSystemSettings)
764 */
765 wxColour backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
766 DoChangeBackgroundColour((WXWidget) hsb, backgroundColour, TRUE);
767 DoChangeBackgroundColour((WXWidget) vsb, backgroundColour, TRUE);
768
769 DoChangeBackgroundColour((WXWidget) parent, m_backgroundColour, TRUE);
770 }
771
772 void wxListBox::ChangeForegroundColour()
773 {
774 wxWindow::ChangeForegroundColour();
775
776 Widget parent = XtParent ((Widget) m_mainWidget);
777 Widget hsb, vsb;
778
779 XtVaGetValues (parent,
780 XmNhorizontalScrollBar, &hsb,
781 XmNverticalScrollBar, &vsb,
782 NULL);
783 /* TODO: should scrollbars be affected? Should probably have separate
784 * function to change them (by default, taken from wxSystemSettings)
785 DoChangeForegroundColour((WXWidget) hsb, m_foregroundColour);
786 DoChangeForegroundColour((WXWidget) vsb, m_foregroundColour);
787 DoChangeForegroundColour((WXWidget) parent, m_foregroundColour);
788 */
789 }
790
791