Esempio n. 1
0
AutoMounter::AutoMounter(bool _DEVICE_MAP_ONLY(checkRemovableOnly),
	bool _DEVICE_MAP_ONLY(checkCDs), bool _DEVICE_MAP_ONLY(checkFloppies),
	bool _DEVICE_MAP_ONLY(checkOtherRemovable), bool _DEVICE_MAP_ONLY(autoMountRemovablesOnly),
	bool _DEVICE_MAP_ONLY(autoMountAll), bool _DEVICE_MAP_ONLY(autoMountAllBFS),
	bool _DEVICE_MAP_ONLY(autoMountAllHFS),
	bool initialMountAll, bool initialMountAllBFS, bool initialMountRestore,
	bool initialMountAllHFS)
	:	BLooper("DirPoller", B_LOW_PRIORITY),
		fInitialMountAll(initialMountAll),
		fInitialMountAllBFS(initialMountAllBFS),
		fInitialMountRestore(initialMountRestore),
		fInitialMountAllHFS(initialMountAllHFS),
		fSuspended(false),
		fQuitting(false)
{
#if _INCLUDES_CLASS_DEVICE_MAP
	fScanParams.shortestRescanHartbeat = 5000000;
	fScanParams.checkFloppies = checkFloppies;
	fScanParams.checkCDROMs = checkCDs;
	fScanParams.checkOtherRemovable = checkOtherRemovable;
	fScanParams.removableOrUnknownOnly = checkRemovableOnly;
	
	fAutomountParams.mountAllFS = autoMountAll;
	fAutomountParams.mountBFS = autoMountAllBFS;
	fAutomountParams.mountHFS = autoMountAllHFS;
	fAutomountParams.mountRemovableDisksOnly = autoMountRemovablesOnly;

	gSilentAutoMounter = true;
	
	if (!BootedInSafeMode()) {
		ReadSettings();
		thread_id rescan = spawn_thread(AutoMounter::InitialRescanBinder, 
			"AutomountInitialScan", B_DISPLAY_PRIORITY, this);
		resume_thread(rescan);
	} else {
		// defeat automounter in safe mode, don't even care about the settings
		fAutomountParams.mountAllFS = false;
		fAutomountParams.mountBFS = false;
		fAutomountParams.mountHFS = false;
		fInitialMountAll = false;
		fInitialMountAllBFS = false;
		fInitialMountRestore = false;
		fInitialMountAllHFS = false;
	}

	//	Watch mount/unmount
	TTracker::WatchNode(0, B_WATCH_MOUNT, this);
#endif
}
Esempio n. 2
0
SPU2init()
{
    assert(regtable[0x400] == NULL);

    if (IsInitialized) {
        printf(" * SPU2-X: Already initialized - Ignoring SPU2init signal.");
        return 0;
    }

    IsInitialized = true;

    ReadSettings();

#ifdef SPU2_LOG
    if (AccessLog()) {
        spu2Log = OpenLog(AccessLogFileName);
        setvbuf(spu2Log, NULL, _IONBF, 0);
        FileLog("SPU2init\n");
    }
#endif
    srand((unsigned)time(NULL));

    spu2regs = (s16 *)malloc(0x010000);
    _spu2mem = (s16 *)malloc(0x200000);

    // adpcm decoder cache:
    //  the cache data size is determined by taking the number of adpcm blocks
    //  (2MB / 16) and multiplying it by the decoded block size (28 samples).
    //  Thus: pcm_cache_data = 7,340,032 bytes (ouch!)
    //  Expanded: 16 bytes expands to 56 bytes [3.5:1 ratio]
    //    Resulting in 2MB * 3.5.

    pcm_cache_data = (PcmCacheEntry *)calloc(pcm_BlockCount, sizeof(PcmCacheEntry));

    if ((spu2regs == NULL) || (_spu2mem == NULL) || (pcm_cache_data == NULL)) {
        SysMessage("SPU2-X: Error allocating Memory\n");
        return -1;
    }

    // Patch up a copy of regtable that directly maps "NULLs" to SPU2 memory.

    memcpy(regtable, regtable_original, sizeof(regtable));

    for (uint mem = 0; mem < 0x800; mem++) {
        u16 *ptr = regtable[mem >> 1];
        if (!ptr) {
            regtable[mem >> 1] = &(spu2Ru16(mem));
        }
    }
	UserFiltersModel::UserFiltersModel (QObject *parent)
	: QAbstractItemModel (parent)
	{
		ReadSettings ();
		Headers_ << tr ("Filter")
			<< tr ("Policy")
			<< tr ("Type")
			<< tr ("Case sensitive")
			<< tr ("Domains");

		qRegisterMetaType<FilterItem> ("LeechCraft::Poshuku::CleanWeb::FilterItem");
		qRegisterMetaType<QList<FilterItem>> ("QList<LeechCraft::Poshuku::CleanWeb::FilterItem>");
		qRegisterMetaTypeStreamOperators<FilterItem> ("LeechCraft::Poshuku::CleanWeb::FilterItem");
		qRegisterMetaTypeStreamOperators<QList<FilterItem>> ("QList<LeechCraft::Poshuku::CleanWeb::FilterItem>");
	}
Esempio n. 4
0
	UserFiltersModel::UserFiltersModel (QObject *parent)
	: QAbstractItemModel (parent)
	{
		ReadSettings ();
		Headers_ << tr ("Filter")
			<< tr ("Policy")
			<< tr ("Type")
			<< tr ("Case sensitive")
			<< tr ("Domains");

		qRegisterMetaType<RegExpsDict_t> ("LeechCraft::Poshuku::CleanWeb::RegExpsDict_t");
		qRegisterMetaType<OptionsDict_t> ("LeechCraft::Poshuku::CleanWeb::OptionsDict_t");
		qRegisterMetaTypeStreamOperators<RegExpsDict_t> ("LeechCraft::Poshuku::CleanWeb::RegExpsDict_t");
		qRegisterMetaTypeStreamOperators<OptionsDict_t> ("LeechCraft::Poshuku::CleanWeb::OptionsDict_t");
	}
Esempio n. 5
0
FolderShaper::FolderShaper	(void)
:	BApplication	(FS_APP_SIGNATURE)
{
//	default values
	m_settings_file 	=	new BFile();
	m_tmpl_dir			=	new BDirectory();
	m_fs_window			=	NULL;
	m_got_refs			=	false;
	m_stay_open 		=	false;
	m_do_quit			=	false;
	m_do_move			=	true;
	m_do_open			=	FS_IF_ORIGINAL_OPEN;
	m_do_clobber		=	false;
	m_do_keep_position	=	true;
	m_do_clean_up		=	false;
	m_winloc.Set(200,200);
	m_messenger = new BMessenger();
	 
	status_t  status;
	
	if ((status = CreateTemplatesFolder())	!= B_OK)	// find templates dir
	{
		beep();
		ErrorMessage("CreateTemplatesFolder()", status);
		SeriousError();
	}

	if ((status = CreateSettingsFile()) != B_OK)	// find settings file
	{
		beep();
		ErrorMessage("CreateSettingsFile()", status);
		SeriousError();
	}
	
	ReadSettings();								// read settings
	
	if ((m_tmpl_dir->	CountEntries()) < 1)	// no templates ?
	{
		OpenTemplatesFolder();
		snooze(500000);
		AddTemplatesMessage();
	}
	
	// create window
	m_fs_window = new FolderShaperWindow(m_winloc, m_do_move, m_do_open, 	
		m_do_clobber, m_do_keep_position, m_do_clean_up);
										 
}
Esempio n. 6
0
/**
 * @brief Completes the second phase of Symbian object construction. 
 * Put initialization code that could leave here. 
 */ 
void CTap2MenuAppUi::ConstructL()
	{
	// [[[ begin generated region: do not modify [Generated Contents]
	ReadSettings();
	ReadExceptions();
	BaseConstructL( EAknEnableSkin  | 
					 EAknEnableMSK ); 
	InitializeContainersL();
	// ]]] end generated region [Generated Contents]
	
	iWinGroup=new (ELeave) RWindowGroup(CEikonEnv::Static()->WsSession());
	iWinGroup->Construct((TUint32)&iWinGroup, EFalse);
	iWinGroup->EnableReceiptOfFocus(EFalse); // Don't capture any key events.
	iWinGroup->SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront);
	
	CApaWindowGroupName* wn=CApaWindowGroupName::NewL(CEikonEnv::Static()->WsSession());
	wn->SetHidden(ETrue);
	wn->SetSystem(ETrue);
	wn->SetWindowGroupName(*iWinGroup);
	delete wn;
	iButton=CContainerButton::NewL(iWinGroup);
	iButton->SetSize(TSize(iSettings[4],iSettings[4]));
	iButton->SetPosition(TPoint(iSettings[0],iSettings[1]));
	iButton->MakeVisible(ETrue);
	CGulIcon* icon;
	const TUid KMenuUid=TUid::Uid(0x101f4cd2);
	TRAPD(erreasy,icon=LoadAppIconEasy(KMenuUid));
	if (erreasy==KErrNotFound)
		{
		CFbsBitmap*	AppIcon(NULL);
		CFbsBitmap*	AppIconMsk(NULL);
		AknIconUtils::CreateIconL(AppIcon,AppIconMsk,_L("\\resource\\apps\\Tap2Menu_aif.mif"), EMbmTap2menu_aifQgn_menu_tap2menu, EMbmTap2menu_aifQgn_menu_tap2menu_mask);
		AknIconUtils::SetSize(AppIcon,TSize(iSettings[4],iSettings[4]));
		AknIconUtils::SetSize(AppIconMsk,TSize(iSettings[4],iSettings[4]));
		icon=CGulIcon::NewL(AppIcon,AppIconMsk);
		}
	else if (erreasy!=KErrNone){TRAPD(errhard,icon=LoadAppIconHard(KMenuUid));}
	iButton->SetIcon(icon);
	iButton->MakeVisible(ETrue);
	iButton->DrawNow();
	iWsSession=new (ELeave) RWsSession();
	iWsSession->Connect();
	UpdateSettings();
	iObserver=CFgrObserver::NewL(*iWsSession,*this);
	CEikonEnv::Static()->RootWin().SetOrdinalPosition(-4);
	HideApplicationFromFSW(ETrue);
	}
