示例#1
0
MainView::MainView(const Rect& cRect) : LayoutView(cRect, "MainView")
//	Here is where we construct the window e.g views, buttons, textviews, etc...
{

//create the vertical root layout node
	LayoutNode* pcRootNode = new VLayoutNode("Root");

//create textview
//top spacer
	pcRootNode->AddChild(new VLayoutSpacer("Spacer1", 19, 19));
//create output box
  	Rect y;
	y.Resize(0,0,0,0);
	textOutputView = new TextView (y, "OutputView", "", CF_FOLLOW_ALL );
	textOutputView ->SetMultiLine(true);
	textOutputView ->SetReadOnly(true);
	pcRootNode->AddChild(textOutputView);
//spacer between input and output
	pcRootNode->AddChild(new VLayoutSpacer("Spacer2", 5, 5));
//create horizontal layer
	LayoutNode* pcButtonNode = new HLayoutNode("Buttons", 0);
	
	pcButtonNode->AddChild(new HLayoutSpacer("Spacer3", 5, 5));
//create input box
  	Rect x;
	x.Resize( 0,0,0,0);
//	TextView* textInputView = new TextView (x, "InputView", "Input", CF_FOLLOW_ALL );
	textInputView = new TextView (x, "InputView", "Input", CF_FOLLOW_ALL );	
	pcButtonNode->AddChild(textInputView);
//bottom spacer
	pcButtonNode->AddChild(new HLayoutSpacer("Spacer4", 5, 5));
	m_pcStart = new Button(Rect(0, 0, 0, 0), "Send", "Send", new Message(MSG_SEND));
	m_pcStart->GetFont()->SetSize(10);
	pcButtonNode->AddChild(m_pcStart);
	pcButtonNode->AddChild(new HLayoutSpacer("Spacer5", 5, 5));
	m_pcStart->GetPreferredSize (false).y;
	
//add the row of buttons to the vertical layout node	
	pcRootNode->AddChild(new VLayoutSpacer("Spacer6", 10, 10));
	pcRootNode->AddChild(pcButtonNode);
	pcRootNode->AddChild(new VLayoutSpacer("Spacer7", 10, 10));

//add it all to this layout view
	SetRoot(pcRootNode);

//	Menu *mainMenuBar, *tempMenu; 
	mainMenuBar = new Menu( Rect(0,0,0,0), "mainMenuBar", ITEMS_IN_ROW ); 
	mainMenuBar ->SetFrame ( Rect (0, 0, GetBounds().Width() + 1, 18) );

// App menu 
	tempMenu = new Menu( Rect(0,0,0,0), "Application", ITEMS_IN_COLUMN ); 
	tempMenu->AddItem( "Settings", new Message(MSG_SETTINGS)); 
	tempMenu->AddItem("About", new Message(M_MENU_ABO)); 
	tempMenu->AddItem("Quit", new Message(M_MENU_QUIT)); 
	mainMenuBar->AddItem( tempMenu ); 
// File menu 
	tempMenu = new Menu( Rect(0,0,0,0), "Server", ITEMS_IN_COLUMN ); 
	tempMenu->AddItem( "Connect", new Message(M_MENU_CONNECT) ); 
	tempMenu->AddItem( "Login", new Message(M_MENU_LOGIN) ); 
	tempMenu->AddItem( "Disconnect", new Message(M_MENU_DISCONNECT) ); 
	mainMenuBar->AddItem( tempMenu ); 
// Help menu 
	tempMenu = new Menu( Rect(0,0,0,0), "Channel", ITEMS_IN_COLUMN ); 
	tempMenu->AddItem( "Join Channel", new Message(MSG_JOINCHANNEL) ); 	
	tempMenu->AddItem( "Send Message", new Message(MSG_SEND) ); 
	mainMenuBar->AddItem( tempMenu ); 
	AddChild( mainMenuBar ); 
//	mainMenuBar->SetTargetForItems( this ); 
	
	m_CommThread = new CommThread( this );
	m_CommThread->Run();
	
	AddMailbox("MainView");
  
}
示例#2
0
文件: editwin.cpp 项目: PyroOS/Pyro
EditWin::EditWin(const Rect & r, const String& name, Message *pcMsg, Looper *pcParent, const String& id)
	:Window(r, "EditWin", String().Format("%s - %s", name.c_str(),ID_SETTINGS_EDITOR_WINDOW.c_str()), 0, CURRENT_DESKTOP)
{
	Rect bounds = GetBounds();

	m_pcMessage = pcMsg;
	m_cName = name;
	m_cID = id;
	m_nIDCtr = 0;
	m_pcMessenger = new Messenger(pcParent, pcParent);

	int nCount;

	pcMsg->GetNameInfo(name.c_str(), &m_nType, &nCount);


 // --- Root layout node ---------------------------------------------------------

	LayoutNode* pcRoot = new VLayoutNode("pcRoot");
 
 // --- ListView -----------------------------------------------------------------

	m_pcItems = new ListView(Rect(), "m_pcListView", ListView::F_NO_AUTO_SORT|ListView::F_RENDER_BORDER);
	
	m_pcItems->InsertColumn(ID_LISTVIEW_INDEX.c_str(), 50);
	m_pcItems->InsertColumn(ID_LISTVIEW_VALUE.c_str(), 250);

	for(int i = 0; i < nCount; i++) {
		ListViewStringRow *lvs = new ListViewStringRow;
		char bfr[16];
		sprintf(bfr, "%d", i);
		lvs->AppendString(bfr);
		lvs->AppendString(MsgDataToText(name, i, pcMsg));
		sprintf(bfr, "%d", ++m_nIDCtr);	
		lvs->AppendString(bfr);
		m_pcItems->InsertRow(lvs);
	}
	
	m_pcItems->SetInvokeMsg(new Message(ID_EDIT_ITEM));

	pcRoot->AddChild(m_pcItems);

 // --- Buttons ------------------------------------------------------------------

	pcRoot->AddChild(new VLayoutSpacer("ButtonTopSpacer", 8, 8));
	LayoutNode *pcButtons = new HLayoutNode("pcButtons", 0.0f);
	pcButtons->AddChild(new HLayoutSpacer("ButtonLeftSpacer", 8, 8));
 	pcButtons->AddChild(new Button(Rect(), "pcAdd", ID_BUTTON_PLUS, new Message(ID_EDIT_ADD)));
	pcButtons->AddChild(new HLayoutSpacer("ButtonIntermediateSpacer", 8, 8));
 	pcButtons->AddChild(new Button(Rect(), "pcRem", ID_BUTTON_MINUS, new Message(ID_EDIT_DELETE)));
	pcButtons->AddChild(new HLayoutSpacer("ButtonIntermediateSpacer", 0, COORD_MAX));
 	pcButtons->AddChild(new Button(Rect(), "pcSave", ID_BUTTON_SAVE, new Message(ID_EDIT_SAVE)));
	pcButtons->AddChild(new HLayoutSpacer("ButtonIntermediateSpacer", 8, 8));
 	pcButtons->AddChild(new Button(Rect(), "pcCancel", ID_BUTTON_CLOSE, new Message(ID_EDIT_CANCEL)));
	pcButtons->AddChild(new HLayoutSpacer("ButtonRightSpacer", 8, 8));
 	pcButtons->SameWidth("pcSave", "pcCancel", NULL);
 	pcButtons->SameWidth("pcRem", "pcAdd", NULL);
 	pcRoot->AddChild(pcButtons);
	pcRoot->AddChild(new VLayoutSpacer("ButtonBottomSpacer", 8, 8));
	
	AddChild(new LayoutView(bounds, "pcLayout", pcRoot));
}