local base = _G

module('Theme')

-- Темы для виджетов
-- Если какой либо параметр закомментирован (--), то этот элемент рисоваться не будет
-- Темой является либо функция, либо таблица
-- Внимание! Регистр букв в названии тем важен!
-- Цвет может содержать 3 или 4 компоненты. Во втором случае, если четвертая компонента меньше 1, 
-- то элемент будет рисоваться полупрозрачным.

fontsPath = base.fontsPath;
imagesPath = base.imagesPath;

Cache = {};
function getImage(fileName)
    --return fileName; -- debug
    if Cache[fileName] ~= nil then
        return Cache[fileName];
    else
        for i, path in base.ipairs(base.imageSearchPath) do
            local fName = path .. fileName;
            local f = base.io.open(fName);
            if f ~= nil then
                --base.print('getImage:',fName);
                base.io.close(f)
                Cache[fileName] = fName;
                return fName;                
            end        
        end;
    end;
    return fileName; -- debug
end;

-- Основные цвета
menu_button =       function () return {216 / 255, 217 / 255, 207 / 255, 1.0} end
menu_button_select = function () return {125 / 255, 135 / 255, 120 / 255, 1.0} end
menu_list =         function () return {125 / 255, 135 / 255, 120 / 255, 1.0} end
menu_select =       function () return {4 / 255, 171 / 255, 226 / 255, 1.0} end
dialog_top =        function () return {0 / 255, 0 / 255, 0 / 255, 1.0} end
dialog_prim =       function () return {120 / 255, 137 / 255, 144 / 255, 1.0} end
dialog_sec =        function () return {99 / 255, 112 / 255, 117 / 255, 1.0} end
dialog_ctrl =       function () return {177 / 255, 191 / 255, 192 / 255, 1.0} end
button_off =        function () return {177 / 255, 191 / 255, 192 / 255, 1.0} end
button_on =         function () return {255 / 255, 255 / 255, 255 / 255, 1.0} end
text_top =          function () return {196 / 255, 191 / 255, 102 / 255, 1.0} end
text_main =         function () return {190 / 255, 192 / 255, 175 / 255, 1.0} end
menu_text_main =         function () return {255 / 255, 255 / 255, 255 / 255, 1.0} end
text_ctrl =         function () return {0 / 255, 0 / 255, 0 / 255, 1.0} end
text_button =       function () return {70 / 255, 80 / 255, 65 / 255, 1.0} end
text_menu_button =  function () return {154 / 255, 156 / 255, 162 / 255, 1.0} end
text_menu_list =    function () return {70 / 255, 80 / 255, 65 / 255, 1.0} end
text_menu_select =  function () return {205 / 255, 255 / 255, 210 / 255, 1.0} end
list_select_color = function () return {70 / 255, 80 / 255, 65 / 255, 100/255} end	-- полупрозрачный
slider_bkg =        function () return {156 / 255, 171 / 255, 172 / 255, 1.0} end
slider_thumb =      function () return {181 / 255, 194 / 255, 195 / 255, 1.0} end
text_toolbar_groups = function () return {196 / 255, 191 / 255, 102 / 255, 1.0}  end
text_statusbar_groups = function () return {120 / 255, 137 / 255, 144 / 255, 1.0}  end
toolbar_main =      function () return {120 / 255, 137 / 255, 144 / 255, 1.0}  end
toolbar_groups =    function () return {70 / 255, 80 / 255, 65 / 255, 1.0} end
statusbar_main =    function () return {57 / 255, 71 / 255, 76 / 255, 1.0} end
statusbar_editbox = function () return {99 / 255, 112 / 255, 117 / 255, 1.0}  end
grid_header = function () return {99 / 255, 112 / 255, 117 / 255, 1.0}  end
loadout_image_bkg = function () return {133 / 255, 155 / 255, 157 / 255, 1.0}  end
border_light = slider_bkg()
border_dark = dialog_top()
arrow_light = text_main()
arrow_dark = dialog_top()

-- цвета для неактивных (disabled) виджетов
bkg_disabled = function () return {0.7, 0.7, 0.7, 1.0} end
text_disabled = function () return {0.5, 0.5, 0.5, 1.0} end
image_disabled = function () return {0.7, 0.7, 0.7, 0.3}  end

-- arial bold = DejaVuLGCSansCondensed-Bold.ttf 
-- arial bold italic = DejaVuLGCSansCondensed-BoldOblique.ttf


-- Шрифты
-- O?eoou
text_ctrl_font = fontsPath .. 'DejaVuLGCSansCondensed-Bold.ttf'
text_ctrl_font_size = 12

text_top_font = fontsPath .. 'DejaVuLGCSansCondensed-Bold.ttf'
text_top_font_size = 12
text_main_font = fontsPath .. 'DejaVuLGCSansCondensed-BoldOblique.ttf'
text_main_font_size = 12
text_button_font = fontsPath .. 'DejaVuLGCSansCondensed-Bold.ttf'
text_button_font_size = 12

function newText()
  -- параметры текста
  return {
    -- цвет текста    
    color = text_main(), 
        
    -- цвет текста у неактивного виджета
    disabledColor = text_disabled(),
    
    -- выравнивание текста {горизонтальное, вертикальное}. 
    -- Допустимые значения для горизонтального выравнивания: 
    -- 'left', 'center', 'right'
    -- Допустимые значения для вертикального выравнивания: 
    -- 'top', 'center', 'bottom'    
    -- textAlign = {'left', 'center'},       
    align = {'left', 'center'},
    
    -- смещение текста в пикселях от позиции выравнивания
    -- textOffset = {0, 0},       
    offset = {0, -2},
    
    -- шрифт.      
    font = text_main_font,
    
    -- размер шрифта
    size = text_main_font_size,
    
    -- коэффициент для межстрочного интервала
    -- на этот коэффициент будет умножаться межстрочный интервал, заданный производителем шрифта
    lineSpacing = 1,
  }
end

function newImage()
  -- параметры картинки
  return {
    -- цвет, с которым будет смешиваться текстура
    -- по умолчанию это белый цвет.     
    color = {1, 1, 1}, 
    
    -- цвет, с которым будет смешиваться текстура у неактивного виджета
    disabledColor = image_disabled(),
    
    -- выравнивание изображения {горизонтальное, вертикальное}. 
    -- Допустимые значения для горизонтального выравнивания: 
    -- 'left', 'center', 'right', 'stretch'
    -- Допустимые значения для вертикального выравнивания: 
    -- 'top', 'center', 'bottom', 'stretch'        
    align = {'center', 'center'},  
    
    -- смещение изображения в пикселях от позиции выравнивания
    offset = {0, 0},  
    
    -- файл картинки
    file = '', 
    
    -- текстурные координаты, если изображение занимает только часть текстуры (в пикселях от вехнего левого угла)
    -- tx = 0,
    -- ty = 0,
    -- tw = 0, -- 0 или nil означает всю ширину текстуры
    -- th = 0, -- 0 или nil означает всю высоту текстуры
    rect = {0, 0, 0, 0},
    
    -- размер картинки в пикселях
    w = 0, -- 0 или nil означает что ширина картинки равна ширине текстуры (tw)
    h = 0, -- 0 или nil означает что высота картинки равна высоте текстуры (tw)
  }
end

function newEmptyBorder() -- пустая рамка
  return { type = 'simple', 
           image = '', 
           size = 0, 
           insets = {0, 0, 0, 0}, --left, top,right, bottom
           color = nil,
           disabledColor = image_disabled(),
  }
end

function newSimple1Border(color) -- рамка толщиной 1 пиксель заданного цвета
  return { type = 'mega', 
           image = getImage('simple1.png'), 
           size = 1, 
           insets = {1, 1, 1, 1}, --left, top,right, bottom
           color = color,
           disabledColor = image_disabled(),
  }
end

function newSimple2Border(color) -- рамка толщиной 2 пикселя заданного цвета
  return { type = 'mega', 
           image = getImage('simple2.png'), 
           size = 2, 
           insets = {2, 2, 2, 2}, --left, top,right, bottom
           color = color,
           disabledColor = image_disabled(),
  }
end

function newUpBorder()
  return { type = 'mega', 
           image = getImage('up.png'), 
           size = 1, 
           insets = {1, 1, 1, 1}, --left, top,right, bottom
           color = {1, 1, 1},
           disabledColor = image_disabled(),
  }
end

function newDownBorder()
  return { type = 'mega', 
           image = getImage('down.png'), 
           size = 1, 
           insets = {1, 1, 1, 1}, --left, top,right, bottom
           color = {1, 1, 1},
           disabledColor = image_disabled(),
  }
end

function newRounded2Border(color) -- рамка со скругленными краями толщиной 2 пикселя заданного цвета
  return { 
    type = 'mega', 
    image = getImage('rounded2.png'), 
    size = 5, 
    insets = {2, 2, 2, 2}, --left, top,right, bottom
    color = color,
    disabledColor = image_disabled(),
  }
end

function newRounded3Border(color) -- рамка со скругленными краями толщиной 3 пикселя заданного цвета
  return { 
    type = 'mega', 
    image = getImage('rounded3.png'), 
    size = 5, 
    insets = {3, 3, 3, 3}, --left, top,right, bottom
    color = color,
    disabledColor = image_disabled(),
  }
end

function newWidgetTheme()
  return {
    -- цвет заливки
    color = {},
    disabledColor = {}, -- bkg_disabled()
    text = newText(),
    image = newImage(),
    border = newEmptyBorder(),
  }
end


-- Тема для контейнеров других виджетов
function newContainerTheme()
  local containerTheme = newWidgetTheme()
  return containerTheme
end

function newUserDrawnWidgetTheme()
  local userDrwanWidgetTheme = newWidgetTheme()
  --userDrwanWidgetTheme.border = newSimple1Border({0,0,1});
  userDrwanWidgetTheme.color = {1,1,1};
  return userDrwanWidgetTheme;
end

-- Тема для десктопа
function newDesktopTheme()
  local desktopTheme = newWidgetTheme()
  desktopTheme.image.file = getImage('loading-window.png');
  desktopTheme.image.align = {'center', 'center'}
  desktopTheme.image.rect = {0, 0, 1024, 768}
  
  return desktopTheme
end

-- Тема для кнопки
-- Тема состоит из набора тем.
-- У кнопки может быть 6 состояний. Каждому состоянию соответствует своя тема.
-- up - кнопка отжата (обычное состояние)
-- down - кнопка нажата
-- hoverUp - кнопка отжата, курсор мыши находится над кнопкой
-- Обычная кнопка использует только три этих темы.
-- Для переключателей добавляется еще три темы:
-- hoverDown (переключатель включен, курсор мыши находится над переключателем)
-- undefinedUp (переключатель вЫключен, кнопка мыши нажата, курсор мыши находится над переключателем)
-- undefinedDown (переключатель включен, кнопка мыши нажата, курсор мыши находится над переключателем)


-- Тема для кнопки
-- Тема состоит из набора тем.
-- У кнопки может быть 6 состояний. Каждому состоянию соответствует своя тема.
-- up - кнопка отжата (обычное состояние)
-- down - кнопка нажата
-- hoverUp - кнопка отжата, курсор мыши находится над кнопкой
-- Обычная кнопка использует только три этих темы.
-- Для переключателей добавляется еще три темы:
-- hoverDown (переключатель включен, курсор мыши находится над переключателем)
-- undefinedUp (переключатель вЫключен, кнопка мыши нажата, курсор мыши находится над переключателем)
-- undefinedDown (переключатель включен, кнопка мыши нажата, курсор мыши находится над переключателем)

function newButtonTheme()
  local upTheme = newWidgetTheme()
  upTheme.color = button_off()
  upTheme.text.color = text_button()
  upTheme.text.align = {'center', 'center'}
  upTheme.text.font = text_button_font
  upTheme.text.size = text_button_font_size
  upTheme.border = newUpBorder()
  
  local downTheme = newWidgetTheme()
  downTheme.color = button_on()
  downTheme.text.color = text_button()
  downTheme.text.align = {'center', 'center'}
  downTheme.text.font = text_button_font
  downTheme.text.size = text_button_font_size
  downTheme.border = newDownBorder()

  local hoverUpTheme = newWidgetTheme()
  hoverUpTheme.color = button_off()
  hoverUpTheme.text.color = text_button()
  hoverUpTheme.text.align = {'center', 'center'}
  hoverUpTheme.text.font = text_button_font
  hoverUpTheme.text.size = text_button_font_size
  hoverUpTheme.border = newUpBorder()

  local hoverDownTheme = newWidgetTheme()
  hoverDownTheme.color = button_on()
  hoverDownTheme.text.color = text_button()
  hoverDownTheme.text.align = {'center', 'center'}
  hoverDownTheme.text.font = text_button_font
  hoverDownTheme.text.size = text_button_font_size
  hoverDownTheme.border = newDownBorder()  

  local undefinedUpTheme = newWidgetTheme()
  undefinedUpTheme.color = button_off()
  undefinedUpTheme.text.color = text_button()
  undefinedUpTheme.text.align = {'center', 'center'}
  undefinedUpTheme.text.font = text_button_font
  undefinedUpTheme.text.size = text_button_font_size
  undefinedUpTheme.border = newUpBorder()

  local undefinedDownTheme = newWidgetTheme()
  undefinedDownTheme.color = button_on()
  undefinedDownTheme.text.color = text_button()
  undefinedDownTheme.text.align = {'center', 'center'}
  undefinedDownTheme.text.font = text_button_font
  undefinedDownTheme.text.size = text_button_font_size
  undefinedDownTheme.border = newDownBorder()
  
  return {
    upTheme = upTheme,
    downTheme = downTheme,
    hoverUpTheme = hoverUpTheme,
    hoverDownTheme = hoverDownTheme,
    undefinedUpTheme = undefinedUpTheme,
    undefinedDownTheme = undefinedDownTheme,
    sound = 'button2.wav'
  }
end


function setThemeImage(theme, image, tx, ty, tw, th)
  theme.border = newEmptyBorder()
  theme.image.file = getImage(image)
  theme.image.rect = { tx, ty, tw, th}
end

-- create button theme with single image for all states
function newImageButtonTheme(image, tx, ty, tw, th)
    local t = newButtonTheme()
    setThemeImage(t.upTheme, image, tx, ty, tw, th)
    t.upTheme.border = newUpBorder()
    setThemeImage(t.downTheme, image, tx, ty, tw, th)
    t.downTheme.border = newDownBorder()
    t.downTheme.image.offset = {1,1}
    setThemeImage(t.hoverUpTheme, image, tx, ty, tw, th)
    t.hoverUpTheme.border = newUpBorder()
    return t
end


--Несколько вспомогательных тем для часто используемых кнопок (кнопки со стрелками вверх, вниз, влево, вправо)
-- Тема для кнопки со стрелкой вверх

-- arrow_up_button_up = Image.new('./data/images/btn-tools-01.tga', 480 , 18 * 2 * 2, 18, 18)
-- arrow_up_button_down = Image.new(base.mainPath..'data/images/btn-tools-01.tga', 480 , 18+18*2*2, 18, 18)
-- arrow_down_button_up = Image.new(base.mainPath..'data/images/btn-tools-01.tga', 480 , 18*2*1, 18, 18)
-- arrow_down_button_down = Image.new(base.mainPath..'data/images/btn-tools-01.tga', 480 , 18+18*2*1, 18, 18)
-- arrow_left_button_up = Image.new(base.mainPath..'data/images/btn-tools-01.tga', 480 , 18*2*3, 18, 18)
-- arrow_left_button_down = Image.new(base.mainPath..'data/images/btn-tools-01.tga', 480 , 18+18*2*3, 18, 18)
-- arrow_right_button_up = Image.new(base.mainPath..'data/images/btn-tools-01.tga', 480 , 18*2*4, 18, 18)
-- arrow_right_button_down = Image.new(base.mainPath..'data/images/btn-tools-01.tga', 480 , 18+18*2*4, 18, 18)

function newButtonUpTheme()
  local theme = newButtonTheme()
  
  theme.upTheme.border = newEmptyBorder()
  theme.upTheme.image.file = getImage('btn-tools-01.png')
  theme.upTheme.image.rect = {481, 73, 16, 16}
  
  theme.downTheme.border = newEmptyBorder()
  theme.downTheme.image.file = getImage('btn-tools-01.png')
  theme.downTheme.image.rect = {481, 91, 16, 16}
  
  theme.hoverUpTheme.border = newEmptyBorder()
  theme.hoverUpTheme.image.file = getImage('btn-tools-01.png')
  theme.hoverUpTheme.image.rect = {481, 73, 16, 16}
  
  return theme
end

-- Тема для кнопки со стрелкой вниз
function newButtonDownTheme()
  local theme = newButtonUpTheme()
  
  theme.upTheme.image.rect = {481, 37, 16, 16}
  theme.downTheme.image.rect = {481, 55, 16, 16}  
  theme.hoverUpTheme.image.rect = {481, 37, 16, 16}   
  
  return theme
end

-- Тема для кнопки со стрелкой влево
function newButtonLeftTheme()
  local theme = newButtonUpTheme()
  
  theme.upTheme.image.rect = {481, 109, 16, 16}
  theme.downTheme.image.rect = {481, 127, 16, 16}  
  theme.hoverUpTheme.image.rect = {481, 109, 16, 16}  
  
  return theme
end

-- Тема для кнопки со стрелкой вправо
function newButtonRightTheme()
  local theme = newButtonLeftTheme()
  
  theme.upTheme.image.rect = {481, 145, 16, 16}
  theme.downTheme.image.rect = {481, 163, 16, 16}  
  theme.hoverUpTheme.image.rect = {481, 145, 16, 16}  
  
  return theme
end

-- Тема для окна
function newWindowTheme()
  local windowTheme = newWidgetTheme()
  windowTheme.color = dialog_prim()
  windowTheme.text.align = {'center', 'center'}
  windowTheme.border = newEmptyBorder()
  
  -- высота заголовка окна
  windowTheme.titleHeight = 0

  -- тема для заголовка неактивного окна  
  windowTheme.titleNormalTheme = newWidgetTheme()
  windowTheme.titleNormalTheme.color = {0.5, 0.5, 0.5}

  -- тема для заголовка активного окна   
  windowTheme.titleSelectedTheme = newWidgetTheme()
  windowTheme.titleSelectedTheme.color = {0, 180 / 255, 0.0}  
  
  -- Тема для кнопки закрытия окна  
  windowTheme.closeButtonTheme = newButtonTheme()
  windowTheme.closeButtonTheme.upTheme.image.file = getImage('close.png')
  windowTheme.closeButtonTheme.downTheme.image.file = getImage('close.png')
  windowTheme.closeButtonTheme.hoverUpTheme.image.file = getImage('close.png')  
  
  return windowTheme
end

-- Тема для тултипа
function newTooltipTheme()
  local tooltipTheme = newWidgetTheme()
  tooltipTheme.color =  {1, 1, 225 / 255}
  tooltipTheme.text.color = {0, 0, 0}
  tooltipTheme.text.align = {'center', 'center'}
  tooltipTheme.border = newSimple1Border({0, 0, 0})
  
  return tooltipTheme
end    

-- Тема для слайдера
function newSliderTheme()
  local sliderTheme = newWidgetTheme()
  sliderTheme.color = slider_bkg()
  sliderTheme.border = newDownBorder({0, 0, 0})
  
  -- Тема для ползунка
  sliderTheme.thumbTheme = newWidgetTheme()
  sliderTheme.thumbTheme.color = slider_thumb()
  sliderTheme.thumbTheme.border = newUpBorder({0, 0, 0})  
  
  return sliderTheme
end  

-- Тема для горизонтального слайдера
function newHSliderTheme()
  return newSliderTheme()
end  

-- Тема для вертикального слайдера
function newVSliderTheme()
  return newSliderTheme()
end

-- Тема для чекбокса
function newCheckBoxFaceTheme(up)
  local theme = newWidgetTheme()
  theme.color = {}
  theme.text.color = text_main()
  theme.text.offset = {18, -2}
  theme.text.align = {'left', 'center'}
  theme.text.font = text_main_font
  theme.text.size = text_main_font_size
  theme.image.align = {'left', 'center'}
  theme.border = newEmptyBorder()
  theme.image.file = getImage('btn-tools-01.png')
  if up then
      theme.image.rect = { 447, 217, 16, 16 }
  else
      theme.image.rect = { 463, 217, 16, 16 }
  end
  
  return theme
end

-- Тема для чекбокса
function newCheckBoxTheme() 
  return {
    upTheme = newCheckBoxFaceTheme(true),
    downTheme = newCheckBoxFaceTheme(false),
    hoverUpTheme = newCheckBoxFaceTheme(true),
    hoverDownTheme = newCheckBoxFaceTheme(false),
    undefinedUpTheme = newCheckBoxFaceTheme(true),
    undefinedDownTheme = newCheckBoxFaceTheme(false)
  }
end

--Тема для радиокнопки
function newRadioButtonFaceTheme()   
  local theme = newWidgetTheme()
  theme.color = {}
  theme.text.color = text_button()
  theme.text.offset = {18, -2}
  theme.text.align = {'left', 'center'}
  theme.text.font = text_button_font
  theme.text.size = text_button_font_size
  theme.image.align = {'left', 'center'}
  theme.border = newEmptyBorder()
  
  return theme
end

--Тема для радиокнопки
function newRadioButtonTheme()
  local upTheme = newRadioButtonFaceTheme()
  upTheme.image.file = getImage('radiooff.png')
  
  local downTheme = newRadioButtonFaceTheme()
  downTheme.image.file = getImage('radioon.png')
  
  local hoverUpTheme = newRadioButtonFaceTheme()
  hoverUpTheme.image.file = getImage('radiooff.png')  
  
  local hoverDownTheme = newRadioButtonFaceTheme()
  hoverDownTheme.image.file = getImage('radioon.png')    
  
  local undefinedUpTheme = newRadioButtonFaceTheme()
  undefinedUpTheme.image.file = getImage('radiooff.png')    
  
  local undefinedDownTheme = newRadioButtonFaceTheme()
  undefinedDownTheme.image.file = getImage('radioon.png')   
  
  return {
    upTheme = upTheme,
    downTheme = downTheme,
    hoverUpTheme = hoverUpTheme,
    hoverDownTheme = hoverDownTheme,
    undefinedUpTheme = undefinedUpTheme,
    undefinedDownTheme = undefinedDownTheme
  }
end  

-- Тема для скроллбара
function newScrollTheme()
  local scrollTheme = newWidgetTheme()
  scrollTheme.color = slider_bkg()
  scrollTheme.border = newDownBorder()
  
  -- Тема для слайдера
  scrollTheme.sliderTheme = newSliderTheme()
  scrollTheme.sliderTheme.border = newEmptyBorder()
  -- Размер скроллбара
  scrollTheme.size = 20
  
  return scrollTheme
end

-- Тема для горизонтального скроллбара
function newHScrollTheme()
  local scrollTheme = newScrollTheme()
  
  -- Тема для кнопки увеличения значения
  scrollTheme.increaseButtonTheme = newButtonRightTheme()
  
  -- Тема для кнопки уменьшения значения  
  scrollTheme.decreaseButtonTheme = newButtonLeftTheme()
  
  return scrollTheme
end

-- Тема для вертикального скроллбара
function newVScrollTheme()
  local scrollTheme = newScrollTheme()
  
  -- Тема для кнопки увеличения значения
  scrollTheme.increaseButtonTheme = newButtonDownTheme()
  
  -- Тема для кнопки уменьшения значения  
  scrollTheme.decreaseButtonTheme = newButtonUpTheme()
  return scrollTheme
end

-- Тема для прогрессбара
function newProgressBarTheme()
  local progressBarTheme = newWidgetTheme()
  progressBarTheme.color = dialog_ctrl()
  progressBarTheme.text.color = text_ctrl()
  progressBarTheme.text.align = {'center', 'center'}
  progressBarTheme.text.font = text_ctrl_font
  progressBarTheme.text.size = text_ctrl_font_size
  -- цвет для рисования заполнения прогрессбара
  progressBarTheme.selColor = list_select_color()
  
  return progressBarTheme
end

-- Тема для крутилки
function newDialTheme()
  local dialTheme = newWidgetTheme()
  dialTheme.image.file = getImage('diallever.png')
  dialTheme.image.align = {'stretch', 'stretch'}
  dialTheme.border = newEmptyBorder()
  
  -- Тема для стрелки
  dialTheme.arrowTheme = newWidgetTheme()
  dialTheme.arrowTheme.image.align = {'stretch', 'stretch'} -- растягиваем изображение на всю стрелку
  dialTheme.arrowTheme.image.file = getImage('dialarrow.png')
  
  -- длина стрелки в пикселях
  -- 0 или nil означает, что длина стрелки соответствует радиусу
  dialTheme.arrowTheme.length = 0
  
  -- высота стрелки в пикселях
  dialTheme.arrowTheme.height = 32
  
  return dialTheme
end  

-- Тема для скроллируемого контейнера
function newScrollPaneTheme()
  local scrollPaneTheme = newWidgetTheme()
  scrollPaneTheme.border = newSimple1Border({0, 0, 0})
  
  -- Тема для view
  scrollPaneTheme.viewTheme = newWidgetTheme()

  -- тема для горизонтального скроллбара
  scrollPaneTheme.hscrollTheme = newHScrollTheme()
  
  -- тема для вертикального скроллбара    
  scrollPaneTheme.vscrollTheme = newVScrollTheme()

  return scrollPaneTheme
end  

-- Тема для скроллируемого контейнера без рамки
function newFramelessScrollPaneTheme()
  local t = newScrollPaneTheme()
  t.border = newEmptyBorder()
  return t
end

