void PolycodeTextEditor::hideFindBar() {
	findBar->visible = false;
	focusChild(textInput);
	Resize(editorSize.x, editorSize.y);
}
Exemple #2
0
void CMaps::Clear()
{
	Resize(m_nWidth, m_nHeight);
}
 DefHist(int BinNum=0)
 {
     m_pHist = NULL;
     m_HistVolume = 0;
     Resize(BinNum);
 }
void CUITrackPopup::Render()
{
	if( !IsVisible() ) return;
	if( m_vecString.size() <= 0 ) return;

	CDrawPort* pDrawPort = CUIManager::getSingleton()->GetDrawPort();

#if defined G_RUSSIA
	// [2011/05/17 : Sora] 팝업창에서 스트링을 쓰지 않을 경우 글자 길이가 0이되어 팝업창 사이즈가 줄어든다
	if( m_strLongestStringInMenu.Length() > 0 )
	{
		Resize( pDrawPort->GetTextWidth( m_strLongestStringInMenu ) );		
	}
#endif

	// 배경 렌더
	int	nX, nY;
	UIRect m_rcBack;

	GetAbsPos( nX, nY );
	m_rcBack.SetRect( nX, nY, nX + m_nWidth, nY + m_nHeight );

	// Item Back region
	pDrawPort->AddTexture( m_rcBack.Left, m_rcBack.Top,
										m_rcBack.Left + 7, m_rcBack.Top + 7,
										m_rtBackUL.U0, m_rtBackUL.V0, m_rtBackUL.U1, m_rtBackUL.V1,
										0xFFFFFFFF );
	pDrawPort->AddTexture( m_rcBack.Left + 7, m_rcBack.Top,
										m_rcBack.Right - 7, m_rcBack.Top + 7,
										m_rtBackUM.U0, m_rtBackUM.V0, m_rtBackUM.U1, m_rtBackUM.V1,
										0xFFFFFFFF );
	pDrawPort->AddTexture( m_rcBack.Right - 7, m_rcBack.Top,
										m_rcBack.Right, m_rcBack.Top + 7,
										m_rtBackUR.U0, m_rtBackUR.V0, m_rtBackUR.U1, m_rtBackUR.V1,
										0xFFFFFFFF );
	pDrawPort->AddTexture( m_rcBack.Left, m_rcBack.Top + 7,
										m_rcBack.Left + 7, m_rcBack.Bottom - 7,
										m_rtBackML.U0, m_rtBackML.V0, m_rtBackML.U1, m_rtBackML.V1,
										0xFFFFFFFF );
	pDrawPort->AddTexture( m_rcBack.Left + 7, m_rcBack.Top + 7,
										m_rcBack.Right - 7, m_rcBack.Bottom - 7,
										m_rtBackMM.U0, m_rtBackMM.V0, m_rtBackMM.U1, m_rtBackMM.V1,
										0xFFFFFFFF );
	pDrawPort->AddTexture( m_rcBack.Right - 7, m_rcBack.Top + 7,
										m_rcBack.Right, m_rcBack.Bottom - 7,
										m_rtBackMR.U0, m_rtBackMR.V0, m_rtBackMR.U1, m_rtBackMR.V1,
										0xFFFFFFFF );
	pDrawPort->AddTexture( m_rcBack.Left, m_rcBack.Bottom - 7,
										m_rcBack.Left + 7, m_rcBack.Bottom,
										m_rtBackLL.U0, m_rtBackLL.V0, m_rtBackLL.U1, m_rtBackLL.V1,
										0xFFFFFFFF );
	pDrawPort->AddTexture( m_rcBack.Left + 7, m_rcBack.Bottom - 7,
										m_rcBack.Right - 7, m_rcBack.Bottom,
										m_rtBackLM.U0, m_rtBackLM.V0, m_rtBackLM.U1, m_rtBackLM.V1,
										0xFFFFFFFF );
	pDrawPort->AddTexture( m_rcBack.Right - 7, m_rcBack.Bottom - 7,
										m_rcBack.Right, m_rcBack.Bottom,
										m_rtBackLR.U0, m_rtBackLR.V0, m_rtBackLR.U1, m_rtBackLR.V1,
										0xFFFFFFFF );

	// 원래 리스트 박스에 대한 내용 랜더
	CUIListBox::Render();
	
}
Exemple #5
0
bool
TopWindow::OnEvent(const Event &event)
{
  switch (event.type) {
    Window *w;

  case Event::NOP:
  case Event::TIMER:
  case Event::USER:
  case Event::CALLBACK:
    break;

  case Event::CLOSE:
    OnClose();
    break;

  case Event::KEY_DOWN:
    w = GetFocusedWindow();
    if (w == nullptr)
      w = this;

    return w->OnKeyDown(event.param);

  case Event::KEY_UP:
    w = GetFocusedWindow();
    if (w == nullptr)
      w = this;

    return w->OnKeyUp(event.param);

  case Event::MOUSE_MOTION:
#ifdef DRAW_MOUSE_CURSOR
    /* redraw to update the mouse cursor position */
    Invalidate();
#endif

    // XXX keys
    return OnMouseMove(event.point.x, event.point.y, 0);

  case Event::MOUSE_DOWN:
    return double_click.Check(event.point)
      ? OnMouseDouble(event.point.x, event.point.y)
      : OnMouseDown(event.point.x, event.point.y);

  case Event::MOUSE_UP:
    double_click.Moved(event.point);

    return OnMouseUp(event.point.x, event.point.y);

  case Event::MOUSE_WHEEL:
    return OnMouseWheel(event.point.x, event.point.y, (int)event.param);

#ifdef USE_X11
  case Event::RESIZE:
    if (unsigned(event.point.x) == GetWidth() &&
        unsigned(event.point.y) == GetHeight())
      /* no-op */
      return true;

    Resize(event.point.x, event.point.y);
    return true;

  case Event::EXPOSE:
    Invalidate();
    return true;
#endif
  }

  return false;
}
Exemple #6
0
void TVector::Add(GObject&e){
	Resize(1);
	*arr[size-1]=e;
}
cv::Mat ColorDiscriminator::LoadImage(const ImagePath& img_path) {
  cv::Mat img_orig_size = ImageLoader::instance().LoadImage(img_path);
  return Resize(img_orig_size, kResizeFactor);
}
Exemple #8
0
template<class TA> void DynObjArray_cl<TA>::operator=(const DynObjArray_cl<TA> &copyArray)
{
  Resize(copyArray.size);
  for (unsigned int i = 0; i < copyArray.size; i++)
    data[i] = copyArray.data[i];
}
Exemple #9
0
template<class TA> void DynObjArray_cl<TA>::AdjustSize()
{
  Resize(GetValidSize());
}
Exemple #10
0
template<class TA> void DynArray_cl<TA>::EnsureSize(unsigned int minSize)
{
  if (minSize>size) 
    Resize(minSize);
}
Exemple #11
0
 /// \brief
 ///   Ensures that the array has at least minSize elements. Resizes the array if necessary.
 inline void EnsureSize(unsigned int minSize) {if (minSize>size) Resize(minSize);}
