Пример #1
0
static void SetSelected(struct AHIAudioModeRequesterExt *req, BOOL all)
{
  LONG sliderlevels,sliderlevel,selected;

  if(all)
  {
    //Set listview
    selected=GetSelected(req);
      GT_SetGadgetAttrs(req->listviewgadget, req->Window, NULL,
          ((selected == ~0) || (GadToolsBase->lib_Version >= 39) ? TAG_IGNORE : GTLV_Top),selected,
          (selected == ~0 ? TAG_IGNORE : GTLV_MakeVisible),selected,
          GTLV_Selected,selected,
          TAG_DONE);
  }

  //Set slider
  GetSliderAttrs(req,&sliderlevels,&sliderlevel);
  GT_SetGadgetAttrs(req->slidergadget, req->Window, NULL,
      GTSL_Max,sliderlevels-1,
      GTSL_Level, sliderlevel,
      GA_Disabled,!sliderlevels || (req->tempAudioID == AHI_DEFAULT_ID),
      TAG_DONE);

  UpdateInfoWindow(req);
}
Пример #2
0
static void SetSelected(struct AHIAudioModeRequesterExt *req, BOOL all)
{
  LONG  sliderlevels,sliderlevel,selected;
  BOOL  disabled    = FALSE;
  ULONG top         = GTLV_Top;
  ULONG makevisible = GTLV_MakeVisible;

  if(all)
  {
    //Set listview
    selected=GetSelected(req);

    if( selected == ~0 || GadToolsBase->lib_Version >= 39 )
    {
      top = TAG_IGNORE;
    }

    if( selected == ~0 )
    {
      makevisible = TAG_IGNORE;
    }

    GT_SetGadgetAttrs(req->listviewgadget, req->Window, NULL,
        top,           selected,
        makevisible,   selected,
        GTLV_Selected, selected,
        TAG_DONE);
  }

  //Set slider
  GetSliderAttrs(req,&sliderlevels,&sliderlevel);

  if( sliderlevels == 0 || req->tempAudioID == AHI_DEFAULT_ID )
  {
    disabled = TRUE;
  }

  GT_SetGadgetAttrs(req->slidergadget, req->Window, NULL,
      GTSL_Max,    sliderlevels-1,
      GTSL_Level,  sliderlevel,
      GA_Disabled, disabled,
      TAG_DONE);

  UpdateInfoWindow(req);
}
Пример #3
0
void
ImageView::SetImage(BMessage *pmsg)
{
	// Replace current image with the image
	// specified in the given BMessage

	entry_ref ref;
	if (!pmsg)
		ref = fcurrentRef;
	else if (pmsg->FindRef("refs", &ref) != B_OK)
		// If refs not found, just ignore the message
		return;

	StatusCheck chk;

	try {
		BFile file(&ref, B_READ_ONLY);
		chk = file.InitCheck();

		BTranslatorRoster roster, *proster;
		proster = SelectTranslatorRoster(roster);
		if (!proster)
			// throw exception
			chk = B_ERROR;
		// determine what type the image is
		translator_info tinfo;
		BMessage ioExtension;
		if (ref != fcurrentRef)
			// if new image, reset to first document
			fdocumentIndex = 1;
		chk = ioExtension.AddInt32("/documentIndex", fdocumentIndex);
		chk = proster->Identify(&file, &ioExtension, &tinfo, 0, NULL,
			B_TRANSLATOR_BITMAP);

		// perform the actual translation
		BBitmapStream outstream;
		chk = proster->Translate(&file, &tinfo, &ioExtension, &outstream,
			B_TRANSLATOR_BITMAP);
		BBitmap *pbitmap = NULL;
		chk = outstream.DetachBitmap(&pbitmap);
		delete fpbitmap;
		fpbitmap = pbitmap;
		pbitmap = NULL;
		fcurrentRef = ref;
			// need to keep the ref around if user wants to switch pages
		int32 documentCount = 0;
		if (ioExtension.FindInt32("/documentCount", &documentCount) == B_OK &&
			documentCount > 0)
			fdocumentCount = documentCount;
		else
			fdocumentCount = 1;

		// Set the name of the Window to reflect the file name
		BWindow *pwin = Window();
		BEntry entry(&ref);
		BPath path;
		if (entry.InitCheck() == B_OK) {
			if (path.SetTo(&entry) == B_OK)
				pwin->SetTitle(path.Leaf());
			else
				pwin->SetTitle(IMAGEWINDOW_TITLE);
		} else
			pwin->SetTitle(IMAGEWINDOW_TITLE);
		UpdateInfoWindow(path, ioExtension, tinfo, proster);

		// Resize parent window and set size limits to
		// reflect the size of the new bitmap
		float width, height;
		BMenuBar *pbar = pwin->KeyMenuBar();
		width = fpbitmap->Bounds().Width() + B_V_SCROLL_BAR_WIDTH + (BORDER_WIDTH * 2);
		height = fpbitmap->Bounds().Height() +
			pbar->Bounds().Height() + B_H_SCROLL_BAR_HEIGHT + (BORDER_HEIGHT * 2) + 1;
		BScreen *pscreen = new BScreen(pwin);
		BRect rctscreen = pscreen->Frame();
		if (width > rctscreen.Width())
			width = rctscreen.Width();
		if (height > rctscreen.Height())
			height = rctscreen.Height();
		pwin->SetSizeLimits(B_V_SCROLL_BAR_WIDTH * 4, width,
			pbar->Bounds().Height() + (B_H_SCROLL_BAR_HEIGHT * 4) + 1, height);
		pwin->SetZoomLimits(width, height);
		AdjustScrollBars();

		//pwin->Zoom();
			// Perform all of the hard work of resizing the
			// window while taking into account the size of
			// the screen, the tab and borders of the window
			//
			// HACK: Need to fix case where window un-zooms
			// when the window is already the correct size
			// for the current image

		// repaint view
		Invalidate();

	} catch (StatusNotOKException) {
		BAlert *palert = new BAlert(NULL,
			B_TRANSLATE("Sorry, unable to load the image."),
			B_TRANSLATE("OK"));
		palert->Go();
	}
}