File: my_config.cpp

package info (click to toggle)
codelite 12.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 95,112 kB
  • sloc: cpp: 424,040; ansic: 18,284; php: 9,569; lex: 4,186; yacc: 2,820; python: 2,294; sh: 312; makefile: 51; xml: 13
file content (106 lines) | stat: -rw-r--r-- 2,348 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include "my_config.h"
#include <wx/font.h>
#include <wx/settings.h>
#include <wx/stdpaths.h>
#include <wx/filename.h>

MyConfig::MyConfig()
    : wxFileConfig("",
                   "",
                   (wxStandardPaths::Get().GetUserDataDir() + "/codelite-terminal.ini"),
                   "",
                   wxCONFIG_USE_LOCAL_FILE)
{
    wxFileName fn(wxStandardPaths::Get().GetUserDataDir(), "codelite-terminal.ini");
    fn.Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL);
}

MyConfig::~MyConfig()
{
    Save();
}

wxPoint MyConfig::GetTerminalPosition() const
{
    wxPoint pt(100, 100);
    Read("frame_position_x", &pt.x);
    Read("frame_position_y", &pt.y);
    return pt;
}

wxSize MyConfig::GetTerminalSize() const
{
    wxSize size(600, 400);
    Read("frame_size_width", &size.x);
    Read("frame_size_height", &size.y);
    return size;
}

void MyConfig::SetTerminalPosition(const wxPoint& pt)
{
    Write("frame_position_x", pt.x);
    Write("frame_position_y", pt.y);
}

void MyConfig::SetTerminalSize(const wxSize& size)
{
    Write("frame_size_width", size.x);
    Write("frame_size_height", size.y);
}

void MyConfig::Save()
{
    Flush();
}

wxColour MyConfig::GetBgColour() const
{
    wxString col;
    if(Read("bg_colour", &col) && !col.IsEmpty()) {
        wxColour colour(col);
        return colour;
    }
    return *wxBLACK;
}

wxColour MyConfig::GetFgColour() const
{
    wxString col;
    if(Read("fg_colour", &col) && !col.IsEmpty()) {
        wxColour colour(col);
        return colour;
    }
    return *wxWHITE;
}

void MyConfig::SetBgColour(const wxColour& col)
{
    Write("bg_colour", col.GetAsString());
}

void MyConfig::SetFgColour(const wxColour& col)
{
    Write("fg_colour", col.GetAsString());
}

wxFont MyConfig::GetFont() const
{
    wxFont defaultFont = wxSystemSettings::GetFont(wxSYS_ANSI_FIXED_FONT);
    defaultFont.SetFamily(wxFONTFAMILY_TELETYPE);

    // read the attributes
    wxString facename;
    int pointSize;

    Read("font_facename", &facename, defaultFont.GetFaceName());
    Read("font_size", &pointSize, defaultFont.GetPointSize());

    wxFont f(wxFontInfo(pointSize).FaceName(facename).Family(wxFONTFAMILY_TELETYPE));
    return f;
}

void MyConfig::SetFont(const wxFont& font)
{
    Write("font_facename", font.GetFaceName());
    Write("font_size", font.GetPointSize());
}