/*=============================================================================================*\
|	Expand																						|
+-----------------------------------------------------------------------------------------------+
|	Effet: Reduire la view, la fenetre mere et deplacer les autre view si necessaire.			|
\*=============================================================================================*/
void ShrinkView::Expand()
{
	BView * pTempView;	//Utiliser pour parcourir les View attacher a la meme fenetre mere.
	
	//Agradir la View.
	ResizeTo(Frame().Width(), m_fFullHeight);
	m_bShrink = false;

	//Redimentionner la fenetre mere
	if( Window() != NULL )
	{
		Window()->ResizeBy(0, m_fFullHeight - 15.0 );		
	}
	
	//Deplacer, si necessaire, les autre View. 
	pTempView = this;
	while( pTempView->PreviousSibling() != NULL)
	{
		pTempView = pTempView->PreviousSibling();
	}
	while(pTempView != NULL)
	{
		if(Frame().top + 16.0 <= pTempView->Frame().top )
		{	
			pTempView->MoveBy(0, m_fFullHeight - 15.0);
		}
		pTempView = pTempView->NextSibling();
	}
	
	Draw(Bounds());
}//End of Expand.
Exemple #2
0
void MainView::moveSelectedFieldsBy(const BPoint& point)
{
	for(int i = 0; i < selected_fields.CountItems(); i++)
	{
		BView *field = (BView *)selected_fields.ItemAt(i);
		field->MoveBy(point.x, point.y);
	}
	
	sel_bounds.OffsetBy(point);
}
Exemple #3
0
/**
	Resizes a child view (pane) and its sibling.
*/
void SplitView::MoveSplitter(BView *pane, BPoint d)
{
	pane->ResizeBy(d.x, d.y);
	BView *sibling = pane->NextSibling();
	if (sibling) {
		// Don't overlap the next view (a smaller update rect).
		if (d.x > 0 || d.y  > 0)
			sibling->ResizeBy(-d.x, -d.y);
		sibling->MoveBy(d.x, d.y);
		if (d.x < 0 || d.y < 0)
			sibling->ResizeBy(-d.x, -d.y);
	}	
	Draw(Bounds());
}
Exemple #4
0
AddOnListInfo::AddOnListInfo(BRect frame,BView *mother)
: BWindow(frame,"DontWorryWindow",B_BORDERED_WINDOW_LOOK, B_MODAL_SUBSET_WINDOW_FEEL,B_AVOID_FOCUS ),
_motherMessenger(mother)
{
	CPreferences	prefs(PREF_FILE_NAME,PREF_PATH_NAME);
	BRect			listRect = Bounds();
	BScrollView		*scrollinfo;
	BView			*scrollHBar;
	float			scrollHsize;

	_lastClass = NULL;
	_typeRequested = -1;

				
	// initialisees les images
	prefs.Load();
	_classesBitmap = prefs.GetBitmap("classes");
	_metodesBitmap = prefs.GetBitmap("metodes");
	_variablesBitmap = prefs.GetBitmap("variables");
	_privateBitmap = prefs.GetBitmap("private");
	_protectedBitmap = prefs.GetBitmap("protected");
	_virtualBitmap = prefs.GetBitmap("virtual");
	
	listRect.right -= 15;
	listRect.bottom -=15;
	_listOfInfos = new AddOnListView(listRect);
	scrollinfo = new BScrollView("scroll-info",_listOfInfos,B_FOLLOW_ALL_SIDES,0,true,true);
	
	// deplace la scroll bar du bas
	scrollHBar = scrollinfo->FindView("_HSB_");
	scrollHBar->ResizeBy(-70,0);
	scrollHBar->MoveBy(70,0);
	scrollHsize = (scrollHBar->Bounds()).Height()+1;
	
	listRect = scrollinfo->Bounds();
	_progress = new AddOnProgressView(BRect(2,listRect.bottom-scrollHsize,70,listRect.bottom-1));
	scrollinfo->AddChild(_progress);

	AddChild(scrollinfo);
	
	// place le focus sur la liste
	_listOfInfos->MakeFocus(true);
	
	// envoyer le pointer de la fenetre a la vue pour les deplacement
	BMessage	moveMsg(MOVE_WINDOW_PTR);
	
	moveMsg.AddPointer(WINDOW_RESULT_PTR,this);
	_motherMessenger.SendMessage(&moveMsg);
}
Exemple #5
0
void
DCCFileWindow::MessageReceived (BMessage *msg)
{
  switch (msg->what)
  {
    case M_DCC_FILE_WIN:
    {
      BRect bounds (Bounds());
      BPoint point (0.0, 0.0);
      DCCConnect *view;

      if (ChildAt (0))
      {
        point.y = bounds.bottom + 1;
      }
						
      msg->FindPointer ("view", reinterpret_cast<void **>(&view));
      view->MoveTo (point);
      AddChild (view);
      ResizeTo (bounds.Width(), view->Frame().bottom);
      if (IsHidden())
      {
        Show();
      }
    }
    break;

    case M_DCC_FINISH:
    {
      bool success, stopped;

      msg->FindBool ("success", &success);
      msg->FindBool ("stopped", &stopped);

      if (success || stopped)
      {
        BView *view;
        
        msg->FindPointer ("source", reinterpret_cast<void **>(&view));
        
        for (int32 i = 0; i < CountChildren(); ++i)
        {
          BView *child (ChildAt (i));
          
          if (child == view)
          {
            float height (view->Frame().Height());
            RemoveChild (view);
            delete view;
            for (int32 j = i; j < CountChildren(); ++j)
            {
              child = ChildAt (j);
              child->MoveBy (0.0, -(height + 1));
            }
            
            if (CountChildren() == 0)
            {
              BMessenger(this).SendMessage(B_QUIT_REQUESTED);
            }
            else
            {
              ResizeBy (0.0, -(height + 1));
            }
            break;
          }
        }
      }
    }
    break;

    case M_ADD_RESUME_DATA:
    {
      const char *nick (NULL);
      const char *file (NULL);
      const char *port (NULL);
      bool hit (false);
      off_t pos (0);
      
      msg->FindString ("vision:nick", &nick);
      msg->FindString ("vision:file", &file);
      msg->FindString ("vision:port", &port);
      msg->FindInt64  ("vision:pos", &pos);
      
      for (int32 i = 0; i < CountChildren(); ++i)
      {
        DCCSend *view (dynamic_cast<DCCSend *>(ChildAt (i)));
        if (view && view->IsMatch (nick, port))
        {
          view->SetResume (pos);
          hit = true;
          break;
        }
      }
      
      BMessage reply (B_REPLY);
      reply.AddBool ("hit", hit);
      msg->SendReply (&reply);
    }
    break;

    default:
      BWindow::MessageReceived (msg);
  }
}
// SavePanel class
SavePanel::SavePanel(const char* name,
					 BMessenger* target,
					 entry_ref* startDirectory,
					 uint32 nodeFlavors,
					 bool allowMultipleSelection,
					 BMessage* message,
					 BRefFilter* filter,
					 bool modal,
					 bool hideWhenDone)
	: BFilePanel(B_SAVE_PANEL, target, startDirectory,
				 nodeFlavors, allowMultipleSelection,
				 message, filter, modal, hideWhenDone),
	  BHandler(name),
	  fConfigWindow(NULL),
	  fFormatM(NULL),
	  fExportMode(EXPORT_MODE_ICON_RDEF)
{
	BWindow* window = Window();
	if (!window || !window->Lock())
		return;

	window->SetTitle(B_TRANSLATE("Save image"));

	// add this instance as BHandler to the window's looper
	window->AddHandler(this);
	
	// find a couple of important views and mess with their layout
	BView* background = Window()->ChildAt(0);
	BButton* cancel = dynamic_cast<BButton*>(background->FindView("cancel button"));
	BView* textview = background->FindView("text view");
	BScrollBar* hscrollbar = dynamic_cast<BScrollBar*>(background->FindView("HScrollBar"));

	if (!background || !cancel || !textview || !hscrollbar) {
		printf("SavePanel::SavePanel() - couldn't find necessary controls.\n");
		return;
	}

	_BuildMenu();

	BRect rect = textview->Frame();
	rect.top = cancel->Frame().top;
	font_height fh;
	be_plain_font->GetHeight(&fh);
	rect.bottom = rect.top + fh.ascent + fh.descent + 5.0;

	fFormatMF = new BMenuField(rect, "format popup", B_TRANSLATE("Format"),
								fFormatM, true,	
								B_FOLLOW_LEFT | B_FOLLOW_BOTTOM,
								B_WILL_DRAW | B_NAVIGABLE);
	fFormatMF->SetDivider(be_plain_font->StringWidth(
		B_TRANSLATE("Format")) + 7);
	fFormatMF->MenuBar()->ResizeToPreferred();
	fFormatMF->ResizeToPreferred();

	float height = fFormatMF->Bounds().Height() + 8.0;

	// find all the views that are in the way and
	// move up them up the height of the menu field
	BView *poseview = background->FindView("PoseView");
	if (poseview) poseview->ResizeBy(0, -height);
	BButton *insert = (BButton *)background->FindView("default button");
	if (hscrollbar) hscrollbar->MoveBy(0, -height);
	BScrollBar *vscrollbar = (BScrollBar *)background->FindView("VScrollBar");
	if (vscrollbar) vscrollbar->ResizeBy(0, -height);
	BView *countvw = (BView *)background->FindView("CountVw");
	if (countvw) countvw->MoveBy(0, -height);
	textview->MoveBy(0, -height);

#if HAIKU_TARGET_PLATFORM_DANO
	fFormatMF->MoveTo(textview->Frame().left, fFormatMF->Frame().top + 2);
#else
	fFormatMF->MoveTo(textview->Frame().left, fFormatMF->Frame().top);
#endif

	background->AddChild(fFormatMF);

	// Build the "Settings" button relative to the format menu
	rect = cancel->Frame();
	rect.OffsetTo(fFormatMF->Frame().right + 5.0, rect.top);
	fSettingsB = new BButton(rect, "settings", 
							 B_TRANSLATE("Settings"B_UTF8_ELLIPSIS),
							 new BMessage(MSG_SETTINGS),
							 B_FOLLOW_LEFT | B_FOLLOW_BOTTOM,
							 B_WILL_DRAW | B_NAVIGABLE);
	fSettingsB->ResizeToPreferred();
	background->AddChild(fSettingsB);
	fSettingsB->SetTarget(this);

	textview->ResizeTo(fSettingsB->Frame().right - fFormatMF->Frame().left,
					   textview->Frame().Height());

	// Make sure the smallest window won't draw the "Settings" button over anything else
	float minWindowWidth = textview->Bounds().Width()
							+ cancel->Bounds().Width()
							+ (insert ? insert->Bounds().Width() : 0.0)
							+ 90;
	Window()->SetSizeLimits(minWindowWidth, 10000, 250, 10000);
	if (Window()->Bounds().IntegerWidth() + 1 < minWindowWidth)
		Window()->ResizeTo(minWindowWidth, Window()->Bounds().Height());


	window->Unlock();
}
BView *
DefaultMediaTheme::MakeViewFor(BParameterWeb *web, const BRect *hintRect)
{
	CALLED();

	if (web == NULL)
		return NULL;

	BRect rect;
	if (hintRect)
		rect = *hintRect;
		
	BRect bestRect;

	// do we have more than one attached parameter group?
	// if so, use a tabbed view with a tab for each group

	TabView *tabView = NULL;

	if (web->CountGroups() > 1)
		tabView = new TabView(rect, "web");

	rect.OffsetTo(B_ORIGIN);

	for (int32 i = 0; i < web->CountGroups(); i++) {
		BParameterGroup *group = web->GroupAt(i);
		if (group == NULL)
			continue;

		BView *groupView = MakeViewFor(*group, hintRect ? &rect : NULL);
		if (groupView == NULL)
			continue;

		if (GroupView *view = dynamic_cast<GroupView *>(groupView)) {
			// the top-level group views must not be larger than their hintRect,
			// but unlike their children, they should follow all sides when
			// their parent is resized
			if (hintRect != NULL)
				view->ResizeTo(rect.Width() - 10, rect.Height() - 10);
			view->SetResizingMode(B_FOLLOW_ALL);
		}

		if (tabView == NULL) {
			// if we don't need a container to put that view into,
			// we're done here (but the groupView may span over the
			// whole hintRect)
			if (groupView->Frame().LeftTop() == BPoint(5, 5)) {
				// remove insets, as they are not needed
				groupView->MoveBy(-5, -5);
				groupView->ResizeBy(10, 10);
			}

			return new DynamicScrollView(groupView->Name(), groupView);
		}
		
		DynamicScrollView *scrollView = new DynamicScrollView(groupView->Name(), groupView);		
		tabView->AddTab(scrollView);
		
		if (!hintRect) {			
			bestRect = bestRect | scrollView->Bounds();			
		}	
	}
	
	if (tabView != NULL) {		
		// this adjustment must be kept in sync with TabView::FrameResized
		bestRect.bottom += tabView->TabHeight();
		bestRect.InsetBy(-3.0,-3.0);	
		
		tabView->ResizeTo(bestRect.Width(), bestRect.Height());
		tabView->FrameResized(bestRect.Width(), bestRect.Height());
			//needed since we're not attached to a window yet
	}

	return tabView;
}
PrefsWindow::PrefsWindow(uint32 msg) : BWindow(BRect(0, 0, 400, 289), GetString(STR_PREFS_TITLE), B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS), this_messenger(this)
{
	int i;
	ok_message = msg;
	send_quit_on_close = true;
	get_system_info(&sys_info);

	// Move window to right position
	Lock();
	MoveTo(80, 80);

	// Set up menus
	BMenuBar *bar = new BMenuBar(Bounds(), "menu");
	BMenu *menu = new BMenu(GetString(STR_PREFS_MENU));
	menu->AddItem(new BMenuItem(GetString(STR_PREFS_ITEM_ABOUT), new BMessage(B_ABOUT_REQUESTED)));
	menu->AddItem(new BSeparatorItem);
	menu->AddItem(new BMenuItem(GetString(STR_PREFS_ITEM_START), new BMessage(MSG_OK)));
	menu->AddItem(new BMenuItem(GetString(STR_PREFS_ITEM_ZAP_PRAM), new BMessage(MSG_ZAP_PRAM)));
	menu->AddItem(new BSeparatorItem);
	menu->AddItem(new BMenuItem(GetString(STR_PREFS_ITEM_QUIT), new BMessage(MSG_CANCEL), 'Q'));
	bar->AddItem(menu);
	AddChild(bar);
	SetKeyMenuBar(bar);
	int mbar_height = int(bar->Bounds().bottom) + 1;

	// Resize window to fit menu bar
	ResizeBy(0, mbar_height);

	// Light gray background
	BRect b = Bounds();
	top = new BView(BRect(0, mbar_height, b.right, b.bottom), "top", B_FOLLOW_NONE, B_WILL_DRAW);
	AddChild(top);
	top->SetViewColor(fill_color);
	top_frame = top->Bounds();

	// Create panes
	panes[0] = create_volumes_pane();
	panes[1] = create_graphics_pane();
	panes[2] = create_serial_pane();
	panes[3] = create_memory_pane();

	// Prefs item tab view
	pane_tabs = new BTabView(BRect(10, 10, top_frame.right-10, top_frame.bottom-50), "items", B_WIDTH_FROM_LABEL);
	for (i=0; i<NUM_PANES; i++)
		pane_tabs->AddTab(panes[i]);
	top->AddChild(pane_tabs);

	volume_list->Select(0);

	// Create volume file panels
	add_volume_panel = new BFilePanel(B_OPEN_PANEL, &this_messenger, NULL, B_FILE_NODE | B_DIRECTORY_NODE, false, new BMessage(MSG_ADD_VOLUME_PANEL));
	add_volume_panel->SetButtonLabel(B_DEFAULT_BUTTON, GetString(STR_ADD_VOLUME_PANEL_BUTTON));
	add_volume_panel->Window()->SetTitle(GetString(STR_ADD_VOLUME_TITLE));
	create_volume_panel = new BFilePanel(B_SAVE_PANEL, &this_messenger, NULL, B_FILE_NODE | B_DIRECTORY_NODE, false, new BMessage(MSG_CREATE_VOLUME_PANEL));
	create_volume_panel->SetButtonLabel(B_DEFAULT_BUTTON, GetString(STR_CREATE_VOLUME_PANEL_BUTTON));
	create_volume_panel->Window()->SetTitle(GetString(STR_CREATE_VOLUME_TITLE));

	create_volume_panel->Window()->Lock();
	BView *background = create_volume_panel->Window()->ChildAt(0);
	background->FindView("PoseView")->ResizeBy(0, -30);
	background->FindView("VScrollBar")->ResizeBy(0, -30);
	background->FindView("CountVw")->MoveBy(0, -30);
	BView *v = background->FindView("HScrollBar");
	if (v)
		v->MoveBy(0, -30);
	else {
		i = 0;
		while ((v = background->ChildAt(i++)) != NULL) {
			if (v->Name() == NULL || v->Name()[0] == 0) {
				v->MoveBy(0, -30);	// unnamed horizontal scroll bar
				break;
			}
		}
	}
	BView *filename = background->FindView("text view");
	BRect fnr(filename->Frame());
	fnr.OffsetBy(0, -30);
	NumberControl *nc = new NumberControl(fnr, 80, "hardfile_size", GetString(STR_HARDFILE_SIZE_CTRL), 40, NULL);
	background->AddChild(nc);
	create_volume_panel->Window()->Unlock();

	// "Start" button
	BButton *button = new BButton(BRect(20, top_frame.bottom-35, 90, top_frame.bottom-10), "start", GetString(STR_START_BUTTON), new BMessage(MSG_OK));
	top->AddChild(button);
	SetDefaultButton(button);

	// "Quit" button
	top->AddChild(new BButton(BRect(top_frame.right-90, top_frame.bottom-35, top_frame.right-20, top_frame.bottom-10), "cancel", GetString(STR_QUIT_BUTTON), new BMessage(MSG_CANCEL)));

	Unlock();
	Show();
}
// Private function to add the config view of the currently
// selected output format to our window
void
OutputFormatView::AddConfigView()
{
	the_window->Lock();
	// Remove the window size limits,
	// so we are free to do whatever we like
	the_window->SetSizeLimits(0.0, 32767.0, 0.0, 32767.0);
	// The current views must stay put while we resize
	// the window to make room for the config view
	MakeFollowBottom(false);

	// Remove the old config view if there is one
	if (config_view)
	{
		RemoveChild(config_view);
		delete config_view;
		config_view = 0;
	}

	BRect config_rect;
	if (the_roster->MakeConfigurationView(
	    	output_list[index].translator,
	    	0,
	    	&config_view,
	    	&config_rect) == B_NO_ERROR &&
	    config_view != 0)
	{
		// Create a caption for the config view
		// if there wasn't one already
		if (!config_caption)
		{
			config_caption = new CaptionView(
				BRect(8.0, info_view->Frame().bottom + 1.0, Bounds().right - 8.0, 0.0),
				"config caption",
				StringsRsrc[STR_TRANSLATOR_SETTINGS]);
			config_caption->SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
			AddChild(config_caption);
		}

		// Move the config view to just below the config caption
		config_view->MoveBy(
			16.0 - config_view->Frame().left,
			config_caption->Frame().bottom + 1.0 - config_view->Frame().top);

		// Colour it gray
		config_view->SetViewColor(222, 222, 222);
		config_view->SetLowColor(222, 222, 222);

		// First resize the window so that the config view will fit,
		// otherwise the config view may want to change with us
		float width_diff = config_view->Frame().right + 16.0 - Bounds().Width();
		the_window->ResizeTo(
			Bounds().Width() + (width_diff > 0.0 ? width_diff : 0.0),
			config_view->Frame().bottom + 8.0);

		// Add it to the main view
		AddChild(config_view);

		// Make the config_view and its children follow the bottom of the window
		RecursiveSetMode(config_view);
	}
	else
	{
		// This translator doesn't have a config view
		if (config_caption)
		{
			RemoveChild(config_caption);
			delete config_caption;
			config_caption = 0;
		}
		the_window->ResizeTo(Bounds().right, info_view->Frame().bottom + 8.0);
	}

	// Make all views follow the bottom of the window again
	MakeFollowBottom();

	// Set the window's minimum size
	float min_width = (config_view ? config_view->Frame().right : 200.0);
	if (min_width < 200.0)
		min_width = 200.0;
	the_window->SetSizeLimits(
		min_width,
		32767.0,
		Bounds().Height() - scroll_view->Bounds().Height() + 50.0,
		32767.0);

	the_window->Unlock();
}