1 /********************************************************************************
2 *                                                                               *
3 *                                 Test Switcher                                 *
4 *                                                                               *
5 *********************************************************************************
6 * Copyright (C) 1997,2006 by Jeroen van der Zijp.   All Rights Reserved.        *
7 *********************************************************************************
8 * $Id: switcher.cpp,v 1.16 2006/01/22 17:59:02 fox Exp $                        *
9 ********************************************************************************/
10 #include "fx.h"
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <string.h>
14 
15 
16 
17 
18 
19 /*******************************************************************************/
20 
21 
22 // Switcher Test Window
23 class SwitcherTest : public FXMainWindow {
24   FXDECLARE(SwitcherTest)
25 protected:
26   FXMenuBar         *menubar;
27   FXMenuPane        *filemenu;
28   FXHorizontalFrame *contents;
29   FXVerticalFrame   *buttons;
30   FXSwitcher        *switcher;
31   FXList            *simplelist;
32   FXFileList        *filelist;
33   FXDirList         *dirlist;
34   FXGIFIcon         *big_folder;
35   FXGIFIcon         *mini_folder;
36 protected:
SwitcherTest()37   SwitcherTest(){}
38 public:
39   SwitcherTest(FXApp *a);
40   virtual void create();
41   virtual ~SwitcherTest();
42   };
43 
44 
45 /*******************************************************************************/
46 
47 /* Generated by reswrap from file bigfolder.gif */
48 const unsigned char bigfolder[]={
49   0x47,0x49,0x46,0x38,0x37,0x61,0x20,0x00,0x20,0x00,0xf2,0x00,0x00,0xb2,0xc0,0xdc,
50   0x80,0x80,0x80,0xff,0xff,0xff,0xff,0xff,0x00,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x80,
51   0x80,0x00,0x00,0x00,0x00,0x2c,0x00,0x00,0x00,0x00,0x20,0x00,0x20,0x00,0x00,0x03,
52   0x83,0x08,0xba,0xdc,0xfe,0x30,0xca,0x49,0x6b,0x0c,0x38,0x67,0x0b,0x83,0xf8,0x20,
53   0x18,0x70,0x8d,0x37,0x10,0x67,0x8a,0x12,0x23,0x09,0x98,0xab,0xaa,0xb6,0x56,0x40,
54   0xdc,0x78,0xae,0x6b,0x3c,0x5f,0xbc,0xa1,0xa0,0x70,0x38,0x2c,0x14,0x60,0xb2,0x98,
55   0x32,0x99,0x34,0x1c,0x05,0xcb,0x28,0x53,0xea,0x44,0x4a,0xaf,0xd3,0x2a,0x74,0xca,
56   0xc5,0x6a,0xbb,0xe0,0xa8,0x16,0x4b,0x66,0x7e,0xcb,0xe8,0xd3,0x38,0xcc,0x46,0x9d,
57   0xdb,0xe1,0x75,0xba,0xfc,0x9e,0x77,0xe5,0x70,0xef,0x33,0x1f,0x7f,0xda,0xe9,0x7b,
58   0x7f,0x77,0x7e,0x7c,0x7a,0x56,0x85,0x4d,0x84,0x82,0x54,0x81,0x88,0x62,0x47,0x06,
59   0x91,0x92,0x93,0x94,0x95,0x96,0x91,0x3f,0x46,0x9a,0x9b,0x9c,0x9d,0x9e,0x9a,0x2e,
60   0xa1,0xa2,0x13,0x09,0x00,0x3b
61   };
62 
63 
64 /* Generated by reswrap from file minifolder.gif */
65 const unsigned char minifolder[]={
66   0x47,0x49,0x46,0x38,0x37,0x61,0x10,0x00,0x10,0x00,0xf2,0x00,0x00,0xb2,0xc0,0xdc,
67   0x80,0x80,0x80,0xc0,0xc0,0xc0,0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x00,
68   0x00,0x00,0x00,0x00,0x00,0x2c,0x00,0x00,0x00,0x00,0x10,0x00,0x10,0x00,0x00,0x03,
69   0x3b,0x08,0xba,0xdc,0x1b,0x10,0x3a,0x16,0xc4,0xb0,0x22,0x4c,0x50,0xaf,0xcf,0x91,
70   0xc4,0x15,0x64,0x69,0x92,0x01,0x31,0x7e,0xac,0x95,0x8e,0x58,0x7b,0xbd,0x41,0x21,
71   0xc7,0x74,0x11,0xef,0xb3,0x5a,0xdf,0x9e,0x1c,0x6f,0x97,0x03,0xba,0x7c,0xa1,0x64,
72   0x48,0x05,0x20,0x38,0x9f,0x50,0xe8,0x66,0x4a,0x75,0x24,0x00,0x00,0x3b
73   };
74 
75 
76 // SwitcherApp implementation
77 FXIMPLEMENT(SwitcherTest,FXMainWindow,NULL,0)
78 
79 
80 
81 /*******************************************************************************/
82 
83 
84 // Make some windows
SwitcherTest(FXApp * a)85 SwitcherTest::SwitcherTest(FXApp *a):FXMainWindow(a,"Switcher Test",NULL,NULL,DECOR_ALL,0,0,600,400){
86 
87   // Tooltip
88   new FXToolTip(getApp());
89 
90   // Make icons
91   big_folder=new FXGIFIcon(getApp(),bigfolder);
92   mini_folder=new FXGIFIcon(getApp(),minifolder);
93 
94   // Menubar
95   menubar=new FXMenuBar(this,LAYOUT_SIDE_TOP|LAYOUT_FILL_X);
96 
97   // Separator
98   new FXHorizontalSeparator(this,LAYOUT_SIDE_TOP|LAYOUT_FILL_X|SEPARATOR_GROOVE);
99 
100   // Contents
101   contents=new FXHorizontalFrame(this,LAYOUT_SIDE_TOP|FRAME_NONE|LAYOUT_FILL_X|LAYOUT_FILL_Y|PACK_UNIFORM_WIDTH);
102 
103   // Buttons
104   buttons=new FXVerticalFrame(contents,LAYOUT_FILL_Y|LAYOUT_LEFT|PACK_UNIFORM_WIDTH);
105 
106   // Switcher
107   switcher=new FXSwitcher(contents,LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_RIGHT|FRAME_THICK|FRAME_RAISED);
108 
109   // First item in switcher is a list
110   simplelist=new FXList(switcher,NULL,0,LIST_EXTENDEDSELECT);
111   simplelist->appendItem("First Entry",mini_folder);
112   simplelist->appendItem("Second Entry",big_folder);
113   simplelist->appendItem("Third Entry",mini_folder);
114   simplelist->appendItem("Fourth Entry",mini_folder);
115   simplelist->appendItem("Fifth Entry",big_folder);
116   simplelist->appendItem("Sixth Entry",mini_folder);
117 
118   // Second item is a file list
119   filelist=new FXFileList(switcher,NULL,0,ICONLIST_EXTENDEDSELECT);
120 
121   // Third item is a directory list
122   dirlist=new FXDirList(switcher,NULL,0,TREELIST_SHOWS_LINES|TREELIST_SHOWS_BOXES);
123 
124   // Add buttons
125   new FXLabel(buttons,"These buttons below\nare connected to the\nFXSwitcher Control.\nSo they are checked\nautomatically depending\non the active page\nof the switcher.",NULL,LAYOUT_FILL_Y|JUSTIFY_LEFT|JUSTIFY_TOP);
126   new FXButton(buttons,"&Simple List\tMake Switcher go to list",NULL,switcher,FXSwitcher::ID_OPEN_FIRST+0,FRAME_THICK|FRAME_RAISED);
127   new FXButton(buttons,"&File List\tMake Switcher go to files",NULL,switcher,FXSwitcher::ID_OPEN_FIRST+1,FRAME_THICK|FRAME_RAISED);
128   new FXButton(buttons,"&Tree List\tMake Switcher go to tree",NULL,switcher,FXSwitcher::ID_OPEN_FIRST+2,FRAME_THICK|FRAME_RAISED);
129 
130   // File Menu
131   filemenu=new FXMenuPane(this);
132   new FXMenuCommand(filemenu,"&Simple List",NULL,switcher,FXSwitcher::ID_OPEN_FIRST+0);
133   new FXMenuCommand(filemenu,"&File List",NULL,switcher,FXSwitcher::ID_OPEN_FIRST+1);
134   new FXMenuCommand(filemenu,"&Tree List",NULL,switcher,FXSwitcher::ID_OPEN_FIRST+2);
135   new FXMenuCommand(filemenu,"Dump widgets",NULL,getApp(),FXApp::ID_DUMP);
136   new FXMenuCommand(filemenu,"&Quit\tCtl-Q",NULL,getApp(),FXApp::ID_QUIT,0);
137   new FXMenuTitle(menubar,"&File",NULL,filemenu);
138   }
139 
140 
141 // Delete all resources
~SwitcherTest()142 SwitcherTest::~SwitcherTest(){
143   delete filemenu;
144   delete big_folder;
145   delete mini_folder;
146   }
147 
148 
149 // Start
create()150 void SwitcherTest::create(){
151   FXMainWindow::create();
152   show(PLACEMENT_SCREEN);
153   }
154 
155 
156 /*******************************************************************************/
157 
158 
159 // Start the whole thing
main(int argc,char * argv[])160 int main(int argc,char *argv[]){
161 
162   // Make application
163   FXApp application("Switcher","FoxTest");
164 
165   // Open display
166   application.init(argc,argv);
167 
168   new SwitcherTest(&application);
169 
170   // Create app
171   application.create();
172 
173   // Run
174   return application.run();
175   }
176 
177 
178