1 /********************************************************************************
2 * *
3 * Test Header Controls *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1997,2006 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * $Id: header.cpp,v 1.27 2006/01/22 17:59:01 fox Exp $ *
9 ********************************************************************************/
10 #include "fx.h"
11 #include <stdio.h>
12 #include <stdlib.h>
13
14
15
16
17 /* Generated by reswrap from file minidoc.gif */
18 const unsigned char minidoc[]={
19 0x47,0x49,0x46,0x38,0x37,0x61,0x10,0x00,0x10,0x00,0xf2,0x00,0x00,0xbf,0xbf,0xbf,
20 0x80,0x80,0x80,0xff,0xff,0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
21 0x00,0x00,0x00,0x00,0x00,0x2c,0x00,0x00,0x00,0x00,0x10,0x00,0x10,0x00,0x00,0x03,
22 0x36,0x08,0x10,0xdc,0xae,0x70,0x89,0x49,0xe7,0x08,0x51,0x56,0x3a,0x04,0x86,0xc1,
23 0x46,0x11,0x24,0x01,0x8a,0xd5,0x60,0x2a,0x21,0x6a,0xad,0x9a,0xab,0x9e,0xae,0x30,
24 0xb3,0xb5,0x0d,0xb7,0xf2,0x9e,0xdf,0x31,0x14,0x90,0x27,0xf4,0xd5,0x86,0x83,0xa4,
25 0x72,0x09,0x2c,0x39,0x9f,0xa6,0x04,0x00,0x3b
26 };
27
28
29
30 /*******************************************************************************/
31
32
33 // Header Window
34 class HeaderWindow : public FXMainWindow {
35 FXDECLARE(HeaderWindow)
36 protected:
HeaderWindow()37 HeaderWindow(){}
38 public:
39 long onQuit(FXObject*,FXSelector,void*);
40 long onCmdAbout(FXObject*,FXSelector,void*);
41 long onCmdHeader(FXObject*,FXSelector,void*);
42 long onCmdHeaderButton(FXObject*,FXSelector,void*);
43 long onCmdContinuous(FXObject*,FXSelector,void*);
44 public:
45 enum {
46 ID_ABOUT=FXMainWindow::ID_LAST,
47 ID_HEADER,
48 ID_TRACKING,
49 ID_LAST
50 };
51 protected:
52 FXMenuBar* menubar;
53 FXMenuPane* filemenu;
54 FXMenuPane* helpmenu;
55 FXVerticalFrame* contents;
56 FXHorizontalFrame* panes;
57 FXHeader* header1;
58 FXHeader* header2;
59 FXList* list[4];
60 FXGIFIcon* doc;
61 FXCheckButton* check;
62 public:
63 HeaderWindow(FXApp* a);
64 virtual void create();
65 virtual ~HeaderWindow();
66 };
67
68
69
70 /*******************************************************************************/
71
72 // Map
73 FXDEFMAP(HeaderWindow) HeaderWindowMap[]={
74 FXMAPFUNC(SEL_COMMAND, HeaderWindow::ID_ABOUT, HeaderWindow::onCmdAbout),
75 FXMAPFUNC(SEL_CHANGED, HeaderWindow::ID_HEADER, HeaderWindow::onCmdHeader),
76 FXMAPFUNC(SEL_COMMAND, HeaderWindow::ID_HEADER, HeaderWindow::onCmdHeaderButton),
77 FXMAPFUNC(SEL_COMMAND, HeaderWindow::ID_TRACKING, HeaderWindow::onCmdContinuous),
78 };
79
80
81 // Object implementation
FXIMPLEMENT(HeaderWindow,FXMainWindow,HeaderWindowMap,ARRAYNUMBER (HeaderWindowMap))82 FXIMPLEMENT(HeaderWindow,FXMainWindow,HeaderWindowMap,ARRAYNUMBER(HeaderWindowMap))
83
84
85 // Make some windows
86 HeaderWindow::HeaderWindow(FXApp* a):FXMainWindow(a,"Header Control Test",NULL,NULL,DECOR_ALL,0,0,800,600){
87
88 // Make menu bar
89 menubar=new FXMenuBar(this,LAYOUT_SIDE_TOP|LAYOUT_FILL_X);
90
91 new FXStatusBar(this,LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X);
92
93 filemenu=new FXMenuPane(this);
94 new FXMenuCommand(filemenu,"&Quit\tCtl-Q\tQuit the application",NULL,getApp(),FXApp::ID_QUIT);
95 new FXMenuTitle(menubar,"&File",NULL,filemenu);
96 helpmenu=new FXMenuPane(this);
97 new FXMenuCommand(helpmenu,"&About Header...",NULL,this,ID_ABOUT,0);
98 new FXMenuTitle(menubar,"&Help",NULL,helpmenu,LAYOUT_RIGHT);
99
100 // Make Main Window contents
101 contents=new FXVerticalFrame(this,FRAME_SUNKEN|FRAME_THICK|LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y,0,0,0,0, 0,0,0,0, 0,0);
102
103 // Make header control
104 header1=new FXHeader(contents,this,ID_HEADER,HEADER_BUTTON|HEADER_RESIZE|FRAME_RAISED|FRAME_THICK|LAYOUT_FILL_X);
105
106 // Document icon
107 doc=new FXGIFIcon(getApp(),minidoc);
108
109 header1->appendItem("Name",doc,150);
110 header1->appendItem("Type",NULL,120);
111 header1->appendItem("Layout Option",doc,230);
112 header1->appendItem("Attributes",NULL,80);
113
114 // Below header
115 panes=new FXHorizontalFrame(contents,FRAME_SUNKEN|FRAME_THICK|LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y,0,0,0,0, 0,0,0,0, 0,0);
116
117 // Make 4 lists
118 list[0]=new FXList(panes,NULL,0,LAYOUT_FILL_Y|LAYOUT_FIX_WIDTH|LIST_BROWSESELECT,0,0,150,0);
119 list[1]=new FXList(panes,NULL,0,LAYOUT_FILL_Y|LAYOUT_FIX_WIDTH|LIST_SINGLESELECT,0,0,120,0);
120 list[2]=new FXList(panes,NULL,0,LAYOUT_FILL_Y|LAYOUT_FIX_WIDTH|LIST_MULTIPLESELECT,0,0,230,0);
121 list[3]=new FXList(panes,NULL,0,LAYOUT_FILL_Y|LAYOUT_FIX_WIDTH|LIST_EXTENDEDSELECT,0,0,80,0);
122 list[0]->setBackColor(FXRGB(255,240,240));
123 list[1]->setBackColor(FXRGB(240,255,240));
124 list[2]->setBackColor(FXRGB(240,240,255));
125 list[3]->setBackColor(FXRGB(255,255,240));
126
127 // Add some contents
128 list[0]->appendItem("Jeroen van der Zijp");
129 list[0]->appendItem("Lyle Johnson");
130 list[0]->appendItem("Freddy Golos");
131 list[0]->appendItem("Charles Warren");
132 list[0]->appendItem("Jonathan Bush");
133 list[0]->appendItem("Guoqing Tian");
134
135 list[1]->appendItem("Incorrigible Hacker");
136 list[1]->appendItem("Windows Hacker");
137 list[1]->appendItem("Russian Hacker");
138 list[1]->appendItem("Shutter Widget");
139 list[1]->appendItem("Progress Bar");
140 list[1]->appendItem("Dial Widget");
141
142 list[2]->appendItem("LAYOUT_FILL_X|LAYOUT_FILL_Y");
143 list[2]->appendItem("LAYOUT_FILL_Y");
144 list[2]->appendItem("LAYOUT_NORMAL");
145 list[2]->appendItem("LAYOUT_NORMAL");
146 list[2]->appendItem("LAYOUT_NORMAL");
147 list[2]->appendItem("LAYOUT_NORMAL");
148
149 list[3]->appendItem("A");
150 list[3]->appendItem("B");
151 list[3]->appendItem("C");
152 list[3]->appendItem("D");
153 list[3]->appendItem("E");
154 list[3]->appendItem("F");
155
156 header2=new FXHeader(panes,NULL,0,HEADER_VERTICAL|HEADER_BUTTON|HEADER_RESIZE|FRAME_RAISED|FRAME_THICK|LAYOUT_FILL_Y);
157 header2->appendItem("Example",NULL,30);
158 header2->appendItem("Of",NULL,30);
159 header2->appendItem("Vertical",NULL,30);
160 header2->appendItem("Header",NULL,30);
161
162 // Group box with some controls
163 FXGroupBox *groupie=new FXGroupBox(panes,"Controls",GROUPBOX_TITLE_CENTER|LAYOUT_FILL_X|LAYOUT_FILL_Y);
164 check=new FXCheckButton(groupie,"Continuous Tracking\tContinuous\tTrack Header continuously",this,ID_TRACKING,ICON_BEFORE_TEXT|LAYOUT_SIDE_TOP);
165
166 // Whip out a tooltip control, jeez, that's hard
167 new FXToolTip(getApp());
168 }
169
170
~HeaderWindow()171 HeaderWindow::~HeaderWindow(){
172 delete filemenu;
173 delete helpmenu;
174 delete doc;
175 }
176
177
178 // About
onCmdAbout(FXObject *,FXSelector,void *)179 long HeaderWindow::onCmdAbout(FXObject*,FXSelector,void*){
180 FXMessageBox::information(this,MBOX_OK,"About Header",
181 "An example of how to work with the header control\n\n\nAnd some attributes of the developers!"
182 );
183 return 1;
184 }
185
186
187 // Changed the header control
onCmdHeader(FXObject *,FXSelector,void * ptr)188 long HeaderWindow::onCmdHeader(FXObject*,FXSelector,void* ptr){
189 FXint which=(FXint)(FXival)ptr;
190 FXASSERT(0<=which && which<4);
191 FXTRACE((1,"Width of item %d = %d\n",which,header1->getItemSize(which)));
192 list[which]->setWidth(header1->getItemSize(which));
193 return 1;
194 }
195
196
197 // Clicked a header button:- we highlight all in the list
onCmdHeaderButton(FXObject *,FXSelector,void * ptr)198 long HeaderWindow::onCmdHeaderButton(FXObject*,FXSelector,void* ptr){
199 FXint which=(FXint)(FXival)ptr;
200 FXint i;
201 FXASSERT(0<=which && which<4);
202 for(i=0; i<list[which]->getNumItems(); i++){
203 list[which]->selectItem(i);
204 }
205 return 1;
206 }
207
208
209 // Tracking continuously
onCmdContinuous(FXObject *,FXSelector,void *)210 long HeaderWindow::onCmdContinuous(FXObject*,FXSelector,void*){
211 header1->setHeaderStyle(HEADER_TRACKING^header1->getHeaderStyle());
212 header2->setHeaderStyle(HEADER_TRACKING^header2->getHeaderStyle());
213 return 1;
214 }
215
216
217 // Start
create()218 void HeaderWindow::create(){
219 FXMainWindow::create();
220 show(PLACEMENT_SCREEN);
221 }
222
223
224 /*******************************************************************************/
225
226
227 // Start the whole thing
main(int argc,char * argv[])228 int main(int argc,char *argv[]){
229
230 // Make application
231 FXApp application("Header","FoxTest");
232
233 // Initialize application and open display;
234 // FOX will parse some parameters, and leave the remaining
235 // ones for the main application.
236 application.init(argc,argv);
237
238 // Make window
239 new HeaderWindow(&application);
240
241 // Create all the windows.
242 application.create();
243
244 // Run the application
245 return application.run();
246 }
247
248
249