-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Temporary commit (will be removed by rebase)
- Loading branch information
Dotsenko Andrey
committed
Oct 23, 2016
1 parent
a5b6ede
commit 389cbd5
Showing
7 changed files
with
374 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
--- | ||
Language: Cpp | ||
Standard: Cpp11 | ||
AccessModifierOffset: -2 | ||
AlignAfterOpenBracket: true | ||
AlignEscapedNewlinesLeft: false | ||
AlignOperands: true | ||
AlignTrailingComments: true | ||
AllowAllParametersOfDeclarationOnNextLine: true | ||
AllowShortBlocksOnASingleLine: false | ||
AllowShortCaseLabelsOnASingleLine: false | ||
AllowShortIfStatementsOnASingleLine: false | ||
AllowShortLoopsOnASingleLine: false | ||
AllowShortFunctionsOnASingleLine: false | ||
AlwaysBreakAfterDefinitionReturnType: false | ||
AlwaysBreakTemplateDeclarations: false | ||
AlwaysBreakBeforeMultilineStrings: false | ||
BreakBeforeBinaryOperators: None | ||
BreakBeforeTernaryOperators: false | ||
BreakConstructorInitializersBeforeComma: false | ||
BinPackParameters: false | ||
BinPackArguments: false | ||
ColumnLimit: 80 | ||
ConstructorInitializerAllOnOneLineOrOnePerLine: false | ||
ConstructorInitializerIndentWidth: 4 | ||
DerivePointerAlignment: false | ||
ExperimentalAutoDetectBinPacking: false | ||
IndentCaseLabels: false | ||
IndentWrappedFunctionNames: false | ||
IndentFunctionDeclarationAfterType: false | ||
MaxEmptyLinesToKeep: 1 | ||
KeepEmptyLinesAtTheStartOfBlocks: true | ||
NamespaceIndentation: None | ||
ObjCBlockIndentWidth: 2 | ||
ObjCSpaceAfterProperty: false | ||
ObjCSpaceBeforeProtocolList: true | ||
PenaltyBreakBeforeFirstCallParameter: 19 | ||
PenaltyBreakComment: 300 | ||
PenaltyBreakString: 1000 | ||
PenaltyBreakFirstLessLess: 120 | ||
PenaltyExcessCharacter: 1000000 | ||
PenaltyReturnTypeOnItsOwnLine: 15 | ||
PointerAlignment: Right | ||
SpacesBeforeTrailingComments: 1 | ||
Cpp11BracedListStyle: true | ||
Standard: Cpp11 | ||
IndentWidth: 4 | ||
TabWidth: 4 | ||
UseTab: Never | ||
BreakBeforeBraces: Linux | ||
SpacesInParentheses: false | ||
SpacesInSquareBrackets: false | ||
SpacesInAngles: false | ||
SpaceInEmptyParentheses: false | ||
SpacesInCStyleCastParentheses: false | ||
SpaceAfterCStyleCast: true | ||
SpacesInContainerLiterals: true | ||
SpaceBeforeAssignmentOperators: true | ||
ContinuationIndentWidth: 8 | ||
ForEachMacros: [ foreach ] | ||
SpaceBeforeParens: ControlStatements | ||
DisableFormat: false | ||
ForEachMacros: [] | ||
MacroBlockBegin: "^START_TEST$" | ||
MacroBlockEnd: "^END_TEST$" | ||
... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Eclipse project file and directories | ||
.cproject | ||
.project | ||
.settings | ||
# Backup files made automatically by text editor | ||
*~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
cmake_minimum_required(VERSION 2.8) | ||
|
||
include(FindPkgConfig) | ||
|
||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11 -Werror=unused-result -Werror=format -Werror=implicit -Werror=return-type -Werror=uninitialized -Wno-deprecated -fPIE -pie -Wl,-z,relro") | ||
|
||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -O0 -fstack-check -fbounds-check") | ||
|
||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O0 -fstack-protector-all -Wall") | ||
|
||
set(PROJECT_NAME emdevgtk) | ||
|
||
if(NOT DEFINED LIBDIR) | ||
if(CMAKE_INSTALL_PREFIX STREQUAL "") | ||
set(LIBDIR "/usr/lib/${PROJECT_NAME}") | ||
elseif(CMAKE_INSTALL_PREFIX STREQUAL "/opt") | ||
set(LIBDIR "/opt/${PROJECT_NAME}/lib") | ||
elseif(CMAKE_INSTALL_PREFIX STREQUAL "/usr/local") | ||
set(LIBDIR "/usr/local/lib/${PROJECT_NAME}") | ||
elseif(DEFINED CMAKE_INSTALL_PREFIX) | ||
set(LIBDIR "${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/lib") | ||
else() | ||
set(LIBDIR "/usr/local/lib/${PROJECT_NAME}") | ||
endif() | ||
endif() | ||
|
||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/gtk3/gtk+/gtk") | ||
|
||
add_subdirectory(gtkwheelcontrol) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
pkg_check_modules(GTK3 REQUIRED gtk+-3.0) | ||
|
||
include_directories( | ||
${GTK3_INCLUDE_DIRS} | ||
) | ||
|
||
link_directories( | ||
${GTK3_LIBRARY_DIRS} | ||
) | ||
|
||
add_definitions(${GTK3_CFLAGS_OTHER}) | ||
|
||
set(GTKCNCWIDGETS_SRCS | ||
gtkwheelcontrol.c | ||
) | ||
|
||
add_library(gtkwheelcontrol SHARED | ||
${GTKCNCWIDGETS_SRCS} | ||
) | ||
|
||
target_link_libraries(gtkwheelcontrol | ||
${GTK3_LIBRARIES} | ||
) | ||
|
||
message("${LIBDIR}") | ||
|
||
install(TARGETS | ||
gtkwheelcontrol | ||
DESTINATION | ||
"${LIBDIR}" | ||
COMPONENT | ||
libraries | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
#include <glib.h> | ||
#include <stdlib.h> | ||
|
||
#include "gtkwheelcontrol_priv.h" | ||
|
||
/*! | ||
* Перечисление свойств виджета. | ||
*/ | ||
enum { | ||
PROP_0 = 0, //!< Код 0 использовать нельзя. | ||
PROP_ROUND_OFFSET, | ||
PROP_ROUND_LENGTH | ||
}; | ||
|
||
//! Регистрация типа данных GtkWheelControl с объявлением служебных функций. | ||
G_DEFINE_TYPE_WITH_PRIVATE(GtkWheelControl, gtk_wheel_control, GTK_TYPE_WIDGET); | ||
|
||
static void gtk_wheel_control_finalize(GObject *object) | ||
{ | ||
GtkWheelControl *wheel_control = GTK_WHEEL_CONTROL(object); | ||
GtkWheelControlPrivate *priv = | ||
gtk_wheel_control_get_instance_private(wheel_control); | ||
|
||
G_OBJECT_CLASS(gtk_wheel_control_parent_class)->finalize(object); | ||
} | ||
|
||
void gtk_wheel_control_set_length(GtkWheelControl *wheel_control, | ||
gdouble length) | ||
{ | ||
GtkWheelControlPrivate *priv = | ||
gtk_wheel_control_get_instance_private(wheel_control); | ||
|
||
priv->round_length = length; | ||
} | ||
|
||
void gtk_wheel_control_set_offset(GtkWheelControl *wheel_control, | ||
gdouble offset) | ||
{ | ||
GtkWheelControlPrivate *priv = | ||
gtk_wheel_control_get_instance_private(wheel_control); | ||
|
||
priv->round_offset = offset; | ||
} | ||
|
||
static void gtk_wheel_control_set_property(GObject *object, | ||
guint prop_id, | ||
const GValue *value, | ||
GParamSpec *pspec) | ||
{ | ||
GtkWheelControl *wheel_control = GTK_WHEEL_CONTROL(object); | ||
GtkWheelControlPrivate *priv = | ||
gtk_wheel_control_get_instance_private(wheel_control); | ||
|
||
switch (prop_id) { | ||
case PROP_ROUND_LENGTH: | ||
gtk_wheel_control_set_length(wheel_control, g_value_get_double(value)); | ||
break; | ||
case PROP_ROUND_OFFSET: | ||
gtk_wheel_control_set_offset(wheel_control, g_value_get_double(value)); | ||
break; | ||
default: | ||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); | ||
break; | ||
} | ||
} | ||
|
||
//! Получение значения свойства виджета по его идентификатору. | ||
static void gtk_wheel_control_get_property(GObject *object, | ||
guint prop_id, | ||
GValue *value, | ||
GParamSpec *pspec) | ||
{ | ||
GtkWheelControl *wheel_control = GTK_WHEEL_CONTROL(object); | ||
GtkWheelControlPrivate *priv = | ||
gtk_wheel_control_get_instance_private(wheel_control); | ||
|
||
switch (prop_id) { | ||
case PROP_ROUND_OFFSET: | ||
g_value_set_double(value, priv->round_length); | ||
break; | ||
case PROP_ROUND_LENGTH: | ||
g_value_set_double(value, priv->round_offset); | ||
break; | ||
default: | ||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); | ||
break; | ||
} | ||
} | ||
|
||
static gboolean gtk_wheel_control_draw(GtkWidget *widget, cairo_t *cr) | ||
{ | ||
gtk_css_gadget_draw(GTK_LABEL(widget)->priv->gadget, cr); | ||
|
||
return FALSE; | ||
} | ||
|
||
//! Инициализация класса виджета. | ||
static void gtk_wheel_control_class_init(GtkWheelControlClass *klass) | ||
{ | ||
GObjectClass *gobject_class = G_OBJECT_CLASS(klass); | ||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); | ||
|
||
gobject_class->get_property = gtk_wheel_control_get_property; | ||
gobject_class->set_property = gtk_wheel_control_set_property; | ||
|
||
gobject_class->finalize = gtk_wheel_control_finalize; | ||
|
||
widget_class->draw = gtk_wheel_control_draw; | ||
|
||
g_object_class_install_property(gobject_class, | ||
PROP_ROUND_LENGTH, | ||
g_param_spec_double("length", | ||
("Round length"), | ||
("One round length"), | ||
-G_MAXDOUBLE, | ||
G_MAXDOUBLE, | ||
0, | ||
G_PARAM_READWRITE)); | ||
g_object_class_install_property( | ||
gobject_class, | ||
PROP_ROUND_OFFSET, | ||
g_param_spec_double("offset", | ||
("Round offset"), | ||
("Offset relative to upper point"), | ||
-G_MAXDOUBLE, | ||
G_MAXDOUBLE, | ||
0, | ||
G_PARAM_READWRITE)); | ||
} | ||
|
||
//! Инициализация виджета (при создании). | ||
static void gtk_wheel_control_init(GtkWheelControl *wheel_control) | ||
{ | ||
GtkWidget *widget = GTK_WIDGET(wheel_control); | ||
|
||
GtkWheelControlPrivate *priv = | ||
gtk_wheel_control_get_instance_private(wheel_control); | ||
|
||
wheel_control->priv = priv; | ||
priv->self = GTK_WIDGET(wheel_control); | ||
|
||
priv->round_length = 1.0; | ||
|
||
priv->round_offset = 0; | ||
} | ||
|
||
//! Функция создания виджета. | ||
GtkWidget *gtk_wheel_control_new(void) | ||
{ | ||
// вызов конструктора класса с передачей в конструктор параметров. | ||
GtkWidget *wheel_control = GTK_WIDGET( | ||
g_object_new(GTK_TYPE_WHEEL_CONTROL, NULL)); | ||
|
||
return wheel_control; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#ifndef GTK_WHEEL_CONTROL_H_ | ||
#define GTK_WHEEL_CONTROL_H_ | ||
|
||
#include <gtk/gtk.h> | ||
|
||
G_BEGIN_DECLS | ||
|
||
#define GTK_TYPE_WHEEL_CONTROL (gtk_wheel_control_get_type()) | ||
|
||
#define GTK_WHEEL_CONTROL(obj) \ | ||
(G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_WHEEL_CONTROL, GtkWheelControl)) | ||
|
||
#define GTK_WHEEL_CONTROL_CLASS(klass) \ | ||
(G_TYPE_CHECK_CLASS_CAST( \ | ||
(klass), GTK_TYPE_WHEEL_CONTROL, GtkWheelControlClass)) | ||
|
||
#define GTK_IS_WHEEL_CONTROL(obj) \ | ||
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_WHEEL_CONTROL)) | ||
|
||
#define GTK_IS_WHEEL_CONTROLCLASS(klass) \ | ||
(G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_WHEEL_CONTROL)) | ||
|
||
#define GTK_WHEEL_CONTROL_GET_CLASS(obj) \ | ||
(G_TYPE_INSTANCE_GET_CLASS( \ | ||
(obj), GTK_TYPE_WHEEL_CONTROL, GtkWheelControlClass)) | ||
|
||
typedef struct _GtkWheelControl GtkWheelControl; | ||
typedef struct _GtkWheelControlPrivate GtkWheelControlPrivate; | ||
typedef struct _GtkWheelControlClass GtkWheelControlClass; | ||
|
||
struct _GtkWheelControl { | ||
GtkWidget box; | ||
|
||
GtkWheelControlPrivate *priv; | ||
}; | ||
|
||
struct _GtkWheelControlClass { | ||
GtkWidgetClass parent_class; | ||
|
||
void (*reserved0)(void); | ||
void (*reserved1)(void); | ||
void (*reserved2)(void); | ||
void (*reserved3)(void); | ||
void (*reserved4)(void); | ||
void (*reserved5)(void); | ||
void (*reserved6)(void); | ||
void (*reserved7)(void); | ||
}; | ||
|
||
void gtk_wheel_control_set_length(GtkWheelControl *wheel_control, | ||
gdouble length); | ||
void gtk_wheel_control_set_offset(GtkWheelControl *wheel_control, | ||
gdouble offset); | ||
|
||
G_END_DECLS | ||
|
||
#endif /* GTK_WHEEL_CONTROL_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#ifndef GTK_WHEEL_CONTROL_PRIV_H_ | ||
#define GTK_WHEEL_CONTROL_PRIV_H_ | ||
|
||
#include <gtk/gtk.h> | ||
|
||
#include "gtkwheelcontrol.h" | ||
#include "gtkcsscustomgadget.h" | ||
|
||
G_BEGIN_DECLS | ||
|
||
//! Внутренние данные виджета. | ||
struct _GtkWheelControlPrivate { | ||
GtkWidget *self; | ||
|
||
GtkCssGadget *gadget; | ||
|
||
gdouble round_length; | ||
gdouble round_offset; | ||
}; | ||
|
||
G_END_DECLS | ||
|
||
#endif /* GTK_WHEEL_CONTROL_PRIV_H_ */ |