-- Тема для окна сообщений
function newMsgWindowTheme()
  local windowTheme = newWindowTheme()

  windowTheme.color = dialog_prim()
  windowTheme.text.align = {'center', 'center'}
  windowTheme.text.color = {1,1,1}
  windowTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.ttf';
  windowTheme.text.size = 14
  windowTheme.border = newSimple1Border({0,0,0})
  
  -- высота заголовка окна
  windowTheme.titleHeight = 0

  -- тема для заголовка неактивного окна  
  windowTheme.titleNormalTheme.color = {0, 0, 0}
  windowTheme.titleNormalTheme.text.color = {1, 1, 1}

  -- тема для заголовка активного окна   
  windowTheme.titleSelectedTheme.color = {0, 0, 0}  
  windowTheme.titleSelectedTheme.text.color = {1, 1, 1}
  
  -- Тема для кнопки закрытия окна  
  windowTheme.closeButtonTheme = newButtonTheme()
  windowTheme.closeButtonTheme.upTheme.image.file = getImage('btn-tools-01.png')
  windowTheme.closeButtonTheme.upTheme.image.rect = {484, 4, 10, 10};
  windowTheme.closeButtonTheme.upTheme.color = {};
  windowTheme.closeButtonTheme.upTheme.border = newEmptyBorder();
  windowTheme.closeButtonTheme.downTheme.image.file = getImage('btn-tools-01.png')
  windowTheme.closeButtonTheme.downTheme.image.rect = {484, 21, 10, 10};
  windowTheme.closeButtonTheme.downTheme.color = {};
  windowTheme.closeButtonTheme.downTheme.border = newEmptyBorder();
  windowTheme.closeButtonTheme.hoverUpTheme.image.file = getImage('btn-tools-01.png')  
  windowTheme.closeButtonTheme.hoverUpTheme.image.rect = {484, 4, 10, 10};
  windowTheme.closeButtonTheme.hoverUpTheme.color = {};
  windowTheme.closeButtonTheme.hoverUpTheme.border = newEmptyBorder();
  
  windowTheme.titleHeight = 20
  
  -- тема для всех кнопок
  windowTheme.buttonTheme = newButtonTheme()
  
  -- расстояние между элементами окна и кнопками
  windowTheme.pad = 14
  
  -- Минимальная ширина кнопок
  windowTheme.minButtonWidth = 80
  
  -- Минимальная высота кнопок
  windowTheme.minButtonHeight = 24
  
  -- Иконка для сообщения Warning
  --windowTheme.iconWarning = getImage('warning.png')
  windowTheme.iconWarning = getImage('warning-labels.png')
  windowTheme.iconWarningRect = {0, 0, 64, 64}
  
  -- Иконка для сообщения Error
  --windowTheme.iconError = getImage('error.png')
  windowTheme.iconError = getImage('warning-labels.png')
  windowTheme.iconErrorRect = {128, 0, 64, 64}
  
  -- Иконка для сообщения Info
  --windowTheme.iconInfo = getImage('info.png')
  windowTheme.iconInfo = getImage('warning-labels.png')
  windowTheme.iconInfoRect = {192, 0, 64, 64}
  
  -- Иконка для сообщения Question
  --windowTheme.iconQuestion = getImage('question.png')
  windowTheme.iconQuestion = getImage('warning-labels.png')
  windowTheme.iconQuestionRect = {64, 0, 64, 64}
  
  windowTheme.buttonSound = 'button2.wav'
  
  return windowTheme
end  


-- Тема для выпадающего меню
function newMenuTheme()
  local menuTheme = newWidgetTheme()
  menuTheme.color = menu_list()
  menuTheme.border = newSimple1Border(border_dark)
  
  return menuTheme
end   

-- Тема для элемента меню
function newMenuItemTheme()
  -- Тема для нормального состояния
  local normalTheme = newWidgetTheme()
  normalTheme.color = menu_button()
  normalTheme.text.color = text_ctrl()
  normalTheme.text.offset = {4 + 16 + 4, -2} -- отступ от края + ширина картинки + отступ от картинки
  normalTheme.text.align = {'left', 'center'}
  normalTheme.text.font = text_ctrl_font
  normalTheme.text.size = text_ctrl_font_size
  normalTheme.image.offset = {4, 0}
  normalTheme.image.align = {'left', 'center'}
  normalTheme.image.w = 16
  normalTheme.image.h = 16
  
  -- Тема для активного состояния
  local selectedTheme = newWidgetTheme()
  selectedTheme.color = menu_select()
  selectedTheme.text.color = text_menu_select()
  selectedTheme.text.offset = {4 + 16 + 4, -2} -- отступ от края + ширина картинки + отступ от картинки
  selectedTheme.text.align = {'left', 'center'}
  selectedTheme.text.font = text_ctrl_font
  selectedTheme.text.size = text_ctrl_font_size
  selectedTheme.image.offset = {4, 0}
  selectedTheme.image.align = {'left', 'center'}
  selectedTheme.image.w = 16
  selectedTheme.image.h = 16
  
  -- тема для задания изображения подменю (обычно стрелка вправо) в неактивном состоянии  
  local submenuNormalTheme = newWidgetTheme()
  submenuNormalTheme.text.offset = {8 + 6 + 4, -2} -- расстояние от правого края до правого края текста (= отступ от правого края до картинки + ширина картинки + отступ от картинки до текста)
  submenuNormalTheme.image.color = {0, 0, 0}
  submenuNormalTheme.image.offset = {-6, 0} -- смещение картинки от правого края
  submenuNormalTheme.image.align = {'right', 'center'} -- выравнивание по правомку краю
  submenuNormalTheme.image.file = getImage('arrowright.png')
  
  -- тема для задания изображения подменю (обычно стрелка вправо) в активном состоянии
  local submenuSelectedTheme = newWidgetTheme()
  submenuSelectedTheme.text.offset = {8 + 6 + 4, -2} -- расстояние от правого края до правого края текста (= отступ от правого края до картинки + ширина картинки + отступ от картинки до текста)  
  submenuSelectedTheme.image.color = {1, 1, 1}
  submenuSelectedTheme.image.offset = {-6, 0} -- смещение картинки от правого края
  submenuSelectedTheme.image.align = {'right', 'center'} -- выравнивание по правомку краю
  submenuSelectedTheme.image.file = getImage('arrowright.png')  
  
  local menuItemTheme = {}
  menuItemTheme.normalTheme = normalTheme
  menuItemTheme.selectedTheme = selectedTheme
  menuItemTheme.submenuNormalTheme = submenuNormalTheme
  menuItemTheme.submenuSelectedTheme = submenuSelectedTheme  
  
  -- Высота элемента
  menuItemTheme.height = 20    
  
  return menuItemTheme
end  

-- Тема для элемента меню
function newMenuSeparatorItemTheme()
  local theme = newWidgetTheme()
  theme.color = {0, 0, 0}
  -- Высота элемента
  theme.height = 1
  
  return theme
end

-- Тема для элемента меню
function newMenuCheckItemTheme()
    local theme = newMenuItemTheme()
  theme.normalTheme.image.file = getImage('checkoff.png')
  theme.selectedTheme.image.file = getImage('checkon.png')  
  
  return theme
end  

-- Тема для элемента меню
function newMenuRadioItemTheme()
    local theme = newMenuItemTheme()
  theme.normalTheme.image.file = getImage('radiooff.png')
  theme.selectedTheme.image.file = getImage('radioon.png')  
  
  return theme
end  

-- Тема для менюбара
function newMenuBarTheme()
  local menuBarTheme = newWidgetTheme()
  -- Расстояние между элементами по горизонтали
  menuBarTheme.horzSpace = 10
  -- Расстояние от элемента до верхней и нижней границ менюбара
  menuBarTheme.vertSpace = 1
  
  return menuBarTheme
end

--Тема для элемента менюбара
function newMenuBarItemTheme()
  local normalTheme = newWidgetTheme()
  normalTheme.text.color = text_menu_button()
  normalTheme.text.align = {'center', 'center'}
  normalTheme.text.font = text_main_font
  normalTheme.text.size = text_main_font_size                        
  
  local hoverTheme = newWidgetTheme()
  hoverTheme.text.color = text_menu_button()
  hoverTheme.text.align = {'center', 'center'}
  hoverTheme.text.font = text_main_font
  hoverTheme.text.size = text_main_font_size   
  hoverTheme.border = newUpBorder()
  
  local selectedTheme = newWidgetTheme()
  selectedTheme.text.color = menu_text_main()
  selectedTheme.text.align = {'center', 'center'}
  selectedTheme.text.font = text_main_font
  selectedTheme.text.size = text_main_font_size   
  selectedTheme.border = newDownBorder()  

  local menuBarItemTheme = {}
  menuBarItemTheme.normalTheme = normalTheme
  menuBarItemTheme.hoverTheme = hoverTheme
  menuBarItemTheme.selectedTheme = selectedTheme
  
  return menuBarItemTheme
end   

-- Тема для таблицы
function newGridTheme()
  local gridTheme = newWidgetTheme()
  -- цвет линий сетки
  gridTheme.horzLinesColor = {0, 0, 0}
  gridTheme.vertLinesColor = {0, 0, 0}
  -- цвет выделенной строки
  gridTheme.selColor = {1, 1, 1}
  
  return gridTheme
end 
 
-- Тема для скроллируемой таблицы
function newScrollGridTheme()
  local scrollGridTheme = newWidgetTheme() 
  scrollGridTheme.border = newDownBorder()
  
  -- Высота заголовка таблицы
  scrollGridTheme.headerSize = 30  

  -- Тема для левого заголовка
  scrollGridTheme.leftHeaderTheme = newGridTheme()
  scrollGridTheme.leftHeaderTheme.color = grid_header()
  
  -- Тема для заголовка
  scrollGridTheme.headerTheme = newGridTheme()
  scrollGridTheme.headerTheme.color = grid_header()
  
  -- Тема для левой таблицы  
  scrollGridTheme.leftGridTheme = newGridTheme()    
  scrollGridTheme.leftGridTheme.color = dialog_ctrl()
  scrollGridTheme.leftGridTheme.selColor = button_on()
  
  -- Тема для таблицы  
  scrollGridTheme.gridTheme = newGridTheme()    
  scrollGridTheme.gridTheme.color = dialog_ctrl()
  scrollGridTheme.gridTheme.selColor = button_on()
  
  -- тема для горизонтального скроллбара
  scrollGridTheme.hscrollTheme = newHScrollTheme()
  
  -- тема для вертикального скроллбара    
  scrollGridTheme.vscrollTheme = newVScrollTheme()
  
  return scrollGridTheme
end 
 
-- Тема для заголовка столбца в таблице
function newGridColumnTheme()
  local gridColumnTheme = newWidgetTheme()
  gridColumnTheme.text.color = text_button()
  gridColumnTheme.text.align = {'center', 'center'}
  gridColumnTheme.text.font = text_top_font
  gridColumnTheme.text.size = text_top_font_size
  gridColumnTheme.image.align = {'center', 'center'}  
  
  return gridColumnTheme
end

-- Тема для заголовка ячейки в таблице
function newGridCellTheme()
  local gridCellTheme = newWidgetTheme()
  gridCellTheme.text.color = text_ctrl()
  gridCellTheme.text.align = {'right', 'center'}
  gridCellTheme.text.font = text_ctrl_font
  gridCellTheme.text.size = text_ctrl_font_size
  gridCellTheme.image.align = {'center', 'center'}    
  return gridCellTheme
end

-- Тема для списка
function newListBoxTheme()
  local listBoxTheme = newWidgetTheme()
  listBoxTheme.color = dialog_ctrl()
  listBoxTheme.border = newDownBorder()
  
  -- Тема для view
  listBoxTheme.viewTheme = newWidgetTheme()
      
  -- тема для горизонтального скроллбара
  listBoxTheme.hscrollTheme = newHScrollTheme()

  -- тема для вертикального скроллбара    
  listBoxTheme.vscrollTheme = newVScrollTheme()
    
  -- Высота элементов списка
  listBoxTheme.itemSize = 20
  
  return listBoxTheme
end  
  
-- Тема для элементов списка
function newListBoxItemTheme()
  -- Тема для нормального состояния
  local normalTheme = newWidgetTheme()
  normalTheme.color = {}
  normalTheme.text.color = text_ctrl()
  normalTheme.text.offset = {4 + 16 + 4, -2} -- отступ от края + ширина картинки + отступ от картинки
  normalTheme.text.align = {'left', 'center'}
  normalTheme.text.font = text_ctrl_font
  normalTheme.text.size = text_ctrl_font_size
  normalTheme.image.align = {'left', 'center'}  
  normalTheme.image.offset = {4, 0}
  normalTheme.image.w = 16
  normalTheme.image.h = 16
  
  -- Тема для активного состояния
  local selectedTheme = newWidgetTheme()
  selectedTheme.color = list_select_color()
  selectedTheme.text.color = text_ctrl()
  selectedTheme.text.offset = {4 + 16 + 4, -2} -- отступ от края + ширина картинки + отступ от картинки
  selectedTheme.text.align = {'left', 'center'}
  selectedTheme.text.font = text_ctrl_font
  selectedTheme.text.size = text_ctrl_font_size
  selectedTheme.image.align = {'left', 'center'}  
  selectedTheme.image.offset = {4, 0}
  selectedTheme.image.w = 16
  selectedTheme.image.h = 16   

  local listBoxItemTheme = {}
  listBoxItemTheme.normalTheme = normalTheme
  listBoxItemTheme.selectedTheme = selectedTheme
  
  return listBoxItemTheme
end 

-- Тема для элементов списка типа "файл" в окне выбора файлов
function newListBoxFileItemTheme()
  local listBoxFileItemTheme = newListBoxItemTheme()
  listBoxFileItemTheme.normalTheme.image.file = getImage('btn-tools-01.png')
  listBoxFileItemTheme.normalTheme.image.rect = {120, 204, 16, 14}
  
  listBoxFileItemTheme.selectedTheme.image.file = getImage('btn-tools-01.png')
  listBoxFileItemTheme.selectedTheme.image.rect = {120, 204, 16, 14}  

  return listBoxFileItemTheme
end

-- Тема для элементов списка типа "папка" в окне выбора файлов
function newListBoxFolderItemTheme()
  local listBoxFolderItemTheme = newListBoxItemTheme()
  listBoxFolderItemTheme.normalTheme.image.file = getImage('btn-tools-01.png')
  listBoxFolderItemTheme.normalTheme.image.rect = {90, 204, 16, 14}
  
  listBoxFolderItemTheme.selectedTheme.image.file = getImage('btn-tools-01.png')
  listBoxFolderItemTheme.selectedTheme.image.rect = {90, 204, 16, 14}

  return listBoxFolderItemTheme
end

-- Тема для списка с чекбоксами
function newCheckListBoxTheme()
  local checkListBoxTheme = newWidgetTheme()
  checkListBoxTheme.color = {170/255, 185/255, 155/255}
  checkListBoxTheme.border = newSimple1Border({1, 1, 1})
  
  -- Тема для view
  checkListBoxTheme.viewTheme = newWidgetTheme()

  -- тема для горизонтального скроллбара
  checkListBoxTheme.hscrollTheme = newHScrollTheme()
  
  -- тема для вертикального скроллбара    
  checkListBoxTheme.vscrollTheme = newVScrollTheme()

  -- Высота элементов списка
  checkListBoxTheme.itemSize = 20
  
  return checkListBoxTheme
end  

-- Тема для списка с чекбоксами
function newCheckListBoxTheme()
  return newListBoxTheme()
end
  
-- Тема для элементов списка типа чекбокс
function newCheckListBoxItemTheme()
  local checkListBoxItemTheme = newListBoxItemTheme()
  checkListBoxItemTheme.normalTheme.image.file = getImage('checkoff.png')
  checkListBoxItemTheme.selectedTheme.image.file = getImage('checkon.png')
  
  return checkListBoxItemTheme
end

-- Тема для поля редактирования
function newEditBoxTheme()
  local editBoxTheme = newWidgetTheme()
  editBoxTheme.color = dialog_ctrl()
  editBoxTheme.text.color = text_ctrl()
  editBoxTheme.text.offset = {5, -2}
  editBoxTheme.text.align = {'left', 'center'}
  editBoxTheme.text.font = text_ctrl_font
  editBoxTheme.text.size = text_ctrl_font_size
  editBoxTheme.image.offset = {4, 0}
  editBoxTheme.image.align = {'left', 'center'}
  editBoxTheme.border = newDownBorder()
  
  -- Тема для курсора
  editBoxTheme.caretTheme = newWidgetTheme()
  editBoxTheme.caretTheme.color = {205/255, 255/255, 210/255}
  
  -- Тема для выделения текста
  editBoxTheme.selectionTheme = newWidgetTheme()
  editBoxTheme.selectionTheme.color = {95/255, 105/255, 90/255, 0.5}
  
  return editBoxTheme
end 
 
-- Тема для многострочного поля редактирования
function newMEditBoxTheme()
  local meditBoxTheme = newWidgetTheme()
  meditBoxTheme.color = {0.5, 0.5, 0.5}
  --meditBoxTheme.text.align = {'left', 'center'}
  meditBoxTheme.border = newSimple1Border({1, 1, 1})
  
  -- Тема для view
  meditBoxTheme.viewTheme = newWidgetTheme()
  --meditBoxTheme.viewTheme.color = {1, 0, 0}
  --meditBoxTheme.viewTheme.text.align = {'left', 'top'}
  --meditBoxTheme.viewTheme.text.font = fontsPath .. 'courier.ttf'

  -- тема для вертикального скроллбара    
  meditBoxTheme.vscrollTheme = newMEVScrollTheme()
  
  -- Тема для выделения текста
  meditBoxTheme.selectionTheme = newWidgetTheme()
  meditBoxTheme.selectionTheme.color = {0, 0, 1, 0.5}
  meditBoxTheme.selectionTheme.caretColor = {1, 0, 0}  
  meditBoxTheme.selectionTheme.caretSize = 2 

  return meditBoxTheme
end   
 
-- Тема для спин бокса
function newSpinBoxTheme()
  local spinBoxTheme = newWidgetTheme()
  spinBoxTheme.color = dialog_ctrl()
  spinBoxTheme.border = newDownBorder()
  
  -- Тема для едитбокса
  spinBoxTheme.editBoxTheme = newEditBoxTheme()
  spinBoxTheme.editBoxTheme.text.align = {'center', 'center'}
  spinBoxTheme.editBoxTheme.border = newEmptyBorder()
  
  -- Тема для кнопки увеличения значения
  spinBoxTheme.increaseButtonTheme = newButtonRightTheme()
  
  -- Тема для кнопки уменьшения значения
  spinBoxTheme.decreaseButtonTheme = newButtonLeftTheme()
   
  return spinBoxTheme
end 

-- Тема для элементов списка комбобокса
function newComboBoxItemTheme()
  -- Тема для элемента в неактивном состоянии
  local normalTheme = newWidgetTheme()
  normalTheme.color = {}
  normalTheme.text.color = text_ctrl()
  normalTheme.text.offset = {4, -2} -- отступ от края
  normalTheme.text.align = {'left', 'center'}
  normalTheme.text.font = text_ctrl_font
  normalTheme.text.size = text_ctrl_font_size
  normalTheme.image.offset = {4, 0}
  normalTheme.image.align = {'left', 'center'}
  
  -- Тема для элемента в активном состоянии
  local selectedTheme = newWidgetTheme()
  selectedTheme.color = list_select_color()
  selectedTheme.text.color = text_ctrl()
  selectedTheme.text.offset = {4, -2} -- отступ от края
  selectedTheme.text.align = {'left', 'center'}
  selectedTheme.text.font = text_ctrl_font
  selectedTheme.text.size = text_ctrl_font_size
  selectedTheme.image.offset = {4, 0}
  selectedTheme.image.align = {'left', 'center'}    
  
  local comboBoxItemTheme = {}
  comboBoxItemTheme.normalTheme = normalTheme
  comboBoxItemTheme.selectedTheme = selectedTheme
  
  return comboBoxItemTheme
end


-- Тема для комбобокса
function newComboBoxTheme()
  local comboBoxTheme = newWidgetTheme()
  comboBoxTheme.color = dialog_ctrl()
  comboBoxTheme.border = newDownBorder()
  
  -- максимальная высота списка (далее внутри списка появляется скроллбар)
  comboBoxTheme.maxListHeight = 250
  
  -- тема для едитбокса
  comboBoxTheme.editBoxTheme = newEditBoxTheme()
  comboBoxTheme.editBoxTheme.border = newEmptyBorder()

  -- Тема для кнопки
  comboBoxTheme.buttonTheme = newButtonDownTheme()
  
  -- Тема для выпадающего списка
  comboBoxTheme.listBoxTheme = newListBoxTheme()
  comboBoxTheme.listBoxTheme.border = newSimple1Border(border_dark)
   
  -- Тема для элемента комбобокса
  comboBoxTheme.itemTheme = newComboBoxItemTheme();
  return comboBoxTheme
end
 

-- Тема для вьюера карты
function newMapViewTheme()
  local mapViewTheme = newWidgetTheme()
  mapViewTheme.color = {88 / 255, 117 / 255, 64 / 255}
  mapViewTheme.border = newSimple1Border({0, 0, 0})
  
  return mapViewTheme
end

-- заголовок вложенных окон
function newHeaderTheme()
  local theme = newWidgetTheme()
  theme.color = dialog_top()
  theme.text.color = text_top()
  theme.text.offset = {4, -2}
  theme.text.align = {'left', 'center'}
  theme.font = text_top_font
  theme.size = text_top_font_size
  
  return theme
end

-- кнопка закрытия вложенного окна
function newHeaderButtonTheme()
  local theme = newButtonTheme()
  local image = getImage('btn-tools-01.png')
  
  theme.upTheme.border = newEmptyBorder()
  theme.upTheme.color = dialog_top()
  theme.upTheme.image.file = image
  theme.upTheme.image.rect = {480 , 0, 18, 18} 
  
  theme.downTheme.border = newEmptyBorder()
  theme.downTheme.color = dialog_top()
  theme.downTheme.image.file = image
  theme.downTheme.image.rect = {480 , 18, 18, 18} 
  
  theme.hoverUpTheme.border = newEmptyBorder()
  theme.hoverUpTheme.color = dialog_top()
  theme.hoverUpTheme.image.file = image
  theme.hoverUpTheme.image.rect = {480 , 0, 18, 18} 

  return theme
end

-- тема для кнопок главного меню
function newMainMenuButtonTheme()
  local upTheme = newWidgetTheme()
  upTheme.text.color = text_button()
  upTheme.text.offset = {50, 0}
  upTheme.text.align =  {'left', 'center'}
  upTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed-Bold.ttf'  
  upTheme.text.size = 16
  upTheme.image.align =  {'left', 'center'}
  upTheme.image.file = getImage('btn-tools-01.png')
  upTheme.image.rect = {1, 177, 42, 26}
  
  local downTheme = newWidgetTheme()
  downTheme.text.color = text_button()
  downTheme.text.offset = {50, 0}
  downTheme.text.align =  {'left', 'center'}
  downTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed-Bold.ttf'  
  downTheme.text.size = 16
  downTheme.image.align =  {'left', 'center'}
  downTheme.image.file = getImage('btn-tools-01.png')
  downTheme.image.rect = {45, 177, 42, 26}
  
  local hoverUpTheme = newWidgetTheme()
  hoverUpTheme.text.color = text_button()
  hoverUpTheme.text.offset = {50, 0}
  hoverUpTheme.text.align =  {'left', 'center'}
  hoverUpTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed-Bold.ttf'  
  hoverUpTheme.text.size = 16
  hoverUpTheme.image.align =  {'left', 'center'}
  hoverUpTheme.image.file = getImage('btn-tools-01.png')
  hoverUpTheme.image.rect = {132, 177, 42, 26}
  
  return {
    upTheme = upTheme,
    downTheme = downTheme,
    hoverUpTheme = hoverUpTheme,
  }
end

-- тема для подписи версии главного меню
function newMainMenuVersionTheme()
  local mainMenuVersionTheme = newWidgetTheme()
  mainMenuVersionTheme.text.color = text_button()
  mainMenuVersionTheme.text.align = {'left', 'center'}
  mainMenuVersionTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed-BoldOblique.ttf'
  mainMenuVersionTheme.text.size = 16  
  
  return mainMenuVersionTheme
end

-- тема для logo верхнего тулбара
function newMEToolbarLogoTheme()
  local meToolbarLogoTheme = newWidgetTheme()
  meToolbarLogoTheme.image.file = getImage('toolbar_top.png')
  meToolbarLogoTheme.image.rect = {1024 - 400, 0, 400, 45}  
  meToolbarLogoTheme.image.align = {'left', 'top'}
  
  return meToolbarLogoTheme
end

-- тема для logo верхнего тулбара Options
function newMEOptionsLogoTheme()
  local meOptionsLogoTheme = newWidgetTheme()
  meOptionsLogoTheme.image.file = getImage('options_top.png')
  meOptionsLogoTheme.image.rect = {1024 - 400, 0, 400, 45}
  meOptionsLogoTheme.image.align = {'left', 'top'}
  return meOptionsLogoTheme
end

-- тема для верхнего тулбара
function newToolbarTheme()
--  local theme = newMEToolbarLogoTheme()
  local theme = newWidgetTheme()
  theme.color = statusbar_main()
--  theme.image.rect = {0, 0, 1024 - 400, 45}
--  theme.image.align = {'stretch', 'top'}
  
  return theme
end

-- Тема для контролов на нижнем тулбаре
function newToolbarWidgetTheme()
  local theme = newWidgetTheme()
  
  theme.color = statusbar_editbox()
  theme.text.color = text_main()
  theme.text.align = {'left', 'center'}
  theme.text.font = text_main_font
  theme.text.size = text_main_font_size
  theme.text.offset[1] = 4
  
  return theme
