Class: Home

Inherits:
FXMainWindow
  • Object
show all
Defined in:
lib/parroquia/main.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Home

Returns a new instance of Home.



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
# File 'lib/parroquia/main.rb', line 6

def initialize(app)
  super(app, 'Parroquia San Judas Tadeo', width: 700, height: 500)
  @app = app
  self.backColor = FXRGB(3, 187, 133)

  # Font
  @font = FXFont.new(app, 'Geneva', 12, FONTWEIGHT_BOLD)

  # Inserar imagen del logo
  @image = File.join(File.dirname(__FILE__), 'assets/images/Logo-SJT.png')
  @image = File.open(@image, 'rb')
  @image = FXPNGIcon.new(app, @image.read)
  @logo = FXImageFrame.new(self, @image, opts: LAYOUT_EXPLICIT | LAYOUT_CENTER_X | LAYOUT_CENTER_Y, width: 400,
                                         height: 250, x: 10, y: 100)
  # Color de fondo de image frame es el mismo que el de la ventana
  @logo.backColor = FXRGB(3, 187, 133)
  # Escalar imagen
  @image.scale(400, 250)

  # Title
  @lbltitle = FXLabel.new(self, 'Bienvenido a la Parroquia San Judas Tadeo',
                          opts: LAYOUT_EXPLICIT | JUSTIFY_CENTER_X, width: 700, height: 20, x: 0, y: 20)
  @lbltitle.font = FXFont.new(app, 'Geneva', 16, FONTWEIGHT_BOLD)
  @lbltitle.backColor = FXRGB(3, 187, 133)
  # Subtitle
  @lblsubtitle = FXLabel.new(self, 'ARQUIDIOSESIS DE QUITO - SERVICIO PARROQUIAL DE SAN JUDAS TADEO',
                             opts: LAYOUT_EXPLICIT | JUSTIFY_CENTER_X, width: 700, height: 20, x: 0, y: 40)
  @lblsubtitle.font = FXFont.new(app, 'Geneva', 10, FONTWEIGHT_BOLD)
  @lblsubtitle.backColor = FXRGB(3, 187, 133)
  # Date
  @date = Time.now.strftime('%d/%m/%Y')
  @lbldate = FXLabel.new(self, "Fecha: #{cambiar_formato_fecha(@date)}", opts: LAYOUT_EXPLICIT | JUSTIFY_RIGHT,
                                                                         width: 700, height: 20, x: 0, y: 60, padRight: 20)
  @lbldate.font = FXFont.new(app, 'Geneva', 12, FONTWEIGHT_BOLD)
  @lbldate.backColor = FXRGB(3, 187, 133)

  # section lista
  @btnsacramentos = FXButton.new(self, 'Sacramentos', opts: LAYOUT_EXPLICIT | BUTTON_NORMAL, width: 150,
                                                      height: 30, x: 460, y: 150)
  @btncatecismo = FXButton.new(self, 'Catecismo', opts: LAYOUT_EXPLICIT | BUTTON_NORMAL, width: 150,
                                                  height: 30, x: 460, y: 190)

  # Footer
  @lblfooter = FXLabel.new(self, 'WebMinds Studio - 2023', opts: LAYOUT_EXPLICIT | JUSTIFY_CENTER_X, width: 700,
                                                           height: 20, x: 0, y: 400)
  @lblfooter.font = FXFont.new(app, 'Geneva', 10)
  @lblfooter.backColor = FXRGB(3, 187, 133)
  @lblauthor = FXLabel.new(self, 'Desarrollado por Ing. Francisco J. Borja L.',
                           opts: LAYOUT_EXPLICIT | JUSTIFY_CENTER_X, width: 700, height: 20, x: 0, y: 420)
  @lblauthor.font = FXFont.new(app, 'Geneva', 10)
  @lblauthor.backColor = FXRGB(3, 187, 133)
  @lblweb = FXLabel.new(self, 'www.webmindsstudio.com', opts: LAYOUT_EXPLICIT | JUSTIFY_CENTER_X, width: 700,
                                                        height: 20, x: 0, y: 440)
  @lblweb.font = FXFont.new(app, 'Geneva', 10)
  @lblweb.backColor = FXRGB(3, 187, 133)
  @lbllicence = FXLabel.new(self, 'MIT License', opts: LAYOUT_EXPLICIT | JUSTIFY_CENTER_X, width: 700,
                                                 height: 20, x: 0, y: 460)
  @lbllicence.font = FXFont.new(app, 'Geneva', 10)
  @lbllicence.backColor = FXRGB(3, 187, 133)
  # section buttons executions
  @btnsacramentos.connect(SEL_COMMAND) do
    require_relative 'sacramentos/sacramentos'
    vtnsacramentos = Sacramentos.new(@app)
    vtnsacramentos.create
    vtnsacramentos.show(PLACEMENT_SCREEN)
  end
  @btncatecismo.connect(SEL_COMMAND) do
    require_relative 'catecismo/catecismo'
    vtncatecismo = Catecismo.new(@app)
    vtncatecismo.create
    vtncatecismo.show(PLACEMENT_SCREEN)
  end
end

Instance Method Details

#cambiar_formato_fecha(fecha) ⇒ Object

Cambiar el formato de la fecha de YYYY-MM-DD a DD de nombre_mes de YYYY



100
101
102
103
104
105
106
107
108
109
# File 'lib/parroquia/main.rb', line 100

def cambiar_formato_fecha(fecha)
  # split "-" or "/"
  fecha = fecha.split(%r{-|/})
  # si el formato de fecha es YYYY-MM-DD o YYYY/MM/DD, sino si es DD-MM-YYYY o DD/MM/YYYY
  if fecha[0].length == 4
    "#{fecha[2]} de #{nombre_mes(fecha[1])} de #{fecha[0]}"
  else
    "#{fecha[0]} de #{nombre_mes(fecha[1])} de #{fecha[2]}"
  end
end

#createObject



111
112
113
114
# File 'lib/parroquia/main.rb', line 111

def create
  super
  show(PLACEMENT_SCREEN)
end

#nombre_mes(mes) ⇒ Object

Nombre del mes



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/parroquia/main.rb', line 81

def nombre_mes(mes)
  meses = {
    '01' => 'enero',
    '02' => 'febrero',
    '03' => 'marzo',
    '04' => 'abril',
    '05' => 'mayo',
    '06' => 'junio',
    '07' => 'julio',
    '08' => 'agosto',
    '09' => 'septiembre',
    '10' => 'octubre',
    '11' => 'noviembre',
    '12' => 'diciembre'
  }
  meses[mes]
end