misc.c

来自「ANFY特效」· C语言 代码 · 共 1,430 行 · 第 1/3 页

C
1,430 行
字号
  {    strcat (strFile, g_strHelpDir);    strcat (strFile, "/blobs.html");    return StartBrowser(strFile);  }  else if (strcmp (szTopic, applet_info[APPLET_CUBEMENU].name ) == 0 )  {    strcat (strFile, g_strHelpDir);    strcat (strFile, "/cmenu.html");    return StartBrowser(strFile);  }  else if (strcmp (szTopic, applet_info[APPLET_DEFORM].name   ) == 0 )  {    strcat (strFile, g_strHelpDir);    strcat (strFile, "/deform.html");    return StartBrowser(strFile);  }  else if (strcmp (szTopic, applet_info[APPLET_FIRE].name     ) == 0 )  {    strcat (strFile, g_strHelpDir);    strcat (strFile, "/fire.html");    return StartBrowser(strFile);  }  else if (strcmp (szTopic, applet_info[APPLET_FLAGLOAD].name ) == 0 )  {    strcat (strFile, g_strHelpDir);    strcat (strFile, "/flag2.html");    return StartBrowser(strFile);  }  else if (strcmp (szTopic, applet_info[APPLET_FLOZOIDS].name ) == 0 )  {    strcat (strFile, g_strHelpDir);    strcat (strFile, "/flozoids.html");    return StartBrowser(strFile);  }  else if (strcmp (szTopic, applet_info[APPLET_FLUID].name    ) == 0 )  {    strcat (strFile, g_strHelpDir);    strcat (strFile, "/fluid.html");    return StartBrowser(strFile);  }  else if (strcmp (szTopic, applet_info[APPLET_HUEROT].name   ) == 0 )  {    strcat (strFile, g_strHelpDir);    strcat (strFile, "/huerot.html");    return StartBrowser(strFile);  }  else if (strcmp (szTopic, applet_info[APPLET_MANDEL].name   ) == 0 )  {    strcat (strFile, g_strHelpDir);    strcat (strFile, "/mandel.html");    return StartBrowser(strFile);  }  else if (strcmp (szTopic, applet_info[APPLET_LIFE2D].name   ) == 0 )  {    strcat (strFile, g_strHelpDir);    strcat (strFile, "/life2d.html");    return StartBrowser(strFile);  }  else if (strcmp (szTopic, applet_info[APPLET_ROTATE].name   ) == 0 )  {    strcat (strFile, g_strHelpDir);    strcat (strFile, "/rot.html");    return StartBrowser(strFile);  }  else if (strcmp (szTopic, applet_info[APPLET_PLASMA].name   ) == 0 )  {    strcat (strFile, g_strHelpDir);    strcat (strFile, "/plasma.html");    return StartBrowser(strFile);  }  else if (strcmp (szTopic, applet_info[APPLET_ANTUNNEL].name ) == 0 )  {    strcat (strFile, g_strHelpDir);    strcat (strFile, "/tunnel.html");    return StartBrowser(strFile);  }  else if (strcmp (szTopic, applet_info[APPLET_TMAPCUBE].name ) == 0 )  {    strcat (strFile, g_strHelpDir);    strcat (strFile, "/tcube.html");    return StartBrowser(strFile);  }  else if (strcmp (szTopic, applet_info[APPLET_ANVOXEL].name	 ) == 0 )  {    strcat (strFile, g_strHelpDir);    strcat (strFile, "/voxel.html");    return StartBrowser(strFile);  }  else if (strcmp (szTopic, applet_info[APPLET_TUNNEL3D].name ) == 0 )  {    strcat (strFile, g_strHelpDir);    strcat (strFile, "/tunnel2.html");    return StartBrowser(strFile);  }  else if (strcmp (szTopic, applet_info[APPLET_ANWATER].name  ) == 0 )  {    strcat (strFile, g_strHelpDir);    strcat (strFile, "/water.html");    return StartBrowser(strFile);  }  else if (strcmp (szTopic, applet_info[APPLET_WARP].name     ) == 0 )  {    strcat (strFile, g_strHelpDir);    strcat (strFile, "/warp.html");    return StartBrowser(strFile);  }  else if (strcmp (szTopic, applet_info[APPLET_WORMHOLE].name ) == 0 )  {    strcat (strFile, g_strHelpDir);    strcat (strFile, "/worm.html");    return StartBrowser(strFile);  }  else if (strcmp (szTopic, applet_info[APPLET_GALAXY].name   ) == 0 )  {    strcat (strFile, g_strHelpDir);    strcat (strFile, "/galaxy.html");    return StartBrowser(strFile);  }  else if (strcmp (szTopic, applet_info[APPLET_BOOKFLIP].name ) == 0 )  {    strcat (strFile, g_strHelpDir);    strcat (strFile, "/bookflip.html");    return StartBrowser(strFile);  }  else if (strcmp (szTopic, applet_info[APPLET_MOSAIC].name	) == 0 )  {    strcat (strFile, g_strHelpDir);    strcat (strFile, "/mosaic.html");    return StartBrowser(strFile);  }  else if (strcmp (szTopic, applet_info[APPLET_ANFY3D].name	) == 0 )  {      strcat (strFile, g_strHelpDir);      strcat (strFile, "/anfy3dl.html");      return StartBrowser(strFile);  }  else if (strcmp (szTopic, applet_info[APPLET_WHEEL].name	) == 0 )  {    strcat (strFile, g_strHelpDir);    strcat (strFile, "/wheel.html");    return StartBrowser(strFile);  }  else if (strcmp (szTopic, applet_info[APPLET_MORPHMENU].name) == 0 )  {    strcat (strFile, g_strHelpDir);    strcat (strFile, "/morph.html");    return StartBrowser(strFile);  }  else if (strcmp (szTopic, applet_info[APPLET_WOBBLER].name	) == 0 )  {    strcat (strFile, g_strHelpDir);    strcat (strFile, "/wobbler.html");    return StartBrowser(strFile);  }  else if (strcmp (szTopic, applet_info[APPLET_TSCROLLER].name) == 0 )  {    strcat (strFile, g_strHelpDir);    strcat (strFile, "/text.html");    return StartBrowser(strFile);  }  else if (strcmp (szTopic, applet_info[APPLET_TREEMENU].name	) == 0 )  {    strcat (strFile, g_strHelpDir);    strcat (strFile, "/tree.html");    return StartBrowser(strFile);  }  else if (strcmp (szTopic, applet_info[APPLET_ANFYCAM].name	) == 0 )  {    strcat (strFile, g_strHelpDir);    strcat (strFile, "/anfycam.html");    return StartBrowser(strFile);  }  else if (strcmp (szTopic, applet_info[APPLET_ANFYPAINT].name) == 0 )  {    strcat (strFile, g_strHelpDir);    strcat (strFile, "/anfypaint.html");    return StartBrowser(strFile);  }  else if (strcmp (szTopic, applet_info[APPLET_SOLIDSCROLLER].name) == 0 )  {    strcat (strFile, g_strHelpDir);    strcat (strFile, "/solidscr.html");    return StartBrowser(strFile);  }  else if (strcmp (szTopic, applet_info[APPLET_ANFYSNOW].name) == 0 )	  {    strcat (strFile, g_strHelpDir);    strcat (strFile, "/ansnow.html");    return StartBrowser(strFile);  }  else if (strcmp (szTopic, applet_info[APPLET_FIREWORKS].name) == 0 )  {    strcat (strFile, g_strHelpDir);    strcat (strFile, "/fireworks.html");    return StartBrowser(strFile);  }  {    GtkWidget *dlg, *vbox, *w, *hbox, *t;    char* txt;    FILE* f;    int len;    dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);    gtk_window_set_title (GTK_WINDOW (dlg), _("Text"));    gtk_window_set_default_size (GTK_WINDOW (dlg), 500, 400);    vbox = gtk_vbox_new (FALSE, 5);    gtk_widget_show (vbox);    gtk_container_add (GTK_CONTAINER (dlg), vbox);    gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);    t = gtk_text_new (NULL, NULL);    gtk_widget_show (t);    gtk_box_pack_start (GTK_BOX (vbox), t, TRUE, TRUE, 0);    hbox = gtk_hbox_new (FALSE, 10);    gtk_widget_show (hbox);    gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);    w = gtk_button_new_with_label (_("OK"));    gtk_widget_show (w);    gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);    gtk_widget_set_usize (w, 75, 22);    gtk_signal_connect_object (GTK_OBJECT (w), "clicked",			       (GtkSignalFunc) gtk_widget_destroy, GTK_OBJECT (dlg));    f = fopen (strFile, "rb");    if (f == NULL)      return 0;    fseek (f, 0, SEEK_END);    len = ftell (f);    rewind (f);    txt = g_malloc (len+1);    len = fread (txt, 1, len, f);    txt[len] = '\0';    gtk_text_insert (GTK_TEXT (t), NULL, NULL, NULL, txt, len);    g_free (txt);    gtk_widget_show (dlg);  }  return 1;}typedef struct _AnfyFontProp{  char name[1024];  guint32 width;  guint32 height;  guint32 vertSpacing;  char charOrder[1024];  char description[1024];} AnfyFontProp;static int GetAnfyFontProp (char* pathFileFont, AnfyFontProp* afp){  int bRet = 1;  char strTmp[1024];  FILE* f;  f = fopen (pathFileFont, "rt");  if (f == NULL)    return 0;  if (fgets (afp->name, 1024, f) == NULL)    bRet=FALSE;  if (fgets (strTmp, 1024, f) == NULL)    bRet=FALSE;  afp->width=_ttoi(strTmp);  if ( afp->width == 0 )    bRet=FALSE;  if (fgets (strTmp, 1024, f) == NULL)    bRet=FALSE;  afp->height=_ttoi(strTmp);  if( afp->height == 0 )    bRet=FALSE;  if (fgets (strTmp, 1024, f) == NULL)    bRet=FALSE;  afp->vertSpacing=_ttoi(strTmp);  if (fgets (afp->charOrder, 1024, f) == NULL)    bRet=FALSE;  fgets (afp->description, 1024, f);  fgets (strTmp, 1024, f);  strcat (afp->description, "\r\n");  strcat (afp->description, strTmp);  fclose (f);  return bRet;}int UpdateFontProperties (char* cstrFontFile){  int bRet = 1;  char buf[16];  AnfyFontProp afp;  if (GetAnfyFontProp (cstrFontFile, &afp))  {    sprintf (buf, "%d", afp.width);    gtk_entry_set_text (GTK_ENTRY (lookup_widget (main_dlg, "width")), buf);    sprintf (buf, "%d", afp.height);    gtk_entry_set_text (GTK_ENTRY (lookup_widget (main_dlg, "height")), buf);    sprintf (buf, "%d", afp.vertSpacing);    gtk_entry_set_text (GTK_ENTRY (lookup_widget (main_dlg, "v_spac")), buf);    gtk_entry_set_text (GTK_ENTRY (lookup_widget (main_dlg, "chars")), afp.charOrder);    gtk_text_insert (GTK_TEXT (lookup_widget (main_dlg, "comment")), NULL, NULL, NULL,    		     afp.description, strlen(afp.description));    gtk_adjustment_set_value (GTK_TEXT(lookup_widget (main_dlg, "comment"))->vadj, 0);  }  else  {    gtk_entry_set_text (GTK_ENTRY (lookup_widget (main_dlg, "width")), "");    gtk_entry_set_text (GTK_ENTRY (lookup_widget (main_dlg, "height")), "");    gtk_entry_set_text (GTK_ENTRY (lookup_widget (main_dlg, "v_spac")), "");    gtk_entry_set_text (GTK_ENTRY (lookup_widget (main_dlg, "chars")), "");    gtk_text_insert (GTK_TEXT (lookup_widget (main_dlg, "comment")), NULL, NULL, NULL,		     "", strlen(0));    bRet = 0;  }  return bRet;}char GetMenuLinkNext(char* strAppletName, char cActualLink){  char nextLink = 0;  if (strcmp (strAppletName, applet_info[APPLET_WHEEL].name) == 0)  {    nextLink=cActualLink+1;  }  else if (strcmp (strAppletName, applet_info[APPLET_MORPHMENU].name) == 0)  {    if( cActualLink >='0' && cActualLink < '9' )      nextLink=cActualLink+1;    else if( cActualLink == '9' )      nextLink='a';    else if( cActualLink >='a' && cActualLink < 'j' )      nextLink=cActualLink+1;  }  return nextLink;}extern int mozilla_remote (char *command);void execute_program (char *program, char *arg){  pid_t pid;   pid = fork ();  if (pid == 0)    {      pid = fork ();      if (pid == 0)        {          execlp (program, program, arg, NULL);          _exit (0);        }      else        {          _exit (0);        }    } }int StartBrowser (char* szPageHtml){  char url[1024];  sprintf (url, "openURL(%s,new-window)", szPageHtml);   if (!mozilla_remote (url))  {    execute_program ("netscape", szPageHtml);    return 0;  }  else    return 1;  message_box (_("Create process failed, verify browser setting"), 0);  return 0;  /*	TCHAR szEXE[_MAX_PATH];	CString strTMP;	CString strDDEServerName;	GetSavedVar(_T(""), INI_BROWSER, strTMP);	if( strTMP == INI_DEF_BROWSER )	{		CString strHtmlFile;		strHtmlFile = g_strAppPath;		strHtmlFile += _T("\\");		strHtmlFile += g_strHelpDir;		strHtmlFile += HTML_HELP_ROOT;		//trova il percoso del programma associato ai file di tipo html		if( FindExecutable( strHtmlFile, NULL, szEXE ) <=(HINSTANCE)32 )			return FALSE;	}	else		//utilizza il browser specificato dall'utente		lstrcpy(szEXE, strTMP);	BOOL bNavigator=FALSE;	if( _tcsstr(_tcsupr(szEXE), _T("NETSCAPE")) != NULL )	{		strDDEServerName = DDE_SNAME_NAVIGATOR ;		bNavigator=TRUE;	}	else		if( _tcsstr(_tcsupr(szEXE), _T("IEXPLORE")) != NULL )			strDDEServerName = DDE_SNAME_IE ;		else			goto create_process;	if( !ConnectDDE(strDDEServerName) )		goto create_process;		if( !ExecuteDDE(strDDEServerName, szPageHtml) )		goto create_process;	//se c'e' gia una finestra aperta la attiva e la porta in primo	//piano	if( g_hwndMainBrowser != NULL )	{		::ShowWindow(g_hwndMainBrowser, SW_SHOWNORMAL );		::SetWindowPos(g_hwndMainBrowser, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );	}	return TRUE;create_process:	DisconnectDDE();	//se non era ancora stato avviato il browser lo avvia ora	lstrcat(szEXE, _T(" "));	lstrcat(szEXE, szPageHtml);	STARTUPINFO si;	PROCESS_INFORMATION pi;	memset(&si, 0, sizeof(si));	si.cb = sizeof(si);	if( CreateProcess(	NULL, szEXE, 						NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,						&si,						&pi						) )	{		TRACE(_T("CreateProcess\n"));		WaitForInputIdle( pi.hProcess, INFINITE ); 		EnumThreadWindows( pi.dwThreadId, (WNDENUMPROC)EnumThreadWndProc, (LPARAM)&g_hwndMainBrowser );		TRACE(_T("HWND borwser : 0x%x\n"),g_hwndMainBrowser);		return TRUE;	}	else		return FALSE;  */}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?