<commit_before>#include "Display.h"

#include <CommCtrl.h>

#include "../3RVX/DisplayManager.h"
#include "../3RVX/Logger.h"
#include "../3RVX/Settings.h"

#include "UIContext.h"
#include "resource.h"

DLGPROC Display::Command(unsigned short nCode, unsigned short ctrlId) {
    switch (nCode) {
    case BN_CLICKED:
        switch (ctrlId) {
        case CHK_EDGE:
            OnCustomCheckChanged();
            return (DLGPROC) TRUE;
        }

        break;

    case CBN_SELCHANGE:
        switch (ctrlId) {
        case CMB_POSITION:
            OnPositionChanged();
            return (DLGPROC) TRUE;

        case CMB_ANIMATION:
            OnAnimationChanged();
            return (DLGPROC) TRUE;
        }

        break;
    }

    return FALSE;
}

DLGPROC Display::Notification(NMHDR *nHdr) {
    unsigned int ctrlId = nHdr->idFrom;
    switch (nHdr->code) {
    case UDN_DELTAPOS:
        if (ctrlId == SP_DELAY || ctrlId == SP_SPEED) {
            NMUPDOWN *ud = (NMUPDOWN *) nHdr;
            ud->iDelta *= 100;
            return FALSE; /* Allows the change */
        }
    }

    return FALSE;
}

void Display::Initialize() {

}

void Display::LoadSettings() {
    Settings *settings = Settings::Instance();

    /* Visibility Settings */
    _ctxt->SetCheck(CHK_ONTOP, settings->AlwaysOnTop());
    _ctxt->SetCheck(CHK_FULLSCREEN, settings->HideFullscreen());

    /* Position on Screen*/
    for (std::wstring pos : settings->OSDPosNames) {
        _ctxt->AddComboItem(CMB_POSITION, pos);
    }
    _ctxt->SelectComboItem(CMB_POSITION, (int) settings->OSDPosition());

    /* Custom positions/offsets */
    _ctxt->SetText(ED_CUSTOMX, settings->OSDX());
    _ctxt->SetText(ED_CUSTOMY, settings->OSDY());
    _ctxt->SetCheck(CHK_EDGE, settings->OSDEdgeOffset() != DEFAULT_OSD_OFFSET);
    _ctxt->SetText(ED_EDGE, settings->OSDEdgeOffset());
    _ctxt->SetSpinRange(SP_EDGE, MIN_EDGE, MAX_EDGE);

    /* Display Devices */<commit_msg>Initialize controls<commit_after>#include "Display.h"

#include <CommCtrl.h>

#include "../3RVX/DisplayManager.h"
#include "../3RVX/Logger.h"
#include "../3RVX/Settings.h"

#include "UIContext.h"
#include "resource.h"

DLGPROC Display::Command(unsigned short nCode, unsigned short ctrlId) {
    switch (nCode) {
    case BN_CLICKED:
        switch (ctrlId) {
        case CHK_EDGE:
            OnCustomCheckChanged();
            return (DLGPROC) TRUE;
        }

        break;

    case CBN_SELCHANGE:
        switch (ctrlId) {
        case CMB_POSITION:
            OnPositionChanged();
            return (DLGPROC) TRUE;

        case CMB_ANIMATION:
            OnAnimationChanged();
            return (DLGPROC) TRUE;
        }

        break;
    }

    return FALSE;
}

DLGPROC Display::Notification(NMHDR *nHdr) {
    unsigned int ctrlId = nHdr->idFrom;
    switch (nHdr->code) {
    case UDN_DELTAPOS:
        if (ctrlId == SP_DELAY || ctrlId == SP_SPEED) {
            NMUPDOWN *ud = (NMUPDOWN *) nHdr;
            ud->iDelta *= 100;
            return FALSE; /* Allows the change */
        }
    }

    return FALSE;
}

void Display::Initialize() {
    INIT_CONTROL(CHK_ONTOP, Checkbox, _onTop);
    INIT_CONTROL(CHK_FULLSCREEN, Checkbox, _hideFullscreen);

    INIT_CONTROL(CMB_POSITION, ComboBox, _position);
    INIT_CONTROL(ED_CUSTOMX, EditBox, _positionX);
    INIT_CONTROL(ED_CUSTOMY, EditBox, _positionY);
    INIT_CONTROL(CHK_EDGE, Checkbox, _customDistance);
    INIT_CONTROL(SP_EDGE, Spinner, _edgeSpinner);
    _edgeSpinner.Buddy(ED_EDGE);

    INIT_CONTROL(LBL_DISPLAYDEV, Label, _displayDevLabel);
    INIT_CONTROL(CMB_MONITOR, ComboBox, _displayDevice);

    INIT_CONTROL(CMB_ANIMATION, ComboBox, _animation);
    INIT_CONTROL(LBL_HIDEDELAY, Label, _hideDelayLabel);
    INIT_CONTROL(SP_HIDEDELAY, Spinner, _hideDelay);
    _hideDelay.Buddy(ED_HIDEDELAY);
    INIT_CONTROL(LBL_HIDESPEED, Label, _hideSpeedLabel);
    INIT_CONTROL(SP_HIDESPEED, Spinner, _hideSpeed);
    _hideSpeed.Buddy(ED_HIDESPEED);
}

void Display::LoadSettings() {
    Settings *settings = Settings::Instance();

    /* Visibility Settings */
    _ctxt->SetCheck(CHK_ONTOP, settings->AlwaysOnTop());
    _ctxt->SetCheck(CHK_FULLSCREEN, settings->HideFullscreen());

    /* Position on Screen*/
    for (std::wstring pos : settings->OSDPosNames) {
        _ctxt->AddComboItem(CMB_POSITION, pos);
    }
    _ctxt->SelectComboItem(CMB_POSITION, (int) settings->OSDPosition());

    /* Custom positions/offsets */
    _ctxt->SetText(ED_CUSTOMX, settings->OSDX());
    _ctxt->SetText(ED_CUSTOMY, settings->OSDY());
    _ctxt->SetCheck(CHK_EDGE, settings->OSDEdgeOffset() != DEFAULT_OSD_OFFSET);
    _ctxt->SetText(ED_EDGE, settings->OSDEdgeOffset());
    _ctxt->SetSpinRange(SP_EDGE, MIN_EDGE, MAX_EDGE);

    /* Display Devices */
{'fraction_non_alphanumeric': 0.12777545035609553, 'fraction_numerical': 0.0025136154168412233, 'mean_word_length': 3.032939189189189, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5132358', 'n_tokens_mistral': 1680, 'n_tokens_neox': 1652, 'n_words': 292}