Esempio n. 7
0
SelectImages::SelectImages(QString basepath, QList<Resource *> image_resources, QString default_selected_image, QWidget *parent) :
    QDialog(parent),
    m_Basepath(basepath),
    m_ImageResources(image_resources),
    m_SelectImagesModel(new QStandardItemModel),
    m_PreviewLoaded(false),
    m_DefaultSelectedImage(default_selected_image),
    m_ThumbnailSize(THUMBNAIL_SIZE)
{
    ui.setupUi(this);

    ReadSettings();

    SetImages();

    connectSignalsSlots();
}
Esempio n. 8
0
LONG CALLBACK
SystemApplet(VOID)
{
    PGLOBAL_DATA pGlobalData;
    PROPSHEETPAGE psp[5];
    PROPSHEETHEADER psh;
    TCHAR Caption[1024];
    INT ret;

    LoadString(hApplet, IDS_CPLSYSTEMNAME, Caption, sizeof(Caption) / sizeof(TCHAR));

    pGlobalData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(GLOBAL_DATA));
    if (pGlobalData == NULL)
        return 0;

    if (!ReadSettings(pGlobalData))
    {
        HeapFree(GetProcessHeap(), 0, pGlobalData);
        return 0;
    }

    ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
    psh.dwSize = sizeof(PROPSHEETHEADER);
    psh.dwFlags =  PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK;
    psh.hwndParent = hCPLWindow;
    psh.hInstance = hApplet;
    psh.pszIcon = MAKEINTRESOURCEW(IDI_CPLACCESS);
    psh.pszCaption = Caption;
    psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
    psh.nStartPage = 0;
    psh.ppsp = psp;
    psh.pfnCallback = PropSheetProc;

    InitPropSheetPage(&psp[0], IDD_PROPPAGEKEYBOARD, KeyboardPageProc, pGlobalData);
    InitPropSheetPage(&psp[1], IDD_PROPPAGESOUND, SoundPageProc, pGlobalData);
    InitPropSheetPage(&psp[2], IDD_PROPPAGEDISPLAY, DisplayPageProc, pGlobalData);
    InitPropSheetPage(&psp[3], IDD_PROPPAGEMOUSE, MousePageProc, pGlobalData);
    InitPropSheetPage(&psp[4], IDD_PROPPAGEGENERAL, GeneralPageProc, pGlobalData);

    ret = PropertySheet(&psh);

    HeapFree(GetProcessHeap(), 0, pGlobalData);

    return (LONG)(ret != -1);
}
Esempio n. 9
0
void configure()
{
    ReadSettings();

    GtkDialogFlags flags = static_cast<GtkDialogFlags>(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT);
    GtkWidget *dialog = gtk_dialog_new_with_buttons("Config", nullptr,
                                                    flags,
                                                    "Cancel", GTK_RESPONSE_REJECT,
                                                    "Ok", GTK_RESPONSE_ACCEPT,
                                                    nullptr);

    GtkWidget *label = gtk_label_new("Device:");
    GtkWidget *combobox = gtk_combo_box_text_new();

    auto drives = GetOpticalDriveList();
    std::string drive;
    g_settings.Get("drive", drive);
    for (size_t n = 0; n < drives.size(); ++n) {
        gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combobox), drives[n].c_str());
        if (drive == drives[n])
            gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), n);
    }

#if GTK_MAJOR_VERSION >= 3
    GtkWidget *box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
#else
    GtkWidget *box = gtk_vbox_new(0, 10);