end

function newMELeftToolbarTheme()
  local theme = newWindowTheme()
  
  theme.color = toolbar_main()
  
  return theme
end

-- Подписи к группам кнопок на левом тулбаре
function newToolbarCaptionTheme()
  local toolbarCaptionTheme = newWidgetTheme()
  toolbarCaptionTheme.color = {0/255, 0/255, 0/255}
  toolbarCaptionTheme.text.color = text_toolbar_groups()
  toolbarCaptionTheme.text.align = {'center', 'center'}
  toolbarCaptionTheme.text.font = text_ctrl_font
  toolbarCaptionTheme.text.size = text_ctrl_font_size
  
  return toolbarCaptionTheme
end

-- Подписи к группам кнопок на нижнем тулбаре
function newStatusbarCaptionTheme()
  local statusbarCaptionTheme = newWidgetTheme()
  statusbarCaptionTheme.text.color = text_statusbar_groups()
  statusbarCaptionTheme.text.align = {'center', 'center'}
  statusbarCaptionTheme.text.font = text_ctrl_font
  statusbarCaptionTheme.text.size = text_ctrl_font_size  
  
  return statusbarCaptionTheme
end

-- Кнопка на левом тулбаре
-- картинка на кнопке задается в файле формы
function newToolbarButtonTheme()
  local theme = newButtonTheme()
  local image = getImage('btn-tools-01.png')
  
  theme.upTheme.color = {}
  theme.upTheme.border = newEmptyBorder()
  theme.upTheme.image.file = image
  theme.upTheme.image.offset = {0, 0}
  theme.upTheme.image.align = {'left', 'top'}
  
  theme.downTheme.color = {}
  theme.downTheme.border = newEmptyBorder()
  theme.downTheme.image.file = image
  theme.downTheme.image.offset = {0, 0}
  theme.downTheme.image.align = {'left', 'top'}
  
  theme.hoverUpTheme.color = {}
  theme.hoverUpTheme.border = newEmptyBorder()
  theme.hoverUpTheme.image.file = image
  theme.hoverUpTheme.image.offset = {0, 0}
  theme.hoverUpTheme.image.align = {'left', 'top'}

  theme.hoverDownTheme.color = {}
  theme.hoverDownTheme.border = newEmptyBorder()
  theme.hoverDownTheme.image.file = image
  theme.hoverDownTheme.image.offset = {0, 0}
  theme.hoverDownTheme.image.align = {'left', 'top'}
  
  theme.undefinedUpTheme.color = {}
  theme.undefinedUpTheme.border = newEmptyBorder()
  theme.undefinedUpTheme.image.file = image
  theme.undefinedUpTheme.image.offset = {0, 0}
  theme.undefinedUpTheme.image.align = {'left', 'top'}

  theme.undefinedDownTheme.color = {}
  theme.undefinedDownTheme.border = newEmptyBorder()
  theme.undefinedDownTheme.image.file = image
  theme.undefinedDownTheme.image.offset = {0, 0}
  theme.undefinedDownTheme.image.align = {'left', 'top'}
  
  return theme
end

-- тема для фона новых окон
function newMEBackgroundTheme()
    local t = newWindowTheme()
    t.color = menu_button()
    
    return t
end

-- тема для фона новых окон
function newMEBackgroundPaneTheme()
    local t = newContainerTheme()
    t.color = dialog_prim()
    
    return t
end

-- тема для кнопок переключения страниц
function newMEPageToggleTheme()
    local t = newButtonTheme()
    t.upTheme.border = newSimple2Border(dialog_top())
    t.upTheme.color = dialog_prim()
    t.upTheme.text.color = text_ctrl()
    
    return t
end

-- тема для рамки диалоговых окон
function newMEFrameTheme()
    local t = newContainerTheme()
    t.color = dialog_prim()
    t.border = newSimple2Border(dialog_top())
    
    return t
end

-- тема для заголовка диалогового окна
function newMEDialogTopTheme()
    local t = newWidgetTheme()
    t.color = dialog_top()
    t.text.offset = { 10, -2 }
    
    return t
end


-- тема для заголовка диалогового окна
function newMECenteredLabelTheme()
    local t = newWidgetTheme()
    t.text.align = {'center', 'center'}
    t.text.color = text_ctrl()
    
    return t
end

-- тема для кнопок
function newMEButtonTheme()
    local t = newButtonTheme()
    t.upTheme.border = newSimple1Border(dialog_top())
    t.upTheme.color = dialog_prim()
    t.upTheme.text.color = text_ctrl()

    return t
end

-- тема для фона панелей группировки виджетов
function newMEGroupPaneTheme()
    local t = newContainerTheme()
    t.color = dialog_sec()
    
    return t
end

function newPresetGroupPaneTheme()
    local t = newMEGroupPaneTheme()
    t.image = newImage()
    t.image.file = getImage('weather-editor-background.png')
    return t
end

-- тема для подписей к комбо-боксам и т.п.
function newRightLabelTheme()
    local t = newWidgetTheme()
    t.text.align = {'right', 'center'}
    
    return t
end

-- тема для окна настройки джойстика
function newTestViewTheme()
  local newTestViewTheme = newWidgetTheme()
  newTestViewTheme.border = newSimple1Border(border_dark)

  return newTestViewTheme
end

function newMainMenuTheme()
  local theme = newWindowTheme()
  theme.color = menu_button()
  theme.image.file = getImage('main-menu-01.png')
  theme.image.rect = {0, 0, 1024, 768}
  theme.image.align = {'stretch', 'stretch'}
  theme.border = newEmptyBorder()
  
  return theme
end

function newWaitScreenTheme()
  local theme = newWidgetTheme()
  --theme.image.file = getImage('start-ka50.png')
  theme.image.file = getImage('loading-window.png')
  theme.image.align = {'stretch', 'stretch'}
  theme.border = newEmptyBorder()
  
  return theme
end

function newImagePreviewTheme()
  local theme = newWidgetTheme()
  theme.image.align = {'stretch', 'stretch'}
  theme.border = newSimple1Border({0,0,0,1})
  return theme
end

function newLoadoutMsgWindowTheme()
  local theme = newWindowTheme()
  theme.titleHeight = 20
  theme.border = newUpBorder()
  
  theme.buttonSound = 'button2.wav'
  
  return theme
end

function newLoadoutExportWindowTheme()
  local theme = newWindowTheme()
  theme.titleHeight = 20
  theme.border = newUpBorder()
  
  return theme
end

-- тема для подписи количества боеприпасов в редакторе подвесок
function newLoadoutCaptionTheme()
  local theme = newWidgetTheme()
  
  theme.text.color = text_ctrl()
  theme.text.align = {'center', 'center'}
  theme.border = newSimple1Border({0, 0, 0})
  
  -- размер подписи
  theme.size = {20, 16}
  
  return theme
end

function newLoadoutImageTheme()
  local theme = newWidgetTheme()  
  
  theme.color = loadout_image_bkg()
  
  return theme
end

function newAutoBriefingTheme()
  local theme = newWidgetTheme()
  theme.titleHeight = 0
  theme.image.align =  {'center', 'center'}
  theme.image.file = getImage('briefing-map-background.png')
  theme.border = newEmptyBorder()  
  return theme
end

function newAutoBriefing_TopRegionTheme()
  local theme = newWidgetTheme()
  theme.image.align =  {'center', 'center'}
  theme.image.file = getImage('background-details-1.png')
  theme.image.rect = {0,0,2048,40}
  theme.border = newEmptyBorder()  
  return theme
end

function newAutoBriefing_TopRegion_WidgetLogoTheme()
  local theme = newWidgetTheme()
  theme.image.align =  {'left', 'center'}
  theme.image.file = getImage('logotypes-v1.png')
  theme.image.rect = {526,47,100,34}
  theme.border = newEmptyBorder()  
  return theme
end

function newAutoBriefing_TopRegion_CloseButtonTheme()
    local pic = 'Keys-v2.png';
    local theme = newButtonTheme();
    theme.upTheme.image.align =  {'center', 'center'}
    theme.upTheme.image.file = getImage(pic)
    theme.upTheme.image.rect = {0,0,20,20}
    theme.upTheme.color = {1,0,1,0}
    theme.upTheme.border = newEmptyBorder()  
    theme.downTheme.image.align =  {'center', 'center'}
    theme.downTheme.image.file = getImage(pic)
    theme.downTheme.image.rect = {20,0,20,20}
    theme.downTheme.color = {1,0,1,0}
    theme.downTheme.border = newEmptyBorder()  
    theme.hoverUpTheme.image.align =  {'center', 'center'}
    theme.hoverUpTheme.image.file = getImage(pic)
    theme.hoverUpTheme.image.rect = {20,0,20,20}
    theme.hoverUpTheme.color = {1,0,1,0}
    theme.hoverUpTheme.border = newEmptyBorder()  
    return theme;
end

function newAutoBriefing_TopRegion_BriefingTextTheme()
    local theme = newWidgetTheme()
    theme.text.font = fontsPath .. 'DejaVuLGCSans-BoldOblique.ttf';
    theme.text.size = 19;
    theme.text.color = {1, 1, 1, 1};
    theme.color = {1,0,1,0}
    return theme;
end

function newAutobriefingWidgetTheme()
  local theme = newWidgetTheme()
  theme.color = {}
  theme.text.color = {0,0,0}
  theme.text.offset = {0, 0}
  theme.text.align = {'center', 'center'}
  theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.ttf';
  theme.text.size = 14
  theme.image.align = {'center', 'center'}
  theme.image.file = getImage('billets-1.png')
  theme.image.rect = {406, 2, 103, 27}
  theme.image.w = 103;
  theme.image.h = 27;
  theme.image.color = {204/255, 204/255, 204/255};
  theme.border = newEmptyBorder()
  return theme
end; 

function newAutobriefingWidget2Theme()
  local theme = newMainMenuLogoTheme()
  theme.image.rect = {256,0,256,42};
  theme.image.color = {0,0,0};
  return theme    
end; 

function newAutobriefingWidget3Theme()
  local theme = newMainMenuLogoTheme()
  theme.image.rect = {256,44,256,19};
  theme.image.color = {1,1,1};
  return theme    
end; 

function newAutoBriefing_BottomRegionTheme()
  local theme = newWidgetTheme()
  theme.image.align =  {'center', 'center'}
  theme.image.file = getImage('background-details-1.png')
  theme.image.rect = {0,53,2048,76}
  theme.border = newEmptyBorder()  
  return theme
end

function newAutoBriefing_ContainerMainTheme()
  local theme = newWidgetTheme()
  theme.color = {0,0,1,0}
  theme.border = newSimple1Border({0,0,0});
  theme.image.file = "c:/LockOn/LockOnExe/New GUI/Alternative/Crops/autobriefing.png"
  return theme
end

function newAutoBriefing_ContainerMain_PictureTextTheme()
    local theme = newWidgetTheme()
    theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.ttf';
    theme.text.size = 14;
    theme.text.color = {0, 0, 0, 1};
    theme.text.align = {'center', 'center'};
    theme.color = {0,0,0,0}
    return theme;
end

function newAutoBriefing_ContainerBottom_ButtonsTheme()
    return newAutoBriefing_ContainerMainTheme()
end;

function newAutoBriefing_ContainerBottom_FlyButtonTheme()
    local pic = 'LightKeys.png';
    local theme = newButtonTheme();
    theme.upTheme.image.align =  {'right', 'center'}
    theme.upTheme.image.file = getImage(pic)
    theme.upTheme.image.rect = {0,150,50,50}
    theme.upTheme.color = {1,0,1,0}
    theme.upTheme.border = newEmptyBorder()  
    theme.downTheme.image.align =  {'right', 'center'}
    theme.downTheme.image.file = getImage(pic)
    theme.downTheme.image.rect = {150,150,50,50}
    theme.downTheme.color = {1,0,1,0}
    theme.downTheme.border = newEmptyBorder()  
    theme.hoverUpTheme.image.align =  {'right', 'center'}
    theme.hoverUpTheme.image.file = getImage(pic)
    theme.hoverUpTheme.image.rect = {50,150,50,50}
    theme.hoverUpTheme.color = {1,0,1,0}
    theme.hoverUpTheme.border = newEmptyBorder()  
    
    theme.upTheme.text.font = fontsPath .. 'DejaVuLGCSans.ttf';
    theme.upTheme.text.size = 20;
    theme.upTheme.text.color = {1,1,1};
    theme.upTheme.text.align =  {'left', 'center'}
    theme.downTheme.text.font = fontsPath .. 'DejaVuLGCSans.ttf';
    theme.downTheme.text.size = 20;
    theme.downTheme.text.color = {1,1,1};
    theme.downTheme.text.align =  {'left', 'center'}
    theme.hoverUpTheme.text.font = fontsPath .. 'DejaVuLGCSans.ttf';
    theme.hoverUpTheme.text.size = 20;
    theme.hoverUpTheme.text.color = {1,1,1};
    theme.hoverUpTheme.text.align =  {'left', 'center'}
    
    return theme;
end

function newAutoBriefing_ContainerBottom_CancelButtonTheme()
    local pic = 'Keys-v1.png';
    local theme = newButtonTheme();
    theme.upTheme.image.align =  {'left', 'center'}
    theme.upTheme.image.file = getImage(pic)
    theme.upTheme.image.rect = {0,150,50,50}
    theme.upTheme.color = {1,0,1,0}
    theme.upTheme.border = newEmptyBorder()  
    theme.downTheme.image.align =  {'left', 'center'}
    theme.downTheme.image.file = getImage(pic)
    theme.downTheme.image.rect = {150,150,50,50}
    theme.downTheme.color = {1,0,1,0}
    theme.downTheme.border = newEmptyBorder()  
    theme.hoverUpTheme.image.align =  {'left', 'center'}
    theme.hoverUpTheme.image.file = getImage(pic)
    theme.hoverUpTheme.image.rect = {50,150,50,50}
    theme.hoverUpTheme.color = {1,0,1,0}
    theme.hoverUpTheme.border = newEmptyBorder()  
    
    theme.upTheme.text.font = fontsPath .. 'DejaVuLGCSans.ttf';
    theme.upTheme.text.size = 20;
    theme.upTheme.text.color = {1,1,1};
    theme.upTheme.text.align =  {'right', 'center'}
    theme.downTheme.text.font = fontsPath .. 'DejaVuLGCSans.ttf';
    theme.downTheme.text.size = 20;
    theme.downTheme.text.color = {1,1,1};
    theme.downTheme.text.align =  {'right', 'center'}
    theme.hoverUpTheme.text.font = fontsPath .. 'DejaVuLGCSans.ttf';
    theme.hoverUpTheme.text.size = 20;
    theme.hoverUpTheme.text.color = {1,1,1};
    theme.hoverUpTheme.text.align =  {'right', 'center'}
    return theme;
end

function download_ButtonTheme()
    --local pic = 'Keys-v1.png';
    local theme = newButtonTheme();
    theme.upTheme.image.align =  {'left', 'center'}
   -- theme.upTheme.image.file = getImage(pic)
    theme.upTheme.image.rect = {0,250,40,40}
    theme.upTheme.color = {1,0,1,0}
    theme.upTheme.border = newEmptyBorder()  
    theme.downTheme.image.align =  {'left', 'center'}
    --theme.downTheme.image.file = getImage(pic)
    theme.downTheme.image.rect = {150,250,40,40}
    theme.downTheme.color = {1,0,1,0}
    theme.downTheme.border = newEmptyBorder()  
    theme.hoverUpTheme.image.align =  {'left', 'center'}
    --theme.hoverUpTheme.image.file = getImage(pic)
    theme.hoverUpTheme.image.rect = {50,250,50,50}
    theme.hoverUpTheme.color = {1,0,1,0}
    theme.hoverUpTheme.border = newEmptyBorder()  
    
    theme.upTheme.text.font = fontsPath .. 'DejaVuLGCSans.ttf';
    theme.upTheme.text.size = 20;
    theme.upTheme.text.color = {1,1,1};
    theme.upTheme.text.align =  {'right', 'center'}
    theme.downTheme.text.font = fontsPath .. 'DejaVuLGCSans.ttf';
    theme.downTheme.text.size = 20;
    theme.downTheme.text.color = {1,0,0};
    theme.downTheme.text.align =  {'right', 'center'}
    theme.hoverUpTheme.text.font = fontsPath .. 'DejaVuLGCSans.ttf';
    theme.hoverUpTheme.text.size = 20;
    theme.hoverUpTheme.text.color = {0.5,0.5,1};
    theme.hoverUpTheme.text.align =  {'right', 'center'}
    return theme;
end

function newAutoBriefing_ContainerBottom_MEButtonTheme()
    local pic = 'LightKeys-v2.png';
    local theme = newButtonTheme();
    theme.upTheme.image.align =  {'center', 'center'}
    theme.upTheme.image.file = getImage(pic)
    theme.upTheme.image.rect = {0,80,60,20}
    theme.upTheme.color = {1,0,1,0}
    theme.upTheme.border = newEmptyBorder()  
    theme.downTheme.image.align =  {'center', 'center'}
    theme.downTheme.image.file = getImage(pic)
    theme.downTheme.image.rect = {0,100,60,20}
    theme.downTheme.color = {1,0,1,0}
    theme.downTheme.border = newEmptyBorder()  
    theme.hoverUpTheme.image.align =  {'center', 'center'}
    theme.hoverUpTheme.image.file = getImage(pic)
    theme.hoverUpTheme.image.rect = {0,80,60,20}
    theme.hoverUpTheme.color = {1,0,1,0}
    theme.hoverUpTheme.border = newEmptyBorder()  

    theme.upTheme.text.font = fontsPath .. 'DejaVuLGCSans.ttf';
    theme.upTheme.text.size = 14;
    theme.upTheme.text.color = {180/255,180/255,180/255};
    theme.upTheme.text.align =  {'center', 'center'}
    theme.downTheme.text.font = fontsPath .. 'DejaVuLGCSans.ttf';
    theme.downTheme.text.size = 14;
    theme.downTheme.text.color = {180/255,180/255,180/255};
    theme.downTheme.text.align =  {'center', 'center'}
    theme.hoverUpTheme.text.font = fontsPath .. 'DejaVuLGCSans.ttf';
    theme.hoverUpTheme.text.size = 14;
    theme.hoverUpTheme.text.color = {180/255,180/255,180/255};
    theme.hoverUpTheme.text.align =  {'center', 'center'}
    return theme;
end

function newAutoBriefing_ContainerMain_ScrollPaneTheme()
  local scrollGridTheme = newWidgetTheme() 
  --scrollGridTheme.border = newDownBorder()
  
  -- Высота заголовка таблицы
  scrollGridTheme.headerSize = 0  
  
  -- Тема для заголовка
  scrollGridTheme.headerTheme = newGridTheme()
  scrollGridTheme.headerTheme.color = button_off()
  scrollGridTheme.headerTheme.selColor =  {1,1,1,0}
  scrollGridTheme.headerTheme.gridColor = {1,1,1,0}
  
    -- Тема для таблицы  
  scrollGridTheme.gridTheme = newGridTheme()    
  scrollGridTheme.gridTheme.color = {1,1,1,0}
  scrollGridTheme.gridTheme.selColor =  {1,1,1,0}
  scrollGridTheme.gridTheme.gridColor = {};--{1,1,1,0}
  
  -- тема для горизонтального скроллбара
  scrollGridTheme.hscrollTheme = newMEHScrollTheme()
  
  -- тема для вертикального скроллбара    
  scrollGridTheme.vscrollTheme = newMEVScrollTheme()
  
  return scrollGridTheme
end 

--[[
function newMainMenu2Theme()
  local theme = newWindowTheme()
  theme.color = menu_button()
  theme.image.file = getImage('base-menu-window.png')
  theme.image.rect = {0, 0, 2048, 2048}
  theme.image.align = {'center', 'center'}
  theme.border = newEmptyBorder()
  theme.color = {0,0,0}   
  return theme

end;
]]--

function newMainMenu2Theme(img)
  local theme = newWindowTheme()
  theme.color = menu_button()
  theme.image.file = img[1]
  --theme.image.rect = {0, 0, 2048, 2048}

  if img[2] == nil then
    img[2] = 2048
  end

  if img[3] == nil then
    img[3] = 2048
  end

  theme.image.rect = {0, 0, img[2], img[3]}
  theme.image.align = {'center', 'center'}
  theme.border = newEmptyBorder()
  theme.color = {0,0,0}   
  return theme

end;

function newMainMenuTopButtonTheme()
    local pic = 'Keys-v1.png';
    local theme = newButtonTheme();
    theme.upTheme.image.align =  {'center', 'top'}
    theme.upTheme.image.file = getImage(pic)
    theme.upTheme.image.rect = {0,0,50,50}
    theme.upTheme.image.offset = {0,48}
    theme.upTheme.color = {1,0,1,0}
    theme.upTheme.border = newEmptyBorder()  
    theme.downTheme.image.align =  {'center', 'top'}
    theme.downTheme.image.file = getImage(pic)
    theme.downTheme.image.rect = {150,0,50,50}
    theme.downTheme.color = {1,0,1,0}
    theme.downTheme.border = newEmptyBorder()  
    theme.downTheme.image.offset = {0,48}
    theme.hoverUpTheme.image.align =  {'center', 'top'}
    theme.hoverUpTheme.image.file = getImage(pic)
    theme.hoverUpTheme.image.rect = {50,0,50,50}
    theme.hoverUpTheme.color = {1,0,1,0}
    theme.hoverUpTheme.border = newEmptyBorder()  
    theme.hoverUpTheme.image.offset = {0,48}
    
    theme.upTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.ttf';
    theme.upTheme.text.size = 19;
    theme.upTheme.text.color = {1,1,1};
    theme.upTheme.text.offset = {0,-27};
    theme.upTheme.text.align =  {'center', 'center'}
    theme.downTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.ttf';
    theme.downTheme.text.size = 19;
    theme.downTheme.text.color = {1,1,1};
    theme.downTheme.text.offset = {0,-27};
    theme.downTheme.text.align =  {'center', 'center'}
    theme.hoverUpTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.ttf';
    theme.hoverUpTheme.text.size = 19;
    theme.hoverUpTheme.text.color = {1,1,1};
    theme.hoverUpTheme.text.offset = {0,-27};
    theme.hoverUpTheme.text.align =  {'center', 'center'}
    
    return theme;
end

function newMainMenuRightButtonTheme()
    local pic = 'Keys-v1.png';
    local theme = newButtonTheme();
    theme.upTheme.image.align =  {'left', 'center'}
    theme.upTheme.image.file = getImage(pic)
    theme.upTheme.image.rect = {0,0,50,50}
    theme.upTheme.color = {1,0,1,0}
    theme.upTheme.border = newEmptyBorder()  
    theme.upTheme.image.offset = {11, 0}
    theme.downTheme.image.align =  {'left', 'center'}
    theme.downTheme.image.file = getImage(pic)
    theme.downTheme.image.rect = {150,0,50,50}
    theme.downTheme.color = {1,0,1,0}
    theme.downTheme.border = newEmptyBorder()  
    theme.downTheme.image.offset = {11, 0}
    theme.hoverUpTheme.image.align =  {'left', 'center'}
    theme.hoverUpTheme.image.file = getImage(pic)
    theme.hoverUpTheme.image.rect = {50,0,50,50}
    theme.hoverUpTheme.color = {1,0,1,0}
    theme.hoverUpTheme.border = newEmptyBorder()  
    theme.hoverUpTheme.image.offset = {11, 0}
    
    --theme.upTheme.text.font = fontsPath .. 'DejaVuLGCSans.ttf';
    theme.upTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.ttf'
    theme.upTheme.text.size = 19;
    theme.upTheme.text.lineSpacing = 0.65;
    theme.upTheme.text.color = {1,1,1};
    theme.upTheme.text.offset = {75,-2};
    theme.upTheme.text.align =  {'left', 'center'}
    theme.downTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.ttf';
    theme.downTheme.text.size = 19;
    theme.downTheme.text.lineSpacing = 0.65;
    theme.downTheme.text.color = {1,1,1};
    theme.downTheme.text.offset = {75,-2};
    theme.downTheme.text.align =  {'left', 'center'}
    theme.hoverUpTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.ttf';
    theme.hoverUpTheme.text.size = 19;
    theme.hoverUpTheme.text.lineSpacing = 0.65;
    theme.hoverUpTheme.text.color = {1,1,1};
    theme.hoverUpTheme.text.offset = {75,-2};
    theme.hoverUpTheme.text.align =  {'left', 'center'}
    
    return theme;

end;

function newMainMenuBottomButtonTheme()
    local pic = 'LightKeys.png';
    local theme = newButtonTheme();
    theme.upTheme.image.align =  {'center', 'top'}
    theme.upTheme.image.file = getImage(pic)
    theme.upTheme.image.rect = {0,0,50,50}
    theme.upTheme.color = {1,0,1,0}
    theme.upTheme.border = newEmptyBorder()  
    theme.upTheme.image.offset = {0, 11}
    theme.downTheme.image.align =  {'center', 'top'}
    theme.downTheme.image.file = getImage(pic)
    theme.downTheme.image.rect = {150,0,50,50}
    theme.downTheme.color = {1,0,1,0}
    theme.downTheme.border = newEmptyBorder()  
    theme.downTheme.image.offset = {0, 11}
    theme.hoverUpTheme.image.align =  {'center', 'top'}
    theme.hoverUpTheme.image.file = getImage(pic)
    theme.hoverUpTheme.image.rect = {50,0,50,50}
    theme.hoverUpTheme.color = {1,0,1,0}
    theme.hoverUpTheme.border = newEmptyBorder()  
    theme.hoverUpTheme.image.offset = {0, 11}
    
    theme.upTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.ttf';
    theme.upTheme.text.size = 19;
    theme.upTheme.text.color = {1,1,1};
    theme.upTheme.text.offset = {0,-18};
    theme.upTheme.text.align =  {'center', 'bottom'}
    theme.downTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.ttf';
    theme.downTheme.text.size = 19;
    theme.downTheme.text.color = {1,1,1};
    theme.downTheme.text.offset = {0,-18};
    theme.downTheme.text.align =  {'center', 'bottom'}
    theme.hoverUpTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.ttf';
    theme.hoverUpTheme.text.size = 19;
    theme.hoverUpTheme.text.color = {1,1,1};
    theme.hoverUpTheme.text.offset = {0,-18};
    theme.hoverUpTheme.text.align =  {'center', 'bottom'}
    
    return theme;
