2017-12-13 22:29:28 +08:00
|
|
|
#include "core_include/api.h"
|
|
|
|
#include "core_include/rect.h"
|
|
|
|
#include "core_include/cmd_target.h"
|
|
|
|
#include "core_include/wnd.h"
|
|
|
|
#include "core_include/surface.h"
|
2018-12-02 22:39:43 +08:00
|
|
|
#include "core_include/display.h"
|
2018-10-04 14:30:29 +08:00
|
|
|
#include "core_include/resource.h"
|
2017-12-13 22:29:28 +08:00
|
|
|
#include "core_include/word.h"
|
2019-04-08 13:17:46 +08:00
|
|
|
#include "core_include/theme.h"
|
2019-05-24 10:20:40 +08:00
|
|
|
#include "widgets_include/dialog.h"
|
2017-12-06 21:43:47 +08:00
|
|
|
|
2018-12-02 22:39:43 +08:00
|
|
|
DIALOG_ARRAY c_dialog::ms_the_dialogs[SURFACE_CNT_MAX];
|
2017-12-06 21:43:47 +08:00
|
|
|
void c_dialog::pre_create_wnd()
|
|
|
|
{
|
2019-05-24 10:20:40 +08:00
|
|
|
m_style = 0;// no focus/visible
|
2017-12-06 21:43:47 +08:00
|
|
|
m_z_order = Z_ORDER_LEVEL_1;
|
2018-12-28 15:56:36 +08:00
|
|
|
m_bg_color = GL_RGB(33, 42, 53);
|
2017-12-06 21:43:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void c_dialog::on_paint()
|
|
|
|
{
|
|
|
|
c_rect rect;
|
|
|
|
get_screen_rect(rect);
|
2019-04-08 13:17:46 +08:00
|
|
|
m_surface->fill_rect(rect, m_bg_color, m_z_order);
|
2017-12-06 21:43:47 +08:00
|
|
|
|
2018-10-04 14:30:29 +08:00
|
|
|
if (m_str)
|
2017-12-06 21:43:47 +08:00
|
|
|
{
|
2019-04-08 13:17:46 +08:00
|
|
|
c_word::draw_string(m_surface, m_z_order, m_str, rect.m_left+35, rect.m_top, c_theme::get_font(FONT_DEFAULT), GL_RGB(255, 255, 255), GL_ARGB(0, 0, 0, 0), ALIGN_LEFT);
|
2017-12-06 21:43:47 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
c_dialog* c_dialog::get_the_dialog(c_surface* surface)
|
|
|
|
{
|
2018-12-02 22:39:43 +08:00
|
|
|
for(int i = 0; i < SURFACE_CNT_MAX; i++)
|
2017-12-06 21:43:47 +08:00
|
|
|
{
|
|
|
|
if(ms_the_dialogs[i].surface == surface)
|
|
|
|
{
|
|
|
|
return ms_the_dialogs[i].dialog;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2019-05-24 15:16:03 +08:00
|
|
|
int c_dialog::open_dialog(c_dialog* p_dlg, bool modal_mode)
|
2017-12-06 21:43:47 +08:00
|
|
|
{
|
|
|
|
if (NULL == p_dlg)
|
|
|
|
{
|
|
|
|
ASSERT(FALSE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
c_dialog* cur_dlg = get_the_dialog(p_dlg->get_surface());
|
|
|
|
if (cur_dlg == p_dlg)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(cur_dlg)
|
|
|
|
{
|
2019-05-24 10:20:40 +08:00
|
|
|
cur_dlg->set_style(0);
|
2017-12-06 21:43:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
c_rect rc;
|
|
|
|
p_dlg->get_screen_rect(rc);
|
|
|
|
p_dlg->get_surface()->set_frame_layer(rc, Z_ORDER_LEVEL_1);
|
|
|
|
|
2019-05-24 15:16:03 +08:00
|
|
|
p_dlg->set_style(modal_mode ? (GL_ATTR_VISIBLE | GL_ATTR_FOCUS | GL_ATTR_MODAL) : (GL_ATTR_VISIBLE | GL_ATTR_FOCUS));
|
2017-12-06 21:43:47 +08:00
|
|
|
p_dlg->show_window();
|
|
|
|
p_dlg->set_me_the_dialog();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2018-12-02 22:39:43 +08:00
|
|
|
int c_dialog::close_dialog(c_surface* surface)
|
2017-12-06 21:43:47 +08:00
|
|
|
{
|
2018-12-02 22:39:43 +08:00
|
|
|
c_dialog* dlg = get_the_dialog(surface);
|
2017-12-06 21:43:47 +08:00
|
|
|
|
|
|
|
if (NULL == dlg)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
c_rect rc;
|
2018-12-02 22:39:43 +08:00
|
|
|
|
2019-05-24 10:20:40 +08:00
|
|
|
dlg->set_style(0);
|
2017-12-06 21:43:47 +08:00
|
|
|
surface->set_frame_layer(rc, dlg->m_z_order);
|
|
|
|
|
|
|
|
//clear the dialog
|
2018-12-02 22:39:43 +08:00
|
|
|
for(int i = 0; i < SURFACE_CNT_MAX; i++)
|
2017-12-06 21:43:47 +08:00
|
|
|
{
|
|
|
|
if(ms_the_dialogs[i].surface == surface)
|
|
|
|
{
|
|
|
|
ms_the_dialogs[i].dialog = NULL;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ASSERT(FALSE);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int c_dialog::set_me_the_dialog()
|
|
|
|
{
|
|
|
|
c_surface* surface = get_surface();
|
2018-12-02 22:39:43 +08:00
|
|
|
for(int i = 0; i < SURFACE_CNT_MAX; i++)
|
2017-12-06 21:43:47 +08:00
|
|
|
{
|
|
|
|
if(ms_the_dialogs[i].surface == surface)
|
|
|
|
{
|
|
|
|
ms_the_dialogs[i].dialog = this;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-02 22:39:43 +08:00
|
|
|
for(int i = 0; i < SURFACE_CNT_MAX; i++)
|
2017-12-06 21:43:47 +08:00
|
|
|
{
|
|
|
|
if(ms_the_dialogs[i].surface == NULL)
|
|
|
|
{
|
|
|
|
ms_the_dialogs[i].dialog = this;
|
|
|
|
if(this)
|
|
|
|
{
|
|
|
|
ms_the_dialogs[i].surface = surface;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ASSERT(FALSE);
|
|
|
|
return -2;
|
|
|
|
}
|