mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 19:20:09 +00:00
Added LinkLabel widget.
This commit is contained in:
parent
cb0488b50b
commit
ee3e04386b
@ -132,6 +132,7 @@ COMMON_SOURCES = \
|
||||
src/jinete/jbutton.cpp \
|
||||
src/jinete/jclipboard.cpp \
|
||||
src/jinete/jcombobox.cpp \
|
||||
src/jinete/jcustom_label.cpp \
|
||||
src/jinete/jdraw.cpp \
|
||||
src/jinete/jentry.cpp \
|
||||
src/jinete/jexception.cpp \
|
||||
@ -145,6 +146,7 @@ COMMON_SOURCES = \
|
||||
src/jinete/jinete.cpp \
|
||||
src/jinete/jintern.cpp \
|
||||
src/jinete/jlabel.cpp \
|
||||
src/jinete/jlink_label.cpp \
|
||||
src/jinete/jlist.cpp \
|
||||
src/jinete/jlistbox.cpp \
|
||||
src/jinete/jmanager.cpp \
|
||||
|
@ -61,7 +61,7 @@ void AboutCommand::execute(Context* context)
|
||||
separator1 = ji_separator_new(NULL, JI_HORIZONTAL);
|
||||
|
||||
label3 = new Label(COPYRIGHT);
|
||||
label4 = new Label(WEBSITE);
|
||||
label4 = new LinkLabel(WEBSITE);
|
||||
textbox = jtextbox_new("Authors:\n\n"
|
||||
" David Capello\n"
|
||||
" - Project leader and developer\n\n"
|
||||
|
45
src/jinete/jcustom_label.cpp
Normal file
45
src/jinete/jcustom_label.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
/* Jinete - a GUI library
|
||||
* Copyright (C) 2003-2010 David Capello.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of the author nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "jinete/jcustom_label.h"
|
||||
|
||||
CustomLabel::CustomLabel(const char *text)
|
||||
: Label(text)
|
||||
{
|
||||
}
|
||||
|
||||
bool CustomLabel::msg_proc(JMessage msg)
|
||||
{
|
||||
return Label::msg_proc(msg);
|
||||
}
|
47
src/jinete/jcustom_label.h
Normal file
47
src/jinete/jcustom_label.h
Normal file
@ -0,0 +1,47 @@
|
||||
/* Jinete - a GUI library
|
||||
* Copyright (C) 2003-2010 David Capello.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of the author nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef JINETE_JCUSTOM_LABEL_H_INCLUDED
|
||||
#define JINETE_JCUSTOM_LABEL_H_INCLUDED
|
||||
|
||||
#include "jinete/jlabel.h"
|
||||
|
||||
class CustomLabel : public Label
|
||||
{
|
||||
public:
|
||||
CustomLabel(const char *text);
|
||||
|
||||
protected:
|
||||
virtual bool msg_proc(JMessage msg);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
@ -39,6 +39,7 @@
|
||||
#include "jinete/jbutton.h"
|
||||
#include "jinete/jclipboard.h"
|
||||
#include "jinete/jcombobox.h"
|
||||
#include "jinete/jcustom_label.h"
|
||||
#include "jinete/jdraw.h"
|
||||
#include "jinete/jentry.h"
|
||||
#include "jinete/jexception.h"
|
||||
@ -49,6 +50,7 @@
|
||||
#include "jinete/jhook.h"
|
||||
#include "jinete/jimage.h"
|
||||
#include "jinete/jlabel.h"
|
||||
#include "jinete/jlink_label.h"
|
||||
#include "jinete/jlist.h"
|
||||
#include "jinete/jlistbox.h"
|
||||
#include "jinete/jmanager.h"
|
||||
|
86
src/jinete/jlink_label.cpp
Normal file
86
src/jinete/jlink_label.cpp
Normal file
@ -0,0 +1,86 @@
|
||||
/* Jinete - a GUI library
|
||||
* Copyright (C) 2003-2010 David Capello.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of the author nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "jinete/jlink_label.h"
|
||||
#include "jinete/jmessage.h"
|
||||
#include "jinete/jtheme.h"
|
||||
#include "jinete/jsystem.h"
|
||||
#include "launcher.h"
|
||||
|
||||
LinkLabel::LinkLabel(const char* urlOrText)
|
||||
: CustomLabel(urlOrText)
|
||||
, m_url(urlOrText)
|
||||
{
|
||||
}
|
||||
|
||||
LinkLabel::LinkLabel(const char* url, const char* text)
|
||||
: CustomLabel(text)
|
||||
, m_url(url)
|
||||
{
|
||||
}
|
||||
|
||||
bool LinkLabel::msg_proc(JMessage msg)
|
||||
{
|
||||
switch (msg->type) {
|
||||
|
||||
case JM_SETCURSOR:
|
||||
// TODO theme stuff
|
||||
if (jwidget_is_enabled(this)) {
|
||||
jmouse_set_cursor(JI_CURSOR_HAND);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
case JM_MOUSEENTER:
|
||||
case JM_MOUSELEAVE:
|
||||
// TODO theme stuff
|
||||
if (jwidget_is_enabled(this))
|
||||
jwidget_dirty(this);
|
||||
break;
|
||||
|
||||
case JM_DRAW:
|
||||
this->theme->draw_link_label(this, &msg->draw.rect);
|
||||
return true;
|
||||
|
||||
case JM_BUTTONRELEASED:
|
||||
if (jwidget_is_enabled(this)) {
|
||||
if (!m_url.empty())
|
||||
Launcher::openUrl(m_url);
|
||||
Click();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return CustomLabel::msg_proc(msg);
|
||||
}
|
54
src/jinete/jlink_label.h
Normal file
54
src/jinete/jlink_label.h
Normal file
@ -0,0 +1,54 @@
|
||||
/* Jinete - a GUI library
|
||||
* Copyright (C) 2003-2010 David Capello.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of the author nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef JINETE_JLINK_LABEL_H_INCLUDED
|
||||
#define JINETE_JLINK_LABEL_H_INCLUDED
|
||||
|
||||
#include "Vaca/Signal.h"
|
||||
#include "jinete/jcustom_label.h"
|
||||
#include <string>
|
||||
|
||||
class LinkLabel : public CustomLabel
|
||||
{
|
||||
std::string m_url;
|
||||
|
||||
public:
|
||||
LinkLabel(const char* urlOrText);
|
||||
LinkLabel(const char* url, const char* text);
|
||||
|
||||
Vaca::Signal0<void> Click;
|
||||
|
||||
protected:
|
||||
virtual bool msg_proc(JMessage msg);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
@ -72,6 +72,7 @@ public:
|
||||
virtual void draw_entry(JWidget widget, JRect clip) = 0;
|
||||
virtual void draw_grid(JWidget widget, JRect clip) = 0;
|
||||
virtual void draw_label(JWidget widget, JRect clip) = 0;
|
||||
virtual void draw_link_label(JWidget widget, JRect clip) = 0;
|
||||
virtual void draw_listbox(JWidget widget, JRect clip) = 0;
|
||||
virtual void draw_listitem(JWidget widget, JRect clip) = 0;
|
||||
virtual void draw_menu(JWidget widget, JRect clip) = 0;
|
||||
|
@ -117,6 +117,7 @@ public:
|
||||
void draw_entry(JWidget widget, JRect clip);
|
||||
void draw_grid(JWidget widget, JRect clip);
|
||||
void draw_label(JWidget widget, JRect clip);
|
||||
void draw_link_label(JWidget widget, JRect clip);
|
||||
void draw_listbox(JWidget widget, JRect clip);
|
||||
void draw_listitem(JWidget widget, JRect clip);
|
||||
void draw_menu(JWidget widget, JRect clip);
|
||||
@ -724,6 +725,23 @@ void jstandard_theme::draw_label(JWidget widget, JRect clip)
|
||||
draw_textstring(NULL, -1, bg, false, widget, widget->rc, 0);
|
||||
}
|
||||
|
||||
void jstandard_theme::draw_link_label(JWidget widget, JRect clip)
|
||||
{
|
||||
int bg = get_bg_color(widget);
|
||||
|
||||
jdraw_rectfill(widget->rc, bg);
|
||||
|
||||
draw_textstring(NULL, makecol(0, 0, 255), bg, false, widget, widget->rc, 0);
|
||||
|
||||
if (widget->hasMouseOver()) {
|
||||
int w = jwidget_get_text_length(widget);
|
||||
int h = jwidget_get_text_height(widget);
|
||||
|
||||
hline(ji_screen,
|
||||
widget->rc->x1, widget->rc->y2-1, widget->rc->x1+w-1, makecol(0, 0, 255));
|
||||
}
|
||||
}
|
||||
|
||||
void jstandard_theme::draw_listbox(JWidget widget, JRect clip)
|
||||
{
|
||||
int bg;
|
||||
|
@ -829,6 +829,23 @@ void SkinneableTheme::draw_label(JWidget widget, JRect clip)
|
||||
draw_textstring(NULL, -1, bg, false, widget, widget->rc, 0);
|
||||
}
|
||||
|
||||
void SkinneableTheme::draw_link_label(JWidget widget, JRect clip)
|
||||
{
|
||||
int bg = BGCOLOR;
|
||||
|
||||
jdraw_rectfill(widget->rc, bg);
|
||||
|
||||
draw_textstring(NULL, makecol(0, 0, 255), bg, false, widget, widget->rc, 0);
|
||||
|
||||
if (widget->hasMouseOver()) {
|
||||
int w = jwidget_get_text_length(widget);
|
||||
int h = jwidget_get_text_height(widget);
|
||||
|
||||
hline(ji_screen,
|
||||
widget->rc->x1, widget->rc->y2-1, widget->rc->x1+w-1, makecol(0, 0, 255));
|
||||
}
|
||||
}
|
||||
|
||||
void SkinneableTheme::draw_listbox(JWidget widget, JRect clip)
|
||||
{
|
||||
jdraw_rectfill(widget->rc, COLOR_BACKGROUND);
|
||||
|
@ -438,6 +438,7 @@ public:
|
||||
void draw_entry(JWidget widget, JRect clip);
|
||||
void draw_grid(JWidget widget, JRect clip);
|
||||
void draw_label(JWidget widget, JRect clip);
|
||||
void draw_link_label(JWidget widget, JRect clip);
|
||||
void draw_listbox(JWidget widget, JRect clip);
|
||||
void draw_listitem(JWidget widget, JRect clip);
|
||||
void draw_menu(JWidget widget, JRect clip);
|
||||
|
Loading…
x
Reference in New Issue
Block a user