end;

function newMainMenuLeftButtonTheme()
    local pic = 'Keys-v1.png';
    local imageAlignment = {'right', 'center'}
    local theme = newButtonTheme();
    theme.upTheme.image.align =  imageAlignment;
    theme.upTheme.image.file = getImage(pic)
    theme.upTheme.image.rect = {0,0,50,50}
    theme.upTheme.color = {1,0,1,0}
    theme.upTheme.border = newEmptyBorder()  
    theme.upTheme.image.offset = {-11, 0}
    theme.downTheme.image.align =  imageAlignment
    theme.downTheme.image.file = getImage(pic)
    theme.downTheme.image.rect = {150,0,50,50}
    theme.downTheme.color = {1,0,1,0}
    theme.downTheme.border = newEmptyBorder()  
    theme.downTheme.image.offset = {-11, 0}
    theme.hoverUpTheme.image.align =  imageAlignment
    theme.hoverUpTheme.image.file = getImage(pic)
    theme.hoverUpTheme.image.rect = {50,0,50,50}
    theme.hoverUpTheme.color = {1,0,1,0}
    theme.hoverUpTheme.border = newEmptyBorder()  
    theme.hoverUpTheme.image.offset = {-11, 0}
    
    theme.upTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.ttf';
    theme.upTheme.text.size = 19;
    theme.upTheme.text.lineSpacing = 0.65;
    theme.upTheme.text.color = {1,1,1};
    theme.upTheme.text.offset = {-75,-2};
    theme.upTheme.text.align =  {'right', 'center'}
    theme.downTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.ttf';
    theme.downTheme.text.size = 19;
    theme.downTheme.text.lineSpacing = 0.65;
    theme.downTheme.text.color = {1,1,1};
    theme.downTheme.text.offset = {-75,-2};
    theme.downTheme.text.align =  {'right', 'center'}
    theme.hoverUpTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.ttf';
    theme.hoverUpTheme.text.size = 19;
    theme.hoverUpTheme.text.lineSpacing = 0.65;
    theme.hoverUpTheme.text.color = {1,1,1};
    theme.hoverUpTheme.text.offset = {-75,-2};
    theme.hoverUpTheme.text.align =  {'right', 'center'}

    return theme;
end;

function newMainMenuCentralButtonTheme()
    local pic = 'Keys-v1.png';
    local theme = newButtonTheme();
    theme.upTheme.image.align =  {'center', 'top'}
    theme.upTheme.image.file = getImage(pic)
    theme.upTheme.image.rect = {0,0,50,50}
    theme.upTheme.color = {1,0,1,0}
    theme.upTheme.border = newEmptyBorder()  
    theme.upTheme.image.offset = {0, 11}
    theme.downTheme.image.align =  {'center', 'top'}
    theme.downTheme.image.file = getImage(pic)
    theme.downTheme.image.rect = {150,0,50,50}
    theme.downTheme.color = {1,0,1,0}
    theme.downTheme.border = newEmptyBorder()  
    theme.downTheme.image.offset = {0, 11}
    theme.hoverUpTheme.image.align =  {'center', 'top'}
    theme.hoverUpTheme.image.file = getImage(pic)
    theme.hoverUpTheme.image.rect = {50,0,50,50}
    theme.hoverUpTheme.color = {1,0,1,0}
    theme.hoverUpTheme.border = newEmptyBorder()  
    theme.hoverUpTheme.image.offset = {0, 11}
    
    theme.upTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.ttf';
    theme.upTheme.text.size = 19;
    theme.upTheme.text.color = {1,1,1};
    theme.upTheme.text.offset = {0,-18};
    theme.upTheme.text.align =  {'center', 'bottom'}
    theme.downTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.ttf';
    theme.downTheme.text.size = 19;
    theme.downTheme.text.color = {1,1,1};
    theme.downTheme.text.offset = {0,-18};
    theme.downTheme.text.align =  {'center', 'bottom'}
    theme.hoverUpTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.ttf';
    theme.hoverUpTheme.text.size = 19;
    theme.hoverUpTheme.text.color = {1,1,1};
    theme.hoverUpTheme.text.offset = {0,-18};
    theme.hoverUpTheme.text.align =  {'center', 'bottom'}
    
    return theme;
end;

function newMainMenuTextTheme()
    local pic = 'main-font-1.png';
    local theme = newWidgetTheme();
    theme.image.align =  {'center', 'center'}
    theme.image.file = getImage(pic)
    theme.image.rect = {0,0,145,16}
    theme.color = {1,0,1,0}
    theme.border = newEmptyBorder()  
    theme.image.offset = {0, 0}

    return theme;
end;

function newMainMenuLogoTheme()
    local pic = 'logotypes-v1.png';
    local theme = newWidgetTheme();
    theme.image.align =  {'left', 'top'}
    theme.image.file = getImage(pic)
    theme.color = {1,0,1,0}
    theme.border = newEmptyBorder()  
    theme.image.offset = {0, 0}
    return theme;
end;


function newMenuBarLogoTheme()
    local theme = newWidgetTheme();
    --if base.__LOP__ then
    -- theme.image.file = getImage('Lockon-simple-logo.png')
    -- theme.image.rect = {12, 11, 234, 40}
    theme.image.file = getImage('editor-toolbar-background-logo.png')
    theme.image.rect = {0, 0, 512, 40}    
    theme.image.align = {'left', 'top'}
    return theme
end


function newMenuBarFillerTheme()
    local theme = newWidgetTheme();
    theme.image.file = getImage('editor-toolbar-background.png')
    theme.image.rect = {0, 0, 512, 40}
    theme.image.align = {'left', 'top'}
    return theme
end

function newUnitListGridCellTheme()
  local gridCellTheme = newWidgetTheme()
  gridCellTheme.text.color = text_ctrl()
  gridCellTheme.text.align = {'left', 'center'}
  gridCellTheme.text.font = text_ctrl_font
  gridCellTheme.text.size = text_ctrl_font_size
  gridCellTheme.image.align = {'center', 'center'}    
  return gridCellTheme
end



function newDialogTemplateTheme()
  local theme = newWidgetTheme()
  theme.titleHeight = 0
  theme.image.align =  {'center', 'center'}
  theme.image.file = getImage('briefing-map-background.png')
  theme.border = newEmptyBorder()  
  theme.color = {0,0,0}  
  return theme
end

function newDialogTemplate_TopRegionTheme()
  local theme = newWidgetTheme()
  theme.image.align =  {'center', 'center'}
  theme.image.file = getImage('background-details-1.png')
  theme.image.rect = {0,0,2048,40}
  theme.border = newEmptyBorder()  
  return theme
end

function newDialogTemplate_TopRegion_WidgetLogoTheme()
  local theme = newWidgetTheme()
  if base.__LOP__ then
    theme.image.align =  {'left', 'top'}
    theme.image.file = getImage('Lockon-simple-logo.png' )
  else
    theme.image.align =  {'left', 'center'}
    theme.image.file = getImage('logotypes-v1.png')
    theme.image.rect = {526,47,100,34}
  end;
  theme.border = newEmptyBorder()  
  return theme
end

function newDialogTemplate_TopRegion_CloseButtonTheme()
    local pic = 'Keys-v2.png';
    local theme = newButtonTheme();
    theme.upTheme.image.align =  {'center', 'center'}
    theme.upTheme.image.file = getImage(pic)
    theme.upTheme.image.rect = {0,0,20,20}
    theme.upTheme.color = {1,0,1,0}
    theme.upTheme.border = newEmptyBorder()  
    theme.downTheme.image.align =  {'center', 'center'}
    theme.downTheme.image.file = getImage(pic)
    theme.downTheme.image.rect = {20,0,20,20}
    theme.downTheme.color = {1,0,1,0}
    theme.downTheme.border = newEmptyBorder()  
    theme.hoverUpTheme.image.align =  {'center', 'center'}
    theme.hoverUpTheme.image.file = getImage(pic)
    theme.hoverUpTheme.image.rect = {20,0,20,20}
    theme.hoverUpTheme.color = {1,0,1,0}
    theme.hoverUpTheme.border = newEmptyBorder()  
    return theme;
end

function newDialogTemplate_TopRegion_TextTheme()
    local theme = newWidgetTheme()
    theme.text.font = fontsPath .. 'DejaVuLGCSans-BoldOblique.ttf';
    theme.text.size = 23;
    theme.text.color = {1, 1, 1, 1};
    theme.text.align = {'right', 'center'};
    theme.color = {1,0,1,0}
    return theme;
end

function newDialogTemplate_BottomRegionTheme()
  local theme = newWidgetTheme()
  theme.image.align =  {'center', 'center'}
  theme.image.file = getImage('background-details-1.png')
  theme.image.rect = {0,53,2048,76}
  theme.border = newEmptyBorder()  
  return theme
end

function newDialogTemplate_ContainerMainTheme()
  local theme = newWidgetTheme()
  theme.color = {0,0,1,0}
  theme.border = newEmptyBorder()  
  return theme
end


function newDialogTemplate_ContainerBottom_RightButtonTheme()
    local pic = 'LightKeys.png';
    local theme = newButtonTheme();
    theme.upTheme.image.align =  {'right', 'center'}
    theme.upTheme.image.file = getImage(pic)
    theme.upTheme.image.rect = {0,150,50,50}
    theme.upTheme.color = {1,0,1,0}
    theme.upTheme.border = newEmptyBorder()  
    theme.downTheme.image.align =  {'right', 'center'}
    theme.downTheme.image.file = getImage(pic)
    theme.downTheme.image.rect = {150,150,50,50}
    theme.downTheme.color = {1,0,1,0}
    theme.downTheme.border = newEmptyBorder()  
    theme.hoverUpTheme.image.align =  {'right', 'center'}
    theme.hoverUpTheme.image.file = getImage(pic)
    theme.hoverUpTheme.image.rect = {50,150,50,50}
    theme.hoverUpTheme.color = {1,0,1,0}
    theme.hoverUpTheme.border = newEmptyBorder()  
    
    theme.upTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    theme.upTheme.text.size = 18;
    theme.upTheme.text.color = {1,1,1};
    theme.upTheme.text.align =  {'left', 'center'}
    theme.downTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    theme.downTheme.text.size = 18;
    theme.downTheme.text.color = {1,1,1};
    theme.downTheme.text.align =  {'left', 'center'}
    theme.hoverUpTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    theme.hoverUpTheme.text.size = 18;
    theme.hoverUpTheme.text.color = {1,1,1};
    theme.hoverUpTheme.text.align =  {'left', 'center'}
    
    return theme;
end

function newDialogTemplate_ContainerBottom_LeftButtonTheme()
    local pic = 'Keys-v1.png';
    local theme = newButtonTheme();
    theme.upTheme.image.align =  {'left', 'center'}
    theme.upTheme.image.file = getImage(pic)
    theme.upTheme.image.rect = {0,150,50,50}
    theme.upTheme.color = {1,0,1,0}
    theme.upTheme.border = newEmptyBorder()  
    theme.downTheme.image.align =  {'left', 'center'}
    theme.downTheme.image.file = getImage(pic)
    theme.downTheme.image.rect = {150,150,50,50}
    theme.downTheme.color = {1,0,1,0}
    theme.downTheme.border = newEmptyBorder()  
    theme.hoverUpTheme.image.align =  {'left', 'center'}
    theme.hoverUpTheme.image.file = getImage(pic)
    theme.hoverUpTheme.image.rect = {50,150,50,50}
    theme.hoverUpTheme.color = {1,0,1,0}
    theme.hoverUpTheme.border = newEmptyBorder()  
    
    theme.upTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    theme.upTheme.text.size = 18;
    theme.upTheme.text.color = {1,1,1};
    theme.upTheme.text.align =  {'right', 'center'}
    theme.downTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    theme.downTheme.text.size = 18;
    theme.downTheme.text.color = {1,1,1};
    theme.downTheme.text.align =  {'right', 'center'}
    theme.hoverUpTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    theme.hoverUpTheme.text.size = 18;
    theme.hoverUpTheme.text.color = {1,1,1};
    theme.hoverUpTheme.text.align =  {'right', 'center'}
    return theme;
end

function newDialogTemplate_ContainerBottom_MiddleButtonTheme()
    local pic = 'LightKeys-v2.png';
    local theme = newButtonTheme();
    theme.upTheme.image.align =  {'center', 'center'}
    theme.upTheme.image.file = getImage(pic)
    theme.upTheme.image.rect = {0,80,60,20}
    theme.upTheme.color = {1,0,1,0}
    theme.upTheme.border = newEmptyBorder()  
    theme.downTheme.image.align =  {'center', 'center'}
    theme.downTheme.image.file = getImage(pic)
    theme.downTheme.image.rect = {0,100,60,20}
    theme.downTheme.color = {1,0,1,0}
    theme.downTheme.border = newEmptyBorder()  
    theme.hoverUpTheme.image.align =  {'center', 'center'}
    theme.hoverUpTheme.image.file = getImage(pic)
    theme.hoverUpTheme.image.rect = {0,80,60,20}
    theme.hoverUpTheme.color = {1,0,1,0}
    theme.hoverUpTheme.border = newEmptyBorder()  

    theme.upTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.ttf';
    theme.upTheme.text.size = 12;
    theme.upTheme.text.color = {180/255,180/255,180/255};
    theme.upTheme.text.align =  {'center', 'center'}
    theme.downTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.ttf';
    theme.downTheme.text.size = 12;
    theme.downTheme.text.color = {180/255,180/255,180/255};
    theme.downTheme.text.align =  {'center', 'center'}
    theme.hoverUpTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.ttf';
    theme.hoverUpTheme.text.size = 12;
    theme.hoverUpTheme.text.color = {180/255,180/255,180/255};
    theme.hoverUpTheme.text.align =  {'center', 'center'}
    return theme;
end

function newDialogTemplate_ContainerBottom_ButtonsTheme()
    return newAutoBriefing_ContainerMainTheme()
end;

function newCampaignDialogTheme()
  local theme = newDialogTemplateTheme()
  theme.image.file = getImage('campaign-window.png')
  return theme
end

function newSemiTransparentContainerTheme()
  local containerTheme = newContainerTheme()
  containerTheme.color = {0,0,0,0.5}
  return containerTheme
end

function newSemiTransparentBorderContainerTheme()
  local containerTheme = newContainerTheme()
  containerTheme.color = {0,0,0,0.1}
  containerTheme.border = newSimple1Border({1,0,0,1})
  return containerTheme
end

function newCampaignTextTheme()
  local theme = newWidgetTheme()
  theme.text.color = {0,0,0};
  theme.text.align = {'center', 'center'};
  theme.text.size = 20;
  theme.text.font = fontsPath .. 'vera.ttf'
  return theme;
end;

function newCampaignSelectCampaignTitleTheme()
  local theme = newCampaignTextTheme()
  theme.image.file = getImage('billets-1.png')
  theme.image.rect = {0, 0, 398, 42};
  theme.image.align = {'center', 'center'};
  theme.text.align = {'left', 'center'};
  theme.text.offset = {20,-3};
  theme.text.size = 29;  
  theme.text.font = fontsPath .. 'DejaVuLGCSans.ttf'
  return theme;
end;

function newCampaignDescriptionTitleTheme()
  local theme = newCampaignTextTheme()
  theme.image.file = getImage('billets-1.png')
  theme.image.rect = {0, 84, 238, 40};
  theme.image.align = {'center', 'center'};
  theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed-Bold.TTF'
  theme.text.color = {196/255,191/255,102/255};
  theme.text.size = 18;
  theme.text.offset = {0, -5};
  return theme;
end;

function newCampaignDescriptionScrollpaneTheme()
  local scrollPaneTheme = newWidgetTheme()
  scrollPaneTheme.border = newEmptyBorder()
  -- Тема для view
  scrollPaneTheme.viewTheme = newWidgetTheme()
  -- тема для горизонтального скроллбара
  scrollPaneTheme.hscrollTheme = newMEHScrollTheme()
  
  -- тема для вертикального скроллбара    
  scrollPaneTheme.vscrollTheme = newMEVScrollTheme()
  --setMEScrollThemeColor(scrollPaneTheme.vscrollTheme, {153/255,155/255,129/255}, {0,0,0,0.1})
  setMEScrollThemeColor(scrollPaneTheme.vscrollTheme, {0,0,0}, {0,0,0,0.1})
  return scrollPaneTheme
end;

function newCampaignMissionsTableTheme()
  local theme = newContainerTheme()
  theme.image.file = getImage('chart-1.png')
  theme.image.rect = {0, 0, 564, 372};
  theme.image.align = {'center', 'center'};
  
  local textTheme = newCampaignTextTheme();
  theme.text = textTheme.text;
  theme.text.align = {'right', 'top'};
  theme.text.color = {1,1,1,1};
  theme.text.offset = {-25, 11};
  theme.text.size = 18;
  theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed-Bold.TTF'
  return theme;
end;

function newCampaignPictureTheme()
  local theme = newWidgetTheme()
  theme.image.file = getImage('campaign-pic-1.png')
  theme.image.rect = {0, 0, 0, 0};
  theme.image.align = {'center', 'center'};
  return theme;
end;

function newCampaignDescriptionContainerTheme()
  local theme = newContainerTheme()
  theme.border = newSimple1Border()
  theme.border.color = {154/255,156/255, 130/255};
  return theme;
end;

function newCampaignTableTheme()
    local theme = newScrollGridTheme();
    theme.border = newEmptyBorder()
    theme.border.color = {};

    theme.headerTheme.color = {};
    theme.headerTheme.gridColor = {};
    theme.headerTheme.selColor = {};

    theme.gridTheme.color = {};    
    theme.gridTheme.gridColor = {};
    theme.gridTheme.selColor = {};

    return theme
end;

function newCampaignMissionGridColumnTheme()
  local gridColumnTheme = newGridColumnTheme()
  gridColumnTheme.text = newCampaignTextTheme().text;
  gridColumnTheme.text.color = {76/255, 77/255, 61/255}
  gridColumnTheme.text.align = {'left', 'center'}
  gridColumnTheme.text.offset = {15, 0};
  gridColumnTheme.text.size = 14;
  gridColumnTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF'
  --gridColumnTheme.image.align = {'center', 'center'}  
  
  return gridColumnTheme
end

-- Тема для заголовка ячейки в таблице
function newCampaignMissionGridCellTheme()
  local gridCellTheme = newGridCellTheme()
  gridCellTheme.text = newCampaignTextTheme().text;
  gridCellTheme.text.color = {148/255, 146/255, 120/255}
  gridCellTheme.text.align = {'left', 'center'}
  gridCellTheme.text.size = 18;
  gridCellTheme.text.offset = {15, 0};
--  gridCellTheme.image.align = {'left', 'center'}    
  gridCellTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF'
  return gridCellTheme
end

function newCampaignWidget1Theme()
  local widgetTheme = newWidgetTheme()
  widgetTheme.text = newCampaignTextTheme().text;
  widgetTheme.text.color = {148/255, 146/255, 120/255}
  widgetTheme.text.align = {'left', 'center'}
  widgetTheme.text.size = 18;
  widgetTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF'
  return widgetTheme
end


function newCampaignMissionGridSelectedCellTheme()
  local gridCellTheme = newCampaignMissionGridCellTheme()
  gridCellTheme.text.color = {1, 1, 1}
  return gridCellTheme
end


function newCampaignCampaignsListTheme()
    local theme = newScrollGridTheme();
    theme.border = newSimple1Border()
    theme.border.color = {0,0,0,1};
    theme.color = {0,0,0,0.2}
        

    theme.headerTheme.color = {154/255, 156/255, 130/255};
    theme.headerTheme.gridColor = {0,0,0};
    theme.headerTheme.selColor = {1,1,1};

    theme.gridTheme.color = {};    
    theme.gridTheme.gridColor = {};
    theme.gridTheme.selColor = {4/225,171/225,226/225};
    theme.gridTheme.vertLinesColor = {0, 0, 0}
    theme.gridTheme.horzLinesColor = {}

    setMEScrollThemeColor(theme.vscrollTheme, {0,0,0}, {0,0,0,0.3})
    return theme
end;

function nnewCampaignCampaignsListColumnTheme()
  local gridColumnTheme = newCampaignMissionGridColumnTheme()
  return gridColumnTheme;
end

-- Тема для ячейки в таблице
function newCampaignCampaignsListCellTheme()
  local gridCellTheme = newCampaignMissionGridCellTheme()
  gridCellTheme.text.color = {0,0,0}
  gridCellTheme.text.offset = {40, 0}
  gridCellTheme.border.color = {};
  gridCellTheme.image.file = getImage('icons-1.png')
  gridCellTheme.image.align = {'left', 'center'};
  gridCellTheme.image.rect = {0, 0, 32, 32};
  gridCellTheme.image.color = {0, 0, 0}
  return gridCellTheme
end

function newCampaignCampaignsListSelectedCellTheme()
  local gridCellTheme = newCampaignMissionGridCellTheme()
  gridCellTheme.text.color = {1,1,1}
  gridCellTheme.text.offset = {40, 0}
  gridCellTheme.border.color = {};
  gridCellTheme.image.file = getImage('icons-1.png')
  gridCellTheme.image.align = {'left', 'center'};
  gridCellTheme.image.rect = {0, 0, 32, 32};
  gridCellTheme.image.color = {1, 1, 1}
  return gridCellTheme
end

function newLogbookWidgetTheme()
    local theme = newWidgetTheme();
    theme.text.color = {0, 0, 0};
    theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    theme.text.size = 18;
    theme.text.align = {'center', 'center'};
    theme.text.offset = {0,-1};
    return theme
end;

function newLogbookWidget2Theme()
    local theme = newWidgetTheme();
    theme.text.color = {123/255, 125/255, 105/255};
    theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    theme.text.size = 14;
    theme.text.align = {'left', 'center'};
    theme.text.offset = {0,0};
    return theme
end;

function newLogbookCallsignEditTheme()
  local editBoxTheme = newEditBoxTheme();
  editBoxTheme.color = {}
  editBoxTheme.text.color = {0, 0, 0};
  editBoxTheme.text.align = {'center', 'center'}
  editBoxTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
  editBoxTheme.text.size = 18;
  editBoxTheme.text.offset = {0,-1};
  editBoxTheme.border = newEmptyBorder(); --newSimple1Border({123/255, 125/255, 105/255})
  editBoxTheme.caretTheme.color = {0,0,0};
  return editBoxTheme    
end;


function newLogbookWidgetValTheme()
    local theme = newWidgetTheme();
    theme.text.color = {0,0,0};
    theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    theme.text.size = 14;
    theme.text.align = {'center','center'};
    return theme
end;


function newLogbookTransparentWidgetTheme()
    local theme = newWidgetTheme();
    theme.text.color = {0, 0, 0};
    theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    theme.text.size = 14;
    theme.color = {};
    return theme
end;

function newLogbookButtonTheme()
    function newLogbookButtonState()
        local theme = newWidgetTheme();
        theme.color = {}
        theme.text.color = {153/255, 153/255, 153/255}
        theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
        theme.text.size = 18;
        theme.text.align = {'center', 'center'};        
        theme.border = {}
        return theme;
    end;
  local theme = newButtonTheme();
  
  theme.upTheme = newLogbookButtonState();
  theme.downTheme = newLogbookButtonState();
  theme.downTheme.text.offset = {1,1};
  theme.hoverUpTheme = newLogbookButtonState();
  theme.hoverDownTheme = newLogbookButtonState();
  theme.undefinedUpTheme = newLogbookButtonState();
  theme.undefinedDownTheme = newLogbookButtonState();
    return theme;
end;

function newLogbookMedalsScrollpaneTheme()
  local scrollPaneTheme = newWidgetTheme()
  scrollPaneTheme.border = newEmptyBorder()
  
  -- Тема для view
  scrollPaneTheme.viewTheme = newWidgetTheme()

  -- тема для горизонтального скроллбара
  scrollPaneTheme.hscrollTheme = newMEHScrollTheme()
  
  -- тема для вертикального скроллбара    
  scrollPaneTheme.vscrollTheme = newMEVScrollTheme()
    setMEScrollThemeColor(scrollPaneTheme.vscrollTheme, {178/255,178/255,178/255}, {0,0,0,0.3})
    setMEScrollThemeColor(scrollPaneTheme.hscrollTheme, {178/255,178/255,178/255}, {0,0,0,0.3})

  return scrollPaneTheme    
end; 