Exemple #12
0
KVFileDialog::KVFileDialog(const TGWindow *p, const TGWindow *main,
                           EKVFileDialogMode dlg_type, TGFileInfo *file_info) :
   TGTransientFrame(p, main, 10, 10, kVerticalFrame)
{
   // Create a file selection dialog. Depending on the dlg_type it can be
   // used for opening or saving a file or selecting a directory.

   fDlgMode=dlg_type;
   SetCleanup(kDeepCleanup);
   Connect("CloseWindow()", "KVFileDialog", this, "CloseWindow()");
   DontCallClose();

   int i;

   if (!p && !main) {
      MakeZombie();
      return;
   }
   if (!file_info) {
      Error("KVFileDialog", "file_info argument not set");
      fFileInfo = &gInfo;
      if (fFileInfo->fIniDir) {
         delete [] fFileInfo->fIniDir;
         fFileInfo->fIniDir = 0;
      }
      if (fFileInfo->fFilename) {
         delete [] fFileInfo->fFilename;
         fFileInfo->fFilename = 0;
      }
      fFileInfo->fFileTypeIdx = 0;
   } else
      fFileInfo = file_info;

   if (!fFileInfo->fFileTypes)
      fFileInfo->fFileTypes = gDefTypes;

   if (!fFileInfo->fIniDir)
      fFileInfo->fIniDir = StrDup(".");

   TGHorizontalFrame *fHtop = new TGHorizontalFrame(this, 10, 10);
   
   //--- top toolbar elements
   TGLabel *fLookin = new TGLabel(fHtop, new TGHotString((dlg_type == kKVFDSave)
                                                  ? "S&ave in:" : "&Look in:"));
   fTreeLB = new TGFSComboBox(fHtop, kIDF_FSLB);
   fTreeLB->Associate(this);

   fPcdup = fClient->GetPicture("tb_uplevel.xpm");
   fPnewf = fClient->GetPicture("tb_newfolder.xpm");
   fPlist = fClient->GetPicture("tb_list.xpm");
   fPdetails = fClient->GetPicture("tb_details.xpm");

   if (!(fPcdup && fPnewf && fPlist && fPdetails))
      Error("KVFileDialog", "missing toolbar pixmap(s).\n");

   fCdup    = new TGPictureButton(fHtop, fPcdup, kIDF_CDUP);
   fNewf    = new TGPictureButton(fHtop, fPnewf, kIDF_NEW_FOLDER);
   fList    = new TGPictureButton(fHtop, fPlist, kIDF_LIST);
   fDetails = new TGPictureButton(fHtop, fPdetails, kIDF_DETAILS);

   fCdup->SetStyle(gClient->GetStyle());
   fNewf->SetStyle(gClient->GetStyle());
   fList->SetStyle(gClient->GetStyle());
   fDetails->SetStyle(gClient->GetStyle());

   fCdup->SetToolTipText("Up One Level");
   fNewf->SetToolTipText("Create New Folder");
   fList->SetToolTipText("List");
   fDetails->SetToolTipText("Details");

   fCdup->Associate(this);
   fNewf->Associate(this);
   fList->Associate(this);
   fDetails->Associate(this);

   fList->AllowStayDown(kTRUE);
   fDetails->AllowStayDown(kTRUE);

   fTreeLB->Resize(200, fTreeLB->GetDefaultHeight());

   fHtop->AddFrame(fLookin, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 5, 2, 2));
   fHtop->AddFrame(fTreeLB, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 3, 0, 2, 2));
   fHtop->AddFrame(fCdup, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 2, 2));
   fHtop->AddFrame(fNewf, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 2, 2));
   fHtop->AddFrame(fList, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 2, 2));
   fHtop->AddFrame(fDetails, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 0, 8, 2, 2));

   if (dlg_type == kKVFDSave) {
      fCheckB = new TGCheckButton(fHtop, "&Overwrite", kIDF_CHECKB);
      fCheckB->SetToolTipText("Overwrite a file without displaying a message if selected");
   } else {
      fCheckB = new TGCheckButton(fHtop, "&Multiple files", kIDF_CHECKB);
      fCheckB->SetToolTipText("Allows multiple file selection when SHIFT is pressed");
      fCheckB->Connect("Toggled(Bool_t)","TGFileInfo",fFileInfo,"SetMultipleSelection(Bool_t)");
   }
   fHtop->AddFrame(fCheckB, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
   fCheckB->SetOn(fFileInfo->fMultipleSelection);
   AddFrame(fHtop, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 4, 4, 3, 1));

   //--- file view

   fFv = new TGListView(this, 400, 161);

   fFc = new TGFileContainer(fFv->GetViewPort(),
                             10, 10, kHorizontalFrame, fgWhitePixel);
   fFc->Associate(this);

   fFv->GetViewPort()->SetBackgroundColor(fgWhitePixel);
   fFv->SetContainer(fFc);
   fFv->SetViewMode(kLVList);
   fFv->SetIncrements(1, 19); // set vertical scroll one line height at a time

   TGTextButton** buttons = fFv->GetHeaderButtons();
   if (buttons) {
      buttons[0]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByName)");
      buttons[1]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByType)");
      buttons[2]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortBySize)");
      buttons[3]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByOwner)");
      buttons[4]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByGroup)");
      buttons[5]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByDate)");
   }

   fFc->SetFilter(fFileInfo->fFileTypes[fFileInfo->fFileTypeIdx+1]);
   fFc->Sort(kSortByName);
   fFc->ChangeDirectory(fFileInfo->fIniDir);
   fFc->SetMultipleSelection(fFileInfo->fMultipleSelection);
   fTreeLB->Update(fFc->GetDirectory());

   fList->SetState(kButtonEngaged);

   AddFrame(fFv, new TGLayoutHints(kLHintsTop | kLHintsExpandX | kLHintsExpandY, 4, 4, 3, 1));

   if (dlg_type == kKVFDOpen) {
      fCheckB->Connect("Toggled(Bool_t)","TGFileContainer",fFc,"SetMultipleSelection(Bool_t)");
      fCheckB->Connect("Toggled(Bool_t)","TGFileContainer",fFc,"UnSelectAll()");
   }
   
   //--- file name and types

   TGHorizontalFrame *fHf = new TGHorizontalFrame(this, 10, 10);

   TGVerticalFrame *fVf = new TGVerticalFrame(fHf, 10, 10);

   TGHorizontalFrame *fHfname = new TGHorizontalFrame(fVf, 10, 10);

   TGLabel *fLfname = new TGLabel(fHfname, new TGHotString("File &name:"));
   fTbfname = new TGTextBuffer(1034);
   fName = new TGTextEntry(fHfname, fTbfname);
   fName->Resize(230, fName->GetDefaultHeight());
   fName->Associate(this);

   fHfname->AddFrame(fLfname, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 5, 2, 2));
   fHfname->AddFrame(fName, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 0, 20, 2, 2));

   fVf->AddFrame(fHfname, new TGLayoutHints(kLHintsLeft | kLHintsCenterY | kLHintsExpandX));

   TGHorizontalFrame *fHftype = new TGHorizontalFrame(fVf, 10, 10);

   TGLabel *fLftypes = new TGLabel(fHftype, new TGHotString("Files of &type:"));
   fTypes = new TGComboBox(fHftype, kIDF_FTYPESLB);
   fTypes->Associate(this);
   fTypes->Resize(230, fName->GetDefaultHeight());

   TString s;
   for (i = 0; fFileInfo->fFileTypes[i] != 0; i += 2) {
      s.Form("%s (%s)", fFileInfo->fFileTypes[i], fFileInfo->fFileTypes[i+1]);
      fTypes->AddEntry(s.Data(), i);
   }
   fTypes->Select(fFileInfo->fFileTypeIdx);

   // Show all items in combobox without scrollbar
   //TGDimension fw = fTypes->GetListBox()->GetContainer()->GetDefaultSize();
   //fTypes->GetListBox()->Resize(fw.fWidth, fw.fHeight);

   if (fFileInfo->fFilename && fFileInfo->fFilename[0])
      fTbfname->AddText(0, fFileInfo->fFilename);
   else
      fTbfname->Clear();

   fTypes->GetListBox()->Resize(230, 120);
   fHftype->AddFrame(fLftypes, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 5, 2, 2));
   fHftype->AddFrame(fTypes, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 0, 20, 2, 2));

   fVf->AddFrame(fHftype, new TGLayoutHints(kLHintsLeft | kLHintsCenterY | kLHintsExpandX));

   fHf->AddFrame(fVf, new TGLayoutHints(kLHintsLeft | kLHintsCenterY | kLHintsExpandX));

   //--- Open/Save and Cancel buttons

   TGVerticalFrame *fVbf = new TGVerticalFrame(fHf, 10, 10, kFixedWidth);

   fOk = new TGTextButton(fVbf, new TGHotString((dlg_type == kKVFDSave)
                                                 ? "&Save" : "&Open"), kIDF_OK);
   fCancel = new TGTextButton(fVbf, new TGHotString("Cancel"), kIDF_CANCEL);

   fOk->Associate(this);
   fCancel->Associate(this);

   fVbf->AddFrame(fOk, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 2, 2));
   fVbf->AddFrame(fCancel, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 2, 2));

   UInt_t width = TMath::Max(fOk->GetDefaultWidth(), fCancel->GetDefaultWidth()) + 20;
   fVbf->Resize(width + 20, fVbf->GetDefaultHeight());

   fHf->AddFrame(fVbf, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));

   AddFrame(fHf, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 4, 4, 3, 1));
   SetEditDisabled(kEditDisable);

   MapSubwindows();

   TGDimension size = GetDefaultSize();

   Resize(size);

   //---- position relative to the parent's window

   CenterOnParent();

   //---- make the message box non-resizable

   SetWMSize(size.fWidth, size.fHeight);
   SetWMSizeHints(size.fWidth, size.fHeight, 10000, 10000, 1, 1);

   const char *wname = ((dlg_type == kKVFDSave) ? "Save As..." : (dlg_type==kKVFDOpen) ? "Open" : "Choose directory...");
   SetWindowName(wname);
   SetIconName(wname);
   SetClassHints("FileDialog", "FileDialog");

   SetMWMHints(kMWMDecorAll | kMWMDecorResizeH  | kMWMDecorMaximize |
                              kMWMDecorMinimize | kMWMDecorMenu,
               kMWMFuncAll |  kMWMFuncResize    | kMWMFuncMaximize |
                              kMWMFuncMinimize,
               kMWMInputModeless);

   MapWindow();
   fFc->DisplayDirectory();
   fClient->WaitFor(this);
}
Exemple #13
0
void format_disk(void)
{
  if (force_f != YES && conf->open_files)
    fatal("Files open on drive");

  if (force_f != YES && f.removable == OFF
   && ((defined_format & REMOVABLE) == 0 || newf.removable == OFF))
  {
    changed_format = defined_format; /* Only for format_f */
    if (format_f || reconfig_f)
    {
      fatal("Changes requested for nonremovable drive");
    }
  }

  /* fill new format structure and check for changes */
  return_val = make_newf();
  if (return_val) {
    /* Could not make the disk as requested */
    if (return_val == ERRL_BADFORMAT)
      return_msg = "Aborted: Impossible format for disk";
    else if (return_val == ERRL_NOMEM)
      return_msg = "Aborted: Not enough memory for the disk";
    if (disk_bad) {
      warning("Impossible format for disk - restoring old format");
      memcpy(&newf, &f, sizeof f);
      WriteNewFormat();
    }
    return;
  }

  if (!disk_bad && !format_f && !reconfig_f) {
    if (!changed_format) {
      if (verbose > 0)
        warning("No change in format - disk remains untouched");
    }
    else {
      if (changed_format & WRITE_PROTECTION)
        set_write_protect();
      if (changed_format & REMOVABLE)
        set_fixed();
      if (changed_format & MAX_PART_SIZES) {
        if (f.size) {
          if (!SavingDiskAllocate(f.sectors))
            error("Failed to rearrange memory");
        }
        else
          ConfigMaxAlloc();
      }
    }
    return;
  }

  /* If Disk will be disabled */
  /* !!!! Move this before the code to adjust parameterf for resize */
  if (!newf.size) {
    if (!f.size) {
      /* If was disabled also before */
      configure_drive();
      if (verbose > 1)
        printf("New configuration saved for later use\n");
    } else {
      /* If disk now get's disabled */
      if (!licence_to_kill()) {
        return_val = ERRL_NO_LICENCE;
        return;
      }
      disable_disk();
    }
    return;
  }

  if (format_f || disk_bad) {
    if (!data_on_disk)
      WriteNewFormat();
    else
      Resize();
  }
  else if (reconfig_f) {
    ReConfig();
    if (f.size)
      RefreshBootSector();
    if (verbose > 1)
      printf("Drive %c: reconfigured\n", drive);
  }
}
Exemple #14
0
status_t
Inode::WriteAt(Transaction& transaction, off_t pos, const uint8* buffer,
	size_t* _length)
{
	TRACE("Inode::WriteAt(%lld, %p, *(%p) = %ld)\n", pos, buffer,
		_length, *_length);
	ReadLocker readLocker(fLock);

	if (IsFileCacheDisabled())
		return B_BAD_VALUE;

	if (pos < 0)
		return B_BAD_VALUE;

	readLocker.Unlock();

	TRACE("Inode::WriteAt(): Starting transaction\n");
	transaction.Start(fVolume->GetJournal());

	WriteLocker writeLocker(fLock);

	TRACE("Inode::WriteAt(): Updating modification time\n");
	struct timespec timespec;
	_BigtimeToTimespec(real_time_clock_usecs(), &timespec);
	SetModificationTime(&timespec);

	// NOTE: Debugging info to find why sometimes resize doesn't happen
	size_t length = *_length;
#ifdef TRACE_EXT2
	off_t oldEnd = pos + length;
	TRACE("Inode::WriteAt(): Old calc for end? %x:%x\n",
		(int)(oldEnd >> 32), (int)(oldEnd & 0xFFFFFFFF));
#endif

	off_t end = pos + (off_t)length;
	off_t oldSize = Size();

	TRACE("Inode::WriteAt(): Old size: %x:%x, new size: %x:%x\n",
		(int)(oldSize >> 32), (int)(oldSize & 0xFFFFFFFF),
		(int)(end >> 32), (int)(end & 0xFFFFFFFF));

	if (end > oldSize) {
		status_t status = Resize(transaction, end);
		if (status != B_OK) {
			*_length = 0;
			WriteLockInTransaction(transaction);
			return status;
		}

		status = WriteBack(transaction);
		if (status != B_OK) {
			*_length = 0;
			WriteLockInTransaction(transaction);
			return status;
		}
	}

	writeLocker.Unlock();

	if (oldSize < pos)
		FillGapWithZeros(oldSize, pos);

	if (length == 0) {
		// Probably just changed the file size with the pos parameter
		return B_OK;
	}

	TRACE("Inode::WriteAt(): Performing write: %p, %lld, %p, %ld\n",
		FileCache(), pos, buffer, *_length);
	status_t status = file_cache_write(FileCache(), NULL, pos, buffer, _length);

	WriteLockInTransaction(transaction);

	TRACE("Inode::WriteAt(): Done\n");

	return status;
}
Exemple #15
0
INT_PTR KBIntDialog::OnInitDialog() {
	//TODO: fix the tab order
	const char * name = ssh_userauth_kbdint_getname(m_session);
	if (!name)
		name = "";
	::SetDlgItemTextA(m_hwnd, IDC_STATIC_NAMEFIELD, name);

	if (m_nrPrompt > 1) {	//for each prompt, clone prompt and input fields

		HWND hPrompt1 = ::GetDlgItem(m_hwnd, IDC_EDIT_PROMPT1);
		HWND hAnswer1 = ::GetDlgItem(m_hwnd, IDC_EDIT_ANSWER1);
		HWND hMarker = ::GetDlgItem(m_hwnd, IDC_STATIC_MARKER);
		RECT promptRect;
		RECT answerRect;
		RECT markerRect;
		::GetWindowRect(hPrompt1, &promptRect);
		ScreenRectToClient(m_hwnd, &promptRect);
		::GetWindowRect(hAnswer1, &answerRect);
		ScreenRectToClient(m_hwnd, &answerRect);
		::GetWindowRect(hMarker, &markerRect);
		ScreenRectToClient(m_hwnd, &markerRect);

		int deltaY = markerRect.top - promptRect.top;
		//int deltaX = 0;	//unused


		int curPromptID = IDC_EDIT_PROMPT1;
		int curAnswerID = IDC_EDIT_ANSWER1;

		for(int i = 1; i < m_nrPrompt; i++) {
			curPromptID = curPromptID+2;
			curAnswerID = curAnswerID+2;

			promptRect.top += deltaY;
			promptRect.bottom += deltaY;
			answerRect.top += deltaY;
			answerRect.bottom += deltaY;

			::CreateWindowEx(0, WC_EDIT, TEXT(""),
							WS_CHILD | WS_VSCROLL | ES_AUTOHSCROLL | ES_MULTILINE | ES_READONLY | WS_VISIBLE,
							promptRect.left, promptRect.top, promptRect.right-promptRect.left, promptRect.bottom-promptRect.top,
							m_hwnd, (HMENU)curPromptID, m_hInstance, NULL);

			::CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, TEXT(""),
							WS_CHILD | WS_BORDER | ES_AUTOHSCROLL | WS_VISIBLE,
							answerRect.left, answerRect.top, answerRect.right-answerRect.left, answerRect.bottom-answerRect.top,
							m_hwnd, (HMENU)curPromptID, m_hInstance, NULL);
		}

		int totalDeltaY = deltaY * (m_nrPrompt-1);

		HWND hBtnOK = ::GetDlgItem(m_hwnd, IDOK);
		HWND hBtnCancel = ::GetDlgItem(m_hwnd, IDCANCEL);
		RECT btnRect;
		::GetWindowRect(hBtnOK, &btnRect);
		ScreenRectToClient(m_hwnd, &btnRect);
		::MoveWindow(hBtnOK, btnRect.left, btnRect.top+totalDeltaY, btnRect.right-btnRect.left, btnRect.bottom-btnRect.top, TRUE);

		::GetWindowRect(hBtnCancel, &btnRect);
		ScreenRectToClient(m_hwnd, &btnRect);
		::MoveWindow(hBtnCancel, btnRect.left, btnRect.top+totalDeltaY, btnRect.right-btnRect.left, btnRect.bottom-btnRect.top, TRUE);

		RECT winRect;
		::GetWindowRect(m_hwnd, &winRect);
		Resize(winRect.right-winRect.left, winRect.bottom-winRect.top+totalDeltaY);
	}

	for(int i = 0; i < m_nrPrompt; i++) {
		char echo = 0;
		const char * prompt = ssh_userauth_kbdint_getprompt(m_session, i, &echo);
		::SetDlgItemTextA(m_hwnd, IDC_EDIT_PROMPT1+(i*2), prompt);

		if (!echo) {
			HWND hCurAnswer = ::GetDlgItem(m_hwnd, IDC_EDIT_ANSWER1+(i*2));
			//LONG_PTR style = ::GetWindowLongPtr(hCurAnswer, GWL_STYLE);
			//::SetWindowLongPtr(hCurAnswer, GWL_STYLE, style|ES_PASSWORD);
			::SendMessage(hCurAnswer, EM_SETPASSWORDCHAR, (WPARAM)'*', 0);
		}

	}

	Dialog::OnInitDialog();
	::SetFocus(::GetDlgItem(m_hwnd, IDC_EDIT_ANSWER1));

	return FALSE;
}
Exemple #16
0
Matrix<T>::Matrix(VectorIndex nRowsP, VectorIndex nColsP) {
    Resize(nRowsP, nColsP);
}
Exemple #17
0
void MapEditor::LoadMapgen(const std::string &name)
{
    std::fstream sfile;
    sfile.open(name, std::ios_base::in);
    if(sfile.fail())
    {
        SYSTEM_STREAM << "Error open " << name << std::endl;
        return;
    }

    ClearMap();

    std::stringstream ss;

    sfile.seekg (0, std::ios::end);
    std::streamoff length = sfile.tellg();
    sfile.seekg (0, std::ios::beg);
    char* buff = new char[static_cast<size_t>(length)];

    sfile.read(buff, length);
    sfile.close();
    ss.write(buff, length);
    delete[] buff;

    int x, y, z;
    ss >> x;
    ss >> y;
    ss >> z;

    Resize(x, y, z);

    while (ss)
    {
        std::string t_item;
        size_t x, y, z;
        ss >> t_item;
        if (!ss)
        {
            continue;
        }
        ss >> x;
        if (!ss)
        {
            continue;
        }
        ss >> y;
        if (!ss)
        {
            continue;
        }
        ss >> z;
        if (!ss)
        {
            continue;
        }

        MapEditor::EditorEntry* ee;
        if (turf_types_.find(t_item) != turf_types_.end())
        {
            ee = &SetTurf(t_item, x, y, z);
        }
        else
        {
            ee = &AddItem(t_item, x, y, z);
        }

        WrapReadMessage(ss, ee->variables);

        // TODO
        UpdateDirs(ee);
    }
}
Exemple #18
0
void CRouteCacheTable::Clear()
{
	Resize( 0 );
}
Exemple #19
0
extern double get_llr_pv(
  double llr,				/* log likelihood ratio */
  double n,				/* wgtd number sequences in alignment */
  int w,				/* width of alignment */
  int range,				/* desired range for resolution */
  double frac,				/* speedup factor */
  int alength,				/* length of alphabet */
  double *dd 				/* alphabet frequency distribution */
)
{
  int i, N;
  double I;				/* weighted log likelihood ratio */
  int I0, I1;				/* position of llr in table */
  double logpv;				/* log pvalue */
  double n0, n1;			/* floor and ceil of n */
  double alpha;				/* scale factor used */

  if (n<=1) return 0.0;			/* only one site p-value = 1.0 */

  /* return geometric mean if N is not integral */
  if ( (n0=floor(n)) != (n1=ceil(n)) )
    return ( 
      (n1-n)*get_llr_pv(llr, n0, w, range, frac, alength, dd) +
      (n-n0)*get_llr_pv(llr, n1, w, range, frac, alength, dd) 
    );

  N = (int) n;				/* make n an integer */

  /* N larger than any previous N? */
  if (ndistrs < N) {			/* first call */
    Resize(distrs, N+1, DISTR);		/* create array of distributions */
    for (i=ndistrs+1; i<=N; i++) {
      distrs[i].w = 0;
      distrs[i].offset = NULL;
      distrs[i].range = NULL;
      distrs[i].d = NULL;
      distrs[i].cdf = NULL;
      distrs[i].mean = 0;
    }
    ndistrs = N;				/* set maximum N */
  }

  /* done if w == 0 */
  if (w == 0) return 0.0;

  /* w larger than any previous w for this N? */
  if (distrs[N].w < w) {			/* larger w */
    Resize(distrs[N].d, w+1, double *);
    Resize(distrs[N].cdf, w+1, double *);
    Resize(distrs[N].offset, w+1, int);
    Resize(distrs[N].range, w+1, int);

    /* first time? */ 
    if (distrs[N].w == 0) {			/* get the w=1 distribution */
      distrs[N].d[1] = llr_distr(alength, dd, N, range, frac,
        &distrs[N].alpha, &distrs[N].offset[1], &distrs[N].range[1]);
      /* get mean of LLR for w = 1 */
      for (i=0; i<=distrs[N].range[1]; i++) {
        double llr = (i + distrs[N].offset[1]) / distrs[N].alpha;
        distrs[N].mean += exp(distrs[N].d[1][i])*llr;
      }
      distrs[N].cdf[1] = cdf(distrs[N].d[1], distrs[N].range[1]);
      distrs[N].w = 1;
    } /* first time */

    /* get the distributions for widths oldw .. maxw */
    /*fprintf(stderr, "enter cdf N= %d w= %d oldw= %d\n", N, w, distrs[N].w);*/
    for (i=distrs[N].w+1; i<=w; i++) {		/* width */
      distrs[N].d[i] = sum_distr(
        distrs[N].d[i-1], 
        distrs[N].range[i-1], 
        distrs[N].d[1], 
        distrs[N].range[1], 
        &distrs[N].range[i]
      );
      distrs[N].offset[i] = distrs[N].offset[i-1] + distrs[N].offset[1];
      distrs[N].cdf[i] = cdf(distrs[N].d[i], distrs[N].range[i]);
    } /* width */
    /*fprintf(stderr, "leave cdf\n");*/
    distrs[N].w = w; 				/* set maximum w */
  } /* new w */
Exemple #20
0
bool
TopWindow::OnEvent(const Event &event)
{
  switch (event.type) {
    Window *w;

  case Event::NOP:
  case Event::QUIT:
  case Event::TIMER:
  case Event::USER:
  case Event::CALLBACK:
    break;

  case Event::KEY_DOWN:
    w = GetFocusedWindow();
    if (w == nullptr)
      w = this;

    return w->OnKeyDown(event.param);

  case Event::KEY_UP:
    w = GetFocusedWindow();
    if (w == nullptr)
      w = this;

    return w->OnKeyUp(event.param);

  case Event::MOUSE_MOTION:
    // XXX keys
    return OnMouseMove(event.point.x, event.point.y, 0);

  case Event::MOUSE_DOWN:
    return double_click.Check(event.point)
      ? OnMouseDouble(event.point.x, event.point.y)
      : OnMouseDown(event.point.x, event.point.y);

  case Event::MOUSE_UP:
    double_click.Moved(event.point);

    return OnMouseUp(event.point.x, event.point.y);

  case Event::MOUSE_WHEEL:
    return OnMouseWheel(event.point.x, event.point.y, (int)event.param);

  case Event::POINTER_DOWN:
    return OnMultiTouchDown();

  case Event::POINTER_UP:
    return OnMultiTouchUp();

  case Event::RESIZE:
    if (!surface_valid)
      /* postpone the resize if we're paused; the real resize will be
         handled by TopWindow::refresh() as soon as XCSoar is
         resumed */
      return true;

    if (unsigned(event.point.x) == GetWidth() &&
        unsigned(event.point.y) == GetHeight())
      /* no-op */
      return true;

    /* it seems the first page flip after a display orientation change
       is ignored on Android (tested on a Dell Streak / Android
       2.2.2); let's do one dummy call before we really draw
       something */
    screen->Flip();

    Resize(event.point.x, event.point.y);
    return true;

  case Event::PAUSE:
    OnPause();
    return true;

  case Event::RESUME:
    OnResume();
    return true;
  }

  return false;
}
Exemple #21
0
Viewport::Viewport(const F32 width, const F32 height, const F32 topLeftX, const F32 topLeftY, const F32 minDepth, const F32 maxDepth)
{
    Resize(width, height, topLeftX, topLeftY, minDepth, maxDepth);
}
// socket¶ÁÈë
int32 BufferStream::SocketFill(MySocket *m_pSocket)
{
	int32 nReceived = 0;
	int32 nFilled = 0;
	int32 nFree = Space();
	if (nFree == 0)
	{
		if (!Resize())
			return nFilled;
		 nFree = Space();
	}

	SOCKET sock = m_pSocket->GetSocket();
	if (m_nHead <= m_nTail)
	{
		if (m_nHead == 0)
		{
			nReceived = Recv(sock, nFree);
			if (nReceived == 0) return 0;

			m_nTail += nReceived;
			nFilled += nReceived;

			if (nReceived == nFree)
			{
				uint32 nAvailable = m_pSocket->Available();
				if (nAvailable > 0)
				{
					if (!Resize())
						return nFilled;

					nReceived = Recv(sock, nFree);
					if (nReceived == 0) return 0;

					m_nTail += nReceived;
					nFilled += nReceived;
				}
			}

		}
		else
		{
			nFree = m_nBufferLen - m_nTail;
			nReceived = Recv(sock, nFree);
			if (nReceived == 0) return 0;

			m_nTail = (m_nTail + nReceived) % m_nBufferLen;
			nFilled += nReceived;

			if (nReceived == nFree)
			{
				nReceived = 0;
				nFree = m_nHead - 1;
				if (nFree != 0)
				{
					nReceived = Recv(sock, nFree);
					if (nReceived == 0) return 0;

					m_nTail += nReceived;
					nFilled += nReceived;
				}

				if (nReceived == nFree)
				{
					uint32 nAvailable = m_pSocket->Available();
					if (nAvailable > 0)
					{
						if (!Resize())
							return nFilled;

						nReceived = Recv(sock, nFree);
						if (nReceived == 0) return 0;

						m_nTail += nReceived;
						nFilled += nReceived;
					}
				}
			}
		}
	}
	else
	{
		nReceived = Recv(sock, nFree);
		if (nReceived == 0) return 0;

		m_nTail += nReceived;
		nFilled += nReceived;

		if (nReceived == nFree)
		{
			uint32 nAvailable = m_pSocket->Available();
			if (nAvailable > 0)
			{
				if (!Resize())
					return nFilled;

				nReceived = Recv(sock, nFree);
				if (nReceived == 0) return 0;

				m_nTail += nReceived;
				nFilled += nReceived;
			}
		}
	}

	return nFilled;
}
Exemple #23
0
void Camera::SetFarClipDist(float dist)
{
	_zFarClip = dist;
	Resize(_windowWidth, _windowHeight);
}
Exemple #24
0
//===========================================================================
//
//	Loads the texture image into the hardware
//
// NOTE: For some strange reason I was unable to find the source buffer
// should be one line higher than the actual texture. I got extremely
// strange crashes deep inside the GL driver when I didn't do it!
//
//===========================================================================
void FHardwareTexture::LoadImage(unsigned char * buffer,int w, int h, unsigned int & glTexID,int wrapparam, bool alphatexture, int texunit)
{
    int rh,rw;
    int texformat=TexFormat[gl_texture_format];
    bool deletebuffer=false;
    bool use_mipmapping = TexFilter[gl_texture_filter].mipmapping;

    if (alphatexture) texformat=GL_ALPHA8;
    else if (forcenocompression) texformat = GL_RGBA8;
    if (glTexID==0) glGenTextures(1,&glTexID);
    glBindTexture(GL_TEXTURE_2D, glTexID);
    lastbound[texunit]=glTexID;

    if (!buffer)
    {
        w=texwidth;
        h=abs(texheight);
        rw = GetTexDimension (w);
        rh = GetTexDimension (h);

        // The texture must at least be initialized if no data is present.
        mipmap=false;
        glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, false);
        buffer=(unsigned char *)calloc(4,rw * (rh+1));
        deletebuffer=true;
        //texheight=-h;
    }
    else
    {
        rw = GetTexDimension (w);
        rh = GetTexDimension (h);

        glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, (mipmap && use_mipmapping && !forcenofiltering));

        if (rw < w || rh < h)
        {
            // The texture is larger than what the hardware can handle so scale it down.
            unsigned char * scaledbuffer=(unsigned char *)calloc(4,rw * (rh+1));
            if (scaledbuffer)
            {
                Resize(rw, rh, buffer, scaledbuffer);
                deletebuffer=true;
                buffer=scaledbuffer;
            }
        }
    }
    glTexImage2D(GL_TEXTURE_2D, 0, texformat, rw, rh, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);

    if (deletebuffer) free(buffer);

    // When using separate samplers the stuff below is not needed.
    // if (gl.flags & RFL_SAMPLER_OBJECTS) return;

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapparam==GL_CLAMP? GL_CLAMP_TO_EDGE : GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapparam==GL_CLAMP? GL_CLAMP_TO_EDGE : GL_REPEAT);
    clampmode = wrapparam==GL_CLAMP? GLT_CLAMPX|GLT_CLAMPY : 0;

    if (forcenofiltering)
    {
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.f);
    }
    else
    {
        if (mipmap && use_mipmapping)
        {
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].minfilter);
            if (gl_texture_filter_anisotropic)
            {
                glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_filter_anisotropic);
            }
        }
        else
        {
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].magfilter);
        }
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter);
    }
}
Exemple #25
0
int CLayerTiles::RenderProperties(CUIRect *pToolBox)
{
	CUIRect Button;

	bool InGameGroup = !find_linear(m_pEditor->m_Map.m_pGameGroup->m_lLayers.all(), this).empty();
	if(m_pEditor->m_Map.m_pGameLayer != this)
	{
		if(m_Image >= 0 && m_Image < m_pEditor->m_Map.m_lImages.size() && m_pEditor->m_Map.m_lImages[m_Image]->m_pAutoMapper)
		{
			static int s_AutoMapperButton = 0;
			pToolBox->HSplitBottom(12.0f, pToolBox, &Button);
			if(m_pEditor->DoButton_Editor(&s_AutoMapperButton, "Auto map", 0, &Button, 0, ""))
				m_pEditor->PopupSelectConfigAutoMapInvoke(m_pEditor->UI()->MouseX(), m_pEditor->UI()->MouseY());

			bool Proceed = m_pEditor->PopupAutoMapProceedOrder();
			if(Proceed)
			{
				if(m_pEditor->m_Map.m_lImages[m_Image]->m_pAutoMapper->GetType() == IAutoMapper::TYPE_TILESET)
				{
					m_pEditor->m_Map.m_lImages[m_Image]->m_pAutoMapper->Proceed(this, m_SelectedRuleSet);
					return 1; // only close the popup when it's a tileset
				}
				else if(m_pEditor->m_Map.m_lImages[m_Image]->m_pAutoMapper->GetType() == IAutoMapper::TYPE_DOODADS)
					m_pEditor->m_Map.m_lImages[m_Image]->m_pAutoMapper->Proceed(this, m_SelectedRuleSet, m_SelectedAmount);
			}
		}
	}
	else
		InGameGroup = false;

	if(InGameGroup)
	{
		pToolBox->HSplitBottom(2.0f, pToolBox, 0);
		pToolBox->HSplitBottom(12.0f, pToolBox, &Button);
		static int s_ColclButton = 0;
		if(m_pEditor->DoButton_Editor(&s_ColclButton, "Game tiles", 0, &Button, 0, "Constructs game tiles from this layer"))
			m_pEditor->PopupSelectGametileOpInvoke(m_pEditor->UI()->MouseX(), m_pEditor->UI()->MouseY());

		int Result = m_pEditor->PopupSelectGameTileOpResult();
		if(Result > -1)
		{
			CLayerTiles *gl = m_pEditor->m_Map.m_pGameLayer;
			int w = min(gl->m_Width, m_Width);
			int h = min(gl->m_Height, m_Height);
			for(int y = 0; y < h; y++)
				for(int x = 0; x < w; x++)
					if(m_pTiles[y*m_Width+x].m_Index)
						gl->m_pTiles[y*gl->m_Width+x].m_Index = TILE_AIR+Result;

			return 1;
		}
	}

	enum
	{
		PROP_WIDTH=0,
		PROP_HEIGHT,
		PROP_SHIFT,
		PROP_IMAGE,
		PROP_COLOR,
		PROP_COLOR_ENV,
		PROP_COLOR_ENV_OFFSET,
		NUM_PROPS,
	};

	int Color = 0;
	Color |= m_Color.r<<24;
	Color |= m_Color.g<<16;
	Color |= m_Color.b<<8;
	Color |= m_Color.a;

	CProperty aProps[] = {
		{"Width", m_Width, PROPTYPE_INT_SCROLL, 1, 1000000000},
		{"Height", m_Height, PROPTYPE_INT_SCROLL, 1, 1000000000},
		{"Shift", 0, PROPTYPE_SHIFT, 0, 0},
		{"Image", m_Image, PROPTYPE_IMAGE, 0, 0},
		{"Color", Color, PROPTYPE_COLOR, 0, 0},
		{"Color Env", m_ColorEnv+1, PROPTYPE_INT_STEP, 0, m_pEditor->m_Map.m_lEnvelopes.size()+1},
		{"Color TO", m_ColorEnvOffset, PROPTYPE_INT_SCROLL, -1000000, 1000000},
		{0},
	};

	if(m_pEditor->m_Map.m_pGameLayer == this) // remove the image and color properties if this is the game layer
	{
		aProps[3].m_pName = 0;
		aProps[4].m_pName = 0;
	}

	static int s_aIds[NUM_PROPS] = {0};
	int NewVal = 0;
	int Prop = m_pEditor->DoProperties(pToolBox, aProps, s_aIds, &NewVal);
	if(Prop != -1)
		m_pEditor->m_Map.m_Modified = true;

	if(Prop == PROP_WIDTH && NewVal > 1)
		Resize(NewVal, m_Height);
	else if(Prop == PROP_HEIGHT && NewVal > 1)
		Resize(m_Width, NewVal);
	else if(Prop == PROP_SHIFT)
		Shift(NewVal);
	else if(Prop == PROP_IMAGE)
	{
		if (NewVal == -1)
		{
			m_Texture = -1;
			m_Image = -1;
		}
		else
			m_Image = NewVal%m_pEditor->m_Map.m_lImages.size();
	}
	else if(Prop == PROP_COLOR)
	{
		m_Color.r = (NewVal>>24)&0xff;
		m_Color.g = (NewVal>>16)&0xff;
		m_Color.b = (NewVal>>8)&0xff;
		m_Color.a = NewVal&0xff;
	}
Exemple #26
0
Fichier : Main.cpp Projet : 4ian/GD
void Keyboard(unsigned char key, int x, int y)
{
	B2_NOT_USED(x);
	B2_NOT_USED(y);

	switch (key)
	{
	case 27:
		exit(0);
		break;

		// Press 'z' to zoom out.
	case 'z':
		viewZoom = b2Min(1.1f * viewZoom, 20.0f);
		Resize(width, height);
		break;

		// Press 'x' to zoom in.
	case 'x':
		viewZoom = b2Max(0.9f * viewZoom, 0.02f);
		Resize(width, height);
		break;

		// Press 'r' to reset.
	case 'r':
		delete test;
		test = entry->createFcn();
		break;

		// Press space to launch a bomb.
	case ' ':
		if (test)
		{
			test->LaunchBomb();
		}
		break;
 
	case 'p':
		settings.pause = !settings.pause;
		break;

		// Press [ to prev test.
	case '[':
		--testSelection;
		if (testSelection < 0)
		{
			testSelection = testCount - 1;
		}
		glui->sync_live();
		break;

		// Press ] to next test.
	case ']':
		++testSelection;
		if (testSelection == testCount)
		{
			testSelection = 0;
		}
		glui->sync_live();
		break;
		
	default:
		if (test)
		{
			test->Keyboard(key);
		}
	}
}
void HKWidgetLayoutFrame::ArrangeChildren()
{
	bool bFitWidth = bAutoWidth && GetHAlign() != Align_Fill; // fitFlags & FitContentHorizontal
	bool bFitHeight = bAutoHeight && GetVAlign() != VAlign_Fill; // fitFlags & FitContentVertical

	// early out?
	int numChildren = GetNumChildren();
	if(numChildren == 0)
	{
		if(bFitWidth || bFitHeight)
		{
			// resize the layout
			MFVector newSize = GetSize();
			if(bFitWidth)
				newSize.x = padding.x + padding.z;
			if(bFitHeight)
				newSize.y = padding.y + padding.w;
			Resize(newSize);
		}
		return;
	}

	if(bFitWidth || bFitHeight)
	{
		// fit to largest child in each dimension
		MFVector fit = MFVector::zero;
		for(int a=0; a<numChildren; ++a)
		{
			HKWidget *pWidget = GetChild(a);
			const MFVector &cSize = pWidget->GetSizeWithMargin();

			fit.x = MFMax(fit.x, cSize.x + padding.x + padding.z);
			fit.y = MFMax(fit.y, cSize.y + padding.y + padding.w);
		}

		// resize the layout
		MFVector newSize = GetSize();
		if(bFitWidth)
			newSize.x = fit.x;
		if(bFitHeight)
			newSize.y = fit.y;
		Resize(newSize);
	}

	MFVector cPos = MakeVector(padding.x, padding.y);
	MFVector cSize = MakeVector(size.x - (padding.x + padding.z), size.y - (padding.y + padding.w));

	for(int a=0; a<numChildren; ++a)
	{
		HKWidget *pWidget = GetChild(a);

		const MFVector &cMargin = pWidget->GetLayoutMargin();
		const MFVector &size = pWidget->GetSize();
		MFVector tPos = cPos + MakeVector(cMargin.x, cMargin.y);
		MFVector tSize = cSize - MakeVector(cMargin.x + cMargin.z, cMargin.y + cMargin.w);

		switch(pWidget->GetLayoutJustification())
		{
		case TopLeft:
			pWidget->SetPosition(tPos);
			break;
		case TopCenter:
			pWidget->SetPosition(tPos + MakeVector((tSize.x - size.x) * 0.5f, 0));
			break;
		case TopRight:
			pWidget->SetPosition(tPos + MakeVector(tSize.x - size.x, 0));
			break;
		case TopFill:
			pWidget->SetPosition(tPos);
			ResizeChild(pWidget, MakeVector(tSize.x, size.y));
			break;
		case CenterLeft:
			pWidget->SetPosition(tPos + MakeVector(0, (tSize.y - size.y) * 0.5f));
			break;
		case Center:
			pWidget->SetPosition(tPos + MakeVector((tSize.x - size.x) * 0.5f, (tSize.y - size.y) * 0.5f));
			break;
		case CenterRight:
			pWidget->SetPosition(tPos + MakeVector(tSize.x - size.x, (tSize.y - size.y) * 0.5f));
			break;
		case CenterFill:
			pWidget->SetPosition(tPos + MakeVector(0, (tSize.y - size.y) * 0.5f));
			ResizeChild(pWidget, MakeVector(tSize.x, size.y));
			break;
		case BottomLeft:
			pWidget->SetPosition(tPos + MakeVector(0, tSize.y - size.y));
			break;
		case BottomCenter:
			pWidget->SetPosition(tPos + MakeVector((tSize.x - size.x) * 0.5f, tSize.y - size.y));
			break;
		case BottomRight:
			pWidget->SetPosition(tPos + MakeVector(tSize.x - size.x, tSize.y - size.y));
			break;
		case BottomFill:
			pWidget->SetPosition(tPos + MakeVector(0, tSize.y - size.y));
			ResizeChild(pWidget, MakeVector(tSize.x, size.y));
			break;
		case FillLeft:
			pWidget->SetPosition(tPos);
			ResizeChild(pWidget, MakeVector(size.x, tSize.y));
			break;
		case FillCenter:
			pWidget->SetPosition(tPos + MakeVector((tSize.x - size.x) * 0.5f, 0));
			ResizeChild(pWidget, MakeVector(size.x, tSize.y));
			break;
		case FillRight:
			pWidget->SetPosition(tPos + MakeVector(tSize.x - size.x, 0));
			ResizeChild(pWidget, MakeVector(size.x, tSize.y));
			break;
		case Fill:
			pWidget->SetPosition(tPos);
			ResizeChild(pWidget, tSize);
			break;
		case None:
			// this widget has absolute coordinates..
		default:
			break;
		}
	}
}
Exemple #28
0
static DWORD WINAPI ReadThread(LPVOID lParam)
{
    Capture * capBox = (Capture *)lParam;
    HRESULT hr;
    IMediaSample *pSample = NULL;
    unsigned long framecount = 0;
    unsigned char *pTarget, *pInput, *pOutput;

    hr = V4l_Prepare(capBox);
    if (FAILED(hr))
        goto fail;

    pOutput = CoTaskMemAlloc(capBox->width * capBox->height * capBox->bitDepth / 8);
    capBox->curframe = 0;
    do {
        V4l_FreeFrame(capBox);
    } while (capBox->curframe != 0);

    while (1)
    {
        EnterCriticalSection(&capBox->CritSect);
        if (capBox->stopped)
            break;
        hr = OutputPin_GetDeliveryBuffer((OutputPin *)capBox->pOut, &pSample, NULL, NULL, 0);
        if (SUCCEEDED(hr))
        {
            int len;
            
            if (!capBox->swresize)
                len = capBox->height * capBox->width * capBox->bitDepth / 8;
            else
                len = capBox->outputheight * capBox->outputwidth * capBox->bitDepth / 8;
            IMediaSample_SetActualDataLength(pSample, len);

            len = IMediaSample_GetActualDataLength(pSample);
            TRACE("Data length: %d KB\n", len / 1024);

            IMediaSample_GetPointer(pSample, &pTarget);
            /* FIXME: Check return values.. */
            V4l_GetFrame(capBox, &pInput);
            capBox->renderer(capBox, pOutput, pInput);
            Resize(capBox, pTarget, pOutput);
            hr = OutputPin_SendSample((OutputPin *)capBox->pOut, pSample);
            TRACE("%p -> Frame %lu: %x\n", capBox, ++framecount, hr);
            IMediaSample_Release(pSample);
            V4l_FreeFrame(capBox);
        }
        LeaveCriticalSection(&capBox->CritSect);
        if (FAILED(hr) && hr != VFW_E_NOT_CONNECTED)
        {
            ERR("Received error: %x\n", hr);
            goto cfail;
        }
    }
    LeaveCriticalSection(&capBox->CritSect);
    CoTaskMemFree(pOutput);

    return 0;

cfail:
    CoTaskMemFree(pOutput);
    V4l_Unprepare(capBox);
    LeaveCriticalSection(&capBox->CritSect);

fail:
    capBox->thread = 0; capBox->stopped = 1;
    FIXME("Stop IFilterGraph\n");
    return 0;
}
void CDialogEpsGraph::OnSize(UINT nType, int cx, int cy) 
{
	CDialog::OnSize(nType, cx, cy);
	
	Resize();	
}
void PolycodeTextEditor::showFindBar() {
	findBar->visible = true;
	findBar->focusChild(findBar->findInput);
	findBar->findInput->selectAll();
	Resize(editorSize.x, editorSize.y);
}