コード例 #1
0
ファイル: AnnotWriter.cpp プロジェクト: Akujiism/BePDF
void AnnotWriter::UpdateBePDFAcroForm() {
	if (mWrittenFonts.empty()) return;

	Object acroForm;
	Object oldDR;

	acroForm.initDict(mXRef);
	oldDR.initNull();

	if (is_empty_ref(mBePDFAcroForm->GetRef())) {
		Ref fieldsRef = mXRefTable.GetNewRef(xrefEntryUncompressed);
		// create empty array for fields
		Object fields;
		fields.initArray(mXRef);
		WriteObject(fieldsRef, &fields);
		fields.free();

		// create new BePDFAcroForm
		mBePDFAcroFormRef = mXRefTable.GetNewRef(xrefEntryUncompressed);
		AddName(&acroForm, "Type", "BePDFAcroForm");
		AddRef(&acroForm, "Fields", fieldsRef);
	} else {
		// copy existing BePDFAcroForm except DR
		mBePDFAcroFormRef = mBePDFAcroForm->GetRef();
		Object ref;
		Object oldForm;
		ref.initRef(mBePDFAcroFormRef.num, mBePDFAcroFormRef.gen);
		ref.fetch(mXRef, &oldForm);
		CopyDict(&oldForm, &acroForm, acroFormExcludeKeys);
		oldForm.dictLookup("DR", &oldDR);
		oldForm.free();
		ref.free();
	}
	// Add DR to BePDFAcroForm
	Object dr;
	dr.initDict(mXRef);
	if (oldDR.isDict()) {
		CopyDict(&oldDR, &dr, drExcludeKeys);
		oldDR.free();
	}
	// Add font dict
	Object font;
	font.initDict(mXRef);
	// add old fonts
	AddFonts(&font, mBePDFAcroForm->GetFonts());
	// add new fonts
	AddFonts(&font, &mWrittenFonts);
	AddDict(&dr, "Font", &font);
	AddDict(&acroForm, "DR", &dr);
	WriteObject(mBePDFAcroFormRef, &acroForm);
	acroForm.free();
}
コード例 #2
0
/* Add opencount-based resources to the tracking list. */
static BOOL AddOpenedResources(struct List *opened)
{
    struct DosInfo *di = BADDR(DOSBase->dl_Root->rn_Info);

    if (!AddLibs(opened))
	return FALSE;
    if (!AddDevs(opened))
	return FALSE;
    if (!AddFonts(opened))
	return FALSE;
    if (!AddNodeNames(opened, &SysBase->ResourceList, "Resource"))
	return FALSE;
    if (!AddNodeNames(opened, &SysBase->IntrList, "Interrupt"))
	return FALSE;
    if (!AddNodeNames(opened, &SysBase->PortList, "Port"))
	return FALSE;
    if (!AddNodeNames(opened, &SysBase->SemaphoreList, "Semaphore"))
	return FALSE;
    if (!AddASemaphore(opened, &di->di_DevLock, "di_DevLock"))
	return FALSE;
    if (!AddAClass(opened, ((struct GadToolsBase_intern *)GadToolsBase)->buttonclass, "button"))
	return FALSE;
    if (!AddAClass(opened, ((struct GadToolsBase_intern *)GadToolsBase)->textclass, "text"))
	return FALSE;
    if (!AddAClass(opened, ((struct GadToolsBase_intern *)GadToolsBase)->sliderclass, "slider"))
	return FALSE;
    if (!AddAClass(opened, ((struct GadToolsBase_intern *)GadToolsBase)->scrollerclass, "scroller"))
	return FALSE;
    if (!AddAClass(opened, ((struct GadToolsBase_intern *)GadToolsBase)->arrowclass, "arrow"))
	return FALSE;
    if (!AddAClass(opened, ((struct GadToolsBase_intern *)GadToolsBase)->stringclass, "string"))
	return FALSE;
    if (!AddAClass(opened, ((struct GadToolsBase_intern *)GadToolsBase)->listviewclass, "listview"))
	return FALSE;
    if (!AddAClass(opened, ((struct GadToolsBase_intern *)GadToolsBase)->checkboxclass, "checkbox"))
	return FALSE;
    if (!AddAClass(opened, ((struct GadToolsBase_intern *)GadToolsBase)->cycleclass, "cycle"))
	return FALSE;
    if (!AddAClass(opened, ((struct GadToolsBase_intern *)GadToolsBase)->mxclass, "mx"))
	return FALSE;
    if (!AddAClass(opened, ((struct GadToolsBase_intern *)GadToolsBase)->paletteclass, "palette"))
	return FALSE;
    return TRUE;
}
コード例 #3
0
ファイル: config.c プロジェクト: 469306621/Languages
//
//	Dialogbox procedure for Configuration window
//
BOOL CALLBACK ConfigDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	static char buf[256];
	HWND	hwndCombo, hwndCtrl;
	int		index, items, val;
	RECT	rect;
	static  int prevwidth, prevheight;

	switch(uMsg)
	{
	case WM_INITDIALOG:

		prevwidth  = GetSystemMetrics(SM_CXSCREEN) / GLYPH_WIDTH;
		prevheight = GetSystemMetrics(SM_CYSCREEN) / GLYPH_HEIGHT + 1;

		//Add any saved messages to the combo box
		for(index = 0; index < g_nNumMessages; index++)
		{
			if(lstrlen(g_szMessages[index]) > 0)
				SendDlgItemMessage(hwnd, IDC_COMBO1, CB_ADDSTRING, 0, (LPARAM)g_szMessages[index]);
		}

		//select the first message, and preview it
		SendDlgItemMessage(hwnd, IDC_COMBO1, CB_SETCURSEL, 0, 0);
		
		SendDlgItemMessage(hwnd, IDC_SLIDER1, TBM_SETRANGE, 0, MAKELONG(SPEED_MIN, SPEED_MAX));
		SendDlgItemMessage(hwnd, IDC_SLIDER2, TBM_SETRANGE, 0, MAKELONG(DENSITY_MIN, DENSITY_MAX));
		SendDlgItemMessage(hwnd, IDC_SLIDER3, TBM_SETRANGE, 0, MAKELONG(MSGSPEED_MIN, MSGSPEED_MAX));
		SendDlgItemMessage(hwnd, IDC_SLIDER4, TBM_SETRANGE, 0, MAKELONG(FONT_MIN, FONT_MAX));

		//SendDlgItemMessage(hwnd, IDC_SLIDER1, TBM_SETTICFREQ, 5, 0);
		SendDlgItemMessage(hwnd, IDC_SLIDER2, TBM_SETTICFREQ, 5, 0);
		SendDlgItemMessage(hwnd, IDC_SLIDER3, TBM_SETTICFREQ, 50, 0);
		SendDlgItemMessage(hwnd, IDC_SLIDER4, TBM_SETTICFREQ, 2, 0);
		
		SendDlgItemMessage(hwnd, IDC_SLIDER1, TBM_SETPOS, TRUE, g_nMatrixSpeed);
		SendDlgItemMessage(hwnd, IDC_SLIDER2, TBM_SETPOS, TRUE, g_nDensity);
		SendDlgItemMessage(hwnd, IDC_SLIDER3, TBM_SETPOS, TRUE, g_nMessageSpeed);
		SendDlgItemMessage(hwnd, IDC_SLIDER4, TBM_SETPOS, TRUE, g_nFontSize);

		CheckDlgButton(hwnd, IDC_RANDOM, g_fRandomizeMessages);
		CheckDlgButton(hwnd, IDC_BOLD, g_fFontBold);

		AddFonts(GetDlgItem(hwnd, IDC_COMBO2));
		index = SendDlgItemMessage(hwnd, IDC_COMBO2, CB_FINDSTRING, 0, (LPARAM)g_szFontName);
		SendDlgItemMessage(hwnd, IDC_COMBO2, CB_SETCURSEL, index, 0);
		UpdatePreview(hwnd);
		return 0;

	case WM_DESTROY:
		//DeInitMessage();
		return 0;

	case WM_CTLCOLORSTATIC:

		if(GetDlgCtrlID((HWND)lParam) == IDC_ABOUT)
		{
			SetTextColor((HDC)wParam, RGB(0,80,0));
			SetBkColor((HDC)wParam, GetSysColor(COLOR_3DFACE));
			return (BOOL)GetSysColorBrush(COLOR_3DFACE);
		}
		else if(GetDlgCtrlID((HWND)lParam) == IDC_PREVIEW)
		{
			HDC hdc = (HDC)wParam;
			RECT clip;

			GetDlgItemText(hwnd, IDC_COMBO1, buf, 256);
			
			GetClientRect((HWND)lParam, &rect);

			if(prevwidth < rect.right)
			{
				rect.left = (rect.right-prevwidth) / 2;
				rect.right = rect.left + prevwidth;
			}
			else
			{
				rect.left  = 0;
				rect.right = prevwidth;
			}		

			if(prevheight < rect.bottom)
			{
				rect.top = (rect.bottom-prevheight) / 2;
				rect.bottom = rect.top + prevheight;
			}
			else
			{
				rect.top = 0;
				rect.bottom = prevheight;
			}

			SetTextColor(hdc, RGB(128,255,128));
			SetBkColor(hdc, 0);

			//SetRect(&rect, 0, 0, PrevMessage->width, MAXMSG_HEIGHT);
			CopyRect(&clip, &rect);
			FillRect(hdc, &rect, GetStockObject(BLACK_BRUSH));

			SelectObject(hdc, g_hFont);

			InflateRect(&clip, 2, 2);

			FrameRect(hdc, &clip, GetSysColorBrush(COLOR_3DSHADOW));
			IntersectClipRect(hdc, rect.left, rect.top, rect.right, rect.bottom);

			// figure out where the bounding rectangle should be
			DrawText(hdc, buf, -1, &rect, DT_CENTER|DT_VCENTER|DT_WORDBREAK|DT_CALCRECT);
			OffsetRect(&rect, (prevwidth-(rect.right-rect.left))/2, (prevheight-(rect.bottom-rect.top))/2);

			// now draw it!
			DrawText(hdc, buf, -1, &rect, DT_CENTER|DT_VCENTER|DT_WORDBREAK);
			

			return (BOOL)GetStockObject(NULL_BRUSH);
		}	
		else
		{
			break;
		}

	case WM_HSCROLL:

		if((HWND)lParam == GetDlgItem(hwnd, IDC_SLIDER4))
		{
			// one of the sliders changed..update
			UpdatePreview(hwnd);
		}

		return 0;

	case WM_COMMAND:

		switch(HIWORD(wParam))
		{
		case CBN_EDITCHANGE:
		case CBN_SELCHANGE:

			//fall through to Preview:
			index = SendDlgItemMessage(hwnd, IDC_COMBO2, CB_GETCURSEL, 0, 0);
			SendDlgItemMessage(hwnd, IDC_COMBO2, CB_GETLBTEXT, index, (LPARAM)g_szFontName);
			//SetMessageFont(hwnd, g_szFontName, g_nFontSize, TRUE);
			
			UpdatePreview(hwnd);
			return 0;
		}

		switch(LOWORD(wParam))
		{
		case IDC_RANDOM:
			g_fRandomizeMessages = IsDlgButtonChecked(hwnd, IDC_RANDOM);
			break;

		case IDC_BOLD:
			g_fFontBold = IsDlgButtonChecked(hwnd, IDC_BOLD);
			UpdatePreview(hwnd);
			break;

		case IDOK:
			
			hwndCtrl = GetDlgItem(hwnd, IDC_COMBO1);

			items = min(MAX_MESSAGES, SendMessage(hwndCtrl, CB_GETCOUNT, 0, 0));

			for(index = 0; index < items; index++)
			{
				SendMessage(hwndCtrl, CB_GETLBTEXT, index, (LPARAM)g_szMessages[index]);
			}

			g_nNumMessages = items;
			
			//matrix speed
			val = SendDlgItemMessage(hwnd, IDC_SLIDER1, TBM_GETPOS, 0, 0);	
			if(val >= SPEED_MIN && val <= SPEED_MAX)
				g_nMatrixSpeed = val;

			//density
			val = SendDlgItemMessage(hwnd, IDC_SLIDER2, TBM_GETPOS, 0, 0);	
			if(val >= DENSITY_MIN && val <= DENSITY_MAX)
				g_nDensity = val;

			//message speed
			val = SendDlgItemMessage(hwnd, IDC_SLIDER3, TBM_GETPOS, 0, 0);	
			if(val >= MSGSPEED_MIN && val <= MSGSPEED_MAX)
				g_nMessageSpeed = val;

			//font size
			val = SendDlgItemMessage(hwnd, IDC_SLIDER4, TBM_GETPOS, 0, 0);	
			if(val >= FONT_MIN && val <= FONT_MAX)
				g_nFontSize = val;

			SaveSettings();
			EndDialog(hwnd, 0);
			return 0;

		case IDCANCEL:
			EndDialog(hwnd, 0);
			return TRUE;

		case IDC_ADD:
			
			hwndCombo = GetDlgItem(hwnd, IDC_COMBO1);
			
			if(GetWindowText(hwndCombo, buf, 256))
			{
				SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)buf);
			}
			
			UpdatePreview(hwnd);

			return 0;

		case IDC_REMOVE:
			hwndCombo = GetDlgItem(hwnd, IDC_COMBO1);
			GetWindowText(hwndCombo, buf, 256);

			index = SendMessage(hwndCombo, CB_GETCURSEL, 0, 0);
			SendMessage(hwndCombo, CB_DELETESTRING, index, 0);

			SendMessage(hwndCombo, CB_SETCURSEL, 0, 0);
			UpdatePreview(hwnd);
			return 0;
		}
		return 0;

	case WM_CLOSE:
		EndDialog(hwnd, 0);
		return 0;
	}
	return 0;
}