function newLogbookComboBoxTheme()
    function _newText()
        local text = newText();
        text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
        text.size = 18;
        text.align = {'center', 'center'};       
        text.color = {0,0,0,1}        
        return text;
    end;
  local comboBoxTheme = newWidgetTheme()
  comboBoxTheme.color = {}
  --comboBoxTheme.border = newDownBorder()
  comboBoxTheme.border = newSimple1Border({123/255, 125/255, 105/255});
  comboBoxTheme.text = _newText()
  comboBoxTheme.text.color = {}
  
  -- максимальная высота списка (далее внутри списка появляется скроллбар)
  comboBoxTheme.maxListHeight = 200
  
  -- тема для едитбокса
  comboBoxTheme.editBoxTheme = newEditBoxTheme()
  comboBoxTheme.editBoxTheme.color = {}
  comboBoxTheme.editBoxTheme.border = newEmptyBorder()
  --comboBoxTheme.editBoxTheme.border = newSimple1Border({123/255, 125/255, 105/255});
  comboBoxTheme.editBoxTheme.text = _newText()  
  comboBoxTheme.editBoxTheme.text.offset = {-5,-2}  
  comboBoxTheme.editBoxTheme.caretTheme.color = {0,0,0}

  -- Тема для кнопки
  comboBoxTheme.buttonTheme = newMEComboButtonTheme();
  comboBoxTheme.buttonTheme.color = {0,0,0};
  
  -- Тема для выпадающего списка
  comboBoxTheme.listBoxTheme = newListBoxTheme()
  comboBoxTheme.listBoxTheme.border = newSimple1Border(border_dark)
  comboBoxTheme.listBoxTheme.color = {190/255, 192/255, 175/255}
  comboBoxTheme.listBoxTheme.text = _newText()
  comboBoxTheme.listBoxTheme.viewTheme.text = _newText()
  comboBoxTheme.listBoxTheme.vscrollTheme = newMEVScrollTheme()
  comboBoxTheme.listBoxTheme.hscrollTheme = newMEHScrollTheme();
  comboBoxTheme.listBoxTheme.itemSize = 30
   
  return comboBoxTheme
end

function newLogbookComboBox2Theme()
    function _newText()
        local text = newText();
        text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
        text.size = 14;
        text.align = {'center', 'center'};       
        text.color = {0,0,0,1}        
        return text;
    end;
  local comboBoxTheme = newWidgetTheme()
  comboBoxTheme.color = {}
  comboBoxTheme.border = newEmptyBorder()
  comboBoxTheme.text = _newText()
  
  -- максимальная высота списка (далее внутри списка появляется скроллбар)
  comboBoxTheme.maxListHeight = 200
  
  -- тема для едитбокса
  comboBoxTheme.editBoxTheme = newEditBoxTheme()
  comboBoxTheme.editBoxTheme.color = {}
  comboBoxTheme.editBoxTheme.border = newEmptyBorder()
  comboBoxTheme.editBoxTheme.text = _newText()
  

  -- Тема для кнопки
  comboBoxTheme.buttonTheme = newMEComboButtonTheme();
  comboBoxTheme.buttonTheme.color = {0,0,0};
  
  
  -- Тема для выпадающего списка
  comboBoxTheme.listBoxTheme = newListBoxTheme()
  comboBoxTheme.listBoxTheme.border = newSimple1Border(border_dark)
  comboBoxTheme.listBoxTheme.color = {1, 1, 1}
  comboBoxTheme.listBoxTheme.text = _newText()
  comboBoxTheme.listBoxTheme.viewTheme.text = _newText()
  comboBoxTheme.text = {};
  comboBoxTheme.listBoxTheme.vscrollTheme = newMEVScrollTheme()
  comboBoxTheme.listBoxTheme.hscrollTheme = newMEHScrollTheme();

   
  return comboBoxTheme
end

function newLogbookComboBoxItemTheme()
    local theme = newComboBoxItemTheme();
    theme.normalTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    theme.normalTheme.text.align = {'center', 'center'};       
    theme.normalTheme.text.color = {0,0,0,1}        
    theme.normalTheme.text.offset = {-14, 0}
    theme.normalTheme.text.size = 18;
    theme.selectedTheme.text.size = 18;
    theme.selectedTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    theme.selectedTheme.text.align = {'center', 'center'};       
    theme.selectedTheme.text.color = {0,0,0,1}        
    theme.selectedTheme.text.offset = {-14, -0}
    return theme;
end;

function newLogbookComboBoxSquadronItemTheme()
    local theme = newComboBoxItemTheme();
    theme.normalTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    theme.normalTheme.text.align = {'left', 'center'};       
    theme.normalTheme.text.color = {0,0,0,1}        
    theme.normalTheme.text.size = 18;
    theme.selectedTheme.text.size = 18;
    theme.selectedTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    theme.selectedTheme.text.align = {'left', 'center'};       
    theme.selectedTheme.text.color = {0,0,0,1}        
    return theme;
end;

function newLogbookNationComboBoxItemTheme(rect)
    local theme = newLogbookComboBoxItemTheme();
    theme.normalTheme.image.file = base.mainPath.. 'data/images/countries/flags-1.png';
    theme.normalTheme.image.rect = rect;
    theme.normalTheme.image.offset = {0,0};
    theme.normalTheme.text.offset = {54, 0};
    theme.normalTheme.text.align = {'left', 'center'};
    theme.normalTheme.border = newEmptyBorder();
    theme.normalTheme.border.insets = {0,0,10,0};
    
    theme.selectedTheme.image.file = base.mainPath.. 'data/images/countries/flags-1.png';
    theme.selectedTheme.image.rect = rect;
    theme.selectedTheme.image.offset = {0,0};
    theme.selectedTheme.text.offset = {54, 0};
    theme.selectedTheme.text.align = {'left', 'center'};
    theme.selectedTheme.border = newEmptyBorder();
    theme.selectedTheme.border.insets = {0,0,10,0};
    
    return theme;
end;

function newLogbookComboBoxNationsTheme()
  local comboBoxTheme = newLogbookComboBoxTheme();
  comboBoxTheme.listBoxTheme.itemSize = 30;
  comboBoxTheme.maxListHeight = 500
  comboBoxTheme.editBoxTheme.text.align = {'left', 'center'}
  comboBoxTheme.text.offset = {54, -2}
  comboBoxTheme.editBoxTheme.text.offset = {54,-2}   
  comboBoxTheme.editBoxTheme.caretTheme.color = {}
  comboBoxTheme.editBoxTheme.selectionTheme.color = {}
  comboBoxTheme.listBoxTheme.vscrollTheme = newMEVScrollTheme()
  comboBoxTheme.buttonTheme = newMEComboButtonTheme();
  comboBoxTheme.buttonTheme.color = {0,0,0};
  
  return comboBoxTheme;
end

function newLogbookComboBoxSquadsTheme()
  local comboBoxTheme = newLogbookComboBoxTheme();
  comboBoxTheme.editBoxTheme.caretTheme.color = {}
  comboBoxTheme.editBoxTheme.selectionTheme.color = {}
  comboBoxTheme.editBoxTheme.text.align = {'left','center'}
  comboBoxTheme.editBoxTheme.text.offset = {4,-2}
  comboBoxTheme.listBoxTheme.vscrollTheme = newMEVScrollTheme()
  comboBoxTheme.buttonTheme = newMEComboButtonTheme();
  comboBoxTheme.buttonTheme.color = {0,0,0};
  comboBoxTheme.maxListHeight = 200
  
  return comboBoxTheme;
end

function newMissionDescriptionWidgetTheme()
  local widgetTheme = newWidgetTheme() 
  widgetTheme.text.align = {'left', 'top'}
  widgetTheme.text.color = {1,1,1}  
  widgetTheme.text.size = 14  
  widgetTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.ttf'

  return widgetTheme;
end;

function newMissionDescriptionScrollPaneTheme()
  
  local scrollPaneTheme = newWidgetTheme()
  scrollPaneTheme.border = newSimple1Border({154/255,156/255,130/255})
  scrollPaneTheme.color = {0, 0, 0, 0.2}
  
  -- Тема для view
  scrollPaneTheme.viewTheme = newWidgetTheme()
  scrollPaneTheme.viewTheme.color = {0, 0, 0, 0.2}

  -- тема для горизонтального скроллбара
  scrollPaneTheme.hscrollTheme = newMEHScrollTheme()
  
  -- тема для вертикального скроллбара    
  scrollPaneTheme.vscrollTheme = newMEVScrollTheme()

  return scrollPaneTheme
end   

function newMissionDriveComboBoxTheme()
  local comboBoxTheme = newComboBoxTheme()
  comboBoxTheme.color = {1,1,1}
  comboBoxTheme.editBoxTheme.color = {1,1,1}
  comboBoxTheme.editBoxTheme.image.offset = {4, 0}
  comboBoxTheme.editBoxTheme.image.align = {'left', 'center'}
  comboBoxTheme.editBoxTheme.image.file = getImage('Keys-v2.png')
  comboBoxTheme.editBoxTheme.image.rect = {0,40,20,20}
  comboBoxTheme.editBoxTheme.text.offset = {30, -2}
  
    comboBoxTheme.editBoxTheme.text.font = fontsPath .. 'DejaVuLGCSans.ttf'
    comboBoxTheme.editBoxTheme.text.size = 15;
    comboBoxTheme.editBoxTheme.text.color = {0,0,0};
    comboBoxTheme.editBoxTheme.text.offset = {30,0 -2};
    comboBoxTheme.vscrollTheme = newVScrollTheme();
  comboBoxTheme.buttonTheme = newMEComboButtonTheme();
  comboBoxTheme.buttonTheme.color = {0,0,0};
  
  
  return comboBoxTheme
end

function newMissionFileTypeComboBoxTheme()
  local comboBoxTheme = newComboBoxTheme()
  comboBoxTheme.color = {1,1,1}
  comboBoxTheme.editBoxTheme.color = {1,1,1}
  comboBoxTheme.editBoxTheme.text.font = fontsPath .. 'DejaVuLGCSans.ttf'
  comboBoxTheme.editBoxTheme.text.size = 15;
  comboBoxTheme.vscrollTheme = newVScrollTheme()
  comboBoxTheme.buttonTheme = newMEComboButtonTheme();
  comboBoxTheme.buttonTheme.color = {0,0,0};
  return comboBoxTheme;
end

function newMissionListBoxTheme()
  local listBoxTheme = newListBoxTheme()
  listBoxTheme.color = {0,0,0,0.2}
  listBoxTheme.itemSize = 23
  listBoxTheme.vscrollTheme = newMEVScrollTheme()
  listBoxTheme.hscrollTheme = newMEHScrollTheme()
  return listBoxTheme
end  

function newMissionListBoxFileItemTheme()
  local listBoxFolderItemTheme = newListBoxFolderItemTheme()
  listBoxFolderItemTheme.normalTheme.image.file = getImage('icons-1.png')
  listBoxFolderItemTheme.normalTheme.color = {}
  listBoxFolderItemTheme.normalTheme.image.rect = {0, 0, 32, 32}
  listBoxFolderItemTheme.normalTheme.image.color = {154/255,156/255,130/255}
  listBoxFolderItemTheme.normalTheme.image.w = 32
  listBoxFolderItemTheme.normalTheme.image.h = 32
  listBoxFolderItemTheme.normalTheme.text.offset = {4 + 32 + 4, -2}
  listBoxFolderItemTheme.normalTheme.text.color = {154/255,156/255,130/255}
  listBoxFolderItemTheme.normalTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.ttf'
  listBoxFolderItemTheme.normalTheme.text.size = 18;
  
  listBoxFolderItemTheme.selectedTheme.image.file = getImage('icons-1.png')
  listBoxFolderItemTheme.selectedTheme.color = {4/255,171/225,226/225}
  listBoxFolderItemTheme.selectedTheme.image.rect = {0, 0, 32, 32}
  listBoxFolderItemTheme.selectedTheme.image.w = 32;
  listBoxFolderItemTheme.selectedTheme.image.h = 32;
  listBoxFolderItemTheme.selectedTheme.text.offset = {4 + 32 + 4, -2}
  listBoxFolderItemTheme.selectedTheme.text.color = {1,1,1}
  listBoxFolderItemTheme.selectedTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.ttf'
  listBoxFolderItemTheme.selectedTheme.text.size = 18;

  return listBoxFolderItemTheme
end

function newMissionListBoxFolderItemTheme()
  local listBoxFolderItemTheme = newListBoxFolderItemTheme()
  listBoxFolderItemTheme.normalTheme.image.file = getImage('Keys-v2.png')
  listBoxFolderItemTheme.normalTheme.color = {}
  listBoxFolderItemTheme.normalTheme.image.rect = {0, 20, 20, 20}
  listBoxFolderItemTheme.normalTheme.image.w = 20
  listBoxFolderItemTheme.normalTheme.image.h = 20
  listBoxFolderItemTheme.normalTheme.image.offset = {10,0};
  listBoxFolderItemTheme.normalTheme.text.offset = {4 + 32 + 4, -2}
  listBoxFolderItemTheme.normalTheme.text.color = {154/255,156/255,130/255}
  listBoxFolderItemTheme.normalTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.ttf'
  --listBoxFolderItemTheme.normalTheme.text.font = fontsPath .. 'cour.ttf'
  listBoxFolderItemTheme.normalTheme.text.size = 18;
  
  listBoxFolderItemTheme.selectedTheme.image.file = getImage('Keys-v2.png')
  listBoxFolderItemTheme.selectedTheme.color = {4/255,171/225,226/225}
  listBoxFolderItemTheme.selectedTheme.image.rect = {0, 20, 20, 20}  
  listBoxFolderItemTheme.selectedTheme.image.w = 20;
  listBoxFolderItemTheme.selectedTheme.image.h = 20;
  listBoxFolderItemTheme.selectedTheme.image.offset = {10,0};
  listBoxFolderItemTheme.selectedTheme.text.offset = {4 + 32 + 4, -2}
  listBoxFolderItemTheme.selectedTheme.text.color = {1,1,1}
  listBoxFolderItemTheme.selectedTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.ttf'
  --listBoxFolderItemTheme.selectedTheme.text.font = fontsPath .. 'cour.ttf'
  listBoxFolderItemTheme.selectedTheme.text.size = 18;

  return listBoxFolderItemTheme
end

function newMissionComboBoxItemTheme()
  local theme = newComboBoxItemTheme();
 
  theme.normalTheme.text.font = fontsPath .. 'DejaVuLGCSans.ttf'
  theme.normalTheme.text.size = 15;
  theme.normalTheme.text.color = {0,0,0};
  theme.normalTheme.color = {1,1,1}
  theme.selectedTheme.text.font = fontsPath .. 'DejaVuLGCSans.ttf'
  theme.selectedTheme.text.size = 15;
  theme.selectedTheme.text.color = {0,0,0};
--  theme.selectedTheme.color = {1,1,1}
  
  
  return theme;
end

function newMissionDriveComboBoxItemTheme()
  local theme = newComboBoxItemTheme();
 
  theme.normalTheme.text.font = fontsPath .. 'DejaVuLGCSans.ttf'
  theme.normalTheme.text.size = 15;
  theme.normalTheme.text.color = {0,0,0};
  theme.normalTheme.text.offset = {30, -2};
  theme.normalTheme.color = {1,1,1}
  theme.selectedTheme.text.font = fontsPath .. 'DejaVuLGCSans.ttf'
  theme.selectedTheme.text.size = 15;
  theme.selectedTheme.text.color = {0,0,0};
  theme.selectedTheme.text.offset = {30, -2};

  theme.normalTheme.image.offset = {4, 0}
  theme.normalTheme.image.align = {'left', 'center'}
  theme.normalTheme.image.file = getImage('Keys-v2.png')
  theme.normalTheme.image.rect = {0,40,20,20}
  
  theme.selectedTheme.image.offset = {4, 0}
  theme.selectedTheme.image.align = {'left', 'center'}
  theme.selectedTheme.image.file = getImage('Keys-v2.png')
  theme.selectedTheme.image.rect = {0,40,20,20}
  
  
  return theme;
end

function newCampaignEditorWidget1Theme()
    local theme = newWidgetTheme()
    theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed-Bold.ttf'
    theme.text.size = 18
    theme.text.color = {194/255, 194/255, 94/255}
    return theme;
end;

function newCampaignEditorWidget2Theme()
    local theme = newWidgetTheme();
    theme.text.color = {123/255, 125/255, 105/255};
    theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    theme.text.size = 14;
    return theme
end;

function newCampaignEditorWidget3Theme()
    local theme = newWidgetTheme();
    theme.text.color = {0, 0, 0};
    theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    theme.text.size = 14;
    theme.text.align = {'left', 'top'};
    return theme
end;

function newCampaignEditorWidget4Theme()
    local theme = newWidgetTheme();
    theme.text.color = {0, 0, 0};
    theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    theme.text.size = 14;
    theme.text.align = {'center', 'center'};
    return theme
end;

function newCampaignEditorWidget5Theme()
    local theme = newCampaignEditorWidget2Theme();
    theme.text.align = {'right', 'center'};
    return theme
end;

function newCampaignEditorContainerTheme()
    local theme = newContainerTheme()
    --theme.image.file = "c:/LockOn/LockOnExe/New GUI/Alternative/cmped_crop.jpg" 
    return theme;
end;

function newCampaignEditorButtonTheme()
    function newCampaignEditorButtonState()
        local theme = newWidgetTheme();
        theme.color = {}
        theme.text.color = {124/255,125/255,109/255,1}
        theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
        theme.text.size = 16;
        theme.text.align = {'center', 'center'};        
        theme.border = newSimple1Border();
        theme.border.color = {124/255,125/255,109/255,1} 
        return theme;
    end;
    
    local theme = newButtonTheme();

    theme.upTheme = newCampaignEditorButtonState();
    theme.downTheme = newCampaignEditorButtonState();
    theme.downTheme.text.offset = {1,1};
    theme.hoverUpTheme = newCampaignEditorButtonState();
    theme.hoverDownTheme = newCampaignEditorButtonState();
    theme.undefinedUpTheme = newCampaignEditorButtonState();
    theme.undefinedDownTheme = newCampaignEditorButtonState();
    return theme;
end;

function newCampaignEditorButtonPicTheme()
    local theme = newButtonTheme();

    theme.upTheme.image.file = getImage('campaign-pic-1.png');
    theme.downTheme.image.file = getImage('campaign-pic-1.png');
    theme.downTheme.text.offset = {1,1};
    theme.downTheme.image.offset = {1,1};
    theme.hoverUpTheme.image.file = getImage('campaign-pic-1.png');
    theme.hoverDownTheme.image.file = getImage('campaign-pic-1.png');
    theme.undefinedUpTheme.image.file = getImage('campaign-pic-1.png');
    theme.undefinedDownTheme.image.file = getImage('campaign-pic-1.png');
    return theme;
end;

function newCampaignEditorComboBoxTheme()
    function _newText()
        local text = newText();
        text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
        text.size = 18;
        text.align = {'center', 'center'};       
        text.color = {0,0,0,1}        
        return text;
    end;
  local comboBoxTheme = newWidgetTheme()
  comboBoxTheme.color = {}
  comboBoxTheme.border = newDownBorder()
  comboBoxTheme.text = _newText()
  comboBoxTheme.text.color = {}
  
  -- максимальная высота списка (далее внутри списка появляется скроллбар)
  comboBoxTheme.maxListHeight = 200
  
  -- тема для едитбокса
  comboBoxTheme.editBoxTheme = newEditBoxTheme()
  comboBoxTheme.editBoxTheme.color = {}
  comboBoxTheme.editBoxTheme.border = newEmptyBorder()
  comboBoxTheme.editBoxTheme.text = _newText()

  

  -- Тема для кнопки
  comboBoxTheme.buttonTheme = newMEComboButtonTheme()
  comboBoxTheme.buttonTheme.color = {0,0,0}
  
  -- Тема для выпадающего списка
  comboBoxTheme.listBoxTheme = newListBoxTheme()
  comboBoxTheme.listBoxTheme.border = newSimple1Border(border_dark)
  comboBoxTheme.listBoxTheme.color = {190/255, 192/255, 175/255}
  comboBoxTheme.listBoxTheme.text = _newText()
  comboBoxTheme.listBoxTheme.viewTheme.text = _newText()
  comboBoxTheme.listBoxTheme.vscrollTheme = newMEVScrollTheme();
  comboBoxTheme.listBoxTheme.hscrollTheme = newMEHScrollTheme();
  return comboBoxTheme
end

function newCampaignEditorTransparentWidgetTheme()
    local theme = newWidgetTheme();
    theme.text.color = {0, 0, 0};
    theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    theme.text.size = 18;
    theme.text.align = {'center','center'};
    theme.color = {};
    return theme
end;

function newCampaignEditorEditBoxTheme()
  local editBoxTheme = newWidgetTheme()
  editBoxTheme.color = {0, 0, 0, 0};
  editBoxTheme.text.color = {0, 0, 0};
  editBoxTheme.text.align = {'center','center'};
  editBoxTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
  editBoxTheme.text.size =  18;
  editBoxTheme.border = newEmptyBorder()
  
  -- Тема для курсора
  editBoxTheme.caretTheme = newWidgetTheme()
  editBoxTheme.caretTheme.color = {0, 0, 0};
  
  -- Тема для выделения текста
  editBoxTheme.selectionTheme = newWidgetTheme()
  editBoxTheme.selectionTheme.color = {95/255, 105/255, 90/255, 0.5}
  
  return editBoxTheme
end 

function newCampaignEditorWindowTheme()
  local windowTheme = newWindowTheme()
    windowTheme.image.file = getImage('campaign-editor-window.png')
  return windowTheme
end


function newCampaignEditorStagesGridTheme()
    local theme = newScrollGridTheme();
    theme.border = newEmptyBorder()
    theme.border.color = {0,0,0,0};
    theme.color = {0,0,0,0}

    theme.headerTheme.color ={0,0,0,0};
    theme.headerTheme.gridColor = {0,0,0,0};
    theme.headerTheme.selColor = {0,0,0,0};
    theme.headerTheme.border.color = {0,0,1,1};    
    theme.headerTheme.vertLinesColor = {}
    theme.headerTheme.horzLinesColor = {}

    theme.gridTheme.color = {0,0,0,0};    
    theme.gridTheme.gridColor = {0,0,0,0};
    theme.gridTheme.selColor = {4/225,171/225,226/225,0.5};
    theme.gridTheme.border.color = {0,1,1,1};
    theme.gridTheme.vertLinesColor = {}
    theme.gridTheme.horzLinesColor = {}
    
    theme.vscrollTheme = newMEVScrollTheme();
    theme.hscrollTheme = newMEHScrollTheme();

    return theme
end;

function newCampaignEditorStagesGridColumnTheme()
  local gridColumnTheme = newGridColumnTheme()
  gridColumnTheme.text = newCampaignTextTheme().text;
  gridColumnTheme.text.color = {76/255, 77/255, 61/255}
  gridColumnTheme.text.align = {'left', 'center'}
  gridColumnTheme.text.size = 14;
  gridColumnTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF'
  --gridColumnTheme.image.align = {'center', 'center'}  
  gridColumnTheme.color = {0,0,0,0}
  
  return gridColumnTheme
end


-- Тема для ячейки в таблице
function newCampaignEditorStagesGridCellTheme()
  local gridCellTheme = newGridCellTheme()
  gridCellTheme.text = newCampaignTextTheme().text;
  gridCellTheme.text.align = {'left', 'center'}
  gridCellTheme.text.size = 18;
  gridCellTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF'
  gridCellTheme.text.color = {0,0,0}
  gridCellTheme.border.color = {0,0,0};
  return gridCellTheme
end

function newCampaignEditorStagesGridSelectedCellTheme()
  local gridCellTheme = newCampaignEditorStagesGridCellTheme()
  gridCellTheme.text.color = {1,1,1}
  return gridCellTheme
end

function newCampaignEditorCampaignDescriptionMEditBoxTheme()
  local meditBoxTheme = newCampaignEditorWidget3Theme()
  meditBoxTheme.color = {0, 0, 0, 0}
  --meditBoxTheme.text.align = {'left', 'center'}
  meditBoxTheme.text.offset = {20, 20}
  meditBoxTheme.border = newEmptyBorder()
  
  -- Тема для view
  meditBoxTheme.viewTheme = newCampaignEditorWidget3Theme()
  --meditBoxTheme.viewTheme.color = {1, 0, 0}
  meditBoxTheme.viewTheme.text.align = {'left', 'center'}
  meditBoxTheme.viewTheme.text.offset = {20, 20}
  --meditBoxTheme.viewTheme.text.font = fontsPath .. 'courier.ttf'

  -- тема для вертикального скроллбара    
  meditBoxTheme.vscrollTheme = newMEVScrollTheme()
  
  -- Тема для выделения текста
  meditBoxTheme.selectionTheme = newWidgetTheme()
  meditBoxTheme.selectionTheme.color = {0.5, 0.5, 0.5, 0.5}
  meditBoxTheme.selectionTheme.caretColor = {0, 0, 0, 1}  
  meditBoxTheme.selectionTheme.caretSize = 2 

  return meditBoxTheme
end

function newCampaignEditorMissionDescriptionScrollpaneTheme()
  local scrollPaneTheme = newWidgetTheme()
  scrollPaneTheme.border = newSimple1Border({0, 0, 0})
  
  -- Тема для view
  scrollPaneTheme.viewTheme = newWidgetTheme()

  -- тема для горизонтального скроллбара
  scrollPaneTheme.hscrollTheme = newMEHScrollTheme()
  
  -- тема для вертикального скроллбара    
  scrollPaneTheme.vscrollTheme = newMEVScrollTheme()

  return scrollPaneTheme
end;

function newTrainingTasksListboxTheme()
  local listBoxTheme = newWidgetTheme()
  listBoxTheme.color = {0,0,0,0}
  listBoxTheme.border = newEmptyBorder()
  
  -- Тема для view
  listBoxTheme.viewTheme = newWidgetTheme()
      
  -- тема для горизонтального скроллбара
  listBoxTheme.hscrollTheme = newMEHScrollTheme()

  -- тема для вертикального скроллбара    
  listBoxTheme.vscrollTheme = newMEVScrollTheme()
    
  -- Высота элементов списка
  listBoxTheme.itemSize = 41
  
  return listBoxTheme
end;

