Esempio n. 1
0
void CTypefaceCombo::OnTimer(UINT nIDEvent) 
{
	// May need to show a preview window
	if (m_bShowPreview)
	{
		ShowPreview();
		m_bShowPreview = FALSE;
	}
}
Esempio n. 2
0
void CAddEdit_Attachment::OnAttImport()
{
  CString filter;
  CSimpleArray<GUID> aguidFileTypes;
  HRESULT hr;

  UpdateData(TRUE);

  if (m_AttFileName.IsEmpty()) {
    // Ask user for file name - annoyingly - returned string is all in upper case!
    // Remove last separator
    const CString cs_allimages(MAKEINTRESOURCE(IDS_ALL_IMAGE_FILES));
    const DWORD dwExclude = CImage::excludeOther;
    hr = m_AttImage.GetImporterFilterString(filter, aguidFileTypes, cs_allimages, dwExclude);
    ASSERT(hr >= 0);

    // Make better visually
    filter = filter.Right(filter.GetLength() - cs_allimages.GetLength());
    filter.MakeLower();
    filter = cs_allimages + filter;

    // Remove last separator to add the all files
    filter = filter.Left(filter.GetLength() - 1);

    // Add "All files"
    const CString cs_allfiles(MAKEINTRESOURCE(IDS_FDF_ALL));
    filter.Append(cs_allfiles);

    CFileDialog fileDlg(TRUE, NULL, NULL, OFN_FILEMUSTEXIST, filter, this);
    if (fileDlg.DoModal() == IDCANCEL)
      return;

    m_AttFileName = CSecString(fileDlg.GetPathName());
  } else {
    if (!pws_os::FileExists(LPCWSTR(m_AttFileName))) {
      CGeneralMsgBox gmb;
      gmb.AfxMessageBox(IDS_ATTACHMENT_NOTFOUND);
      return;
    }
  }

  // Get file information
  struct _stati64 info;
  VERIFY(_wstati64(m_AttFileName, &info) == 0);

  m_csFileCTime = PWSUtil::ConvertToDateTimeString(info.st_ctime, PWSUtil::TMC_LOCALE).c_str();
  m_csFileMTime = PWSUtil::ConvertToDateTimeString(info.st_mtime, PWSUtil::TMC_LOCALE).c_str();

  ShowPreview();

  m_ae_psh->SetChanged(true);
  Invalidate();
  UpdateControls();
  UpdateData(FALSE);
  UpdateWindow();
}
Esempio n. 3
0
void GuiFileDialog::OnListboxClick(const std::string& fullPathAndFilename)
{
  lastPath = CleanPath(fullPathAndFilename); 
  GuiTextEdit* text = dynamic_cast<GuiTextEdit*>(GetElementByName("fd-path-text"));
  Assert(text);
  text->SetText(lastPath);

  ShowPreview();

#ifdef GFD_DEBUG
std::cout << "Listbox click: lastPath is now \"" << lastPath << "\"\n";
#endif
}
Esempio n. 4
0
BOOL CAddEdit_Attachment::OnInitDialog()
{
  CAddEdit_PropertyPage::OnInitDialog();

  // Get Add/Edit font
  Fonts *pFonts = Fonts::GetInstance();
  CFont *pFont = pFonts->GetAddEditFont();

  // Change font size of the attachment name and file name fields
  GetDlgItem(IDC_ATT_NAME)->SetFont(pFont);
  GetDlgItem(IDC_ATT_FILE)->SetFont(pFont);

  // Check initial state
  if (!M_pci()->HasAttRef()) {
    m_attType = NO_ATTACHMENT;
  } else {
    // m_attachment() set in CAddEdit_PropertySheet::SetupInitialValues()
    // If we have an attachment, load & preview
    m_AttName = M_attachment().GetTitle();
    m_AttFileName = M_attachment().GetFilePath() + M_attachment().GetFileName();

    // Get other properties
    m_csMediaType = M_attachment().GetMediaType().c_str();
    if (m_csMediaType == L"unknown") {
      m_csMediaType.LoadString(IDS_UNKNOWN);
    }

    wchar_t szFileSize[256];
    StrFormatByteSize(M_attachment().GetContentSize(), szFileSize, 256);
    m_csSize = szFileSize;

    m_csFileCTime = M_attachment().GetFileCTime().c_str();
    if (m_csFileCTime.IsEmpty())
      m_csFileCTime.LoadString(IDS_NA);

    m_csFileMTime = M_attachment().GetFileMTime().c_str();
    if (m_csFileMTime.IsEmpty())
      m_csFileMTime.LoadString(IDS_NA);

    ShowPreview();
  }

  UpdateData(FALSE);
  UpdateControls();

  m_bInitdone = true;

  return TRUE;  // return TRUE unless you set the focus to a control
}
Esempio n. 5
0
void GuiFileDialog::OnPathChange()
{
  GuiTextEdit* text = dynamic_cast<GuiTextEdit*>(GetElementByName("fd-path-text"));
  Assert(text);
  lastPath = CleanPath(text->GetText()); 

  GuiFileListBox* fb = dynamic_cast<GuiFileListBox*>(GetElementByName("fd-file-list-box"));
  Assert(fb);
  fb->SetDir(lastPath);

  ShowPreview();

#ifdef GFD_DEBUG
std::cout << "Path change: lastPath is now \"" << lastPath << "\"\n";
#endif
}
Esempio n. 6
0
void CTypefaceCombo::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
	// See if we need to set the preview creation timer
	if ((lpDrawItemStruct->itemState & ODS_SELECTED) != 0 &&
		(lpDrawItemStruct->itemID != m_DrawItemStruct.itemID || !m_pPreviewWnd->IsWindowVisible()))
	{
		m_DrawItemStruct = *lpDrawItemStruct;
		if (!m_pPreviewWnd->IsWindowVisible())
		{
			// Kill the last timer
			if (m_nTimer)
			{
				KillTimer(m_nTimer);
				m_nTimer = 0;
			}

			// Set the timer for creation (for a delay)
			if ((m_nTimer = SetTimer(1, 750, NULL)) != 0)
			{
				// All set...
				m_bShowPreview = TRUE;
			}
			else
			{
				// Failed to create timer-- do preview now
				ShowPreview();
			}
		}
		else
		{
			// Update with new font
			UpdatePreview();
		}
	}
	
	CBarMRUCombo::OnDrawItem(nIDCtl, lpDrawItemStruct);
}
Esempio n. 7
0
/*
	Shows menu items and pointing arrow
*/
void ShowMenu(MENU *menu)
{
	int i;
	MENUITEM *mi = menu->m;

	// clear buffer
	SDL_FillRect(menuSurface, NULL, COLOR_BG);

	// show menu lines
	for(i = 0; i < menu->itemNum; i++, mi++) {
		int fg_color;

		if(menu->itemCur == i) fg_color = COLOR_ACTIVE_ITEM; else fg_color = COLOR_INACTIVE_ITEM;
		ShowMenuItem(80, (18 + i) * 8, mi, fg_color);
	}

	// show preview screen
	ShowPreview(menu);

	// print info string
	print_string("Press B to return to game", COLOR_HELP_TEXT, COLOR_BG, 56, 220);
	print_string("Handy320 v0.1 for OpenDingux", COLOR_HELP_TEXT, COLOR_BG, 44, 2);
	print_string("Handy/SDL 0.5 (c) K. Wilkins and SDLemu", COLOR_HELP_TEXT, COLOR_BG, 4, 12);
}
bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
{
    int ItemCount = 0;
    bool nextCmd = false;
    BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
    wxPoint pt;

    auto panel =static_cast<SCH_DRAW_PANEL*>(m_canvas);
    auto view = panel->GetView();
    auto area = view->GetSelectionArea();

    auto start = area->GetOrigin();
    auto end = area->GetEnd();

    block->SetOrigin( wxPoint( start.x, start.y ) );
    block->SetEnd( wxPoint( end.x, end.y ) );

    view->ShowSelectionArea( false );
    view->ClearHiddenFlags();

    if( block->GetCount() )
    {
        BLOCK_STATE_T state     = block->GetState();
        BLOCK_COMMAND_T command = block->GetCommand();

        m_canvas->CallEndMouseCapture( aDC );

        block->SetState( state );
        block->SetCommand( command );
        m_canvas->SetMouseCapture( DrawAndSizingBlockOutlines, AbortBlockCurrentCommand );

        if( block->GetCommand() != BLOCK_ABORT
            && block->GetCommand() != BLOCK_DUPLICATE
            && block->GetCommand() != BLOCK_COPY
            && block->GetCommand() != BLOCK_CUT
            && block->GetCommand() != BLOCK_DELETE )
        {
            SetCrossHairPosition( block->GetEnd() );
            m_canvas->MoveCursorToCrossHair();
        }
    }

    if( m_canvas->IsMouseCaptured() )
    {
        switch( block->GetCommand() )
        {
        case  BLOCK_IDLE:
            DisplayError( this, wxT( "Error in HandleBlockPLace" ) );
            break;

        case BLOCK_DRAG:        // Drag
        case BLOCK_DRAG_ITEM:
        case BLOCK_MOVE:        // Move
        case BLOCK_DUPLICATE:   // Duplicate
            if( GetCurPart() )
                ItemCount = BlockSelectItems( GetCurPart(), block, m_unit, m_convert, m_syncPinEdit );

            if( ItemCount )
            {
                nextCmd = true;
                block->SetState( STATE_BLOCK_MOVE );

                if( block->GetCommand() == BLOCK_DUPLICATE )
                {
                    if( block->AppendUndo() )
                        ; // UR_LIBEDIT saves entire state, so no need to append anything more
                    else
                    {
                        SaveCopyInUndoList( GetCurPart(), UR_LIBEDIT );
                        block->SetAppendUndo();
                    }

                    BlockCopySelectedItems( pt, GetCurPart(), block );
                    block->SetLastCursorPosition( GetCrossHairPosition( true ) );
                }

                m_canvas->SetMouseCaptureCallback( DrawMovingBlockOutlines );
                m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
            }
            else
            {
                m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
                m_canvas->SetMouseCapture( NULL, NULL );
            }
            break;

        case BLOCK_COPY:    // Save a copy of items in the clipboard buffer
        case BLOCK_CUT:
            if( GetCurPart() )
                ItemCount = BlockSelectItems( GetCurPart(), block, m_unit, m_convert, m_syncPinEdit );

            if( ItemCount )
            {
                copySelectedItems();
                auto cmd = block->GetCommand();

                if( cmd == BLOCK_COPY )
                {
                    BlockClearSelectedItems( GetCurPart(), block );
                    block->ClearItemsList();
                }
                else if( cmd == BLOCK_CUT )
                {
                    if( block->AppendUndo() )
                        ; // UR_LIBEDIT saves entire state, so no need to append anything more
                    else
                    {
                        SaveCopyInUndoList( GetCurPart(), UR_LIBEDIT );
                        block->SetAppendUndo();
                    }

                    BlockDeleteSelectedItems( GetCurPart(), block );
                    RebuildView();
                    GetCanvas()->Refresh();
                    OnModify();
                }
            }
            break;

        case BLOCK_DELETE:     // Delete
            if( GetCurPart() )
                ItemCount = BlockSelectItems( GetCurPart(), block, m_unit, m_convert, m_syncPinEdit );

            if( block->AppendUndo() )
                ; // UR_LIBEDIT saves entire state, so no need to append anything more
            else if( ItemCount )
            {
                SaveCopyInUndoList( GetCurPart(), UR_LIBEDIT );
                block->SetAppendUndo();
            }

            if( GetCurPart() )
            {
                BlockDeleteSelectedItems( GetCurPart(), block );
                RebuildView();
                GetCanvas()->Refresh();
                OnModify();
            }
            break;

        case BLOCK_PASTE:
        case BLOCK_ROTATE:
        case BLOCK_MIRROR_X:
        case BLOCK_MIRROR_Y:
        case BLOCK_FLIP:
            wxFAIL; // should not happen
            break;

        case BLOCK_ZOOM:     // Window Zoom
            Window_Zoom( *block );
            break;

        case BLOCK_ABORT:
            break;

        case BLOCK_SELECT_ITEMS_ONLY:
            break;

        case BLOCK_PRESELECT_MOVE:          // not used in LibEdit
        case BLOCK_DUPLICATE_AND_INCREMENT: // not used in Eeschema
        case BLOCK_MOVE_EXACT:              // not used in Eeschema
            break;
        }
    }

    if( block->GetCommand() == BLOCK_ABORT )
    {
        GetScreen()->ClearDrawingState();
    }

    if( !nextCmd )
    {
        if( block->GetCommand() != BLOCK_SELECT_ITEMS_ONLY && GetCurPart() )
            BlockClearSelectedItems( GetCurPart(), block );

        GetScreen()->ClearBlockCommand();
        GetScreen()->SetCurItem( NULL );
        m_canvas->EndMouseCapture( GetToolId(), GetGalCanvas()->GetCurrentCursor(), wxEmptyString,
                                   false );
    }

    view->ShowSelectionArea( false );
    view->ShowPreview( nextCmd );

    return nextCmd;
}