#endif
    gtk_box_pack_start(GTK_BOX(box), label, 0, 0, 0);
    gtk_box_pack_start(GTK_BOX(box), combobox, 0, 0, 10);

    GtkWidget *content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
    gtk_container_add(GTK_CONTAINER(content_area), box);

    Settings settings_copy = g_settings;
    g_signal_connect(combobox, "changed", G_CALLBACK(ComboboxCallback), &settings_copy);

    gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER_ALWAYS);
    gtk_widget_show_all(dialog);
    if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
        g_settings = settings_copy;
        WriteSettings();
    }
    gtk_widget_destroy(dialog);
}
Esempio n. 10
0
void noiseenvironment::regenerate()
{
    ReadSettings();

    for (int n=0; n<MainWin->ui->spinSize->value(); n++)
       for (int m=0; m<MainWin->ui->spinSize->value(); m++)
            {
            for (int i=0;i<3;i++)
                {
                int noiseVal;

                do{noiseVal=Rand8();}while(noiseVal<nMin || noiseVal>nMax);

                environment[n][m][i]=noiseVal;
                }
            }

}
Esempio n. 11
0
void IRemotePCSettings::ReadGlobalSettings()
{
	CommonSettingsStruct *pCommonSettings = GetCommonSettings();

	IniFile.ReadString("ConnectionSettings", "IP", DEFAULT_IP, pCommonSettings->ConnectionSettings.ip, 16);
	IniFile.ReadString("ConnectionSettings", "Password", NULL, pCommonSettings->ConnectionSettings.pw, 32);
	pCommonSettings->ConnectionSettings.Port = IniFile.ReadInteger("ConnectionSettings", "Port", DEFAULT_PORT);

	ReadSettings();

	pCommonSettings->WndCoords.l = IniFile.ReadInteger("ScreenSettings", "WndLeft", 0);
	pCommonSettings->WndCoords.t = IniFile.ReadInteger("ScreenSettings", "WndTop", 0);
	pCommonSettings->WndCoords.w = IniFile.ReadInteger("ScreenSettings", "WndWidth", 0);
	pCommonSettings->WndCoords.h = IniFile.ReadInteger("ScreenSettings", "WndHeight", 0);
	pCommonSettings->WndCoords.wState = IniFile.ReadInteger("ScreenSettings", "WndState", 0);

	pCommonSettings->LangID = IniFile.ReadInteger("Lang", "LanguageID", 0);
}
TBorders Settings::GetBordersConstant(TSettingConstants constant)
{
	if(!iSettingsRead)
	{
	//	WriteSettings();
		ReadSettings();
	}
	switch(constant)
	{
	case 	EImageBorders:
		{
			return KImageBorders;
			break;
		}
		case 	EImageExplorerBorders:
		{
			return KImageExplorerBorders;
			break;
		}
			case 	EWorkspaceExplorerBorders:
		{
			return KWorkspaceExplorerBorders;
			break;
		}
			case 	EWorkspaceBorders:
		{
			return KWorkspaceBorders;
			break;
		}
			case 	EWorkspaceSnapshotBorders:
		{
			return KWorkspaceSnapshotBorders;
			break;
		}

	default:
		break;

	};
	TBorders ret = {0,0,0,0};
	
	return ret;
}
Esempio n. 13
0
void PrintSettings(){
    QlSysTimer loct;
    ReadSettings();
    Ql_GetLocalTime(&loct);
     s32 simcard;
     s32 creg;
     s32 cgreg;
     u8 rssi;
     u8 ber;
     char pp[8];
     Ql_GetDeviceCurrentRunState(&simcard, &creg, &cgreg, &rssi, &ber);
     GetTextStateGpio(&pp[0]);
     OUTER("\r\nAPN=%s IP=%d.%d.%d.%d TCP=%d USER=%s PASS=%s DEBUG=%s LOG=%s NUM=%d TSEND=%d DATE=%.2d.%.2d.%.2d TIME=%.2d:%.2d:%.2d DEBOUNCE=%d LocalIp=%s WUser=%s WPass=%s\r\n\r\n ***** SIM:%d GSM:%d GPRS:%d PINS=%s SIGNAL:%ddBm ******\r\n",
                      __settings.APN,__settings.IP[0],__settings.IP[1],__settings.IP[2],__settings.IP[3],
                      __settings.TCP,__settings.User,__settings.Pass,__settings.Debug,__settings.Log,__settings.Num,__settings.TSend,
                     loct.day,loct.month,loct.year,loct.hour,loct.minute,loct.second,__settings.Deboung,
                     __str_loc_ip_addr,__settings.WUser,__settings.WPass,simcard,creg,cgreg,&pp[0],rssi);
     
}
Esempio n. 14
0
CSettings::CSettings() :
	m_Set_SyncViaAudioEnabled(0),
    m_Set_EnableAudio(0),
    m_Set_FixedAudio(0),
    m_Set_SyncAudio(0),
    m_Set_FullSpeed(0),
    m_Set_LimitFPS(0),
    m_Set_basic_mode(0),
    m_Set_debugger(0),
    m_Set_log_dir(0),
    m_Set_log_flush(0),
    m_FlushLogs(false),
    m_AudioEnabled(true),
    m_advanced_options(false),
    m_debugger_enabled(false),
    m_Volume(100),
    m_TinyBuffer(true),
    m_FPSBuffer(true),
    m_FixedAudio(false),
    m_SyncAudio(false),
    m_FullSpeed(true)
{
    memset(m_log_dir, 0, sizeof(m_log_dir));
    RegisterSettings();
    ReadSettings();

    if (m_Set_EnableAudio != 0) { SettingsRegisterChange(true, m_Set_EnableAudio, this, stSettingsChanged); }
    if (m_Set_basic_mode != 0) { SettingsRegisterChange(true, m_Set_basic_mode, this, stSettingsChanged); }
    if (m_Set_debugger != 0) { SettingsRegisterChange(true, m_Set_debugger, this, stSettingsChanged); }
    if (m_Set_log_flush != 0) { SettingsRegisterChange(true, m_Set_log_flush, this, stSettingsChanged); }
    if (m_Set_FixedAudio != 0) { SettingsRegisterChange(true, m_Set_FixedAudio, this, stSettingsChanged); }
    if (m_Set_SyncAudio != 0) { SettingsRegisterChange(true, m_Set_SyncAudio, this, stSettingsChanged); }
    if (m_Set_FullSpeed != 0) { SettingsRegisterChange(true, m_Set_FullSpeed, this, stSettingsChanged); }
    if (m_Set_LimitFPS != 0) { SettingsRegisterChange(true, m_Set_LimitFPS, this, stSettingsChanged); }
    SettingsRegisterChange(false, Set_Volume, this, stSettingsChanged);

    SettingsRegisterChange(false, Set_Logging_MD5, this, stLogLevelChanged);
    SettingsRegisterChange(false, Set_Logging_Thread, this, stLogLevelChanged);
    SettingsRegisterChange(false, Set_Logging_Path, this, stLogLevelChanged);
    SettingsRegisterChange(false, Set_Logging_InitShutdown, this, stLogLevelChanged);
    SettingsRegisterChange(false, Set_Logging_Interface, this, stLogLevelChanged);
    SettingsRegisterChange(false, Set_Logging_Driver, this, stLogLevelChanged);
}
Esempio n. 15
0
void ChatPanel::Init(const wxString& panelname)
{
	m_chatpanelname = panelname;

	//Clear some controls pointer that can be used in ReadSettings
	m_say_text = nullptr;
	m_chatlog_text = nullptr;

	//Read settings
	ReadSettings();
	CreateControls();
	SetLogFile(panelname);

	GetAui().manager->AddPane(this, wxLEFT, _T("chatpanel-channel-") + panelname);
	m_chatlog_text->Connect(wxEVT_RIGHT_DOWN, wxMouseEventHandler(ChatPanel::OnMouseDown), 0, this);

	SUBSCRIBE_GLOBAL_EVENT(GlobalEventManager::OnLogin, ChatPanel::OnLogin);
	SUBSCRIBE_GLOBAL_EVENT(GlobalEventManager::ApplicationSettingsChangedEvent, ChatPanel::OnSettingsChanged);
}
Esempio n. 16
0
MainWindow::MainWindow(int argc, char** argv, QWidget *parent)
	: QMainWindow(parent)
	, qnode(argc,argv)
{
	ui.setupUi(this); // Calling this incidentally connects all ui's triggers to on_...() callbacks in this class.

    /*********************
    ** a simple uas table view
    **********************/
    model = new QStandardItemModel(2,4,this); //2 Rows and 4 Columns

    model->setHorizontalHeaderItem(0, new QStandardItem(QString("Sensor type")));
    model->setHorizontalHeaderItem(1, new QStandardItem(QString("FoV size (m)")));
    model->setHorizontalHeaderItem(2, new QStandardItem(QString("Autonomy %")));
    model->setHorizontalHeaderItem(3, new QStandardItem(QString("Task")));
    model->setHorizontalHeaderItem(4, new QStandardItem(QString("Latitude")));
    model->setHorizontalHeaderItem(5, new QStandardItem(QString("Longitude")));

    ui.table_view_uas->setModel(model);

    /*******************************************/

    QObject::connect(ui.actionAbout_Qt, SIGNAL(triggered(bool)), qApp, SLOT(aboutQt()));

    ReadSettings();
    ui.tab_manager->setCurrentIndex(1); // ensure the second tab is showing - qt-designer should have this already hardwired, but often loses it (settings?).
    QObject::connect(&qnode, SIGNAL(rosShutdown()), this, SLOT(close()));

    /*********************
    ** Logging
	**********************/

	ui.view_logging->setModel(qnode.loggingModel());
    QObject::connect(&qnode, SIGNAL(loggingUpdated()), this, SLOT(updateLoggingView()));

    /*********************
    ** Auto Start
    **********************/
    if ( ui.checkbox_remember_settings->isChecked() ) {
        on_button_connect_clicked(true);
    }
}
Esempio n. 17
0
// Constructor;
// the first parameter is the book whose TOC
// is being edited, the second is the dialog's parent
HeadingSelector::HeadingSelector(QSharedPointer<Book> book, QWidget *parent)
    :
    QDialog(parent),
    m_Book(book),
    m_ContextMenu(new QMenu(this)),
    m_book_changed(false)
{
    ui.setupUi(this);
    ui.tvTOCDisplay->setContextMenuPolicy(Qt::CustomContextMenu);
    ui.tvTOCDisplay->installEventFilter(this);
    CreateContextMenuActions();
    ConnectSignalsToSlots();
    ui.tvTOCDisplay->setModel(&m_TableOfContents);
    LockHTMLResources();
    QList<Headings::Heading> flat_headings = Headings::GetHeadingList(
                m_Book->GetFolderKeeper().GetResourceTypeList<HTMLResource>(true), true);
    m_Headings = Headings::MakeHeadingHeirarchy(flat_headings);
    PopulateSelectHeadingCombo(GetMaxHeadingLevel(flat_headings));
    RefreshTOCModelDisplay();
    ReadSettings();
}
Esempio n. 18
0
EditTOC::EditTOC(QSharedPointer<Book> book, QList<Resource *> resources, QWidget *parent)
    :
    QDialog(parent),
    m_Book(book),
    m_Resources(resources),
    m_TableOfContents(new QStandardItemModel(this)),
    m_ContextMenu(new QMenu(this)),
    m_NCXModel(new NCXModel(this))
{
    ui.setupUi(this);
    ui.TOCTree->setContextMenuPolicy(Qt::CustomContextMenu);
    ui.TOCTree->installEventFilter(this);
    ui.TOCTree->setModel(m_TableOfContents);
    ui.TOCTree->setIndentation(COLUMN_INDENTATION);
    CreateContextMenuActions();
    ConnectSignalsToSlots();

    CreateTOCModel();
    UpdateTreeViewDisplay();
    ReadSettings();
}
Esempio n. 19
0
SpellcheckEditor::SpellcheckEditor(QWidget *parent)
    :
    QDialog(parent),
    m_Book(NULL),
    m_SpellcheckEditorModel(new QStandardItemModel(this)),
    m_ContextMenu(new QMenu(this)),
    m_MultipleSelection(false),
    m_SelectRow(-1),
    m_FilterSC(new QShortcut(QKeySequence(tr("f", "Filter")), this)),
    m_ShowAllSC(new QShortcut(QKeySequence(tr("s", "ShowAllWords")), this)),
    m_NoCaseSC(new QShortcut(QKeySequence(tr("c", "Case-InsensitiveSort")), this)),
    m_RefreshSC(new QShortcut(QKeySequence(tr("r", "Refresh")), this))
{
    ui.setupUi(this);
    ui.FilterText->installEventFilter(this);

    SetupSpellcheckEditorTree();
    CreateContextMenuActions();
    ConnectSignalsSlots();
    UpdateDictionaries();
    ReadSettings();
}
Esempio n. 20
0
MainWindow::MainWindow(Backend *backend)
    :m_backend(backend)
{
    QAction *new_regtab_act = new QAction(QIcon::fromTheme("document-new"), tr("Register &Tab"), this);
    QAction *new_regedit_act = new QAction(QIcon::fromTheme("document-edit"), tr("Register &Editor"), this);
    QAction *load_desc_act = new QAction(QIcon::fromTheme("document-open"), tr("&Soc Description"), this);
    QAction *quit_act = new QAction(QIcon::fromTheme("application-exit"), tr("&Quit"), this);
    QAction *about_act = new QAction(QIcon::fromTheme("help-about"), tr("&About"), this);
    QAction *about_qt_act = new QAction(QIcon::fromTheme("help-about"), tr("About &Qt"), this);

    connect(new_regtab_act, SIGNAL(triggered()), this, SLOT(OnNewRegTab()));
    connect(new_regedit_act, SIGNAL(triggered()), this, SLOT(OnNewRegEdit()));
    connect(load_desc_act, SIGNAL(triggered()), this, SLOT(OnLoadDesc()));
    connect(quit_act, SIGNAL(triggered()), this, SLOT(OnQuit()));
    connect(about_act, SIGNAL(triggered()), this, SLOT(OnAbout()));
    connect(about_qt_act, SIGNAL(triggered()), this, SLOT(OnAboutQt()));

    QMenu *file_menu = menuBar()->addMenu(tr("&File"));
    QMenu *new_submenu = file_menu->addMenu(QIcon::fromTheme("document-new"), "&New");
    QMenu *load_submenu = file_menu->addMenu(QIcon::fromTheme("document-open"), "&Load");
    file_menu->addAction(quit_act);

    new_submenu->addAction(new_regtab_act);
    new_submenu->addAction(new_regedit_act);

    load_submenu->addAction(load_desc_act);

    QMenu *about_menu = menuBar()->addMenu(tr("&About"));
    about_menu->addAction(about_act);
    about_menu->addAction(about_qt_act);

    m_tab = new MyTabWidget();

    setCentralWidget(m_tab);

    ReadSettings();

    OnNewRegTab();
}
Esempio n. 21
0
void Cwinproc::ShowPropertiesDlg() {
	if (m_pPropertiesDlg != NULL)
		m_pPropertiesDlg->SetForegroundWindow();
	else {
		// Fake out MFC in order to receive the "minimize all windows" syscommand message
		// The window is restored in initdialog
		theApp.m_pMainWnd = NULL;
		
		m_pPropertiesDlg = new DlgPropSheet(SZ_APPNAME, NULL);
		m_pPropertiesDlg->m_psh.dwFlags |= PSH_NOAPPLYNOW | PSH_MODELESS;
		
		if (m_pPropertiesDlg->DoModal() == IDOK)
			SaveSettings();
		else
			ReadSettings();
		
		delete m_pPropertiesDlg;
		m_pPropertiesDlg = NULL;
		
		SetTimer(TIMER_ID_WINPROC, g_nSampleRate, NULL);
	}
}
Esempio n. 22
0
int glide64InitiateGFX (GFX_INFO Gfx_Info)
{
   char name[21] = "DEFAULT";

   rdp_new();

   // Assume scale of 1 for debug purposes
   rdp.scale_x = 1.0f;
   rdp.scale_y = 1.0f;

   memset (&settings, 0, sizeof(SETTINGS));
   ReadSettings ();
   ReadSpecialSettings (name);

   math_init ();
   TexCacheInit ();
   CRC_BuildTable();
   CountCombine();
   if (fb_depth_render_enabled)
      ZLUT_init();

   return true;
}
std::shared_ptr<slaim::PostOffice> CreatePostOffice(PostOfficeInitializer& initializer, const char* clientIdentifier) {
	const std::string host = initializer.GetMessagingServerHost();
	const int port = initializer.GetMessagingServerPort();
	const std::string username = initializer.GetMessagingServerUsername();
	const std::string password = initializer.GetMessagingServerPassword();

	std::ostringstream oss;
	if (!username.empty() && !password.empty()) {
		oss << username << ":" << password << "@";
	}
	if (host.empty()) {
		oss << "localhost";
	}
	else {
		oss << host;
	}
	oss << ":" << port;
	std::string connectInfo = oss.str();

	auto postOffice = std::make_shared<numrabw::PostOffice>(connectInfo, clientIdentifier);
	postOffice->ReadSettings(initializer);

	return postOffice;
}
Esempio n. 24
0
int WINAPI createCfgDlg()
{
  g_is_back=0;
  g_is_cancel=0;

  HWND mainwnd = hMainWindow;
  if (!mainwnd)
  {
    popstring(NULL);
    pushstring("error finding mainwnd");
    return 1; // cannot be used in silent mode unfortunately.
  }

  if (!g_stacktop || !*g_stacktop || !(pszFilename = (*g_stacktop)->text) || !pszFilename[0] || !ReadSettings())
  {
    popstring(NULL);
    pushstring("error finding config");
    return 1;
  }

  HWND childwnd=GetDlgItem(mainwnd,nRectId);
  if (!childwnd)
  {
    popstring(NULL);
    pushstring("error finding childwnd");
    return 1;
  }

  hCancelButton = GetDlgItem(mainwnd,IDCANCEL);
  hNextButton = GetDlgItem(mainwnd,IDOK);
  hBackButton = GetDlgItem(mainwnd,3);

  mySetWindowText(hCancelButton,pszCancelButtonText);
  mySetWindowText(hNextButton,pszNextButtonText);
  mySetWindowText(hBackButton,pszBackButtonText);

  if (bBackEnabled!=-1) EnableWindow(hBackButton,bBackEnabled);
  if (bCancelEnabled!=-1) EnableWindow(hCancelButton,bCancelEnabled);
  if (bCancelShow!=-1) old_cancel_visible=ShowWindow(hCancelButton,bCancelShow?SW_SHOWNA:SW_HIDE);

  HFONT hFont = (HFONT)mySendMessage(mainwnd, WM_GETFONT, 0, 0);

  RECT dialog_r;
  int mainWndWidth, mainWndHeight;
  hConfigWindow=CreateDialog(m_hInstance,MAKEINTRESOURCE(IDD_DIALOG1),mainwnd,cfgDlgProc);
  if (hConfigWindow)
  {
    GetWindowRect(childwnd,&dialog_r);
    MapWindowPoints(0, mainwnd, (LPPOINT) &dialog_r, 2);
    mainWndWidth = dialog_r.right - dialog_r.left;
    mainWndHeight = dialog_r.bottom - dialog_r.top;
    SetWindowPos(
      hConfigWindow,
      0,
      dialog_r.left,
      dialog_r.top,
      mainWndWidth,
      mainWndHeight,
      SWP_NOZORDER|SWP_NOACTIVATE
    );
    // Sets the font of IO window to be the same as the main window
    mySendMessage(hConfigWindow, WM_SETFONT, (WPARAM)hFont, TRUE);
  }
  else
  {
    popstring(NULL);
    pushstring("error creating dialog");
    return 1;
  }

  // Init dialog unit conversion

  HDC memDC = CreateCompatibleDC(GetDC(hConfigWindow));
  SelectObject(memDC, hFont);

  TEXTMETRIC tm;
  GetTextMetrics(memDC, &tm);
  int baseUnitY = tm.tmHeight;

  SIZE size;
  GetTextExtentPoint32(memDC,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 52, &size);
  int baseUnitX = (size.cx / 26 + 1) / 2;

  DeleteDC(memDC);

  BOOL fFocused = FALSE;

#define DEFAULT_STYLES (WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS)

  for (int nIdx = 0; nIdx < nNumFields; nIdx++) {
    static struct {
      char* pszClass;
      DWORD dwStyle;
      DWORD dwRTLStyle;
      DWORD dwExStyle;
      DWORD dwRTLExStyle;
    } ClassTable[] = {
      { "STATIC",       // FIELD_LABEL
        DEFAULT_STYLES,
        DEFAULT_STYLES | SS_RIGHT,
        WS_EX_TRANSPARENT,
        WS_EX_TRANSPARENT | WS_EX_RTLREADING },
      { "STATIC",       // FIELD_ICON
        DEFAULT_STYLES | SS_ICON,
        DEFAULT_STYLES | SS_ICON,
        0,
        WS_EX_RTLREADING },
      { "STATIC",       // FIELD_BITMAP
        DEFAULT_STYLES | SS_BITMAP | SS_CENTERIMAGE,
        DEFAULT_STYLES | SS_BITMAP | SS_CENTERIMAGE,
        0,
        WS_EX_RTLREADING },
      { "BUTTON",       // FIELD_BROWSEBUTTON
        DEFAULT_STYLES | WS_TABSTOP,
        DEFAULT_STYLES | WS_TABSTOP,
        0,
        WS_EX_RTLREADING },
      { "BUTTON",       // FIELD_CHECKBOX
        DEFAULT_STYLES | WS_TABSTOP | BS_TEXT | BS_VCENTER | BS_AUTOCHECKBOX | BS_MULTILINE,
        DEFAULT_STYLES | WS_TABSTOP | BS_TEXT | BS_VCENTER | BS_AUTOCHECKBOX | BS_MULTILINE | BS_RIGHT | BS_LEFTTEXT,
        0,
        WS_EX_RTLREADING },
      { "BUTTON",       // FIELD_RADIOBUTTON
        DEFAULT_STYLES | WS_TABSTOP | BS_TEXT | BS_VCENTER | BS_AUTORADIOBUTTON | BS_MULTILINE,
        DEFAULT_STYLES | WS_TABSTOP | BS_TEXT | BS_VCENTER | BS_AUTORADIOBUTTON | BS_MULTILINE | BS_RIGHT | BS_LEFTTEXT,
        0,
        WS_EX_RTLREADING },
      { "EDIT",         // FIELD_TEXT
        DEFAULT_STYLES | WS_TABSTOP | ES_AUTOHSCROLL,
        DEFAULT_STYLES | WS_TABSTOP | ES_AUTOHSCROLL | ES_RIGHT,
        WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE,
        WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_RTLREADING },
      { "EDIT",         // FIELD_FILEREQUEST
        DEFAULT_STYLES | WS_TABSTOP | ES_AUTOHSCROLL,
        DEFAULT_STYLES | WS_TABSTOP | ES_AUTOHSCROLL | ES_RIGHT,
        WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE,
        WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_RTLREADING },
      { "EDIT",         // FIELD_DIRREQUEST
        DEFAULT_STYLES | WS_TABSTOP | ES_AUTOHSCROLL,
        DEFAULT_STYLES | WS_TABSTOP | ES_AUTOHSCROLL | ES_RIGHT,
        WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE,
        WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_RTLREADING },
      { "COMBOBOX",     // FIELD_COMBOBOX
        DEFAULT_STYLES | WS_TABSTOP | WS_VSCROLL | WS_CLIPCHILDREN | CBS_AUTOHSCROLL | CBS_HASSTRINGS,
        DEFAULT_STYLES | WS_TABSTOP | WS_VSCROLL | WS_CLIPCHILDREN | CBS_AUTOHSCROLL | CBS_HASSTRINGS,
        WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE,
        WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_RIGHT | WS_EX_RTLREADING },
      { "LISTBOX",      // FIELD_LISTBOX
        DEFAULT_STYLES | WS_TABSTOP | WS_VSCROLL | LBS_DISABLENOSCROLL | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT,
        DEFAULT_STYLES | WS_TABSTOP | WS_VSCROLL | LBS_DISABLENOSCROLL | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT,
        WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE,
        WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_RIGHT | WS_EX_RTLREADING },
      { "BUTTON",       // FIELD_GROUPBOX
        DEFAULT_STYLES | BS_GROUPBOX,
        DEFAULT_STYLES | BS_GROUPBOX | BS_RIGHT,
        WS_EX_TRANSPARENT,
        WS_EX_TRANSPARENT | WS_EX_RTLREADING },
      { "BUTTON",       // FIELD_LINK
        DEFAULT_STYLES | WS_TABSTOP | BS_OWNERDRAW,
        DEFAULT_STYLES | WS_TABSTOP | BS_OWNERDRAW | BS_RIGHT,
        0,
        WS_EX_RTLREADING },
      { "BUTTON",       // FIELD_BUTTON
        DEFAULT_STYLES | WS_TABSTOP,
        DEFAULT_STYLES | WS_TABSTOP,
        0,
        WS_EX_RTLREADING }
    };

    FieldType *pField = pFields + nIdx;

#undef DEFAULT_STYLES

    if (pField->nType < 1 || pField->nType > (sizeof(ClassTable) / sizeof(ClassTable[0])))
      continue;

    DWORD dwStyle, dwExStyle;
    if (bRTL) {
      dwStyle = ClassTable[pField->nType - 1].dwRTLStyle;
      dwExStyle = ClassTable[pField->nType - 1].dwRTLExStyle;
    }
    else {
      dwStyle = ClassTable[pField->nType - 1].dwStyle;
      dwExStyle = ClassTable[pField->nType - 1].dwExStyle;
    }

    // Convert from dialog units

    RECT rect;

    rect.left = MulDiv(pField->rect.left, baseUnitX, 4);
    rect.right = MulDiv(pField->rect.right, baseUnitX, 4);
    rect.top = MulDiv(pField->rect.top, baseUnitY, 8);
    rect.bottom = MulDiv(pField->rect.bottom, baseUnitY, 8);

    if (pField->rect.left < 0)
      rect.left += mainWndWidth;
    if (pField->rect.right < 0)
      rect.right += mainWndWidth;
    if (pField->rect.top < 0)
      rect.top += mainWndHeight;
    if (pField->rect.bottom < 0)
      rect.bottom += mainWndHeight;

    if (bRTL) {
      int right = rect.right;
      rect.right = mainWndWidth - rect.left;
      rect.left = mainWndWidth - right;
    }

    char *title = pField->pszText;
    switch (pField->nType) {
      case FIELD_ICON:
      case FIELD_BITMAP:
        title = NULL; // otherwise it is treated as the name of a resource
        break;
      case FIELD_CHECKBOX:
      case FIELD_RADIOBUTTON:
        dwStyle ^= pField->nFlags & BS_LEFTTEXT;
        break;
      case FIELD_TEXT:
      case FIELD_FILEREQUEST:
      case FIELD_DIRREQUEST:
        if (pField->nFlags & FLAG_PASSWORD)
          dwStyle |= ES_PASSWORD;
        if (pField->nFlags & FLAG_ONLYNUMBERS)
          dwStyle |= ES_NUMBER;
        if (pField->nFlags & FLAG_WANTRETURN)
          dwStyle |= ES_WANTRETURN;
        if (pField->nFlags & FLAG_READONLY)
          dwStyle |= ES_READONLY;
        title = pField->pszState;
        if (pField->nFlags & FLAG_MULTILINE)
        {
          dwStyle |= ES_MULTILINE | ES_AUTOVSCROLL;
          // Enable word-wrap unless we have a horizontal scroll bar
          // or it has been explicitly disallowed
          if (!(pField->nFlags & (WS_HSCROLL | FLAG_NOWORDWRAP)))
            dwStyle &= ~ES_AUTOHSCROLL;
          ConvertNewLines(pField->pszState);
          // If multiline-readonly then hold the text back until after the
          // initial focus has been set. This is so the text is not initially
          // selected - useful for License Page look-a-likes.
          if (pField->nFlags & FLAG_READONLY)
            title = NULL;
        }
        break;
      case FIELD_COMBOBOX:
        dwStyle |= (pField->nFlags & FLAG_DROPLIST) ? CBS_DROPDOWNLIST : CBS_DROPDOWN;
        title = pField->pszState;
        break;
      case FIELD_LISTBOX:
        dwStyle |= pField->nFlags & (LBS_NOTIFY | LBS_MULTIPLESEL | LBS_EXTENDEDSEL);
        break;
    }

    dwStyle |= pField->nFlags & (WS_GROUP | WS_HSCROLL | WS_VSCROLL | WS_DISABLED);
    if (pField->nFlags & WS_TABSTOP) dwStyle &= ~WS_TABSTOP;

    HWND hwCtrl = pField->hwnd = CreateWindowEx(
      dwExStyle,
      ClassTable[pField->nType - 1].pszClass,
      title,
      dwStyle,
      rect.left,
      rect.top,
      rect.right - rect.left,
      rect.bottom - rect.top,
      hConfigWindow,
      (HMENU)pField->nControlID,
      m_hInstance,
      NULL
    );

    if (hwCtrl) {
      // Sets the font of IO window to be the same as the main window
      mySendMessage(hwCtrl, WM_SETFONT, (WPARAM)hFont, TRUE);
      // make sure we created the window, then set additional attributes
      switch (pField->nType) {
        case FIELD_TEXT:
        case FIELD_FILEREQUEST:
        case FIELD_DIRREQUEST:
          mySendMessage(hwCtrl, EM_LIMITTEXT, (WPARAM)pField->nMaxLength, (LPARAM)0);
          break;

        case FIELD_CHECKBOX:
        case FIELD_RADIOBUTTON:
          if (pField->pszState[0] == '1')
            mySendMessage(hwCtrl, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
          break;

        case FIELD_COMBOBOX:
        case FIELD_LISTBOX:
          // if this is a listbox or combobox, we need to add the list items.
          if (pField->pszListItems) {
            UINT nAddMsg, nFindMsg, nSetSelMsg;
            if (pField->nType == FIELD_COMBOBOX) {
              nAddMsg = CB_ADDSTRING;
              nFindMsg = CB_FINDSTRINGEXACT;
              nSetSelMsg = CB_SETCURSEL;
            }
            else {
              nAddMsg = LB_ADDSTRING;
              nFindMsg = LB_FINDSTRINGEXACT;
              nSetSelMsg = LB_SETCURSEL;
            }
            char *pszStart, *pszEnd, *pszList;
            pszStart = pszEnd = pszList = STRDUP(pField->pszListItems);
            while ((*pszEnd) && (*pszStart)) {
              if (*pszEnd == '|') {
                *pszEnd = '\0';
                if (pszEnd > pszStart) {
                  mySendMessage(hwCtrl, nAddMsg, 0, (LPARAM)pszStart);
                }
                // jump to the next item, skip any redundant | characters
                do { pszEnd++; } while (*pszEnd == '|');
                pszStart = pszEnd;
              }
              pszEnd++;
            }
            FREE(pszList);
            if (pField->pszState) {
              if (pField->nFlags & (LBS_MULTIPLESEL|LBS_EXTENDEDSEL) && nFindMsg == LB_FINDSTRINGEXACT) {
                mySendMessage(hwCtrl, LB_SETSEL, FALSE, -1);
                pszStart = pszEnd = pField->pszState;
                while (*pszStart) {
                  char cLast = *pszEnd;
                  if (*pszEnd == '|') *pszEnd = '\0';
                  if (!*pszEnd) {
                    if (pszEnd > pszStart) {
                      int nItem = mySendMessage(hwCtrl, nFindMsg, -1, (LPARAM)pszStart);
                      if (nItem != CB_ERR) { // CB_ERR == LB_ERR == -1
                        mySendMessage(hwCtrl, LB_SETSEL, TRUE, nItem);
                      }
                    }
                    if (cLast) {
                      do {
                        pszEnd++;
                      } while (*pszEnd == '|');
                    }
                    pszStart = pszEnd;
                  }
                  pszEnd++;
                }
              }
              else {
                int nItem = mySendMessage(hwCtrl, nFindMsg, -1, (LPARAM)pField->pszState);
                if (nItem != CB_ERR) { // CB_ERR == LB_ERR == -1
                  mySendMessage(hwCtrl, nSetSelMsg, nItem, 0);
                }
              }
            }
          }
          break;

        case FIELD_ICON:
        case FIELD_BITMAP:
        {
          WPARAM nImageType = pField->nType == FIELD_BITMAP ? IMAGE_BITMAP : IMAGE_ICON;
          LPARAM nImage = 0;
          if (pField->pszText) {
            pField->hImage = LoadImage(
              m_hInstance,
              pField->pszText,
              nImageType,
              (pField->nFlags & FLAG_RESIZETOFIT)
                ? (rect.right - rect.left)
                : 0,
              (pField->nFlags & FLAG_RESIZETOFIT)
                ? (rect.bottom - rect.top)
                : 0,
              LR_LOADFROMFILE
            );
            nImage = (LPARAM)pField->hImage;
          }
          else
            nImage = (LPARAM)LoadIcon(GetModuleHandle(0), MAKEINTRESOURCE(103));
          mySendMessage(
            hwCtrl,
            STM_SETIMAGE,
            nImageType,
            nImage
          );
          break;
        }

#ifdef IO_ENABLE_LINK
        case FIELD_LINK:
          pField->nParentIdx = SetWindowLong(hwCtrl, GWL_WNDPROC, (long)StaticLINKWindowProc);
          break;
#endif
      }

      // Set initial focus to the first appropriate field
      if (!fFocused && (dwStyle & (WS_TABSTOP | WS_DISABLED)) == WS_TABSTOP) {
        fFocused = TRUE;
        mySetFocus(hwCtrl);
      }

      // If multiline-readonly then hold the text back until after the
      // initial focus has been set. This is so the text is not initially
      // selected - useful for License Page look-a-likes.
      if ((pField->nFlags & (FLAG_MULTILINE | FLAG_READONLY)) == (FLAG_MULTILINE | FLAG_READONLY))
        mySetWindowText(hwCtrl, pField->pszState);
    }
  }

  if (!fFocused)
    mySetFocus(hNextButton);

  mySetWindowText(mainwnd,pszTitle);
  pFilenameStackEntry = *g_stacktop;
  *g_stacktop = (*g_stacktop)->next;
  static char tmp[32];
  wsprintf(tmp,"%d",hConfigWindow);
  pushstring(tmp);
  return 0;
}
Esempio n. 25
0
int WINAPI createCfgDlg()
{
  g_is_back=0;
  g_is_cancel=0;

  HWND mainwnd = hMainWindow;
  if (!mainwnd)
  {
    popstring(NULL);
    pushstring("error finding mainwnd");
    return 1; // cannot be used in silent mode unfortunately.
  }

  if (!g_stacktop || !*g_stacktop || !(pszFilename = (*g_stacktop)->text) || !pszFilename[0] || !ReadSettings())
  {
    popstring(NULL);
    pushstring("error finding config");
    return 1;
  }

  HWND childwnd=GetDlgItem(mainwnd,nRectId);
  if (!childwnd)
  {
    popstring(NULL);
    pushstring("error finding childwnd");
    return 1;
  }

  hCancelButton = GetDlgItem(mainwnd,IDCANCEL);
  hNextButton = GetDlgItem(mainwnd,IDOK);
  hBackButton = GetDlgItem(mainwnd,3);

  mySetWindowText(hCancelButton,pszCancelButtonText);
  mySetWindowText(hNextButton,pszNextButtonText);
  mySetWindowText(hBackButton,pszBackButtonText);

  if (bBackEnabled!=-1) EnableWindow(hBackButton,bBackEnabled);
  if (bCancelEnabled!=-1) EnableWindow(hCancelButton,bCancelEnabled);
  if (bCancelShow!=-1) old_cancel_visible=ShowWindow(hCancelButton,bCancelShow?SW_SHOWNA:SW_HIDE);

  HFONT hFont = (HFONT)mySendMessage(mainwnd, WM_GETFONT, 0, 0);

  // Prevent WM_COMMANDs from being processed while we are building
  g_done = 1;

  int mainWndWidth, mainWndHeight;
  hConfigWindow=CreateDialog(m_hInstance,MAKEINTRESOURCE(IDD_DIALOG1),mainwnd,cfgDlgProc);
  if (hConfigWindow)
  {
    RECT dialog_r;
    GetWindowRect(childwnd,&dialog_r);
    MapWindowPoints(0, mainwnd, (LPPOINT) &dialog_r, 2);
    mainWndWidth = dialog_r.right - dialog_r.left;
    mainWndHeight = dialog_r.bottom - dialog_r.top;
    SetWindowPos(
      hConfigWindow,
      0,
      dialog_r.left,
      dialog_r.top,
      mainWndWidth,
      mainWndHeight,
      SWP_NOZORDER|SWP_NOACTIVATE
    );
    // Sets the font of IO window to be the same as the main window
    mySendMessage(hConfigWindow, WM_SETFONT, (WPARAM)hFont, TRUE);
  }
  else
  {
    popstring(NULL);
    pushstring("error creating dialog");
    return 1;
  }

  BOOL fFocused = FALSE;
  BOOL fFocusedByFlag = FALSE;

#define DEFAULT_STYLES (WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS)
#define RTL_EX_STYLES (WS_EX_RTLREADING | WS_EX_LEFTSCROLLBAR)

  for (int nIdx = 0; nIdx < nNumFields; nIdx++) {
    static struct {
      char* pszClass;
      DWORD dwStyle;
      DWORD dwRTLStyle;
      DWORD dwExStyle;
      DWORD dwRTLExStyle;
    } ClassTable[] = {
      { "STATIC",       // FIELD_LABEL
        DEFAULT_STYLES,
        DEFAULT_STYLES | SS_RIGHT,
        WS_EX_TRANSPARENT,
        WS_EX_TRANSPARENT | RTL_EX_STYLES },
      { "STATIC",       // FIELD_ICON
        DEFAULT_STYLES | SS_ICON,
        DEFAULT_STYLES | SS_ICON,
        0,
        RTL_EX_STYLES },
      { "STATIC",       // FIELD_BITMAP
        DEFAULT_STYLES | SS_BITMAP,
        DEFAULT_STYLES | SS_BITMAP,
        0,
        RTL_EX_STYLES },
      { "BUTTON",       // FIELD_BROWSEBUTTON
        DEFAULT_STYLES | WS_TABSTOP,
        DEFAULT_STYLES | WS_TABSTOP,
        0,
        RTL_EX_STYLES },
      { "BUTTON",       // FIELD_LINK
        DEFAULT_STYLES | WS_TABSTOP | BS_OWNERDRAW,
        DEFAULT_STYLES | WS_TABSTOP | BS_OWNERDRAW | BS_RIGHT,
        0,
        RTL_EX_STYLES },
      { "BUTTON",       // FIELD_BUTTON
        DEFAULT_STYLES | WS_TABSTOP,
        DEFAULT_STYLES | WS_TABSTOP,
        0,
        RTL_EX_STYLES },
      { "BUTTON",       // FIELD_GROUPBOX
        DEFAULT_STYLES | BS_GROUPBOX,
        DEFAULT_STYLES | BS_GROUPBOX | BS_RIGHT,
        WS_EX_TRANSPARENT,
        WS_EX_TRANSPARENT | RTL_EX_STYLES },
      { "BUTTON",       // FIELD_CHECKBOX
        DEFAULT_STYLES | WS_TABSTOP | BS_TEXT | BS_VCENTER | BS_AUTOCHECKBOX | BS_MULTILINE,
        DEFAULT_STYLES | WS_TABSTOP | BS_TEXT | BS_VCENTER | BS_AUTOCHECKBOX | BS_MULTILINE | BS_RIGHT | BS_LEFTTEXT,
        0,
        RTL_EX_STYLES },
      { "BUTTON",       // FIELD_RADIOBUTTON
        DEFAULT_STYLES | WS_TABSTOP | BS_TEXT | BS_VCENTER | BS_AUTORADIOBUTTON | BS_MULTILINE,
        DEFAULT_STYLES | WS_TABSTOP | BS_TEXT | BS_VCENTER | BS_AUTORADIOBUTTON | BS_MULTILINE | BS_RIGHT | BS_LEFTTEXT,
        0,
        RTL_EX_STYLES },
      { "EDIT",         // FIELD_TEXT
        DEFAULT_STYLES | WS_TABSTOP | ES_AUTOHSCROLL,
        DEFAULT_STYLES | WS_TABSTOP | ES_AUTOHSCROLL | ES_RIGHT,
        WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE,
        WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | RTL_EX_STYLES },
      { "EDIT",         // FIELD_FILEREQUEST
        DEFAULT_STYLES | WS_TABSTOP | ES_AUTOHSCROLL,
        DEFAULT_STYLES | WS_TABSTOP | ES_AUTOHSCROLL | ES_RIGHT,
        WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE,
        WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | RTL_EX_STYLES },
      { "EDIT",         // FIELD_DIRREQUEST
        DEFAULT_STYLES | WS_TABSTOP | ES_AUTOHSCROLL,
        DEFAULT_STYLES | WS_TABSTOP | ES_AUTOHSCROLL | ES_RIGHT,
        WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE,
        WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | RTL_EX_STYLES },
      { "COMBOBOX",     // FIELD_COMBOBOX
        DEFAULT_STYLES | WS_TABSTOP | WS_VSCROLL | WS_CLIPCHILDREN | CBS_AUTOHSCROLL | CBS_HASSTRINGS,
        DEFAULT_STYLES | WS_TABSTOP | WS_VSCROLL | WS_CLIPCHILDREN | CBS_AUTOHSCROLL | CBS_HASSTRINGS,
        WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE,
        WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_RIGHT | RTL_EX_STYLES },
      { "LISTBOX",      // FIELD_LISTBOX
        DEFAULT_STYLES | WS_TABSTOP | WS_VSCROLL | LBS_DISABLENOSCROLL | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT,
        DEFAULT_STYLES | WS_TABSTOP | WS_VSCROLL | LBS_DISABLENOSCROLL | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT,
        WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE,
        WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_RIGHT | RTL_EX_STYLES }
    };

    FieldType *pField = pFields + nIdx;

#undef DEFAULT_STYLES

    if (pField->nType < 1 || pField->nType > (sizeof(ClassTable) / sizeof(ClassTable[0])))
      continue;

    DWORD dwStyle, dwExStyle;
    if (bRTL) {
      dwStyle = ClassTable[pField->nType - 1].dwRTLStyle;
      dwExStyle = ClassTable[pField->nType - 1].dwRTLExStyle;
    }
    else {
      dwStyle = ClassTable[pField->nType - 1].dwStyle;
      dwExStyle = ClassTable[pField->nType - 1].dwExStyle;
    }

    // Convert from dialog units

    RECT rect = pField->rect;
    // MapDialogRect uses the font used when a dialog is created, and ignores
    // any subsequent WM_SETFONT messages (like we used above); so use the main
    // NSIS window for the conversion, instead of this one.
    MapDialogRect(mainwnd, &rect);

    if (pField->rect.left < 0)
      rect.left += mainWndWidth;
    if (pField->rect.right < 0)
      rect.right += mainWndWidth;
    if (pField->rect.top < 0)
      rect.top += mainWndHeight;
    if (pField->rect.bottom < 0)
      rect.bottom += mainWndHeight;

    if (bRTL) {
      int right = rect.right;
      rect.right = mainWndWidth - rect.left;
      rect.left = mainWndWidth - right;
    }

    char *title = pField->pszText;
    switch (pField->nType) {
      case FIELD_ICON:
      case FIELD_BITMAP:
        title = NULL; // otherwise it is treated as the name of a resource
        break;
      case FIELD_CHECKBOX:
      case FIELD_RADIOBUTTON:
        dwStyle ^= pField->nFlags & BS_LEFTTEXT;
        break;
      case FIELD_TEXT:
      case FIELD_FILEREQUEST:
      case FIELD_DIRREQUEST:
        if (pField->nFlags & FLAG_PASSWORD)
          dwStyle |= ES_PASSWORD;
        if (pField->nFlags & FLAG_ONLYNUMBERS)
          dwStyle |= ES_NUMBER;
        if (pField->nFlags & FLAG_WANTRETURN)
          dwStyle |= ES_WANTRETURN;
        if (pField->nFlags & FLAG_READONLY)
          dwStyle |= ES_READONLY;
        title = pField->pszState;
        if (pField->nFlags & FLAG_MULTILINE)
        {
          dwStyle |= ES_MULTILINE | ES_AUTOVSCROLL;
          // Enable word-wrap unless we have a horizontal scroll bar
          // or it has been explicitly disallowed
          if (!(pField->nFlags & (WS_HSCROLL | FLAG_NOWORDWRAP)))
            dwStyle &= ~ES_AUTOHSCROLL;
          ConvertNewLines(pField->pszState);
          // If multiline-readonly then hold the text back until after the
          // initial focus has been set. This is so the text is not initially
          // selected - useful for License Page look-a-likes.
          if (pField->nFlags & FLAG_READONLY)
            title = NULL;
        }
        break;
      case FIELD_COMBOBOX:
        dwStyle |= (pField->nFlags & FLAG_DROPLIST) ? CBS_DROPDOWNLIST : CBS_DROPDOWN;
        title = pField->pszState;
        break;
      case FIELD_LISTBOX:
        dwStyle |= pField->nFlags & (LBS_NOTIFY | LBS_MULTIPLESEL | LBS_EXTENDEDSEL);
        break;
    }

    dwStyle |= pField->nFlags & (WS_GROUP | WS_HSCROLL | WS_VSCROLL | WS_DISABLED);
    if (pField->nFlags & WS_TABSTOP) dwStyle &= ~WS_TABSTOP;

    HWND hwCtrl = pField->hwnd = CreateWindowEx(
      dwExStyle,
      ClassTable[pField->nType - 1].pszClass,
      title,
      dwStyle,
      rect.left,
      rect.top,
      rect.right - rect.left,
      rect.bottom - rect.top,
      hConfigWindow,
      (HMENU)pField->nControlID,
      m_hInstance,
      NULL
    );

    {
      char szField[64];
      char szHwnd[64];
      wsprintf(szField, "Field %d", pField->nField);
      wsprintf(szHwnd, "%d", hwCtrl);
      WritePrivateProfileString(szField, pField->pszHwndEntry, szHwnd, pszFilename);
    }

    if (hwCtrl) {
      // Sets the font of IO window to be the same as the main window
      mySendMessage(hwCtrl, WM_SETFONT, (WPARAM)hFont, TRUE);
      // make sure we created the window, then set additional attributes
      switch (pField->nType) {
        case FIELD_TEXT:
        case FIELD_FILEREQUEST:
        case FIELD_DIRREQUEST:
          mySendMessage(hwCtrl, EM_LIMITTEXT, (WPARAM)pField->nMaxLength, (LPARAM)0);
          if (dwStyle & ES_NUMBER)
          {
            pField->wndProc = GetWindowLong(hwCtrl, GWL_WNDPROC);
            SetWindowLong(hwCtrl, GWL_WNDPROC, (long) NumbersOnlyPasteWndProc);
          }
          break;

        case FIELD_CHECKBOX:
        case FIELD_RADIOBUTTON:
          if (pField->pszState[0] == '1')
            mySendMessage(hwCtrl, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
          break;

        case FIELD_COMBOBOX:
        case FIELD_LISTBOX:
          // if this is a listbox or combobox, we need to add the list items.
          if (pField->pszListItems) {
            UINT nAddMsg, nFindMsg, nSetSelMsg;
            if (pField->nType == FIELD_COMBOBOX) {
              nAddMsg = CB_ADDSTRING;
              nFindMsg = CB_FINDSTRINGEXACT;
              nSetSelMsg = CB_SETCURSEL;
            }
            else {
              nAddMsg = LB_ADDSTRING;
              nFindMsg = LB_FINDSTRINGEXACT;
              nSetSelMsg = LB_SETCURSEL;
            }
            char *pszStart, *pszEnd, *pszList;
            pszStart = pszEnd = pszList = STRDUP(pField->pszListItems);
            // pszListItems has a trailing pipe
            while (*pszEnd) {
              if (*pszEnd == '|') {
                *pszEnd = '\0';
                if (*pszStart)
                  mySendMessage(hwCtrl, nAddMsg, 0, (LPARAM) pszStart);
                pszStart = ++pszEnd;
              }
              else
                pszEnd = CharNext(pszEnd);
            }
            FREE(pszList);
            if (pField->pszState) {
              if (pField->nFlags & (LBS_MULTIPLESEL|LBS_EXTENDEDSEL) && nFindMsg == LB_FINDSTRINGEXACT) {
                mySendMessage(hwCtrl, LB_SETSEL, FALSE, (LPARAM)-1);
                pszStart = pszEnd = pField->pszState;
                for (;;) {
                  char c = *pszEnd;
                  if (c == '|' || c == '\0') {
                    *pszEnd = '\0';
                    if (*pszStart)
                    {
                      int nItem = mySendMessage(hwCtrl, LB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)pszStart);
                      if (nItem != LB_ERR)
                        mySendMessage(hwCtrl, LB_SETSEL, TRUE, nItem);
                    }
                    if (!c)
                      break;
                    pszStart = ++pszEnd;
                  }
                  else
                    pszEnd = CharNext(pszEnd);
                }
              }
              else {
                int nItem = mySendMessage(hwCtrl, nFindMsg, (WPARAM)-1, (LPARAM)pField->pszState);
                if (nItem != CB_ERR) { // CB_ERR == LB_ERR == -1
                  mySendMessage(hwCtrl, nSetSelMsg, nItem, 0);
                }
              }
            }
          }
          break;

        case FIELD_ICON:
        case FIELD_BITMAP:
        {
          WPARAM nImageType = pField->nType == FIELD_BITMAP ? IMAGE_BITMAP : IMAGE_ICON;
          LPARAM nImage = 0;

          if (pField->pszText) {
            pField->hImage = LoadImage(
              m_hInstance,
              pField->pszText,
              nImageType,
              (pField->nFlags & FLAG_RESIZETOFIT)
                ? (rect.right - rect.left)
                : 0,
              (pField->nFlags & FLAG_RESIZETOFIT)
                ? (rect.bottom - rect.top)
                : 0,
              LR_LOADFROMFILE
            );
            nImage = (LPARAM)pField->hImage;
          }
          else
            nImage = (LPARAM)LoadIcon(GetModuleHandle(0), MAKEINTRESOURCE(103));

          if ((pField->nFlags & TRANSPARENT_BMP) && nImageType == IMAGE_BITMAP)
          {
            // based on AdvSplash's SetTransparentRegion
            BITMAP bm;
            HBITMAP hBitmap = (HBITMAP) nImage;

            if (GetObject(hBitmap, sizeof(bm), &bm))
            {
              HDC dc;
              int x, y;
              HRGN region, cutrgn;
              BITMAPINFO bmi;
              int size = bm.bmWidth * bm.bmHeight * sizeof(int);
              int *bmp = (int *) MALLOC(size);
              if (bmp)
              {
                bmi.bmiHeader.biBitCount = 32;
                bmi.bmiHeader.biCompression = BI_RGB;
                bmi.bmiHeader.biHeight = bm.bmHeight;
                bmi.bmiHeader.biPlanes = 1;
                bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
                bmi.bmiHeader.biWidth = bm.bmWidth;
                bmi.bmiHeader.biClrUsed = 0;
                bmi.bmiHeader.biClrImportant = 0;

                dc = CreateCompatibleDC(NULL);
                SelectObject(dc, hBitmap);

                x = GetDIBits(dc, hBitmap, 0, bm.bmHeight, bmp, &bmi, DIB_RGB_COLORS);

                region = CreateRectRgn(0, 0, bm.bmWidth, bm.bmHeight);

                int keycolor = *bmp & 0xFFFFFF;

                // Search for transparent pixels 
                for (y = bm.bmHeight - 1; y >= 0; y--) {
                  for (x = 0; x < bm.bmWidth;) {
                    if ((*bmp & 0xFFFFFF) == keycolor) {
                      int j = x;
                      while ((x < bm.bmWidth) && ((*bmp & 0xFFFFFF) == keycolor)) {
                        bmp++, x++;
                      }

                      // Cut transparent pixels from the original region
                      cutrgn = CreateRectRgn(j, y, x, y + 1);
                      CombineRgn(region, region, cutrgn, RGN_XOR);
                      DeleteObject(cutrgn);
                    } else {
                      bmp++, x++;
                    }
                  }
                }

                // Set resulting region.
                SetWindowRgn(hwCtrl, region, TRUE);
                DeleteObject(region);
                DeleteObject(dc);
                FREE(bmp);
              }
            }
          }

          mySendMessage(
            hwCtrl,
            STM_SETIMAGE,
            nImageType,
            nImage
          );

          if (pField->nType == FIELD_BITMAP)
          {
            // Centre the image in the requested space.
            // Cannot use SS_CENTERIMAGE because it behaves differently on XP to
            // everything else.  (Thank you Microsoft.)
            RECT  bmp_rect;
            GetClientRect(hwCtrl, &bmp_rect);
            bmp_rect.left = (rect.left + rect.right - bmp_rect.right) / 2;
            bmp_rect.top = (rect.top + rect.bottom - bmp_rect.bottom) / 2;
            SetWindowPos(hwCtrl, NULL, bmp_rect.left, bmp_rect.top, 0, 0,
                         SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER);
          }

          break;
        }

#ifdef IO_ENABLE_LINK
        case FIELD_LINK:
          pField->nParentIdx = SetWindowLong(hwCtrl, GWL_WNDPROC, (long)StaticLINKWindowProc);
          break;
#endif
      }

      // Set initial focus to the first appropriate field ( with FOCUS flag)
      if (!fFocusedByFlag && (dwStyle & (WS_TABSTOP | WS_DISABLED)) == WS_TABSTOP && pField->nType >= FIELD_SETFOCUS) {
        if (pField->nFlags & FLAG_FOCUS) {
          fFocusedByFlag = TRUE;
        }
        if (!fFocused || fFocusedByFlag) {
          fFocused = TRUE;
          mySetFocus(hwCtrl);
        }
      }

      // If multiline-readonly then hold the text back until after the
      // initial focus has been set. This is so the text is not initially
      // selected - useful for License Page look-a-likes.
      if ((pField->nFlags & (FLAG_MULTILINE | FLAG_READONLY)) == (FLAG_MULTILINE | FLAG_READONLY))
        mySetWindowText(hwCtrl, pField->pszState);
    }
  }

  if (!fFocused)
    mySetFocus(hNextButton);

  mySetWindowText(mainwnd,pszTitle);
  pFilenameStackEntry = *g_stacktop;
  *g_stacktop = (*g_stacktop)->next;
  static char tmp[32];
  wsprintf(tmp,"%d",hConfigWindow);
  pushstring(tmp);
  return 0;
}
Esempio n. 26
0
int main(int argc, char **argv)
{
	FILE *fpin;
	AppData *ad;

	if (argc < 2 || argc > 4)
	{
		fprintf(stderr, "gpxrewrite - Part of %s\n", PACKAGE_STRING);
		fprintf(stderr, "Error:  Incorrect arguments\n");
		fprintf(stderr, "    gpxrewrite settings.ini   (reads file from stdin, writes to stdout)\n");
		fprintf(stderr, "    gpxrewrite settings.ini gpxfile.gpx   (writes to stdout)\n");
		fprintf(stderr, "    gpxrewrite settings.ini gpxfile.gpx output.gpx\n");
		exit(1);
	}

	DEBUG("Get memory");
	ad = getMemory(sizeof(AppData));
	DEBUG("Write default settings");
	WriteDefaultSettings(&(ad->settings));
	DEBUG("Read settings file");
	ReadSettings(&(ad->settings), argv[1]);

	if (argc >= 3)
	{
		DEBUG("Opening input file");
		fpin = fopen(argv[2], "r");
		if (! fpin)
		{
			fprintf(stderr, "Error opening input file: %s\n", argv[2]);
			exit(3);
		}
	}
	else
	{
		DEBUG("Using stdin");
		fpin = stdin;
	}

	if (argc >= 4)
	{
		DEBUG("Opening output file");
		ad->fpout = fopen(argv[3], "w");
		if (! ad->fpout)
		{
			fprintf(stderr, "Error opening output file: %s\n", argv[3]);
			exit(4);
		}
	}
	else
	{
		DEBUG("Using stdout");
		ad->fpout = stdout;
	}

	DEBUG("Writing XML header");
	fputs("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", ad->fpout);
	DEBUG("Parsing XML");
	ParseXML(fpin, &WaypointHandler, &NonWaypointHandler, (void *) ad);
	DEBUG("Writing trailing newline");
	fputs(GetXMLNewline(), ad->fpout);

	if (fpin != stdin)
	{
		DEBUG("Closing input file");
		fclose(fpin);
	}

	if (ad->fpout != stdout)
	{
		DEBUG("Closing output file");
		fclose(ad->fpout);
	}

	DEBUG("Freeing settings");
	FreeSettings(&(ad->settings));
	DEBUG("Freeing memory");
	freeMemory((void **) &ad);

	return 0;
}
Esempio n. 27
0
	void Core::SecondInit ()
	{
		ReadSettings ();
	}
Esempio n. 28
0
void DisplayDialog()
{
    GtkWidget *dialog;
    int return_value;

    GtkWidget *msg_box, *log_box, *dump_box, *main_box;
    GtkWidget *msg_frame, *log_frame, *dump_frame, *main_frame;

    GtkWidget *msg_console_check, *msg_key_check, *msg_voice_check, *msg_dma_check;
    GtkWidget *msg_autodma_check, *msg_overrun_check, *msg_cache_check;

    GtkWidget *log_access_check, *log_dma_check, *log_wave_check;
    GtkWidget *dump_core_check, *dump_mem_check, *dump_reg_check;

	ReadSettings();

    // Create the widgets
    dialog = gtk_dialog_new_with_buttons (
		"Spu2-X Config",
		NULL, // parent window
		(GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
		"OK", GTK_RESPONSE_ACCEPT,
		"Cancel", GTK_RESPONSE_REJECT,
		NULL);

    main_box = gtk_hbox_new(false, 5);
    main_frame = gtk_frame_new ("Spu2-X Config");
    gtk_container_add (GTK_CONTAINER(main_frame), main_box);

    // Message Section

    msg_box =  gtk_vbox_new(false, 5);

	msg_console_check = gtk_check_button_new_with_label("Show In Console");
    msg_key_check = gtk_check_button_new_with_label("KeyOn/Off Events");
    msg_voice_check = gtk_check_button_new_with_label("Voice Stop Events");
    msg_dma_check = gtk_check_button_new_with_label("DMA Operations");
    msg_autodma_check = gtk_check_button_new_with_label("AutoDMA Operations");
    msg_overrun_check = gtk_check_button_new_with_label("Buffer Over/Underruns");
    msg_cache_check = gtk_check_button_new_with_label("ADPCM Cache Statistics");

	gtk_container_add(GTK_CONTAINER(msg_box), msg_console_check);
	gtk_container_add(GTK_CONTAINER(msg_box), msg_key_check);
	gtk_container_add(GTK_CONTAINER(msg_box), msg_voice_check);
	gtk_container_add(GTK_CONTAINER(msg_box), msg_dma_check);
	gtk_container_add(GTK_CONTAINER(msg_box), msg_autodma_check);
	gtk_container_add(GTK_CONTAINER(msg_box), msg_overrun_check);
	gtk_container_add(GTK_CONTAINER(msg_box), msg_cache_check);

    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(msg_console_check), _MsgToConsole);
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(msg_key_check), _MsgKeyOnOff);
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(msg_voice_check), _MsgVoiceOff);
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(msg_dma_check), _MsgDMA);
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(msg_autodma_check), _MsgAutoDMA);
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(msg_overrun_check), _MsgOverruns);
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(msg_cache_check), _MsgCache);

    msg_frame = gtk_frame_new ("Message/Log Options");
    gtk_container_add (GTK_CONTAINER(msg_frame), msg_box);

    // Log Section
    log_box =  gtk_vbox_new(false, 5);

    log_access_check = gtk_check_button_new_with_label("Log Register/DMA Actions");
    log_dma_check = gtk_check_button_new_with_label("Log DMA Writes");
    log_wave_check = gtk_check_button_new_with_label("Log Audio Output");

	gtk_container_add(GTK_CONTAINER(log_box), log_access_check);
	gtk_container_add(GTK_CONTAINER(log_box), log_dma_check);
	gtk_container_add(GTK_CONTAINER(log_box), log_wave_check);

    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(log_access_check), _AccessLog);
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(log_dma_check), _DMALog);
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(log_wave_check), _WaveLog);

    log_frame = gtk_frame_new ("Log Options");
    gtk_container_add (GTK_CONTAINER(log_frame), log_box);

    // Dump Section
    dump_box = gtk_vbox_new(false, 5);

    dump_core_check = gtk_check_button_new_with_label("Dump Core and Voice State");
    dump_mem_check = gtk_check_button_new_with_label("Dump Memory Contents");
    dump_reg_check = gtk_check_button_new_with_label("Dump Register Data");

	gtk_container_add(GTK_CONTAINER(dump_box), dump_core_check);
	gtk_container_add(GTK_CONTAINER(dump_box), dump_mem_check);
	gtk_container_add(GTK_CONTAINER(dump_box), dump_reg_check);

    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dump_core_check), _CoresDump);
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dump_mem_check), _MemDump);
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dump_reg_check), _RegDump);

    dump_frame = gtk_frame_new ("Dumps (on close)");
    gtk_container_add (GTK_CONTAINER(dump_frame), dump_box);

    // Add everything

    gtk_container_add (GTK_CONTAINER(main_box), msg_frame);
    gtk_container_add (GTK_CONTAINER(main_box), log_frame);
    gtk_container_add (GTK_CONTAINER(main_box), dump_frame);

    // Add all our widgets, and show everything we've added to the dialog.
    gtk_container_add (GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), main_frame);
    gtk_widget_show_all (dialog);

    return_value = gtk_dialog_run (GTK_DIALOG (dialog));

    if (return_value == GTK_RESPONSE_ACCEPT)
    {
		_MsgToConsole = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(msg_console_check));
		_MsgKeyOnOff = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(msg_key_check));
		_MsgVoiceOff = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(msg_voice_check));
		_MsgDMA = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(msg_dma_check));
		_MsgAutoDMA = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(msg_autodma_check));
		_MsgOverruns = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(msg_overrun_check));
		_MsgCache = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(msg_cache_check));

		_AccessLog = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(log_access_check));
		_DMALog = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(log_dma_check));
		_WaveLog = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(log_wave_check));

		_CoresDump = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dump_core_check));
		_MemDump = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dump_mem_check));
		_RegDump = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dump_reg_check));
    }

    gtk_widget_destroy (dialog);

    WriteSettings();
}
Esempio n. 29
0
void init() {
	ReadSettings();
}
Esempio n. 30
0
void DisplayDialog()
{
    int return_value;
    GtkWidget *dialog, *main_label, *adv_box;
    GtkWidget *default_button;

    ReadSettings();

    /* Create the widgets */
    dialog = gtk_dialog_new_with_buttons(
        "Advanced Settings",
        NULL, /* parent window*/
        (GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
        "Cancel", GTK_RESPONSE_REJECT,
        "OK", GTK_RESPONSE_ACCEPT,
        NULL);

    main_label = gtk_label_new("These are advanced configuration options for fine tuning time stretching behavior. \nLarger values are better for slowdown, while smaller values are better for speedup (more then 60 fps.). \nAll options are in microseconds.");
    gtk_label_set_line_wrap(GTK_LABEL(main_label), true);

    default_button = gtk_button_new_with_label("Reset to Defaults");

    seq_label = gtk_label_new("Sequence Length");
    seq_slide = spu2x_gtk_hscale_new_with_range(SequenceLen_Min, SequenceLen_Max, 2);
    gtk_range_set_value(GTK_RANGE(seq_slide), SequenceLenMS);

    seek_label = gtk_label_new("Seek Window Size");
    seek_slide = spu2x_gtk_hscale_new_with_range(SeekWindow_Min, SeekWindow_Max, 2);
    gtk_range_set_value(GTK_RANGE(seek_slide), SeekWindowMS);

    over_label = gtk_label_new("Overlap");
    over_slide = spu2x_gtk_hscale_new_with_range(Overlap_Min, Overlap_Max, 2);
    gtk_range_set_value(GTK_RANGE(over_slide), OverlapMS);

    adv_box = spu2x_gtk_vbox_new(5);

    gtk_box_pack_start(GTK_BOX(adv_box), main_label, TRUE, TRUE, 0);
    gtk_box_pack_start(GTK_BOX(adv_box), default_button, TRUE, TRUE, 5);

    gtk_box_pack_start(GTK_BOX(adv_box), seq_label, TRUE, TRUE, 0);
    gtk_box_pack_start(GTK_BOX(adv_box), seq_slide, TRUE, TRUE, 5);

    gtk_box_pack_start(GTK_BOX(adv_box), seek_label, TRUE, TRUE, 0);
    gtk_box_pack_start(GTK_BOX(adv_box), seek_slide, TRUE, TRUE, 5);

    gtk_box_pack_start(GTK_BOX(adv_box), over_label, TRUE, TRUE, 0);
    gtk_box_pack_start(GTK_BOX(adv_box), over_slide, TRUE, TRUE, 5);

    gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), adv_box);
    g_signal_connect_swapped(default_button, "clicked", G_CALLBACK(restore_defaults), default_button);
    gtk_widget_show_all(dialog);

    return_value = gtk_dialog_run(GTK_DIALOG(dialog));

    if (return_value == GTK_RESPONSE_ACCEPT) {
        SequenceLenMS = gtk_range_get_value(GTK_RANGE(seq_slide));
        SeekWindowMS = gtk_range_get_value(GTK_RANGE(seek_slide));
        OverlapMS = gtk_range_get_value(GTK_RANGE(over_slide));
    }

    gtk_widget_destroy(dialog);

    WriteSettings();
}