function newTrainingTasksListBoxItemTheme()
  -- Тема для нормального состояния
  local normalTheme = newWidgetTheme()
  normalTheme.color = {}
  normalTheme.text.color = {196/255, 197/255, 183/255}
  normalTheme.text.offset = {15, 0} -- отступ от края + ширина картинки + отступ от картинки
  normalTheme.text.align = {'left', 'center'}
  normalTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.ttf';
  normalTheme.text.size = 15
  
  -- Тема для активного состояния
  local selectedTheme = newWidgetTheme()
  selectedTheme.color = {}
  selectedTheme.text.color = {1,1,1}
  selectedTheme.text.offset = {15, 0} -- отступ от края + ширина картинки + отступ от картинки
  selectedTheme.text.align = {'left', 'center'}
  selectedTheme.text.font =fontsPath .. 'DejaVuLGCSansCondensed.ttf';
  selectedTheme.text.size = 15

  local listBoxItemTheme = {}
  listBoxItemTheme.normalTheme = normalTheme
  listBoxItemTheme.selectedTheme = selectedTheme
  
  return listBoxItemTheme
end 

function newTrainingTasksContainerTheme()
  local theme = newContainerTheme()
  theme.image.file = getImage('chart-1.png')
  theme.image.rect = {0, 0, 564, 372};
  --theme.image.color = {1, 1, 1, 0};
  theme.image.align = {'center', 'center'};
  
  local textTheme = newCampaignTextTheme();
  theme.text = textTheme.text;
  theme.text.align = {'right', 'top'};
  theme.text.color = {1,1,1,1};
  theme.text.offset = {-35, 15};
  theme.text.size = 19;
  theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF'
  return theme;
end;

function newTrainingLOPTasksContainerTheme()
  local theme = newContainerTheme()
  theme.image.file = getImage('chart-4.png')
  theme.image.rect = {0, 0, 564, 372};
  --theme.image.color = {1, 1, 1, 0};
  theme.image.align = {'center', 'center'};
  
  local textTheme = newCampaignTextTheme();
  theme.text = textTheme.text;
  theme.text.align = {'left', 'top'};
  theme.text.color = {1,1,1,1};
  theme.text.offset = {-35, 15};
  theme.text.size = 19;
  theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF'
  return theme;
end;

function newTrainingLessonsContainerTheme()
  local theme = newContainerTheme()
  theme.image.file = getImage('chart-2.png')
  theme.image.rect = {0, 0, 401, 580};
  --theme.image.color = {1, 1, 1, 0};
  theme.image.align = {'left', 'top'};
  
  local textTheme = newCampaignTextTheme();
  theme.text = textTheme.text;
  theme.text.align = {'right', 'top'};
  theme.text.color = {1,1,1,1};
  theme.text.offset = {-35, 15};
  theme.text.size = 19;
  theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF'
  return theme;
end;

function newTrainingWidget1Theme()
    local theme = newWidgetTheme()
    theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed-Bold.ttf'
    theme.text.size = 18
    theme.text.color = {194/255, 194/255, 94/255}
    return theme;
end;


function newTrainingWidget2Theme()
    local theme = newWidgetTheme()
    theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed-Bold.ttf'
    theme.text.size = 18
    theme.text.color = {1, 1, 1}
    return theme;
end;

function newTrainingWidget3Theme()
    local theme = newWidgetTheme();
    theme.text.color = {0, 0, 0};
    theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    theme.text.size = 14;
    theme.text.align = {'left', 'top'};
    return theme
end;

function newTrainingWidget4Theme()
    local theme = newWidgetTheme();
    theme.image.file = getImage('DCS-pilot.png');
    --theme.image.rect = {60, 80, 137, 359};
    theme.image.align = {'left','top'};
    return theme
end;

function newTrainingDescriptionScrollpane()
  local scrollPaneTheme = newWidgetTheme()
  scrollPaneTheme.border = newSimple1Border({0, 0, 0})
  
  -- Тема для view
  scrollPaneTheme.viewTheme = newWidgetTheme()

  -- тема для горизонтального скроллбара
  scrollPaneTheme.hscrollTheme = newMEHScrollTheme()
  
  -- тема для вертикального скроллбара    
  scrollPaneTheme.vscrollTheme = newMEVScrollTheme()

  return scrollPaneTheme

end;

function newTrainingLessonsListboxTheme()
  local listBoxTheme = newWidgetTheme()
  listBoxTheme.color = {0,0,0,0}
  listBoxTheme.border = newEmptyBorder()
  
  -- Тема для view
  listBoxTheme.viewTheme = newWidgetTheme()
      
  -- тема для горизонтального скроллбара
  listBoxTheme.hscrollTheme = newMEHScrollTheme()

  -- тема для вертикального скроллбара    
  listBoxTheme.vscrollTheme = newMEVScrollTheme()
    
  -- Высота элементов списка
  listBoxTheme.itemSize = 41
  
  return listBoxTheme
end;

function newTrainingLessonsListboxItemTheme()
  -- Тема для нормального состояния
  local normalTheme = newWidgetTheme()
  normalTheme.color = {}
  normalTheme.text.color = {0, 0, 0}
  normalTheme.text.offset = {20, 0} -- отступ от края + ширина картинки + отступ от картинки
  normalTheme.text.align = {'left', 'center'}
  normalTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.ttf';
  normalTheme.text.size = 15
  
  -- Тема для активного состояния
  local selectedTheme = newWidgetTheme()
  selectedTheme.color = {196/255, 191/255, 102/255}
  selectedTheme.text.color = {1,1,1}
  selectedTheme.text.offset = {20, 0} -- отступ от края + ширина картинки + отступ от картинки
  selectedTheme.text.align = {'left', 'center'}
  selectedTheme.text.font =fontsPath .. 'DejaVuLGCSansCondensed.ttf';
  selectedTheme.text.size = 15

  local listBoxItemTheme = {}
  listBoxItemTheme.normalTheme = normalTheme
  listBoxItemTheme.selectedTheme = selectedTheme
  
  return listBoxItemTheme
end 


function newEncyclopediaContainerDetailsTheme()
    local theme = newContainerTheme()
    theme.image.file = getImage('gradient1.png');
    theme.image.color = {};
    theme.image.align = {'stretch', 'stretch'};
    theme.image.offset = {0, 0};
    theme.image.rect = {1.5, 3, 2.5, 4};
    theme.image.w = 260;
    theme.image.h = 568;
    return theme;
end;

function newEncyclopediaContainerControlsTheme()
    local theme = newContainerTheme()
    theme.color = {0, 0, 0};
    return theme;
end;

function newEncyclopediaContainer2Theme()
    local theme = newContainerTheme()
    theme.border = newSimple1Border({196/255, 191/255, 102/255});
    return theme;
end;

function newEncyclopediaRadioButtonFaceTheme()   
  local theme = newWidgetTheme()
  theme.color = {}
  theme.text.color = {0,0,0}
  theme.text.offset = {0, 0}
  theme.text.align = {'center', 'center'}
  theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.ttf';
  theme.text.size = 14
  theme.image.align = {'center', 'center'}
  theme.image.file = getImage('billets-1.png')
  theme.image.rect = {406, 2, 103, 27}
  theme.image.w = 103;
  theme.image.h = 27;
  theme.border = newEmptyBorder()
  return theme
end

function newEncyclopediaRadioButtonTheme()
  local upTheme = newEncyclopediaRadioButtonFaceTheme()
  upTheme.image.color = {145/255, 145/255, 145/255};
  
  local downTheme = newEncyclopediaRadioButtonFaceTheme()
  downTheme.image.color = {196/255, 191/255, 102/255};
  
  local hoverUpTheme = newEncyclopediaRadioButtonFaceTheme()
  hoverUpTheme.image.color = {145/255, 145/255, 145/255};
  
  local hoverDownTheme = newEncyclopediaRadioButtonFaceTheme()
  hoverDownTheme.image.color = {196/255, 191/255, 102/255};
  
  local undefinedUpTheme = newEncyclopediaRadioButtonFaceTheme()
  undefinedUpTheme.image.color = {145/255, 145/255, 145/255};
  
  local undefinedDownTheme = newEncyclopediaRadioButtonFaceTheme()
  undefinedDownTheme.image.color = {196/255, 191/255, 102/255};
  
  return {
    upTheme = upTheme,
    downTheme = downTheme,
    hoverUpTheme = hoverUpTheme,
    hoverDownTheme = hoverDownTheme,
    undefinedUpTheme = undefinedUpTheme,
    undefinedDownTheme = undefinedDownTheme
  }
end  

function newEncyclopediaComboBoxTheme()
  -- local comboBoxTheme = newComboBoxTheme()
  -- comboBoxTheme.color = {1,1,1}
  -- comboBoxTheme.editBoxTheme.color = {1,1,1}
  -- comboBoxTheme.editBoxTheme.text.font = fontsPath .. 'DejaVuLGCSans.ttf'
  -- comboBoxTheme.editBoxTheme.text.size = 15;
  -- return comboBoxTheme;
  
    function _newText()
        local text = newText();
        text.font = fontsPath .. 'DejaVuLGCSans.ttf'
        text.size = 15;
        text.align = {'left', 'center'};       
        text.color = {0,0,0}        
        return text;
    end;
  local comboBoxTheme = newWidgetTheme()
  comboBoxTheme.color = {1,1,1}
  comboBoxTheme.border = newDownBorder()
  comboBoxTheme.text = _newText()
  comboBoxTheme.text.color = {}
  
  -- максимальная высота списка (далее внутри списка появляется скроллбар)
  comboBoxTheme.maxListHeight = 200
  
  -- тема для едитбокса
  comboBoxTheme.editBoxTheme = newEditBoxTheme()
  comboBoxTheme.editBoxTheme.color = {1,1,1}
  comboBoxTheme.editBoxTheme.border = newEmptyBorder()
  comboBoxTheme.editBoxTheme.text = _newText()
  comboBoxTheme.editBoxTheme.text.font = fontsPath .. 'DejaVuLGCSans.ttf'
  comboBoxTheme.editBoxTheme.text.size = 15;
  comboBoxTheme.editBoxTheme.text.offset = {4, 0} -- отступ от края

  

  -- Тема для кнопки
  comboBoxTheme.buttonTheme = newMEComboButtonTheme()
  comboBoxTheme.buttonTheme.color = {1,0,0}
  
  -- Тема для выпадающего списка
  comboBoxTheme.listBoxTheme = newListBoxTheme()
  comboBoxTheme.listBoxTheme.border = newSimple1Border(border_dark)
  comboBoxTheme.listBoxTheme.color = {1,1,1}
  comboBoxTheme.listBoxTheme.text = _newText()
  comboBoxTheme.listBoxTheme.viewTheme.text = _newText()
  comboBoxTheme.listBoxTheme.vscrollTheme = newMEVScrollTheme();
  comboBoxTheme.listBoxTheme.hscrollTheme = newMEHScrollTheme();
  return comboBoxTheme  
end

function newEncyclopediaComboBoxItemTheme()
  -- Тема для элемента в неактивном состоянии
  local normalTheme = newWidgetTheme()
  normalTheme.color = {}
  normalTheme.text.color = {0,0,0}
  normalTheme.text.offset = {4, 0} -- отступ от края
  normalTheme.text.align = {'left', 'center'}
  normalTheme.text.font = fontsPath .. 'DejaVuLGCSans.ttf'
  normalTheme.text.size = 15
  normalTheme.image.offset = {4, 0}
  normalTheme.image.align = {'left', 'center'}
  
  -- Тема для элемента в активном состоянии
  local selectedTheme = newWidgetTheme()
  selectedTheme.color = list_select_color()
  selectedTheme.text.color = {0,0,0}
  selectedTheme.text.offset = {4, 0} -- отступ от края
  selectedTheme.text.align = {'left', 'center'}
  selectedTheme.text.font = fontsPath .. 'DejaVuLGCSans.ttf'
  selectedTheme.text.size = 15
  selectedTheme.image.offset = {4, 0}
  selectedTheme.image.align = {'left', 'center'}    
  
  local comboBoxItemTheme = {}
  comboBoxItemTheme.normalTheme = normalTheme
  comboBoxItemTheme.selectedTheme = selectedTheme
  
  return comboBoxItemTheme
end


function newEncyclopediaWidgetTheme()
    local theme = newWidgetTheme();
    theme.text.color = {120/255, 124/255, 99/255};
    theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.ttf';
    theme.text.size = 16;
    theme.text.align = {'center', 'center'};    
    return theme
end;

function newEncyclopediaButton1Theme()
    function buttonTheme(x,y)
      local upTheme = newWidgetTheme()
      upTheme.color = {};
      upTheme.border = newEmptyBorder()
      upTheme.image.file = getImage('Keys-v2.png');
      upTheme.image.rect = {x,y,21,21};
      upTheme.image.w = 21;
      upTheme.image.h = 21;
      upTheme.image.align = {'right', 'center'};
      return upTheme
    end;
   
   local theme  = {
    upTheme = buttonTheme(0,78),
    downTheme = buttonTheme(42,78),
    hoverUpTheme = buttonTheme(21,78),
    hoverDownTheme = buttonTheme(0,78),
    undefinedUpTheme = buttonTheme(0,78),
    undefinedDownTheme = buttonTheme(0,78),
  }  
  return theme;
end

function newEncyclopediaButton2Theme()
    function buttonTheme(x,y)
      local upTheme = newWidgetTheme()
      upTheme.color = {};
      upTheme.border = newEmptyBorder()
      upTheme.image.file = getImage('Keys-v2.png');
      upTheme.image.rect = {x,y,21,21};
      upTheme.image.w = 21;
      upTheme.image.h = 21;
      upTheme.image.align = {'left', 'center'};
      return upTheme
    end;
   
   local theme  = {
    upTheme = buttonTheme(0,58),
    downTheme = buttonTheme(42,58),
    hoverUpTheme = buttonTheme(21,58),
    hoverDownTheme = buttonTheme(0,58),
    undefinedUpTheme = buttonTheme(0,58),
    undefinedDownTheme = buttonTheme(0,58),
  }  
  return theme;
end

function newEncyclopediaDescriptionMEditBoxTheme()
  local meditBoxTheme = newCampaignEditorWidget3Theme()
  meditBoxTheme.color = {0, 0, 0, 0}
  --meditBoxTheme.text.align = {'left', 'center'}
  meditBoxTheme.text.offset = {10, 20}
  meditBoxTheme.border = newEmptyBorder()
  
  -- Тема для view
  meditBoxTheme.viewTheme = newCampaignEditorWidget3Theme()
  --meditBoxTheme.viewTheme.color = {1, 0, 0}
  meditBoxTheme.viewTheme.text.align = {'left', 'center'}
  meditBoxTheme.viewTheme.text.offset = {10, 20}
  --meditBoxTheme.viewTheme.text.font = fontsPath .. 'courier.ttf'

  -- тема для вертикального скроллбара    
  meditBoxTheme.vscrollTheme = newMEVScrollTheme()
  
  -- Тема для выделения текста
  meditBoxTheme.selectionTheme = newWidgetTheme()
  meditBoxTheme.selectionTheme.color = {}
  meditBoxTheme.selectionTheme.caretColor = {}  
  meditBoxTheme.selectionTheme.caretSize = 2 

  return meditBoxTheme
end;

--************************************************************************************

function newMEDownBorder()
  return { type = 'mega', 
           image = getImage('down.png'), 
           size = 1, 
           insets = {1, 1, 1, 1},
           color = {1, 1, 1}
  }
end
function newMEUpBorder()
  return { type = 'mega', 
           image = getImage('up.png'), 
           size = 1, 
           insets = {1, 1, 1, 1},
           color = {1, 1, 1}
  }
end

function newMESliderTheme()
  local sliderTheme = newWidgetTheme()
  sliderTheme.color = {}
  sliderTheme.border = newSimple1Border()  
  -- Тема для ползунка
  sliderTheme.thumbTheme = newWidgetTheme()
  sliderTheme.thumbTheme.color = {}
  sliderTheme.thumbTheme.border = newSimple1Border() 
  sliderTheme.thumbTheme.image.file = getImage('Keys-v3.png')  
  sliderTheme.thumbTheme.image.rect = {4, 43, 11, 13}
  return sliderTheme
end  

function setMEScrollThemeColor(theme, color, _background)
    local background = _background or {0,0,0};
    local arrowColor = {59/255,255/255,190/255};
    theme.increaseButtonTheme.color = color;
    theme.increaseButtonTheme.upTheme.image.color = color;
    theme.increaseButtonTheme.downTheme.image.color = arrowColor;
    theme.increaseButtonTheme.hoverUpTheme.image.color = color;
    
    theme.decreaseButtonTheme.color = color;
    theme.decreaseButtonTheme.upTheme.image.color = color;
    theme.decreaseButtonTheme.downTheme.image.color = arrowColor;
    theme.decreaseButtonTheme.hoverUpTheme.image.color = color;
    
    theme.increaseButtonTheme.downTheme.border.color = color;
    theme.increaseButtonTheme.upTheme.border.color = color;
    theme.increaseButtonTheme.hoverUpTheme.border.color = color;
    
    theme.decreaseButtonTheme.downTheme.border.color = color;
    theme.decreaseButtonTheme.upTheme.border.color = color;
    theme.decreaseButtonTheme.hoverUpTheme.border.color = color;
    
    theme.sliderTheme.border.color = color;
    theme.sliderTheme.color = background;
    theme.sliderTheme.thumbTheme.border.color  = color;
    --theme.sliderTheme.thumbTheme.image.color = color;
    theme.sliderTheme.thumbTheme.image.color = {153/255,153/255,153/255};
    theme.sliderTheme.thumbTheme.color = {0,0,0,0.3};
end;


function newMEScrollTheme()
  local scrollTheme = newWidgetTheme()
  scrollTheme.color = {}
  scrollTheme.border = newEmptyBorder()
  scrollTheme.sliderTheme = newMESliderTheme()
  scrollTheme.sliderTheme.border = newSimple1Border()
  scrollTheme.size = 20
  return scrollTheme
end

function newMEButtonUpTheme()
  local theme = newButtonTheme()  
  local up = {3,3,14,14};
  local down = {23,3,15,15};
  theme.upTheme.border = newSimple1Border({0,0,0})
  --theme.upTheme.border.insets = {1,1,1,0}
  theme.upTheme.image.file = getImage('Keys-v3.png')
  theme.upTheme.image.rect = up
  theme.upTheme.image.align = {'center', 'center'}
  theme.upTheme.color = {}
    
  --theme.downTheme.border = newSimple1Border()
  theme.downTheme.border = newSimple1Border({0,0,0})
  theme.downTheme.image.file = getImage('Keys-v3.png')
  theme.downTheme.image.rect = down
  theme.downTheme.image.align = {'center', 'center'}
  theme.downTheme.color = {}
  
  theme.hoverUpTheme.border = newSimple1Border({0,0,0})
  theme.hoverUpTheme.image.file = getImage('Keys-v3.png')
  theme.hoverUpTheme.image.rect = up
  theme.hoverUpTheme.image.align = {'center', 'center'}
  theme.hoverUpTheme.color = {}
  
  theme.hoverDownTheme.border = newSimple1Border({0,0,0})
  theme.hoverDownTheme.color = {}
  
  return theme
end

function newMEButtonDownTheme()
  local theme = newMEButtonUpTheme()
  local up = {3,23,14,14};
  local down = {23,23,15,15};
  
  theme.upTheme.image.rect = up
  theme.downTheme.image.rect = down
  theme.hoverUpTheme.image.rect = up
  
  return theme
end

function newMEVScrollTheme()
  local scrollTheme = newMEScrollTheme()  
  scrollTheme.sliderTheme.border.image = getImage('simple1_1.png');
  scrollTheme.sliderTheme.thumbTheme.border.image = getImage('simple1_2.png');
  scrollTheme.increaseButtonTheme = newMEButtonDownTheme()
  scrollTheme.decreaseButtonTheme = newMEButtonUpTheme()
  setMEScrollThemeColor(scrollTheme, {52/255,52/255,52/255}, {0,0,0,0.1})
  return scrollTheme
end

function newMEButtonLeftTheme()
  local theme = newMEButtonUpTheme()  
  theme.upTheme.image.file = getImage('Keys-v3h.png')
  theme.downTheme.image.file = getImage('Keys-v3h.png')
  theme.hoverUpTheme.image.file = getImage('Keys-v3h.png')
  return theme
end


function newMEButtonRightTheme()
  local theme = newMEButtonDownTheme()  
  theme.upTheme.image.file = getImage('Keys-v3h.png')
  theme.downTheme.image.file = getImage('Keys-v3h.png')
  theme.hoverUpTheme.image.file = getImage('Keys-v3h.png')
  return theme
end


function newMEHScrollTheme()
  local scrollTheme = newMEScrollTheme()
  scrollTheme.sliderTheme.border.image = getImage('simple1_2.png');
  scrollTheme.sliderTheme.thumbTheme.border.image = getImage('simple1_1.png');
  scrollTheme.increaseButtonTheme = newMEButtonRightTheme()
  scrollTheme.decreaseButtonTheme = newMEButtonLeftTheme()
  setMEScrollThemeColor(scrollTheme, {52/255,52/255,52/255}, {0,0,0,0.1})
  return scrollTheme
end


function newMEComboButtonTheme()
  local theme = newButtonTheme()  
  theme.upTheme.border = newEmptyBorder({0,0,0})
  theme.upTheme.image.file = getImage('Keys-v2.png')
  theme.upTheme.image.rect = {0, 100, 20, 20}
  theme.upTheme.image.color = {0, 0, 0}
  theme.upTheme.color = {}
    
  --theme.downTheme.border = newSimple1Border()
  theme.downTheme.border = newEmptyBorder({0,0,0})
  theme.downTheme.image.file = getImage('Keys-v2.png')
  theme.downTheme.image.rect = {20, 100, 20, 20}
  theme.downTheme.image.color = {0, 0, 0}
  theme.downTheme.color = {}
  
  theme.hoverUpTheme.border = newEmptyBorder({0,0,0})
  theme.hoverUpTheme.image.file = getImage('Keys-v2.png')
  theme.hoverUpTheme.image.rect = {0, 100, 20, 20}
  theme.hoverUpTheme.image.color = {0, 0, 0}
  theme.hoverUpTheme.color = {}
  
  theme.hoverDownTheme.border = newEmptyBorder()
  theme.hoverDownTheme.color = {}
  
  return theme
end

function newOptionsStripTheme()
    local theme = newWidgetTheme();
    theme.image.file = getImage('chart-1.png');
    theme.image.rect = {0, 1, 17, 42};
    theme.image.w = 17;
    theme.image.h = 42;    
    --theme.color = {0,0,0,0};    
    theme.image.align = {'left','top'};    
    return theme;
end; 

function newOptionsStrip1Theme()
    local theme = newOptionsStripTheme();
    theme.image.rect = {1, 1, 17, 42};
    return theme;
end; 

function newOptionsStrip2Theme()
    local theme = newOptionsStripTheme();
    theme.image.rect = {549, 1, 17, 42};
    return theme;
end; 

function newOptionsStrip3Theme()
    local theme = newOptionsStripTheme();
    theme.image.rect = {550, 330, 17, 42};
    return theme;
end; 

function newOptionsStrip4Theme()
    local theme = newOptionsStripTheme();
    theme.image.rect = {1, 330, 17, 42};
    return theme;
end; 

function newOptionsStrip5Theme()
    local theme = newWidgetTheme();
    theme.color = {0,0,0,1};
    return theme;
end; 

function newOptionsButton1Theme()
    function newOptionsButtonState()
        local color = {196/255, 189/255, 98/255, 1}
        local theme = newWidgetTheme();
        theme.color = {}
        theme.text.color = color;
        theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
        theme.text.size = 14;
        theme.text.align = {'center', 'center'};        
        theme.text.offset = {1,-1};
        theme.border = newSimple1Border();
        theme.border.color = color; 
        return theme;
    end;
    
    local theme = newButtonTheme();
    theme.upTheme = newOptionsButtonState();
    theme.downTheme = newOptionsButtonState();
    theme.downTheme.text.offset = {2,0};
    theme.hoverUpTheme = newOptionsButtonState();
    theme.hoverDownTheme = newOptionsButtonState();
    theme.undefinedUpTheme = newOptionsButtonState();
    theme.undefinedDownTheme = newOptionsButtonState();
    return theme;
end;

function newOptionsButton2Theme()
    function newOptionsButtonState()
        local color = {154/255, 156/255, 130/255, 1}
        local theme = newWidgetTheme();
        theme.color = {}
        theme.text.color = color;
        theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
        theme.text.size = 14;
        theme.text.align = {'center', 'center'};        
        theme.text.offset = {1,-1};
        theme.border = newSimple1Border();
        theme.border.color = color; 
        return theme;
    end;
    
    local theme = newButtonTheme();
    theme.upTheme = newOptionsButtonState();
    theme.downTheme = newOptionsButtonState();
    theme.downTheme.text.offset = {2,0};
    theme.hoverUpTheme = newOptionsButtonState();
    theme.hoverDownTheme = newOptionsButtonState();
    theme.undefinedUpTheme = newOptionsButtonState();
    theme.undefinedDownTheme = newOptionsButtonState();
    return theme;
end;

function newOptionsWidget1Theme()
    local color = {154/255, 156/255, 130/255, 1}
    local theme = newWidgetTheme()
    theme.color = {}
    theme.text.color = color;
    theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    theme.text.size = 14;
    theme.text.align = {'center', 'center'};        
    theme.text.offset = {1,-1};
    return theme
end

function newOptionsWidget2Theme()
    local color = {1, 1, 1, 1}
    local theme = newWidgetTheme()
    theme.color = {}
    theme.text.color = color;
    theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed-Bold.ttf';
    theme.text.size = 19;
    theme.text.align = {'left', 'center'};        
    theme.text.offset = {0,0};
    return theme
