File: dirlist.cpp

package info (click to toggle)
fox 1.0.52-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 10,788 kB
  • ctags: 13,384
  • sloc: cpp: 96,482; sh: 8,338; ansic: 1,935; makefile: 1,010; perl: 32
file content (127 lines) | stat: -rw-r--r-- 3,456 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/********************************************************************************
*                                                                               *
*                  D i r e c t o r y   L i s t   C o n t r o l                  *
*                                                                               *
*********************************************************************************
* Copyright (C) 1998 by Jeroen van der Zijp.   All Rights Reserved.             *
*********************************************************************************
* $Id: dirlist.cpp,v 1.11 2001/11/02 06:07:19 jeroen Exp $                      *
********************************************************************************/
#include "fx.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#ifndef WIN32
#include <unistd.h>
#endif




/*******************************************************************************/


// Main Window
class DirListWindow : public FXMainWindow {
  FXDECLARE(DirListWindow)
protected:
  FXMenubar*         menubar;
  FXMenuPane*        filemenu;
  FXMenuPane*        helpmenu;
  FXDirList*         contents;
  FXTextField*       text;
protected:
  DirListWindow(){}
public:
  long onCmdAbout(FXObject*,FXSelector,void*);
public:
  enum{
    ID_ABOUT=FXMainWindow::ID_LAST,
    ID_LAST
    };
public:
  DirListWindow(FXApp* a);
  virtual void create();
  virtual ~DirListWindow();
  };


  
/*******************************************************************************/
  
// Map
FXDEFMAP(DirListWindow) DirListWindowMap[]={
  FXMAPFUNC(SEL_COMMAND, DirListWindow::ID_ABOUT, DirListWindow::onCmdAbout),
  };


// Object implementation
FXIMPLEMENT(DirListWindow,FXMainWindow,DirListWindowMap,ARRAYNUMBER(DirListWindowMap))


// Make some windows
DirListWindow::DirListWindow(FXApp* a):FXMainWindow(a,"Directory List",NULL,NULL,DECOR_ALL,0,0,800,600){
  
  // Make menu bar
  menubar=new FXMenubar(this,LAYOUT_FILL_X);
  filemenu=new FXMenuPane(this);
    new FXMenuCommand(filemenu,"&Quit\tCtl-Q",NULL,getApp(),FXApp::ID_QUIT);
    new FXMenuTitle(menubar,"&File",NULL,filemenu);
  helpmenu=new FXMenuPane(this);
    new FXMenuCommand(helpmenu,"&About FOX...",NULL,this,ID_ABOUT,0);
    new FXMenuTitle(menubar,"&Help",NULL,helpmenu,LAYOUT_RIGHT);

  // Text field at bottom
  text=new FXTextField(this,10,NULL,0,LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|FRAME_SUNKEN|FRAME_THICK);
  
  // Make contents
  contents=new FXDirList(this,0,NULL,0,HSCROLLING_OFF|TREELIST_SHOWS_LINES|TREELIST_SHOWS_BOXES|FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X|LAYOUT_FILL_Y,0,0,0,0);
  
  text->setTarget(contents);
  text->setSelector(FXWindow::ID_SETVALUE);
  }


DirListWindow::~DirListWindow(){
  delete filemenu;
  delete helpmenu;
  }


// About
long DirListWindow::onCmdAbout(FXObject*,FXSelector,void*){
  FXMessageBox::information(this,MBOX_OK,"About FOX","FOX is a really, really cool C++ library!");
  return 1;
  }


// Start
void DirListWindow::create(){
  FXMainWindow::create();
  show(PLACEMENT_SCREEN);
  }


/*******************************************************************************/


// Start the whole thing
int main(int argc,char *argv[]){

  // Make application
  FXApp application("DirList","FoxTest");
  
  // Open display
  application.init(argc,argv);

  // Make window
  new DirListWindow(&application);
  
  // Create app  
  application.create();
  
  // Run
  return application.run();
  }