home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
g
/
gina15.zip
/
demos
/
graph.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-02-27
|
9KB
|
249 lines
/* @(#)hello.C 1.20 7/30/91 */
/*
This application shows its own class hierarchy.
*/
#include <CC/math.h>
#include <Gina/Gina.h>
#ifdef INCLUDE_SRC
#include "Gina.C"
#endif
//---------------------------------------------------------------------
class ClassApplication : public GnApplication {
public:
GnDocument* create_document();
char * app_class () { return "Class" ; }
char * app_signature() { return "Class" ; }
char * app_file_type() { return ".Class" ; }
};
class ClassDocument : public GnDocument {
GnGraphView *view;
public:
ClassDocument();
GnView *create_view();
void create_windows(int new_width, int new_height);
void CreateErichsGraph(caddr_t, caddr_t);
void CreateGraph(caddr_t, caddr_t);
void DeleteGraph(caddr_t, caddr_t){ view->DeleteGraph(); }
void CircleLayout(caddr_t, caddr_t)
{ view->SelectLayout(new GnCircleLayout()); }
void ISILayout(caddr_t, caddr_t)
{ view->SelectLayout(new GnISILayout()); }
void SquareLayout(caddr_t, caddr_t)
{ view->SelectLayout(new GnLayout()); }
void VerticalLayout(caddr_t, caddr_t){ view->SelectDirection(eVertical); };
void HorizontalLayout(caddr_t, caddr_t){ view->SelectDirection(eHorizontal); };
Boolean write_to_stream( ostream &ofs );
Boolean read_from_stream ( istream &ifs );
void HDistance(XmScaleCallbackStruct *new_D)
{view->SetHorizontalDistance(new_D->value);};
void VDistance(XmScaleCallbackStruct *new_D)
{view->SetVerticalDistance(new_D->value);};
private:
GnScale *vScale, *hScale;
};
//---------------------------------------------------------------------
GnDocument *ClassApplication ::
create_document () { return new ClassDocument; }
//---------------------------------------------------------------------
GnView *ClassDocument ::
create_view () { return( view=new GnGraphView( this, 12)); }
ClassDocument::
ClassDocument()
{}
void ClassDocument ::
create_windows (int new_width, int new_height)
{
Gina_Debug_NL ("MandelbrotDocument :: create_windows");
main_shell = new GnDocumentShell( this, new_width, new_height );
main_shell->create( GnApplication::get()->get_application_shell(),
"mainShell" );
main_shell->add_menu_command( "Graph", "Create the Class Graph",
CALLBACK(ClassDocument,CreateGraph,this));
main_shell->add_menu_command( "Graph", "Create the Erichs Graph",
CALLBACK(ClassDocument,CreateErichsGraph,this));
main_shell->add_menu_command( "Graph", "Delete the Graph",
CALLBACK(ClassDocument,DeleteGraph,this));
main_shell->add_menu_command( "Layout", "Chose Circle Layout",
CALLBACK(ClassDocument,CircleLayout,this));
main_shell->add_menu_command( "Layout", "Chose Square Layout",
CALLBACK(ClassDocument,SquareLayout,this));
main_shell->add_menu_command( "Layout", "Chose ISI Layout",
CALLBACK(ClassDocument,ISILayout,this));
main_shell->add_menu_command( "Layout", "Chose Vertical Layout",
CALLBACK(ClassDocument,VerticalLayout,this));
main_shell->add_menu_command( "Layout", "Chose Horizontal Layout",
CALLBACK(ClassDocument,HorizontalLayout,this));
main_shell->setR_allowShellResize(True);
main_shell->SetValues();
GnForm *form = new GnForm;
form->create(main_shell, "ClassForm");
GnLabel *hLabel=new GnLabel;
hScale = new GnScale;
GnLabel *vLabel=new GnLabel;
vScale = new GnScale;
vLabel->setR_topAttachment(XmATTACH_FORM);
vLabel->setR_leftAttachment(XmATTACH_FORM);
vLabel->create(form, "Vertical distance: ");
vScale->setR_orientation(XmHORIZONTAL);
vScale->setR_showValue(TRUE);
vScale->setR_value(10);
vScale->setR_maximum(100);
vScale->setR_topAttachment(XmATTACH_FORM);
vScale->setR_leftAttachment(XmATTACH_WIDGET);
vScale->setR_leftWidget(vLabel);
vScale->setR_rightAttachment(XmATTACH_POSITION);
vScale->setR_rightPosition(50);
vScale->create(form, "vScale");
vScale->add_valueChangedCallback(CALLBACK(ClassDocument, VDistance,this));
hLabel->setR_topAttachment(XmATTACH_FORM);
hLabel->setR_leftAttachment(XmATTACH_WIDGET);
hLabel->setR_leftWidget(vScale);
hLabel->create(form, "Horizontal distance: ");
hScale->setR_orientation(XmHORIZONTAL);
hScale->setR_showValue(TRUE);
hScale->setR_value(10);
hScale->setR_maximum(100);
hScale->setR_topAttachment(XmATTACH_FORM);
hScale->setR_leftAttachment(XmATTACH_WIDGET);
hScale->setR_leftWidget(hLabel);
hScale->setR_rightAttachment(XmATTACH_FORM);
hScale->create(form, "hScale");
hScale->add_valueChangedCallback(CALLBACK(ClassDocument, HDistance,this));
GnVariableScrolledWindow *scroller = new GnStaticScrolledWindow;
scroller->setR_topAttachment(XmATTACH_WIDGET);
scroller->setR_topWidget(vScale);
scroller->setR_leftAttachment(XmATTACH_FORM);
scroller->setR_rightAttachment(XmATTACH_FORM);
scroller->setR_bottomAttachment(XmATTACH_FORM);
scroller->setR_width( 1200 );
scroller->setR_height( 800 );
scroller->create(form, "scrolledWindow");
main_view=view=new GnGraphView( this, 12 );
view->setR_width( 1200 );
view->setR_height( 800 );
view->setR_resizePolicy( XmRESIZE_NONE );
view->create(scroller, "mainView");
}
void ClassDocument ::
CreateGraph(caddr_t, caddr_t)
{
Gina_Debug_NL ("GraphDocument :: CreateGraph");
GnClassListIterator *all_classes_it = GnClass::ClassListIterator();
GnClassInfoListIterator *one_class_it;
for (all_classes_it->Start(); !all_classes_it->Off(); all_classes_it->Forth())
view->add(all_classes_it->Item(), False, True);
for (all_classes_it->Start(); !all_classes_it->Off(); all_classes_it->Forth())
for (one_class_it = all_classes_it->Item()->SubclassesIterator();
!one_class_it->Off(); one_class_it->Forth())
view->AddEdge(all_classes_it->Item(),
one_class_it->Item()->TheClass());
view->DoLayout();
}
void ClassDocument ::
CreateErichsGraph(caddr_t, caddr_t)
{
Gina_Debug_NL ("GraphDocument :: CreateErichsGraph");
GnPresentable *basic_mixin = view->add("Basic");
GnPresentable *word_mixin = view->add("Word");
GnPresentable *data_mixin = view->add("Data");
GnPresentable *date_mixin = view->add("Date");
GnPresentable *scoping_mixin = view->add("Scoping");
GnPresentable *graphic_mixin = view->add("Graphic");
GnPresentable *free_mixin = view->add("Free");
GnPresentable *document_mixin = view->add("Document");
GnPresentable *program_mixin = view->add("Program");
GnPresentable *electronic_mixin = view->add("Electronic");
GnPresentable *mail_mixin = view->add("Mail");
GnPresentable *business_mixin = view->add("Business");
GnPresentable *natural_mixin = view->add("Natural");
GnPresentable *sequel_mixin = view->add("Sequel");
GnPresentable *rpg_mixin = view->add("RPG");
GnPresentable *pascal_mixin = view->add("Pascal");
GnPresentable *budget_mixin = view->add("Budget");
GnPresentable *visicalc_mixin = view->add("VisiCalc");
GnPresentable *project_mixin = view->add("Project");
view->AddEdge(basic_mixin, word_mixin);
view->AddEdge(basic_mixin, data_mixin);
view->AddEdge(basic_mixin, date_mixin);
view->AddEdge(basic_mixin, scoping_mixin);
view->AddEdge(basic_mixin, graphic_mixin);
view->AddEdge(word_mixin, free_mixin);
view->AddEdge(word_mixin, program_mixin);
view->AddEdge(word_mixin, electronic_mixin);
view->AddEdge(data_mixin, document_mixin);
view->AddEdge(data_mixin, program_mixin);
view->AddEdge(data_mixin, electronic_mixin);
view->AddEdge(date_mixin, document_mixin);
view->AddEdge(date_mixin, program_mixin);
view->AddEdge(date_mixin, electronic_mixin);
view->AddEdge(scoping_mixin, document_mixin);
view->AddEdge(scoping_mixin, program_mixin);
view->AddEdge(scoping_mixin, electronic_mixin);
view->AddEdge(graphic_mixin, electronic_mixin);
view->AddEdge(document_mixin, mail_mixin);
view->AddEdge(document_mixin, business_mixin);
view->AddEdge(document_mixin, natural_mixin);
view->AddEdge(program_mixin, sequel_mixin);
view->AddEdge(program_mixin, rpg_mixin);
view->AddEdge(program_mixin, pascal_mixin);
view->AddEdge(electronic_mixin, budget_mixin);
view->AddEdge(electronic_mixin, visicalc_mixin);
view->AddEdge(electronic_mixin, project_mixin);
view->AddEdge(free_mixin, document_mixin);
view->AddEdge(free_mixin, program_mixin);
view->DoLayout();
}
Boolean ClassDocument ::
write_to_stream( ostream &ofs )
{
return(TRUE);
}
Boolean ClassDocument ::
read_from_stream ( istream &ifs )
{
return(TRUE);
}
//---------------------------------------------------------------------
//---------------------------------------------------------------------
int main (unsigned int argc, char ** argv)
{
ClassApplication Class;
#ifdef GINA_DEBUG
Class.set_sync();
#endif
Class.run( argc, argv );
}