end

function newOptionsWidget3Theme()
    local color = {1, 1, 1, 1}
    local theme = newWidgetTheme()
    theme.color = {}
    theme.text.color = color;
    theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    theme.text.size = 14;
    theme.text.align = {'right', 'center'};        
    theme.text.offset = {-10,0};
    return theme
end
 
function newOptionsWidget4Theme()
    local color = {196/255, 189/255, 98/255, 1}
    local theme = newOptionsWidget2Theme()
    theme.text.color = color;
    return theme
end

function newOptionsWidget5Theme()
    local theme = newOptionsWidget1Theme();
    theme.text.align = {'right', 'center'};        
    return theme
end

function newOptionsWidget6Theme()
    local color = {154/255, 156/255, 130/255, 1}
    local theme = newWidgetTheme()
    theme.color = {}
    theme.text.color = color;
    theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    theme.text.size = 14;
    theme.text.align = {'right', 'center'};        
    theme.text.offset = {1,-1};
    return theme
end

function newOptionsWidget7Theme()
    local color = {154/255, 156/255, 130/255, 1}
    local theme = newWidgetTheme()
    theme.color = {}
    theme.text.color = color;
    theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    theme.text.size = 14;
    theme.text.align = {'left', 'center'};        
    theme.text.offset = {1,-1};
    return theme
end

function newOptionsSytemLineWidgetTheme()
    local color = {196/255, 189/255, 98/255, 1}
    local theme = newImagePreviewTheme()
    theme.border.color = color
    return theme
end



function newOptionsCheckBoxTheme() 
    local function newOptionsCheckBoxFaceTheme()   
        local color = {1, 1, 1, 1}
        local theme = newWidgetTheme()
        theme.color = {}
        theme.text.color = color;
        theme.text.offset = {26, 0}
        theme.text.align = {'left', 'center'}
        theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
        theme.text.size = 14;
        theme.image.align = {'left', 'center'}
        theme.image.file = getImage('Keys-v2.png')
        --theme.image.rect = {2, 240, 16, 16}
        theme.image.rect = {22, 240, 16, 16}
        theme.image.offset = {0,1}
        theme.border = newEmptyBorder()      
        return theme
    end

    
  local upTheme = newOptionsCheckBoxFaceTheme()
  
  local downTheme = newOptionsCheckBoxFaceTheme()
  downTheme.image.rect = {2, 240, 16, 16}
  
  local hoverUpTheme = newOptionsCheckBoxFaceTheme()
  
  local hoverDownTheme = newOptionsCheckBoxFaceTheme()
  hoverDownTheme.image.rect = {2, 240, 16, 16}
  
  local undefinedUpTheme = newOptionsCheckBoxFaceTheme()
  
  local undefinedDownTheme = newOptionsCheckBoxFaceTheme()
  undefinedDownTheme.image.rect = {2, 240, 16, 16}
  
  return {
    upTheme = upTheme,
    downTheme = downTheme,
    hoverUpTheme = hoverUpTheme,
    hoverDownTheme = hoverDownTheme,
    undefinedUpTheme = undefinedUpTheme,
    undefinedDownTheme = undefinedDownTheme
  }
end

function newOptionsCheckBox2Theme() 
    local color = {154/255, 156/255, 130/255, 1};
    local theme = newOptionsCheckBoxTheme();

    theme.upTheme.text.color = color;
    theme.downTheme.text.color = color;
    theme.hoverUpTheme.text.color = color;
    theme.hoverDownTheme.text.color = color;
    theme.undefinedUpTheme.text.color = color;
    theme.undefinedDownTheme.text.color = color;
    return theme;
end


function newOptionsComboBoxTheme()
    local function newComboBoxTheme()
        local function _newText()
            local text = newText();
            text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
            text.size = 14;
            text.align = {'left', 'center'};
            text.offset = {10,0};
            text.color = {0,0,0,1}        
            return text;
        end;
      local comboBoxTheme = newWidgetTheme()
      comboBoxTheme.color = {1,1,1,1}
      comboBoxTheme.border = newDownBorder()
      comboBoxTheme.text = _newText()
      --comboBoxTheme.text.color = {}
      
      -- максимальная высота списка (далее внутри списка появляется скроллбар)
      comboBoxTheme.maxListHeight = 600
      
      -- тема для едитбокса
      comboBoxTheme.editBoxTheme = newEditBoxTheme()
      comboBoxTheme.editBoxTheme.color = {1,1,1,1}
      comboBoxTheme.editBoxTheme.border = newEmptyBorder()
      comboBoxTheme.editBoxTheme.text = _newText()  
      comboBoxTheme.editBoxTheme.caretTheme.color = {0,0,0}

      -- Тема для кнопки
      comboBoxTheme.buttonTheme = newMEComboButtonTheme();
      --comboBoxTheme.buttonTheme.color = {123/255, 127/255, 104/255, 1};
      comboBoxTheme.buttonTheme.upTheme.image.color = {123/255, 127/255, 104/255, 1};
      comboBoxTheme.buttonTheme.downTheme.image.color = {123/255, 127/255, 104/255, 1};
      comboBoxTheme.buttonTheme.hoverUpTheme.image.color = {123/255, 127/255, 104/255, 1};
      comboBoxTheme.buttonTheme.hoverDownTheme.image.color = {123/255, 127/255, 104/255, 1};
      
      -- Тема для выпадающего списка
      comboBoxTheme.listBoxTheme = newListBoxTheme()
      comboBoxTheme.listBoxTheme.border = newSimple1Border(border_dark)
      comboBoxTheme.listBoxTheme.color = {1,1,1}
      comboBoxTheme.listBoxTheme.text = _newText()
      comboBoxTheme.listBoxTheme.viewTheme.text = _newText()
      comboBoxTheme.listBoxTheme.vscrollTheme = newMEVScrollTheme()
      comboBoxTheme.listBoxTheme.hscrollTheme = newMEHScrollTheme();
      comboBoxTheme.listBoxTheme.itemSize = 15
       
      return comboBoxTheme
    end

  local comboBoxTheme = newComboBoxTheme();
  return comboBoxTheme;
end

function newOptionsComboBoxItemTheme()
    -- Тема для элемента в неактивном состоянии
    local normalTheme = newWidgetTheme()
    normalTheme.color = {}
    normalTheme.text.color = {0,0,0}
    normalTheme.text.offset = {10, 0} -- отступ от края
    normalTheme.text.align = {'left', 'center'}
    normalTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    normalTheme.text.size = 14
    normalTheme.image.offset = {4, 0}
    normalTheme.image.align = {'left', 'center'}

    -- Тема для элемента в активном состоянии
    local selectedTheme = newWidgetTheme()
    selectedTheme.color = list_select_color()
    selectedTheme.text.color = {0,0,0}
    selectedTheme.text.offset = {10, 0} -- отступ от края
    selectedTheme.text.align = {'left', 'center'}
    selectedTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    selectedTheme.text.size = 14
    selectedTheme.image.offset = {4, 0}
    selectedTheme.image.align = {'left', 'center'}    

    local comboBoxItemTheme = {}
    comboBoxItemTheme.normalTheme = normalTheme
    comboBoxItemTheme.selectedTheme = selectedTheme

    return comboBoxItemTheme    
end; 

--[[
function newMESliderTheme()
  local sliderTheme = newWidgetTheme()
  sliderTheme.color = {}
  sliderTheme.border = newSimple1Border()  
  -- Тема для ползунка
  sliderTheme.thumbTheme = newWidgetTheme()
  sliderTheme.thumbTheme.color = {}
  sliderTheme.thumbTheme.border = newSimple1Border() 
  sliderTheme.thumbTheme.image.file = getImage('Keys-v3.png')
  sliderTheme.thumbTheme.image.rect = {4, 43, 11, 13}
  return sliderTheme
end  
--]]

function newBirdsSliderTheme()
    local color = {1, 1, 1, 0.6};
    local sliderTheme = newWidgetTheme()
    sliderTheme.color = {0,0,0,0.2};
    sliderTheme.border = newSimple1Border(color)

    sliderTheme.thumbTheme = newWidgetTheme()
    sliderTheme.thumbTheme.color = {};
    sliderTheme.thumbTheme.border = newEmptyBorder()  
    --sliderTheme.thumbTheme.border = newSimple1Border() 
    sliderTheme.thumbTheme.image.file = getImage('Keys-v3h.png')
    sliderTheme.thumbTheme.image.rect = {0, 41, 19, 17}
    sliderTheme.thumbTheme.image.color = color;
    return sliderTheme
end 

function newOptionsSliderTheme()
    local color = {196/255, 189/255, 98/255, 1};
    local sliderTheme = newWidgetTheme()
    sliderTheme.color = {0,0,0,0.2};
    sliderTheme.border = newSimple1Border(color)

    sliderTheme.thumbTheme = newWidgetTheme()
    sliderTheme.thumbTheme.color = {};
    sliderTheme.thumbTheme.border = newEmptyBorder()  
    --sliderTheme.thumbTheme.border = newSimple1Border() 
    sliderTheme.thumbTheme.image.file = getImage('Keys-v3h.png')
    sliderTheme.thumbTheme.image.rect = {0, 41, 19, 17}
    sliderTheme.thumbTheme.image.color = color;
    return sliderTheme
end  

function newOptionsHSliderTheme()
  return newOptionsSliderTheme()
end  

function newOptionsControlsGridTheme()
    local theme = newScrollGridTheme();
    theme.border = newSimple1Border()
    theme.border.color = {0,0,0,1};
    theme.color = {0,0,0,0.2}

    theme.headerTheme.color = {154/255, 156/255, 130/255};
    theme.headerTheme.gridColor = {0,0,0};
    theme.headerTheme.selColor = {1,1,1};

    theme.leftHeaderTheme.color = {154/255, 156/255, 130/255};
    theme.leftHeaderTheme.gridColor = {0,0,0};
    theme.leftHeaderTheme.selColor = {1,1,1};

    theme.gridTheme.color = {};    
    theme.gridTheme.gridColor = {};
    theme.gridTheme.selColor = {4/225,171/225,226/225};
    theme.gridTheme.vertLinesColor = {0, 0, 0}
    theme.gridTheme.horzLinesColor = {}

    theme.leftGridTheme.color = {};    
    theme.leftGridTheme.gridColor = {};
    theme.leftGridTheme.selColor = {4/225,171/225,226/225};
    theme.leftGridTheme.vertLinesColor = {0, 0, 0}
    theme.leftGridTheme.horzLinesColor = {}

    theme.hscrollTheme = newMEHScrollTheme()
    theme.vscrollTheme = newMEVScrollTheme()

    setMEScrollThemeColor(theme.vscrollTheme, {190/255,190/255,100/255}, {0,0,0,0.3})
    setMEScrollThemeColor(theme.hscrollTheme, {190/255,190/255,100/255}, {0,0,0,0.3})
    return theme
end  

function newOptionsControlsGridHeaderCellTheme()
  local gridCellTheme = newWidgetTheme()
  gridCellTheme.text.color = {75/255,75/255,58/255}
  gridCellTheme.text.offset = {10,0}
  gridCellTheme.text.align = {'left', 'center'}
  gridCellTheme.text.size = 16
  --gridCellTheme.text.font =  fontsPath .. 'DejaVuLGCSansCondensed-Bold.TTF';
  gridCellTheme.text.font =  fontsPath .. 'DejaVuLGCSansCondensed.TTF';
  gridCellTheme.border.color = {};
  return gridCellTheme;
end

function newOptionsControlsGridCellTheme()
  local gridCellTheme = newWidgetTheme()
  gridCellTheme.text.color = {1,1,1}
  gridCellTheme.text.offset = {10,0}
  gridCellTheme.text.size = 12
  --gridCellTheme.text.font =  fontsPath .. 'DejaVuLGCSansCondensed-Bold.TTF';
  gridCellTheme.text.font =  fontsPath .. 'DejaVuLGCSansCondensed.TTF';
  gridCellTheme.border.color = {};
  return gridCellTheme;
end

function newOptionsControlsOddGridCellTheme()
  local gridCellTheme = newOptionsControlsGridCellTheme()
  gridCellTheme.color = {0,0,0,0.2};
  return gridCellTheme;
end

function newOptionsAssignmentWindowTheme()
  local windowTheme = newWidgetTheme()
  windowTheme.color = {}
  windowTheme.text.align = {'center', 'center'}
  windowTheme.text.file = fontsPath .. 'DejaVuLGCSansCondensed-Bold.ttf'; 
  windowTheme.border = newEmptyBorder()
  --windowTheme.image.file = "c:/LockOn/LockOnExe/New GUI/Alternative/Crops/options-assignment-crop.png" 
  
  -- высота заголовка окна
  windowTheme.titleHeight = 39
 
  windowTheme.titleSelectedTheme = newWidgetTheme()
  windowTheme.titleSelectedTheme.color = {}
  windowTheme.titleSelectedTheme.image.file = getImage('chart-1.png');
  windowTheme.titleSelectedTheme.image.rect = {1, 1, 563, 41};
  windowTheme.titleSelectedTheme.image.align = {'stretch', 'stretch'}
  windowTheme.titleSelectedTheme.text.file = fontsPath .. 'DejaVuLGCSansCondensed-Bold.ttf'; 
  windowTheme.titleSelectedTheme.text.size = 19;
  windowTheme.titleSelectedTheme.text.align = {'center', 'center'};
  windowTheme.titleSelectedTheme.text.color = {196/255, 191/255, 102/255};

  windowTheme.titleNormalTheme = newWidgetTheme()
  windowTheme.titleNormalTheme.color = {}
  windowTheme.titleNormalTheme.image.file = getImage('chart-1.png');
  windowTheme.titleNormalTheme.image.rect = {1, 1, 563, 41};
  windowTheme.titleNormalTheme.image.align = {'stretch', 'stretch'}
  windowTheme.titleNormalTheme.text.file = fontsPath .. 'DejaVuLGCSansCondensed-Bold.ttf'; 
  windowTheme.titleNormalTheme.text.size = 19;
  windowTheme.titleNormalTheme.text.align = {'center', 'center'};
  windowTheme.titleNormalTheme.text.color = {196/255, 191/255, 102/255};

  
  windowTheme.titleNormalTheme = windowTheme.titleSelectedTheme;
  
  -- Тема для кнопки закрытия окна  
  windowTheme.closeButtonTheme = newOptionsAssignmentCloseButtonTheme()
  
  return windowTheme
end

function newOptionsAssignmentCloseButtonTheme()
    local pic = 'Keys-v2.png';
    local theme = newButtonTheme();
    theme.upTheme.image.align =  {'center', 'center'}
    theme.upTheme.image.file = getImage(pic)
    theme.upTheme.image.rect = {0,0,20,20}
    theme.upTheme.color = {1,0,1,0}
    theme.upTheme.border = newEmptyBorder()  
    theme.downTheme.image.align =  {'center', 'center'}
    theme.downTheme.image.file = getImage(pic)
    theme.downTheme.image.rect = {20,0,20,20}
    theme.downTheme.color = {1,0,1,0}
    theme.downTheme.border = newEmptyBorder()  
    theme.hoverUpTheme.image.align =  {'center', 'center'}
    theme.hoverUpTheme.image.file = getImage(pic)
    theme.hoverUpTheme.image.rect = {20,0,20,20}
    theme.hoverUpTheme.color = {1,0,1,0}
    theme.hoverUpTheme.border = newEmptyBorder()  
    return theme;
end

function newOptionsAssignmentWidget1Theme()
    local color = {154/255, 156/255, 130/255, 1}
    local theme = newWidgetTheme()
    theme.color = {}
    theme.text.color = color;
    theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    theme.text.size = 14;
    theme.text.align = {'left', 'center'};        
    theme.text.offset = {1,-1};
    return theme
end

function newOptionsAssignmentContainerTheme()
    local theme = newWidgetTheme()
    theme.color = {}
    theme.image.file = getImage('chart-1.png');
    theme.image.rect = {1, 330, 563, 41};
    theme.image.align = {'stretch', 'stretch'}
    -- theme.text.file = fontsPath .. 'DejaVuLGCSansCondensed-Bold.ttf'; 
    -- theme.text.size = 19;
    -- theme.text.align = {'center', 'center'};
    -- theme.text.color = {196/255, 191/255, 102/255};
    --windowTheme.titleSelectedTheme.image.h = 39;
    return theme
end;

function newOptionsAssignmentContainer2Theme()
    local theme = newWidgetTheme()
    theme.color = {}
    theme.image.file = getImage('assignment-panel.png');
    --theme.image.rect = {1, 330, 563, 41};
    theme.image.align = {'stretch', 'stretch'}
    theme.border = newSimple1Border({0,0,0});
    return theme
end;

function newOptionsAssignmentEditboxTheme()
    local function _newText()
        local text = newText();
        text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
        text.size = 14;
        text.align = {'left', 'center'};
        text.offset = {10,0};
        text.color = {0,0,0,1}        
        return text;
    end;
  editBoxTheme = newEditBoxTheme()
  editBoxTheme.color = {1,1,1,1}
  --editBoxTheme.border = newEmptyBorder()
  editBoxTheme.text = _newText()  
  editBoxTheme.caretTheme.color = {0,0,0}

  return editBoxTheme;
end

function newOptionsAxisTuneContainer1Theme()
    local theme = newWidgetTheme()
    theme.color = {190/255, 193/255, 176/255}
    theme.border = newSimple1Border({0,0,0});
    return theme
end;

function newOptionsAxisTuneWidget1Theme()
    local color = {124/255, 127/255, 110/255, 1}
    local theme = newWidgetTheme()
    theme.color = {}
    theme.text.color = color;
    theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    theme.text.size = 14;
    theme.text.align = {'left', 'center'};        
    theme.text.offset = {1,-1};
    return theme
end

function newOptionsAxisTuneWidget2Theme()
    local color = {124/255, 127/255, 110/255, 1}
    local theme = newWidgetTheme()
    theme.color = {}
    theme.text.color = color;
    theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    theme.text.size = 14;
    theme.text.align = {'center', 'center'};        
    theme.text.offset = {1,-1};
    theme.border = newSimple1Border(color);
    return theme
end

function newOptionsAxisTuneCheckBoxTheme() 
    local function newOptionsCheckBoxFaceTheme()   
        local color = {1, 1, 1, 1}
        local theme = newWidgetTheme()
        theme.color = {}
        theme.text.color = color;
        theme.text.offset = {26, 0}
        theme.text.align = {'left', 'center'}
        theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
        theme.text.size = 14;
        theme.image.align = {'left', 'center'}
        theme.image.file = getImage('Keys-v2.png')
        --theme.image.rect = {2, 240, 16, 16}
        theme.image.rect = {22, 240, 16, 16}
        theme.image.offset = {0,1}
        theme.border = newEmptyBorder()      
        return theme
    end
    
  local upTheme = newOptionsCheckBoxFaceTheme()
  
  local downTheme = newOptionsCheckBoxFaceTheme()
  downTheme.image.rect = {2, 240, 16, 16}
  
  local hoverUpTheme = newOptionsCheckBoxFaceTheme()
  
  local hoverDownTheme = newOptionsCheckBoxFaceTheme()
  hoverDownTheme.image.rect = {2, 240, 16, 16}
  
  local undefinedUpTheme = newOptionsCheckBoxFaceTheme()
  
  local undefinedDownTheme = newOptionsCheckBoxFaceTheme()
  undefinedDownTheme.image.rect = {2, 240, 16, 16}
  
  return {
    upTheme = upTheme,
    downTheme = downTheme,
    hoverUpTheme = hoverUpTheme,
    hoverDownTheme = hoverDownTheme,
    undefinedUpTheme = undefinedUpTheme,
    undefinedDownTheme = undefinedDownTheme
  }
end

function newOptionsBirdsWidgetTheme()
    local color = {1,1,1,0.6};
    local theme = newWidgetTheme()
    theme.color = {}
    theme.text.color = color;
    theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    theme.text.size = 14;
    theme.text.align = {'center', 'center'};        
    theme.text.offset = {1,-1};
    theme.border = newSimple1Border(color);
    return theme
end

function newOptionsAxisTuneHSliderTheme()
    local color = {124/255, 127/255, 110/255, 1}
    local sliderTheme = newWidgetTheme()
    sliderTheme.color = {0,0,0,0};
    sliderTheme.image.file = getImage('white.png');
    sliderTheme.image.rect = {0, 0, 1, 1};
    sliderTheme.image.w = 180;
    sliderTheme.image.h = 1;
    sliderTheme.image.color = color;
    --sliderTheme.image.offset = {0,10};
    sliderTheme.image.align = {'center','center'};
    
    --sliderTheme.border = newSimple1Border(color)

    sliderTheme.thumbTheme = newWidgetTheme()
    sliderTheme.thumbTheme.color = {};
    sliderTheme.thumbTheme.border = newEmptyBorder()  
    --sliderTheme.thumbTheme.border = newSimple1Border() 
    sliderTheme.thumbTheme.image.file = getImage('Keys-v3h.png')  
    sliderTheme.thumbTheme.image.rect = {0, 41, 19, 17}
    sliderTheme.thumbTheme.image.color = color;
    return sliderTheme
end  

function newOptionsAxisTuneVSliderTheme()
    local color = {124/255, 127/255, 110/255, 1}
    local sliderTheme = newWidgetTheme()
    sliderTheme.color = {0,0,0,0};
    sliderTheme.image.file = getImage('white.png');
    sliderTheme.image.rect = {0, 0, 1, 1};
    sliderTheme.image.h = 130;
    sliderTheme.image.w = 1;
    sliderTheme.image.color = color;
    --sliderTheme.image.offset = {0,10};
    sliderTheme.image.align = {'center','center'};
    
    --sliderTheme.border = newSimple1Border(color)

    sliderTheme.thumbTheme = newWidgetTheme()
    sliderTheme.thumbTheme.color = {};
    sliderTheme.thumbTheme.border = newEmptyBorder()  
    --sliderTheme.thumbTheme.border = newSimple1Border() 
    sliderTheme.thumbTheme.image.file = getImage('Keys-v3.png') 
    sliderTheme.thumbTheme.image.rect = {0, 41, 19, 17}
    sliderTheme.thumbTheme.image.color = color;
    return sliderTheme
end  

function newOptionsAxisTuneWindowTheme()
  local windowTheme = newOptionsAssignmentWindowTheme()
  --windowTheme.image.file = "c:/LockOn/LockOnExe/New GUI/Alternative/Crops/axis-tune-crop.png"
  return windowTheme
end

function newOptionsModifiersWindowTheme()
  local windowTheme = newOptionsAssignmentWindowTheme()
  -- windowTheme.image.file = "c:/LockOn/LockOnExe/New GUI/Alternative/Crops/options-modifiers-panel-crop.png"
  windowTheme.image.file = getImage("options-window-modifiers-panel-background.png")
  windowTheme.image.align = {'left', 'top'};
  windowTheme.image.offset = {0, 39};
  return windowTheme
end

function newOptionsModifiersListBoxTheme()
        local function _newText()
            local text = newText();
            text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
            text.size = 14;
            text.align = {'left', 'center'};
            text.offset = {10,0};
            text.color = {0,0,0,1}        
            return text;
        end;
    local listBoxTheme = newListBoxTheme()
    listBoxTheme = newListBoxTheme()
    listBoxTheme.border = newSimple1Border(border_dark)
    listBoxTheme.color = {1,1,1}
    listBoxTheme.text = _newText()
    listBoxTheme.viewTheme.text = _newText()
    listBoxTheme.vscrollTheme = newMEVScrollTheme()
    listBoxTheme.hscrollTheme = newMEHScrollTheme();
    listBoxTheme.itemSize = 15
       
  return listBoxTheme;
end  

function newOptionsModifiersGridTheme()
    local theme = newOptionsControlsGridTheme();
    theme.headerSize = 0;
    theme.border = newEmptyBorder();
    return theme
end  

function newOptionsModifiersListBoxItemTheme()
  -- Тема для нормального состояния
  local normalTheme = newWidgetTheme()
  normalTheme.color = {}
  normalTheme.text.color = {0,0,0}
  normalTheme.text.offset = {8, 0}
  normalTheme.text.align = {'left', 'center'}
  normalTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.ttf';
  normalTheme.text.size = 14
  
  -- Тема для активного состояния
  local selectedTheme = newWidgetTheme()
  selectedTheme.color = list_select_color();
  selectedTheme.text.color = {0,0,0}
  selectedTheme.text.offset = {8, 0}
  selectedTheme.text.align = {'left', 'center'}
  selectedTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.ttf';
  selectedTheme.text.size = 14

  local listBoxItemTheme = {}
  listBoxItemTheme.normalTheme = normalTheme
  listBoxItemTheme.selectedTheme = selectedTheme
  
  return listBoxItemTheme
end 

function newOptionsModifiersAddModifierSwitchWindowTheme()
  local windowTheme = newOptionsAssignmentWindowTheme()
  -- windowTheme.image.file = "c:/LockOn/LockOnExe/New GUI/Alternative/Crops/modifier-switch-crop.png"
  windowTheme.image.file = getImage("options-window-modifiers-panel-background.png")
  windowTheme.image.align = {'left', 'top'};
  windowTheme.image.offset = {0, 39};
  windowTheme.image.rect = {0,0,600, 215};
  return windowTheme
end

function newOptionsForceFeedbackWindowTheme()
  local windowTheme = newOptionsAssignmentWindowTheme()
  -- windowTheme.image.file = "c:/LockOn/LockOnExe/New GUI/Alternative/Crops/options-force-feedback.png"
  windowTheme.image.file = getImage("options-window-modifiers-panel-background.png")
  windowTheme.image.align = {'left', 'top'};
  windowTheme.image.offset = {0, 39};
  windowTheme.image.rect = {0,0,600, 215};
  return windowTheme
end

function newOptionsEditboxTheme()
    local color = {154/255, 156/255, 130/255, 1}
  local editBoxTheme = newOptionsWidget1Theme();
  editBoxTheme.text.align = {'center', 'center'}
  editBoxTheme.border = newSimple1Border(color)
  
  -- Тема для курсора
  editBoxTheme.caretTheme = newWidgetTheme()
  editBoxTheme.caretTheme.color = color
  
  -- Тема для выделения текста
  editBoxTheme.selectionTheme = newWidgetTheme()
  editBoxTheme.selectionTheme.color = {95/255, 105/255, 90/255, 0.5}
  
  return editBoxTheme
end; 



-- tab button theme in bottom units panel
function newTabButtonTheme()
  local theme = newButtonTheme()
  local image = getImage('btn-tools-01.png')
  
  theme.upTheme.color = {}
  theme.upTheme.border = newEmptyBorder()
  theme.upTheme.image.file = image
  theme.upTheme.image.offset = {0, 0}
  theme.upTheme.image.align = {'left', 'top'}
  
  theme.downTheme.color = {}
  theme.downTheme.border = newEmptyBorder()
  theme.downTheme.image.file = image
  theme.downTheme.image.offset = {0, 0}
  theme.downTheme.image.align = {'left', 'top'}
  
  theme.hoverUpTheme.color = {}
  theme.hoverUpTheme.border = newEmptyBorder()
  theme.hoverUpTheme.image.file = image
  theme.hoverUpTheme.image.offset = {0, 0}
  theme.hoverUpTheme.image.align = {'left', 'top'}

  theme.hoverDownTheme.color = {}
  theme.hoverDownTheme.border = newEmptyBorder()
  theme.hoverDownTheme.image.file = image
  theme.hoverDownTheme.image.offset = {0, 0}
  theme.hoverDownTheme.image.align = {'left', 'top'}
  
  theme.undefinedUpTheme.color = {}
  theme.undefinedUpTheme.border = newEmptyBorder()
  theme.undefinedUpTheme.image.file = image
  theme.undefinedUpTheme.image.offset = {0, 0}
  theme.undefinedUpTheme.image.align = {'left', 'top'}

  theme.undefinedDownTheme.color = {}
  theme.undefinedDownTheme.border = newEmptyBorder()
  theme.undefinedDownTheme.image.file = image
  theme.undefinedDownTheme.image.offset = {0, 0}
  theme.undefinedDownTheme.image.align = {'left', 'top'}
  
  return theme
end

function newDebriefngWindowTheme()
  local windowTheme = newWindowTheme()
  -- высота заголовка окна
  windowTheme.titleHeight = 0
  windowTheme.image.file = getImage( 'debriefing-window.png');
  return windowTheme
end

function newDebriefingContainerTheme()
    local theme = newImagePreviewTheme();
    --theme.image.file = "c:\\LockOn\\LockOnExe\\New GUI\\Alternative\\Crops\\debriefing-window.png";
    --theme.image.color = {1,1,1,0.3};
    --theme.color = {};
    return theme;
end; 

function newDebriefingWidget1Theme()
    local theme = newOptionsWidget4Theme()
    theme.text.size = 18;
    return theme
end

function newDebriefingWidget2Theme()
    local color = {237/255, 33/255, 39/255}
    local theme = newDebriefingWidget1Theme()
    theme.text.color = color;
    theme.text.size = 17;    
    theme.text.align = {'right','center'};    
    return theme
end

function newDebriefingWidget3Theme()
    local color = {4/255, 171/255, 226/255}
    local theme = newDebriefingWidget1Theme()
    theme.text.color = color;
    theme.text.size = 17;
    theme.text.align = {'left','center'};    
    return theme
end

function newDebriefingWidget4Theme()
    local color = {1, 1, 1}
    local theme = newOptionsWidget1Theme();
    theme.text.align = {'right', 'center'};        
    theme.text.color = color;
    return theme
end

function newDebriefingWidget5Theme()
    local color = {76/255, 77/255, 61/255}
    local theme = newOptionsWidget1Theme();
    theme.text.align = {'center', 'center'};        
    theme.text.color = color;
    return theme
end

function newDebriefingWidget6Theme()
    local color = {1, 1, 1}
    local theme = newOptionsWidget1Theme();
    theme.text.align = {'left', 'center'};        
    theme.text.color = color;
    return theme
end

function newDebriefingWidget7Theme()
    local color = {76/255, 77/255, 61/255}
    local theme = newOptionsWidget1Theme();
    theme.text.align = {'left', 'center'};        
    theme.text.color = color;
    return theme
end


function newDebriefingButton1Theme()
    function newOptionsButtonState()
        local color = {196/255, 189/255, 98/255, 1}
        local theme = newWidgetTheme();
        theme.color = {}
        theme.text.color = color;
        theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
        theme.text.size = 14;
        theme.text.align = {'center', 'center'};        
        theme.text.offset = {1,-1};
        theme.border = newSimple1Border();
        theme.border.color = color; 
        return theme;
    end;
    
    local theme = newButtonTheme();
    theme.upTheme = newOptionsButtonState();
    theme.downTheme = newOptionsButtonState();
    theme.downTheme.text.offset = {2,0};
    theme.hoverUpTheme = newOptionsButtonState();
    theme.hoverDownTheme = newOptionsButtonState();
    theme.undefinedUpTheme = newOptionsButtonState();
    theme.undefinedDownTheme = newOptionsButtonState();
    return theme;
end;

function newDebriefingComboboxTheme()
    local theme = newOptionsComboBoxTheme();
    
    return theme;
end; 

function newDebriefingGridTheme()
    local theme = newScrollGridTheme();
    theme.border = newEmptyBorder()
    theme.color = {0,0,0,0.1}
    
    theme.headerSize = 31 

    theme.headerTheme.color = {154/255, 156/255, 130/255};
    theme.headerTheme.gridColor = {};
    theme.headerTheme.selColor = {};

    theme.gridTheme.color = {};    
    theme.gridTheme.gridColor = {};
    theme.gridTheme.selColor = {};
    theme.gridTheme.vertLinesColor = {}
    theme.gridTheme.horzLinesColor = {}

    theme.hscrollTheme = newMEHScrollTheme()
    theme.vscrollTheme = newMEVScrollTheme()

    setMEScrollThemeColor(theme.vscrollTheme, {190/255,190/255,100/255}, {0,0,0,0.3})
    setMEScrollThemeColor(theme.hscrollTheme, {190/255,190/255,100/255}, {0,0,0,0.3})
    return theme
end  

function newDebriefingGridHeaderCellTheme()
  local gridCellTheme = newWidgetTheme()
  gridCellTheme.text.color = {75/255,75/255,58/255}
  gridCellTheme.text.offset = {1,-1}
  gridCellTheme.text.align = {'center', 'center'}
  gridCellTheme.text.size = 14
  --gridCellTheme.text.font =  fontsPath .. 'DejaVuLGCSansCondensed-Bold.TTF';
  gridCellTheme.text.font =  fontsPath .. 'DejaVuLGCSansCondensed.TTF';
  gridCellTheme.border.color = {};
  return gridCellTheme;
end

function newDebriefingGridCellTheme(textColor)
  local gridCellTheme = newWidgetTheme()
  -- if textColor == nil then
    -- gridCellTheme.text.color = {1,1,1}
  -- else
    -- gridCellTheme.text.color = textColor;
  -- end;
  gridCellTheme.text.color = {1,1,1}
  gridCellTheme.text.offset = {0,0}
  gridCellTheme.text.size = 12
  gridCellTheme.text.align = {'center','center'};

  gridCellTheme.text.font =  fontsPath .. 'DejaVuLGCSansCondensed.TTF';
  gridCellTheme.border.color = {};
  --gridCellTheme.color = {1,0,0};
  return gridCellTheme;
end;

function newAutobriefingSpinBoxTheme()
  local spinBoxTheme = newWidgetTheme()
  spinBoxTheme.color = {}
  spinBoxTheme.border = newEmptyBorder()
  
  -- Тема для едитбокса
  spinBoxTheme.editBoxTheme = newOptionsEditboxTheme()
  spinBoxTheme.editBoxTheme.text.align = {'center', 'center'}
  spinBoxTheme.editBoxTheme.text.color = {1,1,1}
  spinBoxTheme.editBoxTheme.text.offset = {1,1};  
  spinBoxTheme.editBoxTheme.border = newEmptyBorder()
  spinBoxTheme.editBoxTheme.caretTheme.color = {}
  
  -- Тема для кнопки увеличения значения
  spinBoxTheme.increaseButtonTheme = newEncyclopediaButton2Theme()
  
  -- Тема для кнопки уменьшения значения
  spinBoxTheme.decreaseButtonTheme = newEncyclopediaButton1Theme()
   
  return spinBoxTheme
end 

function newAutoBriefingSpinWidgetTheme()
    local theme = newWidgetTheme()
    local color = {1, 1, 1}

    theme.color = {}
    theme.text.color = color;
    theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    theme.text.size = 14;
    theme.text.align = {'left', 'center'};        
    theme.text.offset = {1,1};
    
    return theme;
end; 

function newFileDialogWindowTheme()
  local windowTheme = newWindowTheme()
  -- высота заголовка окна
  windowTheme.titleHeight = 0
  windowTheme.color = {}
  --windowTheme.image.file = "c:/lockon/lockonexe/blackshark/themes/open-file-dialog-window-2.png"
  windowTheme.image.file = getImage("open-file-dialog-window-2.png")
  --windowTheme.image.align = {'left', 'top'}
  windowTheme.image.rect = {0,0,474,474}
  windowTheme.image.align = {'left','top'}

  return windowTheme
end

function newFileDialogButton1Theme()
    local color = {150/255, 150/255, 150/255, 1}
    local hoverColor = {180/255, 180/255, 180/255, 1}
    
    function newOptionsButtonState()
        local theme = newWidgetTheme();
        theme.color = {}
        theme.text.color = color;
        theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
        theme.text.size = 18;
        theme.text.align = {'center', 'center'};        
        theme.text.offset = {1,-3};
        theme.border = newSimple1Border();
        theme.border.color = color; 
        return theme;
    end;
    
    local theme = newButtonTheme();
    theme.upTheme = newOptionsButtonState();
    theme.downTheme = newOptionsButtonState();
    theme.downTheme.text.offset = {2,-2};
    theme.hoverUpTheme = newOptionsButtonState();
    theme.hoverUpTheme.text.color = hoverColor;
    theme.hoverDownTheme = newOptionsButtonState();
    theme.undefinedUpTheme = newOptionsButtonState();
    theme.undefinedDownTheme = newOptionsButtonState();
    return theme;
end;

function newFileDialogButton2Theme()
    local theme = newFileDialogButton1Theme();
    local color = {0.85, 0.85, 0.85, 1}
    local hoverColor = {1, 1, 1, 1}
    theme.upTheme.text.color = color;
    theme.downTheme.text.color = color;
    theme.hoverUpTheme.text.color = hoverColor;
    theme.hoverDownTheme.text.color = color;
    theme.undefinedUpTheme.text.color = color;
    theme.undefinedDownTheme.text.color = color;
    return theme;
end;

function newFileDialogCloseButtonTheme()
    local closeButtonTheme = newButtonTheme();
  -- Тема для кнопки закрытия окна  
  closeButtonTheme = newButtonTheme()
  closeButtonTheme.upTheme.image.file = getImage('keys-v2.png')
  closeButtonTheme.upTheme.image.rect = {0,0,20,20};
  closeButtonTheme.upTheme.color = {};
  closeButtonTheme.upTheme.border = newEmptyBorder();
  closeButtonTheme.downTheme.image.file = getImage('keys-v2.png')
  closeButtonTheme.downTheme.image.rect = {20,0,20,20};
  closeButtonTheme.downTheme.color = {};
  closeButtonTheme.downTheme.border = newEmptyBorder();
  closeButtonTheme.hoverUpTheme.image.file = getImage('keys-v2.png')
  closeButtonTheme.hoverUpTheme.image.rect = {0,0,20,20};
  closeButtonTheme.hoverUpTheme.image.offset = {1,1};
  closeButtonTheme.hoverUpTheme.color = {};
  closeButtonTheme.hoverUpTheme.border = newEmptyBorder();    
  return closeButtonTheme;
end; 

function newFileDialogWidget1Theme()
    local theme = newWidgetTheme();
    local color = {196/255, 191/255, 102/255, 1}
    theme.color = {}
    theme.text.color = color;
    theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    theme.text.size = 18;
    theme.text.align = {'left', 'center'};        
    theme.border = newEmptyBorder();
    return theme;
end;

function newFileDialogWidget2Theme()
    local theme = newWidgetTheme();
    local color = {157/255, 212/255, 235/255, 1}
    theme.color = {}
    theme.text.color = color;
    theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    theme.text.size = 12;
    theme.text.align = {'right', 'center'};        
    theme.border = newEmptyBorder();
    return theme;
end;


function newFileDialogComboBoxItemTheme()
    local function _newText()
        local text = newText();
        text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
        text.size = 14;
        text.align = {'left', 'center'};
        text.offset = {10,-1};
        text.color = {0,0,0,1}        
        return text;
    end;

  -- Тема для элемента в неактивном состоянии
  local normalTheme = newWidgetTheme()
  normalTheme.color = {1,1,1}
  normalTheme.text = _newText()
  
  -- Тема для элемента в активном состоянии
  local selectedTheme = newWidgetTheme()
  selectedTheme.color = list_select_color()
  selectedTheme.text = _newText()
  
  local comboBoxItemTheme = {}
  comboBoxItemTheme.normalTheme = normalTheme
  comboBoxItemTheme.selectedTheme = selectedTheme
  
  return comboBoxItemTheme
end


function newFileDialogComboBoxTheme()
    local function newComboBoxTheme()
        local function _newText()
            local text = newText();
            text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
            text.size = 14;
            text.align = {'left', 'center'};
            text.offset = {10,-1};
            text.color = {0,0,0,1}        
            return text;
        end;
      local comboBoxTheme = newWidgetTheme()
      local color = {1,1,1,0.6};
      comboBoxTheme.color = color;
      comboBoxTheme.border = newSimple1Border({154/255, 156/255, 130/255})
      comboBoxTheme.text = _newText()
      --comboBoxTheme.text.color = {}
      
      -- максимальная высота списка (далее внутри списка появляется скроллбар)
      comboBoxTheme.maxListHeight = 100
      
      -- тема для едитбокса
      comboBoxTheme.editBoxTheme = newEditBoxTheme()
      comboBoxTheme.editBoxTheme.color = {}
      comboBoxTheme.editBoxTheme.border = newEmptyBorder()
      comboBoxTheme.editBoxTheme.text = _newText()  
      comboBoxTheme.editBoxTheme.caretTheme.color = {0,0,0}

      -- Тема для кнопки
      comboBoxTheme.buttonTheme = newMEComboButtonTheme();
      --comboBoxTheme.buttonTheme.color = {123/255, 127/255, 104/255, 1};
      comboBoxTheme.buttonTheme.upTheme.image.color = {0,0,0};
      comboBoxTheme.buttonTheme.downTheme.image.color = {0,0,0};
      comboBoxTheme.buttonTheme.hoverUpTheme.image.color = {0,0,0};
      comboBoxTheme.buttonTheme.hoverDownTheme.image.color = {0,0,0};
      
      -- Тема для выпадающего списка
      comboBoxTheme.listBoxTheme = newListBoxTheme()
      comboBoxTheme.listBoxTheme.border = newSimple1Border(border_dark)
      comboBoxTheme.listBoxTheme.color = {1,1,1};
      comboBoxTheme.listBoxTheme.text = _newText()
      comboBoxTheme.listBoxTheme.viewTheme.text = _newText()
      comboBoxTheme.listBoxTheme.vscrollTheme = newMEVScrollTheme()
      comboBoxTheme.listBoxTheme.hscrollTheme = newMEHScrollTheme();
      comboBoxTheme.listBoxTheme.itemSize = 25
       
      comboBoxTheme.itemTheme = newFileDialogComboBoxItemTheme(); 
       
      return comboBoxTheme
    end

  local comboBoxTheme = newComboBoxTheme();
  return comboBoxTheme;
end


function newFileDialogEditBoxTheme()
    local function _newText()
        local text = newText();
        text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
        text.size = 14;
        text.align = {'left', 'center'};
        text.offset = {5,-1};
        text.color = {0,0,0,1}        
        return text;
    end;
    local editBoxTheme = newEditBoxTheme()
    editBoxTheme.text = _newText()  
    editBoxTheme.caretTheme.color = {0,0,0}
    editBoxTheme.color = {1,1,1,0.6}
    editBoxTheme.border = newSimple1Border({154/255, 156/255, 130/255})
    return editBoxTheme
end; 

function newFileDialogListBoxTheme()
  local listBoxTheme = newWidgetTheme()
  listBoxTheme.color = {0,0,0,0.3}
  listBoxTheme.border = newSimple1Border({1,1,1})
  
  -- Тема для view
  listBoxTheme.viewTheme = newWidgetTheme()
  listBoxTheme.viewTheme.color = newWidgetTheme()
      
  -- тема для горизонтального скроллбара
  listBoxTheme.hscrollTheme = newMEHScrollTheme()

  -- тема для вертикального скроллбара    
  listBoxTheme.vscrollTheme = newMEVScrollTheme()
    
  -- Высота элементов списка
  listBoxTheme.itemSize = 25
  
  return listBoxTheme
end  

function newFileDialogListBoxFolderItemTheme()
  local listBoxFolderItemTheme = newListBoxItemTheme()
  listBoxFolderItemTheme.normalTheme.image.file = getImage('keys-v2.png')
  listBoxFolderItemTheme.normalTheme.image.rect = {0, 20, 20, 20}
  listBoxFolderItemTheme.normalTheme.image.align = {'left', 'center'}
  listBoxFolderItemTheme.normalTheme.image.offset = {13,0}
  listBoxFolderItemTheme.normalTheme.image.w = 20;
  listBoxFolderItemTheme.normalTheme.image.h = 20;
  listBoxFolderItemTheme.normalTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
  listBoxFolderItemTheme.normalTheme.text.size = 19;
  listBoxFolderItemTheme.normalTheme.text.color = {1,1,1};
  listBoxFolderItemTheme.normalTheme.text.offset = {40,-2};
  listBoxFolderItemTheme.normalTheme.text.align = {'left','center'};
  
  listBoxFolderItemTheme.selectedTheme.image.file = getImage('keys-v2.png')
  listBoxFolderItemTheme.selectedTheme.image.rect = {0, 20, 20, 20}
  listBoxFolderItemTheme.selectedTheme.image.align = {'left', 'center'}
  listBoxFolderItemTheme.selectedTheme.image.offset = {13,0}
  listBoxFolderItemTheme.selectedTheme.image.w = 20;
  listBoxFolderItemTheme.selectedTheme.image.h = 20;
  listBoxFolderItemTheme.selectedTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
  listBoxFolderItemTheme.selectedTheme.text.size = 19;
  listBoxFolderItemTheme.selectedTheme.text.color = {1,1,1};
  listBoxFolderItemTheme.selectedTheme.text.offset = {40,-2};
  listBoxFolderItemTheme.selectedTheme.text.align = {'left','center'};
  listBoxFolderItemTheme.selectedTheme.color = {4/225,171/225, 226/225};

  return listBoxFolderItemTheme
end

function newFileDialogListBoxFileItemTheme()
  local listBoxFileItemTheme = newFileDialogListBoxFolderItemTheme()
  listBoxFileItemTheme.normalTheme.image.file = getImage('btn-tools-01.png')
  listBoxFileItemTheme.normalTheme.image.rect = {120, 204, 16, 14}
  
  listBoxFileItemTheme.selectedTheme.image.file = getImage('btn-tools-01.png')
  listBoxFileItemTheme.selectedTheme.image.rect = {120, 204, 16, 14}  
  return listBoxFileItemTheme
end

function newExitMsgWindowTheme()
  local windowTheme = newWidgetTheme()
  windowTheme.color = {}
  windowTheme.text.align = {'center', 'center'}
  windowTheme.border = newEmptyBorder()

  windowTheme.image.file  = getImage('warning-window.png')
  windowTheme.image.color = {1,1,1};
  windowTheme.image.rect = {0, 0, 360, 180};
  windowTheme.image.align = {'left', 'top'};
  
  -- высота заголовка окна
  windowTheme.titleHeight = 0

  -- тема для заголовка неактивного окна  
  windowTheme.titleNormalTheme = newWidgetTheme()
  windowTheme.titleNormalTheme.color = {0.5, 0.5, 0.5}

  -- тема для заголовка активного окна   
  windowTheme.titleSelectedTheme = newWidgetTheme()
  windowTheme.titleSelectedTheme.color = {0, 180 / 255, 0.0}  
  
  -- Тема для кнопки закрытия окна  
  windowTheme.closeButtonTheme = newButtonTheme()
  windowTheme.closeButtonTheme.upTheme.image.file = getImage('close.png')
  windowTheme.closeButtonTheme.downTheme.image.file = getImage('close.png')
  windowTheme.closeButtonTheme.hoverUpTheme.image.file = getImage('close.png')

  windowTheme.buttonSound = 'button2.wav'
  
  return windowTheme

end  

function newExitMsgWindowWidgetTheme()
    local theme = newWidgetTheme();
    theme.image.file = getImage('warning-labels.png')
    theme.image.rect = {64, 0, 64, 64}
    
    theme.buttonSound = 'button2.wav'    
  
    return theme
end; 




function newExtMsgWindowTheme()
  local windowTheme = newWindowTheme()
  windowTheme.color = {}
  windowTheme.text.align = {'center', 'center'}
  windowTheme.border = newEmptyBorder()

  windowTheme.image.file  = getImage('msg-window.png')
  windowTheme.image.color = {1,1,1};
  windowTheme.image.rect = {0, 0, 420, 300};
  windowTheme.image.align = {'left', 'top'};
  
  -- высота заголовка окна
  windowTheme.titleHeight = 0

  -- тема для заголовка неактивного окна  
  windowTheme.titleNormalTheme = newWidgetTheme()
  windowTheme.titleNormalTheme.color = {0.5, 0.5, 0.5}

  -- тема для заголовка активного окна   
  windowTheme.titleSelectedTheme = newWidgetTheme()
  windowTheme.titleSelectedTheme.color = {0, 180 / 255, 0.0}  
  
  -- Тема для кнопки закрытия окна  
  windowTheme.closeButtonTheme = newButtonTheme()
  windowTheme.closeButtonTheme.upTheme.image.file = getImage('close.png')
  windowTheme.closeButtonTheme.downTheme.image.file = getImage('close.png')
  windowTheme.closeButtonTheme.hoverUpTheme.image.file = getImage('close.png' ) 
  
  windowTheme.buttonTheme = newFileDialogButton2Theme();
  
  return windowTheme

end  

function newExtMsgWindowWidgetTheme()
    local theme = newWidgetTheme()
    theme.text.align =  {'left', 'center'};
    theme.text.color = {196/255, 191/255, 102/255, 1};
    theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    theme.text.size = 18;
    --theme.border = newSimple1Border({1,1,1})
    return theme;
end



function newExtMsgWindowMEditBoxTheme()
    local meditBoxTheme = newWidgetTheme();
    meditBoxTheme.text.color = {196/255, 191/255, 102/255, 1};
    meditBoxTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    meditBoxTheme.text.size = 18;
    meditBoxTheme.text.align = {'center', 'center'};

  meditBoxTheme.color = {0, 0, 0, 0}
  --meditBoxTheme.text.align = {'left', 'center'}
  meditBoxTheme.text.offset = {20, 20}
  meditBoxTheme.border = newEmptyBorder()
  
  -- Тема для view
    meditBoxTheme.viewTheme = newCampaignEditorWidget3Theme()
    meditBoxTheme.viewTheme.text.align =  {'center', 'center'};
    meditBoxTheme.viewTheme.text.color = {196/255, 191/255, 102/255, 1};
    meditBoxTheme.viewTheme.text.font = fontsPath .. 'DejaVuLGCSansCondensed.TTF';
    meditBoxTheme.viewTheme.text.size = 18;
    
  -- тема для вертикального скроллбара    
  meditBoxTheme.vscrollTheme = newMEVScrollTheme()
  
  -- Тема для выделения текста
  meditBoxTheme.selectionTheme = newWidgetTheme()
  meditBoxTheme.selectionTheme.color = {}
  meditBoxTheme.selectionTheme.caretColor = {0}  
  meditBoxTheme.selectionTheme.caretSize = 2 

  return meditBoxTheme
end

function newCampaignEndWidgetTheme()
    local theme = newWidgetTheme()
    theme.text.font = fontsPath .. 'DejaVuLGCSans.ttf';
    theme.text.size = 16;
    theme.text.color = {1,1,1};
    theme.text.offset = {20,0};
    return theme
end; 

function newQuickStartWindowTheme()
    local theme = newWindowTheme();
    theme.color = {0, 0, 0, 0};
    theme.image.file = getImage("chart-3.png");
    theme.image.rect = {1, 1, 371, 371};
    return theme;
end;

function newWidgetDescriptionMissionTheme()
    local theme = newWindowTheme();
    theme.text.offset = {0,-3};
    theme.text.font = fontsPath .. 'DejaVuLGCSansCondensed-Bold.ttf';
    theme.text.color = {0.76862745, 0.749019, 0.4, };
    theme.text.align = {"center", "center"};
    theme.text.size = 18;
    theme.image.file = getImage('billets-1.png');
    theme.image.rect = {0, 84, 237, 40};   
    theme.color = {0, 0, 0, 0};   
    return theme;
end;