From bb22e7b2a0af67cc65ce5179917b20e5977ed4ef Mon Sep 17 00:00:00 2001 From: Vadim Dashevskiy Date: Wed, 11 Jul 2012 17:09:09 +0000 Subject: MyDetails reverted to older version that doesn't use Skins plugin git-svn-id: http://svn.miranda-ng.org/main/trunk@905 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MyDetails/Docs/Skins/Default/MyDetails.msk | 399 --- plugins/MyDetails/Docs/Skins/Pidgin/MyDetails.msk | 59 - plugins/MyDetails/Docs/mydetails_changelog.txt | 32 - plugins/MyDetails/Docs/mydetails_readme.txt | 10 - plugins/MyDetails/Docs/mydetails_version.txt | 2 +- plugins/MyDetails/commons.h | 48 +- plugins/MyDetails/data.cpp | 714 ++-- plugins/MyDetails/data.h | 120 +- plugins/MyDetails/frame.cpp | 2446 ++++++++----- plugins/MyDetails/frame.h | 4 +- plugins/MyDetails/m_simpleaway.h | 20 + plugins/MyDetails/mydetails.cpp | 396 +-- plugins/MyDetails/mydetails.dsp | 223 ++ plugins/MyDetails/mydetails.dsw | 29 + plugins/MyDetails/options.cpp | 19 +- plugins/MyDetails/options.h | 16 +- plugins/MyDetails/res/mail.ico | Bin 2550 -> 0 bytes plugins/MyDetails/resource.h | 3 +- plugins/MyDetails/resource.rc | 98 +- plugins/MyDetails/sdk/m_NewAwaySys.h | 119 + plugins/MyDetails/sdk/m_avatars.h | 297 ++ plugins/MyDetails/sdk/m_cluiframes.h | 338 ++ plugins/MyDetails/sdk/m_ersatz.h | 40 + plugins/MyDetails/sdk/m_listeningto.h | 56 + plugins/MyDetails/sdk/m_metacontacts.h | 162 + plugins/MyDetails/sdk/m_proto_listeningto.h | 137 + plugins/MyDetails/sdk/m_smileyadd.h | 172 + plugins/MyDetails/sdk/m_statusplugins.h | 156 + plugins/MyDetails/sdk/m_updater.h | 146 + plugins/MyDetails/sdk/m_variables.h | 668 ++++ plugins/Skins/Docs/langpack_skins.txt | 2 - plugins/Skins/Docs/skins_changelog.txt | 25 - plugins/Skins/Docs/skins_readme.txt | 31 - plugins/Skins/Docs/skins_version.txt | 1 - plugins/Skins/MirandaField.h | 14 - plugins/Skins/MirandaFont.cpp | 87 - plugins/Skins/MirandaFont.h | 28 - plugins/Skins/MirandaIconField.cpp | 19 - plugins/Skins/MirandaIconField.h | 21 - plugins/Skins/MirandaImageField.cpp | 19 - plugins/Skins/MirandaImageField.h | 21 - plugins/Skins/MirandaSkinnedDialog.cpp | 252 -- plugins/Skins/MirandaSkinnedDialog.h | 64 - plugins/Skins/MirandaTextField.cpp | 27 - plugins/Skins/MirandaTextField.h | 27 - plugins/Skins/SkinLib/BorderState.cpp | 61 - plugins/Skins/SkinLib/BorderState.h | 28 - plugins/Skins/SkinLib/BorderState_v8_wrapper.cpp | 160 - plugins/Skins/SkinLib/BorderState_v8_wrapper.h | 10 - plugins/Skins/SkinLib/ButtonField.cpp | 22 - plugins/Skins/SkinLib/ButtonField.h | 19 - plugins/Skins/SkinLib/ButtonFieldState.cpp | 30 - plugins/Skins/SkinLib/ButtonFieldState.h | 23 - .../Skins/SkinLib/ButtonFieldState_v8_wrapper.cpp | 20 - .../Skins/SkinLib/ButtonFieldState_v8_wrapper.h | 10 - plugins/Skins/SkinLib/ControlField.cpp | 123 - plugins/Skins/SkinLib/ControlField.h | 37 - plugins/Skins/SkinLib/ControlFieldState.cpp | 86 - plugins/Skins/SkinLib/ControlFieldState.h | 39 - .../Skins/SkinLib/ControlFieldState_v8_wrapper.cpp | 59 - .../Skins/SkinLib/ControlFieldState_v8_wrapper.h | 10 - plugins/Skins/SkinLib/Dialog.cpp | 100 - plugins/Skins/SkinLib/Dialog.h | 41 - plugins/Skins/SkinLib/DialogInfo.cpp | 190 - plugins/Skins/SkinLib/DialogInfo.h | 50 - plugins/Skins/SkinLib/DialogState.cpp | 132 - plugins/Skins/SkinLib/DialogState.h | 59 - plugins/Skins/SkinLib/DialogState_v8_wrapper.cpp | 233 -- plugins/Skins/SkinLib/DialogState_v8_wrapper.h | 10 - plugins/Skins/SkinLib/EditField.cpp | 23 - plugins/Skins/SkinLib/EditField.h | 19 - plugins/Skins/SkinLib/EditFieldState.cpp | 58 - plugins/Skins/SkinLib/EditFieldState.h | 24 - .../Skins/SkinLib/EditFieldState_v8_wrapper.cpp | 20 - plugins/Skins/SkinLib/EditFieldState_v8_wrapper.h | 10 - plugins/Skins/SkinLib/Field.cpp | 56 - plugins/Skins/SkinLib/Field.h | 66 - plugins/Skins/SkinLib/FieldState.cpp | 303 -- plugins/Skins/SkinLib/FieldState.h | 108 - plugins/Skins/SkinLib/FieldState.rec | 89 - plugins/Skins/SkinLib/FieldState_v8_wrapper.cpp | 539 --- plugins/Skins/SkinLib/FieldState_v8_wrapper.h | 10 - plugins/Skins/SkinLib/FontState.cpp | 186 - plugins/Skins/SkinLib/FontState.h | 57 - plugins/Skins/SkinLib/FontState_v8_wrapper.cpp | 269 -- plugins/Skins/SkinLib/FontState_v8_wrapper.h | 10 - plugins/Skins/SkinLib/IconField.cpp | 38 - plugins/Skins/SkinLib/IconField.h | 27 - plugins/Skins/SkinLib/IconFieldState.cpp | 37 - plugins/Skins/SkinLib/IconFieldState.h | 28 - .../Skins/SkinLib/IconFieldState_v8_wrapper.cpp | 20 - plugins/Skins/SkinLib/IconFieldState_v8_wrapper.h | 10 - plugins/Skins/SkinLib/ImageField.cpp | 38 - plugins/Skins/SkinLib/ImageField.h | 26 - plugins/Skins/SkinLib/ImageFieldState.cpp | 37 - plugins/Skins/SkinLib/ImageFieldState.h | 28 - .../Skins/SkinLib/ImageFieldState_v8_wrapper.cpp | 20 - plugins/Skins/SkinLib/ImageFieldState_v8_wrapper.h | 10 - plugins/Skins/SkinLib/LabelField.cpp | 23 - plugins/Skins/SkinLib/LabelField.h | 20 - plugins/Skins/SkinLib/LabelFieldState.cpp | 35 - plugins/Skins/SkinLib/LabelFieldState.h | 25 - .../Skins/SkinLib/LabelFieldState_v8_wrapper.cpp | 20 - plugins/Skins/SkinLib/LabelFieldState_v8_wrapper.h | 10 - plugins/Skins/SkinLib/Position.cpp | 9 - plugins/Skins/SkinLib/Position.h | 16 - plugins/Skins/SkinLib/Size.cpp | 84 - plugins/Skins/SkinLib/Size.h | 27 - plugins/Skins/SkinLib/SkinOption.h | 1 - plugins/Skins/SkinLib/SkinOption_v8_wrapper.cpp | 179 - plugins/Skins/SkinLib/SkinOption_v8_wrapper.h | 10 - plugins/Skins/SkinLib/SkinOptions.cpp | 216 -- plugins/Skins/SkinLib/SkinOptions.h | 98 - plugins/Skins/SkinLib/SkinnedDialog.cpp | 235 -- plugins/Skins/SkinLib/SkinnedDialog.h | 89 - plugins/Skins/SkinLib/TextField.cpp | 78 - plugins/Skins/SkinLib/TextField.h | 35 - plugins/Skins/SkinLib/TextFieldState.cpp | 65 - plugins/Skins/SkinLib/TextFieldState.h | 38 - .../Skins/SkinLib/TextFieldState_v8_wrapper.cpp | 59 - plugins/Skins/SkinLib/TextFieldState_v8_wrapper.h | 10 - plugins/Skins/SkinLib/V8Script.cpp | 236 -- plugins/Skins/SkinLib/V8Script.h | 46 - plugins/Skins/SkinLib/V8Templates.cpp | 475 --- plugins/Skins/SkinLib/V8Templates.h | 114 - plugins/Skins/SkinLib/V8Wrappers.cpp | 385 -- plugins/Skins/SkinLib/V8Wrappers.h | 35 - plugins/Skins/SkinLib/globals.h | 20 - plugins/Skins/SkinLib/scope.h | 37 - plugins/Skins/SkinLib/tstring.h | 13 - plugins/Skins/commons.h | 119 - plugins/Skins/libs/v8-debug.h | 384 -- plugins/Skins/libs/v8.h | 3686 -------------------- plugins/Skins/libs/v8.lib | Bin 34627500 -> 0 bytes plugins/Skins/libs/v8_g.lib | Bin 40003716 -> 0 bytes plugins/Skins/options.cpp | 487 --- plugins/Skins/options.h | 47 - plugins/Skins/resource.h | 22 - plugins/Skins/resource.rc | 111 - plugins/Skins/skins.cpp | 968 ----- plugins/Skins/skins.vcproj | 1066 ------ 141 files changed, 4641 insertions(+), 16277 deletions(-) delete mode 100644 plugins/MyDetails/Docs/Skins/Default/MyDetails.msk delete mode 100644 plugins/MyDetails/Docs/Skins/Pidgin/MyDetails.msk create mode 100644 plugins/MyDetails/m_simpleaway.h create mode 100644 plugins/MyDetails/mydetails.dsp create mode 100644 plugins/MyDetails/mydetails.dsw delete mode 100644 plugins/MyDetails/res/mail.ico create mode 100644 plugins/MyDetails/sdk/m_NewAwaySys.h create mode 100644 plugins/MyDetails/sdk/m_avatars.h create mode 100644 plugins/MyDetails/sdk/m_cluiframes.h create mode 100644 plugins/MyDetails/sdk/m_ersatz.h create mode 100644 plugins/MyDetails/sdk/m_listeningto.h create mode 100644 plugins/MyDetails/sdk/m_metacontacts.h create mode 100644 plugins/MyDetails/sdk/m_proto_listeningto.h create mode 100644 plugins/MyDetails/sdk/m_smileyadd.h create mode 100644 plugins/MyDetails/sdk/m_statusplugins.h create mode 100644 plugins/MyDetails/sdk/m_updater.h create mode 100644 plugins/MyDetails/sdk/m_variables.h delete mode 100644 plugins/Skins/Docs/langpack_skins.txt delete mode 100644 plugins/Skins/Docs/skins_changelog.txt delete mode 100644 plugins/Skins/Docs/skins_readme.txt delete mode 100644 plugins/Skins/Docs/skins_version.txt delete mode 100644 plugins/Skins/MirandaField.h delete mode 100644 plugins/Skins/MirandaFont.cpp delete mode 100644 plugins/Skins/MirandaFont.h delete mode 100644 plugins/Skins/MirandaIconField.cpp delete mode 100644 plugins/Skins/MirandaIconField.h delete mode 100644 plugins/Skins/MirandaImageField.cpp delete mode 100644 plugins/Skins/MirandaImageField.h delete mode 100644 plugins/Skins/MirandaSkinnedDialog.cpp delete mode 100644 plugins/Skins/MirandaSkinnedDialog.h delete mode 100644 plugins/Skins/MirandaTextField.cpp delete mode 100644 plugins/Skins/MirandaTextField.h delete mode 100644 plugins/Skins/SkinLib/BorderState.cpp delete mode 100644 plugins/Skins/SkinLib/BorderState.h delete mode 100644 plugins/Skins/SkinLib/BorderState_v8_wrapper.cpp delete mode 100644 plugins/Skins/SkinLib/BorderState_v8_wrapper.h delete mode 100644 plugins/Skins/SkinLib/ButtonField.cpp delete mode 100644 plugins/Skins/SkinLib/ButtonField.h delete mode 100644 plugins/Skins/SkinLib/ButtonFieldState.cpp delete mode 100644 plugins/Skins/SkinLib/ButtonFieldState.h delete mode 100644 plugins/Skins/SkinLib/ButtonFieldState_v8_wrapper.cpp delete mode 100644 plugins/Skins/SkinLib/ButtonFieldState_v8_wrapper.h delete mode 100644 plugins/Skins/SkinLib/ControlField.cpp delete mode 100644 plugins/Skins/SkinLib/ControlField.h delete mode 100644 plugins/Skins/SkinLib/ControlFieldState.cpp delete mode 100644 plugins/Skins/SkinLib/ControlFieldState.h delete mode 100644 plugins/Skins/SkinLib/ControlFieldState_v8_wrapper.cpp delete mode 100644 plugins/Skins/SkinLib/ControlFieldState_v8_wrapper.h delete mode 100644 plugins/Skins/SkinLib/Dialog.cpp delete mode 100644 plugins/Skins/SkinLib/Dialog.h delete mode 100644 plugins/Skins/SkinLib/DialogInfo.cpp delete mode 100644 plugins/Skins/SkinLib/DialogInfo.h delete mode 100644 plugins/Skins/SkinLib/DialogState.cpp delete mode 100644 plugins/Skins/SkinLib/DialogState.h delete mode 100644 plugins/Skins/SkinLib/DialogState_v8_wrapper.cpp delete mode 100644 plugins/Skins/SkinLib/DialogState_v8_wrapper.h delete mode 100644 plugins/Skins/SkinLib/EditField.cpp delete mode 100644 plugins/Skins/SkinLib/EditField.h delete mode 100644 plugins/Skins/SkinLib/EditFieldState.cpp delete mode 100644 plugins/Skins/SkinLib/EditFieldState.h delete mode 100644 plugins/Skins/SkinLib/EditFieldState_v8_wrapper.cpp delete mode 100644 plugins/Skins/SkinLib/EditFieldState_v8_wrapper.h delete mode 100644 plugins/Skins/SkinLib/Field.cpp delete mode 100644 plugins/Skins/SkinLib/Field.h delete mode 100644 plugins/Skins/SkinLib/FieldState.cpp delete mode 100644 plugins/Skins/SkinLib/FieldState.h delete mode 100644 plugins/Skins/SkinLib/FieldState.rec delete mode 100644 plugins/Skins/SkinLib/FieldState_v8_wrapper.cpp delete mode 100644 plugins/Skins/SkinLib/FieldState_v8_wrapper.h delete mode 100644 plugins/Skins/SkinLib/FontState.cpp delete mode 100644 plugins/Skins/SkinLib/FontState.h delete mode 100644 plugins/Skins/SkinLib/FontState_v8_wrapper.cpp delete mode 100644 plugins/Skins/SkinLib/FontState_v8_wrapper.h delete mode 100644 plugins/Skins/SkinLib/IconField.cpp delete mode 100644 plugins/Skins/SkinLib/IconField.h delete mode 100644 plugins/Skins/SkinLib/IconFieldState.cpp delete mode 100644 plugins/Skins/SkinLib/IconFieldState.h delete mode 100644 plugins/Skins/SkinLib/IconFieldState_v8_wrapper.cpp delete mode 100644 plugins/Skins/SkinLib/IconFieldState_v8_wrapper.h delete mode 100644 plugins/Skins/SkinLib/ImageField.cpp delete mode 100644 plugins/Skins/SkinLib/ImageField.h delete mode 100644 plugins/Skins/SkinLib/ImageFieldState.cpp delete mode 100644 plugins/Skins/SkinLib/ImageFieldState.h delete mode 100644 plugins/Skins/SkinLib/ImageFieldState_v8_wrapper.cpp delete mode 100644 plugins/Skins/SkinLib/ImageFieldState_v8_wrapper.h delete mode 100644 plugins/Skins/SkinLib/LabelField.cpp delete mode 100644 plugins/Skins/SkinLib/LabelField.h delete mode 100644 plugins/Skins/SkinLib/LabelFieldState.cpp delete mode 100644 plugins/Skins/SkinLib/LabelFieldState.h delete mode 100644 plugins/Skins/SkinLib/LabelFieldState_v8_wrapper.cpp delete mode 100644 plugins/Skins/SkinLib/LabelFieldState_v8_wrapper.h delete mode 100644 plugins/Skins/SkinLib/Position.cpp delete mode 100644 plugins/Skins/SkinLib/Position.h delete mode 100644 plugins/Skins/SkinLib/Size.cpp delete mode 100644 plugins/Skins/SkinLib/Size.h delete mode 100644 plugins/Skins/SkinLib/SkinOption.h delete mode 100644 plugins/Skins/SkinLib/SkinOption_v8_wrapper.cpp delete mode 100644 plugins/Skins/SkinLib/SkinOption_v8_wrapper.h delete mode 100644 plugins/Skins/SkinLib/SkinOptions.cpp delete mode 100644 plugins/Skins/SkinLib/SkinOptions.h delete mode 100644 plugins/Skins/SkinLib/SkinnedDialog.cpp delete mode 100644 plugins/Skins/SkinLib/SkinnedDialog.h delete mode 100644 plugins/Skins/SkinLib/TextField.cpp delete mode 100644 plugins/Skins/SkinLib/TextField.h delete mode 100644 plugins/Skins/SkinLib/TextFieldState.cpp delete mode 100644 plugins/Skins/SkinLib/TextFieldState.h delete mode 100644 plugins/Skins/SkinLib/TextFieldState_v8_wrapper.cpp delete mode 100644 plugins/Skins/SkinLib/TextFieldState_v8_wrapper.h delete mode 100644 plugins/Skins/SkinLib/V8Script.cpp delete mode 100644 plugins/Skins/SkinLib/V8Script.h delete mode 100644 plugins/Skins/SkinLib/V8Templates.cpp delete mode 100644 plugins/Skins/SkinLib/V8Templates.h delete mode 100644 plugins/Skins/SkinLib/V8Wrappers.cpp delete mode 100644 plugins/Skins/SkinLib/V8Wrappers.h delete mode 100644 plugins/Skins/SkinLib/globals.h delete mode 100644 plugins/Skins/SkinLib/scope.h delete mode 100644 plugins/Skins/SkinLib/tstring.h delete mode 100644 plugins/Skins/commons.h delete mode 100644 plugins/Skins/libs/v8-debug.h delete mode 100644 plugins/Skins/libs/v8.h delete mode 100644 plugins/Skins/libs/v8.lib delete mode 100644 plugins/Skins/libs/v8_g.lib delete mode 100644 plugins/Skins/options.cpp delete mode 100644 plugins/Skins/options.h delete mode 100644 plugins/Skins/resource.h delete mode 100644 plugins/Skins/resource.rc delete mode 100644 plugins/Skins/skins.cpp delete mode 100644 plugins/Skins/skins.vcproj diff --git a/plugins/MyDetails/Docs/Skins/Default/MyDetails.msk b/plugins/MyDetails/Docs/Skins/Default/MyDetails.msk deleted file mode 100644 index 93c46b457a..0000000000 --- a/plugins/MyDetails/Docs/Skins/Default/MyDetails.msk +++ /dev/null @@ -1,399 +0,0 @@ -function configure() -{ - // Options for this skin - - opts.align_right.description = "Align to right" - opts.align_right.type = CHECKBOX - opts.align_right.value = false - - opts.show_avatar.description = "Show avatar" - opts.show_avatar.type = CHECKBOX - opts.show_avatar.value = true - - opts.avatar_allow_grow.description = "Allow avatar to grow (be bigger than original image)" - opts.avatar_allow_grow.type = CHECKBOX - opts.avatar_allow_grow.value = false - - opts.avatar_use_fixed_size.description = "Use fixed size avatar" - opts.avatar_use_fixed_size.type = CHECKBOX - opts.avatar_use_fixed_size.value = false - - opts.avatar_fixed_size.description = "Avatar fixed size (pixels)" - opts.avatar_fixed_size.type = NUMBER - opts.avatar_fixed_size.value = 30 - opts.avatar_fixed_size.min = 1 - opts.avatar_fixed_size.max = 255 - - opts.show_protocol.description = "Show protocol" - opts.show_protocol.type = CHECKBOX - opts.show_protocol.value = true - - opts.show_email.description = "Show unread mail count" - opts.show_email.type = CHECKBOX - opts.show_email.value = true - - opts.show_status.description = "Show status" - opts.show_status.type = CHECKBOX - opts.show_status.value = true - - opts.show_status_msg.description = "Show status message" - opts.show_status_msg.type = CHECKBOX - opts.show_status_msg.value = true - - opts.show_listening.description = "Show listening to" - opts.show_listening.type = CHECKBOX - opts.show_listening.value = true - - opts.show_protocol_cycle.description = "Show protocol cycle buttons" - opts.show_protocol_cycle.type = CHECKBOX - opts.show_protocol_cycle.value = false - - opts.use_under_avatar.description = "Use free space (under avatar) to other texts" - opts.use_under_avatar.type = CHECKBOX - opts.use_under_avatar.value = true - - opts.border_left.description = "Left border" - opts.border_left.type = NUMBER - opts.border_left.value = 8 - opts.border_left.min = 0 - opts.border_left.max = 100 - - opts.border_top.description = "Top border" - opts.border_top.type = NUMBER - opts.border_top.value = 8 - opts.border_top.min = 0 - opts.border_top.max = 100 - - opts.border_right.description = "Right border" - opts.border_right.type = NUMBER - opts.border_right.value = 8 - opts.border_right.min = 0 - opts.border_right.max = 100 - - opts.border_bottom.description = "Bottom border" - opts.border_bottom.type = NUMBER - opts.border_bottom.value = 8 - opts.border_bottom.min = 0 - opts.border_bottom.max = 100 - - // Default fonts - - nickname.font.face = "Tahoma" - nickname.font.size = 13 - nickname.font.bold = true - nickname.font.color = RGB(0,0,0) - - protocol.font.face = "Tahoma" - protocol.font.size = 8 - protocol.font.color = RGB(0,0,0) - - email.font.face = "Tahoma" - email.font.size = 8 - email.font.color = RGB(0,0,0) - - status_name.font.face = "Tahoma" - status_name.font.size = 8 - status_name.font.color = RGB(0,0,0) - - status_msg.font.face = "Tahoma" - status_msg.font.size = 8 - status_msg.font.italic = true - status_msg.font.color = RGB(150,150,150) - - listening.font.face = "Tahoma" - listening.font.size = 8 - listening.font.italic = true - listening.font.color = RGB(150,150,150) -} - -function valign_center(top) -{ - var height = 0 - for(var i = 1; i < arguments.length; i++) - height = Math.max(height, arguments[i].height) - for(var i = 1; i < arguments.length; i++) - arguments[i].top = top + (height - arguments[i].height)/2 - return top + height -} - -// Resize a field, keeping its aspect ratio -function resize(field, maxWidth, maxHeight, allowGrow) -{ - if (allowGrow == null) - allowGrow = true - - var factor = Math.min(maxWidth / field.width, maxHeight / field.height) - if (!allowGrow && factor >= 1) - return - - field.width *= factor - field.height *= factor -} - -function draw() -{ - // Default texts - if (nickname.enabled && nickname.text == "") - nickname.text = "" - if (status_msg.enabled && status_msg.text == "") - status_msg.text = "" - if (listening.enabled && listening.text == "") - listening.text = "" - - if (info.protocol.locked) - status_name.text += " (locked)" - - - // ToolTips - nickname.toolTip = nickname.text - protocol.toolTip = protocol.text - status_icon.toolTip = status_name.toolTip = status_name.text - status_msg.toolTip = status_msg.text - listening_icon.toolTip = listening.toolTip = listening.text - next_proto.toolTip = "Show next protocol" - prev_proto.toolTip = "Show previous protocol" - email_icon.toolTip = email.toolTip = "Unread Email Count: " + email.text - - - // Borders - window.borders.left = opts.border_left - window.borders.top = opts.border_top - window.borders.right = opts.border_right - window.borders.bottom = opts.border_bottom - - - // Visible - nickname.visible = true - prev_proto.visible = next_proto.visible = opts.show_protocol_cycle && !IsEmpty(next_proto, prev_proto) - avatar.visible = opts.show_avatar && avatar.enabled && !IsEmpty(avatar) - protocol.visible = opts.show_protocol && protocol.enabled - status_icon.visible = status_name.visible = opts.show_status && status_name.enabled - status_msg.visible = opts.show_status_msg && !IsEmpty(status_msg) - listening_icon.visible = listening.visible = opts.show_listening && !IsEmpty(listening_icon, listening) - email_icon.visible = email.visible = opts.show_email && email.enabled && !IsEmpty(email_icon, email) && email.text > 0 - - - // Space to draw the frame around - var BORDER_SPACE = 2 - nickname.borders = BORDER_SPACE - protocol.borders = BORDER_SPACE - status_icon.borders = BORDER_SPACE - status_name.borders = BORDER_SPACE - status_msg.borders = BORDER_SPACE - listening_icon.borders = BORDER_SPACE - listening.borders = BORDER_SPACE - email_icon.borders = BORDER_SPACE - email.borders = BORDER_SPACE - - - if (avatar.visible) - { - if (opts.avatar_use_fixed_size) - resize(avatar, opts.avatar_fixed_size, opts.avatar_fixed_size, opts.avatar_allow_grow) - else - resize(avatar, window.width/2.5, window.height - (!info.resize_frame && prev_proto.visible ? prev_proto.height : 0), opts.avatar_allow_grow) - } - - if (!info.resize_frame && prev_proto.visible) - { - prev_proto.left = 0 - prev_proto.bottom = window.height - - next_proto.right = window.width - next_proto.bottom = window.height - } - - var avatar_bottom = avatar.bottom - if (opts.show_avatar && opts.avatar_use_fixed_size) - avatar_bottom = opts.avatar_fixed_size - - var top = 0 - - if (opts.align_right) - { - // Align - nickname.hAlign = RIGHT - protocol.hAlign = RIGHT - status_name.hAlign = RIGHT - status_msg.hAlign = RIGHT - listening.hAlign = RIGHT - - - var right = window.right - - function updateTopRight(val) - { - top = val - if (opts.use_under_avatar && top > avatar_bottom) - right = window.right - } - - if (avatar.visible) - { - avatar.right = window.right - avatar.top = 0 - - right = avatar.left - 6 - } - - if (opts.show_avatar && opts.avatar_use_fixed_size) - right = window.right - opts.avatar_fixed_size - 6 - - nickname.right = right - nickname.top = top - - updateTopRight(nickname.bottom) - - if (protocol.visible) - { - protocol.right = right - protocol.top = top - - if (email.visible) - { - email_icon.right = protocol.left - 10 - email.right = email_icon.left - - var bottom = valign_center(top, protocol, email_icon, email) - updateTopRight(bottom) - } - else - updateTopRight(protocol.bottom) - } - else if (email.visible) - { - email_icon.borders.left = 0 - email_icon.right = right - - email.right = email_icon.left - - var bottom = valign_center(top, email_icon, email) - updateTopRight(bottom) - } - - if (status_name.visible) - { - status_icon.right = right - status_name.right = status_icon.left - - var bottom = valign_center(top, status_icon, status_name) - updateTopRight(bottom) - } - - if (status_msg.visible) - { - status_msg.right = right - status_msg.top = top - - updateTopRight(status_msg.bottom) - } - - if (listening.visible) - { - listening_icon.borders.left = 0 - listening_icon.right = right - - listening.right = listening_icon.left - - var bottom = valign_center(top, listening_icon, listening) - updateTopRight(bottom) - } - } - else - { - var left = 0 - - function updateTopLeft(val) - { - top = val - if (opts.use_under_avatar && top > avatar_bottom) - left = 0 - } - - if (avatar.visible) - { - avatar.left = 0 - avatar.top = 0 - - left = avatar.right + 6 - } - - if (opts.show_avatar && opts.avatar_use_fixed_size) - left = opts.avatar_fixed_size + 6 - - nickname.left = left - nickname.top = top - - updateTopLeft(nickname.bottom) - - if (protocol.visible) - { - protocol.left = left - protocol.top = top - - if (email.visible) - { - email_icon.left = protocol.right + 10 - email.left = email_icon.right - - var bottom = valign_center(top, protocol, email_icon, email) - updateTopLeft(bottom) - } - else - updateTopLeft(protocol.bottom) - } - else if (email.visible) - { - email_icon.borders.right = 0 - email_icon.left = left - - email.left = email_icon.right - - var bottom = valign_center(top, email_icon, email) - updateTopLeft(bottom) - } - - if (status_name.visible) - { - status_icon.left = left - status_name.left = status_icon.right - - var bottom = valign_center(top, status_icon, status_name) - updateTopLeft(bottom) - } - - if (status_msg.visible) - { - status_msg.left = left - status_msg.top = top - - updateTopLeft(status_msg.bottom) - } - - if (listening.visible) - { - listening_icon.borders.right = 0 - listening_icon.left = left - - listening.borders.left = 0 - listening.left = listening_icon.right - - var bottom = valign_center(top, listening_icon, listening) - updateTopLeft(bottom) - } - } - - if (info.resize_frame) - { - if (prev_proto.visible) - { - top = Math.max(avatar.bottom, top) - - prev_proto.left = 0 - prev_proto.top = top - - next_proto.right = window.width - next_proto.top = top - } - } -} \ No newline at end of file diff --git a/plugins/MyDetails/Docs/Skins/Pidgin/MyDetails.msk b/plugins/MyDetails/Docs/Skins/Pidgin/MyDetails.msk deleted file mode 100644 index 89295899f8..0000000000 --- a/plugins/MyDetails/Docs/Skins/Pidgin/MyDetails.msk +++ /dev/null @@ -1,59 +0,0 @@ -function configure() -{ - // Default fonts - - status_msg.font.face = "Tahoma" - status_msg.font.size = 8 - status_msg.font.color = RGB(0,0,0) -} - -function draw() -{ - if (status_msg.text == "") - status_msg.text = status_name.text - - // ToolTips - status_icon.toolTip = protocol.text + " : " + status_name.text - if (info.protocol.locked) - status_icon.toolTip += " (locked)" - if (email.text > 0) - status_icon.toolTip += " [" + email.text + " emails]" - - status_msg.toolTip = status_msg.text - - // Borders - window.borders = 10 - - // Visible - status_msg.visible = true - avatar.visible = true - status_icon.visible = true - - status_name.visible = false - protocol.visible = false - nickname.visible = false - prev_proto.visible = next_proto.visible = false - listening_icon.visible = listening.visible = false - email_icon.visible = email.visible = false - - // Space to draw the frame around - var BORDER_SPACE = 2 - status_icon.borders = BORDER_SPACE - status_msg.borders = BORDER_SPACE - status_name.borders = BORDER_SPACE - - // Positions - var HEIGHT = 45 - - avatar.right = window.right - avatar.top = 0 - avatar.width = HEIGHT - avatar.height = HEIGHT - - status_icon.left = 0 - status_icon.top = (HEIGHT - status_icon.height) / 2 - - status_msg.left = status_icon.right + 5 - status_msg.top = (HEIGHT - status_msg.height) / 2 - status_msg.right = avatar.left - 5 -} diff --git a/plugins/MyDetails/Docs/mydetails_changelog.txt b/plugins/MyDetails/Docs/mydetails_changelog.txt index 011a1c63b3..c4b1b441b7 100644 --- a/plugins/MyDetails/Docs/mydetails_changelog.txt +++ b/plugins/MyDetails/Docs/mydetails_changelog.txt @@ -2,38 +2,6 @@ My Details Changelog: -. 0.0.2.6 - + Added support for clist modern skin engine - + Added pidgin style skin - * Fix for last shown protocol - * Updated updater to use googlecode - -. 0.0.2.5 - + Use account name and ordering - * Better handling status messages - * Fix for jabber status names - * Bug fixes - -. 0.0.2.3 - * Moved background color to font service settings - + Better simple away support - -. 0.0.2.2 - * Fix for email count - * Better handling of hover - * Better handling of small sizes - * If fixed avatar size is set, use it even if no avatar present - + If windows uses RTL, it is selected by default - -. 0.0.2.1 - + Show lock icon over status - + Show unread mail count - * Resize frame is working again - * Still work in progress - -. 0.0.2.0 - + Now uses skins plugin to position elements (work in progress) - . 0.0.1.11 * Fix for arrows: always draw then at right side diff --git a/plugins/MyDetails/Docs/mydetails_readme.txt b/plugins/MyDetails/Docs/mydetails_readme.txt index c9e58d0136..931ef0418d 100644 --- a/plugins/MyDetails/Docs/mydetails_readme.txt +++ b/plugins/MyDetails/Docs/mydetails_readme.txt @@ -14,16 +14,6 @@ To request support to other away system: If someone wants to use another away sy 1. Get current status message for a protocol, given its name 2. Set current status message for a protocol, given its name and the message - -To use skin engine of clist modern: the following glyphs are used: -- MyDetails,ID=Background : background of frame -- MyDetails,ID=MouseOver : base mouse over background (for all fields) -- MyDetails,ID=MouseOverNick : base mouse over background for nick (drawn over the base one) -- MyDetails,ID=MouseOverProto : base mouse over background for protocol (drawn over the base one) -- MyDetails,ID=MouseOverStatus : base mouse over status name/icon for nick (drawn over the base one) -- MyDetails,ID=MouseOverStatusMsg : base mouse over background for status message (drawn over the base one) -- MyDetails,ID=MouseOverListening : base mouse over background for listening info (drawn over the base one) - To report bugs/make suggestions, go to the forum thread: http://forums.miranda-im.org/showthread.php?t=5643 Dependencies: diff --git a/plugins/MyDetails/Docs/mydetails_version.txt b/plugins/MyDetails/Docs/mydetails_version.txt index e078af1e48..12817e638a 100644 --- a/plugins/MyDetails/Docs/mydetails_version.txt +++ b/plugins/MyDetails/Docs/mydetails_version.txt @@ -1 +1 @@ -My Details 0.0.2.6 \ No newline at end of file +My Details 0.0.1.11 \ No newline at end of file diff --git a/plugins/MyDetails/commons.h b/plugins/MyDetails/commons.h index ca1849c826..e553fee299 100644 --- a/plugins/MyDetails/commons.h +++ b/plugins/MyDetails/commons.h @@ -27,9 +27,6 @@ Boston, MA 02111-1307, USA. #include #include #include -#include - -#define MIRANDA_VER 0x800 #include #include #include @@ -64,8 +61,6 @@ Boston, MA 02111-1307, USA. #include -#include "../skins/m_skins_cpp.h" - #include "resource.h" @@ -81,8 +76,6 @@ extern PLUGINLINK *pluginLink; extern long nickname_dialog_open; extern long status_msg_dialog_open; -extern SkinDialog *dialog; - #include "m_mydetails.h" #include "data.h" @@ -92,42 +85,16 @@ extern SkinDialog *dialog; #include "../utils/mir_memory.h" #include "../utils/mir_options.h" #include "../utils/mir_icons.h" -#include "../utils/tstring.h" #define PS_SETMYAVATAR "/SetMyAvatar" #define PS_GETMYAVATAR "/GetMyAvatar" #define PS_GETMYAVATARMAXSIZE "/GetMyAvatarMaxSize" -#define PS_GETUNREADEMAILCOUNT "/GetUnreadEmailCount" #define PS_SETMYNICKNAME "/SetNickname" #define PS_GETMYNICKNAMEMAXLENGTH "/GetMyNicknameMaxLength" -#define WAYD_UNICODE 1 // return Unicode texts -#if defined( _UNICODE ) - #define WAYD_TCHAR WAYD_UNICODE -#else - #define WAYD_TCHAR 0 -#endif - -// Get the max length that a WAYD message can have -// wParam=(WPARAM)0 -// lParam=(LPARAM)0 -// Returns the max length -#define PS_GET_MY_WAYD_MAXLENGTH "/GetMyWAYDMaxLength" - -// Get the WAYD message for the user -// wParam=(WPARAM)WAYD_xxx -// lParam=(LPARAM)0 -// Returns the text or NULL if there is none. Remember to mir_free the return value. -#define PS_GET_MY_WAYD "/GetMyWAYD" - -// Sets the WAYD message for the user -// wParam=(WPARAM)WAYD_xxx -// lParam=(LPARAM)(WCHAR * or char *)The text to set -// Returns 0 on success, nonzero on failure -#define PS_SET_MY_WAYD "/SetMyWAYD" #define MAX_REGS(_A_) ( sizeof(_A_) / sizeof(_A_[0]) ) @@ -142,6 +109,21 @@ __inline static int ProtoServiceExists(const char *szModule,const char *szServic } +// Helper +static __inline int DRAW_TEXT(HDC hDC, LPCSTR lpString, int nCount, LPRECT lpRect, UINT uFormat, const char *protocol, + SmileysParseInfo parseInfo) +{ + if (opts.replace_smileys) + { + return Smileys_DrawText(hDC, lpString, nCount, lpRect, uFormat | (opts.resize_smileys ? DT_RESIZE_SMILEYS : 0), + opts.use_contact_list_smileys ? "clist" : protocol, parseInfo); + } + else + { + return DrawText(hDC, lpString, nCount, lpRect, uFormat); + } +} + diff --git a/plugins/MyDetails/data.cpp b/plugins/MyDetails/data.cpp index eccd72e0e7..62192aa42e 100644 --- a/plugins/MyDetails/data.cpp +++ b/plugins/MyDetails/data.cpp @@ -20,183 +20,50 @@ Boston, MA 02111-1307, USA. #include "commons.h" #include "data.h" -#include static char *StatusModeToDbSetting(int status,const char *suffix); -static bool IsValid(const char *proto) -{ - if (proto == NULL || proto[0] == 0) - return false; - - int caps = CallProtoService(proto, PS_GETCAPS, PFLAGNUM_1, 0); - return (caps & PF1_IM) == PF1_IM && strcmp(proto, "MetaContacts") != 0; -} -static bool AccOrderComp(PROTOACCOUNT *p1, PROTOACCOUNT *p2) -{ - return p1->iOrder < p2->iOrder; -} - -static void GetAccounts(std::vector *result) -{ - int count; - PROTOACCOUNT **protos; - ProtoEnumAccounts(&count, &protos); - - for (int i = 0; i < count; i++) - { - if (protos[i]->type != PROTOTYPE_PROTOCOL) - continue; - - if (!IsAccountEnabled(protos[i])) - continue; - - if (!IsValid(protos[i]->szModuleName)) - continue; - - result->push_back(protos[i]); - } - - std::sort(result->begin(), result->begin(), AccOrderComp); -} - - -void GetProtocols(std::vector *result) -{ - std::vector accs; - GetAccounts(&accs); - - unsigned int accsSize = accs.size(); - for (unsigned int i = 0; i < accsSize ; ++i) - result->push_back(Protocol(accs[i]->szModuleName)); -} - - -int GetProtocolIndexByName(const char *moduleName) -{ - std::vector protos; - GetAccounts(&protos); - - int protosSize = (int) protos.size(); - for(int i = 0; i < protosSize; ++i) - { - if (strcmp(protos[i]->szModuleName, moduleName) == 0) - return i; - } - - return -1; -} +ProtocolArray *protocols = NULL; -int GetNumProtocols() +void InitProtocolData() { - std::vector protos; - GetAccounts(&protos); - return protos.size(); -} + PROTOCOLDESCRIPTOR **protos; + int i, count; + CallService(MS_PROTO_ENUMPROTOCOLS, (WPARAM)&count, (LPARAM)&protos); -struct ProtoCache -{ - Protocol *proto; - int index; + protocols = new ProtocolArray(count); - void Free() + for (i = 0; i < count; i++) { - delete proto; - proto = NULL; - index = -1; - } -}; - -static ProtoCache current = { NULL, -1 }; - - -void SetCurrentProtocol(int index) -{ - current.Free(); - - int protosSize = GetNumProtocols(); - if (protosSize > 0) - current.index = (index % protosSize + protosSize) % protosSize; + if (protos[i]->type != PROTOTYPE_PROTOCOL) + continue; - DBWriteContactSettingWord(NULL, "MyDetails", "ProtocolNumber", current.index); -} + if (protos[i]->szName == NULL || protos[i]->szName[0] == '\0') + continue; -Protocol * GetCurrentProtocol(bool createIfDontExist) -{ - if (createIfDontExist && current.index >= 0 && current.proto == NULL) - { - std::vector protos; - GetAccounts(&protos); + // Found a protocol + Protocol *p = new Protocol(protos[i]->szName); - int protosSize = protos.size(); - if (current.index >= protosSize) + if (p->IsValid()) { - current.index = -1; - return NULL; + protocols->Add(p); + } + else + { + delete p; } - - current.proto = new Protocol(protos[current.index]->szModuleName); - } - - return current.proto; -} - -int GetCurrentProtocolIndex() -{ - return current.index; -} - - -Protocol GetProtocolByIndex(int index) -{ - std::vector protos; - GetAccounts(&protos); - int protosSize = protos.size(); - - if (protosSize < 1) - return Protocol(NULL); - - index = (index % protosSize + protosSize) % protosSize; - return Protocol(protos[index]->szModuleName); -} - - -Protocol GetProtocolByName(const char *moduleName) -{ - std::vector protos; - GetAccounts(&protos); - - int protosSize = (int) protos.size(); - for(int i = 0; i < protosSize; ++i) - { - if (strcmp(protos[i]->szModuleName, moduleName) == 0) - return Protocol(protos[i]->szModuleName); } - - return Protocol(NULL); -} - - -ProtocolArray *protocols = NULL; - - -void InitProtocolData() -{ - protocols = new ProtocolArray(); } void DeInitProtocolData() { - current.Free(); - delete protocols; - protocols = NULL; } @@ -205,206 +72,139 @@ void DeInitProtocolData() Protocol::Protocol(const char *aName) { - if (aName) - name = aName; + lstrcpyn(name, aName, MAX_REGS(name)); + description[0] = _T('\0'); + nickname[0] = _T('\0'); + status_message[0] = _T('\0'); + listening_to[0] = _T('\0'); + ace = NULL; + avatar_file[0] = _T('\0'); avatar_bmp = NULL; - status = 0; custom_status = 0; - locked = false; - emails = 0; - - // Initial value - UpdateAll(); -} + data_changed = true; -Protocol::~Protocol() -{ -} + // Load services + int caps; -bool Protocol::IsValid() -{ - return !name.empty(); -} + caps = CallProtoService(name, PS_GETCAPS, PFLAGNUM_1, 0); + valid = (caps & PF1_IM) == PF1_IM && strcmp(aName, "MetaContacts"); + if (!valid) + return; -Protocol::operator bool () -{ - return IsValid(); -} + can_have_listening_to = (ProtoServiceExists(name, PS_SET_LISTENINGTO) != 0); + caps = CallProtoService(name, PS_GETCAPS, PFLAGNUM_4, 0); + can_have_avatar = (caps & PF4_AVATARS) != 0; -void Protocol::UpdateAll() -{ - status_initialized = false; - status_message_initialized = false; - nickname_initialized = false; - avatar_initialized = false; - locked_initialized = false; - emails_initialized = false; - listening_to_initialized = false; -} + PF3 = CallProtoService(name, PS_GETCAPS, (WPARAM)PFLAGNUM_3, 0); + avatar_max_width = 0; + avatar_max_height = 0; + if (ProtoServiceExists(name, PS_GETMYAVATARMAXSIZE)) + { + CallProtoService(name, PS_GETMYAVATARMAXSIZE, (WPARAM) &avatar_max_width, (LPARAM) &avatar_max_height); + } -int Protocol::Call(const char *service, WPARAM wParam, LPARAM lParam) -{ - return CallProtoService(name.c_str(), service, wParam, lParam); -} + CallProtoService(name, PS_GETNAME, sizeof(description),(LPARAM) description); + can_set_nick = ProtoServiceExists(name, PS_SETMYNICKNAME) != FALSE; -bool Protocol::CanCall(const char *service) -{ - return ProtoServiceExists(name.c_str(), service) != 0; + // Initial value + GetStatus(); + GetStatusMsg(); + GetNick(); + GetAvatar(); } - -std::string Protocol::GetDBSettingString(const char *key, const char *def) +Protocol::~Protocol() { - std::string result = def; +} - DBVARIANT dbv; - if (!DBGetContactSettingTString(0, name.c_str(), key, &dbv)) +void Protocol::lcopystr(TCHAR *dest, TCHAR *src, int maxlen) +{ + if (lstrcmp(dest, src) != 0) { - if (dbv.ptszVal != NULL && dbv.ptszVal[0] != 0) - result = dbv.ptszVal; - - DBFreeVariant(&dbv); + data_changed = true; + lstrcpyn(dest, src, maxlen); } - - return result; } - -const char * Protocol::GetName() +bool Protocol::IsValid() { - return name.c_str(); + return valid; } -const char * Protocol::GetDescription() -{ - if (description.empty()) - { - PROTOACCOUNT *acc = ProtoGetAccount(name.c_str()); - - if (acc == NULL || acc->tszAccountName == NULL || acc->tszAccountName[0] == 0) - { - char tmp[1024]; - Call(PS_GETNAME, sizeof(tmp), (LPARAM) tmp); - description = tmp; - } - else - { - if (mir_is_unicode()) - { - char *tmp = mir_u2a((const wchar_t *) acc->tszAccountName); - description = tmp; - mir_free(tmp); - } - else - { - description = acc->tszAccountName; - } - } - } - - return description.c_str(); -} - -void Protocol::UpdateStatus() +int Protocol::GetStatus() { - status_initialized = true; + int old_status = status; + status = CallProtoService(name, PS_GETSTATUS, 0, 0); - status = Call(PS_GETSTATUS); + if (old_status != status) + data_changed = true; - if (status > ID_STATUS_OFFLINE && CanCall(PS_ICQ_GETCUSTOMSTATUS)) + if (/*status > ID_STATUS_OFFLINE &&*/ ProtoServiceExists(name, PS_ICQ_GETCUSTOMSTATUS)) { - char *name_key = NULL; - char *message_key = NULL; - - custom_status = Call(PS_ICQ_GETCUSTOMSTATUS, (WPARAM) &name_key, (LPARAM) &message_key); - - // Fix fo jabber, that returns 0xbaadf00d here - if (custom_status < 0) - custom_status = 0; - - custom_status_name_key = (name_key ? name_key : ""); - custom_status_message_key = (message_key ? message_key : ""); + custom_status = CallProtoService(name, PS_ICQ_GETCUSTOMSTATUS, (WPARAM) &custom_status_name, + (LPARAM) &custom_status_message); } else { custom_status = 0; - custom_status_name_key = ""; - custom_status_message_key = ""; } if (custom_status == 0) { - status_name = (char *) CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, status, GCMDF_TCHAR); + TCHAR *tmp = (char *) CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, status, GCMDF_TCHAR); + lcopystr(status_name, tmp, MAX_REGS(status_name)); } else { - status_name = ""; + DBVARIANT dbv; + TCHAR tmp[256] = "\0"; - if (!custom_status_name_key.empty()) - status_name = GetDBSettingString(custom_status_name_key.c_str()); + if (custom_status_name != NULL && custom_status_name[0] != '\0' + && !DBGetContactSettingTString(0, name, custom_status_name, &dbv)) + { + if (dbv.ptszVal != NULL && dbv.ptszVal[0] != _T('\0')) + lstrcpyn(tmp, dbv.ptszVal, MAX_REGS(tmp)); + else + lstrcpyn(tmp, TranslateTS(""), MAX_REGS(tmp)); - if (!custom_status_message_key.empty()) + DBFreeVariant(&dbv); + } + else { - std::string tmp = GetDBSettingString(custom_status_message_key.c_str()); - if (!tmp.empty()) - { - status_name += ": "; - status_name += tmp; - } + lstrcpyn(tmp, TranslateTS(""), MAX_REGS(tmp)); } - } - - if (status_name.empty()) - status_name = TranslateTS(""); -} -const char * Protocol::GetStatusName() -{ - if (!status_initialized) - UpdateStatus(); + if (custom_status_message != NULL && custom_status_message[0] != '\0' + && !DBGetContactSettingTString(0, name, custom_status_message, &dbv)) + { + if (dbv.ptszVal != NULL && dbv.ptszVal[0] != '\0') + { + int len = lstrlen(tmp); - return status_name.c_str(); -} + if (len < MAX_REGS(tmp)) + lstrcpyn(&tmp[len], _T(": "), MAX_REGS(tmp) - len); -const char * Protocol::GetCustomStatusNameKey() -{ - if (!status_initialized) - UpdateStatus(); - - return custom_status_name_key.c_str(); -} + len += 2; -const char * Protocol::GetCustomStatusMessageKey() -{ - if (!status_initialized) - UpdateStatus(); - - return custom_status_message_key.c_str(); -} + if (len < MAX_REGS(tmp)) + lstrcpyn(&tmp[len], dbv.ptszVal, MAX_REGS(tmp) - len); + } -int Protocol::GetStatus() -{ - if (!status_initialized) - UpdateStatus(); - - return status; -} + DBFreeVariant(&dbv); + } -int Protocol::GetCustomStatus() -{ - if (!status_initialized) - UpdateStatus(); - - return custom_status; -} + lcopystr(status_name, tmp, MAX_REGS(status_name)); + } + return status; +} void Protocol::SetStatus(int aStatus) { @@ -437,7 +237,7 @@ void Protocol::SetStatus(int aStatus) pse[0]->cbSize = sizeof(PROTOCOLSETTINGEX); pse[0]->status = aStatus; - pse[0]->szName = (char *) name.c_str(); + pse[0]->szName = name; GetStatusMsg(aStatus, status_msg, sizeof(status_msg)); pse[0]->szMsg = status_msg; @@ -450,7 +250,7 @@ void Protocol::SetStatus(int aStatus) } else { - Call(PS_SETSTATUS, aStatus); + CallProtoService(name, PS_SETSTATUS, aStatus, 0); if (CanSetStatusMsg(aStatus)) { @@ -464,13 +264,13 @@ void Protocol::SetStatus(int aStatus) bool Protocol::CanGetStatusMsg() { - return CanGetStatusMsg(GetStatus()); + return CanGetStatusMsg(status); } bool Protocol::CanGetStatusMsg(int aStatus) { - return (Call(PS_GETCAPS, PFLAGNUM_1) & PF1_MODEMSGSEND) != 0 - && (Call(PS_GETCAPS, (WPARAM)PFLAGNUM_3) & Proto_Status2Flag(aStatus)); + return (CallProtoService(name, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) != 0 + && (PF3 & Proto_Status2Flag(aStatus)); } @@ -490,37 +290,23 @@ void Protocol::GetStatusMsg(int aStatus, char *msg, size_t msg_size) { if (!CanGetStatusMsg()) { - lstrcpyn(msg, "", msg_size); + lcopystr(msg, "", msg_size); return; } - bool isCurrentStatus = (aStatus == GetStatus()); - - if (isCurrentStatus && CanCall(PS_GETMYAWAYMSG)) - { - char *tmp = (char *) Call(PS_GETMYAWAYMSG); - lstrcpyn(msg, tmp == NULL ? "" : tmp, msg_size); - } - else if (isCurrentStatus && ServiceExists(MS_SA_ISSARUNNING) && CallService(MS_SA_ISSARUNNING, 0, 0)) + if (aStatus == status && ProtoServiceExists(name, PS_GETMYAWAYMSG) ) { - char *tmp = (char *) CallService(MS_AWAYMSG_GETSTATUSMSG, (WPARAM) ID_STATUS_CURRENT, (LPARAM) name.c_str()); - - if (tmp != NULL) - { - lstrcpyn(msg, tmp, msg_size); - mir_free(tmp); - } - else lstrcpyn(msg, "", msg_size); - - } + char *tmp = (char *) CallProtoService(name, PS_GETMYAWAYMSG, 0, 0); + lcopystr(msg, tmp == NULL ? "" : tmp, msg_size); + } else if (ServiceExists(MS_NAS_GETSTATE)) { NAS_PROTOINFO pi; ZeroMemory(&pi, sizeof(pi)); pi.cbSize = sizeof(NAS_PROTOINFO); - pi.szProto = (char *) name.c_str(); - pi.status = (isCurrentStatus ? 0 : aStatus); + pi.szProto = name; + pi.status = aStatus == status ? 0 : aStatus; pi.szMsg = NULL; if (CallService(MS_NAS_GETSTATE, (WPARAM) &pi, 1) == 0) @@ -533,25 +319,25 @@ void Protocol::GetStatusMsg(int aStatus, char *msg, size_t msg_size) { if (pi.szMsg != NULL) { - lstrcpyn(msg, pi.szMsg, msg_size); + lcopystr(msg, pi.szMsg, msg_size); mir_free(pi.szMsg); } - else lstrcpyn(msg, "", msg_size); + else lcopystr(msg, "", msg_size); } - else lstrcpyn(msg, "", msg_size); + else lcopystr(msg, "", msg_size); } else // if (pi.szMsg != NULL) { - lstrcpyn(msg, pi.szMsg, msg_size); + lcopystr(msg, pi.szMsg, msg_size); mir_free(pi.szMsg); } } - else lstrcpyn(msg, "", msg_size); + else lcopystr(msg, "", msg_size); if (ServiceExists(MS_VARS_FORMATSTRING)) { char *tmp = variables_parse(msg, NULL, NULL); - lstrcpyn(msg, tmp, msg_size); + lcopystr(msg, tmp, msg_size); variables_free(tmp); } } @@ -562,8 +348,8 @@ void Protocol::GetStatusMsg(int aStatus, char *msg, size_t msg_size) ZeroMemory(&pi, sizeof(pi)); pi.cbSize = sizeof(NAS_PROTOINFO); - pi.szProto = (char *) name.c_str(); - pi.status = (isCurrentStatus ? 0 : aStatus); + pi.szProto = name; + pi.status = aStatus == status ? 0 : aStatus; pi.szMsg = NULL; pii = π @@ -578,25 +364,25 @@ void Protocol::GetStatusMsg(int aStatus, char *msg, size_t msg_size) { if (pi.szMsg != NULL) { - lstrcpyn(msg, pi.szMsg, msg_size); + lcopystr(msg, pi.szMsg, msg_size); mir_free(pi.szMsg); } - else lstrcpyn(msg, "", msg_size); + else lcopystr(msg, "", msg_size); } - else lstrcpyn(msg, "", msg_size); + else lcopystr(msg, "", msg_size); } else // if (pi.szMsg != NULL) { - lstrcpyn(msg, pi.szMsg, msg_size); + lcopystr(msg, pi.szMsg, msg_size); mir_free(pi.szMsg); } } - else lstrcpyn(msg, "", msg_size); + else lcopystr(msg, "", msg_size); if (ServiceExists(MS_VARS_FORMATSTRING)) { char *tmp = variables_parse(msg, NULL, NULL); - lstrcpyn(msg, tmp, msg_size); + lcopystr(msg, tmp, msg_size); variables_free(tmp); } } @@ -606,29 +392,17 @@ void Protocol::GetStatusMsg(int aStatus, char *msg, size_t msg_size) if (tmp != NULL) { - lstrcpyn(msg, tmp, msg_size); + lcopystr(msg, tmp, msg_size); mir_free(tmp); } - else lstrcpyn(msg, "", msg_size); + else lcopystr(msg, "", msg_size); } } -void Protocol::UpdateStatusMsg() +char * Protocol::GetStatusMsg() { - status_message_initialized = true; - - TCHAR tmp[1024]; - GetStatusMsg(GetStatus(), tmp, sizeof(tmp)); - - status_message = tmp; -} - -const char * Protocol::GetStatusMsg() -{ - if (!status_message_initialized) - UpdateStatusMsg(); - - return status_message.c_str(); + GetStatusMsg(status, status_message, sizeof(status_message)); + return status_message; } void Protocol::SetStatusMsg(const char *message) @@ -646,7 +420,7 @@ void Protocol::SetStatusMsg(int aStatus, const char *message) NAS_PROTOINFO pi = {0}, *pii; pi.cbSize = sizeof(pi); - pi.szProto = (char *) name.c_str(); + pi.szProto = name; pi.szMsg = mir_strdup(message); pi.status = aStatus; @@ -656,23 +430,20 @@ void Protocol::SetStatusMsg(int aStatus, const char *message) } else { - Call(PS_SETAWAYMSG, (WPARAM) aStatus, (LPARAM) message); + CallProtoService(name, PS_SETAWAYMSG, (WPARAM)aStatus, (LPARAM)message); } } bool Protocol::HasAvatar() { - if (!avatar_initialized) - UpdateAvatar(); + GetAvatar(); return avatar_bmp != NULL; } bool Protocol::CanGetAvatar() { - int caps = Call(PS_GETCAPS, PFLAGNUM_4); - - if ((caps & PF4_AVATARS) == 0) + if (!can_have_avatar) return false; if (!ServiceExists(MS_AV_GETMYAVATAR)) @@ -681,39 +452,22 @@ bool Protocol::CanGetAvatar() return true; } -void Protocol::UpdateAvatar() +void Protocol::GetAvatar() { - avatar_initialized = true; - avatar_file = ""; - avatar_bmp = NULL; - // See if can get one if (!CanGetAvatar()) return; + avatar_file[0] = '\0'; + avatar_bmp = NULL; + ace = NULL; + // Get HBITMAP from cache - AVATARCACHEENTRY *ace = (avatarCacheEntry *) CallService(MS_AV_GETMYAVATAR, 0, (LPARAM) name.c_str()); + ace = (avatarCacheEntry *)CallService(MS_AV_GETMYAVATAR, 0, (LPARAM) name); if (ace != NULL) - { - avatar_file = ace->szFilename; avatar_bmp = ace->hbmPic; - } -} - -const char * Protocol::GetAvatarFile() -{ - if (!avatar_initialized) - UpdateAvatar(); - return avatar_file.c_str(); -} - -HBITMAP Protocol::GetAvatarImage() -{ - if (!avatar_initialized) - UpdateAvatar(); - - return avatar_bmp; + data_changed = true; } @@ -724,9 +478,9 @@ bool Protocol::CanGetNick() int Protocol::GetNickMaxLength() { - if (CanCall(PS_GETMYNICKNAMEMAXLENGTH)) + if (ProtoServiceExists(name, PS_GETMYNICKNAMEMAXLENGTH)) { - int ret = Call(PS_GETMYNICKNAMEMAXLENGTH); + int ret = CallProtoService(name, PS_GETMYNICKNAMEMAXLENGTH, 0, 0); if (ret <= 0) ret = MS_MYDETAILS_GETMYNICKNAME_BUFFER_SIZE; return ret; @@ -735,21 +489,18 @@ int Protocol::GetNickMaxLength() return MS_MYDETAILS_GETMYNICKNAME_BUFFER_SIZE; } -void Protocol::UpdateNick() +char * Protocol::GetNick() { - nickname_initialized = true; - nickname = ""; - // See if can get one if (!CanGetNick()) - return; + return NULL; // Get it CONTACTINFO ci; ZeroMemory(&ci, sizeof(ci)); ci.cbSize = sizeof(ci); ci.hContact = NULL; - ci.szProto = (char *) name.c_str(); + ci.szProto = name; ci.dwFlag = CNF_DISPLAY; #ifdef UNICODE @@ -759,23 +510,19 @@ void Protocol::UpdateNick() if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) & ci)) { // CNF_DISPLAY always returns a string type - nickname = ci.pszVal; + lcopystr(nickname, ci.pszVal, MAX_REGS(nickname)); mir_free(ci.pszVal); } -} - -const char * Protocol::GetNick() -{ - if (!nickname_initialized) - UpdateNick(); + else + lcopystr(nickname, "", MAX_REGS(nickname)); - return nickname.c_str(); + return nickname; } bool Protocol::CanSetNick() { - return CanCall(PS_SETMYNICKNAME) != 0; + return can_set_nick; } @@ -789,14 +536,14 @@ void Protocol::SetNick(const char *nick) return; // Get it - Call(PS_SETMYNICKNAME, NULL, (LPARAM) nick); + CallProtoService(name, PS_SETMYNICKNAME, NULL, (LPARAM)nick); } bool Protocol::CanSetAvatar() { return ServiceExists(MS_AV_SETMYAVATAR) != FALSE && ServiceExists(MS_AV_CANSETMYAVATAR) != FALSE && - CallService(MS_AV_CANSETMYAVATAR, (WPARAM) name.c_str(), 0); + CallService(MS_AV_CANSETMYAVATAR, (WPARAM) name, 0); } void Protocol::SetAvatar(const char *file_name) @@ -804,12 +551,12 @@ void Protocol::SetAvatar(const char *file_name) if (!CanSetAvatar()) return; - CallService(MS_AV_SETMYAVATAR, (WPARAM) name.c_str(), (LPARAM) file_name); + CallService(MS_AV_SETMYAVATAR, (WPARAM) name, (LPARAM) file_name); } bool Protocol::CanGetListeningTo() { - return CanCall(PS_SET_LISTENINGTO) != 0; + return can_have_listening_to; } bool Protocol::CanSetListeningTo() @@ -819,82 +566,135 @@ bool Protocol::CanSetListeningTo() bool Protocol::ListeningToEnabled() { - return CanSetListeningTo() && CallService(MS_LISTENINGTO_ENABLED, (WPARAM) name.c_str(), 0) != 0; + return CanSetListeningTo() && CallService(MS_LISTENINGTO_ENABLED, (WPARAM) name, 0) != 0; } -void Protocol::UpdateListeningTo() +TCHAR * Protocol::GetListeningTo() { - listening_to_initialized = true; - listening_to = ""; - if (!CanGetListeningTo()) - return; + { + lcopystr(listening_to, "", MAX_REGS(listening_to)); + return listening_to; + } + + DBVARIANT dbv = {0}; + if (DBGetContactSettingTString(NULL, name, "ListeningTo", &dbv)) + { + lcopystr(listening_to, "", MAX_REGS(listening_to)); + return listening_to; + } - listening_to = GetDBSettingString("ListeningTo"); + lcopystr(listening_to, dbv.pszVal, MAX_REGS(listening_to)); + + DBFreeVariant(&dbv); + + return listening_to; } -const char * Protocol::GetListeningTo() + + +// ProtocolDataArray Class ///////////////////////////////////////////////////////////////////////////// + + +ProtocolArray::ProtocolArray(int max_size) { - if (!listening_to_initialized) - UpdateListeningTo(); + buffer = (Protocol **) malloc(max_size * sizeof(Protocol*)); + buffer_len = 0; - return listening_to.c_str(); + GetDefaultNick(); + GetDefaultAvatar(); } -void Protocol::UpdateLocked() + +ProtocolArray::~ProtocolArray() { - locked_initialized = true; + if (buffer != NULL) + { + for ( int i = 0 ; i < buffer_len ; i++ ) + { + delete buffer[i]; + } - locked = (DBGetContactSettingByte(NULL, name.c_str(), "LockMainStatus", 0) != 0); + free(buffer); + } } -bool Protocol::IsLocked() -{ - if (!locked_initialized) - UpdateLocked(); - return locked; +int ProtocolArray::GetSize() +{ + return buffer_len; } -bool Protocol::CanGetEmailCount() + +void ProtocolArray::Add(Protocol *p) { - return CanCall(PS_GETUNREADEMAILCOUNT) != 0 - && GetStatus() > ID_STATUS_OFFLINE; + buffer[buffer_len] = p; + buffer_len++; } -void Protocol::UpdateEmailCount() + +Protocol * ProtocolArray::Get(int i) { - emails_initialized = true; - - if (!CanGetEmailCount()) - emails = 0; + if (i >= buffer_len) + return NULL; else - emails = max(0, Call(PS_GETUNREADEMAILCOUNT)); + return buffer[i]; } -int Protocol::GetEmailCount() + +Protocol * ProtocolArray::Get(const char *name) { - if (!emails_initialized) - UpdateEmailCount(); + if (name == NULL) + return NULL; + + for ( int i = 0 ; i < buffer_len ; i++ ) + { + if (strcmp(name, buffer[i]->name) == 0) + return buffer[i]; + } - return emails; + return NULL; } -// ProtocolDataArray Class ///////////////////////////////////////////////////////////////////////////// +bool ProtocolArray::CanSetStatusMsgPerProtocol() +{ + return ServiceExists(MS_ERSATZ_ENABLED) || + ServiceExists(MS_NAS_INVOKESTATUSWINDOW) || ServiceExists(MS_SA_CHANGESTATUSMSG); +} -ProtocolArray::ProtocolArray() +void ProtocolArray::GetAvatars() { - GetDefaultNick(); - GetDefaultAvatar(); + for ( int i = 0 ; i < buffer_len ; i++ ) + { + buffer[i]->GetAvatar(); + } +} + +void ProtocolArray::GetStatusMsgs() +{ + for ( int i = 0 ; i < buffer_len ; i++ ) + { + buffer[i]->GetStatusMsg(); + } +} + +void ProtocolArray::GetStatuses() +{ + for ( int i = 0 ; i < buffer_len ; i++ ) + { + buffer[i]->GetStatus(); + } } int ProtocolArray::GetGlobalStatus() { int status = CallService(MS_CLIST_GETSTATUSMODE, 0, 0); if (status == ID_STATUS_CONNECTING) + { status = ID_STATUS_OFFLINE; + } return status; } @@ -921,13 +721,11 @@ void ProtocolArray::SetNicks(const char *nick) lstrcpyn(default_nick, nick, sizeof(default_nick)); DBWriteContactSettingString(0, MODULE_NAME, SETTING_DEFAULT_NICK, nick); - - std::vector protos; - GetProtocols(&protos); - - unsigned int protosSize = protos.size(); - for (int i = 0; i < protosSize; ++i) - protos[i].SetNick(default_nick); + + for ( int i = 0 ; i < buffer_len ; i++ ) + { + buffer[i]->SetNick(default_nick); + } } @@ -952,15 +750,11 @@ void ProtocolArray::SetStatusMsgs(int status, const char *message) // Save default also DBWriteContactSettingString(NULL,"SRAway",StatusModeToDbSetting(status,"Default"),message); } - - std::vector protos; - GetProtocols(&protos); - - unsigned int protosSize = protos.size(); - for (int i = 0; i < protosSize; ++i) + + for ( int i = 0 ; i < buffer_len ; i++ ) { - if (protos[i].GetStatus() == status) - protos[i].SetStatusMsg(status, message); + if (buffer[i]->status == status) + buffer[i]->SetStatusMsg(status, message); } } diff --git a/plugins/MyDetails/data.h b/plugins/MyDetails/data.h index 9c458b50dd..4ae35dbce7 100644 --- a/plugins/MyDetails/data.h +++ b/plugins/MyDetails/data.h @@ -27,65 +27,57 @@ Boston, MA 02111-1307, USA. class Protocol { // Attributes //////////// - std::string name; - - std::string description; +protected: + bool valid; + bool can_set_nick; + bool can_have_avatar; + bool can_have_listening_to; + int PF3; - bool avatar_initialized; - std::string avatar_file; - HBITMAP avatar_bmp; - - bool status_message_initialized; - std::string status_message; + void lcopystr(TCHAR *dest, TCHAR *src, int maxlen); - bool nickname_initialized; - std::string nickname; +public: + // Name of protocol + char name[256]; + char description[256]; + TCHAR nickname[256]; + TCHAR status_name[256]; + TCHAR *custom_status_name; + TCHAR status_message[1024]; + TCHAR *custom_status_message; + TCHAR listening_to[1024]; + AVATARCACHEENTRY *ace; + TCHAR avatar_file[1024]; + HBITMAP avatar_bmp; + int status; + int custom_status; - bool locked_initialized; - bool locked; + int avatar_max_width; + int avatar_max_height; - bool emails_initialized; - int emails; + bool data_changed; - bool listening_to_initialized; - std::string listening_to; - bool status_initialized; - std::string status_name; - std::string custom_status_name_key; - std::string custom_status_message_key; - int status; - int custom_status; + // Methods /////////////// -public: Protocol(const char *name); ~Protocol(); bool IsValid(); - operator bool (); - void UpdateAll(); - - const char * GetName(); - const char * GetDescription(); - - const char * GetStatusName(); - const char * GetCustomStatusNameKey(); - const char * GetCustomStatusMessageKey(); - int GetStatus(); - int GetCustomStatus(); + int GetStatus(); // Copy to cache and return a copy void SetStatus(int aStatus); bool HasAvatar(); bool CanGetAvatar(); - const char * GetAvatarFile(); - HBITMAP GetAvatarImage(); + void GetAvatar(); // Copy to cache bool CanSetAvatar(); void SetAvatar(const TCHAR *file_name); + //void SetAvatar(const char *file_name, HBITMAP hBmp); bool CanGetNick(); - const char * GetNick(); + TCHAR * GetNick(); // Copy to cache and return a copy int GetNickMaxLength(); bool CanSetNick(); void SetNick(const TCHAR *nick); @@ -93,42 +85,27 @@ public: bool CanGetListeningTo(); bool CanSetListeningTo(); bool ListeningToEnabled(); - const char * GetListeningTo(); + TCHAR * GetListeningTo(); // Copy to cache and return a copy bool CanGetStatusMsg(); bool CanGetStatusMsg(int aStatus); + TCHAR * GetStatusMsg(); // Copy to cache and return a copy void GetStatusMsg(int aStatus, TCHAR *msg, size_t msg_size); - const char * GetStatusMsg(); - bool CanSetStatusMsg(); bool CanSetStatusMsg(int aStatus); void SetStatusMsg(const TCHAR *message); void SetStatusMsg(int aStatus, const TCHAR *message); - - bool IsLocked(); - - bool CanGetEmailCount(); - int GetEmailCount(); - - int Call(const char *service, WPARAM wParam = 0, LPARAM lParam = 0); - bool CanCall(const char *service); - - std::string GetDBSettingString(const char *key, const char *def = ""); - -private: - void UpdateStatus(); - void UpdateAvatar(); - void UpdateNick(); - void UpdateListeningTo(); - void UpdateStatusMsg(); - void UpdateLocked(); - void UpdateEmailCount(); }; class ProtocolArray { +protected: + // Attributes //////////// + Protocol **buffer; + int buffer_len; + public: TCHAR default_nick[256]; TCHAR default_avatar_file[256]; @@ -136,8 +113,16 @@ public: // Methods /////////////// - ProtocolArray(); + ProtocolArray(int max_size); + virtual ~ProtocolArray(); + + int GetSize(); + + void Add(Protocol *p); + Protocol * Get(int i); + Protocol * Get(const char *name); + void GetAvatars(); bool CanSetAvatars(); void SetAvatars(const TCHAR *file); @@ -148,8 +133,12 @@ public: void SetStatusMsgs(const TCHAR *message); void SetStatusMsgs(int status, const TCHAR *message); + void GetStatusMsgs(); + void GetStatuses(); int GetGlobalStatus(); + bool CanSetStatusMsgPerProtocol(); + void GetDefaultNick(); // Copy to cache void GetDefaultAvatar(); // Copy to cache TCHAR * GetDefaultStatusMsg(); // Copy to cache @@ -162,15 +151,6 @@ public: extern ProtocolArray *protocols; -void SetCurrentProtocol(int index); -Protocol * GetCurrentProtocol(bool createIfDontExist = true); -int GetCurrentProtocolIndex(); - -void GetProtocols(std::vector *result); -int GetProtocolIndexByName(const char *moduleName); -int GetNumProtocols(); -Protocol GetProtocolByIndex(int index); -Protocol GetProtocolByName(const char *proto); void InitProtocolData(); void DeInitProtocolData(); diff --git a/plugins/MyDetails/frame.cpp b/plugins/MyDetails/frame.cpp index d5b609a4e9..a14883c639 100644 --- a/plugins/MyDetails/frame.cpp +++ b/plugins/MyDetails/frame.cpp @@ -22,7 +22,6 @@ Boston, MA 02111-1307, USA. #include "frame.h" #include "wingdi.h" #include "winuser.h" -#include // Prototypes ///////////////////////////////////////////////////////////////////////////////////// @@ -36,14 +35,22 @@ Boston, MA 02111-1307, USA. #define ID_RECALC_TIMER 1012 #define ID_STATUSMESSAGE_TIMER 1013 -#define RECALC_TIME 500 +#define RECALC_TIME 1000 #define IDC_HAND MAKEINTRESOURCE(32649) +#define DEFAULT_NICKNAME "" +#define DEFAULT_STATUS_MESSAGE "" +#define DEFAULT_LISTENING_TO "" + // Messages #define MWM_REFRESH (WM_USER+10) -#define MWM_REFRESH_DATA (WM_USER+18) +#define MWM_NICK_CHANGED (WM_USER+11) +#define MWM_STATUS_CHANGED (WM_USER+12) +#define MWM_STATUS_MSG_CHANGED (WM_USER+13) +#define MWM_AVATAR_CHANGED (WM_USER+14) +#define MWM_LISTENINGTO_CHANGED (WM_USER+15) HWND hwnd_frame = NULL; @@ -53,15 +60,33 @@ int frame_id = -1; HANDLE hMenuShowHideFrame = 0; +#define FONT_NICK 0 +#define FONT_PROTO 1 +#define FONT_STATUS 2 +#define FONT_AWAY_MSG 3 +#define FONT_LISTENING_TO 4 +#define NUM_FONTS 5 + +FontID font_id[NUM_FONTS]; +HFONT hFont[NUM_FONTS]; +COLORREF font_colour[NUM_FONTS]; + +// Defaults +char *font_names[] = { "Nickname", "Protocol", "Status", "Status Message", "Listening To" }; +char font_sizes[] = { 13, 8, 8, 8, 8 }; +BYTE font_styles[] = { DBFONTF_BOLD, 0, 0, DBFONTF_ITALIC, DBFONTF_ITALIC }; +COLORREF font_colors[] = { RGB(0,0,0), RGB(0,0,0), RGB(0,0,0), RGB(150,150,150), RGB(150,150,150) }; + + int CreateFrame(); void FixMainMenu(); -void UpdateFrameData(); +void RefreshFrame(); void RedrawFrame(); // used when no multiwindow functionality available -BOOL MyDetailsFrameVisible(); -void SetMyDetailsFrameVisible(BOOL visible); +bool MyDetailsFrameVisible(); +void SetMyDetailsFrameVisible(bool visible); int ShowHideMenuFunc(WPARAM wParam, LPARAM lParam); int ShowFrameFunc(WPARAM wParam, LPARAM lParam); int HideFrameFunc(WPARAM wParam, LPARAM lParam); @@ -80,295 +105,66 @@ int AvatarChangedHook(WPARAM wParam, LPARAM lParam); int ProtoAckHook(WPARAM wParam, LPARAM lParam); int SmileyAddOptionsChangedHook(WPARAM wParam,LPARAM lParam); int ListeningtoEnableStateChangedHook(WPARAM wParam,LPARAM lParam); -int AccListChanged(WPARAM wParam, LPARAM lParam); - - -void ExternalRect(RECT &ret, const RECT r1, const RECT r2); -bool InsideRect(const POINT &p, const RECT &r); - - -int operator==(const RECT& left, const RECT& right) -{ - return left.left == right.left && left.right == right.right - && left.top == right.top && left.bottom == right.bottom; -} - -class ToolTipArea -{ -public: - ToolTipArea() : hwndTT(0), hwndParent(0) { memset(&rc, 0, sizeof(rc)); } - ~ToolTipArea() { removeTooltip(); } - - void createTooltip(HWND hwnd, const RECT &rc, const TCHAR *text) - { - if (text == NULL || text[0] == 0) - { - removeTooltip(); - return; - } - - this->text = text; - - if (this->rc == rc && hwndParent == hwnd && hwndTT != NULL) - return; - - removeTooltip(); - - this->rc = rc; - this->hwndParent = hwnd; - this->hwndTT = CreateTooltip(this->hwndParent, this->rc); - } - - void removeTooltip() - { - if (hwndTT == NULL) - return; - - DestroyWindow(hwndTT); - hwndTT = NULL; - hwndParent = NULL; - } - - const TCHAR * getTextFor(HWND hwndFrom) - { - if (hwndTT == NULL || hwndTT != hwndFrom) - return NULL; - return text.c_str(); - } - - -private: - - HWND hwndTT; - RECT rc; - HWND hwndParent; - std::tstring text; - - HWND CreateTooltip(HWND hwnd, RECT &rect) - { - // struct specifying control classes to register - INITCOMMONCONTROLSEX iccex; - HWND hwndTT; // handle to the ToolTip control - // struct specifying info about tool in ToolTip control - TOOLINFO ti; - unsigned int uid = 0; // for ti initialization - - // Load the ToolTip class from the DLL. - iccex.dwSize = sizeof(iccex); - iccex.dwICC = ICC_BAR_CLASSES; - - if(!InitCommonControlsEx(&iccex)) - return NULL; - - /* CREATE A TOOLTIP WINDOW */ - hwndTT = CreateWindowEx(WS_EX_TOPMOST, - TOOLTIPS_CLASS, - NULL, - WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, - CW_USEDEFAULT, - CW_USEDEFAULT, - CW_USEDEFAULT, - CW_USEDEFAULT, - hwnd, - NULL, - hInst, - NULL - ); - - /* Gives problem with mToolTip - SetWindowPos(hwndTT, - HWND_TOPMOST, - 0, - 0, - 0, - 0, - SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); - */ - - /* INITIALIZE MEMBERS OF THE TOOLINFO STRUCTURE */ - ti.cbSize = sizeof(TOOLINFO); - ti.uFlags = TTF_SUBCLASS; - ti.hwnd = hwnd; - ti.hinst = hInst; - ti.uId = uid; - ti.lpszText = LPSTR_TEXTCALLBACK; - // ToolTip control will cover the whole window - ti.rect.left = rect.left; - ti.rect.top = rect.top; - ti.rect.right = rect.right; - ti.rect.bottom = rect.bottom; - - /* SEND AN ADDTOOL MESSAGE TO THE TOOLTIP CONTROL WINDOW */ - SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti); - SendMessage(hwndTT, TTM_SETDELAYTIME, (WPARAM) (DWORD) TTDT_AUTOPOP, (LPARAM) MAKELONG(24 * 60 * 60 * 1000, 0)); - - return hwndTT; - } -}; - - -struct SimpleItem -{ - RECT rc; - bool draw; - bool mouseOver; - ToolTipArea tt; - bool alignRight; - - SimpleItem() : draw(FALSE), mouseOver(FALSE), alignRight(FALSE) - { - memset(&rc, 0, sizeof(rc)); - } - virtual ~SimpleItem() {} - - virtual void hide() - { - draw = false; - mouseOver = false; - tt.removeTooltip(); - } - - virtual void update(HWND hwnd, SkinFieldState *item) - { - draw = item->isVisible(); - alignRight = ( item->getHorizontalAlign() == SKN_HALIGN_RIGHT ); - - if (draw) - { - rc = item->getRect(); - tt.createTooltip(hwnd, rc, item->getToolTip()); - } - else - { - tt.removeTooltip(); - } - } - - virtual bool hitTest(const POINT &p) - { - return draw && InsideRect(p, rc); - } - - virtual const TCHAR * getToolTipFor(HWND hwndFrom) - { - return tt.getTextFor(hwndFrom); - } - bool setMouseOver(POINT *mousePos) - { - bool over = (mousePos != NULL && hitTest(*mousePos)); - - if (mouseOver == over) - return FALSE; - - mouseOver = over; - return TRUE; - } - -}; - -struct IconAndItem : public SimpleItem -{ - RECT rcIcon; - RECT rcItem; - BOOL drawIcon; - BOOL drawItem; - ToolTipArea ttIcon; - - IconAndItem() : drawIcon(FALSE), drawItem(FALSE) - { - memset(&rcIcon, 0, sizeof(rcIcon)); - memset(&rcItem, 0, sizeof(rcItem)); - } - virtual ~IconAndItem() {} - - virtual void hide() - { - SimpleItem::hide(); - drawIcon = FALSE; - drawItem = FALSE; - } - - virtual void update(HWND hwnd, SkinIconFieldState *icon, SkinTextFieldState *item) - { - drawIcon = icon->isVisible(); - drawItem = item->isVisible(); - alignRight = ( item->getHorizontalAlign() == SKN_HALIGN_RIGHT ); - draw = drawIcon || drawItem; - if (draw) - { - if (drawIcon) - rcIcon = icon->getRect(); - if (drawItem) - rcItem = item->getRect(); - - if (drawIcon && drawItem) - ExternalRect(rc, rcIcon, rcItem); - else if (drawIcon) - rc = rcIcon; - else // if (drawItem) - rc = rcItem; - } - - if (drawItem) - tt.createTooltip(hwnd, rcItem, item->getToolTip()); - else - tt.removeTooltip(); - - if (drawIcon) - ttIcon.createTooltip(hwnd, rcIcon, icon->getToolTip()); - else - ttIcon.removeTooltip(); - } - - virtual const TCHAR * getToolTipFor(HWND hwndFrom) - { - const TCHAR * ret = tt.getTextFor(hwndFrom); - - if (ret == NULL) - ret = ttIcon.getTextFor(hwndFrom); - - return ret; - } -}; +#define OUTSIDE_BORDER 6 +#define SPACE_IMG_TEXT 6 +#define SPACE_TEXT_TEXT 0 +#define SPACE_ICON_TEXT 2 +#define ICON_SIZE 16 +#define BORDER_SPACE 2 struct MyDetailsFrameData { - std::vector items; - SimpleItem proto; - SimpleItem proto_cycle_next; - SimpleItem proto_cycle_prev; - SimpleItem avatar; - SimpleItem nick; - IconAndItem status; - SimpleItem away_msg; - IconAndItem listening_to; - IconAndItem email; + RECT proto_rect; + bool draw_proto; + bool mouse_over_proto; + + bool draw_proto_cycle; + RECT next_proto_rect; + HWND next_proto_tt_hwnd; + RECT prev_proto_rect; + HWND prev_proto_tt_hwnd; + + RECT img_rect; + bool draw_img; + bool mouse_over_img; + + RECT nick_rect; + bool draw_nick; + bool mouse_over_nick; + HWND nick_tt_hwnd; + + RECT status_rect; + RECT status_icon_rect; + RECT status_text_rect; + bool draw_status; + bool mouse_over_status; + HWND status_tt_hwnd; + + RECT away_msg_rect; + bool draw_away_msg; + bool mouse_over_away_msg; + HWND away_msg_tt_hwnd; + + RECT listening_to_rect; + RECT listening_to_icon_rect; + RECT listening_to_text_rect; + bool draw_listening_to; + bool mouse_over_listening_to; + HWND listening_to_tt_hwnd; + + int protocol_number; bool showing_menu; - bool tracking_exit; + bool recalc_rectangles; - MyDetailsFrameData() - : showing_menu(false) - , tracking_exit(false) - { - items.push_back(&proto); - items.push_back(&proto_cycle_next); - items.push_back(&proto_cycle_prev); - items.push_back(&avatar); - items.push_back(&nick); - items.push_back(&status); - items.push_back(&away_msg); - items.push_back(&listening_to); - items.push_back(&email); - } + bool get_status_messages; }; - // Functions ////////////////////////////////////////////////////////////////////////////////////// void InitFrames() @@ -382,7 +178,6 @@ void InitFrames() HookEvent(ME_PROTO_ACK, ProtoAckHook); HookEvent(ME_SMILEYADD_OPTIONSCHANGED,SmileyAddOptionsChangedHook); HookEvent(ME_LISTENINGTO_ENABLE_STATE_CHANGED,ListeningtoEnableStateChangedHook); - HookEvent(ME_PROTO_ACCLISTCHANGED, AccListChanged); } @@ -393,20 +188,94 @@ void DeInitFrames() CallService(MS_CLIST_FRAMES_REMOVEFRAME, (WPARAM)frame_id, 0); } + for (int i = 0 ; i < NUM_FONTS ; i++ ) + { + if (hFont[i] != 0) DeleteObject(hFont[i]); + } + if (hwnd_frame != NULL) DestroyWindow(hwnd_frame); if (hwnd_container != NULL) DestroyWindow(hwnd_container); } -int SmileyAddOptionsChangedHook(WPARAM wParam,LPARAM lParam) + +int ReloadFont(WPARAM wParam, LPARAM lParam) { - UpdateFrameData(); + LOGFONT log_font; + + for (int i = 0 ; i < NUM_FONTS ; i++ ) + { + if (hFont[i] != 0) DeleteObject(hFont[i]); + + font_colour[i] = CallService(MS_FONT_GET, (WPARAM)&font_id[i], (LPARAM)&log_font); + hFont[i] = CreateFontIndirect(&log_font); + } + + RefreshFrame(); return 0; } -int SkinEngineDrawCallback(HWND hWnd, HDC hDC, RECT * rcPaint, HRGN rgn, DWORD dFlags, void * CallBackData); +int SmileyAddOptionsChangedHook(WPARAM wParam,LPARAM lParam) +{ + RefreshFrame(); + return 0; +} int CreateFrame() { + if(ServiceExists(MS_FONT_REGISTER)) + { + HDC hdc = GetDC(NULL); + + for (int i = 0 ; i < NUM_FONTS ; i++ ) + { + ZeroMemory(&font_id[i], sizeof(font_id[i])); + + font_id[i].cbSize = sizeof(FontID); + strncpy(font_id[i].group, Translate("My Details"), sizeof(font_id[i].group)); + strncpy(font_id[i].name, Translate(font_names[i]), sizeof(font_id[i].name)); + strncpy(font_id[i].dbSettingsGroup, MODULE_NAME, sizeof(font_id[i].dbSettingsGroup)); + + char tmp[128]; + mir_snprintf(tmp, sizeof(tmp), "%sFont", font_names[i]); + strncpy(font_id[i].prefix, tmp, sizeof(font_id[i].prefix)); + + font_id[i].deffontsettings.colour = font_colors[i]; + font_id[i].deffontsettings.size = -MulDiv(font_sizes[i], GetDeviceCaps(hdc, LOGPIXELSY), 72); + font_id[i].deffontsettings.style = font_styles[i]; + font_id[i].deffontsettings.charset = DEFAULT_CHARSET; + strncpy(font_id[i].deffontsettings.szFace, "Tahoma", sizeof(font_id[i].deffontsettings.szFace)); + font_id[i].order = i; + font_id[i].flags = FIDF_DEFAULTVALID; + + CallService(MS_FONT_REGISTER, (WPARAM)&font_id[i], 0); + } + + ReleaseDC(NULL, hdc); + + ReloadFont(0,0); + HookEvent(ME_FONT_RELOAD, ReloadFont); + } + else + { + LOGFONT lf; + ZeroMemory(&lf, sizeof(lf)); + lf.lfCharSet = DEFAULT_CHARSET; + + HDC hdc = GetDC(NULL); + + for (int i = 0 ; i < NUM_FONTS ; i++ ) + { + lf.lfHeight = -MulDiv(font_sizes[i], GetDeviceCaps(hdc, LOGPIXELSY), 72); + lf.lfWeight = font_styles[i] == DBFONTF_BOLD ? FW_BOLD : FW_NORMAL; + lf.lfItalic = font_styles[i] == DBFONTF_ITALIC ? TRUE : FALSE; + strncpy(lf.lfFaceName, "Tahoma", sizeof(lf.lfFaceName)); + + hFont[i] = CreateFontIndirect(&lf); + font_colour[i] = font_colors[i]; + } + } + + WNDCLASS wndclass; wndclass.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW; //CS_PARENTDC | CS_HREDRAW | CS_VREDRAW; wndclass.lpfnWndProc = FrameWindowProc; @@ -429,20 +298,15 @@ int CreateFrame() CLISTFrame Frame = {0}; Frame.cbSize = sizeof(Frame); - Frame.name = "My Details"; - Frame.TBname = Translate("My Details"); + Frame.name = Translate("My Details"); + Frame.cbSize = sizeof(CLISTFrame); Frame.hWnd = hwnd_frame; Frame.align = alTop; - Frame.Flags = F_VISIBLE | F_SHOWTB | F_SHOWTBTIP | F_NOBORDER | F_NO_SUBCONTAINER; + Frame.Flags = F_VISIBLE | F_SHOWTB | F_SHOWTBTIP | F_NOBORDER; Frame.height = 100; frame_id = CallService(MS_CLIST_FRAMES_ADDFRAME, (WPARAM)&Frame, 0); - if (ServiceExists(MS_SKINENG_REGISTERPAINTSUB)) - { - CallService(MS_BACKGROUNDCONFIG_REGISTER,(WPARAM)"My Details Background/MyDetails", 0); - CallService(MS_SKINENG_REGISTERPAINTSUB, (WPARAM) Frame.hWnd, (LPARAM) SkinEngineDrawCallback); - } if (DBGetContactSettingByte(NULL, "MyDetails", "ForceHideFrame", 0)) { @@ -516,7 +380,7 @@ int CreateFrame() } -BOOL FrameIsFloating() +bool FrameIsFloating() { if (frame_id == -1) { @@ -621,200 +485,214 @@ RECT GetInnerRect(const RECT &rc, const RECT &clipping) } - - - -void ExternalRect(RECT &ret, const RECT r1, const RECT r2) -{ - ret.left = min(r1.left, r2.left); - ret.right = max(r1.right, r2.right); - ret.top = min(r1.top, r2.top); - ret.bottom = max(r1.bottom, r2.bottom); -} - - -HBITMAP CreateBitmap32(int cx, int cy) +RECT GetRect(HDC hdc, RECT rc, SIZE s, UINT uFormat, int next_top, int text_left, bool frame = true, + bool end_elipsis_on_frame = true) { - BITMAPINFO RGB32BitsBITMAPINFO; - UINT * ptPixels; - HBITMAP DirectBitmap; - - ZeroMemory(&RGB32BitsBITMAPINFO,sizeof(BITMAPINFO)); - RGB32BitsBITMAPINFO.bmiHeader.biSize=sizeof(BITMAPINFOHEADER); - RGB32BitsBITMAPINFO.bmiHeader.biWidth=cx;//bm.bmWidth; - RGB32BitsBITMAPINFO.bmiHeader.biHeight=cy;//bm.bmHeight; - RGB32BitsBITMAPINFO.bmiHeader.biPlanes=1; - RGB32BitsBITMAPINFO.bmiHeader.biBitCount=32; - - DirectBitmap = CreateDIBSection(NULL, - (BITMAPINFO *)&RGB32BitsBITMAPINFO, - DIB_RGB_COLORS, - (void **)&ptPixels, - NULL, 0); - return DirectBitmap; -} + RECT r = rc; + if (frame && end_elipsis_on_frame) + { + // Add space to ... + uFormat &= ~DT_END_ELLIPSIS; -BOOL UseLayeredMode() -{ - return isLayeredEnabled() && !FrameIsFloating(); -} + RECT rc_tmp = rc; + DrawText(hdc, " ...", 4, &rc_tmp, DT_CALCRECT | uFormat); + s.cx += rc_tmp.right - rc_tmp.left; + } -void EraseBackground(HWND hwnd, HDC hdc) -{ - RECT r; - GetClientRect(hwnd, &r); + r.top = next_top; + r.bottom = r.top + s.cy; - if (isSkinEngineEnabled()) + if (opts.draw_text_align_right) { - if (FrameIsFloating()) - { - HBRUSH hB = CreateSolidBrush(opts.bkg_color); - FillRect(hdc, &r, hB); - DeleteObject(hB); - } - else - { - SkinDrawWindowBack(hwnd, hdc, &r, "Main,ID=Background"); - } - - SkinDrawGlyph(hdc, &r, &r,"MyDetails,ID=Background"); + r.left = r.right - s.cx; } else { - HBRUSH hB = CreateSolidBrush(opts.bkg_color); - FillRect(hdc, &r, hB); - DeleteObject(hB); + r.left = text_left; + r.right = r.left + s.cx; } -} -static int Width(const RECT &rc) -{ - return rc.right - rc.left; -} + if (frame) + { + r.bottom += 2 * BORDER_SPACE; -static int Height(const RECT &rc) -{ - return rc.bottom - rc.top; -} + if (opts.draw_text_align_right) + r.left -= 2 * BORDER_SPACE; + else + r.right += 2 * BORDER_SPACE; + } -static HICON CreateOverlayedIcon(HICON icon, HICON overlay) -{ - HIMAGELIST il = ImageList_Create( - GetSystemMetrics(SM_CXICON), - GetSystemMetrics(SM_CYICON), - ILC_COLOR32|ILC_MASK, 2, 2); - ImageList_AddIcon(il, icon); - ImageList_AddIcon(il, overlay); - HIMAGELIST newImage = ImageList_Merge(il,0,il,1,0,0); - ImageList_Destroy(il); - HICON hIcon = ImageList_GetIcon(newImage, 0, 0); - ImageList_Destroy(newImage); - return hIcon; // the result should be destroyed by DestroyIcon() + // Make it fit inside original rc + r.top = max(next_top, r.top); + r.bottom = min(rc.bottom, r.bottom); + r.left = max(text_left, r.left); + r.right = min(rc.right, r.right); + + return r; } -void Draw(HDC hdc, SkinIconFieldState &state) +RECT GetRect(HDC hdc, RECT rc, const char *text, const char *def_text, Protocol *proto, UINT uFormat, + int next_top, int text_left, bool smileys = true, bool frame = true, bool end_elipsis_on_frame = true) { - if (!state.isVisible()) - return; + const char *tmp; - RECT rc = state.getInsideRect(); - HRGN rgn = CreateRectRgnIndirect(&rc); - SelectClipRgn(hdc, rgn); + if (text[0] == '\0') + tmp = Translate(def_text); + else + tmp = text; - rc = state.getInsideRect(true); + uFormat &= ~DT_END_ELLIPSIS; - skin_DrawIconEx(hdc, rc.left, rc.top, state.getIcon(), Width(rc), Height(rc), 0, NULL, DI_NORMAL); + SIZE s; + RECT r_tmp = rc; - SelectClipRgn(hdc, NULL); - DeleteObject(rgn); -} + // Only first line + char *tmp2 = strdup(tmp); + char *pos = strchr(tmp2, '\r'); + if (pos != NULL) pos[0] = '\0'; + pos = strchr(tmp2, '\n'); + if (pos != NULL) pos[0] = '\0'; -void Draw(HDC hdc, SkinTextFieldState &state, BOOL replace_smileys = FALSE, const char *protocol = NULL) -{ - if (!state.isVisible()) - return; + if (smileys) + DRAW_TEXT(hdc, tmp2, strlen(tmp2), &r_tmp, uFormat | DT_CALCRECT, proto->name, NULL); + else + DrawText(hdc, tmp2, strlen(tmp2), &r_tmp, uFormat | DT_CALCRECT); - RECT rc = state.getInsideRect(); - HRGN rgn = CreateRectRgnIndirect(&rc); - SelectClipRgn(hdc, rgn); + free(tmp2); - HGDIOBJ oldFont = SelectObject(hdc, state.getFont()); - COLORREF oldColor = SetTextColor(hdc, state.getFontColor()); + s.cx = r_tmp.right - r_tmp.left; + s.cy = r_tmp.bottom - r_tmp.top; - UINT uFormat = DT_NOPREFIX | DT_END_ELLIPSIS | (opts.draw_text_rtl ? DT_RTLREADING : 0); + return GetRect(hdc, rc, s, uFormat, next_top, text_left, frame, end_elipsis_on_frame); +} - switch(state.getHorizontalAlign()) - { - case SKN_HALIGN_RIGHT: - uFormat |= DT_RIGHT; - break; - case SKN_HALIGN_CENTER: - uFormat |= DT_CENTER; - break; - case SKN_HALIGN_LEFT: - uFormat |= DT_LEFT; - break; +HWND CreateTooltip(HWND hwnd, RECT &rect) +{ + // struct specifying control classes to register + INITCOMMONCONTROLSEX iccex; + HWND hwndTT; // handle to the ToolTip control + // struct specifying info about tool in ToolTip control + TOOLINFO ti; + unsigned int uid = 0; // for ti initialization + + // Load the ToolTip class from the DLL. + iccex.dwSize = sizeof(iccex); + iccex.dwICC = ICC_BAR_CLASSES; + + if(!InitCommonControlsEx(&iccex)) + return NULL; + + /* CREATE A TOOLTIP WINDOW */ + hwndTT = CreateWindowEx(WS_EX_TOPMOST, + TOOLTIPS_CLASS, + NULL, + WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, + CW_USEDEFAULT, + CW_USEDEFAULT, + CW_USEDEFAULT, + CW_USEDEFAULT, + hwnd, + NULL, + hInst, + NULL + ); + + /* Gives problem with mToolTip + SetWindowPos(hwndTT, + HWND_TOPMOST, + 0, + 0, + 0, + 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); + */ + + /* INITIALIZE MEMBERS OF THE TOOLINFO STRUCTURE */ + ti.cbSize = sizeof(TOOLINFO); + ti.uFlags = TTF_SUBCLASS; + ti.hwnd = hwnd; + ti.hinst = hInst; + ti.uId = uid; + ti.lpszText = LPSTR_TEXTCALLBACK; + // ToolTip control will cover the whole window + ti.rect.left = rect.left; + ti.rect.top = rect.top; + ti.rect.right = rect.right; + ti.rect.bottom = rect.bottom; + + /* SEND AN ADDTOOL MESSAGE TO THE TOOLTIP CONTROL WINDOW */ + SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti); + SendMessage(hwndTT, TTM_SETDELAYTIME, (WPARAM) (DWORD) TTDT_AUTOPOP, (LPARAM) MAKELONG(24 * 60 * 60 * 1000, 0)); + + return hwndTT; +} + +void DeleteTooltipWindows(MyDetailsFrameData *data) +{ + if (data->nick_tt_hwnd != NULL) + { + DestroyWindow(data->nick_tt_hwnd); + data->nick_tt_hwnd = NULL; } - if (replace_smileys && opts.replace_smileys) - { - uFormat |= DT_SINGLELINE; - - // Draw only first line of text - char *tmp = strdup(state.getText()); - char *pos = strchr(tmp, '\r'); - if (pos != NULL) - pos[0] = '\0'; - pos = strchr(tmp, '\n'); - if (pos != NULL) - pos[0] = '\0'; - - Smileys_DrawText(hdc, tmp, -1, &rc, uFormat | (opts.resize_smileys ? DT_RESIZE_SMILEYS : 0), - opts.use_contact_list_smileys ? "clist" : protocol, NULL); - } - else - { - skin_DrawText(hdc, state.getText(), -1, &rc, uFormat); + if (data->status_tt_hwnd != NULL) + { + DestroyWindow(data->status_tt_hwnd); + data->status_tt_hwnd = NULL; } + if (data->next_proto_tt_hwnd != NULL) + { + DestroyWindow(data->next_proto_tt_hwnd); + data->next_proto_tt_hwnd = NULL; + } - SelectObject(hdc, oldFont); - SetTextColor(hdc, oldColor); - - SelectClipRgn(hdc, NULL); - DeleteObject(rgn); -} - - -void DrawMouseOver(HDC hdc, RECT *lprc, const char *place) -{ - if (isSkinEngineEnabled()) - { - SkinDrawGlyph(hdc, lprc, lprc, "MyDetails,ID=MouseOver"); + if (data->prev_proto_tt_hwnd != NULL) + { + DestroyWindow(data->prev_proto_tt_hwnd); + data->prev_proto_tt_hwnd = NULL; + } - char glyph[1024]; - mir_snprintf(glyph, MAX_REGS(glyph), "MyDetails,ID=MouseOver%s", place); - SkinDrawGlyph(hdc, lprc, lprc, glyph); + if (data->away_msg_tt_hwnd != NULL) + { + DestroyWindow(data->away_msg_tt_hwnd); + data->away_msg_tt_hwnd = NULL; } - else - { - FrameRect(hdc, lprc, (HBRUSH) GetStockObject(GRAY_BRUSH)); + + if (data->listening_to_tt_hwnd != NULL) + { + DestroyWindow(data->listening_to_tt_hwnd); + data->listening_to_tt_hwnd = NULL; } } - -void Draw(HWND hwnd, HDC hdc_orig) +void CalcRectangles(HWND hwnd) { - MyDetailsFrameData *data = (MyDetailsFrameData *) GetWindowLong(hwnd, GWL_USERDATA); + HDC hdc = GetDC(hwnd); + HFONT hOldFont = (HFONT) GetCurrentObject(hdc, OBJ_FONT); + MyDetailsFrameData *data = (MyDetailsFrameData *)GetWindowLong(hwnd, GWL_USERDATA); - Protocol *proto = GetCurrentProtocol(); + if (hdc == NULL || data == NULL) + return; + + Protocol *proto = protocols->Get(data->protocol_number); if (proto == NULL) - { - EraseBackground(hwnd, hdc_orig); return; - } + + data->recalc_rectangles = false; + proto->data_changed = false; + + data->draw_proto = false; + data->draw_proto_cycle = false; + data->draw_img = false; + data->draw_nick = false; + data->draw_status = false; + data->draw_away_msg = false; + data->draw_listening_to = false; + + DeleteTooltipWindows(data); if (ServiceExists(MS_CLIST_FRAMES_SETFRAMEOPTIONS) && frame_id != -1) { @@ -824,7 +702,9 @@ void Draw(HWND hwnd, HDC hdc_orig) RECT rf; GetClientRect(hwnd, &rf); - if (rf.bottom - rf.top != 0) + int size = 0; + + if (rf.bottom - rf.top != size) { if (FrameIsFloating()) { @@ -840,212 +720,571 @@ void Draw(HWND hwnd, HDC hdc_orig) if(ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) diff += (r_window.top - rp_window.top); - SetWindowPos(parent, 0, 0, 0, rp_window.right - rp_window.left, diff, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); + SetWindowPos(parent, 0, 0, 0, rp_window.right - rp_window.left, size + diff, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); } } } - - for (size_t i = 0; i < data->items.size(); ++i) - data->items[i]->hide(); - + SelectObject(hdc, hOldFont); + ReleaseDC(hwnd, hdc); return; } } + RECT r; + GetClientRect(hwnd, &r); - RECT r_full; - GetClientRect(hwnd, &r_full); + if (opts.resize_frame) + r.bottom = 0x7FFFFFFF; - HDC hdc; - HBITMAP hBmp; - BOOL useLayeredMode = UseLayeredMode(); - if (useLayeredMode) - { - hdc = hdc_orig; - hBmp = NULL; - } - else - { - hdc = CreateCompatibleDC(hdc_orig); - hBmp = CreateBitmap32(Width(r_full), Height(r_full)); - SelectObject(hdc, hBmp); - } + int next_top; + int text_left; + int avatar_bottom = 0; - int old_bk_mode = SetBkMode(hdc, TRANSPARENT); - HFONT old_font = (HFONT) GetCurrentObject(hdc, OBJ_FONT); - COLORREF old_color = GetTextColor(hdc); - SetStretchBltMode(hdc, HALFTONE); + UINT uFormat = DT_SINGLELINE | DT_NOPREFIX | DT_END_ELLIPSIS + | (opts.draw_text_align_right ? DT_RIGHT : DT_LEFT) + | (opts.draw_text_rtl ? DT_RTLREADING : 0); + // make some borders + r.left += min(opts.borders[LEFT], r.right); + r.right = max(r.right - opts.borders[RIGHT], r.left); + r.top += min(opts.borders[TOP], r.bottom); + r.bottom = max(r.bottom - opts.borders[BOTTOM], r.top); - HICON hStatusIcon; - bool freeStatusIcon = false; - if (proto->GetCustomStatus() != 0 && proto->CanCall(PS_ICQ_GETCUSTOMSTATUSICON)) - hStatusIcon = (HICON) proto->Call(PS_ICQ_GETCUSTOMSTATUSICON, proto->GetCustomStatus(), LR_SHARED); - else - hStatusIcon = LoadSkinnedProtoIcon(proto->GetName(), proto->GetStatus()); + next_top = r.top; + text_left = r.left; - if (proto->IsLocked()) + //if (r.right > r.left && r.bottom > r.top) { - HICON hLockOverlay = LoadSkinnedIcon(SKINICON_OTHER_STATUS_LOCKED); - if (hLockOverlay != NULL) + // Draw image? + //proto->GetAvatar(); + if (proto->CanGetAvatar()) { - freeStatusIcon = true; - hStatusIcon = CreateOverlayedIcon(hStatusIcon, hLockOverlay); - } - } - + if (proto->avatar_bmp != NULL) + { + data->draw_img = true; - HICON hListeningIcon = IcoLib_LoadIcon("LISTENING_TO_ICON"); - HICON hEmailIcon = IcoLib_LoadIcon("MYDETAILS_EMAIL"); - HICON hNextIcon = IcoLib_LoadIcon("MYDETAILS_NEXT_PROTOCOL"); - HICON hPrevIcon = IcoLib_LoadIcon("MYDETAILS_PREV_PROTOCOL"); + BITMAP bmp; + if (GetObject(proto->avatar_bmp, sizeof(bmp), &bmp)) + { + // make bounds + RECT rc = r; - { - dialog->setInfoBool("resize_frame", opts.resize_frame); - dialog->setInfoBool("protocol.locked", proto->IsLocked()); + LONG width; + LONG height; + if (opts.draw_avatar_custom_size) + { + rc.right = opts.draw_avatar_custom_size_pixels; - if (opts.resize_frame) - dialog->setSize(Width(r_full), 0x1FFFFFFF); - else - dialog->setSize(Width(r_full), Height(r_full)); + width = opts.draw_avatar_custom_size_pixels; + height = opts.draw_avatar_custom_size_pixels; + } + else if (opts.resize_frame) + { + rc.right = rc.left + (rc.right - rc.left) / 3; + width = rc.right - rc.left; + height = rc.bottom - rc.top; + } + else + { + rc.right = rc.left + min((rc.right - rc.left) / 3, rc.bottom - rc.top); + + width = rc.right - rc.left; + height = rc.bottom - rc.top; + } + // Fit to image proportions + if (!opts.draw_avatar_allow_to_grow) + { + if (width > bmp.bmWidth) + width = bmp.bmWidth; - SkinImageField avatar = dialog->getImageField("avatar"); - if (proto->CanGetAvatar() && proto->GetAvatarImage() != NULL) - { - avatar.setEnabled(TRUE); - avatar.setImage(proto->GetAvatarImage()); + if (height > bmp.bmHeight) + height = bmp.bmHeight; + } + + if (!opts.resize_frame && height * bmp.bmWidth / bmp.bmHeight <= width) + { + width = height * bmp.bmWidth / bmp.bmHeight; + } + else + { + height = width * bmp.bmHeight / bmp.bmWidth; + } + + rc.right = rc.left + width; + rc.bottom = rc.top + height; + + data->img_rect = rc; + + avatar_bottom = data->img_rect.bottom + SPACE_TEXT_TEXT; + + // Make space to nick + text_left = data->img_rect.right + SPACE_IMG_TEXT; + } + } } - else + + // Always draw nick { - avatar.setEnabled(FALSE); - avatar.setImage(NULL); + data->draw_nick = true; + + SelectObject(hdc, hFont[FONT_NICK]); + + data->nick_rect = GetRect(hdc, r, proto->nickname, DEFAULT_NICKNAME, proto, uFormat, + next_top, text_left); + + if (proto->nickname[0] != '\0') + data->nick_tt_hwnd = CreateTooltip(hwnd, data->nick_rect); + + next_top = data->nick_rect.bottom + SPACE_TEXT_TEXT; } - SkinTextField nickname = dialog->getTextField("nickname"); - nickname.setText(proto->GetNick()); + // Fits more? + if (next_top > r.bottom) + goto finish; + + if (next_top > avatar_bottom && opts.use_avatar_space_to_draw_text) + text_left = r.left; + + // Protocol? + if (opts.draw_show_protocol_name) + { + data->draw_proto = true; + + SelectObject(hdc, hFont[FONT_PROTO]); + + RECT tmp_r = r; + int tmp_text_left = text_left; + if (opts.show_protocol_cycle_button) + { + tmp_r.right -= 2 * ICON_SIZE; + } + + data->proto_rect = GetRect(hdc, tmp_r, proto->description, "", proto, uFormat, + next_top, tmp_text_left, false, true, false); + + + if (opts.show_protocol_cycle_button) + { + data->draw_proto_cycle= true; + + RECT prev = r; + prev.top = next_top; + prev.bottom = min(r.bottom, prev.top + ICON_SIZE); + + int diff = (data->proto_rect.bottom - data->proto_rect.top) - (prev.bottom - prev.top); + if (diff < 0) + { + diff = -diff / 2; + data->proto_rect.top += diff; + data->proto_rect.bottom += diff; + } + else + { + diff = diff / 2; + prev.top += diff; + prev.bottom += diff; + } + + prev.right -= ICON_SIZE; + prev.left = prev.right - ICON_SIZE; + + RECT next = prev; + next.left += ICON_SIZE; + next.right += ICON_SIZE; + + prev.left = max(text_left, prev.left); + prev.right = min(r.right, prev.right); + next.left = max(text_left, next.left); + next.right = min(r.right, next.right); + + data->prev_proto_rect = prev; + data->next_proto_rect = next; + + data->next_proto_tt_hwnd = CreateTooltip(hwnd, data->next_proto_rect); + data->prev_proto_tt_hwnd = CreateTooltip(hwnd, data->prev_proto_rect); - SkinTextField protocol = dialog->getTextField("protocol"); - protocol.setText(proto->GetDescription()); - SkinIconField status_icon = dialog->getIconField("status_icon"); - status_icon.setIcon(hStatusIcon); + next_top = max(data->next_proto_rect.bottom, data->proto_rect.bottom) + SPACE_TEXT_TEXT; + } + else + { + next_top = data->proto_rect.bottom + SPACE_TEXT_TEXT; + } + } + + // Fits more? + if (next_top + 2 * BORDER_SPACE > r.bottom) + goto finish; - SkinTextField status_name = dialog->getTextField("status_name"); - status_name.setText(proto->GetStatusName()); + if (next_top > avatar_bottom && opts.use_avatar_space_to_draw_text) + text_left = r.left; - SkinTextField status_msg = dialog->getTextField("status_msg"); - if (proto->CanGetStatusMsg()) + // Status data? { - status_msg.setEnabled(TRUE); - status_msg.setText(proto->GetStatusMsg()); + data->draw_status = true; + + SelectObject(hdc, hFont[FONT_STATUS]); + + // Text size + RECT r_tmp = r; + DrawText(hdc, proto->status_name, strlen(proto->status_name), &r_tmp, + DT_CALCRECT | (uFormat & ~DT_END_ELLIPSIS)); + + SIZE s; + s.cy = max(r_tmp.bottom - r_tmp.top, ICON_SIZE); + s.cx = ICON_SIZE + SPACE_ICON_TEXT + r_tmp.right - r_tmp.left; + + // Status global rect + data->status_rect = GetRect(hdc, r, s, uFormat, next_top, text_left, true, false); + + if (proto->status_name[0] != '\0') + data->status_tt_hwnd = CreateTooltip(hwnd, data->status_rect); + + next_top = data->status_rect.bottom + SPACE_TEXT_TEXT; + + RECT rc_inner = data->status_rect; + rc_inner.top += BORDER_SPACE; + rc_inner.bottom -= BORDER_SPACE; + rc_inner.left += BORDER_SPACE; + rc_inner.right -= BORDER_SPACE; + + // Icon + data->status_icon_rect = rc_inner; + + if (opts.draw_text_align_right || opts.draw_text_rtl) + data->status_icon_rect.left = max(data->status_icon_rect.right - ICON_SIZE, rc_inner.left); + else + data->status_icon_rect.right = min(data->status_icon_rect.left + ICON_SIZE, rc_inner.right); + + if (r_tmp.bottom - r_tmp.top > ICON_SIZE) + { + data->status_icon_rect.top += (r_tmp.bottom - r_tmp.top - ICON_SIZE) / 2; + data->status_icon_rect.bottom = data->status_icon_rect.top + ICON_SIZE; + } + + // Text + data->status_text_rect = GetInnerRect(rc_inner, r); + + if (opts.draw_text_align_right || opts.draw_text_rtl) + data->status_text_rect.right = max(data->status_icon_rect.left - SPACE_ICON_TEXT, rc_inner.left); + else + data->status_text_rect.left = min(data->status_icon_rect.right + SPACE_ICON_TEXT, rc_inner.right); + + if (ICON_SIZE > r_tmp.bottom - r_tmp.top) + { + data->status_text_rect.top += (ICON_SIZE - (r_tmp.bottom - r_tmp.top)) / 2; + data->status_text_rect.bottom = data->status_text_rect.top + r_tmp.bottom - r_tmp.top; + } } - else + + // Fits more? + if (next_top + 2 * BORDER_SPACE > r.bottom) + goto finish; + + if (next_top > avatar_bottom && opts.use_avatar_space_to_draw_text) + text_left = r.left; + + // Away msg? + if(proto->CanGetStatusMsg()) { - status_msg.setEnabled(FALSE); - status_msg.setText(_T("")); + data->draw_away_msg = true; + + SelectObject(hdc, hFont[FONT_AWAY_MSG]); + + data->away_msg_rect = GetRect(hdc, r, proto->status_message, DEFAULT_STATUS_MESSAGE, proto, uFormat, + next_top, text_left); + + if (proto->status_message[0] != '\0') + data->away_msg_tt_hwnd = CreateTooltip(hwnd, data->away_msg_rect); + + next_top = data->away_msg_rect.bottom + SPACE_TEXT_TEXT; } - SkinIconField listening_icon = dialog->getIconField("listening_icon"); - SkinTextField listening = dialog->getTextField("listening"); - if (proto->ListeningToEnabled() && proto->GetStatus() > ID_STATUS_OFFLINE - && proto->GetListeningTo()[0] != 0) + // Fits more? + if (next_top + 2 * BORDER_SPACE > r.bottom) + goto finish; + + if (next_top > avatar_bottom && opts.use_avatar_space_to_draw_text) + text_left = r.left; + + // Listening to + if(proto->ListeningToEnabled() && proto->GetStatus() > ID_STATUS_OFFLINE) { - listening_icon.setEnabled(TRUE); - listening.setEnabled(TRUE); - listening_icon.setIcon(hListeningIcon); - listening.setText(proto->GetListeningTo()); + data->draw_listening_to = true; + + if (proto->listening_to[0] == '\0') + { + SelectObject(hdc, hFont[FONT_LISTENING_TO]); + + data->listening_to_rect = GetRect(hdc, r, proto->listening_to, DEFAULT_LISTENING_TO, proto, uFormat, + next_top, text_left); + + data->listening_to_text_rect = data->listening_to_rect; + ZeroMemory(&data->listening_to_icon_rect, sizeof(data->listening_to_icon_rect)); + + next_top = data->listening_to_rect.bottom + SPACE_TEXT_TEXT; + } + else + { + SelectObject(hdc, hFont[FONT_LISTENING_TO]); + + // Text size + RECT r_tmp = r; + DrawText(hdc, proto->listening_to, strlen(proto->listening_to), &r_tmp, + DT_CALCRECT | (uFormat & ~DT_END_ELLIPSIS)); + + SIZE s; + s.cy = max(r_tmp.bottom - r_tmp.top, ICON_SIZE); + s.cx = ICON_SIZE + SPACE_ICON_TEXT + r_tmp.right - r_tmp.left; + + // listening to global rect + data->listening_to_rect = GetRect(hdc, r, s, uFormat, next_top, text_left, true, false); + + data->listening_to_tt_hwnd = CreateTooltip(hwnd, data->listening_to_rect); + + next_top = data->listening_to_rect.bottom + SPACE_TEXT_TEXT; + + RECT rc_inner = data->listening_to_rect; + rc_inner.top += BORDER_SPACE; + rc_inner.bottom -= BORDER_SPACE; + rc_inner.left += BORDER_SPACE; + rc_inner.right -= BORDER_SPACE; + + // Icon + data->listening_to_icon_rect = rc_inner; + + if (opts.draw_text_align_right || opts.draw_text_rtl) + data->listening_to_icon_rect.left = max(data->listening_to_icon_rect.right - ICON_SIZE, rc_inner.left); + else + data->listening_to_icon_rect.right = min(data->listening_to_icon_rect.left + ICON_SIZE, rc_inner.right); + + if (r_tmp.bottom - r_tmp.top > ICON_SIZE) + { + data->listening_to_icon_rect.top += (r_tmp.bottom - r_tmp.top - ICON_SIZE) / 2; + data->listening_to_icon_rect.bottom = data->listening_to_icon_rect.top + ICON_SIZE; + } + + // Text + data->listening_to_text_rect = GetInnerRect(rc_inner, r); + + if (opts.draw_text_align_right || opts.draw_text_rtl) + data->listening_to_text_rect.right = max(data->listening_to_icon_rect.left - SPACE_ICON_TEXT, rc_inner.left); + else + data->listening_to_text_rect.left = min(data->listening_to_icon_rect.right + SPACE_ICON_TEXT, rc_inner.right); + + if (ICON_SIZE > r_tmp.bottom - r_tmp.top) + { + data->listening_to_text_rect.top += (ICON_SIZE - (r_tmp.bottom - r_tmp.top)) / 2; + data->listening_to_text_rect.bottom = data->listening_to_text_rect.top + r_tmp.bottom - r_tmp.top; + } + } } - else + } + + r.bottom = max(next_top - SPACE_TEXT_TEXT, avatar_bottom); + + if (opts.resize_frame && ServiceExists(MS_CLIST_FRAMES_SETFRAMEOPTIONS) && frame_id != -1) + { + RECT rf; + GetClientRect(hwnd, &rf); + + int size = r.bottom + opts.borders[BOTTOM]; + + if (rf.bottom - rf.top != size) { - listening_icon.setEnabled(FALSE); - listening.setEnabled(FALSE); - listening_icon.setIcon(NULL); - listening.setText(_T("")); + if (FrameIsFloating()) + { + HWND parent = GetParent(hwnd); + + if (parent != NULL) + { + RECT rp_client, rp_window, r_window; + GetClientRect(parent, &rp_client); + GetWindowRect(parent, &rp_window); + GetWindowRect(hwnd, &r_window); + int diff = (rp_window.bottom - rp_window.top) - (rp_client.bottom - rp_client.top); + if(ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) + diff += (r_window.top - rp_window.top); + + SetWindowPos(parent, 0, 0, 0, rp_window.right - rp_window.left, size + diff, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); + } + } + else if (IsWindowVisible(hwnd) && ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) + { + int flags = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, frame_id), 0); + if(flags & F_VISIBLE) + { + CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_HEIGHT, frame_id), (LPARAM)(size)); + CallService(MS_CLIST_FRAMES_UPDATEFRAME, (WPARAM)frame_id, (LPARAM)(FU_TBREDRAW | FU_FMREDRAW | FU_FMPOS)); + } + } } + } + +finish: + SelectObject(hdc, hOldFont); + ReleaseDC(hwnd, hdc); +} + + +HBITMAP CreateBitmap32(int cx, int cy) +{ + BITMAPINFO RGB32BitsBITMAPINFO; + UINT * ptPixels; + HBITMAP DirectBitmap; - SkinIconField email_icon = dialog->getIconField("email_icon"); - SkinTextField email = dialog->getTextField("email"); - if (proto->CanGetEmailCount()) + ZeroMemory(&RGB32BitsBITMAPINFO,sizeof(BITMAPINFO)); + RGB32BitsBITMAPINFO.bmiHeader.biSize=sizeof(BITMAPINFOHEADER); + RGB32BitsBITMAPINFO.bmiHeader.biWidth=cx;//bm.bmWidth; + RGB32BitsBITMAPINFO.bmiHeader.biHeight=cy;//bm.bmHeight; + RGB32BitsBITMAPINFO.bmiHeader.biPlanes=1; + RGB32BitsBITMAPINFO.bmiHeader.biBitCount=32; + + DirectBitmap = CreateDIBSection(NULL, + (BITMAPINFO *)&RGB32BitsBITMAPINFO, + DIB_RGB_COLORS, + (void **)&ptPixels, + NULL, 0); + return DirectBitmap; +} + + void EraseBackground(HWND hwnd, HDC hdc) +{ + RECT r; + GetClientRect(hwnd, &r); + + HBRUSH hB = CreateSolidBrush((COLORREF) DBGetContactSettingDword(NULL,"MyDetails","BackgroundColor",GetSysColor(COLOR_BTNFACE))); + FillRect(hdc, &r, hB); + DeleteObject(hB); +} + +void DrawTextWithRect(HDC hdc, const char *text, const char *def_text, RECT rc, UINT uFormat, + bool mouse_over, Protocol *proto, bool replace_smileys = true) +{ + const char *tmp; + + if (text[0] == '\0') + tmp = Translate(def_text); + else + tmp = text; + + // Only first line + char *tmp2 = strdup(tmp); + char *pos = strchr(tmp2, '\r'); + if (pos != NULL) pos[0] = '\0'; + pos = strchr(tmp2, '\n'); + if (pos != NULL) pos[0] = '\0'; + + + RECT r = rc; + r.top += BORDER_SPACE; + r.bottom -= BORDER_SPACE; + r.left += BORDER_SPACE; + r.right -= BORDER_SPACE; + + HRGN rgn = CreateRectRgnIndirect(&r); + SelectClipRgn(hdc, rgn); + + RECT rc_tmp; + int text_height; + + if (mouse_over) + { + uFormat &= ~DT_END_ELLIPSIS; + + rc_tmp = r; + text_height = DrawText(hdc, " ...", 4, &rc_tmp, DT_CALCRECT | uFormat); + rc_tmp.top += (r.bottom - r.top - text_height) >> 1; + rc_tmp.bottom = rc_tmp.top + text_height; + + if (uFormat & DT_RTLREADING) { - email_icon.setEnabled(TRUE); - email.setEnabled(TRUE); - email_icon.setIcon(hEmailIcon); + rc_tmp.right = r.left + (rc_tmp.right - rc_tmp.left); + rc_tmp.left = r.left; - TCHAR tmp[64]; - _sntprintf(tmp, MAX_REGS(tmp), _T("%d"), proto->GetEmailCount()); - email.setText(tmp); + r.left += rc_tmp.right - rc_tmp.left; } else { - email_icon.setEnabled(FALSE); - email.setEnabled(FALSE); - email_icon.setIcon(NULL); - email.setText(_T("")); - } + rc_tmp.left = r.right - (rc_tmp.right - rc_tmp.left); + rc_tmp.right = r.right; - SkinIconField next_proto = dialog->getIconField("next_proto"); - SkinIconField prev_proto = dialog->getIconField("prev_proto"); - prev_proto.setIcon(hPrevIcon); - next_proto.setIcon(hNextIcon); + r.right -= rc_tmp.right - rc_tmp.left; + } } - SkinDialogState state = dialog->run(); - SkinImageFieldState avatar = state.getImageField("avatar"); - SkinTextFieldState nickname = state.getTextField("nickname"); - SkinTextFieldState protocol = state.getTextField("protocol"); - SkinIconFieldState status_icon = state.getIconField("status_icon"); - SkinTextFieldState status_name = state.getTextField("status_name"); - SkinTextFieldState status_msg = state.getTextField("status_msg"); - SkinIconFieldState listening_icon = state.getIconField("listening_icon"); - SkinTextFieldState listening = state.getTextField("listening"); - SkinIconFieldState email_icon = state.getIconField("email_icon"); - SkinTextFieldState email = state.getTextField("email"); - SkinIconFieldState next_proto = state.getIconField("next_proto"); - SkinIconFieldState prev_proto = state.getIconField("prev_proto"); - + if (replace_smileys) + DRAW_TEXT(hdc, tmp2, strlen(tmp2), &r, uFormat, proto->name, NULL); + else + DrawText(hdc, tmp2, strlen(tmp2), &r, uFormat); + if (mouse_over) { - data->proto.update(hwnd, &protocol); - data->proto_cycle_next.update(hwnd, &next_proto); - data->proto_cycle_prev.update(hwnd, &prev_proto); - data->avatar.update(hwnd, &avatar); - data->nick.update(hwnd, &nickname); - data->status.update(hwnd, &status_icon, &status_name); - data->away_msg.update(hwnd, &status_msg); - data->listening_to.update(hwnd, &listening_icon, &listening); - data->email.update(hwnd, &email_icon, &email); + DrawText(hdc, " ...", 4, &rc_tmp, uFormat); + } - - POINT p = {0}; - GetCursorPos(&p); - ScreenToClient(hwnd, &p); + SelectClipRgn(hdc, NULL); + DeleteObject(rgn); + + if (mouse_over) + FrameRect(hdc, &rc, (HBRUSH) GetStockObject(GRAY_BRUSH)); + + free(tmp2); +} + +void Draw(HWND hwnd, HDC hdc_orig) +{ + MyDetailsFrameData *data = (MyDetailsFrameData *)GetWindowLong(hwnd, GWL_USERDATA); + Protocol *proto = protocols->Get(data->protocol_number); - for(size_t i = 0; i < data->items.size(); ++i) - data->items[i]->setMouseOver(&p); + if (proto == NULL) + { + EraseBackground(hwnd, hdc_orig); + return; } + if (data->recalc_rectangles || proto->data_changed) + CalcRectangles(hwnd); + + RECT r_full; + GetClientRect(hwnd, &r_full); + RECT r = r_full; + + HDC hdc = CreateCompatibleDC(hdc_orig); + HBITMAP hBmp = CreateBitmap32(r.right,r.bottom);//,1,GetDeviceCaps(hdc,BITSPIXEL),NULL); + SelectObject(hdc, hBmp); + + int old_bk_mode = SetBkMode(hdc, TRANSPARENT); + HFONT old_font = (HFONT) SelectObject(hdc, hFont[0]); + COLORREF old_color = GetTextColor(hdc); + SetStretchBltMode(hdc, HALFTONE); + // Erase EraseBackground(hwnd, hdc); + r.left += min(opts.borders[LEFT], r.right); + r.right = max(r.right - opts.borders[RIGHT], r.left); + r.top += min(opts.borders[TOP], r.bottom); + r.bottom = max(r.bottom - opts.borders[BOTTOM], r.top); + // Draw items UINT uFormat = DT_SINGLELINE | DT_NOPREFIX | DT_END_ELLIPSIS + | (opts.draw_text_align_right ? DT_RIGHT : DT_LEFT) | (opts.draw_text_rtl ? DT_RTLREADING : 0); // Image - if (avatar.isVisible() && proto->CanGetAvatar() && proto->GetAvatarImage() != NULL) + if (data->draw_img) { - RECT rc = avatar.getInsideRect(); + RECT rc = GetInnerRect(data->img_rect, r); HRGN rgn = CreateRectRgnIndirect(&rc); SelectClipRgn(hdc, rgn); - rc = avatar.getInsideRect(true); - - int width = Width(rc); - int height = Height(rc); + int width = data->img_rect.right - data->img_rect.left; + int height = data->img_rect.bottom - data->img_rect.top; int round_radius; if (opts.draw_avatar_round_corner) @@ -1065,19 +1304,15 @@ void Draw(HWND hwnd, HDC hdc_orig) adr.cbSize = sizeof(AVATARDRAWREQUEST); adr.hTargetDC = hdc; - adr.rcDraw = rc; + adr.rcDraw = data->img_rect; adr.dwFlags = AVDRQ_OWNPIC | AVDRQ_HIDEBORDERONTRANSPARENCY | (opts.draw_avatar_border ? AVDRQ_DRAWBORDER : 0 ) | (opts.draw_avatar_round_corner ? AVDRQ_ROUNDEDCORNER : 0 ); - - if (useLayeredMode) - adr.dwFlags |= AVDRQ_AERO; - adr.clrBorder = opts.draw_avatar_border_color; adr.radius = round_radius; adr.alpha = 255; - adr.szProto = (char *) proto->GetName(); + adr.szProto = proto->name; CallService(MS_AV_DRAWAVATAR, 0, (LPARAM) &adr); @@ -1087,151 +1322,262 @@ void Draw(HWND hwnd, HDC hdc_orig) } // Nick - if (data->nick.draw && data->nick.mouseOver && proto->CanSetNick()) - DrawMouseOver(hdc, &nickname.getRect(), "Nick"); + if (data->draw_nick) + { + RECT rc = GetInnerRect(data->nick_rect, r); + HRGN rgn = CreateRectRgnIndirect(&rc); + SelectClipRgn(hdc, rgn); - Draw(hdc, nickname, TRUE, proto->GetName()); + SelectObject(hdc, hFont[FONT_NICK]); + SetTextColor(hdc, font_colour[FONT_NICK]); + DrawTextWithRect(hdc, proto->nickname, DEFAULT_NICKNAME, rc, uFormat, + data->mouse_over_nick && proto->CanSetNick(), proto); - // Protocol - if (data->proto.draw && data->proto.mouseOver) - DrawMouseOver(hdc, &data->proto.rc, "Proto"); - - Draw(hdc, protocol); - + // Clipping rgn + SelectClipRgn(hdc, NULL); + DeleteObject(rgn); + } - // Status - if (data->status.draw && data->status.mouseOver) - DrawMouseOver(hdc, &data->status.rc, "Status"); - - Draw(hdc, status_icon); - Draw(hdc, status_name); + // Protocol cycle icon + if (data->draw_proto_cycle) + { + RECT rc = GetInnerRect(data->next_proto_rect, r); + HRGN rgn = CreateRectRgnIndirect(&rc); + SelectClipRgn(hdc, rgn); + HICON icon = LoadIconEx("MYDETAILS_NEXT_PROTOCOL"); + if (icon == NULL) + icon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_RIGHT_ARROW)); + DrawIconEx(hdc, data->next_proto_rect.left, data->next_proto_rect.top, icon, ICON_SIZE, ICON_SIZE, 0, NULL, DI_NORMAL); + ReleaseIconEx(icon); - // Away message - if (data->away_msg.draw && data->away_msg.mouseOver && proto->CanSetStatusMsg()) - DrawMouseOver(hdc, &data->away_msg.rc, "StatusMsg"); - - Draw(hdc, status_msg, TRUE, proto->GetName()); + SelectClipRgn(hdc, NULL); + DeleteObject(rgn); + rc = GetInnerRect(data->prev_proto_rect, r); + rgn = CreateRectRgnIndirect(&rc); + SelectClipRgn(hdc, rgn); - // Listening to - Draw(hdc, listening_icon); - Draw(hdc, listening); - - if (data->listening_to.draw && data->listening_to.mouseOver && protocols->CanSetListeningTo()) - DrawMouseOver(hdc, &data->listening_to.rc, "Listening"); - + icon = LoadIconEx("MYDETAILS_PREV_PROTOCOL"); + if (icon == NULL) + icon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_RIGHT_ARROW)); + DrawIconEx(hdc, data->prev_proto_rect.left, data->prev_proto_rect.top, icon, ICON_SIZE, ICON_SIZE, 0, NULL, DI_NORMAL); + ReleaseIconEx(icon); - // Unread email count - Draw(hdc, email_icon); - Draw(hdc, email); + SelectClipRgn(hdc, NULL); + DeleteObject(rgn); + } - // Protocol cycle icon - Draw(hdc, next_proto); - Draw(hdc, prev_proto); + // Protocol + if (data->draw_proto) + { + RECT rc = GetInnerRect(data->proto_rect, r); + RECT rr = rc; + rr.top += BORDER_SPACE; + rr.bottom -= BORDER_SPACE; + rr.left += BORDER_SPACE; + rr.right -= BORDER_SPACE; + HRGN rgn = CreateRectRgnIndirect(&rc); + SelectClipRgn(hdc, rgn); - SelectObject(hdc, old_font); - SetTextColor(hdc, old_color); - SetBkMode(hdc, old_bk_mode); + SelectObject(hdc, hFont[FONT_PROTO]); + SetTextColor(hdc, font_colour[FONT_PROTO]); - if (!useLayeredMode) - { - BitBlt(hdc_orig, r_full.left, r_full.top, r_full.right - r_full.left, - r_full.bottom - r_full.top, hdc, r_full.left, r_full.top, SRCCOPY); - DeleteDC(hdc); - DeleteObject(hBmp); + DrawText(hdc, proto->description, strlen(proto->description), &rr, uFormat); + + // Clipping rgn + SelectClipRgn(hdc, NULL); + DeleteObject(rgn); + + if (data->mouse_over_proto) + FrameRect(hdc, &rc, (HBRUSH) GetStockObject(GRAY_BRUSH)); } - if (freeStatusIcon) - DestroyIcon(hStatusIcon); - IcoLib_ReleaseIcon(hListeningIcon); - IcoLib_ReleaseIcon(hEmailIcon); - IcoLib_ReleaseIcon(hPrevIcon); - IcoLib_ReleaseIcon(hNextIcon); + // Status + if (data->draw_status) + { + RECT rtmp = GetInnerRect(data->status_rect, r); + RECT rr = rtmp; + rr.top += BORDER_SPACE; + rr.bottom -= BORDER_SPACE; + rr.left += BORDER_SPACE; + rr.right -= BORDER_SPACE; + + RECT rc = GetInnerRect(data->status_icon_rect, rr); + HRGN rgn = CreateRectRgnIndirect(&rc); + SelectClipRgn(hdc, rgn); - if (opts.resize_frame && ServiceExists(MS_CLIST_FRAMES_SETFRAMEOPTIONS) && frame_id != -1) + HICON status_icon; + if (proto->custom_status != 0 && ProtoServiceExists(proto->name, PS_ICQ_GETCUSTOMSTATUSICON)) + { + status_icon = (HICON) CallProtoService(proto->name, PS_ICQ_GETCUSTOMSTATUSICON, proto->custom_status, 0); + } + else + { + status_icon = LoadSkinnedProtoIcon(proto->name, proto->status); + } + if (status_icon != NULL) + { + DrawIconEx(hdc, data->status_icon_rect.left, data->status_icon_rect.top, status_icon, + ICON_SIZE, ICON_SIZE, 0, NULL, DI_NORMAL); + DeleteObject(status_icon); + } + + SelectClipRgn(hdc, NULL); + DeleteObject(rgn); + + rc = GetInnerRect(data->status_text_rect, rr); + rgn = CreateRectRgnIndirect(&rc); + SelectClipRgn(hdc, rgn); + + SelectObject(hdc, hFont[FONT_STATUS]); + SetTextColor(hdc, font_colour[FONT_STATUS]); + + DrawText(hdc, proto->status_name, strlen(proto->status_name), &rc, uFormat); + + SelectClipRgn(hdc, NULL); + DeleteObject(rgn); + + if (data->mouse_over_status) + FrameRect(hdc, &rtmp, (HBRUSH) GetStockObject(GRAY_BRUSH)); + } + + // Away message + if (data->draw_away_msg) { - RECT rf; - GetClientRect(hwnd, &rf); + RECT rc = GetInnerRect(data->away_msg_rect, r); + HRGN rgn = CreateRectRgnIndirect(&rc); + SelectClipRgn(hdc, rgn); + + SelectObject(hdc, hFont[FONT_AWAY_MSG]); + SetTextColor(hdc, font_colour[FONT_AWAY_MSG]); - int currentSize = Height(r_full); + DrawTextWithRect(hdc, proto->status_message, DEFAULT_STATUS_MESSAGE, rc, uFormat, + data->mouse_over_away_msg && proto->CanSetStatusMsg(), proto); + + // Clipping rgn + SelectClipRgn(hdc, NULL); + DeleteObject(rgn); + } - int expectedSize = 0; - for(size_t i = 0; i < data->items.size(); ++i) + // Listening to + if (data->draw_listening_to) + { + if (data->listening_to_icon_rect.left == 0 && data->listening_to_icon_rect.right == 0) { - SimpleItem *item = data->items[i]; - if (!item->draw) - continue; + RECT rc = GetInnerRect(data->listening_to_rect, r); + HRGN rgn = CreateRectRgnIndirect(&rc); + SelectClipRgn(hdc, rgn); - expectedSize = max(expectedSize, item->rc.bottom); - } - expectedSize += state.getBorders().bottom; + SelectObject(hdc, hFont[FONT_LISTENING_TO]); + SetTextColor(hdc, font_colour[FONT_LISTENING_TO]); + + DrawTextWithRect(hdc, proto->listening_to, DEFAULT_LISTENING_TO, rc, uFormat, + data->mouse_over_listening_to && protocols->CanSetListeningTo(), proto); - if (expectedSize != currentSize) + // Clipping rgn + SelectClipRgn(hdc, NULL); + DeleteObject(rgn); + } + else { - if (FrameIsFloating()) - { - HWND parent = GetParent(hwnd); + RECT rtmp = GetInnerRect(data->listening_to_rect, r); + RECT rr = rtmp; + rr.top += BORDER_SPACE; + rr.bottom -= BORDER_SPACE; + rr.left += BORDER_SPACE; + rr.right -= BORDER_SPACE; + + RECT rc = GetInnerRect(data->listening_to_icon_rect, rr); + HRGN rgn = CreateRectRgnIndirect(&rc); + SelectClipRgn(hdc, rgn); + + HICON icon = LoadIconEx("LISTENING_TO_ICON"); + if (icon == NULL) + icon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_LISTENINGTO)); + DrawIconEx(hdc, data->listening_to_icon_rect.left, data->listening_to_icon_rect.top, icon, ICON_SIZE, ICON_SIZE, 0, NULL, DI_NORMAL); + ReleaseIconEx(icon); + + SelectClipRgn(hdc, NULL); + DeleteObject(rgn); - if (parent != NULL) - { - RECT rp_client, rp_window, r_window; - GetClientRect(parent, &rp_client); - GetWindowRect(parent, &rp_window); - GetWindowRect(hwnd, &r_window); - int diff = (rp_window.bottom - rp_window.top) - (rp_client.bottom - rp_client.top); - if(ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) - diff += (r_window.top - rp_window.top); + rc = GetInnerRect(data->listening_to_text_rect, rr); + rgn = CreateRectRgnIndirect(&rc); + SelectClipRgn(hdc, rgn); - SetWindowPos(parent, 0, 0, 0, rp_window.right - rp_window.left, expectedSize + diff, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); - } - } - else if (IsWindowVisible(hwnd) && ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) - { - int flags = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, frame_id), 0); - if(flags & F_VISIBLE) - { - CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_HEIGHT, frame_id), (LPARAM) expectedSize); - CallService(MS_CLIST_FRAMES_UPDATEFRAME, (WPARAM)frame_id, (LPARAM)(FU_TBREDRAW | FU_FMREDRAW | FU_FMPOS)); - } - } + SelectObject(hdc, hFont[FONT_LISTENING_TO]); + SetTextColor(hdc, font_colour[FONT_LISTENING_TO]); + + DrawText(hdc, proto->listening_to, strlen(proto->listening_to), &rc, uFormat); + + SelectClipRgn(hdc, NULL); + DeleteObject(rgn); + + if (data->mouse_over_listening_to && protocols->CanSetListeningTo()) + FrameRect(hdc, &rtmp, (HBRUSH) GetStockObject(GRAY_BRUSH)); } } -} -int SkinEngineDrawCallback(HWND hWnd, HDC hDC, RECT * rcPaint, HRGN rgn, DWORD dFlags, void * CallBackData) -{ - Draw(hWnd, hDC); - return 0; + SelectObject(hdc, old_font); + SetTextColor(hdc, old_color); + SetBkMode(hdc, old_bk_mode); + + BitBlt(hdc_orig, r_full.left, r_full.top, r_full.right - r_full.left, + r_full.bottom - r_full.top, hdc, r_full.left, r_full.top, SRCCOPY); + DeleteDC(hdc); + DeleteObject(hBmp); } -bool InsideRect(const POINT &p, const RECT &r) +bool InsideRect(POINT *p, RECT *r) { - return p.x >= r.left && p.x < r.right && p.y >= r.top && p.y < r.bottom; + return p->x >= r->left && p->x < r->right && p->y >= r->top && p->y < r->bottom; } -int ShowPopupMenu(HWND hwnd, HMENU submenu, SimpleItem &item) +void MakeHover(HWND hwnd, bool draw, bool *hover, POINT *p, RECT *r) { - POINT p; - if (item.alignRight) - p.x = item.rc.right; - else - p.x = item.rc.left; - p.y = item.rc.bottom+1; - ClientToScreen(hwnd, &p); - - return TrackPopupMenu(submenu, TPM_TOPALIGN|TPM_RIGHTBUTTON|TPM_RETURNCMD - | (item.alignRight ? TPM_RIGHTALIGN : TPM_LEFTALIGN), p.x, p.y, 0, hwnd, NULL); -} + if (draw && p != NULL && r != NULL && InsideRect(p, r)) + { + if (!*hover) + { + *hover = true; + + InvalidateRect(hwnd, NULL, FALSE); + + TRACKMOUSEEVENT tme; + tme.cbSize = sizeof(TRACKMOUSEEVENT); + tme.dwFlags = TME_LEAVE; + tme.hwndTrack = hwnd; + tme.dwHoverTime = HOVER_DEFAULT; + TrackMouseEvent(&tme); + } + } + else + { + if (*hover) + { + *hover = false; + InvalidateRect(hwnd, NULL, FALSE); + } + } +} void ShowGlobalStatusMenu(HWND hwnd, MyDetailsFrameData *data, Protocol *proto, POINT &p) { HMENU submenu = (HMENU) CallService(MS_CLIST_MENUGETSTATUS,0,0); - int ret = ShowPopupMenu(hwnd, submenu, data->status); + if (opts.draw_text_align_right) + p.x = data->status_rect.right; + else + p.x = data->status_rect.left; + p.y = data->status_rect.bottom+1; + ClientToScreen(hwnd, &p); + + int ret = TrackPopupMenu(submenu, TPM_TOPALIGN|TPM_RIGHTBUTTON|TPM_RETURNCMD + | (opts.draw_text_align_right ? TPM_RIGHTALIGN : TPM_LEFTALIGN), p.x, p.y, 0, hwnd, NULL); + if(ret) CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(ret),MPCF_MAINMENU),(LPARAM)NULL); } @@ -1268,7 +1614,7 @@ void ShowProtocolStatusMenu(HWND hwnd, MyDetailsFrameData *data, Protocol *proto mii.dwTypeData = (char *)malloc(sizeof(char) * mii.cch); GetMenuItemInfo(menu, i, TRUE, &mii); - if (strcmp(mii.dwTypeData, proto->GetDescription()) == 0) + if (strcmp(mii.dwTypeData, proto->description) == 0) { submenu = GetSubMenu(menu, i); } @@ -1277,17 +1623,56 @@ void ShowProtocolStatusMenu(HWND hwnd, MyDetailsFrameData *data, Protocol *proto } } - if (submenu == NULL && GetNumProtocols() == 1) - { - submenu = menu; - } - } + if (submenu == NULL && protocols->GetSize() == 1) + { + submenu = menu; + } + } + + if (submenu != NULL) + { + /* + // Remove the first itens (protocol name and separator) + int to_remove = 0; + for(; to_remove < 5; to_remove++) + { + MENUITEMINFO mii = {0}; + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_TYPE; + GetMenuItemInfo(submenu, to_remove, TRUE, &mii); + + if (mii.fType == MFT_SEPARATOR) + break; + } + + if (to_remove < 5) + { + submenu = CopyMenu(submenu); + + for(int i = 0; i <= to_remove; i++) + RemoveMenu(submenu, i, MF_BYPOSITION); + } + */ + + if (opts.draw_text_align_right) + p.x = data->status_rect.right; + else + p.x = data->status_rect.left; + p.y = data->status_rect.bottom+1; + ClientToScreen(hwnd, &p); + + int ret = TrackPopupMenu(submenu, TPM_TOPALIGN|TPM_RIGHTBUTTON|TPM_RETURNCMD + | (opts.draw_text_align_right ? TPM_RIGHTALIGN : TPM_LEFTALIGN), p.x, p.y, 0, hwnd, NULL); - if (submenu != NULL) - { - int ret = ShowPopupMenu(hwnd, submenu, data->status); if(ret) CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(ret),MPCF_MAINMENU),(LPARAM)NULL); + + /* + if (to_remove < 5) + { + DestroyMenu(submenu); + } + */ } else { @@ -1298,7 +1683,7 @@ void ShowProtocolStatusMenu(HWND hwnd, MyDetailsFrameData *data, Protocol *proto submenu = GetSubMenu(menu, 0); CallService(MS_LANGPACK_TRANSLATEMENU,(WPARAM)submenu,0); - DWORD flags = proto->Call(PS_GETCAPS, PFLAGNUM_2); + DWORD flags = CallProtoService(proto->name, PS_GETCAPS, PFLAGNUM_2,0); for ( int i = GetMenuItemCount(submenu) -1 ; i >= 0 ; i-- ) { if (!(flags & statusModePf2List[i])) @@ -1308,11 +1693,20 @@ void ShowProtocolStatusMenu(HWND hwnd, MyDetailsFrameData *data, Protocol *proto } } - int ret = ShowPopupMenu(hwnd, submenu, data->status); + if (opts.draw_text_align_right) + p.x = data->status_rect.right; + else + p.x = data->status_rect.left; + p.y = data->status_rect.bottom+1; + ClientToScreen(hwnd, &p); + + int ret = TrackPopupMenu(submenu, TPM_TOPALIGN|TPM_RIGHTBUTTON|TPM_RETURNCMD + | (opts.draw_text_align_right ? TPM_RIGHTALIGN : TPM_LEFTALIGN), p.x, p.y, 0, hwnd, NULL); DestroyMenu(menu); - if(ret) + { proto->SetStatus(ret); + } } } @@ -1324,7 +1718,7 @@ void ShowListeningToMenu(HWND hwnd, MyDetailsFrameData *data, Protocol *proto, P // Add this proto to menu char tmp[128]; - mir_snprintf(tmp, sizeof(tmp), Translate("Enable Listening To for %s"), proto->GetDescription()); + mir_snprintf(tmp, sizeof(tmp), Translate("Enable Listening To for %s"), proto->description); MENUITEMINFO mii = {0}; mii.cbSize = sizeof(mii); @@ -1354,15 +1748,22 @@ void ShowListeningToMenu(HWND hwnd, MyDetailsFrameData *data, Protocol *proto, P SetMenuItemInfo(submenu, ID_LISTENINGTOPOPUP_SENDLISTENINGTO, FALSE, &mii); - int ret = ShowPopupMenu(hwnd, submenu, data->listening_to); - + if (opts.draw_text_align_right) + p.x = data->listening_to_rect.right; + else + p.x = data->listening_to_rect.left; + p.y = data->listening_to_rect.bottom+1; + ClientToScreen(hwnd, &p); + + int ret = TrackPopupMenu(submenu, TPM_TOPALIGN|TPM_RIGHTBUTTON|TPM_RETURNCMD + | (opts.draw_text_align_right ? TPM_RIGHTALIGN : TPM_LEFTALIGN), p.x, p.y, 0, hwnd, NULL); DestroyMenu(menu); switch(ret) { case 1: { - CallService(MS_LISTENINGTO_ENABLE, (LPARAM) proto->GetName(), !proto->ListeningToEnabled()); + CallService(MS_LISTENINGTO_ENABLE, (LPARAM) proto->name, !proto->ListeningToEnabled()); break; } case ID_LISTENINGTOPOPUP_SENDLISTENINGTO: @@ -1382,51 +1783,58 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar case WM_CREATE: { MyDetailsFrameData *data = new MyDetailsFrameData(); + ZeroMemory(data, sizeof(MyDetailsFrameData)); SetWindowLong(hwnd, GWL_USERDATA, (LONG) data); - SetCurrentProtocol(DBGetContactSettingWord(NULL, "MyDetails", "ProtocolNumber", 0)); + data->recalc_rectangles = true; + data->get_status_messages = false; + data->showing_menu = false; + + data->protocol_number = DBGetContactSettingWord(NULL,"MyDetails","ProtocolNumber",0); + if (data->protocol_number >= protocols->GetSize()) + { + data->protocol_number = 0; + } SetCycleTime(hwnd); - SetStatusMessageRefreshTime(hwnd); + TRACKMOUSEEVENT tme; + tme.cbSize = sizeof(TRACKMOUSEEVENT); + tme.dwFlags = TME_HOVER | TME_LEAVE; + tme.hwndTrack = hwnd; + tme.dwHoverTime = HOVER_DEFAULT; + TrackMouseEvent(&tme); + return TRUE; } - + /* case WM_ERASEBKGND: { //EraseBackground(hwnd, (HDC)wParam); - //Draw(hwnd, (HDC)wParam); + Draw(hwnd, (HDC)wParam); return TRUE; } + */ - /* case WM_PRINTCLIENT: { Draw(hwnd, (HDC)wParam); return TRUE; } - */ case WM_PAINT: { - if (UseLayeredMode()) - { - CallService(MS_SKINENG_INVALIDATEFRAMEIMAGE, (WPARAM) hwnd, 0); - ValidateRect(hwnd, NULL); - } - else + RECT r; + + if(GetUpdateRect(hwnd, &r, FALSE)) { - RECT r; - if(GetUpdateRect(hwnd, &r, FALSE)) - { - PAINTSTRUCT ps; - - HDC hdc = BeginPaint(hwnd, &ps); - Draw(hwnd, hdc); - EndPaint(hwnd, &ps); - } + PAINTSTRUCT ps; + + HDC hdc = BeginPaint(hwnd, &ps); + Draw(hwnd, hdc); + EndPaint(hwnd, &ps); } return TRUE; @@ -1436,6 +1844,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar { //InvalidateRect(hwnd, NULL, FALSE); MyDetailsFrameData *data = (MyDetailsFrameData *)GetWindowLong(hwnd, GWL_USERDATA); + data->recalc_rectangles = true; RedrawFrame(); break; } @@ -1453,13 +1862,24 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar { KillTimer(hwnd, ID_RECALC_TIMER); - PostMessage(hwnd, MWM_REFRESH_DATA, 0, 0); + if (data->get_status_messages) + { + SetStatusMessageRefreshTime(hwnd); + data->get_status_messages = false; + + protocols->GetStatuses(); + protocols->GetStatusMsgs(); + + data->recalc_rectangles = true; + } + + RedrawFrame(); } else if (wParam == ID_STATUSMESSAGE_TIMER) { SetStatusMessageRefreshTime(hwnd); - PostMessage(hwnd, MWM_REFRESH_DATA, 0, 0); + PostMessage(hwnd, MWM_STATUS_MSG_CHANGED, 0, 0); } return TRUE; @@ -1468,7 +1888,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar case WM_LBUTTONUP: { MyDetailsFrameData *data = (MyDetailsFrameData *)GetWindowLong(hwnd, GWL_USERDATA); - Protocol *proto = GetCurrentProtocol(); + Protocol *proto = protocols->Get(data->protocol_number); if (proto == NULL) break; @@ -1476,41 +1896,41 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar p.x = LOWORD(lParam); p.y = HIWORD(lParam); - // In proto cycle button? - if (data->proto_cycle_next.hitTest(p)) - { - CallService(MS_MYDETAILS_SHOWNEXTPROTOCOL, 0, 0); - } - else if (data->proto_cycle_prev.hitTest(p)) - { - CallService(MS_MYDETAILS_SHOWPREVIOUSPROTOCOL, 0, 0); - } // In image? - else if (data->avatar.hitTest(p) && proto->CanSetAvatar()) + if (data->draw_img && InsideRect(&p, &data->img_rect) && proto->CanSetAvatar()) { if (opts.global_on_avatar) CallService(MS_MYDETAILS_SETMYAVATARUI, 0, 0); else - CallService(MS_MYDETAILS_SETMYAVATARUI, 0, (LPARAM) proto->GetName()); + CallService(MS_MYDETAILS_SETMYAVATARUI, 0, (LPARAM) proto->name); } // In nick? - else if (data->nick.hitTest(p) && proto->CanSetNick()) + else if (data->draw_nick && InsideRect(&p, &data->nick_rect) && proto->CanSetNick()) { if (opts.global_on_nickname) CallService(MS_MYDETAILS_SETMYNICKNAMEUI, 0, 0); else - CallService(MS_MYDETAILS_SETMYNICKNAMEUI, 0, (LPARAM) proto->GetName()); + CallService(MS_MYDETAILS_SETMYNICKNAMEUI, 0, (LPARAM) proto->name); + } + // In proto cycle button? + else if (data->draw_proto_cycle && InsideRect(&p, &data->next_proto_rect)) + { + CallService(MS_MYDETAILS_SHOWNEXTPROTOCOL, 0, 0); + } + else if (data->draw_proto_cycle && InsideRect(&p, &data->prev_proto_rect)) + { + CallService(MS_MYDETAILS_SHOWPREVIOUSPROTOCOL, 0, 0); } // In status message? - else if (data->away_msg.hitTest(p) && proto->CanSetStatusMsg()) + else if (data->draw_away_msg && InsideRect(&p, &data->away_msg_rect) && proto->CanSetStatusMsg()) { if (opts.global_on_status_message) CallService(MS_MYDETAILS_SETMYSTATUSMESSAGEUI, 0, 0); else - CallService(MS_MYDETAILS_SETMYSTATUSMESSAGEUI, 0, (LPARAM) proto->GetName()); + CallService(MS_MYDETAILS_SETMYSTATUSMESSAGEUI, 0, (LPARAM) proto->name); } // In status? - else if (data->status.hitTest(p)) + else if (data->draw_status && InsideRect(&p, &data->status_rect)) { data->showing_menu = true; @@ -1522,36 +1942,28 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar data->showing_menu = false; } // In listening to? - else if (data->listening_to.hitTest(p) && protocols->CanSetListeningTo()) + else if (data->draw_listening_to && InsideRect(&p, &data->listening_to_rect) && protocols->CanSetListeningTo()) { ShowListeningToMenu(hwnd, data, proto, p); } // In protocol? - else if (data->proto.hitTest(p)) + else if (data->draw_proto && InsideRect(&p, &data->proto_rect)) { data->showing_menu = true; HMENU menu = CreatePopupMenu(); - std::vector protos; - GetProtocols(&protos); - - int current = GetCurrentProtocolIndex(); - - int protosSize = (int) protos.size(); - for (int i = protosSize - 1 ; i >= 0 ; i--) + for (int i = protocols->GetSize() - 1 ; i >= 0 ; i--) { - Protocol &proto = protos[i]; - MENUITEMINFO mii = {0}; mii.cbSize = sizeof(mii); mii.fMask = MIIM_ID | MIIM_TYPE; mii.fType = MFT_STRING; - mii.dwTypeData = (char *) proto.GetDescription(); - mii.cch = strlen(mii.dwTypeData); + mii.dwTypeData = protocols->Get(i)->description; + mii.cch = strlen(protocols->Get(i)->description); mii.wID = i + 1; - if (i == current) + if (i == data->protocol_number) { mii.fMask |= MIIM_STATE; mii.fState = MFS_DISABLED; @@ -1560,12 +1972,20 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar InsertMenuItem(menu, 0, TRUE, &mii); } - int ret = ShowPopupMenu(hwnd, menu, data->proto); - + if (opts.draw_text_align_right) + p.x = data->proto_rect.right; + else + p.x = data->proto_rect.left; + p.y = data->proto_rect.bottom+1; + ClientToScreen(hwnd, &p); + + int ret = TrackPopupMenu(menu, TPM_TOPALIGN|TPM_LEFTALIGN|TPM_RIGHTBUTTON|TPM_RETURNCMD, p.x, p.y, 0, hwnd, NULL); DestroyMenu(menu); if (ret != 0) - PluginCommand_ShowProtocol(NULL, (WPARAM) GetProtocolByIndex(ret - 1).GetName()); + { + PluginCommand_ShowProtocol(NULL, (WPARAM) protocols->Get(ret-1)->name); + } data->showing_menu = false; } @@ -1585,7 +2005,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar case WM_CONTEXTMENU: { MyDetailsFrameData *data = (MyDetailsFrameData *)GetWindowLong(hwnd, GWL_USERDATA); - Protocol *proto = GetCurrentProtocol(); + Protocol *proto = protocols->Get(data->protocol_number); if (proto == NULL) break; @@ -1597,17 +2017,8 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar data->showing_menu = true; - // In proto cycle button? - if (data->proto_cycle_next.hitTest(p)) - { - CallService(MS_MYDETAILS_SHOWPREVIOUSPROTOCOL, 0, 0); - } - else if (data->proto_cycle_prev.hitTest(p)) - { - CallService(MS_MYDETAILS_SHOWNEXTPROTOCOL, 0, 0); - } // In image? - else if (data->avatar.hitTest(p)) + if (data->draw_img && InsideRect(&p, &data->img_rect)) { HMENU menu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU1)); HMENU submenu = GetSubMenu(menu, 4); @@ -1615,7 +2026,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar // Add this proto to menu char tmp[128]; - mir_snprintf(tmp, sizeof(tmp), Translate("Set My Avatar for %s..."), proto->GetDescription()); + mir_snprintf(tmp, sizeof(tmp), Translate("Set My Avatar for %s..."), proto->description); MENUITEMINFO mii = {0}; mii.cbSize = sizeof(mii); @@ -1642,7 +2053,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar { case 1: { - CallService(MS_MYDETAILS_SETMYAVATARUI, 0, (LPARAM) proto->GetName()); + CallService(MS_MYDETAILS_SETMYAVATARUI, 0, (LPARAM) proto->name); break; } case ID_AVATARPOPUP_SETMYAVATAR: @@ -1653,7 +2064,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar } } // In nick? - else if (data->nick.hitTest(p)) + else if (data->draw_nick && InsideRect(&p, &data->nick_rect)) { HMENU menu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU1)); HMENU submenu = GetSubMenu(menu, 2); @@ -1661,7 +2072,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar // Add this proto to menu char tmp[128]; - mir_snprintf(tmp, sizeof(tmp), Translate("Set My Nickname for %s..."), proto->GetDescription()); + mir_snprintf(tmp, sizeof(tmp), Translate("Set My Nickname for %s..."), proto->description); MENUITEMINFO mii = {0}; mii.cbSize = sizeof(mii); @@ -1688,7 +2099,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar { case 1: { - CallService(MS_MYDETAILS_SETMYNICKNAMEUI, 0, (LPARAM) proto->GetName()); + CallService(MS_MYDETAILS_SETMYNICKNAMEUI, 0, (LPARAM) proto->name); break; } case ID_NICKPOPUP_SETMYNICKNAME: @@ -1698,8 +2109,17 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar } } } + // In proto cycle button? + else if (data->draw_proto_cycle && InsideRect(&p, &data->next_proto_rect)) + { + CallService(MS_MYDETAILS_SHOWPREVIOUSPROTOCOL, 0, 0); + } + else if (data->draw_proto_cycle && InsideRect(&p, &data->prev_proto_rect)) + { + CallService(MS_MYDETAILS_SHOWNEXTPROTOCOL, 0, 0); + } // In status message? - else if (data->away_msg.hitTest(p)) + else if (data->draw_away_msg && InsideRect(&p, &data->away_msg_rect)) { char tmp[128]; @@ -1707,30 +2127,33 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar HMENU submenu = GetSubMenu(menu, 3); CallService(MS_LANGPACK_TRANSLATEMENU,(WPARAM)submenu,0); - // Add this proto to menu - mir_snprintf(tmp, sizeof(tmp), Translate("Set My Status Message for %s..."), - proto->GetDescription()); + if (protocols->CanSetStatusMsgPerProtocol()) + { + // Add this proto to menu + mir_snprintf(tmp, sizeof(tmp), Translate("Set My Status Message for %s..."), + proto->description); - MENUITEMINFO mii = {0}; - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_ID | MIIM_TYPE; - mii.fType = MFT_STRING; - mii.dwTypeData = tmp; - mii.cch = strlen(tmp); - mii.wID = 1; + MENUITEMINFO mii = {0}; + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_ID | MIIM_TYPE; + mii.fType = MFT_STRING; + mii.dwTypeData = tmp; + mii.cch = strlen(tmp); + mii.wID = 1; - if (!proto->CanSetStatusMsg()) - { - mii.fMask |= MIIM_STATE; - mii.fState = MFS_DISABLED; - } + if (!proto->CanSetStatusMsg()) + { + mii.fMask |= MIIM_STATE; + mii.fState = MFS_DISABLED; + } - InsertMenuItem(submenu, 0, TRUE, &mii); + InsertMenuItem(submenu, 0, TRUE, &mii); + } { // Add this to menu mir_snprintf(tmp, sizeof(tmp), Translate("Set My Status Message for %s..."), - CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, proto->GetStatus(), 0)); + CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, proto->status, 0)); MENUITEMINFO mii = {0}; mii.cbSize = sizeof(mii); @@ -1740,7 +2163,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar mii.cch = strlen(tmp); mii.wID = 2; - if (proto->GetStatus() == ID_STATUS_OFFLINE) + if (proto->status == ID_STATUS_OFFLINE) { mii.fMask |= MIIM_STATE; mii.fState = MFS_DISABLED; @@ -1758,12 +2181,12 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar { case 1: { - CallService(MS_MYDETAILS_SETMYSTATUSMESSAGEUI, 0, (LPARAM) proto->GetName()); + CallService(MS_MYDETAILS_SETMYSTATUSMESSAGEUI, 0, (LPARAM) proto->name); break; } case 2: { - CallService(MS_MYDETAILS_SETMYSTATUSMESSAGEUI, (WPARAM) proto->GetStatus(), 0); + CallService(MS_MYDETAILS_SETMYSTATUSMESSAGEUI, (WPARAM) proto->status, 0); break; } case ID_STATUSMESSAGEPOPUP_SETMYSTATUSMESSAGE: @@ -1774,7 +2197,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar } } // In status? - else if (data->status.hitTest(p)) + else if (data->draw_status && InsideRect(&p, &data->status_rect)) { if (opts.global_on_status) ShowProtocolStatusMenu(hwnd, data, proto, p); @@ -1782,12 +2205,12 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar ShowGlobalStatusMenu(hwnd, data, proto, p); } // In listening to? - else if (data->listening_to.hitTest(p) && protocols->CanSetListeningTo()) + else if (data->draw_listening_to && InsideRect(&p, &data->listening_to_rect) && protocols->CanSetListeningTo()) { ShowListeningToMenu(hwnd, data, proto, p); } // In protocol? - else if (data->proto.hitTest(p)) + else if (data->draw_proto && InsideRect(&p, &data->proto_rect)) { } // Default context menu @@ -1806,7 +2229,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar char tmp[128]; MENUITEMINFO mii = {0}; - mir_snprintf(tmp, sizeof(tmp), Translate("Enable Listening To for %s"), proto->GetDescription()); + mir_snprintf(tmp, sizeof(tmp), Translate("Enable Listening To for %s"), proto->description); ZeroMemory(&mii, sizeof(mii)); mii.cbSize = sizeof(mii); @@ -1826,7 +2249,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar // Add this to menu mir_snprintf(tmp, sizeof(tmp), Translate("Set My Status Message for %s..."), - CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, proto->GetStatus(), 0)); + CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, proto->status, 0)); ZeroMemory(&mii, sizeof(mii)); mii.cbSize = sizeof(mii); @@ -1836,7 +2259,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar mii.cch = strlen(tmp); mii.wID = 4; - if (proto->GetStatus() == ID_STATUS_OFFLINE) + if (proto->status == ID_STATUS_OFFLINE) { mii.fMask |= MIIM_STATE; mii.fState = MFS_DISABLED; @@ -1844,26 +2267,29 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar InsertMenuItem(submenu, 0, TRUE, &mii); - // Add this proto to menu - mir_snprintf(tmp, sizeof(tmp), Translate("Set My Status Message for %s..."), proto->GetDescription()); + if (protocols->CanSetStatusMsgPerProtocol()) + { + // Add this proto to menu + mir_snprintf(tmp, sizeof(tmp), Translate("Set My Status Message for %s..."), proto->description); - ZeroMemory(&mii, sizeof(mii)); - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_ID | MIIM_TYPE; - mii.fType = MFT_STRING; - mii.dwTypeData = tmp; - mii.cch = strlen(tmp); - mii.wID = 3; + ZeroMemory(&mii, sizeof(mii)); + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_ID | MIIM_TYPE; + mii.fType = MFT_STRING; + mii.dwTypeData = tmp; + mii.cch = strlen(tmp); + mii.wID = 3; - if (!proto->CanSetStatusMsg()) - { - mii.fMask |= MIIM_STATE; - mii.fState = MFS_DISABLED; - } + if (!proto->CanSetStatusMsg()) + { + mii.fMask |= MIIM_STATE; + mii.fState = MFS_DISABLED; + } - InsertMenuItem(submenu, 0, TRUE, &mii); + InsertMenuItem(submenu, 0, TRUE, &mii); + } - mir_snprintf(tmp, sizeof(tmp), Translate("Set My Nickname for %s..."), proto->GetDescription()); + mir_snprintf(tmp, sizeof(tmp), Translate("Set My Nickname for %s..."), proto->description); ZeroMemory(&mii, sizeof(mii)); mii.cbSize = sizeof(mii); @@ -1881,7 +2307,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar InsertMenuItem(submenu, 0, TRUE, &mii); - mir_snprintf(tmp, sizeof(tmp), Translate("Set My Avatar for %s..."), proto->GetDescription()); + mir_snprintf(tmp, sizeof(tmp), Translate("Set My Avatar for %s..."), proto->description); ZeroMemory(&mii, sizeof(mii)); mii.cbSize = sizeof(mii); @@ -1920,7 +2346,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar { case 1: { - CallService(MS_MYDETAILS_SETMYAVATARUI, 0, (LPARAM) proto->GetName()); + CallService(MS_MYDETAILS_SETMYAVATARUI, 0, (LPARAM) proto->name); break; } case ID_AVATARPOPUP_SETMYAVATAR: @@ -1930,7 +2356,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar } case 2: { - CallService(MS_MYDETAILS_SETMYNICKNAMEUI, 0, (LPARAM) proto->GetName()); + CallService(MS_MYDETAILS_SETMYNICKNAMEUI, 0, (LPARAM) proto->name); break; } case ID_NICKPOPUP_SETMYNICKNAME: @@ -1940,12 +2366,12 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar } case 3: { - CallService(MS_MYDETAILS_SETMYSTATUSMESSAGEUI, 0, (LPARAM) proto->GetName()); + CallService(MS_MYDETAILS_SETMYSTATUSMESSAGEUI, 0, (LPARAM) proto->name); break; } case 4: { - CallService(MS_MYDETAILS_SETMYSTATUSMESSAGEUI, (WPARAM) proto->GetStatus(), 0); + CallService(MS_MYDETAILS_SETMYSTATUSMESSAGEUI, (WPARAM) proto->status, 0); break; } case ID_STATUSMESSAGEPOPUP_SETMYSTATUSMESSAGE: @@ -1955,7 +2381,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar } case 5: { - CallService(MS_LISTENINGTO_ENABLE, (LPARAM) proto->GetName(), !proto->ListeningToEnabled()); + CallService(MS_LISTENINGTO_ENABLE, (LPARAM) proto->name, !proto->ListeningToEnabled()); break; } case ID_CONTEXTPOPUP_ENABLELISTENINGTO: @@ -1992,55 +2418,55 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar break; } - case WM_NCMOUSELEAVE: case WM_MOUSELEAVE: { - MyDetailsFrameData *data = (MyDetailsFrameData *)GetWindowLong(hwnd, GWL_USERDATA); - data->tracking_exit = false; + TRACKMOUSEEVENT tme; + tme.cbSize = sizeof(TRACKMOUSEEVENT); + tme.dwFlags = TME_HOVER; + tme.hwndTrack = hwnd; + tme.dwHoverTime = HOVER_DEFAULT; + TrackMouseEvent(&tme); } case WM_NCMOUSEMOVE: { MyDetailsFrameData *data = (MyDetailsFrameData *)GetWindowLong(hwnd, GWL_USERDATA); - bool changed = false; - for(size_t i = 0; i < data->items.size(); ++i) - changed = changed || data->items[i]->setMouseOver(NULL); - - if (changed) - InvalidateRect(hwnd, NULL, FALSE); + MakeHover(hwnd, data->draw_img, &data->mouse_over_img, NULL, NULL); + MakeHover(hwnd, data->draw_nick, &data->mouse_over_nick, NULL, NULL); + MakeHover(hwnd, data->draw_proto, &data->mouse_over_proto, NULL, NULL); + MakeHover(hwnd, data->draw_status, &data->mouse_over_status, NULL, NULL); + MakeHover(hwnd, data->draw_away_msg, &data->mouse_over_away_msg, NULL, NULL); + MakeHover(hwnd, data->draw_listening_to, &data->mouse_over_listening_to, NULL, NULL); break; } + case WM_MOUSEHOVER: + { + TRACKMOUSEEVENT tme; + tme.cbSize = sizeof(TRACKMOUSEEVENT); + tme.dwFlags = TME_LEAVE; + tme.hwndTrack = hwnd; + tme.dwHoverTime = HOVER_DEFAULT; + TrackMouseEvent(&tme); + } case WM_MOUSEMOVE: { MyDetailsFrameData *data = (MyDetailsFrameData *)GetWindowLong(hwnd, GWL_USERDATA); - Protocol *proto = GetCurrentProtocol(); + Protocol *proto = protocols->Get(data->protocol_number); if (proto == NULL) break; - if (!data->tracking_exit) - { - TRACKMOUSEEVENT tme; - tme.cbSize = sizeof(TRACKMOUSEEVENT); - tme.dwFlags = TME_LEAVE; - tme.hwndTrack = hwnd; - tme.dwHoverTime = HOVER_DEFAULT; - TrackMouseEvent(&tme); - - data->tracking_exit = true; - } - POINT p; p.x = LOWORD(lParam); p.y = HIWORD(lParam); - bool changed = false; - for(size_t i = 0; i < data->items.size(); ++i) - changed = changed || data->items[i]->setMouseOver(&p); - - if (changed) - InvalidateRect(hwnd, NULL, FALSE); + MakeHover(hwnd, data->draw_img, &data->mouse_over_img, &p, &data->img_rect); + MakeHover(hwnd, data->draw_nick, &data->mouse_over_nick, &p, &data->nick_rect); + MakeHover(hwnd, data->draw_proto, &data->mouse_over_proto, &p, &data->proto_rect); + MakeHover(hwnd, data->draw_status, &data->mouse_over_status, &p, &data->status_rect); + MakeHover(hwnd, data->draw_away_msg, &data->mouse_over_away_msg, &p, &data->away_msg_rect); + MakeHover(hwnd, data->draw_listening_to, &data->mouse_over_listening_to, &p, &data->listening_to_rect); break; } @@ -2055,16 +2481,23 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar case TTN_GETDISPINFO: { MyDetailsFrameData *data = (MyDetailsFrameData *)GetWindowLong(hwnd, GWL_USERDATA); + Protocol *proto = protocols->Get(data->protocol_number); LPNMTTDISPINFO lpttd = (LPNMTTDISPINFO) lpnmhdr; SendMessage(lpnmhdr->hwndFrom, TTM_SETMAXTIPWIDTH, 0, 300); - for(int i = 0; i < data->items.size(); i++) - { - lpttd->lpszText = (char *) data->items[i]->getToolTipFor(lpnmhdr->hwndFrom); - if (lpttd->lpszText != NULL) - break; - } + if (lpnmhdr->hwndFrom == data->nick_tt_hwnd) + lpttd->lpszText = proto->nickname; + else if (lpnmhdr->hwndFrom == data->status_tt_hwnd) + lpttd->lpszText = proto->status_name; + else if (lpnmhdr->hwndFrom == data->away_msg_tt_hwnd) + lpttd->lpszText = proto->status_message; + else if (lpnmhdr->hwndFrom == data->listening_to_tt_hwnd) + lpttd->lpszText = proto->listening_to; + else if (lpnmhdr->hwndFrom == data->next_proto_tt_hwnd) + lpttd->lpszText = _T("Show next protocol"); + else if (lpnmhdr->hwndFrom == data->prev_proto_tt_hwnd) + lpttd->lpszText = _T("Show previous protocol"); return 0; } @@ -2078,6 +2511,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar KillTimer(hwnd, ID_FRAME_TIMER); MyDetailsFrameData *tmp = (MyDetailsFrameData *)GetWindowLong(hwnd, GWL_USERDATA); + DeleteTooltipWindows(tmp); if (tmp != NULL) delete tmp; break; @@ -2087,19 +2521,75 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar case MWM_REFRESH: { + MyDetailsFrameData *data = (MyDetailsFrameData *)GetWindowLong(hwnd, GWL_USERDATA); +// data->recalc_rectangles = true; + KillTimer(hwnd, ID_RECALC_TIMER); SetTimer(hwnd, ID_RECALC_TIMER, RECALC_TIME, NULL); break; } - case MWM_REFRESH_DATA: + case MWM_AVATAR_CHANGED: { - Protocol *proto = GetCurrentProtocol(false); - if (proto) + Protocol *proto = protocols->Get((const char *) wParam); + + if (proto != NULL) { - proto->UpdateAll(); - RedrawFrame(); + proto->GetAvatar(); + RefreshFrame(); + } + + break; + } + + case MWM_NICK_CHANGED: + { + Protocol *proto = protocols->Get((const char *) wParam); + + if (proto != NULL) + { + proto->GetNick(); + RefreshFrame(); } + + break; + } + + case MWM_STATUS_CHANGED: + { + Protocol *proto = protocols->Get((const char *) wParam); + + if (proto != NULL) + { + proto->GetStatus(); + proto->GetStatusMsg(); + proto->GetNick(); + + RefreshFrame(); + } + + break; + } + + case MWM_STATUS_MSG_CHANGED: + { + MyDetailsFrameData *data = (MyDetailsFrameData *)GetWindowLong(hwnd, GWL_USERDATA); + data->get_status_messages = true; + + RefreshFrame(); + break; + } + + case MWM_LISTENINGTO_CHANGED: + { + if (wParam != NULL) + { + Protocol *proto = protocols->Get((const char *) wParam); + if (proto != NULL) + proto->GetListeningTo(); + } + + RefreshFrameAndCalcRects(); break; } } @@ -2194,29 +2684,46 @@ void FixMainMenu() void RedrawFrame() { - if (frame_id == -1) - { - InvalidateRect(hwnd_container, NULL, TRUE); - } - else +// MyDetailsFrameData *data = (MyDetailsFrameData *)GetWindowLong(hwnd_frame, GWL_USERDATA); +// if (data != NULL) +// { +// data->recalc_rectangles = true; + + if(frame_id == -1) + { + InvalidateRect(hwnd_container, NULL, TRUE); + } + else + { + CallService(MS_CLIST_FRAMES_UPDATEFRAME, (WPARAM)frame_id, (LPARAM)FU_TBREDRAW | FU_FMREDRAW); + } +// } +} + +void RefreshFrameAndCalcRects() +{ + if (hwnd_frame != NULL) { - CallService(MS_CLIST_FRAMES_UPDATEFRAME, (WPARAM)frame_id, (LPARAM)FU_TBREDRAW | FU_FMREDRAW); + MyDetailsFrameData *data = (MyDetailsFrameData *)GetWindowLong(hwnd_frame, GWL_USERDATA); + data->recalc_rectangles = true; + + PostMessage(hwnd_frame, MWM_REFRESH, 0, 0); } } -void UpdateFrameData() +void RefreshFrame() { if (hwnd_frame != NULL) PostMessage(hwnd_frame, MWM_REFRESH, 0, 0); } // only used when no multiwindow functionality is available -BOOL MyDetailsFrameVisible() +bool MyDetailsFrameVisible() { return IsWindowVisible(hwnd_container) ? true : false; } -void SetMyDetailsFrameVisible(BOOL visible) +void SetMyDetailsFrameVisible(bool visible) { if (frame_id == -1 && hwnd_container != 0) { @@ -2248,7 +2755,7 @@ void SetStatusMessageRefreshTime(HWND hwnd) { KillTimer(hwnd, ID_STATUSMESSAGE_TIMER); - opts.refresh_status_message_timer = DBGetContactSettingWord(NULL, "MyDetails", "RefreshStatusMessageTimer",5); + opts.refresh_status_message_timer = DBGetContactSettingWord(NULL,"MyDetails","RefreshStatusMessageTimer",12); if (opts.refresh_status_message_timer > 0) { SetTimer(hwnd, ID_STATUSMESSAGE_TIMER, opts.refresh_status_message_timer * 1000, NULL); @@ -2260,7 +2767,17 @@ int PluginCommand_ShowNextProtocol(WPARAM wParam,LPARAM lParam) if (hwnd_frame == NULL) return -1; - SetCurrentProtocol(GetCurrentProtocolIndex() + 1); + MyDetailsFrameData *data = (MyDetailsFrameData *)GetWindowLong(hwnd_frame, GWL_USERDATA); + + data->protocol_number ++; + if (data->protocol_number >= protocols->GetSize()) + { + data->protocol_number = 0; + } + + DBWriteContactSettingWord(NULL,"MyDetails","ProtocolNumber",data->protocol_number); + + data->recalc_rectangles = true; SetCycleTime(); @@ -2274,7 +2791,17 @@ int PluginCommand_ShowPreviousProtocol(WPARAM wParam,LPARAM lParam) if (hwnd_frame == NULL) return -1; - SetCurrentProtocol(GetCurrentProtocolIndex() - 1); + MyDetailsFrameData *data = (MyDetailsFrameData *)GetWindowLong(hwnd_frame, GWL_USERDATA); + + data->protocol_number --; + if (data->protocol_number < 0) + { + data->protocol_number = protocols->GetSize() - 1; + } + + DBWriteContactSettingWord(NULL,"MyDetails","ProtocolNumber",data->protocol_number); + + data->recalc_rectangles = true; SetCycleTime(); @@ -2286,18 +2813,32 @@ int PluginCommand_ShowPreviousProtocol(WPARAM wParam,LPARAM lParam) int PluginCommand_ShowProtocol(WPARAM wParam,LPARAM lParam) { char * proto = (char *)lParam; + int proto_num = -1; if (proto == NULL) return -1; - int proto_num = GetProtocolIndexByName(proto); + for(int i = 0 ; i < protocols->GetSize() ; i++) + { + if (stricmp(protocols->Get(i)->name, proto) == 0) + { + proto_num = i; + break; + } + } + if (proto_num == -1) return -2; if (hwnd_frame == NULL) return -3; - SetCurrentProtocol(proto_num); + MyDetailsFrameData *data = (MyDetailsFrameData *)GetWindowLong(hwnd_frame, GWL_USERDATA); + + data->protocol_number = proto_num; + DBWriteContactSettingWord(NULL,"MyDetails","ProtocolNumber",data->protocol_number); + + data->recalc_rectangles = true; SetCycleTime(); @@ -2313,49 +2854,43 @@ int SettingsChangedHook(WPARAM wParam, LPARAM lParam) DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam; - if (wParam != NULL) - return 0; - - if (strstr(cws->szModule,"Away")) - { - // Status message changed - UpdateFrameData(); - return 0; - } - - Protocol *proto = GetCurrentProtocol(false); - if (proto == NULL || strcmp(proto->GetName(), cws->szModule) != 0) - return 0; - - if (!strcmp(cws->szSetting,"Status") - || !strcmp(cws->szSetting,"StatusMood") - || !strcmp(cws->szSetting,"XStatusName") - || !strcmp(cws->szSetting,"XStatusMsg") - || !strcmp(cws->szSetting,"XStatusId") - || ( proto->GetCustomStatus() != 0 && !strcmp(cws->szSetting, proto->GetCustomStatusNameKey()) ) - || ( proto->GetCustomStatus() != 0 && !strcmp(cws->szSetting, proto->GetCustomStatusMessageKey()) )) - { - // Status changed - UpdateFrameData(); - } - else if(!strcmp(cws->szSetting,"MyHandle") - || !strcmp(cws->szSetting,"UIN") - || !strcmp(cws->szSetting,"Nick") - || !strcmp(cws->szSetting,"FirstName") - || !strcmp(cws->szSetting,"e-mail") - || !strcmp(cws->szSetting,"LastName") - || !strcmp(cws->szSetting,"JID")) - { - // Name changed - UpdateFrameData(); - } - else if (strcmp(cws->szSetting,"ListeningTo") == 0) - { - UpdateFrameData(); - } - else if (strcmp(cws->szSetting,"LockMainStatus") == 0) + if ((HANDLE)wParam == NULL) { - UpdateFrameData(); + Protocol *proto = protocols->Get((const char *) cws->szModule); + + if (!strcmp(cws->szSetting,"Status") + || ( proto != NULL && proto->custom_status != 0 + && proto->custom_status_name != NULL + && !strcmp(cws->szSetting, proto->custom_status_name) ) + || ( proto != NULL && proto->custom_status != 0 + && proto->custom_status_message != NULL + && !strcmp(cws->szSetting, proto->custom_status_message) )) + { + // Status changed + if (proto != NULL) + PostMessage(hwnd_frame, MWM_STATUS_CHANGED, (WPARAM) proto->name, 0); + } + else if(!strcmp(cws->szSetting,"MyHandle") + || !strcmp(cws->szSetting,"UIN") + || !strcmp(cws->szSetting,"Nick") + || !strcmp(cws->szSetting,"FirstName") + || !strcmp(cws->szSetting,"e-mail") + || !strcmp(cws->szSetting,"LastName") + || !strcmp(cws->szSetting,"JID")) + { + // Name changed + if (proto != NULL) + PostMessage(hwnd_frame, MWM_NICK_CHANGED, (WPARAM) proto->name, 0); + } + else if (strstr(cws->szModule,"Away")) + { + // Status message changed + PostMessage(hwnd_frame, MWM_STATUS_MSG_CHANGED, 0, 0); + } + else if (proto != NULL && strcmp(cws->szSetting,"ListeningTo") == 0) + { + PostMessage(hwnd_frame, MWM_LISTENINGTO_CHANGED, (WPARAM) proto->name, 0); + } } return 0; @@ -2366,11 +2901,10 @@ int AvatarChangedHook(WPARAM wParam, LPARAM lParam) if (hwnd_frame == NULL) return 0; - Protocol *proto = GetCurrentProtocol(false); - if (proto == NULL || strcmp(proto->GetName(), (const char *) wParam) != 0) - return 0; + Protocol *proto = protocols->Get((const char *) wParam); - UpdateFrameData(); + if (proto != NULL) + PostMessage(hwnd_frame, MWM_AVATAR_CHANGED, (WPARAM) proto->name, 0); return 0; } @@ -2380,25 +2914,21 @@ int ProtoAckHook(WPARAM wParam, LPARAM lParam) if (hwnd_frame == NULL) return 0; - ACKDATA *ack = (ACKDATA*) lParam; - if (ack->hContact != NULL) - return 0; - - Protocol *proto = GetCurrentProtocol(false); - if (proto == NULL || strcmp(proto->GetName(), ack->szModule) != 0) - return 0; + ACKDATA *ack = (ACKDATA*)lParam; if (ack->type == ACKTYPE_STATUS) { - UpdateFrameData(); + Protocol *proto = protocols->Get((const char *) ack->szModule); + + if (proto != NULL) + PostMessage(hwnd_frame, MWM_STATUS_CHANGED, (WPARAM) proto->name, 0); } else if (ack->type == ACKTYPE_AWAYMSG) { - UpdateFrameData(); - } - else if (ack->type == ACKTYPE_EMAIL) - { - UpdateFrameData(); + Protocol *proto = protocols->Get((const char *) ack->szModule); + + if (proto != NULL) + PostMessage(hwnd_frame, MWM_STATUS_MSG_CHANGED, (WPARAM) proto->name, 0); } return 0; @@ -2409,20 +2939,8 @@ int ListeningtoEnableStateChangedHook(WPARAM wParam,LPARAM lParam) if (hwnd_frame == NULL) return 0; - Protocol *proto = GetCurrentProtocol(false); - if (proto == NULL || strcmp(proto->GetName(), (const char *) wParam) != 0) - return 0; - - UpdateFrameData(); - - return 0; -} - -int AccListChanged(WPARAM wParam, LPARAM lParam) -{ - SetCurrentProtocol(0); - - RedrawFrame(); + if (wParam == NULL || protocols->Get((const char *) wParam) != NULL) + PostMessage(hwnd_frame, MWM_LISTENINGTO_CHANGED, wParam, 0); return 0; } diff --git a/plugins/MyDetails/frame.h b/plugins/MyDetails/frame.h index 58aa800090..ca314d56d0 100644 --- a/plugins/MyDetails/frame.h +++ b/plugins/MyDetails/frame.h @@ -25,8 +25,8 @@ Boston, MA 02111-1307, USA. void InitFrames(); void DeInitFrames(); -void UpdateFrameData(); -void RedrawFrame(); +void RefreshFrame(); +void RefreshFrameAndCalcRects(); void SetCycleTime(); diff --git a/plugins/MyDetails/m_simpleaway.h b/plugins/MyDetails/m_simpleaway.h new file mode 100644 index 0000000000..698a6f038d --- /dev/null +++ b/plugins/MyDetails/m_simpleaway.h @@ -0,0 +1,20 @@ +// lParam = (char *)status message +// wParam = new status, from statusmodes.h +#define MS_SA_SETSTATUSMODE "SimpleAway/SetStatusMode" +#define MS_AWAYSYS_SETSTATUSMODE MS_SA_SETSTATUSMODE //for compatibility with some plugins + +//Internal use only +#define MS_SA_TTCHANGESTATUSMSG "SimpleAway/TTChangeStatusMessage" + +//wParam=new status, from statusmodes.h +//lParam=protocol name, NULL if for all protocols (added in v0.3.1alpha) +#define MS_SA_CHANGESTATUSMSG "SimpleAway/ChangeStatusMessage" + +// wParam = 0 +// lParam = 0 +// allways returns 1 +#define MS_SA_ISSARUNNING "SimpleAway/IsSARunning" + +// wParam = 0 +// lParam = 0 +#define MS_SA_COPYAWAYMSG "SimpleAway/CopyAwayMsg" \ No newline at end of file diff --git a/plugins/MyDetails/mydetails.cpp b/plugins/MyDetails/mydetails.cpp index 9351765f6c..5790fa6d48 100644 --- a/plugins/MyDetails/mydetails.cpp +++ b/plugins/MyDetails/mydetails.cpp @@ -31,11 +31,11 @@ PLUGINLINK *pluginLink; PLUGININFOEX pluginInfo={ sizeof(PLUGININFOEX), "My Details", - PLUGIN_MAKE_VERSION(0,0,2,6), + PLUGIN_MAKE_VERSION(0,0,1,11), "Show and allows you to edit your details for all protocols.", "Ricardo Pescuma Domenecci, Drugwash", "", - "© 2005-2010 Ricardo Pescuma Domenecci, Drugwash", + "© 2005-2008 Ricardo Pescuma Domenecci, Drugwash", "http://pescuma.org/miranda/mydetails", 0, //not transient 0, //doesn't replace anything built-in @@ -43,17 +43,11 @@ PLUGININFOEX pluginInfo={ }; -struct MM_INTERFACE mmi; -struct UTF8_INTERFACE utfi; -struct SKIN_INTERFACE mski; - - HANDLE hTTB = NULL; // Hooks HANDLE hModulesLoadedHook = NULL; HANDLE hPreShutdownHook = NULL; -HANDLE hColorChangedHook = NULL; long nickname_dialog_open; HWND hwndSetNickname; @@ -61,8 +55,6 @@ HWND hwndSetNickname; long status_msg_dialog_open; HWND hwndSetStatusMsg; -SkinDialog *dialog; - // Hook called after init static int MainInit(WPARAM wparam,LPARAM lparam); @@ -118,11 +110,7 @@ int __declspec(dllexport) Load(PLUGINLINK *link) // Copy data pluginLink = link; - // CHECK_VERSION("My Details") - - mir_getMMI(&mmi); - mir_getUTFI(&utfi); - + init_mir_malloc(); init_list_interface(); // Hook event to load messages and show first one @@ -188,116 +176,10 @@ static int Menu_SetMyStatusMessageUI(WPARAM wParam,LPARAM lParam) return PluginCommand_SetMyStatusMessageUI(0, 0); } -static void SkinChanged(void *param, SKINNED_DIALOG dlg) -{ - RedrawFrame(); -} - - -static int ColorChanged(WPARAM wparam, LPARAM lparam) -{ - ColourID cid = {0}; - cid.cbSize = sizeof(ColourID); - lstrcpynA(cid.group, "My Details", sizeof(cid.group)); - lstrcpynA(cid.name, "Background", sizeof(cid.name)); - - opts.bkg_color = (COLORREF) CallService(MS_COLOUR_GET, (WPARAM) &cid, 0); - - RedrawFrame(); - - return 0; -} - // Hook called after init static int MainInit(WPARAM wparam,LPARAM lparam) -{ - if ( mir_skins_getInterface(&mski) != 0 ) - { - MessageBox(NULL, _T("MyDetails needs Skins plugin in order to work"), _T("MyDetails"), MB_OK | MB_ICONERROR); - return 0; - } - - if (CallService(MS_SKIN2_GETICON, 0, (LPARAM) "LISTENING_TO_ICON") == NULL) - { - SKINICONDESC sid = {0}; - sid.cbSize = sizeof(SKINICONDESC); - sid.ptszSection = "Contact List"; - sid.ptszDescription = "Listening to"; - sid.pszName = "LISTENING_TO_ICON"; - sid.hDefaultIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_LISTENINGTO)); - CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid); - } - - { - SKINICONDESC sid = {0}; - sid.cbSize = sizeof(SKINICONDESC); - sid.ptszSection = "My Details"; - sid.ptszDescription = "Email"; - sid.pszName = "MYDETAILS_EMAIL"; - sid.hDefaultIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_EMAIL)); - CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid); - } - - { - SKINICONDESC sid = {0}; - sid.cbSize = sizeof(SKINICONDESC); - sid.ptszSection = "My Details"; - sid.ptszDescription = "Previous protocol"; - sid.pszName = "MYDETAILS_PREV_PROTOCOL"; - sid.hDefaultIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_LEFT_ARROW)); - CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid); - } - - { - SKINICONDESC sid = {0}; - sid.cbSize = sizeof(SKINICONDESC); - sid.ptszSection = "My Details"; - sid.ptszDescription = "Next protocol"; - sid.pszName = "MYDETAILS_NEXT_PROTOCOL"; - sid.hDefaultIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_RIGHT_ARROW)); - CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid); - } - - { - ColourID cid = {0}; - cid.cbSize = sizeof(ColourID); - lstrcpynA(cid.group, "My Details", sizeof(cid.group)); - lstrcpynA(cid.name, "Background", sizeof(cid.name)); - lstrcpynA(cid.dbSettingsGroup, MODULE_NAME, sizeof(cid.dbSettingsGroup)); - lstrcpynA(cid.setting, "BackgroundColor", sizeof(cid.setting)); - cid.defcolour = GetSysColor(COLOR_BTNFACE); - - CallService(MS_COLOUR_REGISTER, (WPARAM) &cid, 0); - - ColorChanged(0,0); - - hColorChangedHook = HookEvent(ME_COLOUR_RELOAD, ColorChanged); - } - - dialog = new SkinDialog("MyDetails", "My Details", MODULE_NAME); - if (!dialog->isValid()) - { - MessageBox(NULL, _T("MyDetails could not create dialog. Check if default skin is installed"), _T("MyDetails"), MB_OK | MB_ICONERROR); - return 0; - } - - dialog->addImageField("avatar", "Avatar"); - dialog->addTextField("nickname", "Nickname"); - dialog->addTextField("protocol", "Protocol"); - dialog->addIconField("email_icon", "Unread Email Count Icon"); - dialog->addTextField("email", "Unread Email Count"); - dialog->addIconField("status_icon", "Status Icon"); - dialog->addTextField("status_name", "Status"); - dialog->addTextField("status_msg", "Status Message"); - dialog->addIconField("listening_icon", "Listening To Icon"); - dialog->addTextField("listening", "Listening To"); - dialog->addIconField("next_proto", "Next Protocol"); - dialog->addIconField("prev_proto", "Previous Protocol"); - dialog->setSkinChangedCallback(SkinChanged, NULL); - dialog->finishedConfiguring(); - - +{ InitProtocolData(); // Add options to menu @@ -356,6 +238,43 @@ static int MainInit(WPARAM wparam,LPARAM lparam) InitFrames(); + if (ServiceExists(MS_SKIN2_ADDICON)) + { + if (CallService(MS_SKIN2_GETICON, 0, (LPARAM) "LISTENING_TO_ICON") == NULL) + { + SKINICONDESC sid = {0}; + sid.cbSize = sizeof(SKINICONDESC); + sid.flags = SIDF_TCHAR; + sid.ptszSection = TranslateT("Contact List"); + sid.ptszDescription = TranslateT("Listening to"); + sid.pszName = "LISTENING_TO_ICON"; + sid.hDefaultIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_LISTENINGTO)); + CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid); + } + + { + SKINICONDESC sid = {0}; + sid.cbSize = sizeof(SKINICONDESC); + sid.flags = SIDF_TCHAR; + sid.ptszSection = TranslateT("My Details"); + sid.ptszDescription = TranslateT("Previous protocol"); + sid.pszName = "MYDETAILS_PREV_PROTOCOL"; + sid.hDefaultIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_LEFT_ARROW)); + CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid); + } + + { + SKINICONDESC sid = {0}; + sid.cbSize = sizeof(SKINICONDESC); + sid.flags = SIDF_TCHAR; + sid.ptszSection = TranslateT("My Details"); + sid.ptszDescription = TranslateT("Next protocol"); + sid.pszName = "MYDETAILS_NEXT_PROTOCOL"; + sid.hDefaultIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_RIGHT_ARROW)); + CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid); + } + } + // updater plugin support if(ServiceExists(MS_UPDATE_REGISTER)) { @@ -367,11 +286,11 @@ static int MainInit(WPARAM wparam,LPARAM lparam) upd.szUpdateURL = UPDATER_AUTOREGISTER; - upd.szBetaVersionURL = "http://svn.berlios.de/svnroot/repos/mgoodies/trunk/mydetails/Docs/mydetails_version.txt"; - upd.szBetaChangelogURL = "http://svn.berlios.de/svnroot/repos/mgoodies/trunk/mydetails/Docs/mydetails_changelog.txt"; + upd.szBetaVersionURL = "http://pescuma.org/miranda/mydetails_version.txt"; + upd.szBetaChangelogURL = "http://pescuma.org/miranda/mydetails_changelog.txt"; upd.pbBetaVersionPrefix = (BYTE *)"My Details "; upd.cpbBetaVersionPrefix = strlen((char *)upd.pbBetaVersionPrefix); - upd.szBetaUpdateURL = "http://pescuma.googlecode.com/files/mydetails.%VERSION%.zip"; + upd.szBetaUpdateURL = "http://pescuma.org/miranda/mydetails.zip"; upd.pbVersion = (BYTE *)CreateVersionStringPlugin((PLUGININFO*) &pluginInfo, szCurrentVersion); upd.cpbVersion = strlen((char *)upd.pbVersion); @@ -379,15 +298,13 @@ static int MainInit(WPARAM wparam,LPARAM lparam) CallService(MS_UPDATE_REGISTER, 0, (LPARAM)&upd); } + return 0; } static int MainUninit(WPARAM wParam, LPARAM lParam) { DeInitFrames(); - - delete dialog; - return 0; } @@ -419,19 +336,14 @@ static BOOL CALLBACK DlgProcSetNickname(HWND hwndDlg, UINT msg, WPARAM wParam, L SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadSkinnedIcon(SKINICON_OTHER_MIRANDA)); // All protos have the same nick? - - std::vector protos; - GetProtocols(&protos); - - int protosSize = protos.size(); - if (protosSize > 0) + if (protocols->GetSize() > 0) { - std::string nick = protos[0].GetNick(); + char *nick = protocols->Get(0)->nickname; bool foundDefNick = true; - for(int i = 1; i < protosSize; i++) + for(int i = 1 ; foundDefNick && i < protocols->GetSize() ; i++) { - if (stricmp(protos[i].GetNick(), nick.c_str()) != 0) + if (stricmp(protocols->Get(i)->nickname, nick) != 0) { foundDefNick = false; break; @@ -440,8 +352,8 @@ static BOOL CALLBACK DlgProcSetNickname(HWND hwndDlg, UINT msg, WPARAM wParam, L if (foundDefNick) { - if (stricmp(protocols->default_nick, nick.c_str()) != 0) - lstrcpy(protocols->default_nick, nick.c_str()); + if (stricmp(protocols->default_nick, nick) != 0) + lstrcpy(protocols->default_nick, nick); } } @@ -450,23 +362,23 @@ static BOOL CALLBACK DlgProcSetNickname(HWND hwndDlg, UINT msg, WPARAM wParam, L } else { - Protocol proto = GetProtocolByIndex(proto_num); + Protocol *proto = protocols->Get(proto_num); char tmp[128]; - mir_snprintf(tmp, sizeof(tmp), Translate("Set My Nickname for %s"), proto.GetDescription()); + mir_snprintf(tmp, sizeof(tmp), Translate("Set My Nickname for %s"), proto->description); SendMessage(hwndDlg, WM_SETTEXT, 0, (LPARAM)tmp); - HICON hIcon = (HICON) proto.Call(PS_LOADICON, PLI_PROTOCOL); + HICON hIcon = (HICON)CallProtoService(proto->name, PS_LOADICON, PLI_PROTOCOL, 0); if (hIcon != NULL) { SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon); DestroyIcon(hIcon); } - SetDlgItemText(hwndDlg, IDC_NICKNAME, proto.GetNick()); + SetDlgItemText(hwndDlg, IDC_NICKNAME, proto->nickname); SendDlgItemMessage(hwndDlg, IDC_NICKNAME, EM_LIMITTEXT, - min(MS_MYDETAILS_GETMYNICKNAME_BUFFER_SIZE, proto.GetNickMaxLength()), 0); + min(MS_MYDETAILS_GETMYNICKNAME_BUFFER_SIZE, proto->GetNickMaxLength()), 0); } return TRUE; @@ -480,14 +392,14 @@ static BOOL CALLBACK DlgProcSetNickname(HWND hwndDlg, UINT msg, WPARAM wParam, L char tmp[MS_MYDETAILS_GETMYNICKNAME_BUFFER_SIZE]; GetDlgItemText(hwndDlg, IDC_NICKNAME, tmp, sizeof(tmp)); - int proto_num = (int) GetWindowLong(hwndDlg, GWL_USERDATA); + int proto_num = (int)GetWindowLong(hwndDlg, GWL_USERDATA); if (proto_num == -1) { protocols->SetNicks(tmp); } else { - GetProtocolByIndex(proto_num).SetNick(tmp); + protocols->Get(proto_num)->SetNick(tmp); } DestroyWindow(hwndDlg); @@ -520,12 +432,22 @@ static int PluginCommand_SetMyNicknameUI(WPARAM wParam,LPARAM lParam) if (proto != NULL) { - proto_num = GetProtocolIndexByName(proto); + int i; + for(i = 0 ; i < protocols->GetSize() ; i++) + { + if (stricmp(protocols->Get(i)->name, proto) == 0) + { + proto_num = i; + break; + } + } + if (proto_num == -1) return -1; - if (!GetProtocolByIndex(proto_num).CanSetNick()) + if (!protocols->Get(i)->CanSetNick()) return -2; + } if (!nickname_dialog_open) @@ -551,21 +473,30 @@ static int PluginCommand_SetMyNickname(WPARAM wParam,LPARAM lParam) if (proto != NULL) { - Protocol protocol = GetProtocolByName(proto); - if (!protocol) - return -1; - - if (!protocol.CanSetNick()) - return -2; + for(int i = 0 ; i < protocols->GetSize() ; i++) + { + if (stricmp(protocols->Get(i)->name, proto) == 0) + { + if (!protocols->Get(i)->CanSetNick()) + { + return -2; + } + else + { + protocols->Get(i)->SetNick((char *)lParam); + return 0; + } + } + } - protocol.SetNick((char *)lParam); + return -1; } else { protocols->SetNicks((char *)lParam); - } - return 0; + return 0; + } } @@ -583,17 +514,21 @@ static int PluginCommand_GetMyNickname(WPARAM wParam,LPARAM lParam) lstrcpyn(ret, protocols->default_nick, MS_MYDETAILS_GETMYNICKNAME_BUFFER_SIZE); else ret[0] = '\0'; + + return 0; } else { - Protocol protocol = GetProtocolByName(proto); - if (!protocol) - return -1; - - lstrcpyn(ret, protocol.GetNick(), MS_MYDETAILS_GETMYNICKNAME_BUFFER_SIZE); - } + Protocol *protocol = protocols->Get(proto); - return 0; + if (protocol != NULL) + { + lstrcpyn(ret, protocol->nickname, MS_MYDETAILS_GETMYNICKNAME_BUFFER_SIZE); + return 0; + } + + return -1; + } } @@ -606,18 +541,32 @@ static int PluginCommand_SetMyAvatarUI(WPARAM wParam,LPARAM lParam) if (proto != NULL) { - Protocol protocol = GetProtocolByName(proto); - if (!protocol) + int i; + for(i = 0 ; i < protocols->GetSize() ; i++) + { + if (stricmp(protocols->Get(i)->name, proto) == 0) + { + proto_num = i; + break; + } + } + + if (proto_num == -1) return -1; - if (!protocol.CanSetAvatar()) + if (!protocols->Get(i)->CanSetAvatar()) + { return -2; + } + } - protocol.SetAvatar(NULL); + if (proto_num == -1) + { + protocols->SetAvatars(NULL); } else { - protocols->SetAvatars(NULL); + protocols->Get(proto_num)->SetAvatar(NULL); } return 0; @@ -630,18 +579,29 @@ static int PluginCommand_SetMyAvatar(WPARAM wParam,LPARAM lParam) if (proto != NULL) { - Protocol protocol = GetProtocolByName(proto); - if (!protocol) - return -1; - - if (!protocol.CanSetAvatar()) - return -2; - - protocol.SetAvatar((char *)lParam); + for(int i = 0 ; i < protocols->GetSize() ; i++) + { + if (stricmp(protocols->Get(i)->name, proto) == 0) + { + if (!protocols->Get(i)->CanSetAvatar()) + { + return -2; + } + else + { + protocols->Get(i)->SetAvatar((char *)lParam); + return 0; + } + } + } + + return -1; } else { protocols->SetAvatars((char *)lParam); + + return 0; } return 0; @@ -682,20 +642,35 @@ static int PluginCommand_GetMyAvatar(WPARAM wParam,LPARAM lParam) lstrcpyn(ret, protocols->default_avatar_file, MS_MYDETAILS_GETMYAVATAR_BUFFER_SIZE); else ret[0] = '\0'; + + return 0; } else { - Protocol protocol = GetProtocolByName(proto); - if (!protocol) - return -1; - - if (!protocol.CanGetAvatar()) - return -2; + for(int i = 0 ; i < protocols->GetSize() ; i++) + { + if (stricmp(protocols->Get(i)->name, proto) == 0) + { + if (!protocols->Get(i)->CanGetAvatar()) + { + return -2; + } + else + { + protocols->Get(i)->GetAvatar(); + + if (protocols->Get(i)->avatar_file != NULL) + lstrcpyn(ret, protocols->Get(i)->avatar_file, MS_MYDETAILS_GETMYAVATAR_BUFFER_SIZE); + else + ret[0] = '\0'; - lstrcpyn(ret, protocol.GetAvatarFile(), MS_MYDETAILS_GETMYAVATAR_BUFFER_SIZE); + return 0; + } + } + } } - - return 0; + + return -1; } static LRESULT CALLBACK StatusMsgEditSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) @@ -748,9 +723,9 @@ static BOOL CALLBACK DlgProcSetStatusMessage(HWND hwndDlg, UINT msg, WPARAM wPar if (data->proto_num >= 0) { - Protocol proto = GetProtocolByIndex(data->proto_num); + Protocol *proto = protocols->Get(data->proto_num); - HICON hIcon = (HICON) proto.Call(PS_LOADICON, PLI_PROTOCOL); + HICON hIcon = (HICON)CallProtoService(proto->name, PS_LOADICON, PLI_PROTOCOL, 0); if (hIcon != NULL) { SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon); @@ -759,10 +734,10 @@ static BOOL CALLBACK DlgProcSetStatusMessage(HWND hwndDlg, UINT msg, WPARAM wPar char title[256]; mir_snprintf(title, sizeof(title), Translate("Set My Status Message for %s"), - proto.GetDescription()); + proto->description); SendMessage(hwndDlg, WM_SETTEXT, 0, (LPARAM)title); - SetDlgItemText(hwndDlg, IDC_STATUSMESSAGE, proto.GetStatusMsg()); + SetDlgItemText(hwndDlg, IDC_STATUSMESSAGE, proto->GetStatusMsg()); } else if (data->status != 0) { @@ -795,15 +770,12 @@ static BOOL CALLBACK DlgProcSetStatusMessage(HWND hwndDlg, UINT msg, WPARAM wPar SetStatusMessageData *data = (SetStatusMessageData *) GetWindowLong(hwndDlg, GWL_USERDATA); if (data->proto_num >= 0) - GetProtocolByIndex(data->proto_num).SetStatusMsg(tmp); + protocols->Get(data->proto_num)->SetStatusMsg(tmp); else if (data->status == 0) protocols->SetStatusMsgs(tmp); else protocols->SetStatusMsgs(data->status, tmp); - // To force a refresh - UpdateFrameData(); - DestroyWindow(hwndDlg); break; } @@ -835,7 +807,7 @@ static int PluginCommand_SetMyStatusMessageUI(WPARAM wParam,LPARAM lParam) int status = (int)wParam; char * proto_name = (char *)lParam; int proto_num = -1; - Protocol proto(NULL); + Protocol *proto = NULL; TCHAR status_message[256]; if (status != 0 && (status < ID_STATUS_OFFLINE || status > ID_STATUS_OUTTOLUNCH)) @@ -843,13 +815,24 @@ static int PluginCommand_SetMyStatusMessageUI(WPARAM wParam,LPARAM lParam) if (proto_name != NULL) { - proto_num = GetProtocolIndexByName(proto_name); + for(int i = 0 ; i < protocols->GetSize() ; i++) + { + proto = protocols->Get(i); + + if (stricmp(proto->name, proto_name) == 0) + { + proto_num = i; + break; + } + } + if (proto_num == -1) return -1; - proto = GetProtocolByIndex(proto_num); - if (!proto.CanSetStatusMsg()) + if (protocols->CanSetStatusMsgPerProtocol() && !proto->CanSetStatusMsg()) + { return -2; + } } if (ServiceExists(MS_NAS_INVOKESTATUSWINDOW)) @@ -860,14 +843,14 @@ static int PluginCommand_SetMyStatusMessageUI(WPARAM wParam,LPARAM lParam) iswi.cbSize = sizeof(NAS_ISWINFO); - if (proto) + if (proto != NULL) { // Has to get the unparsed message NAS_PROTOINFO pi; ZeroMemory(&pi, sizeof(pi)); pi.cbSize = sizeof(NAS_PROTOINFO); - pi.szProto = (char *) proto.GetName(); + pi.szProto = proto->name; pi.status = status; pi.szMsg = NULL; @@ -924,7 +907,7 @@ static int PluginCommand_SetMyStatusMessageUI(WPARAM wParam,LPARAM lParam) } } - iswi.szProto = (char *) proto.GetName(); + iswi.szProto = proto->name; iswi.szMsg = status_message; } else @@ -938,20 +921,15 @@ static int PluginCommand_SetMyStatusMessageUI(WPARAM wParam,LPARAM lParam) return 0; } - else if (ServiceExists(MS_SA_SHOWSTATUSMSGDIALOG)) - { - CallService(MS_SA_SHOWSTATUSMSGDIALOG, 0, (LPARAM) proto_name); - return 0; - } else if (ServiceExists(MS_SA_CHANGESTATUSMSG)) { - if (!proto && status == 0) + if (proto == NULL && status == 0) { CallService(MS_SA_CHANGESTATUSMSG, protocols->GetGlobalStatus(), NULL); } else if (status == 0) { - CallService(MS_SA_CHANGESTATUSMSG, proto.GetStatus(), (LPARAM) proto_name); + CallService(MS_SA_CHANGESTATUSMSG, proto->status, (LPARAM) proto_name); } else { @@ -960,7 +938,7 @@ static int PluginCommand_SetMyStatusMessageUI(WPARAM wParam,LPARAM lParam) return 0; } - else if (!proto || proto.GetStatus() != ID_STATUS_OFFLINE) + else if (proto == NULL || proto->status != ID_STATUS_OFFLINE) { if (!status_msg_dialog_open) { diff --git a/plugins/MyDetails/mydetails.dsp b/plugins/MyDetails/mydetails.dsp new file mode 100644 index 0000000000..f6a5638056 --- /dev/null +++ b/plugins/MyDetails/mydetails.dsp @@ -0,0 +1,223 @@ +# Microsoft Developer Studio Project File - Name="mydetails" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=mydetails - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "mydetails.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "mydetails.mak" CFG="mydetails - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "mydetails - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "mydetails - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "mydetails - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MYDETAILS_EXPORTS" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../include" /I "sdk" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MYDETAILS_EXPORTS" /YX /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 +# ADD LINK32 comctl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"../../bin/release/plugins/mydetails.dll" + +!ELSEIF "$(CFG)" == "mydetails - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MYDETAILS_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /I "../../include" /I "sdk" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MYDETAILS_EXPORTS" /FR /YX /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 comctl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x3EC10000" /dll /map /debug /machine:I386 /out:"../../bin/debug unicode/plugins/mydetails.dll" /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "mydetails - Win32 Release" +# Name "mydetails - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\data.cpp +# End Source File +# Begin Source File + +SOURCE=.\frame.cpp +# End Source File +# Begin Source File + +SOURCE=..\utils\mir_dblists.cpp +# End Source File +# Begin Source File + +SOURCE=..\utils\mir_icons.cpp +# End Source File +# Begin Source File + +SOURCE=..\utils\mir_memory.cpp +# End Source File +# Begin Source File + +SOURCE=..\utils\mir_options.cpp +# End Source File +# Begin Source File + +SOURCE=..\utils\mir_smileys.cpp +# End Source File +# Begin Source File + +SOURCE=.\mydetails.cpp +# End Source File +# Begin Source File + +SOURCE=.\options.cpp +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=.\res\leftarrow.ico +# End Source File +# Begin Source File + +SOURCE=.\res\listening_to.ico +# End Source File +# Begin Source File + +SOURCE=.\resource.rc +# End Source File +# Begin Source File + +SOURCE=.\res\rightarrow.ico +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\commons.h +# End Source File +# Begin Source File + +SOURCE=.\data.h +# End Source File +# Begin Source File + +SOURCE=.\frame.h +# End Source File +# Begin Source File + +SOURCE=.\m_mydetails.h +# End Source File +# Begin Source File + +SOURCE=.\m_simpleaway.h +# End Source File +# Begin Source File + +SOURCE=..\utils\mir_dblists.h +# End Source File +# Begin Source File + +SOURCE=..\utils\mir_icons.h +# End Source File +# Begin Source File + +SOURCE=..\utils\mir_memory.h +# End Source File +# Begin Source File + +SOURCE=..\utils\mir_options.h +# End Source File +# Begin Source File + +SOURCE=..\utils\mir_smileys.h +# End Source File +# Begin Source File + +SOURCE=.\mydetails.h +# End Source File +# Begin Source File + +SOURCE=.\options.h +# End Source File +# End Group +# Begin Group "Docs" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\Docs\langpack_MyDetails.txt +# End Source File +# Begin Source File + +SOURCE=.\Docs\mydetails_changelog.txt +# End Source File +# Begin Source File + +SOURCE=.\Docs\mydetails_readme.txt +# End Source File +# Begin Source File + +SOURCE=.\Docs\mydetails_version.txt +# End Source File +# End Group +# End Target +# End Project diff --git a/plugins/MyDetails/mydetails.dsw b/plugins/MyDetails/mydetails.dsw new file mode 100644 index 0000000000..0344f9eb93 --- /dev/null +++ b/plugins/MyDetails/mydetails.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "mydetails"=".\mydetails.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/plugins/MyDetails/options.cpp b/plugins/MyDetails/options.cpp index c5c298c798..5865010683 100644 --- a/plugins/MyDetails/options.cpp +++ b/plugins/MyDetails/options.cpp @@ -36,9 +36,12 @@ static BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l static OptPageControl pageControls[] = { - { &opts.draw_text_rtl, CONTROL_CHECKBOX, IDC_TEXT_RTL, "TextRTL", (BYTE) 0 }, { &opts.cycle_through_protocols, CONTROL_CHECKBOX, IDC_CYCLE_THROUGH_PROTOS, "CicleThroughtProtocols", (BYTE) 1 }, { &opts.seconds_to_show_protocol, CONTROL_SPIN, IDC_CYCLE_TIME, "CicleTime", (WORD) 5, IDC_CYCLE_TIME_SPIN, (WORD) 1, (WORD) 255 }, + { &opts.draw_show_protocol_name, CONTROL_CHECKBOX, IDC_SHOW_PROTO_NAME, "ShowProtocolName", (BYTE) 1 }, + { &opts.show_protocol_cycle_button, CONTROL_CHECKBOX, IDC_SHOW_CYCLE_PROTO_BUTTON, "ShowProtocolCycleButton", (BYTE) 0 }, + { &opts.draw_text_rtl, CONTROL_CHECKBOX, IDC_TEXT_RTL, "TextRTL", (BYTE) 0 }, + { &opts.draw_text_align_right, CONTROL_CHECKBOX, IDC_TEXT_ALIGN_RIGHT, "TextAlignRight", (BYTE) 0 }, { &opts.replace_smileys, CONTROL_CHECKBOX, IDC_REPLACE_SMILEYS, "ReplaceSmileys", (BYTE) 1 }, { &opts.resize_smileys, CONTROL_CHECKBOX, IDC_RESIZE_SMILEYS, "ResizeSmileys", (BYTE) 0 }, { &opts.use_contact_list_smileys, CONTROL_CHECKBOX, IDC_USE_CONTACT_LIST_SMILEYS, "UseContactListSmileys", (BYTE) 0 }, @@ -46,21 +49,27 @@ static OptPageControl pageControls[] = { { &opts.global_on_nickname, CONTROL_CHECKBOX, IDC_GLOBAL_ON_NICKNAME, "GlobalOnNickname", (BYTE) 0 }, { &opts.global_on_status, CONTROL_CHECKBOX, IDC_GLOBAL_ON_STATUS, "GlobalOnStatus", (BYTE) 0 }, { &opts.global_on_status_message, CONTROL_CHECKBOX, IDC_GLOBAL_ON_STATUS_MESSAGE, "GlobalOnStatusMessage", (BYTE) 0 }, + { &opts.draw_avatar_allow_to_grow, CONTROL_CHECKBOX, IDC_AVATAR_ALLOW_TO_GROW, "AvatarAllowToGrow", (BYTE) 0 }, + { &opts.draw_avatar_custom_size, CONTROL_CHECKBOX, IDC_AVATAR_CUSTOM_SIZE_CHK, "AvatarCustomSize", (BYTE) 0 }, + { &opts.draw_avatar_custom_size_pixels, CONTROL_SPIN, IDC_AVATAR_CUSTOM_SIZE, "AvatarCustomSizePixels", (WORD) 30, IDC_AVATAR_CUSTOM_SIZE_SPIN, (WORD) 1, (WORD) 255 }, { &opts.draw_avatar_border, CONTROL_CHECKBOX, IDC_AVATAR_DRAW_BORDER, "AvatarDrawBorders", (BYTE) 0 }, { &opts.draw_avatar_border_color, CONTROL_COLOR, IDC_AVATAR_BORDER_COLOR, "AvatarBorderColor", (DWORD) RGB(0,0,0) }, { &opts.draw_avatar_round_corner, CONTROL_CHECKBOX, IDC_AVATAR_ROUND_CORNERS, "AvatarRoundCorners", (BYTE) 1 }, { &opts.draw_avatar_use_custom_corner_size, CONTROL_CHECKBOX, IDC_AVATAR_CUSTOM_CORNER_SIZE_CHECK, "AvatarUseCustomCornerSize", (BYTE) 0 }, { &opts.draw_avatar_custom_corner_size, CONTROL_SPIN, IDC_AVATAR_CUSTOM_CORNER_SIZE, "AvatarCustomCornerSize", (WORD) 4, IDC_AVATAR_CUSTOM_CORNER_SIZE_SPIN, (WORD) 1, (WORD) 255 }, + { &opts.use_avatar_space_to_draw_text, CONTROL_CHECKBOX, IDC_AVATAR_USE_FREE_SPACE, "AvatarUseFreeSpaceToDrawText", (BYTE) 1 }, { &opts.resize_frame, CONTROL_CHECKBOX, IDC_RESIZE_FRAME, "ResizeFrame", (BYTE) 0 }, + { &opts.borders[RIGHT], CONTROL_SPIN, IDC_BORDER_RIGHT, "BorderRight", (WORD) 8, IDC_BORDER_RIGHT_SPIN, (WORD) 0, (WORD) 255 }, + { &opts.borders[LEFT], CONTROL_SPIN, IDC_BORDER_LEFT, "BorderLeft", (WORD) 8, IDC_BORDER_LEFT_SPIN, (WORD) 0, (WORD) 255 }, + { &opts.borders[TOP], CONTROL_SPIN, IDC_BORDER_TOP, "BorderTop", (WORD) 8, IDC_BORDER_TOP_SPIN, (WORD) 0, (WORD) 255 }, + { &opts.borders[BOTTOM], CONTROL_SPIN, IDC_BORDER_BOTTOM, "BorderBottom", (WORD) 8, IDC_BORDER_BOTTOM_SPIN, (WORD) 0, (WORD) 255 }, + { &opts.bkg_color, CONTROL_COLOR, IDC_AVATAR_BKG_COLOR, "BackgroundColor", (DWORD) GetSysColor(COLOR_BTNFACE) } }; // Initializations needed by options void LoadOptions() { - if (GetSystemMetrics(SM_MIDEASTENABLED)) - pageControls[0].dwDefValue = TRUE; - LoadOpts(pageControls, MAX_REGS(pageControls), MODULE_NAME); // This is created here to assert that this key always exists @@ -68,7 +77,7 @@ void LoadOptions() DBWriteContactSettingWord(NULL,"MyDetails","RefreshStatusMessageTimer", opts.refresh_status_message_timer); SetCycleTime(); - RedrawFrame(); + RefreshFrameAndCalcRects(); } diff --git a/plugins/MyDetails/options.h b/plugins/MyDetails/options.h index 71d5f474c1..a17ad13ed5 100644 --- a/plugins/MyDetails/options.h +++ b/plugins/MyDetails/options.h @@ -36,19 +36,19 @@ struct Options bool use_contact_list_smileys; bool draw_text_rtl; -// bool draw_text_align_right; + bool draw_text_align_right; -// bool draw_show_protocol_name; -// bool show_protocol_cycle_button; + bool draw_show_protocol_name; + bool show_protocol_cycle_button; bool global_on_avatar; bool global_on_nickname; bool global_on_status; bool global_on_status_message; -// bool draw_avatar_custom_size; -// bool draw_avatar_allow_to_grow; -// int draw_avatar_custom_size_pixels; + bool draw_avatar_custom_size; + bool draw_avatar_allow_to_grow; + int draw_avatar_custom_size_pixels; bool draw_avatar_border; COLORREF draw_avatar_border_color; bool draw_avatar_round_corner; @@ -56,9 +56,9 @@ struct Options int draw_avatar_custom_corner_size; COLORREF bkg_color; -// int borders[4]; + int borders[4]; -// bool use_avatar_space_to_draw_text; + bool use_avatar_space_to_draw_text; bool resize_frame; diff --git a/plugins/MyDetails/res/mail.ico b/plugins/MyDetails/res/mail.ico deleted file mode 100644 index ba0e7d35de..0000000000 Binary files a/plugins/MyDetails/res/mail.ico and /dev/null differ diff --git a/plugins/MyDetails/resource.h b/plugins/MyDetails/resource.h index 9bc277ea60..b53e46d1a3 100644 --- a/plugins/MyDetails/resource.h +++ b/plugins/MyDetails/resource.h @@ -9,7 +9,6 @@ #define IDI_LISTENINGTO 105 #define IDI_RIGHT_ARROW 106 #define IDI_LEFT_ARROW 107 -#define IDI_EMAIL 111 #define IDC_NICKNAME 1000 #define IDC_SHOW_PROTO_NAME 1001 #define IDC_CYCLE_THROUGH_PROTOS 1002 @@ -64,7 +63,7 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 112 +#define _APS_NEXT_RESOURCE_VALUE 108 #define _APS_NEXT_COMMAND_VALUE 40013 #define _APS_NEXT_CONTROL_VALUE 1011 #define _APS_NEXT_SYMED_VALUE 101 diff --git a/plugins/MyDetails/resource.rc b/plugins/MyDetails/resource.rc index 5706422e8e..da0ebf3c11 100644 --- a/plugins/MyDetails/resource.rc +++ b/plugins/MyDetails/resource.rc @@ -13,30 +13,6 @@ ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// Neutral resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) -#ifdef _WIN32 -LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_LISTENINGTO ICON DISCARDABLE "res\\listening_to.ico" -IDI_RIGHT_ARROW ICON DISCARDABLE "res\\rightarrow.ico" -IDI_LEFT_ARROW ICON DISCARDABLE "res\\leftarrow.ico" -IDI_EMAIL ICON DISCARDABLE "res\\mail.ico" -#endif // Neutral resources -///////////////////////////////////////////////////////////////////////////// - - ///////////////////////////////////////////////////////////////////////////// // English (U.S.) resources @@ -113,7 +89,7 @@ END IDD_OPTS DIALOGEX 0, 0, 316, 246 STYLE DS_FIXEDSYS | WS_CHILD | WS_VISIBLE EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN GROUPBOX " General ",IDC_STATIC,7,7,302,70 CONTROL "Cycle through protocols every:", @@ -128,6 +104,8 @@ BEGIN BS_AUTOCHECKBOX | WS_TABSTOP,207,18,96,14 CONTROL "RTL",IDC_TEXT_RTL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, 13,32,85,14 + CONTROL "Align text to right",IDC_TEXT_ALIGN_RIGHT,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,105,32,96,14 CONTROL "Global on nickname",IDC_GLOBAL_ON_NICKNAME,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,207,32,96,14 CONTROL "Auto-resize frame",IDC_RESIZE_FRAME,"Button", @@ -142,22 +120,63 @@ BEGIN BS_AUTOCHECKBOX | WS_TABSTOP,105,60,96,14 CONTROL "Global on status message",IDC_GLOBAL_ON_STATUS_MESSAGE, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,207,61,96,14 - GROUPBOX " Avatar ",IDC_STATIC,7,80,302,59 + GROUPBOX " Frame Options ",IDC_STATIC,7,78,302,44 + LTEXT "Top:",IDC_STATIC,16,91,41,11 + EDITTEXT IDC_BORDER_TOP,59,89,35,12,ES_NUMBER + CONTROL "",IDC_BORDER_TOP_SPIN,"msctls_updown32",UDS_SETBUDDYINT | + UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_NOTHOUSANDS | + UDS_HOTTRACK,88,89,11,12 + LTEXT "Bottom:",IDC_STATIC,111,91,41,11 + EDITTEXT IDC_BORDER_BOTTOM,154,89,35,12,ES_NUMBER + CONTROL "",IDC_BORDER_BOTTOM_SPIN,"msctls_updown32", + UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_ARROWKEYS | + UDS_NOTHOUSANDS | UDS_HOTTRACK,182,89,11,12 + LTEXT "Left:",IDC_STATIC,15,105,41,11 + EDITTEXT IDC_BORDER_LEFT,59,103,35,12,ES_NUMBER + CONTROL "",IDC_BORDER_LEFT_SPIN,"msctls_updown32", + UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_ARROWKEYS | + UDS_NOTHOUSANDS | UDS_HOTTRACK,88,103,11,12 + LTEXT "Right:",IDC_STATIC,111,106,41,11 + EDITTEXT IDC_BORDER_RIGHT,154,104,35,12,ES_NUMBER + CONTROL "",IDC_BORDER_RIGHT_SPIN,"msctls_updown32", + UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_ARROWKEYS | + UDS_NOTHOUSANDS | UDS_HOTTRACK,182,104,11,12 + LTEXT "Background Color:",IDC_AVATAR_BKG_COLOR_L,205,91,66,10 + CONTROL "",IDC_AVATAR_BKG_COLOR,"ColourPicker",WS_TABSTOP,277,89, + 17,13 + GROUPBOX " Avatar ",IDC_STATIC,7,124,302,83 + CONTROL "Custom size:",IDC_AVATAR_CUSTOM_SIZE_CHK,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,16,137,66,9 + EDITTEXT IDC_AVATAR_CUSTOM_SIZE,87,135,35,12,ES_NUMBER + CONTROL "",IDC_AVATAR_CUSTOM_SIZE_SPIN,"msctls_updown32", + UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_ARROWKEYS | + UDS_NOTHOUSANDS | UDS_HOTTRACK,116,134,11,12 + LTEXT "pixels",IDC_STATIC,130,137,24,11 + CONTROL "Allow it to grow",IDC_AVATAR_ALLOW_TO_GROW,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,174,137,106,9 CONTROL "Draw border on avatar",IDC_AVATAR_DRAW_BORDER,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,16,95,103,9 - LTEXT "Border Color:",IDC_AVATAR_BORDER_COLOR_L,123,95,53,10 + BS_AUTOCHECKBOX | WS_TABSTOP,16,152,103,9 + LTEXT "Border Color:",IDC_AVATAR_BORDER_COLOR_L,123,152,53,10 CONTROL "",IDC_AVATAR_BORDER_COLOR,"ColourPicker",WS_TABSTOP,180, - 92,17,13 + 149,17,13 CONTROL "Round corners of avatars",IDC_AVATAR_ROUND_CORNERS, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,109,280,8 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,166,280,8 CONTROL "Custom corner size:", IDC_AVATAR_CUSTOM_CORNER_SIZE_CHECK,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,27,122,93,11 - EDITTEXT IDC_AVATAR_CUSTOM_CORNER_SIZE,127,121,35,12,ES_NUMBER + BS_AUTOCHECKBOX | WS_TABSTOP,27,179,93,11 + EDITTEXT IDC_AVATAR_CUSTOM_CORNER_SIZE,127,178,35,12,ES_NUMBER CONTROL "",IDC_AVATAR_CUSTOM_CORNER_SIZE_SPIN,"msctls_updown32", UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_ARROWKEYS | - UDS_NOTHOUSANDS | UDS_HOTTRACK,165,121,11,12 - LTEXT "pixels",IDC_STATIC,179,124,41,11 + UDS_NOTHOUSANDS | UDS_HOTTRACK,165,178,11,12 + LTEXT "pixels",IDC_STATIC,179,181,41,11 + CONTROL "Use free space (under avatar) to other texts", + IDC_AVATAR_USE_FREE_SPACE,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,16,195,280,8 + GROUPBOX " Protocol ",IDC_STATIC,7,209,302,28 + CONTROL "Show protocol name",IDC_SHOW_PROTO_NAME,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,13,221,138,14 + CONTROL "Show protocol cycle button",IDC_SHOW_CYCLE_PROTO_BUTTON, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,163,221,138,14 END IDD_SETSTATUSMESSAGE DIALOG DISCARDABLE 0, 0, 283, 68 @@ -208,6 +227,17 @@ BEGIN END #endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_LISTENINGTO ICON DISCARDABLE "res\\listening_to.ico" +IDI_RIGHT_ARROW ICON DISCARDABLE "res\\rightarrow.ico" +IDI_LEFT_ARROW ICON DISCARDABLE "res\\leftarrow.ico" #endif // English (U.S.) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/plugins/MyDetails/sdk/m_NewAwaySys.h b/plugins/MyDetails/sdk/m_NewAwaySys.h new file mode 100644 index 0000000000..4038fadaa7 --- /dev/null +++ b/plugins/MyDetails/sdk/m_NewAwaySys.h @@ -0,0 +1,119 @@ +/* + New Away System plugin for Miranda IM + Copyright (c) 2005-2006 Chervov Dmitry + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef __M_NEWAWAYSYS_H +#define __M_NEWAWAYSYS_H + +// NAS_PROTOINFO::Flags constants +#define PIF_NO_CLIST_SETSTATUSMODE 1 // NAS won't call MS_CLIST_SETSTATUSMODE service on a global status change, if this flag is set. it's useful if you want to change the global message and status in NAS without changing current "real" protocol statuses. NAS ignores this flag if szProto != NULL +#define PIF_NOTTEMPORARY 2 +// usually you should NOT set this flag +// for MS_NAS_SETSTATE: NAS will overwrite current user-defined message for szProto if this flag is specified; otherwise (if the flag isn't specified), your szMsg will be stored only until the next szProto status change, and won't overwrite any messages specified by user +// for MS_NAS_GETSTATE: NAS ignores any temporary messages and returns only non-temporary ones. this flag affects something only when status == 0 + +typedef struct { + int cbSize; + char *szProto; // pointer to protocol modulename (NULL means global) + union + { + char *szMsg; + WCHAR *wszMsg; + TCHAR *tszMsg; + }; // pointer to the status message _format_ (i.e. it's an unparsed message containing variables, in any case. NAS takes care of parsing) (may be NULL - means that there's no specific message for this protocol - then the global status message will be used) +/* + Be aware that MS_NAS_GETSTATE allocates memory for szMsg through Miranda's + memory management interface (MS_SYSTEM_GET_MMI). And MS_NAS_SETSTATE + expects szMsg to be allocated through the same service. MS_NAS_SETSTATE deallocates szMsg. +*/ + WORD status; // status mode. 0 means current (NAS will overwrite 0 with the current status mode) +// for MS_NAS_GETSTATE if the specified status is not 0, MS_NAS_GETSTATE will return the default/last status message (depends on settings) - i.e. the same message that will be shown by default when user changes status to the specified one. please note that, for example, if current status mode is ID_STATUS_AWAY, then status messages returned by MS_NAS_GETSTATE for status=0 and status=ID_STATUS_AWAY may be different! for status=ID_STATUS_AWAY it always returns the default/last status message, and for status=0 it returns _current_ status message. + int Flags; +} NAS_PROTOINFO; + +// MS_NAS_GETSTATE +// Fills specified array of NAS_PROTOINFO items with protocol data. +// You must construct the array and specify cbSize and szProto fields of +// all items in the array before calling this service. +// Remember to free szMsg fields through Miranda's MMI if you don't pass them back to NAS through MS_NAS_SETSTATE later. +// wParam = (WPARAM)(NAS_PROTOINFO*)pi - pointer to an array of NAS_PROTOINFO items to be filled. +// lParam = (LPARAM)(int)protoCount - number of items in pi. +// returns 0 on success +#define MS_NAS_GETSTATEA "NewAwaySystem/GetStateA" +#define MS_NAS_GETSTATEW "NewAwaySystem/GetStateW" +#ifdef _UNICODE + #define MS_NAS_GETSTATE MS_NAS_GETSTATEW +#else + #define MS_NAS_GETSTATE MS_NAS_GETSTATEA +#endif + +// MS_NAS_SETSTATE +// Changes status mode and message of specified protocols. +// (Note that this service deallocates szMsg field of the specified items through +// Miranda's MMI, so the array is not valid anymore after MS_NAS_SETSTATE returns!) +// wParam = (WPARAM)(NAS_PROTOINFO*)pi - pointer to an array of NAS_PROTOINFO items. +// lParam = (LPARAM)(int)protoCount - number of items in pi. +// returns 0 on success +#define MS_NAS_SETSTATEA "NewAwaySystem/SetStateA" +#define MS_NAS_SETSTATEW "NewAwaySystem/SetStateW" +#ifdef _UNICODE + #define MS_NAS_SETSTATE MS_NAS_SETSTATEW +#else + #define MS_NAS_SETSTATE MS_NAS_SETSTATEA +#endif + +// NAS_ISWINFO::Flags constants +#define ISWF_NOCOUNTDOWN 1 // don't start the countdown to close the window +#define ISWF_UNICODE 2 // specifies that NAS_ISWINFO::szMsg is a WCHAR* +#ifdef _UNICODE + #define ISWF_TCHAR ISWF_UNICODE // will use WCHAR* instead of char* +#else + #define ISWF_TCHAR 0 // will use char*, as usual +#endif + +typedef struct { + int cbSize; + char *szProto; // pointer to initial protocol modulename (NULL means global); ignored when hContact is not NULL. + HANDLE hContact; // NAS will select this contact in the window initially, if it's not NULL. + union + { + char *szMsg; + WCHAR *wszMsg; + TCHAR *tszMsg; + }; // pointer to an initial status message (may be NULL, NAS will use the default message then) + WORD status; // status mode. 0 means current. + int Flags; // a combination of ISWF_ constants +} NAS_ISWINFO; + +// MS_NAS_INVOKESTATUSWINDOW +// Invokes the status message change window. +// Though if the window is open already, this service just activates an existing window and changes protocol status (i.e. it ignores szMsg and hContact). This behavior may change in future. +// wParam = (WPARAM)(NAS_ISWINFO*)iswi - pointer to a NAS_ISWINFO structure. +// lParam = 0 +// returns HWND of the window on success, or NULL on failure. +#define MS_NAS_INVOKESTATUSWINDOW "NewAwaySystem/InvokeStatusWindow" + +/* An example: + NAS_ISWINFO iswi = {0}; // for C you may use ZeroMemory() instead + iswi.cbSize = sizeof(iswi); + iswi.tszMsg = _T("New global status message."); + iswi.Flags = ISWF_TCHAR; + CallService(MS_NAS_INVOKESTATUSWINDOW, (WPARAM)&iswi, 0); +*/ + +#endif // __M_NEWAWAYSYS_H \ No newline at end of file diff --git a/plugins/MyDetails/sdk/m_avatars.h b/plugins/MyDetails/sdk/m_avatars.h new file mode 100644 index 0000000000..46c6d2b614 --- /dev/null +++ b/plugins/MyDetails/sdk/m_avatars.h @@ -0,0 +1,297 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2004 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +Avatar service + +- load and maintain a cache of contact avatars. +- draw avatars to a given target device context +- maintain per protocol fallback images + +The avatar service builds on top of Mirandas core bitmap loading service (MS_UTILS_LOADBITMAP). +However, if imgdecoder.dll is installed in mirandas main or Plugins directory, it can be used +to support PNG images. The avatar service loads 32bit PNG images and peforms alpha channel +premultiplication so that these images can be rendered by using the Win32 AlphaBlend() API. + +The cache grows on demand only, that is, no avatars are PREloaded. An avatar is only loaded +if a plugin requests this by using the MS_AV_GETAVATAR service. Since avatars may update +asynchronously, the avatar iamge may not be ready when a plugin calls the service. In that +case, an event (ME_AV_AVATARCHANGED) is fired when a contacts avatar changes. This event +is also fired, when a contact avatar changes automatically. + +The service takes care about protocol capabilites (does not actively fetch avatars for +protocols which do not report avatar capabilities via PF4_AVATARS or for protocols which +have been disabled in the option dialog). It also does not actively fetch avatars for +protocols which are in invisible status mode (may cause privacy issues and some protocols +like MSN don't allow any outbound client communication when in invisible status mode). + +- TODO +- maintain recent avatars (store the last hashes to avoid re-fetching) +- cache expiration, based on least recently used algorithm. + +(c) 2005 by Nightwish, silvercircle@gmail.com + +*/ + +#ifndef _M_AVATARS_H +#define _M_AVATARS_H + +#define AVS_BITMAP_VALID 1 +#define AVS_BITMAP_EXPIRED 2 // the bitmap has been expired from the cache. (unused, currently. +#define AVS_HIDEONCLIST 4 +#define AVS_PREMULTIPLIED 8 // set in the dwFlags member of the struct avatarCacheEntry for 32 bit transparent + // images when loaded with imgdecoder. These images can be rendered transparently + // using the AlphaBlend() API with AC_SRC_ALPHA +#define AVS_PROTOPIC 16 // picture is a protocol picture +#define AVS_CUSTOMTRANSPBKG 32 // Bitmap was changed to set the background color transparent +#define AVS_HASTRANSPARENCY 64 // Bitmap has at least one pixel transparent +#define AVS_OWNAVATAR 128 // is own avatar entry +#define AVS_NOTREADY 4096 + +struct avatarCacheEntry { + DWORD cbSize; // set to sizeof(struct) + HANDLE hContact; // contacts handle, 0, if it is a protocol avatar + HBITMAP hbmPic; // bitmap handle of the picutre itself + DWORD dwFlags; // see above for flag values + LONG bmHeight, bmWidth; // bitmap dimensions + DWORD t_lastAccess; // last access time (currently unused, but plugins should still + // use it whenever they access the avatar. may be used in the future + // to implement cache expiration + LPVOID lpDIBSection; // unused field + char szFilename[MAX_PATH]; // filename of the avatar (absolute path) +}; + +typedef struct avatarCacheEntry AVATARCACHEENTRY; + +struct CacheNode { + struct CacheNode *pNextNode; + struct avatarCacheEntry ace; + //CRITICAL_SECTION cs; + BOOL loaded; + int mustLoad; + DWORD dwFlags; + int pa_format; +}; + +#define AVDRQ_FALLBACKPROTO 1 // use the protocol picture as fallback (currently not used) +#define AVDRQ_FAILIFNOTCACHED 2 // don't create a cache entry if it doesn't already exist. (currently not working) +#define AVDRQ_ROUNDEDCORNER 4 // draw with rounded corners +#define AVDRQ_DRAWBORDER 8 // draw a border around the picture +#define AVDRQ_PROTOPICT 16 // draw a protocol picture (if available). +#define AVDRQ_HIDEBORDERONTRANSPARENCY 32 // hide border if bitmap has transparency +#define AVDRQ_OWNPIC 64 // draw own avatar (szProto is valid) +#define AVDRQ_RESPECTHIDDEN 128 // don't draw images marked as hidden + +// request to draw a contacts picture. See MS_AV_DRAWAVATAR service description + +typedef struct _avatarDrawRequest { + DWORD cbSize; // set this to sizeof(AVATARDRAWREQUEST) - mandatory, service will return failure code if + // cbSize is wrong + HANDLE hContact; // the contact for which the avatar should be drawn. set it to 0 to draw a protocol picture + HDC hTargetDC; // target device context + RECT rcDraw; // target rectangle. The avatar will be centered within the rectangle and scaled to fit. + DWORD dwFlags; // flags (see above for valid bitflags) + DWORD dwReserved; // for future use + DWORD dwInternal; // don't use it + COLORREF clrBorder; // color for the border (used with AVDRQ_DRAWBORDER) + UCHAR radius; // radius (used with AVDRQ_ROUNDEDCORNER) + UCHAR alpha; // alpha value for semi-transparent avatars (valid values form 1 to 255, if it is set to 0 + // the avatar won't be transparent. + char *szProto; // only used when AVDRQ_PROTOPICT or AVDRQ_OWNPIC is set +} AVATARDRAWREQUEST; + +#define CACHE_BLOCKSIZE 20 + +#define AVS_MODULE "AVS_Settings" // db settings module path +#define PPICT_MODULE "AVS_ProtoPics" // protocol pictures are saved here + +// obtain the bitmap handle of the avatar for the given contact +// wParam = (HANDLE)hContact +// lParam = 0; +// returns: pointer to a struct avatarCacheEntry *, NULL on failure +// if it returns a failure, the avatar may be ready later and the caller may receive +// a notification via ME_AV_AVATARCHANGED +// DONT modify the contents of the returned data structure + +#define MS_AV_GETAVATARBITMAP "SV_Avatars/GetAvatar" + +// obtain a avatar cache entry for one of my own avatars +// wParam = 0 +// lParam = (char *)szProto (protocol for which we need to obtain the own avatar information) +// returns: pointer to a struct avatarCacheEntry *, NULL on failure +// DONT modify the contents of the returned data structure + +#define MS_AV_GETMYAVATAR "SV_Avatars/GetMyAvatar" + +// protect the current contact picture from being overwritten by automatic +// avatar updates. Actually, it only backups the contact picture filename +// and will used the backuped version until the contact picture gets unlocked +// again. So this service does not disable avatar updates, but it "fakes" +// a locked contact picture to the users of the GetAvatar service. +// +// wParam = (HANDLE)hContact +// lParam = 1 -> lock the avatar, lParam = 0 -> unlock + +#define MS_AV_PROTECTAVATAR "SV_Avatars/ProtectAvatar" + +// set (and optionally protect) a local contact picture for the given hContact +// +// wParam = (HANDLE)hContact +// lParam = either a full picture filename or NULL. If lParam == NULL, the service +// will open a file selection dialog. + +#define MS_AV_SETAVATAR "SV_Avatars/SetAvatar" + +// set a local picture for the given protocol +// +// wParam = (char *) protocol name +// lParam = either a full picture filename or NULL. If lParam == NULL, the service +// will open a file selection dialog. + +#define MS_AV_SETMYAVATAR "SV_Avatars/SetMyAvatar" + +// see if is possible to set the avatar for the expecified protocol +// +// wParam = (char *) protocol name +// lParam = 0 +// return = 1 if can set, 0 if can't + +#define MS_AV_CANSETMYAVATAR "SV_Avatars/CanSetMyAvatar" + +// Call avatar option dialog for contact +// +// wParam = (HANDLE)hContact + +#define MS_AV_CONTACTOPTIONS "SV_Avatars/ContactOptions" + +// draw an avatar picture +// +// wParam = 0 (not used) +// lParam = AVATARDRAWREQUEST *avdr +// draw a contact picture to a destination device context. see description of +// the AVATARDRAWREQUEST structure for more information on how to use this +// service. +// return value: 0 -> failure, avatar probably not available, or not ready. The drawing +// service DOES schedule an avatar update so your plugin will be notified by the ME_AV_AVATARCHANGED +// event when the requested avatar is ready for use. +// 1 -> success. avatar was found and drawing should be ok. + +#define MS_AV_DRAWAVATAR "SV_Avatars/Draw" + +// fired when a contacts avatar cached by avs changes +// it includes changes made by the user +// wParam = hContact +// lParam = struct avatarCacheEntry *cacheEntry +// the event CAN pass a NULL pointer in lParam which means that the avatar has changed, +// but is no longer valid (happens, when a contact removes his avatar, for example). +// DONT DESTROY the bitmap handle passed in the struct avatarCacheEntry * +// +// It is also possible that this event passes 0 as wParam (hContact), in which case, +// a protocol picture (pseudo - avatar) has been changed. + +#define ME_AV_AVATARCHANGED "SV_Avatars/AvatarChanged" + + +typedef struct _contactAvatarChangedNotification { + int cbSize; // sizeof() + HANDLE hContact; // this might have to be set by the caller too + int format; // PA_FORMAT_* + char filename[MAX_PATH]; // full path to filename which contains the avatar + char hash[128]; // avatar hash (always an empty string by now) +} CONTACTAVATARCHANGEDNOTIFICATION; + +// fired when the contacts avatar is changed by the contact +// wParam = hContact +// lParam = struct CONTACTAVATARCHANGENOTIFICATION *cacn +// the event CAN pass a NULL pointer in lParam which means that the contact deleted its avatar + +#define ME_AV_CONTACTAVATARCHANGED "SV_Avatars/ContactAvatarChanged" + +// fired when one of our own avatars was changed +// wParam = (char *)szProto (protocol for which a new avatar was set) +// lParam = AVATARCACHEENTRY *ace (new cache entry, NULL if the new avatar is not valid) + +#define ME_AV_MYAVATARCHANGED "SV_Avatars/MyAvatarChanged" + +// Service to be called by protocols to report an avatar has changed. Some avatar changes +// can be detected automatically, but some not (by now only Skype ones) +// wParam = (char *)szProto (protocol for which a new avatar was set) +// lParam = 0 + +#define MS_AV_REPORTMYAVATARCHANGED "SV_Avatars/ReportMyAvatarChanged" + + + +// Bitmap services ////////////////////////////////////////////////////////////////////// + +// Load an image +// wParam = NULL +// lParam = filename +#define MS_AV_LOADBITMAP32 "SV_Avatars/LoadBitmap32" + +// Save an HBITMAP to an image +// wParam = HBITMAP +// lParam = full path of filename +#define MS_AV_SAVEBITMAP "SV_Avatars/SaveBitmap" + +// Returns != 0 if can save that type of image, = 0 if cant +// wParam = 0 +// lParam = PA_FORMAT_* // image format +#define MS_AV_CANSAVEBITMAP "SV_Avatars/CanSaveBitmap" + + +#define RESIZEBITMAP_STRETCH 0 // Distort bitmap to size in (max_width, max_height) +#define RESIZEBITMAP_KEEP_PROPORTIONS 1 // Keep bitmap proportions (probabily only one of the + // max_width/max_height will be respected, and the other will be + // smaller) +#define RESIZEBITMAP_CROP 2 // Keep bitmap proportions but crop it to fix exactly in (max_width, max_height) + // Some image info outside will be lost +#define RESIZEBITMAP_MAKE_SQUARE 3 // Image will be allways square. Image will be croped and the size + // returned will be min(max_width, max_height) + +#define RESIZEBITMAP_FLAG_DONT_GROW 0x1000 // If set, the image will not grow. Else, it will grow to fit the max width/height + +typedef struct { + size_t size; // sizeof(ResizeBitmap); + + HBITMAP hBmp; + + int max_width; + int max_height; + + int fit; // One of: RESIZEBITMAP_* +} ResizeBitmap; + +// Returns a copy of the bitmap with the size especified or the original bitmap if nothing has to be changed +// wParam = ResizeBitmap * +// lParam = NULL +#define MS_AV_RESIZEBITMAP "SV_Avatars/ResizeBitmap" + +/* + * flags for internal use ONLY + */ + +#define MC_ISMASTERCONTACT 0x01 +#define MC_ISSUBCONTACT 0x02 +#define AVH_MUSTNOTIFY 0x04 // node->dwFlags (loader thread must notify avatar history about change/delete event) +#define AVS_DELETENODEFOREVER 0x08 + +#endif diff --git a/plugins/MyDetails/sdk/m_cluiframes.h b/plugins/MyDetails/sdk/m_cluiframes.h new file mode 100644 index 0000000000..067d586f1c --- /dev/null +++ b/plugins/MyDetails/sdk/m_cluiframes.h @@ -0,0 +1,338 @@ +/* +Miranda ICQ: the free icq client for MS Windows +Copyright (C) 2000-2 Richard Hughes, Roland Rabien & Tristan Van de Vreede + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +/************************************************************************/ +/* Extra Image Column Support +0.5.0.0 */ +/************************************************************************/ +/* + HINT: Common usage of Extra icons by modules + Usage sequence is next: + The Plugin have to be subscribed to ME_CLIST_EXTRA_LIST_REBUILD and + ME_CLIST_EXTRA_IMAGE_APPLY notifications. + + During .._REBUILD Notification handle plugin should register required + icons in CList internal list via MS_CLIST_EXTRA_ADD_ICON servise + and should to keep returned icon indexes. + + Note: _REBUILD notification means that list was rebuilded and + all previously registered icon indexes became invalid and can not be used. + + Note: After calling _ADD_ICON services the icon handle you provided is not + need for extra images porpouses and have to be released by you in order + to reduce GDI resources consumptions. + + Note: Don't forget that icon handle loaded by LoadIcon GDI function is + shared and will be kept in memory till plugin unloading. So it is not + better way to load icon. Please use appropriate Iconlib services. + + Note: The icon can be registered in Clist at any time. + + During .._ME_CLIST_EXTRA_IMAGE_APPLY the plugin has to call + MS_CLIST_EXTRA_SET_ICON passing appropriate icon index for contact. This + service can be called any time in order to change current extra image. + + ATTENTION: Currently Module support only 254 registered extra icons. The returned + value 0xFF internally means 'No extra icon' so thry t register only realy required + icons. The best solution - register not registered/invalidated icon just before + setting of extra image. + + ATTENTION: Due to different module may use same extra icons slot - they will be conflicted. + Please provide ability to end-user to change extra image slot to be used to show + your plugin information. + +*/ + +//Extra columns type. +//column arranged in this way +// +// [statusicon] ContactName [WEB][ADV1][ADV2][SMS][EMAIL][PROTO][CLIENT] +// +#define EXTRA_ICON_EMAIL 1 +#define EXTRA_ICON_PROTO 2 +#define EXTRA_ICON_SMS 3 +#define EXTRA_ICON_ADV1 4 +#define EXTRA_ICON_ADV2 5 +#define EXTRA_ICON_WEB 6 +#define EXTRA_ICON_CLIENT 7 +#define EXTRA_ICON_VISMODE 8 +#define EXTRA_ICON_ADV3 9 +#define EXTRA_ICON_ADV4 10 + +#define EXTRA_ICON_COUNT 10 + +typedef struct +{ + int cbSize; //must be sizeof(IconExtraColumn) + int ColumnType; + HANDLE hImage; //return value from MS_CLIST_EXTRA_ADD_ICON +}IconExtraColumn,*pIconExtraColumn; + +//Set icon for contact at needed column +//wparam=hContact +//lparam=pIconExtraColumn +//return 0 on success,-1 on failure +// +//See above for supported columns +#define MS_CLIST_EXTRA_SET_ICON "CListFrames/SetIconForExraColumn" + +//Adding icon to extra image list. +//Call this in ME_CLIST_EXTRA_LIST_REBUILD event +// +//wparam=hIcon +//lparam=0 +//return hImage on success,-1 on failure +#define MS_CLIST_EXTRA_ADD_ICON "CListFrames/AddIconToExtraImageList" + +#define ME_CLIST_EXTRA_LIST_REBUILD "CListFrames/OnExtraListRebuild" + +//called with wparam=hContact +#define ME_CLIST_EXTRA_IMAGE_APPLY "CListFrames/OnExtraImageApply" + +//End of extra images header. TODO move it to separate m_extraimages.h file +//Cause it has not any relationship to cluiframes engine + + +/************************************************************************/ +/* CLUI Frames Support */ +/************************************************************************/ + +// NOTE: Clui frames engine is in to be reconsructed.. + +// Constants used bellow +typedef struct tagCLISTFrame { + DWORD cbSize; + HWND hWnd ; + HICON hIcon; + int align; //al flags below + union { + int height; + int minSize; //the actual meaning depends from type of frame + }; + int Flags; //F_flags below + union { + char *name; //frame window name indentifier (DO NOT TRANSLATE) + wchar_t *wname; + LPTSTR tname; + }; + union { + char *TBname; //titlebar & menu caption + wchar_t *TBwname; + LPTSTR TBtname; + }; +} CLISTFrame; + +#define F_VISIBLE 1 //Frame visible +#define F_SHOWTB 2 //Show TitleBar +#define F_UNCOLLAPSED 4 //UnCollapse frame +#define F_LOCKED 8 //Lock Frame +#define F_NOBORDER 16 //Dont apply WS_BORDER style for window +#define F_SHOWTBTIP 32 //Show titlebar tooltip +#define F_CANBEVERTICAL 64 //frames can be vertical +#define F_CANNOTBEHORIZONTAL 128 //frames can NOT be horizontal F_CANBEVERTICAL have to be set +#define F_NO_SUBCONTAINER 1024 //Support skining no subcontainer needed +#define F_UNICODE 32768 //Use unicode text +#ifdef _UNICODE +# define F_TCHAR F_UNICODE +#else +# define F_TCHAR 0 +#endif + +// frame alignment +#define alTop 0x00000001 +#define alBottom 0x00000002 +#define alClient 0x00000004 //only one alClient frame + +// since 0.7.0.20 +#define alLeft 0x00000011 // frame is vertical +#define alRight 0x00000012 + +#define alVertFrameMask 0x00000010 + +#define FU_TBREDRAW 1 //redraw titlebar +#define FU_FMREDRAW 2 //redraw Frame +#define FU_FMPOS 4 //update Frame position + +#define FO_FLAGS 0x0001 //return set of F_VISIBLE,F_SHOWTB,F_UNCOLLAPSED,F_LOCKED,F_NOBORDER,F_SHOWTBTIP +#define FO_NAME 0x0002 //Change name +#define FO_TBNAME 0x0003 //Change TB caption +#define FO_TBSTYLE 0x0004 //Change TB style +#define FO_TBEXSTYLE 0x0005 //Change TB exstyle +#define FO_ICON 0x0006 //Change icon +#define FO_HEIGHT 0x0007 //Change height +#define FO_ALIGN 0x0008 //Change align +#define FO_TBTIPNAME 0x0009 //Change TB tooltip +#define FO_FLOATING 0x000a //Change floating mode + +#define FO_UNICODETEXT 0x8000 // flag for FO_NAME,FO_TBNAME, FO_TBTIPNAME set/get lPAram as unicode wchar_t +#ifdef _UNICODE + #define FO_TCHAR FO_UNICODETEXT +#else + #define FO_TCHAR 0x0000 +#endif + + +////////////////////////////////////////////////////////////////////////// +//want show tooltip for statusbar +//wparam=(char *)protocolname +//lparam=0 +#define ME_CLIST_FRAMES_SB_SHOW_TOOLTIP "CListFrames/StatusBarShowToolTip" + +////////////////////////////////////////////////////////////////////////// +//want hide tooltip for statusbar +//wparam=lparam=0 +#define ME_CLIST_FRAMES_SB_HIDE_TOOLTIP "CListFrames/StatusBarHideToolTip" + +////////////////////////////////////////////////////////////////////////// +//adds a frame window +//wParam=(CLISTFrame*) +//lParam=0 +//returns an integer, the frame id. +#define MS_CLIST_FRAMES_ADDFRAME "CListFrames/AddFrame" + +////////////////////////////////////////////////////////////////////////// +// remove frame. It destroy your window +// +#define MS_CLIST_FRAMES_REMOVEFRAME "CListFrames/RemoveFrame" + +////////////////////////////////////////////////////////////////////////// +//shows all frames +//wParam=lParam=0 +//returns 0 on success, -1 on failure +#define MS_CLIST_FRAMES_SHOWALLFRAMES "CListFrames/ShowALLFrames" + +////////////////////////////////////////////////////////////////////////// +//shows the titlebars of all frames +//wParam=lParam=0 +//returns 0 on success, -1 on failure +#define MS_CLIST_FRAMES_SHOWALLFRAMESTB "CListFrames/ShowALLFramesTB" + +////////////////////////////////////////////////////////////////////////// +//hides the titlebars of all frames +//wParam=lParam=0 +//returns 0 on success, -1 on failure +#define MS_CLIST_FRAMES_HIDEALLFRAMESTB "CListFrames/HideALLFramesTB" + +////////////////////////////////////////////////////////////////////////// +//shows the frame if it is hidden, +//hides the frame if it is shown +//wParam=FrameId +//lParam=0 +//returns 0 on success, -1 on failure +#define MS_CLIST_FRAMES_SHFRAME "CListFrames/SHFrame" + +////////////////////////////////////////////////////////////////////////// +//shows the frame titlebar if it is hidden, +//hides the frame titlebar if it is shown +//wParam=FrameId +//lParam=0 +//returns 0 on success, -1 on failure +#define MS_CLIST_FRAMES_SHFRAMETITLEBAR "CListFrame/SHFrameTitleBar" + +////////////////////////////////////////////////////////////////////////// +//locks the frame if it is unlocked, +//unlock the frame if it is locked +//wParam=FrameId +//lParam=0 +//returns 0 on success, -1 on failure +#define MS_CLIST_FRAMES_ULFRAME "CListFrame/ULFrame" + +////////////////////////////////////////////////////////////////////////// +//collapses the frame if it is uncollapsed, +//uncollapses the frame if it is collapsed +//wParam=FrameId +//lParam=0 +//returns 0 on success, -1 on failure +#define MS_CLIST_FRAMES_UCOLLFRAME "CListFrame/UCOLLFrame" + +////////////////////////////////////////////////////////////////////////// +//trigger border flags +//wparam=frameid +//lparam=0 +#define MS_CLIST_FRAMES_SETUNBORDER "CListFrame/SetUnBorder" + +////////////////////////////////////////////////////////////////////////// +//redraws the frame +//wParam=FrameId, -1 for all frames +//lparam=FU_flags +//returns a pointer to option, -1 on failure +#define MS_CLIST_FRAMES_UPDATEFRAME "CListFrame/UpdateFrame" + +////////////////////////////////////////////////////////////////////////// +//gets the frame options +//(HIWORD)wParam=FrameId +//(LOWORD)wParam=FO_flag +//lParam=0 +//returns a pointer to option, -1 on failure +#define MS_CLIST_FRAMES_GETFRAMEOPTIONS "CListFrame/GetFrameOptions" + +//sets the frame options +//(HIWORLD)wParam=FrameId +//(LOWORD)wParam=FO_flag +//lParam=value +//returns 0 on success, -1 on failure +#define MS_CLIST_FRAMES_SETFRAMEOPTIONS "CListFrame/SetFrameOptions" + +////////////////////////////////////////////////////////////////////////// +//Frames related menu stuff +////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////// +//add a new item to the context frame menu +//wParam=0 +//lParam=(LPARAM)(CLISTMENUITEM*)&mi +//returns a handle to the new item +//popupposition=frameid +//contactowner=advanced parameter +#define MS_CLIST_ADDCONTEXTFRAMEMENUITEM "CList/AddContextFrameMenuItem" + +////////////////////////////////////////////////////////////////////////// +//remove a item from context frame menu +//wParam=hMenuItem returned by MS_CLIST_ADDCONTACTMENUITEM +//lParam=0 +//returns 0 on success, nonzero on failure +#define MS_CLIST_REMOVECONTEXTFRAMEMENUITEM "CList/RemoveContextFrameMenuItem" + +////////////////////////////////////////////////////////////////////////// +//builds the context menu for a frame +//wparam=frameid +//lParam=0 +//returns a HMENU on success, or NULL on failure +#define MS_CLIST_MENUBUILDFRAMECONTEXT "CList/BuildContextFrameMenu" + +////////////////////////////////////////////////////////////////////////// +// the frame menu is about to be built +// wparam=frameid +// lparam= +// -1 for build from titlebar, +// use +// MS_CLIST_ADDCONTEXTFRAMEMENUITEM +// MS_CLIST_REMOVECONTEXTFRAMEMENUITEM +// +// >0 for build in main menu, +// must be popupname=lparam to place your items in right popup of main menu. +// use +// MS_CLIST_ADDMAINMENUITEM +// MS_CLIST_REMOVEMAINMENUITEM +// +#define ME_CLIST_PREBUILDFRAMEMENU "CList/PreBuildFrameMenu" + +////////////////////////////////////////////////////////////////////////// +//needed by cluiframes module to add frames menu to main menu. +//it just calls NotifyEventHooks(hPreBuildFrameMenuEvent,wParam,lParam); +#define MS_CLIST_FRAMEMENUNOTIFY "CList/ContextFrameMenuNotify" diff --git a/plugins/MyDetails/sdk/m_ersatz.h b/plugins/MyDetails/sdk/m_ersatz.h new file mode 100644 index 0000000000..8136a8bd5d --- /dev/null +++ b/plugins/MyDetails/sdk/m_ersatz.h @@ -0,0 +1,40 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2006 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +#ifndef __M_ERSATZ_H__ +# define __M_ERSATZ_H__ + + +//Returns the current status message for yourself +//wParam=(WPARAM)0 +//lParam=(LPARAM)0 +//returns status msg or NULL if there is none. Remember to mir_free the return value +#define PS_GETMYAWAYMSG "/GetMyAwayMsg" + +//Created if ersatz is installed +//wParam=(WPARAM)0 +//lParam=(LPARAM)0 +//returns always 1 +#define MS_ERSATZ_ENABLED "ERSATZ/Enabled" + + +#endif // __M_ERSATZ_H__ diff --git a/plugins/MyDetails/sdk/m_listeningto.h b/plugins/MyDetails/sdk/m_listeningto.h new file mode 100644 index 0000000000..0dddde710a --- /dev/null +++ b/plugins/MyDetails/sdk/m_listeningto.h @@ -0,0 +1,56 @@ +/* +Copyright (C) 2006 Ricardo Pescuma Domenecci + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this file; see the file license.txt. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. +*/ + + +#ifndef __M_LISTENINGTO_H__ +# define __M_LISTENINGTO_H__ + +// To be used by other plugins to send listening info to miranda +#define MIRANDA_WINDOWCLASS _T("Miranda.ListeningTo") +#define MIRANDA_DW_PROTECTION 0x8754 + + +/* +Return TRUE if sending listening to is enabled for this protocol + +wParam: char * - protocol name or NULL for all protocols +lParam: ignored +*/ +#define MS_LISTENINGTO_ENABLED "ListeningTo/Enabled" + + +/* +Enable/disable sending listening to this protocol + +wParam: char * - protocol name or NULL for all protocols +lParam: BOOL - TRUE to enable, FALSE to disable +*/ +#define MS_LISTENINGTO_ENABLE "ListeningTo/Enable" + + +/* +Notification fired when enable state changed + +wParam: char * - protocol name or NULL for all protocols +lParam: BOOL - enabled +*/ +#define ME_LISTENINGTO_ENABLE_STATE_CHANGED "ListeningTo/EnableStateChanged" + + +#endif // __M_LISTENINGTO_H__ diff --git a/plugins/MyDetails/sdk/m_metacontacts.h b/plugins/MyDetails/sdk/m_metacontacts.h new file mode 100644 index 0000000000..1da12b97fa --- /dev/null +++ b/plugins/MyDetails/sdk/m_metacontacts.h @@ -0,0 +1,162 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright © 2004 Universite Louis PASTEUR, STRASBOURG. +Copyright © 2004 Scott Ellis (www.scottellis.com.au mail@scottellis.com.au) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#ifndef M_METACONTACTS_H__ +#define M_METACONTACTS_H__ 1 + +//get the handle for a contact's parent metacontact +//wParam=(HANDLE)hSubContact +//lParam=0 +//returns a handle to the parent metacontact, or null if this contact is not a subcontact +#define MS_MC_GETMETACONTACT "MetaContacts/GetMeta" + +//gets the handle for the default contact +//wParam=(HANDLE)hMetaContact +//lParam=0 +//returns a handle to the default contact, or null on failure +#define MS_MC_GETDEFAULTCONTACT "MetaContacts/GetDefault" + +//gets the contact number for the default contact +//wParam=(HANDLE)hMetaContact +//lParam=0 +//returns a DWORD contact number, or -1 on failure +#define MS_MC_GETDEFAULTCONTACTNUM "MetaContacts/GetDefaultNum" + +//gets the handle for the 'most online' contact +//wParam=(HANDLE)hMetaContact +//lParam=0 +//returns a handle to the 'most online' contact +#define MS_MC_GETMOSTONLINECONTACT "MetaContacts/GetMostOnline" + +//gets the number of subcontacts for a metacontact +//wParam=(HANDLE)hMetaContact +//lParam=0 +//returns a DWORD representing the number of subcontacts for the given metacontact +#define MS_MC_GETNUMCONTACTS "MetaContacts/GetNumContacts" + +//gets the handle of a subcontact, using the subcontact's number +//wParam=(HANDLE)hMetaContact +//lParam=(DWORD)contact number +//returns a handle to the specified subcontact +#define MS_MC_GETSUBCONTACT "MetaContacts/GetSubContact" + +//sets the default contact, using the subcontact's contact number +//wParam=(HANDLE)hMetaContact +//lParam=(DWORD)contact number +//returns 0 on success +#define MS_MC_SETDEFAULTCONTACTNUM "MetaContacts/SetDefault" + +//sets the default contact, using the subcontact's handle +//wParam=(HANDLE)hMetaContact +//lParam=(HANDLE)hSubcontact +//returns 0 on success +#define MS_MC_SETDEFAULTCONTACT "MetaContacts/SetDefaultByHandle" + +//forces the metacontact to send using a specific subcontact, using the subcontact's contact number +//wParam=(HANDLE)hMetaContact +//lParam=(DWORD)contact number +//returns 0 on success +#define MS_MC_FORCESENDCONTACTNUM "MetaContacts/ForceSendContact" + +//forces the metacontact to send using a specific subcontact, using the subcontact's handle +//wParam=(HANDLE)hMetaContact +//lParam=(HANDLE)hSubcontact +//returns 0 on success (will fail if 'force default' is in effect) +#define MS_MC_FORCESENDCONTACT "MetaContacts/ForceSendContactByHandle" + +//'unforces' the metacontact to send using a specific subcontact +//wParam=(HANDLE)hMetaContact +//lParam=0 +//returns 0 on success (will fail if 'force default' is in effect) +#define MS_MC_UNFORCESENDCONTACT "MetaContacts/UnforceSendContact" + +//'forces' or 'unforces' (i.e. toggles) the metacontact to send using it's default contact +// overrides (and clears) 'force send' above, and will even force use of offline contacts +// will send ME_MC_FORCESEND or ME_MC_UNFORCESEND event +//wParam=(HANDLE)hMetaContact +//lParam=0 +//returns 1(true) or 0(false) representing new state of 'force default' +#define MS_MC_FORCEDEFAULT "MetaContacts/ForceSendDefault" + +// method to get state of 'force' for a metacontact +// wParam=(HANDLE)hMetaContact +// lParam= (DWORD)&contact_number or NULL +// +// if lparam supplied, the contact_number of the contatct 'in force' will be copied to the address it points to, +// or if none is in force, the value (DWORD)-1 will be copied +// (v0.8.0.8+ returns 1 if 'force default' is true with *lParam == default contact number, else returns 0 with *lParam as above) +#define MS_MC_GETFORCESTATE "MetaContacts/GetForceState" + +// fired when a metacontact's default contact changes (fired upon creation of metacontact also, when default is initially set) +// wParam=(HANDLE)hMetaContact +// lParam=(HANDLE)hDefaultContact +#define ME_MC_DEFAULTTCHANGED "MetaContacts/DefaultChanged" + +// fired when a metacontact's subcontacts change (fired upon creation of metacontact, when contacts are added or removed, and when +// contacts are reordered) - a signal to re-read metacontact data +// wParam=(HANDLE)hMetaContact +// lParam=0 +#define ME_MC_SUBCONTACTSCHANGED "MetaContacts/SubcontactsChanged" + +// fired when a metacontact is forced to send using a specific subcontact +// wParam=(HANDLE)hMetaContact +// lParam=(HANDLE)hForceContact +#define ME_MC_FORCESEND "MetaContacts/ForceSend" + +// fired when a metacontact is 'unforced' to send using a specific subcontact +// wParam=(HANDLE)hMetaContact +// lParam=0 +#define ME_MC_UNFORCESEND "MetaContacts/UnforceSend" + +// method to get protocol name - used to be sure you're dealing with a "real" metacontacts plugin :) +// wParam=lParam=0 +#define MS_MC_GETPROTOCOLNAME "MetaContacts/GetProtoName" + + +// added 0.9.5.0 (22/3/05) +// wParam=(HANDLE)hContact +// lParam=0 +// convert a given contact into a metacontact +#define MS_MC_CONVERTTOMETA "MetaContacts/ConvertToMetacontact" + +// added 0.9.5.0 (22/3/05) +// wParam=(HANDLE)hContact +// lParam=(HANDLE)hMeta +// add an existing contact to a metacontact +#define MS_MC_ADDTOMETA "MetaContacts/AddToMetacontact" + +// added 0.9.5.0 (22/3/05) +// wParam=0 +// lParam=(HANDLE)hContact +// remove a contact from a metacontact +#define MS_MC_REMOVEFROMMETA "MetaContacts/RemoveFromMetacontact" + + +// added 0.9.13.2 (6/10/05) +// wParam=(BOOL)disable +// lParam=0 +// enable/disable the 'hidden group hack' - for clists that support subcontact hiding using 'IsSubcontact' setting +// should be called once in the clist 'onmodulesloaded' event handler (which, since it's loaded after the db, will be called +// before the metacontact onmodulesloaded handler where the subcontact hiding is usually done) +#define MS_MC_DISABLEHIDDENGROUP "MetaContacts/DisableHiddenGroup" + +#endif diff --git a/plugins/MyDetails/sdk/m_proto_listeningto.h b/plugins/MyDetails/sdk/m_proto_listeningto.h new file mode 100644 index 0000000000..b3e5f9dcd3 --- /dev/null +++ b/plugins/MyDetails/sdk/m_proto_listeningto.h @@ -0,0 +1,137 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2006 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +//this module was created in v0.6.0.0 + +#ifndef M_PROTO_LISTENINGTO_H__ +#define M_PROTO_LISTENINGTO_H__ 1 + + +// Protocol Services ///////////////////////////////////////////////////////////////// + +// This is the services a protocol have to support to support listening info + +typedef struct { + int cbSize; + + union { + char* pszType; // Media type: Music, Video, etc... + TCHAR* ptszType; + }; + union { + char* pszArtist; // Artist name + TCHAR* ptszArtist; + }; + union { + char* pszAlbum; // Algum name + TCHAR* ptszAlbum; + }; + union { + char* pszTitle; // Song name + TCHAR* ptszTitle; + }; + union { + char* pszTrack; // Track number + TCHAR* ptszTrack; + }; + union { + char* pszYear; // Song year + TCHAR* ptszYear; + }; + union { + char* pszGenre; // Song genre + TCHAR* ptszGenre; + }; + union { + char* pszLength; // Song length + TCHAR* ptszLength; + }; + union { + char* pszPlayer; // Player name + TCHAR* ptszPlayer; + }; + + DWORD dwFlags; + +} LISTENINGTOINFO; + +#define LTI_UNICODE 1 + +#ifdef UNICODE + #define LTI_TCHAR LTI_UNICODE +#else + #define LTI_TCHAR 0 +#endif + +// Set the listening info for the protocol. +// Pass NULL to remove it. +// wParam = NULL +// lParam = LISTENINGTOINFO * +#define PS_SET_LISTENINGTO "/SetListeningTo" + +// Get the listening info for the protocol +// wParam = NULL +// lParam = LISTENINGTOINFO * +// The strings inside the struct need to be free using miranda free. +#define PS_GET_LISTENINGTO "/GetListeningTo" + +// Also the protocol have to save a string with the text the other user is (probabily) +// seeing under the main db key: /ListeningTo + +// For a contact, the protocol should store the listening info as an string inside +// the contact db key: /ListeningTo + + +// ListeningTo configuration plugin ////////////////////////////////////////////////// + +// One plugin can be used to set some options relative to the listening to information. +// But protocols should not assume this plugin exists. If it does not exist, protocols +// have to decide what default to use. +// This plugin have to support the following services: + +// Get the text format the user wants him / his contacts to see. Some strings represents +// the text information: +// %artist%, %album%, %title%, %track%, %year%, %genre%, %length%, %player%, %type% +// This service is optional +// wParam = TCHAR* - default text for this protocol +// lParam = 0 +// Returns a TCHAR* containg the user setting. This need to be free using miranda free. +#define MS_LISTENINGTO_GETTEXTFORMAT "ListeningTo/GetTextFormat" + +// Get the text the user wants him / his contacts to see, parsed with the info sent to +// this service. Uses the same variables as the above service to the default text. +// wParam = TCHAR* - default text for this protocol +// lParam = LISTENINGTOINFO * +// Returns a TCHAR* containg the parsed text. This need to be free using miranda free. +#define MS_LISTENINGTO_GETPARSEDTEXT "ListeningTo/GetParsedText" + +// Get if the contact options about how to show the music info should be overriten or +// not. +// wParam = NULL +// lParam = hContact +// Returns a BOOL +#define MS_LISTENINGTO_OVERRIDECONTACTOPTION "ListeningTo/OverrideContactOption" + + +#endif // M_PROTO_LISTENINGTO_H__ + diff --git a/plugins/MyDetails/sdk/m_smileyadd.h b/plugins/MyDetails/sdk/m_smileyadd.h new file mode 100644 index 0000000000..c950202f0d --- /dev/null +++ b/plugins/MyDetails/sdk/m_smileyadd.h @@ -0,0 +1,172 @@ +/* +Miranda SmileyAdd Plugin +Plugin support header file +Copyright (C) 2004-2006 borkra, portions by Rein-Peter de Boer + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + + +#define SAFLRE_INSERTEMF 2 // insert smiley as EMF into RichEdit, otherwise bitmap inserted + // this flag allows "true" transparency + +typedef struct +{ + int cbSize; //size of the structure + HWND hwndRichEditControl; //handle to the rich edit control + CHARRANGE* rangeToReplace; //same meaning as for normal Richedit use (NULL = replaceall) + const char* Protocolname; //protocol to use... if you have defined a protocol, u can + //use your own protocol name. SmileyAdd will automatically + //select the smileypack that is defined for your protocol. + //Or, use "Standard" for standard smiley set. Or "ICQ", "MSN" + //if you prefer those icons. + //If not found or NULL, "Standard" will be used + unsigned flags; //Flags (SAFLRE_*) that define the behaivior + BOOL disableRedraw; //Parameter have been depricated, have no effect on operation + HANDLE hContact; //Contact handle +} SMADD_RICHEDIT3; + +//Replace smileys in a rich edit control... +//wParam = (WPARAM) 0; not used +//lParam = (LPARAM) (SMADD_RICHEDIT3*) &smre; //pointer to SMADD_RICHEDIT3 +//return: TRUE if API succeeded (all parameters were valid) , FALSE if not. +#define MS_SMILEYADD_REPLACESMILEYS "SmileyAdd/ReplaceSmileys" + + +typedef struct +{ + int cbSize; //size of the structure + char* Protocolname; //protocol to use... if you have defined a protocol, you can + //use your own protocol name. Smiley add will automatically + //select the smileypack that is defined for your protocol. + //Or, use "Standard" for standard smiley set. Or "ICQ", "MSN" + //if you prefer those icons. + //If not found or NULL: "Standard" will be used + int xPosition; //Postition to place the selectwindow + int yPosition; // " + int Direction; //Direction (i.e. size upwards/downwards/etc) of the window 0, 1, 2, 3 + + HWND hwndTarget; //Window, where to send the message when smiley is selected. + UINT targetMessage; //Target message, to be sent. + LPARAM targetWParam; //Target WParam to be sent (LParam will be char* to select smiley) + //see the example file. + HWND hwndParent; //Parent window for smiley dialog + HANDLE hContact; //Contact handle +} SMADD_SHOWSEL3; + +//Show smiley selection window +//wParam = (WPARAM) 0; not used +//lParam = (LPARAM) (SMADD_SHOWSEL3*) &smre; //pointer to SMADD_SHOWSEL3 +//return: TRUE if API succeeded (all parameters were valid) , FALSE if not. +#define MS_SMILEYADD_SHOWSELECTION "SmileyAdd/ShowSmileySelection" + + +typedef struct +{ + int cbSize; //size of the structure + char* Protocolname; // " " + HICON ButtonIcon; //RETURN VALUE: this is filled with the icon handle + //of the smiley that can be used on the button + //if used with GETINFO2 handle must be destroyed by user! + //NULL if the buttonicon is not defined... + int NumberOfVisibleSmileys; //Number of visible smileys defined. + int NumberOfSmileys; //Number of total smileys defined + HANDLE hContact; //Contact handle +} SMADD_INFO2; + +//get button smiley icon +//wParam = (WPARAM) 0; not used +//lParam = (LPARAM) (SMADD_INFO2*) &smgi; //pointer to SMADD_INFO2 +//return: TRUE if API succeeded (all parameters were valid) , FALSE if not. +#define MS_SMILEYADD_GETINFO2 "SmileyAdd/GetInfo2" + +// Event notifies that SmileyAdd options have changed +// Message dialogs usually need to redraw it's content on reception of this event +//wParam = Contact handle which options have changed, NULL if global options changed +//lParam = (LPARAM) 0; not used +#define ME_SMILEYADD_OPTIONSCHANGED "SmileyAdd/OptionsChanged" + +#define SAFL_PATH 1 // provide smiley file path, icon otherwise +#define SAFL_UNICODE 2 // string fields in OPTIONSDIALOGPAGE are WCHAR* + +#if defined _UNICODE || defined UNICODE + #define SAFL_TCHAR SAFL_UNICODE +#else + #define SAFL_TCHAR 0 +#endif + +typedef struct +{ + int cbSize; //size of the structure + const char* Protocolname; //protocol to use... if you have defined a protocol, u can + //use your own protocol name. Smiley add wil automatically + //select the smileypack that is defined for your protocol. + //Or, use "Standard" for standard smiley set. Or "ICQ", "MSN" + //if you prefer those icons. + //If not found or NULL: "Standard" will be used + union { + TCHAR* str; //String to parse + char* astr; + wchar_t* wstr; + }; + unsigned flag; //One of the SAFL_ flags specifies parsing requirements + //This parameter should be filled by the user + + unsigned numSmileys; //Number of Smileys found, this parameter filled by SmileyAdd + unsigned oflag; //One of the SAFL_ flags specifies content of the parse results + //this parameter filled by SmileyAdd + HANDLE hContact; //Contact handle +} SMADD_BATCHPARSE2; + +typedef struct +{ + unsigned startChar; //Starting smiley character + //Because of iterative nature of the API caller should set this + //parameter to correct value + unsigned size; //Number of characters in smiley (0 if not found) + //Because of iterative nature of the API caller should set this + //parameter to correct value + union { + const TCHAR* filepath; + const char* afilepath; + const wchar_t* wfilepath; + HICON hIcon; //User responsible for destroying icon handle + }; +} SMADD_BATCHPARSERES; + +//find all smileys in text, API parses the provided text and returns all smileys found +//wParam = (WPARAM) 0; not used +//lParam = (LPARAM) (SMADD_BATCHPARSE2*) &smgp; //pointer to SMADD_BATCHPARSE2 +//function returns pointer to array SMADD_BATCHPARSERES records for each smiley found +//if no smileys found NULL is returned +//if non NULL value returned pointer must be freed with MS_SMILEYADD_BATCHFREE API +#define MS_SMILEYADD_BATCHPARSE "SmileyAdd/BatchParse" + +//Free memory allocated by MS_SMILEYADD_BATCHPARSE +//wParam = (WPARAM) 0; not used +//lParam = (LPARAM) (SMADD_BATCHPARSERES*) &smgp; //pointer to SMADD_BATCHPARSERES +#define MS_SMILEYADD_BATCHFREE "SmileyAdd/BatchFree" + +typedef struct +{ + int cbSize; //size of the structure + char* name; //smiley category name for reference + char* dispname; //smiley category name for display +} SMADD_REGCAT; + +//Register smiley category +//wParam = (WPARAM) 0; not used +//lParam = (LPARAM) (SMADD_REGCAT*) &smgp; //pointer to SMADD_REGCAT +#define MS_SMILEYADD_REGISTERCATEGORY "SmileyAdd/RegisterCategory" diff --git a/plugins/MyDetails/sdk/m_statusplugins.h b/plugins/MyDetails/sdk/m_statusplugins.h new file mode 100644 index 0000000000..6a70f297ec --- /dev/null +++ b/plugins/MyDetails/sdk/m_statusplugins.h @@ -0,0 +1,156 @@ +/* + AdvancedAutoAway Plugin for Miranda-IM (www.miranda-im.org) + KeepStatus Plugin for Miranda-IM (www.miranda-im.org) + StartupStatus Plugin for Miranda-IM (www.miranda-im.org) + Copyright 2003-2006 P. Boon + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +#ifndef __M_STATUSPLUGINS +#define __M_STATUSPLUGINS + +// -- common status -- (all three plugins) +typedef struct { + int cbSize; + char *szName; // pointer to protocol modulename + char *szMsg; // pointer to the status message (may be NULL) + WORD status; // the status + WORD lastStatus;// last status +} PROTOCOLSETTINGEX; + +// wParam = PROTOCOLSETTINGEX*** (keep it like this for compatibility) +// lParam = 0 +// returns 0 on success +#define MS_CS_SETSTATUSEX "CommonStatus/SetStatusEx" + +// wParam = PROTOCOLSETTINGEX*** (keep it like this for compatibility) +// lParam = timeout +// returns hwnd +#define MS_CS_SHOWCONFIRMDLGEX "CommonStatus/ShowConfirmDialogEx" + +// wParam = 0 +// lParam = 0 +// returns the number of protocols registerd +#define MS_CS_GETPROTOCOUNT "CommonStatus/GetProtocolCount" // added dec '04 + +// wParam = PROTOCOLSETTINGEX*** (keep it like this for compatibility) +// lParam = 0 +#define ME_CS_STATUSCHANGEEX "CommonStatus/StatusChangeEx" + +// wParam = protoCount +// lParam = 0 +#define ME_CS_CSMODULELOADED "CommonStatus/CommonStatusLoaded" + +// -- startup status -- +// wParam = profile number (set to -1 to get default profile) +// lParam = PROTOCOLSETTINGEX*** (keep for... )(memory must be allocated protoCount*PROTOCOLSETTINGEX* and protoCount*PROTOCOLSETTINGEX) +// szMsg member does not have to be freed +// returns 0 on success +#define MS_SS_GETPROFILE "StartupStatus/GetProfile" // don't use this > jan '05, internal use only + +// wParam = profile number +// lParam = 0 +// return 0 on success +#define MS_SS_LOADANDSETPROFILE "StartupStatus/LoadAndSetProfile" // you can use this + +// wParam = int*, maybe NULL sets this int to the default profile number +// lParam = 0 +// returns profile count +#define MS_SS_GETPROFILECOUNT "StartupStatus/GetProfileCount" + +// wParam = profile number +// lParam = char* (must be allocated, size = 128) +// returns 0 on success +#define MS_SS_GETPROFILENAME "StartupStatus/GetProfileName" + +// -- AdvancedAutoAway -- +typedef enum { + ACTIVE, // user is active + STATUS1_SET, // first status change happened + STATUS2_SET, // second status change happened + SET_ORGSTATUS, // user was active again, original status will be restored + STATUS1_SET2, // first status change happened, but user may be active ('on inactive only was disabled') + STATUS2_SET2 // second status change happened, but user may be active ('on inactive only was disabled') +} STATES; + +typedef struct { + PROTOCOLSETTINGEX* protocolSetting; + int originalStatusMode; // this is set only when going from ACTIVE to STATUS1_SET (or to STATUS2_SET) + // (note: this is therefore not always valid) + STATES + oldState, // state before the call + curState; // current state + BOOL statusChanged; // the status of the protocol will actually be changed + // (note: unlike the name suggests, the status is changed AFTER this hook is called) +} AUTOAWAYSETTING; +// wParam = 0; +// lParam = AUTOAWAYSETTING* +// Called when a protocol's state in AAA is changed this does NOT necessary means the status was changed +// note: this hook is called for each protocol seperately +#define ME_AAA_STATECHANGED "AdvancedAutoAway/StateChanged" + +// -- KeepStatus -- +#define KS_CONN_STATE_LOST 1 // lParam = protocol +#define KS_CONN_STATE_OTHERLOCATION 2 // lParam = protocol +#define KS_CONN_STATE_RETRY 3 // lParam = nth retry +#define KS_CONN_STATE_STOPPEDCHECKING 4 // lParam = TRUE if success, FALSE if failed +#define KS_CONN_STATE_LOGINERROR 5 // lParam = protocol, only if selected in options +#define KS_CONN_STATE_RETRYNOCONN 6 // lParam = nth try, a connection attempt will not be made +// wParam = one of above +// lParam depends on wParam +#define ME_KS_CONNECTIONEVENT "KeepStatus/ConnectionEvent" + +// wParam = 0 +// lParam = 0 +// returns 0 on succes, nonzero on failure, probably keepstatus wasn't reconnecting +#define MS_KS_STOPRECONNECTING "KeepStatus/StopReconnecting" + +// wParam = TRUE to enable checking a protocol, FALSE to disable checking a protocol +// lParam = protocol +// return 0 on success, nonzero on failure, probably the protocol is 'hard' disabled or not found +// note: you cannot enable a protocol that is disabled in the options screen, you can disable a protocol +// if it's enabled in the option screen. +#define MS_KS_ENABLEPROTOCOL "KeepStatus/EnableProtocol" + +// wParam = 0 +// lParam = protocol +// returns TRUE if protocol is enabled for checked, FALSE otherwise +#define MS_KS_ISPROTOCOLENABLED "KeepStatus/IsProtocolEnabled" + +// Indicate the status will be changed which will not be regarded as a connection failure. +// wParam = 0 +// lParam = PROTOCOLSETTINGEX* of the new situation +// returns 0 +#define MS_KS_ANNOUNCESTATUSCHANGE "KeepStatus/AnnounceStatusChange" + +__inline static int announce_status_change(char *szProto, int newstatus, char *szMsg) { + + PROTOCOLSETTINGEX ps; + + ZeroMemory(&ps, sizeof(PROTOCOLSETTINGEX)); + ps.cbSize = sizeof(PROTOCOLSETTINGEX); + if (szProto != NULL) { + ps.lastStatus = CallProtoService(szProto, PS_GETSTATUS, 0, 0); + } else { + ps.lastStatus = CallService(MS_CLIST_GETSTATUSMODE, 0, 0); + } + ps.status = newstatus; + ps.szMsg = szMsg; + ps.szName = szProto; + + return CallService(MS_KS_ANNOUNCESTATUSCHANGE, 0, (LPARAM)&ps); +} + +#endif // __M_STATUSPLUGINS diff --git a/plugins/MyDetails/sdk/m_updater.h b/plugins/MyDetails/sdk/m_updater.h new file mode 100644 index 0000000000..371b7437a0 --- /dev/null +++ b/plugins/MyDetails/sdk/m_updater.h @@ -0,0 +1,146 @@ +#ifndef _M_UPDATER_H +#define _M_UPDATER_H + +// NOTES: +// - For langpack updates, include a string of the following format in the langpack text file: +// ";FLID: " +// version must be four numbers seperated by '.', in the range 0-255 inclusive +// - Updater will disable plugins that are downloaded but were not active prior to the update (this is so that, if an archive contains e.g. ansi and +// unicode versions, the correct plugin will be the only one active after the new version is installed)...so if you add a support plugin, you may need +// to install an ini file to make the plugin activate when miranda restarts after the update +// - Updater will replace all dlls that have the same internal shortName as a downloaded update dll (this is so that msn1.dll and msn2.dll, for example, +// will both be updated) - so if you have a unicode and a non-unicode version of a plugin in your archive, you should make the internal names different (which will break automatic +// updates from the file listing if there is only one file listing entry for both versions, unless you use the 'MS_UPDATE_REGISTER' service below) +// - Updater will install all files in the root of the archive into the plugins folder, except for langpack files that contain the FLID string which go into the root folder (same +// folder as miranda32.exe)...all folders in the archive will also be copied to miranda's root folder, and their contents transferred into the new folders. The only exception is a +// special folder called 'root_files' - if there is a folder by that name in the archive, it's contents will also be copied into miranda's root folder - this is intended to be used +// to install additional dlls etc that a plugin may require) + +// if you set Update.szUpdateURL to the following value when registering, as well as setting your beta site and version data, +// Updater will ignore szVersionURL and pbVersionPrefix, and attempt to find the file listing URL's from the backend XML data. +// for this to work, the plugin name in pluginInfo.shortName must match the file listing exactly (except for case) +#define UPDATER_AUTOREGISTER "UpdaterAUTOREGISTER" +// Updater will also use the backend xml data if you provide URL's that reference the miranda file listing for updates (so you can use that method +// if e.g. your plugin shortName does not match the file listing) - it will grab the file listing id from the end of these URLs + +typedef struct Update_tag { + int cbSize; + char *szComponentName; // component name as it will appear in the UI (will be translated before displaying) + + char *szVersionURL; // URL where the current version can be found (NULL to disable) + BYTE *pbVersionPrefix; // bytes occuring in VersionURL before the version, used to locate the version information within the URL data + // (note that this URL could point at a binary file - dunno why, but it could :) + int cpbVersionPrefix; // number of bytes pointed to by pbVersionPrefix + char *szUpdateURL; // URL where dll/zip is located + // set to UPDATER_AUTOREGISTER if you want Updater to find the file listing URLs (ensure plugin shortName matches file listing!) + + char *szBetaVersionURL; // URL where the beta version can be found (NULL to disable betas) + BYTE *pbBetaVersionPrefix; // bytes occuring in VersionURL before the version, used to locate the version information within the URL data + int cpbBetaVersionPrefix; // number of bytes pointed to by pbVersionPrefix + char *szBetaUpdateURL; // URL where dll/zip is located + + BYTE *pbVersion; // bytes of current version, used for comparison with those in VersionURL + int cpbVersion; // number of bytes pointed to by pbVersion + + char *szBetaChangelogURL; // url for displaying changelog for beta versions +} Update; + +// register a comonent with Updater +// +// wparam = 0 +// lparam = (LPARAM)&Update +#define MS_UPDATE_REGISTER "Update/Register" + +// utility functions to create a version string from a DWORD or from pluginInfo +// point buf at a buffer at least 16 chars wide - but note the version string returned may be shorter +// +__inline static char *CreateVersionString(DWORD version, char *buf) { + mir_snprintf(buf, 16, "%d.%d.%d.%d", (version >> 24) & 0xFF, (version >> 16) & 0xFF, (version >> 8) & 0xFF, version & 0xFF); + return buf; +} + +__inline static char *CreateVersionStringPlugin(PLUGININFO *pluginInfo, char *buf) { + return CreateVersionString(pluginInfo->version, buf); +} + + +// register the 'easy' way - use this method if you have no beta URL and the plugin is on the miranda file listing +// NOTE: the plugin version string on the file listing must be the string version of the version in pluginInfo (i.e. 0.0.0.1, +// four numbers between 0 and 255 inclusivem, so no letters, brackets, etc.) +// +// wParam = (int)fileID - this is the file ID from the file listing (i.e. the number at the end of the download link) +// lParam = (PLUGININFO*)&pluginInfo +#define MS_UPDATE_REGISTERFL "Update/RegisterFL" + +// this function can be used to 'unregister' components - useful for plugins that register non-plugin/langpack components and +// may need to change those components on the fly +// lParam = (char *)szComponentName +#define MS_UPDATE_UNREGISTER "Update/Unregister" + +// this event is fired when the startup process is complete, but NOT if a restart is imminent +// it is designed for status managment plugins to use as a trigger for beggining their own startup process +// wParam = lParam = 0 (unused) +// (added in version 0.1.6.0) +#define ME_UPDATE_STARTUPDONE "Update/StartupDone" + +// this service can be used to enable/disable Updater's global status control +// it can be called from the StartupDone event handler +// wParam = (BOOL)enable +// lParam = 0 +// (added in version 0.1.6.0) +#define MS_UPDATE_ENABLESTATUSCONTROL "Update/EnableStatusControl" + +// An description of usage of the above service and event: +// Say you are a status control plugin that normally sets protocol or global statuses in your ModulesLoaded event handler. +// In order to make yourself 'Updater compatible', you would move the status control code from ModulesLoaded to another function, +// say DoStartup. Then, in ModulesLoaded you would check for the existence of the MS_UPDATE_ENABLESTATUSCONTROL service. +// If it does not exist, call DoStartup. If it does exist, hook the ME_UPDATE_STARTUPDONE event and call DoStartup from there. You may +// also wish to call MS_UPDATE_ENABLESTATUSCONTROL with wParam == FALSE at this time, to disable Updater's own status control feature. + +// this service can be used to determine whether updates are possible for a component with the given name +// wParam = 0 +// lParam = (char *)szComponentName +// returns TRUE if updates are supported, FALSE otherwise +#define MS_UPDATE_ISUPDATESUPPORTED "Update/IsUpdateSupported" + +#endif + + +/////////////// Usage Example /////////////// + +#ifdef EXAMPLE_CODE + +// you need to #include "m_updater.h" and HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded) in your Load function... + +int OnModulesLoaded(WPARAM wParam, LPARAM lParam) { + + Update update = {0}; // for c you'd use memset or ZeroMemory... + char szVersion[16]; + + update.cbSize = sizeof(Update); + + update.szComponentName = pluginInfo.shortName; + update.pbVersion = (BYTE *)CreateVersionString(&pluginInfo, szVersion); + update.cpbVersion = strlen((char *)update.pbVersion); + + // these are the three lines that matter - the archive, the page containing the version string, and the text (or data) + // before the version that we use to locate it on the page + // (note that if the update URL and the version URL point to standard file listing entries, the backend xml + // data will be used to check for updates rather than the actual web page - this is not true for beta urls) + update.szUpdateURL = "http://scottellis.com.au:81/test/updater.zip"; + update.szVersionURL = "http://scottellis.com.au:81/test/updater_test.html"; + update.pbVersionPrefix = (BYTE *)"Updater version "; + + update.cpbVersionPrefix = strlen((char *)update.pbVersionPrefix); + + // do the same for the beta versions of the above struct members if you wish to allow beta updates from another URL + + CallService(MS_UPDATE_REGISTER, 0, (WPARAM)&update); + + // Alternatively, to register a plugin with e.g. file ID 2254 on the file listing... + // CallService(MS_UPDATE_REGISTERFL, (WPARAM)2254, (LPARAM)&pluginInfo); + + return 0; +} + +#endif diff --git a/plugins/MyDetails/sdk/m_variables.h b/plugins/MyDetails/sdk/m_variables.h new file mode 100644 index 0000000000..152994dbbc --- /dev/null +++ b/plugins/MyDetails/sdk/m_variables.h @@ -0,0 +1,668 @@ +/* + Variables Plugin for Miranda-IM (www.miranda-im.org) + Copyright 2003-2006 P. Boon + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef __M_VARS +#define __M_VARS + +#if !defined(_TCHAR_DEFINED) +#include +#endif + +#ifndef VARIABLES_NOHELPER +#include +#endif + +// -------------------------------------------------------------------------- +// Memory management +// -------------------------------------------------------------------------- + +// Release memory that was allocated by the Variables plugin, e.g. returned +// strings. + +#define MS_VARS_FREEMEMORY "Vars/FreeMemory" + +// Parameters: +// ------------------------ +// wParam = (WPARAM)(void *)pntr +// Pointer to memory that was allocated by the Variables plugin (e.g. a +// returned string) (can be NULL). +// lParam = 0 + +// Return Value: +// ------------------------ +// Does return 0 on success, nozero otherwise. + +// Note: Do only use this service to free memory that was *explicitliy* +// stated that it should be free with this service. + + + +#define MS_VARS_GET_MMI "Vars/GetMMI" + +// Get Variable's RTL/CRT function poiners to malloc(), free() and +// realloc(). + +// Parameters: +// ------------------------ +// wParam = 0 +// lParam = (LPARAM) &MM_INTERFACE +// Pointer to a memory manager interface struct (see m_system.h). + +// Return Value: +// ------------------------ +// Returns 0 on success, nozero otherwise + +// Note: Works exactly the same as the MS_SYSTEM_GET_MMI service +// service of m_system.h. + +// Helper function for easy using: +#ifndef VARIABLES_NOHELPER +__inline static void variables_free(void *pntr) { + + CallService(MS_VARS_FREEMEMORY, (WPARAM)pntr, 0); +} +#endif + + + +// -------------------------------------------------------------------------- +// String formatting +// -------------------------------------------------------------------------- + +#define MS_VARS_FORMATSTRING "Vars/FormatString" + +// This service can be used to parse tokens in a text. The tokens will be +// replaced by their resolved values. A token can either be a field or a +// function. A field takes no arguments and is represented between +// %-characters, e.g. "%winampsong%". A function can take any number of +// arguments and is represented by a ? or !-character followed by the name +// of the function and a list of arguments, e.g. "?add(1,2)". + +// Parameters: +// ------------------------ +// wParam = (WPARAM)(FORMATINFO *)&fi +// See below. +// lParam = 0 + +// Return Value: +// ------------------------ +// Returns a pointer to the resolved string or NULL in case of an error. + +// Note: The returned pointer needs to be freed using MS_VARS_FREEMEMORY. + +typedef struct { + int cbSize; // Set this to sizeof(FORMATINFO). + int flags; // Flags to use (see FIF_* below). + union { + char *szFormat; // Text in which the tokens will be replaced (can't be + // NULL). + WCHAR *wszFormat; + TCHAR *tszFormat; + }; + union { + char *szExtraText; // Extra, context-specific string (can be NULL) -> + // The field "extratext" will be replaced by this + // string. (Previously szSource). + WCHAR *wszExtraText; + TCHAR *tszExtraText; + }; + HANDLE hContact; // Handle to contact (can be NULL) -> The field "subject" + // represents this contact. + int pCount; // (output) Number of succesful parsed tokens, needs to be set + // to 0 before the call + int eCount; // (output) Number of failed tokens, needs to be set to 0 + // before the call +} FORMATINFO; + +// Possible flags: +#define FIF_UNICODE 0x01 // Expects and returns unicode text (WCHAR*). + +#if defined(UNICODE) || defined(_UNICODE) +#define FIF_TCHAR FIF_UNICODE // Strings in structure are TCHAR*. +#else +#define FIF_TCHAR 0 +#endif + +// Helper functions for easy using: + +// Helper #1: variables_parse +// ------------------------ +// The returned string needs to be freed using MS_VARS_FREEMEMORY. + +#ifndef VARIABLES_NOHELPER +__inline static TCHAR *variables_parse(TCHAR *tszFormat, TCHAR *tszExtraText, HANDLE hContact) { + + FORMATINFO fi; + + ZeroMemory(&fi, sizeof(fi)); + fi.cbSize = sizeof(fi); + fi.tszFormat = tszFormat; + fi.tszExtraText = tszExtraText; + fi.hContact = hContact; + fi.flags = FIF_TCHAR; + + return (TCHAR *)CallService(MS_VARS_FORMATSTRING, (WPARAM)&fi, 0); +} +#endif + +// Helper #2: variables_parsedup +// ------------------------ +// Returns a _strdup()'ed copy of the unparsed string when Variables is not +// installed, returns a strdup()'ed copy of the parsed result otherwise. + +// Note: The returned pointer needs to be released using your own free(). + +#ifndef VARIABLES_NOHELPER +__inline static TCHAR *variables_parsedup(TCHAR *tszFormat, TCHAR *tszExtraText, HANDLE hContact) { + + if (ServiceExists(MS_VARS_FORMATSTRING)) { + FORMATINFO fi; + TCHAR *tszParsed, *tszResult; + + ZeroMemory(&fi, sizeof(fi)); + fi.cbSize = sizeof(fi); + fi.tszFormat = tszFormat; + fi.tszExtraText = tszExtraText; + fi.hContact = hContact; + fi.flags |= FIF_TCHAR; + tszParsed = (TCHAR *)CallService(MS_VARS_FORMATSTRING, (WPARAM)&fi, 0); + if (tszParsed) { + tszResult = _tcsdup(tszParsed); + CallService(MS_VARS_FREEMEMORY, (WPARAM)tszParsed, 0); + return tszResult; + } + } + return tszFormat?_tcsdup(tszFormat):tszFormat; +} +#endif + + + +// -------------------------------------------------------------------------- +// Register tokens +// -------------------------------------------------------------------------- + +// Plugins can define tokens which will be parsed by the Variables plugin. + +#define MS_VARS_REGISTERTOKEN "Vars/RegisterToken" + +// With this service you can define your own token. The newly added tokens +// using this service are taken into account on every call to +// MS_VARS_FORMATSTRING. + +// Parameters: +// ------------------------ +// wParam = 0 +// lParam = (LPARAM)(TOKENREGISTER*)&tr +// See below. + +// Return Value: +// ------------------------ +// Returns 0 on success, nonzero otherwise. Existing tokens will be +// 'overwritten' if registered twice. + +// Needed for szService and parseFunction: +typedef struct { + int cbSize; // You need to check if this is >=sizeof(ARGUMENTSINFO) + // (already filled in). + FORMATINFO *fi; // Arguments passed to MS_VARS_FORMATSTRING. + unsigned int argc; // Number of elements in the argv array. + union { + char **argv; // Argv[0] will be the token name, the following elements + // are the additional arguments. + WCHAR **wargv; // If the registered token was registered as a unicode + // token, wargv should be accessed. + TCHAR **targv; + }; + int flags; // (output) You can set flags here (initially 0), use the + // AIF_* flags (see below). +} ARGUMENTSINFO; + +// Available flags for ARGUMENTSINFO: +// Set the flags of the ARGUMENTSINFO struct to any of these to influence +// further parsing. +#define AIF_DONTPARSE 0x01 // Don't parse the result of this function, + // usually the result of a token is parsed + // again, if the `?` is used as a function + // character. +#define AIF_FALSE 0x02 // The function returned logical false. + +// Definition of parse/cleanup functions: +typedef char* (*VARPARSEFUNCA)(ARGUMENTSINFO *ai); +typedef WCHAR* (*VARPARSEFUNCW)(ARGUMENTSINFO *ai); +typedef void (*VARCLEANUPFUNCA)(char *szReturn); +typedef void (*VARCLEANUPFUNCW)(WCHAR *wszReturn); + +#if defined(UNICODE) || defined(_UNICODE) +#define VARPARSEFUNC VARPARSEFUNCW +#define VARCLEANUPFUNC VARCLEANUPFUNCW +#else +#define VARPARSEFUNC VARPARSEFUNCA +#define VARCLEANUPFUNC VARCLEANUPFUNCA +#endif + +typedef struct { + int cbSize; // Set this to sizeof(TOKENREGISTER). + union { + char *szTokenString; // Name of the new token to be created, without %, + // ?, ! etc. signs (can't be NULL). + WCHAR *wszTokenString; + TCHAR *tszTokenString; + }; + union { + char *szService; // Name of a service that is used to request the + // token's value, if no service is used, a function + // and TRF_PARSEFUNC must be used. + VARPARSEFUNCA parseFunction; // See above, use with TRF_PARSEFUNC. + VARPARSEFUNCW parseFunctionW; + VARPARSEFUNC parseFunctionT; + }; + union { + char *szCleanupService; // Name of a service to be called when the + // memory allocated in szService can be freed + // (only used when flag VRF_CLEANUP is set, + // else set this to NULL). + VARCLEANUPFUNCA cleanupFunction; // See above, use with TRF_CLEANUPFUNC. + VARCLEANUPFUNCW cleanupFunctionW; + VARCLEANUPFUNC cleanupFunctionT; + }; + char *szHelpText; // Help info shown in help dialog (can be NULL). Has to + // be in the following format: + // "subject\targuments\tdescription" + // (Example: "math\t(x, y ,...)\tx + y + ..."), or: + // "subject\tdescription" + // (Example: "miranda\tPath to the Miranda-IM + // executable"). + // Note: subject and description are translated by + // Variables. + int memType; // Describes which method Varibale's plugin needs to use to + // free the returned buffer, use one of the VR_MEM_* values + // (see below). Only valid if the flag VRF_FREEMEM is set, + // use TR_MEM_OWNER otherwise). + int flags; // Flags to use (see below), one of TRF_* (see below). +} TOKENREGISTER; + +// Available Memory Storage Types: +// These values describe which method Variables Plugin will use to free the +// buffer returned by the parse function or service +#define TR_MEM_VARIABLES 1 // Memory is allocated using the functions + // retrieved by MS_VARS_GET_MMI. +#define TR_MEM_MIRANDA 2 // Memory is allocated using Miranda's Memory + // Manager Interface (using the functions + // returned by MS_SYSTEM_GET_MMI), if + // VRF_FREEMEM is set, the memory will be + // freed by Variables. +#define TR_MEM_OWNER 3 // Memory is owned by the calling plugin + // (can't be freed by Variables Plugin + // automatically). This should be used if + // VRF_FREEMEM is not specified in the flags. + +// Available Flags for TOKENREGISTER: +#define TRF_FREEMEM 0x01 // Variables Plugin will automatically free the + // pointer returned by the parse function or + // service (which method it will us is + // specified in memType -> see above). +#define TRF_CLEANUP 0x02 // Call cleanup service or function, notifying + // that the returned buffer can be freed. + // Normally you should use either TRF_FREEMEM + // or TRF_CLEANUP. +#define TRF_PARSEFUNC 0x40 // parseFunction will be used instead of a + // service. +#define TRF_CLEANUPFUNC 0x80 // cleanupFunction will be used instead of a + // service. +#define TRF_USEFUNCS TRF_PARSEFUNC|TRF_CLEANUPFUNC +#define TRF_UNPARSEDARGS 0x04 // Provide the arguments for the parse + // function in their raw (unparsed) form. + // By default, arguments are parsed before + // presenting them to the parse function. +#define TRF_FIELD 0x08 // The token can be used as a %field%. +#define TRF_FUNCTION 0x10 // The token can be used as a ?function(). + // Normally you should use either TRF_FIELD or + // TRF_FUNCTION. +#define TRF_UNICODE 0x20 // Strings in structure are unicode (WCHAR*). + // In this case, the strings pointing to the + // arguments in the ARGUMENTS struct are + // unicode also. The returned buffer is + // expected to be unicode also, and the + // unicode parse and cleanup functions are + // called. + +#if defined(UNICODE) || defined(_UNICODE) +#define TRF_TCHAR TRF_UNICODE // Strings in structure are TCHAR*. +#else +#define TRF_TCHAR 0 +#endif + +// Deprecated: +#define TRF_CALLSVC TRF_CLEANUP + +// Callback Service (szService) / parseFunction: +// ------------------------ +// Service that is called automatically by the Variable's Plugin to resolve a +// registered variable. + +// Parameters: +// wParam = 0 +// lParam = (LPARAM)(ARGUMENTSINFO *)&ai +// see above + +// Return Value: +// Needs to return the pointer to a dynamically allocacated string or NULL. +// A return value of NULL is regarded as an error (eCount will be increaded). +// Flags in the ARGUMENTSINFO struct can be set (see above). + +// Callback Service (szCallbackService) / cleanupFunction: +// ------------------------ +// This service is called when the memory that was allocated by the parse +// function or service can be freed. Note: It will only be called when the +// flag VRF_CLEANUP of TOKENREGISTER is set. + +// Parameters: +// wParam = 0 +// lParam = (LPARAM)(char *)&res +// Result from parse function or service (pointer to a string). + +// Return Value: +// Should return 0 on success. + + + +// -------------------------------------------------------------------------- +// Show the help dialog +// -------------------------------------------------------------------------- + +// Plugins can invoke Variables' help dialog which can be used for easy input +// by users. + +#define MS_VARS_SHOWHELPEX "Vars/ShowHelpEx" + +// This service can be used to open the help dialog of Variables. This dialog +// provides easy input for the user and/or information about the available +// tokens. + +// Parameters: +// ------------------------ +// wParam = (WPARAM)(HWND)hwndParent +// lParam = (LPARAM)(VARHELPINFO)&vhi +// See below. + +// Return Value: +// ------------------------ +// Returns 0 on succes, any other value on error. + +typedef struct { + int cbSize; // Set to sizeof(VARHELPINFO). + FORMATINFO *fi; // Used for both input and output. If this pointer is not + // NULL, the information is used as the initial values for + // the dialog. + HWND hwndCtrl; // Used for both input and output. The window text of this + // window will be read and used as the initial input of the + // input dialog. If the user presses the OK button the window + // text of this window will be set to the text of the input + // field and a EN_CHANGE message via WM_COMMAND is send to + // this window. (Can be NULL). + char *szSubjectDesc; // The description of the %subject% token will be set + // to this text, if not NULL. This is translated + // automatically. + char *szExtraTextDesc; // The description of the %extratext% token will be + // set to this text, if not NULL. This is translated + // automatically. + int flags; // Flags, see below. +} VARHELPINFO; + + +// Flags for VARHELPINFO +#define VHF_TOKENS 0x00000001 // Create a dialog with the list of + // tokens +#define VHF_INPUT 0x00000002 // Create a dialog with an input + // field (this contains the list of + // tokens as well). +#define VHF_SUBJECT 0x00000004 // Create a dialog to select a + // contact for the %subject% token. +#define VHF_EXTRATEXT 0x00000008 // Create a dialog to enter a text + // for the %extratext% token. +#define VHF_HELP 0x00000010 // Create a dialog with help info. +#define VHF_HIDESUBJECTTOKEN 0x00000020 // Hide the %subject% token in the + // list of tokens. +#define VHF_HIDEEXTRATEXTTOKEN 0x00000040 // Hide the %extratext% token in + // the list of tokens. +#define VHF_DONTFILLSTRUCT 0x00000080 // Don't fill the struct with the + // new information if OK is pressed +#define VHF_FULLFILLSTRUCT 0x00000100 // Fill all members of the struct + // when OK is pressed. By default + // only szFormat is set. With this + // flag on, hContact and + // szExtraText are also set. +#define VHF_SETLASTSUBJECT 0x00000200 // Set the last contact that was + // used in the %subject% dialog in + // case fi.hContact is NULL. + +// Predefined flags +#define VHF_FULLDLG VHF_INPUT|VHF_SUBJECT|VHF_EXTRATEXT|VHF_HELP +#define VHF_SIMPLEDLG VHF_INPUT|VHF_HELP +#define VHF_NOINPUTDLG VHF_TOKENS|VHF_HELP + +// If the service fills information in the struct for szFormat or szExtraText, +// these members must be free'd using the free function of Variables. +// If wParam==NULL, the dialog is created modeless. Only one dialog can be +// shown at the time. +// If both hwndCtrl and fi are NULL, the user input will not be retrievable. +// In this case, the dialog is created with only a "Close" button, instead of +// the "OK" and "Cancel" buttons. +// In case of modeless dialog and fi != NULL, please make sure this pointer +// stays valid while the dialog is open. + +// Helper function for easy use in standard case: +#ifndef VARIABLES_NOHELPER +__inline static int variables_showhelp(HWND hwndDlg, UINT uIDEdit, int flags, char *szSubjectDesc, char *szExtraDesc) { + + VARHELPINFO vhi; + + ZeroMemory(&vhi, sizeof(VARHELPINFO)); + vhi.cbSize = sizeof(VARHELPINFO); + if (flags == 0) { + flags = VHF_SIMPLEDLG; + } + vhi.flags = flags; + vhi.hwndCtrl = GetDlgItem(hwndDlg, uIDEdit); + vhi.szSubjectDesc = szSubjectDesc; + vhi.szExtraTextDesc = szExtraDesc; + + return CallService(MS_VARS_SHOWHELPEX, (WPARAM)hwndDlg, (LPARAM)&vhi); +} +#endif + + +#define MS_VARS_GETSKINITEM "Vars/GetSkinItem" + +// This service can be used to get the icon you can use for example on the +// Variables help button in your options screen. You can also get the tooltip +// text to use with such a button. If icon library is available the icon will +// be retrieved from icon library manager, otherwise the default is returned. + +// Parameters: +// ------------------------ +// wParam = (WPARAM)0 +// lParam = (LPARAM)VSI_* (see below) + +// Return Value: +// ------------------------ +// Depends on the information to retrieve (see below). + +// VSI_ constants +#define VSI_HELPICON 1 // Can be used on the button accessing the + // Variables help dialog. Returns (HICON)hIcon on + // success or NULL on failure; +#define VSI_HELPTIPTEXT 2 // Returns the tooltip text you can use for the + // help button. Returns (char *)szTipText, a + // static, translated buffer containing the help + // text or NULL on error. + +// Helper to set the icon on a button accessing the help dialog. +// Preferably a 16x14 MButtonClass control, but it works on a standard +// button control as well. If no icon is availble (because of old version of +// Variables) the string "V" is shown on the button. If Variables is not +// available, the button will be hidden. +#ifndef VARIABLES_NOHELPER +__inline static int variables_skin_helpbutton(HWND hwndDlg, UINT uIDButton) { + + int res; + HICON hIcon; + TCHAR tszClass[32]; + + hIcon = NULL; + res = 0; + if (ServiceExists(MS_VARS_GETSKINITEM)) { + hIcon = (HICON)CallService(MS_VARS_GETSKINITEM, 0, (LPARAM)VSI_HELPICON); + } + GetClassName(GetDlgItem(hwndDlg, uIDButton), tszClass, sizeof(tszClass)); + if (!_tcscmp(tszClass, _T("Button"))) { + if (hIcon != NULL) { + SetWindowLong(GetDlgItem(hwndDlg, uIDButton), GWL_STYLE, GetWindowLong(GetDlgItem(hwndDlg, uIDButton), GWL_STYLE)|BS_ICON); + SendMessage(GetDlgItem(hwndDlg, uIDButton), BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)hIcon); + } + else { + SetWindowLong(GetDlgItem(hwndDlg, uIDButton), GWL_STYLE, GetWindowLong(GetDlgItem(hwndDlg, uIDButton), GWL_STYLE)&~BS_ICON); + SetDlgItemText(hwndDlg, uIDButton, _T("V")); + } + } + else if (!_tcscmp(tszClass, MIRANDABUTTONCLASS)) { + if (hIcon != NULL) { + char *szTipInfo; + + SendMessage(GetDlgItem(hwndDlg, uIDButton), BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)hIcon); + if (ServiceExists(MS_VARS_GETSKINITEM)) { + szTipInfo = (char *)CallService(MS_VARS_GETSKINITEM, 0, (LPARAM)VSI_HELPTIPTEXT); + } + if (szTipInfo == NULL) { + szTipInfo = Translate("Open String Formatting Help"); + } + SendMessage(GetDlgItem(hwndDlg, uIDButton), BUTTONADDTOOLTIP, (WPARAM)szTipInfo, 0); + SendDlgItemMessage(hwndDlg, uIDButton, BUTTONSETASFLATBTN, 0, 0); + } + else { + SetDlgItemText(hwndDlg, uIDButton, _T("V")); + } + } + else { + res = -1; + } + ShowWindow(GetDlgItem(hwndDlg, uIDButton), ServiceExists(MS_VARS_FORMATSTRING)); + + return res; +} +#endif + + +#define MS_VARS_SHOWHELP "Vars/ShowHelp" + +// WARNING: This service is obsolete, please use MS_VARS_SHOWHELPEX + +// Shows a help dialog where all possible tokens are displayed. The tokens +// are explained on the dialog, too. The user can edit the initial string and +// insert as many tokens as he likes. + +// Parameters: +// ------------------------ +// wParam = (HWND)hwndEdit +// Handle to an edit control in which the modified string +// should be inserted (When the user clicks OK in the dialog the edited +// string will be set to hwndEdit) (can be NULL). +// lParam = (char *)pszInitialString +// String that the user is provided with initially when +// the dialog gets opened (If this is NULL then the current text in the +// hwndEdit edit control will be used) (can be NULL). + +// Return Value: +// ------------------------ +// Returns the handle to the help dialog (HWND). + +// Note: Only one help dialog can be opened at a time. When the dialog gets +// closed an EN_CHANGE of the edit controll will be triggered because the +// contents were updated. (Only when user selected OK). + +// Example: +// CallService(MS_VARS_SHOWHELP, (WPARAM)hwndEdit, (LPARAM)"some initial text"); + +// -------------------------------------------------------------------------- +// Retrieve a contact's HANDLE given a string +// -------------------------------------------------------------------------- + +#define MS_VARS_GETCONTACTFROMSTRING "Vars/GetContactFromString" + +// Searching for contacts in the database. You can find contacts in db by +// searching for their name, e.g first name. + +// Parameters: +// ------------------------ +// wParam = (WPARAM)(CONTACTSINFO *)&ci +// See below. +// lParam = 0 + +// Return Value: +// ------------------------ +// Returns number of contacts found matching the given string representation. +// The hContacts array of CONTACTSINFO struct contains these hContacts after +// the call. + +// Note: The hContacts array needs to be freed after use using +// MS_VARS_FREEMEMORY. + +typedef struct { + int cbSize; // Set this to sizeof(CONTACTSINFO). + union { + char *szContact; // String to search for, e.g. last name (can't be NULL). + WCHAR * wszContact; + TCHAR *tszContact; + }; + HANDLE *hContacts; // (output) Array of contacts found. + DWORD flags; // Contact details that will be matched with the search + // string (flags can be combined). +} CONTACTSINFO; + +// Possible flags: +#define CI_PROTOID 0x00000001 // The contact in the string is encoded + // in the format , e.g. + // . +#define CI_NICK 0x00000002 // Search nick names. +#define CI_LISTNAME 0x00000004 // Search custom names shown in contact + // list. +#define CI_FIRSTNAME 0x00000008 // Search contact's first names (contact + // details). +#define CI_LASTNAME 0x00000010 // Search contact's last names (contact + // details). +#define CI_EMAIL 0x00000020 // Search contact's email adresses + // (contact details). +#define CI_UNIQUEID 0x00000040 // Search unique ids of the contac, e.g. + // UIN. +#define CI_CNFINFO 0x40000000 // Searches one of the CNF_* flags (set + // flags to CI_CNFINFO|CNF_X), only one + // CNF_ type possible +#define CI_UNICODE 0x80000000 // tszContact is a unicode string + // (WCHAR*). + +#if defined(UNICODE) || defined(_UNICODE) +#define CI_TCHAR CI_UNICODE // Strings in structure are TCHAR*. +#else +#define CI_TCHAR 0 +#endif + + + +#endif //__M_VARS diff --git a/plugins/Skins/Docs/langpack_skins.txt b/plugins/Skins/Docs/langpack_skins.txt deleted file mode 100644 index 1819d74fce..0000000000 --- a/plugins/Skins/Docs/langpack_skins.txt +++ /dev/null @@ -1,2 +0,0 @@ -; Skins -; Author: Pescuma diff --git a/plugins/Skins/Docs/skins_changelog.txt b/plugins/Skins/Docs/skins_changelog.txt deleted file mode 100644 index fcaa8da44c..0000000000 --- a/plugins/Skins/Docs/skins_changelog.txt +++ /dev/null @@ -1,25 +0,0 @@ -Skins - -Changelog: - -. 0.0.0.5 - + Allow changing skins - * Updated v8 - * Updated updater to use googlecode - -. 0.0.0.4 - * Fixed font service iteration - * Fixed naming of skin options - -. 0.0.0.3 - * Better handling of small sizes - -. 0.0.0.2 - * Fix for float numbers - + Added valign (not used yet) - + Added dialog info (allow clients to set script variables starting with info) - + The zip will contain also the pdbs (at least until it is more stable) - * Fix for ASCII strings - -. 0.0.0.1 - + Initial version \ No newline at end of file diff --git a/plugins/Skins/Docs/skins_readme.txt b/plugins/Skins/Docs/skins_readme.txt deleted file mode 100644 index fd06309ad1..0000000000 --- a/plugins/Skins/Docs/skins_readme.txt +++ /dev/null @@ -1,31 +0,0 @@ -Skins plugin ----------------- - -CAUTION: THIS IS AN ALPHA STAGE PLUGIN. IT CAN DO VERY BAD THINGS. USE AT YOUR OWN RISK. - -This is a service plugin to allow using different skins. It uses javascript as the language the skins are written, thus allowing a lot of flexibility. - -Keep in mind that this is an initial version of the plugin. It is intended to grow a loot (its to do list is bigger than its features list :P ). Currently it allows only calculating the position of elements. - -It works based in the consept of a skin beeing a group of small skins (one for each client). The skins are inside the dir \Skins\ , and inside that folder, each client skin has the name .msk - -Inside the zip there is also a version of MyDetails using this plugin. - -Many thanks to the v8 team for the javascript engine implementation. - -This needs Miranda 0.8 to work. - -To report bugs/make suggestions, go to the forum thread: http://forums.miranda-im.org/showthread.php?p=172392 - - -TODO: - - Allow changing skin without restart - - Add support for handling skin packs - - Add support for emoticons in text fields - - Add code to draw elements on screen - - Add service to create a new frame only based on the fields - - Allow setting variables by the users of the plugin - - -KNOWN PROBLEMS: - - It seems to have a memory leak (last time I debugged it, it was inside v8 - maybe I just don't understant its garbage collector?) diff --git a/plugins/Skins/Docs/skins_version.txt b/plugins/Skins/Docs/skins_version.txt deleted file mode 100644 index 92fad2b10f..0000000000 --- a/plugins/Skins/Docs/skins_version.txt +++ /dev/null @@ -1 +0,0 @@ -Skins 0.0.0.5 \ No newline at end of file diff --git a/plugins/Skins/MirandaField.h b/plugins/Skins/MirandaField.h deleted file mode 100644 index d89901c77d..0000000000 --- a/plugins/Skins/MirandaField.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __MIRANDA_FIELD_H__ -# define __MIRANDA_FIELD_H__ - - -class MirandaField -{ -public: - virtual void configure() = 0; -}; - - - - -#endif // __MIRANDA_FIELD_H__ diff --git a/plugins/Skins/MirandaFont.cpp b/plugins/Skins/MirandaFont.cpp deleted file mode 100644 index 51b0f34f9b..0000000000 --- a/plugins/Skins/MirandaFont.cpp +++ /dev/null @@ -1,87 +0,0 @@ -#include "MirandaFont.h" - -MirandaFont::MirandaFont(Field *aField, const char *description) - : field(aField), hFont(NULL) -{ - ZeroMemory(&fid, sizeof(fid)); - lstrcpyn(fid.name, CharToTchar(description), sizeof(fid.name)); -} - -MirandaFont::~MirandaFont() -{ - releaseFont(); -} - -void MirandaFont::registerFont(FontState *font) -{ - if (fid.cbSize != 0) - return; - - MirandaSkinnedDialog * dlg = (MirandaSkinnedDialog *) field->getDialog(); - - HDC hdc = GetDC(NULL); - - fid.cbSize = sizeof(fid); - lstrcpyn(fid.group, CharToTchar(dlg->getDescription()), sizeof(fid.group)); - strncpy(fid.dbSettingsGroup, dlg->getModule(), sizeof(fid.dbSettingsGroup)); - - char tmp[sizeof(fid.prefix)]; - mir_snprintf(tmp, sizeof(tmp), "%s%s%sFont", TcharToChar(dlg->getSkinName()), dlg->getName(), field->getName()); - strncpy(fid.prefix, tmp, sizeof(fid.prefix)); - - fid.deffontsettings.colour = font->getColor(); - fid.deffontsettings.size = -MulDiv(font->getSize(), GetDeviceCaps(hdc, LOGPIXELSY), 72); - fid.deffontsettings.style = (font->isBold() ? DBFONTF_BOLD : 0) - | (font->isItalic() ? DBFONTF_ITALIC : 0) - | (font->isUnderline() ? DBFONTF_UNDERLINE : 0) - | (font->isStrikeOut() ? DBFONTF_STRIKEOUT : 0); - fid.deffontsettings.charset = DEFAULT_CHARSET; - lstrcpyn(fid.deffontsettings.szFace, font->getFace(), sizeof(fid.deffontsettings.szFace)); - fid.order = dlg->getIndexOf(field); - fid.flags = FIDF_DEFAULTVALID | FIDF_ALLOWEFFECTS; - - CallService(MS_FONT_REGISTERT, (WPARAM)&fid, 0); - - ReleaseDC(NULL, hdc); - - HookEventObj(ME_FONT_RELOAD, staticReloadFont, this); - - reloadFont(); -} - -void MirandaFont::reloadFont() -{ - releaseFont(); - - LOGFONT log_font; - COLORREF color = (COLORREF) CallService(MS_FONT_GETT, (WPARAM) &fid, (LPARAM) &log_font); - hFont = CreateFontIndirect(&log_font); - - switch(field->getType()) - { - case SIMPLE_TEXT: - ((TextField *) field)->setFontColor(color); - ((TextField *) field)->setFont(hFont); - break; - case CONTROL_LABEL: - case CONTROL_BUTTON: - case CONTROL_EDIT: - ((ControlField *) field)->setFont(hFont); - break; - } -} - -int MirandaFont::staticReloadFont(void *obj, WPARAM wParam, LPARAM lParam) -{ - ((MirandaFont *) obj)->reloadFont(); - return 0; -} - -void MirandaFont::releaseFont() -{ - if (hFont != NULL) - { - DeleteObject(hFont); - hFont = NULL; - } -} \ No newline at end of file diff --git a/plugins/Skins/MirandaFont.h b/plugins/Skins/MirandaFont.h deleted file mode 100644 index da9a40a06e..0000000000 --- a/plugins/Skins/MirandaFont.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef __MIRANDA_FONT_H__ -# define __MIRANDA_FONT_H__ - -#include "commons.h" - - -class MirandaFont -{ -public: - MirandaFont(Field *field, const char *description); - ~MirandaFont(); - - void registerFont(FontState *font); - void reloadFont(); - -private: - FontIDT fid; - HFONT hFont; - Field *field; - - void releaseFont(); - - static int staticReloadFont(void *obj, WPARAM wParam, LPARAM lParam); -}; - - - -#endif // __MIRANDA_FONT_H__ diff --git a/plugins/Skins/MirandaIconField.cpp b/plugins/Skins/MirandaIconField.cpp deleted file mode 100644 index 7861e11091..0000000000 --- a/plugins/Skins/MirandaIconField.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "MirandaIconField.h" - -MirandaIconField::MirandaIconField(MirandaSkinnedDialog *dlg, const char *name, const char *description) - : IconField(dlg, name) -{ -} - -MirandaIconField::~MirandaIconField() -{ -} - -MirandaSkinnedDialog * MirandaIconField::getDialog() const -{ - return (MirandaSkinnedDialog *) IconField::getDialog(); -} - -void MirandaIconField::configure() -{ -} \ No newline at end of file diff --git a/plugins/Skins/MirandaIconField.h b/plugins/Skins/MirandaIconField.h deleted file mode 100644 index 0f6f15af9e..0000000000 --- a/plugins/Skins/MirandaIconField.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef __MIRANDA_ICON_FIELD_H__ -# define __MIRANDA_ICON_FIELD_H__ - -#include "commons.h" -#include "MirandaField.h" - - -class MirandaIconField : public IconField, public MirandaField -{ -public: - MirandaIconField(MirandaSkinnedDialog *dlg, const char *name, const char *description); - virtual ~MirandaIconField(); - - virtual MirandaSkinnedDialog * getDialog() const; - - virtual void configure(); -}; - - - -#endif // __MIRANDA_ICON_FIELD_H__ diff --git a/plugins/Skins/MirandaImageField.cpp b/plugins/Skins/MirandaImageField.cpp deleted file mode 100644 index 2c9efe11f2..0000000000 --- a/plugins/Skins/MirandaImageField.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "MirandaImageField.h" - -MirandaImageField::MirandaImageField(MirandaSkinnedDialog *dlg, const char *name, const char *description) - : ImageField(dlg, name) -{ -} - -MirandaImageField::~MirandaImageField() -{ -} - -MirandaSkinnedDialog * MirandaImageField::getDialog() const -{ - return (MirandaSkinnedDialog *) ImageField::getDialog(); -} - -void MirandaImageField::configure() -{ -} \ No newline at end of file diff --git a/plugins/Skins/MirandaImageField.h b/plugins/Skins/MirandaImageField.h deleted file mode 100644 index 70cd1ce873..0000000000 --- a/plugins/Skins/MirandaImageField.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef __MIRANDA_IMAGE_FIELD_H__ -# define __MIRANDA_IMAGE_FIELD_H__ - -#include "commons.h" -#include "MirandaField.h" - - -class MirandaImageField : public ImageField, public MirandaField -{ -public: - MirandaImageField(MirandaSkinnedDialog *dlg, const char *name, const char *description); - virtual ~MirandaImageField(); - - virtual MirandaSkinnedDialog * getDialog() const; - - virtual void configure(); -}; - - -#endif // __MIRANDA_IMAGE_FIELD_H__ - diff --git a/plugins/Skins/MirandaSkinnedDialog.cpp b/plugins/Skins/MirandaSkinnedDialog.cpp deleted file mode 100644 index 97bf236a5a..0000000000 --- a/plugins/Skins/MirandaSkinnedDialog.cpp +++ /dev/null @@ -1,252 +0,0 @@ -#include "commons.h" -#include "MirandaSkinnedDialog.h" - -#define SETTING_NAME_SIZE 256 - - -MirandaSkinnedDialog::MirandaSkinnedDialog(const char *name, const char *aDescription, const char *aModule) - : SkinnedDialog(name), description(aDescription), module(aModule), - skinChangedCallback(NULL), skinChangedCallbackParam(NULL) -{ - getSettting("Skin", _T(DEFAULT_SKIN_NAME), skinName, true); -} - -MirandaSkinnedDialog::~MirandaSkinnedDialog() -{ -} - -const char * MirandaSkinnedDialog::getDescription() const -{ - return description.c_str(); -} - -const char * MirandaSkinnedDialog::getModule() const -{ - return module.c_str(); -} - -const TCHAR * MirandaSkinnedDialog::getSkinName() const -{ - return skinName.c_str(); -} - -void MirandaSkinnedDialog::setSkinName(const TCHAR *name) -{ - if (skinName == name) - return; - - skinName = name; - setSettting("Skin", skinName.c_str(), true); - updateFilename(); -} - -bool MirandaSkinnedDialog::finishedConfiguring() -{ - updateFilename(); - - if (getDefaultState() == NULL || getOpts() == NULL) - return false; - - return true; -} - -void MirandaSkinnedDialog::updateFilename() -{ - std::tstring filename; - getSkinnedDialogFilename(filename, getSkinName(), getName()); - setFilename(filename.c_str()); -} - -void MirandaSkinnedDialog::loadFromDB(SkinOption *opt) -{ - switch(opt->getType()) - { - case CHECKBOX: - { - opt->setValueCheckbox(getSettting(opt->getName(), opt->getValueCheckbox())); - break; - } - case NUMBER: - { - opt->setValueNumber(getSettting(opt->getName(), opt->getValueNumber())); - break; - } - case TEXT: - { - std::tstring tmp; - getSettting(opt->getName(), opt->getValueText(), tmp); - opt->setValueText(tmp.c_str()); - break; - } - } -} - -void MirandaSkinnedDialog::storeToDB(const SkinOptions *opts) -{ - for (unsigned int i = 0; i < opts->getNumOptions(); i++) - storeToDB(opts->getOption(i)); - - fireOnSkinChanged(); -} - -void MirandaSkinnedDialog::storeToDB(const SkinOption *opt) -{ - switch(opt->getType()) - { - case CHECKBOX: - { - setSettting(opt->getName(), opt->getValueCheckbox()); - break; - } - case NUMBER: - { - setSettting(opt->getName(), opt->getValueNumber()); - break; - } - case TEXT: - { - setSettting(opt->getName(), opt->getValueText()); - break; - } - } -} - -bool MirandaSkinnedDialog::getSettting(const char *name, bool defVal, bool global) -{ - char setting[SETTING_NAME_SIZE]; - getSettingName(setting, name, global); - - return DBGetContactSettingByte(NULL, getModule(), setting, defVal ? 1 : 0) != 0; -} - -void MirandaSkinnedDialog::setSettting(const char *name, bool val, bool global) -{ - char setting[SETTING_NAME_SIZE]; - getSettingName(setting, name, global); - - DBWriteContactSettingByte(NULL, getModule(), setting, val ? 1 : 0); -} - -int MirandaSkinnedDialog::getSettting(const char *name, int defVal, bool global) -{ - char setting[SETTING_NAME_SIZE]; - getSettingName(setting, name, global); - - return DBGetContactSettingDword(NULL, getModule(), setting, defVal); -} - -void MirandaSkinnedDialog::setSettting(const char *name, int val, bool global) -{ - char setting[SETTING_NAME_SIZE]; - getSettingName(setting, name, global); - - DBWriteContactSettingDword(NULL, getModule(), setting, val); -} - -void MirandaSkinnedDialog::getSettting(const char *name, const WCHAR *defVal, std::wstring &ret, bool global) -{ - char setting[SETTING_NAME_SIZE]; - getSettingName(setting, name, global); - - DBVARIANT dbv = {0}; - if (DBGetContactSettingWString(NULL, getModule(), setting, &dbv)) - { - ret = defVal; - return; - } - - ret = dbv.pwszVal; - DBFreeVariant(&dbv); -} - -void MirandaSkinnedDialog::setSettting(const char *name, const WCHAR *val, bool global) -{ - char setting[SETTING_NAME_SIZE]; - getSettingName(setting, name, global); - - DBWriteContactSettingWString(NULL, getModule(), setting, val); -} - -void MirandaSkinnedDialog::getSettting(const char *name, const char *defVal, std::string &ret, bool global) -{ - char setting[SETTING_NAME_SIZE]; - getSettingName(setting, name, global); - - DBVARIANT dbv = {0}; - if (DBGetContactSettingString(NULL, getModule(), setting, &dbv)) - { - ret = defVal; - return; - } - - ret = dbv.pszVal; - DBFreeVariant(&dbv); -} - -void MirandaSkinnedDialog::setSettting(const char *name, const char *val, bool global) -{ - char setting[SETTING_NAME_SIZE]; - getSettingName(setting, name, global); - - DBWriteContactSettingString(NULL, getModule(), setting, val); -} - -void MirandaSkinnedDialog::getSettingName(char *setting, const char * name, bool global) -{ - if (global) - mir_snprintf(setting, SETTING_NAME_SIZE, "%s%s", getName(), name); - else - mir_snprintf(setting, SETTING_NAME_SIZE, "%s%s%s", TcharToChar(getSkinName()), getName(), name); -} - -void MirandaSkinnedDialog::setOnSkinChangedCallback(MirandaSkinnedCallback cb, void *param) -{ - skinChangedCallback = cb; - skinChangedCallbackParam = param; -} - -void MirandaSkinnedDialog::fireOnSkinChanged() -{ - if (skinChangedCallback != NULL) - skinChangedCallback(skinChangedCallbackParam, this); -} - -int MirandaSkinnedDialog::compile() -{ - int ret = SkinnedDialog::compile(); - - if (ret == 2) - { - SkinOptions * opts = getOpts(); - _ASSERT(opts != NULL); - - for(unsigned int i = 0; i < opts->getNumOptions(); ++i) - { - SkinOption *opt = opts->getOption(i); - loadFromDB(opt); - opt->setOnChangeCallback(&staticOnOptionChange, this); - } - - for(unsigned int i = 0; i < getFieldCount(); ++i) - { - MirandaField *field = dynamic_cast(getField(i)); - field->configure(); - } - - fireOnSkinChanged(); - } - - return ret; -} - -void MirandaSkinnedDialog::onOptionChange(const SkinOption *opt) -{ - storeToDB(opt); -} - -void MirandaSkinnedDialog::staticOnOptionChange(void *param, const SkinOption *opt) -{ - _ASSERT(param != NULL); - - ((MirandaSkinnedDialog *) param)->onOptionChange(opt); -} diff --git a/plugins/Skins/MirandaSkinnedDialog.h b/plugins/Skins/MirandaSkinnedDialog.h deleted file mode 100644 index d556b9a495..0000000000 --- a/plugins/Skins/MirandaSkinnedDialog.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef __MIRANDA_SKINNED_DIALOG_H__ -# define __MIRANDA_SKINNED_DIALOG_H__ - -#include "SkinLib\SkinnedDialog.h" - -class SkinOption; -class MirandaSkinnedDialog; - -typedef void (*MirandaSkinnedCallback)(void *param, const MirandaSkinnedDialog *dlg); - - -class MirandaSkinnedDialog : public SkinnedDialog -{ -public: - MirandaSkinnedDialog(const char *name, const char *description, const char *module); - virtual ~MirandaSkinnedDialog(); - - virtual const char * getDescription() const; - virtual const char * getModule() const; - - virtual const TCHAR * getSkinName() const; - virtual void setSkinName(const TCHAR *name); - - virtual bool finishedConfiguring(); - - virtual void storeToDB(const SkinOptions *opts); - - virtual void setOnSkinChangedCallback(MirandaSkinnedCallback cb, void *param); - -protected: - virtual int compile(); - -private: - std::string description; - std::string module; - std::tstring skinName; - MirandaSkinnedCallback skinChangedCallback; - void *skinChangedCallbackParam; - - void updateFilename(); - - void loadFromDB(SkinOption *opt); - void storeToDB(const SkinOption *opt); - - bool getSettting(const char *name, bool defVal, bool global = false); - void setSettting(const char *name, bool val, bool global = false); - int getSettting(const char *name, int defVal, bool global = false); - void setSettting(const char *name, int val, bool global = false); - void getSettting(const char *name, const WCHAR *defVal, std::wstring &ret, bool global = false); - void setSettting(const char *name, const WCHAR *val, bool global = false); - void getSettting(const char *name, const char *defVal, std::string &ret, bool global = false); - void setSettting(const char *name, const char *val, bool global = false); - - inline void getSettingName(char *setting, const char * name, bool global); - - void fireOnSkinChanged(); - - void onOptionChange(const SkinOption *opt); - - static void staticOnOptionChange(void *param, const SkinOption *opt); -}; - - -#endif // __MIRANDA_SKINNED_DIALOG_H__ diff --git a/plugins/Skins/MirandaTextField.cpp b/plugins/Skins/MirandaTextField.cpp deleted file mode 100644 index 4a3591a322..0000000000 --- a/plugins/Skins/MirandaTextField.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "MirandaTextField.h" -#include "MirandaFont.h" - - -MirandaTextField::MirandaTextField(MirandaSkinnedDialog *dlg, const char *name, const char *aDescription) - : TextField(dlg, name) -{ - font = new MirandaFont(this, aDescription); -} - -MirandaTextField::~MirandaTextField() -{ - delete font; -} - -MirandaSkinnedDialog * MirandaTextField::getDialog() const -{ - return (MirandaSkinnedDialog *) TextField::getDialog(); -} - -void MirandaTextField::configure() -{ - TextFieldState *field = (TextFieldState *) getDialog()->getDefaultState()->getField(getName()); - _ASSERT(field != NULL); - - font->registerFont(field->getFont()); -} diff --git a/plugins/Skins/MirandaTextField.h b/plugins/Skins/MirandaTextField.h deleted file mode 100644 index 36b7ea7292..0000000000 --- a/plugins/Skins/MirandaTextField.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef __MIRANDA_TEXT_FIELD_H__ -# define __MIRANDA_TEXT_FIELD_H__ - -#include "commons.h" -#include "MirandaField.h" - -class MirandaFont; - - -class MirandaTextField : public TextField, public MirandaField -{ -public: - MirandaTextField(MirandaSkinnedDialog *dlg, const char *name, const char *description); - virtual ~MirandaTextField(); - - virtual MirandaSkinnedDialog * getDialog() const; - - virtual void configure(); - -private: - MirandaFont *font; - -}; - - - -#endif // __MIRANDA_TEXT_FIELD_H__ diff --git a/plugins/Skins/SkinLib/BorderState.cpp b/plugins/Skins/SkinLib/BorderState.cpp deleted file mode 100644 index 83dcdbcf11..0000000000 --- a/plugins/Skins/SkinLib/BorderState.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include "globals.h" -#include -#include "BorderState.h" - -BorderState::BorderState(int aLeft, int aRight, int aTop, int aBottom) - : left(aLeft), right(aRight), top(aTop), bottom(aBottom) -{ -} - -BorderState::~BorderState() -{ -} - -int BorderState::getLeft() const -{ - return left; -} - -void BorderState::setLeft(int left) -{ - this->left = max(0, left); -} - -int BorderState::getRight() const -{ - return right; -} - -void BorderState::setRight(int right) -{ - this->right = max(0, right); -} - -int BorderState::getTop() const -{ - return top; -} - -void BorderState::setTop(int top) -{ - this->top = max(0, top); -} - -int BorderState::getBottom() const -{ - return bottom; -} - -void BorderState::setBottom(int bottom) -{ - this->bottom = max(0, bottom); -} - -void BorderState::setAll(int border) -{ - border = max(0, border); - left = border; - right = border; - top = border; - bottom = border; -} diff --git a/plugins/Skins/SkinLib/BorderState.h b/plugins/Skins/SkinLib/BorderState.h deleted file mode 100644 index 2cac3c1aa5..0000000000 --- a/plugins/Skins/SkinLib/BorderState.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once - -class BorderState -{ -public: - BorderState(int left, int right, int top, int bottom); - ~BorderState(); - - int getLeft() const; - void setLeft(int left); - - int getRight() const; - void setRight(int right); - - int getTop() const; - void setTop(int top); - - int getBottom() const; - void setBottom(int bottom); - - void setAll(int border); - -private: - int left; - int right; - int top; - int bottom; -}; diff --git a/plugins/Skins/SkinLib/BorderState_v8_wrapper.cpp b/plugins/Skins/SkinLib/BorderState_v8_wrapper.cpp deleted file mode 100644 index 71cc057419..0000000000 --- a/plugins/Skins/SkinLib/BorderState_v8_wrapper.cpp +++ /dev/null @@ -1,160 +0,0 @@ -#include "globals.h" -#include "BorderState_v8_wrapper.h" -#include -#include "BorderState.h" - -using namespace v8; - - -#ifdef UNICODE -# define V8_TCHAR uint16_t -#else -# define V8_TCHAR char -#endif - - -static Handle Get_BorderState_left(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - BorderState *tmp = (BorderState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( Int32::New(tmp->getLeft()) ); -} - -static void Set_BorderState_left(Local property, Local value, const AccessorInfo& info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return; - - BorderState *tmp = (BorderState *) wrap->Value(); - if (tmp == NULL) - return; - - if (!value.IsEmpty() && value->IsNumber()) - tmp->setLeft(value->Int32Value()); -} - - -static Handle Get_BorderState_right(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - BorderState *tmp = (BorderState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( Int32::New(tmp->getRight()) ); -} - -static void Set_BorderState_right(Local property, Local value, const AccessorInfo& info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return; - - BorderState *tmp = (BorderState *) wrap->Value(); - if (tmp == NULL) - return; - - if (!value.IsEmpty() && value->IsNumber()) - tmp->setRight(value->Int32Value()); -} - - -static Handle Get_BorderState_top(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - BorderState *tmp = (BorderState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( Int32::New(tmp->getTop()) ); -} - -static void Set_BorderState_top(Local property, Local value, const AccessorInfo& info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return; - - BorderState *tmp = (BorderState *) wrap->Value(); - if (tmp == NULL) - return; - - if (!value.IsEmpty() && value->IsNumber()) - tmp->setTop(value->Int32Value()); -} - - -static Handle Get_BorderState_bottom(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - BorderState *tmp = (BorderState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( Int32::New(tmp->getBottom()) ); -} - -static void Set_BorderState_bottom(Local property, Local value, const AccessorInfo& info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return; - - BorderState *tmp = (BorderState *) wrap->Value(); - if (tmp == NULL) - return; - - if (!value.IsEmpty() && value->IsNumber()) - tmp->setBottom(value->Int32Value()); -} - - -void AddBorderStateAcessors(Handle &templ) -{ - HandleScope scope; - - templ->SetAccessor(String::New("left"), Get_BorderState_left, Set_BorderState_left); - templ->SetAccessor(String::New("right"), Get_BorderState_right, Set_BorderState_right); - templ->SetAccessor(String::New("top"), Get_BorderState_top, Set_BorderState_top); - templ->SetAccessor(String::New("bottom"), Get_BorderState_bottom, Set_BorderState_bottom); -} diff --git a/plugins/Skins/SkinLib/BorderState_v8_wrapper.h b/plugins/Skins/SkinLib/BorderState_v8_wrapper.h deleted file mode 100644 index 70af9e41dc..0000000000 --- a/plugins/Skins/SkinLib/BorderState_v8_wrapper.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef __BORDER_STATE_V8_WRAPPER_H__ -# define __BORDER_STATE_V8_WRAPPER_H__ - -#include - -void AddBorderStateAcessors(v8::Handle &templ); - - - -#endif // __BORDER_STATE_V8_WRAPPER_H__ diff --git a/plugins/Skins/SkinLib/ButtonField.cpp b/plugins/Skins/SkinLib/ButtonField.cpp deleted file mode 100644 index e6c82ba5e3..0000000000 --- a/plugins/Skins/SkinLib/ButtonField.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "globals.h" -#include "ButtonField.h" -#include "ButtonFieldState.h" - - -ButtonField::ButtonField(Dialog *dlg, const char *name, HWND hwnd) : ControlField(dlg, name, hwnd) -{ -} - -ButtonField::~ButtonField() -{ -} - -FieldType ButtonField::getType() const -{ - return CONTROL_BUTTON; -} - -FieldState * ButtonField::createState(DialogState *dialogState) -{ - return new ButtonFieldState(dialogState, this); -} \ No newline at end of file diff --git a/plugins/Skins/SkinLib/ButtonField.h b/plugins/Skins/SkinLib/ButtonField.h deleted file mode 100644 index 0d7a1555ca..0000000000 --- a/plugins/Skins/SkinLib/ButtonField.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef __BUTTON_FIELD_H__ -# define __BUTTON_FIELD_H__ - -#include "ControlField.h" - -class ButtonField : public ControlField -{ -public: - ButtonField(Dialog *dlg, const char *name, HWND hwnd); - virtual ~ButtonField(); - - virtual FieldType getType() const; - - virtual FieldState * createState(DialogState *dialogState); -}; - - - -#endif // __BUTTON_FIELD_H__ diff --git a/plugins/Skins/SkinLib/ButtonFieldState.cpp b/plugins/Skins/SkinLib/ButtonFieldState.cpp deleted file mode 100644 index 986484b20b..0000000000 --- a/plugins/Skins/SkinLib/ButtonFieldState.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "globals.h" -#include "ButtonFieldState.h" - -ButtonFieldState::ButtonFieldState(DialogState *dialog, ControlField *field) - : ControlFieldState(dialog, field) -{ -} - -ButtonFieldState::~ButtonFieldState() -{ -} - -Size ButtonFieldState::getPreferedSize() const -{ - Size ret = getTextPreferedSize(DT_SINGLELINE); - - int border = getField()->getBorderSize(); - ret.x += 2 * border; - ret.y += 2 * border; - - ret.x += 12; - ret.y += 10; - - return ret; -} - -bool ButtonFieldState::isEmpty() const -{ - return false; -} \ No newline at end of file diff --git a/plugins/Skins/SkinLib/ButtonFieldState.h b/plugins/Skins/SkinLib/ButtonFieldState.h deleted file mode 100644 index 12b701035a..0000000000 --- a/plugins/Skins/SkinLib/ButtonFieldState.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef __BUTTON_FIELD_STATE_H__ -# define __BUTTON_FIELD_STATE_H__ - -#include "ControlFieldState.h" - - -class ButtonFieldState : public ControlFieldState -{ -public: - virtual ~ButtonFieldState(); - - virtual Size getPreferedSize() const; - - virtual bool isEmpty() const; - -private: - ButtonFieldState(DialogState *dialog, ControlField *field); - - friend class ButtonField; -}; - - -#endif // __BUTTON_FIELD_STATE_H__ diff --git a/plugins/Skins/SkinLib/ButtonFieldState_v8_wrapper.cpp b/plugins/Skins/SkinLib/ButtonFieldState_v8_wrapper.cpp deleted file mode 100644 index c5916b284c..0000000000 --- a/plugins/Skins/SkinLib/ButtonFieldState_v8_wrapper.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "globals.h" -#include "ButtonFieldState_v8_wrapper.h" -#include -#include "ButtonFieldState.h" - -using namespace v8; - - -#ifdef UNICODE -# define V8_TCHAR uint16_t -#else -# define V8_TCHAR char -#endif - - -void AddButtonFieldStateAcessors(Handle &templ) -{ - HandleScope scope; - -} diff --git a/plugins/Skins/SkinLib/ButtonFieldState_v8_wrapper.h b/plugins/Skins/SkinLib/ButtonFieldState_v8_wrapper.h deleted file mode 100644 index c69fdc5c87..0000000000 --- a/plugins/Skins/SkinLib/ButtonFieldState_v8_wrapper.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef __BUTTON_FIELD_STATE_V8_WRAPPER_H__ -# define __BUTTON_FIELD_STATE_V8_WRAPPER_H__ - -#include - -void AddButtonFieldStateAcessors(v8::Handle &templ); - - - -#endif // __BUTTON_FIELD_STATE_V8_WRAPPER_H__ diff --git a/plugins/Skins/SkinLib/ControlField.cpp b/plugins/Skins/SkinLib/ControlField.cpp deleted file mode 100644 index dd9d7026d9..0000000000 --- a/plugins/Skins/SkinLib/ControlField.cpp +++ /dev/null @@ -1,123 +0,0 @@ -#include "globals.h" -#include "ControlField.h" -#include "ControlFieldState.h" - - -ControlField::ControlField(Dialog *dlg, const char *name, HWND aHwnd) - : Field(dlg, name), hwnd(aHwnd), textSet(false), hFont(NULL) -{ -} - - -ControlField::~ControlField() -{ -} - - -HWND ControlField::getHWND() -{ - return hwnd; -} - - - -void ControlField::setText(const TCHAR *text) -{ - if (text == NULL) - { - if (!textSet) - return; - - textSet = false; - this->text.clear(); - fireOnChange(); - } - else - { - textSet = true; - if (this->text == text) - return; - - this->text = text; - // SetWindowText(hwnd, text); - fireOnChange(); - } -} - - -const TCHAR * ControlField::getText() -{ - if (textSet) - return text.c_str(); - - // Control text is the default value - int length = GetWindowTextLength(hwnd); - if (length <= 0) - { - text = _T(""); - } - else - { - TCHAR *tmp = new TCHAR[length+1]; - - if (GetWindowText(hwnd, tmp, length+1) == 0) - tmp[0] = 0; - - text = tmp; - - delete[] tmp; - } - - return text.c_str(); -} - - -void ControlField::setFont(HFONT hFont) -{ - if (this->hFont == hFont) - return; - - this->hFont = hFont; -// SendMessage(hwnd, WM_SETFONT, (WPARAM) hFont, FALSE); - fireOnChange(); -} - - -HFONT ControlField::getFont() const -{ - if (hFont != NULL) - return hFont; - - // Control font is the default value - return (HFONT) SendMessage(hwnd, WM_GETFONT, 0, 0); -} - - -COLORREF ControlField::getFontColor() const -{ - return GetSysColor(COLOR_WINDOWTEXT); -} - - -int ControlField::getBorderSize() const -{ - int exstyle = GetWindowLong(hwnd, GWL_EXSTYLE); - if (exstyle & WS_EX_CLIENTEDGE) - return GetSystemMetrics(SM_CXEDGE); - if (exstyle & WS_EX_STATICEDGE) - return GetSystemMetrics(SM_CXBORDER); - - int style = GetWindowLong(hwnd, GWL_STYLE); - if (style & WS_BORDER) - return GetSystemMetrics(SM_CXBORDER); - - return 0; -} - -bool ControlField::isScrollVisible(bool horizontal) const -{ - SCROLLBARINFO sbi = {0}; - sbi.cbSize = sizeof(SCROLLBARINFO); - GetScrollBarInfo(hwnd, horizontal ? OBJID_HSCROLL : OBJID_VSCROLL, &sbi); - return (sbi.rgstate[0] & STATE_SYSTEM_INVISIBLE) == 0; -} diff --git a/plugins/Skins/SkinLib/ControlField.h b/plugins/Skins/SkinLib/ControlField.h deleted file mode 100644 index 014ee04b9b..0000000000 --- a/plugins/Skins/SkinLib/ControlField.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef __LABEL_CONTROL_FIELD_H__ -# define __LABEL_CONTROL_FIELD_H__ - -#include "Field.h" - -class ControlField : public Field -{ -public: - ControlField(Dialog *dlg, const char *name, HWND hwnd); - virtual ~ControlField(); - - virtual HWND getHWND(); - - virtual void setText(const TCHAR *text); - virtual const TCHAR * getText(); - - virtual void setFont(HFONT hFont); - virtual HFONT getFont() const; - - virtual COLORREF getFontColor() const; - - virtual int getBorderSize() const; - - virtual bool isScrollVisible(bool horizontal) const; - -private: - HWND hwnd; - - bool textSet; - std::tstring text; - - HFONT hFont; -}; - - - -#endif // __LABEL_CONTROL_FIELD_H__ diff --git a/plugins/Skins/SkinLib/ControlFieldState.cpp b/plugins/Skins/SkinLib/ControlFieldState.cpp deleted file mode 100644 index 37c412058a..0000000000 --- a/plugins/Skins/SkinLib/ControlFieldState.cpp +++ /dev/null @@ -1,86 +0,0 @@ -#include "globals.h" -#include "ControlFieldState.h" - - -ControlFieldState::ControlFieldState(DialogState *dialog, ControlField *field) - : FieldState(dialog, field), textSet(false), font(field->getFont(), field->getFontColor()) -{ -} - - -ControlFieldState::~ControlFieldState() -{ -} - - -ControlField * ControlFieldState::getField() const -{ - return (ControlField *) FieldState::getField(); -} - - -Size ControlFieldState::getTextPreferedSize(unsigned int format) const -{ - HDC hdc = CreateCompatibleDC(NULL); - - HFONT newFont = getFont()->getHFONT(); - HFONT oldFont = (HFONT) SelectObject(hdc, newFont); - - int width = 0; - int height = 0; - - const TCHAR *text = getText(); - int len = lstrlen(text); - if (len <= 0) - { - TEXTMETRIC tm = {0}; - GetTextMetrics(hdc, &tm); - height = tm.tmHeight; - } - else - { - RECT rc = {0}; - if ((format & DT_SINGLELINE) == 0 && size.x >= 0) - { - format |= DT_WORDBREAK; - rc.right = size.x; - } - DrawText(hdc, text, len, &rc, DT_CALCRECT | format); - width = rc.right - rc.left; - height = rc.bottom - rc.top; - } - - SelectObject(hdc, oldFont); - - DeleteDC(hdc); - - return Size(width, height); -} - - -const TCHAR * ControlFieldState::getText() const -{ - if (textSet) - return text.c_str(); - - return getField()->getText(); -} - - -void ControlFieldState::setText(const TCHAR *text) -{ - this->text = text; - textSet = true; -} - - -FontState * ControlFieldState::getFont() -{ - return &font; -} - - -const FontState * ControlFieldState::getFont() const -{ - return &font; -} \ No newline at end of file diff --git a/plugins/Skins/SkinLib/ControlFieldState.h b/plugins/Skins/SkinLib/ControlFieldState.h deleted file mode 100644 index 85186c304a..0000000000 --- a/plugins/Skins/SkinLib/ControlFieldState.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef __LABEL_CONTROL_FIELD_STATE_H__ -# define __LABEL_CONTROL_FIELD_STATE_H__ - -#include "ControlField.h" -#include "FieldState.h" -#include "FontState.h" - - -class ControlFieldState : public FieldState -{ -public: - virtual ~ControlFieldState(); - - virtual ControlField * getField() const; - - virtual Size getPreferedSize() const = 0; - - virtual const TCHAR * getText() const; - virtual void setText(const TCHAR *text); - - virtual FontState * getFont(); - virtual const FontState * getFont() const; - -protected: - ControlFieldState(DialogState *dialog, ControlField *field); - - virtual Size getTextPreferedSize(unsigned int format) const; - -private: - FontState font; - - bool textSet; - std::tstring text; - - friend class ControlField; -}; - - -#endif // __LABEL_CONTROL_FIELD_STATE_H__ \ No newline at end of file diff --git a/plugins/Skins/SkinLib/ControlFieldState_v8_wrapper.cpp b/plugins/Skins/SkinLib/ControlFieldState_v8_wrapper.cpp deleted file mode 100644 index 70d3e06a45..0000000000 --- a/plugins/Skins/SkinLib/ControlFieldState_v8_wrapper.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "globals.h" -#include "ControlFieldState_v8_wrapper.h" -#include -#include "ControlFieldState.h" -#include - -using namespace v8; - - -#ifdef UNICODE -# define V8_TCHAR uint16_t -#else -# define V8_TCHAR char -#endif - - -static Handle Get_ControlFieldState_text(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - ControlFieldState *tmp = (ControlFieldState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( String::New((const V8_TCHAR *) tmp->getText()) ); -} - -static void Set_ControlFieldState_text(Local property, Local value, const AccessorInfo& info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return; - - ControlFieldState *tmp = (ControlFieldState *) wrap->Value(); - if (tmp == NULL) - return; - - if (!value.IsEmpty() && value->IsString()) - { - String::Utf8Value utf8_value(value); - tmp->setText(Utf8ToTchar(*utf8_value)); - } -} - - -void AddControlFieldStateAcessors(Handle &templ) -{ - HandleScope scope; - - templ->SetAccessor(String::New("text"), Get_ControlFieldState_text, Set_ControlFieldState_text); -} diff --git a/plugins/Skins/SkinLib/ControlFieldState_v8_wrapper.h b/plugins/Skins/SkinLib/ControlFieldState_v8_wrapper.h deleted file mode 100644 index c86964ce30..0000000000 --- a/plugins/Skins/SkinLib/ControlFieldState_v8_wrapper.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef __CONTROL_FIELD_STATE_V8_WRAPPER_H__ -# define __CONTROL_FIELD_STATE_V8_WRAPPER_H__ - -#include - -void AddControlFieldStateAcessors(v8::Handle &templ); - - - -#endif // __CONTROL_FIELD_STATE_V8_WRAPPER_H__ diff --git a/plugins/Skins/SkinLib/Dialog.cpp b/plugins/Skins/SkinLib/Dialog.cpp deleted file mode 100644 index edc8437817..0000000000 --- a/plugins/Skins/SkinLib/Dialog.cpp +++ /dev/null @@ -1,100 +0,0 @@ -#include "globals.h" -#include "Dialog.h" -#include "DialogState.h" - - -Dialog::Dialog(const char *aName) : name(aName) -{ -} - - -Dialog::~Dialog() -{ - for(unsigned int i = 0; i < fields.size(); i++) - delete fields[i]; - - fields.clear(); -} - - -const char * Dialog::getName() const -{ - return name.c_str(); -} - - -bool Dialog::addField(Field *field) -{ - if (getField(field->getName()) != NULL) - return false; - - fields.push_back(field); - return true; -} - - -Field * Dialog::getField(const char *name) const -{ - if (name == NULL || name[0] == 0) - return NULL; - - for(unsigned int i = 0; i < fields.size(); i++) - { - Field *field = fields[i]; - if (strcmp(name, field->getName()) == 0) - return field; - } - - return NULL; -} - -Field * Dialog::getField(unsigned int pos) const -{ - if (pos >= fields.size()) - return NULL; - return fields[pos]; -} - -int Dialog::getIndexOf(Field *field) const -{ - for(unsigned int i = 0; i < fields.size(); i++) - { - Field *f = fields[i]; - if (field == f) - return i; - } - - return -1; -} - -unsigned int Dialog::getFieldCount() const -{ - return fields.size(); -} - -DialogInfo * Dialog::getInfo() -{ - return &info; -} - -const Size & Dialog::getSize() const -{ - return size; -} - - -void Dialog::setSize(const Size &size) -{ - this->size = size; -} - - -DialogState * Dialog::createState() -{ - DialogState *ret = new DialogState(this); - - for(unsigned int i = 0; i < fields.size(); i++) - ret->fields.push_back(fields[i]->createState(ret)); - - return ret; -} diff --git a/plugins/Skins/SkinLib/Dialog.h b/plugins/Skins/SkinLib/Dialog.h deleted file mode 100644 index 0e85b8e340..0000000000 --- a/plugins/Skins/SkinLib/Dialog.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef __DIALOG_H__ -# define __DIALOG_H__ - -#include -#include "Field.h" -#include "DialogInfo.h" - -class DialogState; - - -/// It is responsible for freeing the Fields -class Dialog -{ -public: - Dialog(const char *name); - virtual ~Dialog(); - - virtual const char * getName() const; - - virtual bool addField(Field *field); - virtual Field * getField(const char *name) const; - virtual Field * getField(unsigned int pos) const; - virtual int getIndexOf(Field *field) const; - virtual unsigned int getFieldCount() const; - - virtual DialogInfo * getInfo(); - - virtual const Size & getSize() const; - virtual void setSize(const Size &size); - - virtual DialogState * createState(); - -private: - const std::string name; - std::vector fields; - DialogInfo info; - Size size; -}; - - -#endif // __DIALOG_H__ diff --git a/plugins/Skins/SkinLib/DialogInfo.cpp b/plugins/Skins/SkinLib/DialogInfo.cpp deleted file mode 100644 index fd29a37392..0000000000 --- a/plugins/Skins/SkinLib/DialogInfo.cpp +++ /dev/null @@ -1,190 +0,0 @@ -#include "globals.h" -#include "DialogInfo.h" -#include "tstring.h" - -class DialogInfoValue -{ -public: - DialogInfoValue(const char *aName) : name(aName), type(UNKNOWN) {} - - const char * getName() { return name.c_str(); } - - void set(const TCHAR *value) { valueString = value; type = TYPE_STRING; } - void set(int value) { valueInt = value; type = TYPE_INT; } - void set(double value) { valueDouble = value; type = TYPE_DOUBLE; } - void set(bool value) { valueBool = value; type = TYPE_BOOL; } - - DialogInfoType getType() { return type; } - - const TCHAR * getAsString() { return valueString.c_str(); } - int getAsInt() { return valueInt; } - double getAsDouble() { return valueDouble; } - bool getAsBool() { return valueBool; } - -private: - std::string name; - - DialogInfoType type; - - std::tstring valueString; - int valueInt; - double valueDouble; - bool valueBool; -}; - -DialogInfo::DialogInfo() -{ -} - -DialogInfo::~DialogInfo() -{ - for(size_t i = 0; i < values.size(); ++i) - delete values[i]; -} - - -void DialogInfo::set(const char *name, const TCHAR *value) -{ - bool isVar; - DialogInfoValue * val = findValue(name, true, &isVar); - - if (isVar) - return; - - val->set(value); -} - -void DialogInfo::set(const char *name, int value) -{ - bool isVar; - DialogInfoValue * val = findValue(name, true, &isVar); - - if (isVar) - return; - - val->set(value); -} - -void DialogInfo::set(const char *name, double value) -{ - bool isVar; - DialogInfoValue * val = findValue(name, true, &isVar); - - if (isVar) - return; - - val->set(value); -} - -void DialogInfo::set(const char *name, bool value) -{ - bool isVar; - DialogInfoValue * val = findValue(name, true, &isVar); - - if (isVar) - return; - - val->set(value); -} - -void DialogInfo::remove(const char *name) -{ - size_t len = strlen(name); - - for(std::vector::iterator it = values.begin(); it != values.end(); ) - { - DialogInfoValue *val = *it; - - if (stricmp(name, val->getName()) == 0) - it = values.erase(it); - - else if (strnicmp(name, val->getName(), len) == 0 && val->getName()[len] == '.') - it = values.erase(it); - - else - it++; - } -} - -DialogInfoType DialogInfo::getType(const char *name) -{ - bool isVar; - DialogInfoValue * val = findValue(name, false, &isVar); - - if (isVar) - return TYPE_VARIABLE; - - else if (val == NULL) - return UNKNOWN; - - else - return val->getType(); -} - - -const TCHAR * DialogInfo::getAsString(const char *name) -{ - DialogInfoValue * val = findValue(name); - if (val == NULL) - return NULL; - - return val->getAsString(); -} - -int DialogInfo::getAsInt(const char *name) -{ - DialogInfoValue * val = findValue(name); - if (val == NULL) - return 0; - - return val->getAsInt(); -} - -double DialogInfo::getAsDouble(const char *name) -{ - DialogInfoValue * val = findValue(name); - if (val == NULL) - return 0; - - return val->getAsDouble(); -} - -bool DialogInfo::getAsBool(const char *name) -{ - DialogInfoValue * val = findValue(name); - if (val == NULL) - return false; - - return val->getAsBool(); -} - -DialogInfoValue * DialogInfo::findValue(const char *name, bool create, bool *isVar) -{ - size_t len = strlen(name); - - if (isVar != NULL) *isVar = false; - - for(size_t i = 0; i < values.size(); ++i) - { - DialogInfoValue *val = values[i]; - - if (stricmp(name, val->getName()) == 0) - { - return val; - } - else if (strnicmp(name, val->getName(), len) == 0 && val->getName()[len] == '.') - { - if (isVar != NULL) *isVar = true; - return val; - } - } - - if (create) - { - DialogInfoValue *ret = new DialogInfoValue(name); - values.push_back(ret); - return ret; - } - - return NULL; -} diff --git a/plugins/Skins/SkinLib/DialogInfo.h b/plugins/Skins/SkinLib/DialogInfo.h deleted file mode 100644 index 02f07310d7..0000000000 --- a/plugins/Skins/SkinLib/DialogInfo.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef __DIALOG_INFO_H__ -# define __DIALOG_INFO_H__ - -#include -#include - - -enum DialogInfoType -{ - UNKNOWN = 0, - TYPE_VARIABLE, - TYPE_INT, - TYPE_DOUBLE, - TYPE_BOOL, - TYPE_STRING -}; - - -class DialogInfoValue; - -class DialogInfo -{ -public: - DialogInfo(); - ~DialogInfo(); - - void set(const char *name, const TCHAR *value); - void set(const char *name, int value); - void set(const char *name, double value); - void set(const char *name, bool value); - - void remove(const char *name); - - DialogInfoType getType(const char *name); - - const TCHAR * getAsString(const char *name); - int getAsInt(const char *name); - double getAsDouble(const char *name); - bool getAsBool(const char *name); - -private: - std::vector values; - - DialogInfoValue * findValue(const char *name, bool create = false, bool *isVar = NULL); - -}; - - - -#endif // __DIALOG_INFO_H__ \ No newline at end of file diff --git a/plugins/Skins/SkinLib/DialogState.cpp b/plugins/Skins/SkinLib/DialogState.cpp deleted file mode 100644 index e1e7654930..0000000000 --- a/plugins/Skins/SkinLib/DialogState.cpp +++ /dev/null @@ -1,132 +0,0 @@ -#include "globals.h" -#include "DialogState.h" - - -DialogState::DialogState(Dialog *aDialog) : dialog(aDialog), size(-1,-1), borders(0,0,0,0) -{ -} - -DialogState::~DialogState() -{ - for(unsigned int i = 0; i < fields.size(); i++) - delete fields[i]; - - fields.clear(); -} - -Dialog * DialogState::getDialog() const -{ - return dialog; -} - -FieldState * DialogState::getField(const char *name) const -{ - if (name == NULL || name[0] == 0) - return NULL; - - for(unsigned int i = 0; i < fields.size(); i++) - { - FieldState *field = fields[i]; - if (strcmp(name, field->getField()->getName()) == 0) - return field; - } - - return NULL; -} - -int DialogState::getX() const -{ - return 0; -} - -int DialogState::getY() const -{ - return 0; -} - -int DialogState::getLeft() const -{ - return getX(); -} - -int DialogState::getTop() const -{ - return getY(); -} - -int DialogState::getRight() const -{ - return getX() + getWidth(); -} - -int DialogState::getBottom() const -{ - return getY() + getHeight(); -} - -int DialogState::getWidth() const -{ - if (size.x >= 0) - return size.x - getHorizontalBorders(); - - return dialog->getSize().x - getHorizontalBorders(); -} - -void DialogState::setWidth(int width) -{ - size.x = max(0, width) + getHorizontalBorders(); -} - -int DialogState::getHeight() const -{ - if (size.y >= 0) - return size.y - getVerticalBorders(); - - return dialog->getSize().y - getVerticalBorders(); -} - -void DialogState::setHeight(int height) -{ - size.y = max(0, height) + getVerticalBorders(); -} - -BorderState * DialogState::getBorders() -{ - return &borders; -} - -const BorderState * DialogState::getBorders() const -{ - return &borders; -} - -int DialogState::getHorizontalBorders() const -{ - return borders.getLeft() + borders.getRight(); -} - -int DialogState::getVerticalBorders() const -{ - return borders.getTop() + borders.getBottom(); -} - -RECT DialogState::getInsideRect() const -{ - RECT ret; - ret.left = borders.getLeft(); - ret.right = ret.left + getWidth(); - ret.top = borders.getTop(); - ret.bottom = ret.top + getHeight(); - return ret; -} - -RECT DialogState::getRect() const -{ - RECT ret; - ret.left = 0; - ret.right = borders.getLeft() + getWidth() + borders.getRight(); - ret.top = 0; - ret.bottom = borders.getTop() + getHeight() + borders.getBottom(); - return ret; -} - diff --git a/plugins/Skins/SkinLib/DialogState.h b/plugins/Skins/SkinLib/DialogState.h deleted file mode 100644 index e27fc929da..0000000000 --- a/plugins/Skins/SkinLib/DialogState.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef __DIALOG_STATE_H__ -# define __DIALOG_STATE_H__ - -#include "Dialog.h" -#include "FieldState.h" -#include "BorderState.h" - - -/// This have to be deleted before the owning dialog -/// It is responsible for freeing the FieldStates -class DialogState -{ -public: - ~DialogState(); - - Dialog * getDialog() const; - - std::vector fields; - FieldState * getField(const char *name) const; - - // Used inside script - - virtual int getX() const; - virtual int getY() const; - virtual int getLeft() const; - virtual int getTop() const; - virtual int getRight() const; - virtual int getBottom() const; - - int getWidth() const; - void setWidth(int width); - - int getHeight() const; - void setHeight(int height); - - BorderState * getBorders(); - const BorderState * getBorders() const; - - // Results - - RECT getInsideRect() const; - RECT getRect() const; - -private: - DialogState(Dialog *dialog); - - Dialog *dialog; - - Size size; - BorderState borders; - - int getHorizontalBorders() const; - int getVerticalBorders() const; - - friend class Dialog; -}; - - -#endif // __DIALOG_STATE_H__ \ No newline at end of file diff --git a/plugins/Skins/SkinLib/DialogState_v8_wrapper.cpp b/plugins/Skins/SkinLib/DialogState_v8_wrapper.cpp deleted file mode 100644 index 5739414d69..0000000000 --- a/plugins/Skins/SkinLib/DialogState_v8_wrapper.cpp +++ /dev/null @@ -1,233 +0,0 @@ -#include "globals.h" -#include "DialogState_v8_wrapper.h" -#include -#include "DialogState.h" - -using namespace v8; - - -#ifdef UNICODE -# define V8_TCHAR uint16_t -#else -# define V8_TCHAR char -#endif - - -static Handle Get_DialogState_width(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - DialogState *tmp = (DialogState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( Int32::New(tmp->getWidth()) ); -} - -static void Set_DialogState_width(Local property, Local value, const AccessorInfo& info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return; - - DialogState *tmp = (DialogState *) wrap->Value(); - if (tmp == NULL) - return; - - if (!value.IsEmpty() && value->IsNumber()) - tmp->setWidth(value->Int32Value()); -} - - -static Handle Get_DialogState_height(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - DialogState *tmp = (DialogState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( Int32::New(tmp->getHeight()) ); -} - -static void Set_DialogState_height(Local property, Local value, const AccessorInfo& info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return; - - DialogState *tmp = (DialogState *) wrap->Value(); - if (tmp == NULL) - return; - - if (!value.IsEmpty() && value->IsNumber()) - tmp->setHeight(value->Int32Value()); -} - - -static Handle Get_DialogState_x(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - DialogState *tmp = (DialogState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( Int32::New(tmp->getX()) ); -} - - -static Handle Get_DialogState_y(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - DialogState *tmp = (DialogState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( Int32::New(tmp->getY()) ); -} - - -static Handle Get_DialogState_left(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - DialogState *tmp = (DialogState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( Int32::New(tmp->getLeft()) ); -} - - -static Handle Get_DialogState_top(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - DialogState *tmp = (DialogState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( Int32::New(tmp->getTop()) ); -} - - -static Handle Get_DialogState_right(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - DialogState *tmp = (DialogState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( Int32::New(tmp->getRight()) ); -} - - -static Handle Get_DialogState_bottom(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - DialogState *tmp = (DialogState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( Int32::New(tmp->getBottom()) ); -} - - -static Handle Get_DialogState_borders(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - DialogState *tmp = (DialogState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( self->Get(String::New("bordersRaw")) ); -} - -static void Set_DialogState_borders(Local property, Local value, const AccessorInfo& info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return; - - DialogState *tmp = (DialogState *) wrap->Value(); - if (tmp == NULL) - return; - - if (!value.IsEmpty() && value->IsInt32()) - tmp->getBorders()->setAll(value->Int32Value()); -} - - -void AddDialogStateAcessors(Handle &templ) -{ - HandleScope scope; - - templ->SetAccessor(String::New("width"), Get_DialogState_width, Set_DialogState_width); - templ->SetAccessor(String::New("height"), Get_DialogState_height, Set_DialogState_height); - templ->SetAccessor(String::New("x"), Get_DialogState_x, NULL, Handle(), DEFAULT, ReadOnly); - templ->SetAccessor(String::New("y"), Get_DialogState_y, NULL, Handle(), DEFAULT, ReadOnly); - templ->SetAccessor(String::New("left"), Get_DialogState_left, NULL, Handle(), DEFAULT, ReadOnly); - templ->SetAccessor(String::New("top"), Get_DialogState_top, NULL, Handle(), DEFAULT, ReadOnly); - templ->SetAccessor(String::New("right"), Get_DialogState_right, NULL, Handle(), DEFAULT, ReadOnly); - templ->SetAccessor(String::New("bottom"), Get_DialogState_bottom, NULL, Handle(), DEFAULT, ReadOnly); - templ->SetAccessor(String::New("borders"), Get_DialogState_borders, Set_DialogState_borders); -} diff --git a/plugins/Skins/SkinLib/DialogState_v8_wrapper.h b/plugins/Skins/SkinLib/DialogState_v8_wrapper.h deleted file mode 100644 index 709ef2d738..0000000000 --- a/plugins/Skins/SkinLib/DialogState_v8_wrapper.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef __DIALOG_STATE_V8_WRAPPER_H__ -# define __DIALOG_STATE_V8_WRAPPER_H__ - -#include - -void AddDialogStateAcessors(v8::Handle &templ); - - - -#endif // __DIALOG_STATE_V8_WRAPPER_H__ diff --git a/plugins/Skins/SkinLib/EditField.cpp b/plugins/Skins/SkinLib/EditField.cpp deleted file mode 100644 index 8eb0d5050f..0000000000 --- a/plugins/Skins/SkinLib/EditField.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "globals.h" -#include "EditField.h" -#include "EditFieldState.h" - - -EditField::EditField(Dialog *dlg, const char *name, HWND hwnd) - : ControlField(dlg, name, hwnd) -{ -} - -EditField::~EditField() -{ -} - -FieldType EditField::getType() const -{ - return CONTROL_EDIT; -} - -FieldState * EditField::createState(DialogState *dialogState) -{ - return new EditFieldState(dialogState, this); -} \ No newline at end of file diff --git a/plugins/Skins/SkinLib/EditField.h b/plugins/Skins/SkinLib/EditField.h deleted file mode 100644 index f69f23576c..0000000000 --- a/plugins/Skins/SkinLib/EditField.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef __EDIT_FIELD_H__ -# define __EDIT_FIELD_H__ - -#include "ControlField.h" - - -class EditField : public ControlField -{ -public: - EditField(Dialog *dlg, const char *name, HWND hwnd); - virtual ~EditField(); - - virtual FieldType getType() const; - - virtual FieldState * createState(DialogState *dialogState); -}; - - -#endif // __EDIT_FIELD_H__ diff --git a/plugins/Skins/SkinLib/EditFieldState.cpp b/plugins/Skins/SkinLib/EditFieldState.cpp deleted file mode 100644 index e634be7b55..0000000000 --- a/plugins/Skins/SkinLib/EditFieldState.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include "globals.h" -#include "EditFieldState.h" - - -EditFieldState::EditFieldState(DialogState *dialog, EditField *field) - : ControlFieldState(dialog, field) -{ -} - -EditFieldState::~EditFieldState() -{ -} - -Size EditFieldState::getPreferedSize() const -{ - ControlField *field = getField(); - HWND hwnd = field->getHWND(); - - int style = GetWindowLong(hwnd, GWL_STYLE); - int exstyle = GetWindowLong(hwnd, GWL_EXSTYLE); - - int format = DT_NOPREFIX | DT_EDITCONTROL; - if (!(style & ES_MULTILINE)) - format |= DT_SINGLELINE; - Size ret = getTextPreferedSize(format); - - RECT rc = {0}; - SetRect(&rc, 0, 0, ret.x, ret.y); - AdjustWindowRectEx(&rc, style, false, exstyle); - - bool hasHorScroll = field->isScrollVisible(true); - if (hasHorScroll) - rc.bottom += GetSystemMetrics(SM_CYHSCROLL); - if (field->isScrollVisible(false)) - rc.right += GetSystemMetrics(SM_CXVSCROLL); - - int margins = SendMessage(hwnd, EM_GETMARGINS, 0, 0); - rc.left -= LOWORD(margins); - rc.right += HIWORD(margins); - if (hasHorScroll || (style & ES_AUTOHSCROLL)) - rc.right++; - - ret.x = rc.right - rc.left; - ret.y = rc.bottom - rc.top; - - if ((exstyle & WS_EX_CLIENTEDGE) || (exstyle & WS_EX_STATICEDGE) || (style & WS_BORDER)) - { - ret.x += 3; - ret.y += 3; - } - - return ret; -} - -bool EditFieldState::isEmpty() const -{ - return false; -} \ No newline at end of file diff --git a/plugins/Skins/SkinLib/EditFieldState.h b/plugins/Skins/SkinLib/EditFieldState.h deleted file mode 100644 index c2372d553d..0000000000 --- a/plugins/Skins/SkinLib/EditFieldState.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef __EDIT_FIELD_STATE_H__ -# define __EDIT_FIELD_STATE_H__ - -#include "ControlFieldState.h" -#include "EditField.h" - - -class EditFieldState : public ControlFieldState -{ -public: - virtual ~EditFieldState(); - - virtual Size getPreferedSize() const; - - virtual bool isEmpty() const; - -private: - EditFieldState(DialogState *dialog, EditField *field); - - friend class EditField; -}; - - -#endif // __EDIT_FIELD_STATE_H__ diff --git a/plugins/Skins/SkinLib/EditFieldState_v8_wrapper.cpp b/plugins/Skins/SkinLib/EditFieldState_v8_wrapper.cpp deleted file mode 100644 index 86522b87e3..0000000000 --- a/plugins/Skins/SkinLib/EditFieldState_v8_wrapper.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "globals.h" -#include "EditFieldState_v8_wrapper.h" -#include -#include "EditFieldState.h" - -using namespace v8; - - -#ifdef UNICODE -# define V8_TCHAR uint16_t -#else -# define V8_TCHAR char -#endif - - -void AddEditFieldStateAcessors(Handle &templ) -{ - HandleScope scope; - -} diff --git a/plugins/Skins/SkinLib/EditFieldState_v8_wrapper.h b/plugins/Skins/SkinLib/EditFieldState_v8_wrapper.h deleted file mode 100644 index a58972549f..0000000000 --- a/plugins/Skins/SkinLib/EditFieldState_v8_wrapper.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef __EDIT_FIELD_STATE_V8_WRAPPER_H__ -# define __EDIT_FIELD_STATE_V8_WRAPPER_H__ - -#include - -void AddEditFieldStateAcessors(v8::Handle &templ); - - - -#endif // __EDIT_FIELD_STATE_V8_WRAPPER_H__ diff --git a/plugins/Skins/SkinLib/Field.cpp b/plugins/Skins/SkinLib/Field.cpp deleted file mode 100644 index 24b823bde6..0000000000 --- a/plugins/Skins/SkinLib/Field.cpp +++ /dev/null @@ -1,56 +0,0 @@ -#include "globals.h" -#include "Field.h" -#include "FieldState.h" - - -Field::Field(Dialog *aDlg, const char *aName) - : dlg(aDlg), name(aName), onChangeCallback(NULL), onChangeCallbackParam(NULL), enabled(true) -{ -} - -Field::~Field() -{ -} - -Dialog * Field::getDialog() const -{ - return dlg; -} - -const char * Field::getName() const -{ - return name.c_str(); -} - -bool Field::isEnabled() const -{ - return enabled; -} - -void Field::setEnabled(bool enabled) -{ - this->enabled = enabled; - fireOnChange(); -} - -const TCHAR * Field::getToolTip() const -{ - return tooltip.c_str(); -} - -void Field::setToolTip(const TCHAR *tooltip) -{ - this->tooltip = tooltip; -} - -void Field::setOnChangeCallback(FieldCallback cb, void *param /*= NULL*/) -{ - onChangeCallback = cb; - onChangeCallbackParam = param; -} - -void Field::fireOnChange() const -{ - if (onChangeCallback != NULL) - onChangeCallback(onChangeCallbackParam, this); -} diff --git a/plugins/Skins/SkinLib/Field.h b/plugins/Skins/SkinLib/Field.h deleted file mode 100644 index 4cf7faaa51..0000000000 --- a/plugins/Skins/SkinLib/Field.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef __FIELD_H__ -# define __FIELD_H__ - -#include -#include -#include "tstring.h" -#include "Size.h" -#include "Position.h" - - -enum FieldType -{ - SIMPLE_TEXT = 1, - SIMPLE_IMAGE, - SIMPLE_ICON, - CONTROL_LABEL, - CONTROL_BUTTON, - CONTROL_EDIT, - USER_DEFINED = 0x100 -}; - -class Dialog; -class DialogState; -class Field; -class FieldState; - -typedef void (*FieldCallback)(void *param, const Field *field); - - -class Field -{ -public: - Field(Dialog *dlg, const char *name); - virtual ~Field(); - - virtual Dialog * getDialog() const; - virtual const char * getName() const; - virtual FieldType getType() const = 0; - - virtual bool isEnabled() const; - virtual void setEnabled(bool enabled); - - virtual const TCHAR * getToolTip() const; - virtual void setToolTip(const TCHAR *tooltip); - - virtual FieldState * createState(DialogState *dialogState) = 0; - - virtual void setOnChangeCallback(FieldCallback cb, void *param = NULL); - -protected: - void fireOnChange() const; - -private: - Dialog *dlg; - const std::string name; - bool enabled; - std::tstring tooltip; - - FieldCallback onChangeCallback; - void *onChangeCallbackParam; -}; - - - - -#endif // __FIELD_H__ \ No newline at end of file diff --git a/plugins/Skins/SkinLib/FieldState.cpp b/plugins/Skins/SkinLib/FieldState.cpp deleted file mode 100644 index 68510051da..0000000000 --- a/plugins/Skins/SkinLib/FieldState.cpp +++ /dev/null @@ -1,303 +0,0 @@ -#include "globals.h" -#include "FieldState.h" -#include "DialogState.h" -#include "BorderState.h" - -#define START 1<<0 -#define LEN 1<<1 -#define END 1<<2 -#define USING_MASK 0xFF -#define LAST_SHIFT 8 -#define SET(_FIELD_, _ITEM_) _FIELD_ = (((_FIELD_ | _ITEM_) & USING_MASK) | (_ITEM_ << LAST_SHIFT)) -#define LAST_SET(_FIELD_) (_FIELD_ >> LAST_SHIFT) - - -FieldState::FieldState(DialogState *aDialog, Field *aField) - : field(aField), dialog(aDialog), size(-1, -1), pos(0, 0), - usingX(0), usingY(0), visible(aField->isEnabled()), borders(0,0,0,0), - tooltipSet(false), halign(HORIZONTAL_ALIGN_LEFT), valign(VERTICAL_ALIGN_TOP) -{ -} - -FieldState::~FieldState() -{ -} - -Field * FieldState::getField() const -{ - return field; -} - -DialogState * FieldState::getDialog() const -{ - return dialog; -} - -int FieldState::getX() const -{ - return pos.x; -} - -void FieldState::setX(int x) -{ - if (usingX & END) - { - int diff = x - getX(); - size.x = max(0, getWidth() - getHorizontalBorders() - diff); - } - - pos.x = x; - - SET(usingX, START); -} - -int FieldState::getY() const -{ - return pos.y; -} - -void FieldState::setY(int y) -{ - if (usingY & END) - { - int diff = y - getY(); - size.y = max(0, getHeight() - getVerticalBorders() - diff); - } - - pos.y = y; - - SET(usingY, START); -} - -int FieldState::getWidth() const -{ - if (size.x >= 0) - return size.x + getHorizontalBorders(); - - return getPreferedSize().x + getHorizontalBorders(); -} - -void FieldState::setWidth(int width) -{ - width = max(0, width - getHorizontalBorders()) + getHorizontalBorders(); - - if (LAST_SET(usingX) == END) - { - int diff = width - getWidth(); - pos.x = getX() - diff; - } - - size.x = width - getHorizontalBorders(); - - usingX |= LEN; -} - -int FieldState::getHeight() const -{ - if (size.y >= 0) - return size.y + getVerticalBorders(); - - return getPreferedSize().y + getVerticalBorders(); -} - -void FieldState::setHeight(int height) -{ - height = max(0, height - getVerticalBorders()) + getVerticalBorders(); - - if (LAST_SET(usingY) == END) - { - int diff = height - getHeight(); - pos.y = getY() - diff; - } - - size.y = height - getVerticalBorders(); - - usingY |= LEN; -} - -bool FieldState::isVisible() const -{ - if (!visible) - return false; - - RECT rc = getRect(); - if (rc.right <= rc.left || rc.bottom <= rc.top) - return false; - - return true; -} - -void FieldState::setVisible(bool visible) -{ - this->visible = visible; -} - -bool FieldState::isEnabled() const -{ - return field->isEnabled(); -} - -int FieldState::getLeft() const -{ - return getX(); -} - -void FieldState::setLeft(int left) -{ - setX(left); -} - -int FieldState::getTop() const -{ - return getY(); -} - -void FieldState::setTop(int top) -{ - setY(top); -} - -int FieldState::getRight() const -{ - return getX() + getWidth(); -} - -void FieldState::setRight(int right) -{ - if (usingX & START) - { - size.x = max(0, right - getX()); - } - else - { - pos.x = right - getWidth(); - } - - SET(usingX, END); -} - -int FieldState::getBottom() const -{ - return getY() + getHeight(); -} - -void FieldState::setBottom(int botom) -{ - if (usingY & START) - { - size.y = max(0, botom - getY()); - } - else - { - pos.y = botom - getHeight(); - } - - SET(usingY, END); -} - -const TCHAR * FieldState::getToolTip() const -{ - if (tooltipSet) - return tooltip.c_str(); - else - return field->getToolTip(); -} - -void FieldState::setToolTip(const TCHAR *tooltip) -{ - this->tooltip = tooltip; - tooltipSet = true; -} - -BorderState * FieldState::getBorders() -{ - return &borders; -} - -const BorderState * FieldState::getBorders() const -{ - return &borders; -} - -int FieldState::getHorizontalBorders() const -{ - return borders.getLeft() + borders.getRight(); -} - -int FieldState::getVerticalBorders() const -{ - return borders.getTop() + borders.getBottom(); -} - -static inline int beetween(int val, int minVal, int maxVal) -{ - return max(minVal, min(maxVal, val)); -} - -static inline void intersection(RECT &main, const RECT &other) -{ - main.left = beetween(main.left, other.left, other.right); - main.right = beetween(main.right, other.left, other.right); - main.top = beetween(main.top, other.top, other.bottom); - main.bottom = beetween(main.bottom, other.top, other.bottom); -} - -RECT FieldState::getRect(bool raw) const -{ - RECT ret = {0}; - - if (!visible) - return ret; - - RECT inside = dialog->getInsideRect(); - - ret.left = getLeft() + inside.left; - ret.right = getRight() + inside.left; - ret.top = getTop() + inside.top; - ret.bottom = getBottom() + inside.top; - - if (!raw) - intersection(ret, inside); - - return ret; -} - -RECT FieldState::getInsideRect(bool raw) const -{ - RECT ret = {0}; - - if (!visible) - return ret; - - RECT inside = dialog->getInsideRect(); - - ret.left = getLeft() + borders.getLeft() + inside.left; - ret.right = getRight() - borders.getRight() + inside.left; - ret.top = getTop() + borders.getTop() + inside.top; - ret.bottom = getBottom() - borders.getBottom() + inside.top; - - if (!raw) - intersection(ret, inside); - - return ret; -} - -HORIZONTAL_ALIGN FieldState::getHAlign() const -{ - return halign; -} - -void FieldState::setHAlign(HORIZONTAL_ALIGN halign) -{ - this->halign = halign; -} - -VERTICAL_ALIGN FieldState::getVAlign() const -{ - return valign; -} - -void FieldState::setVAlign(VERTICAL_ALIGN valign) -{ - this->valign = valign; -} diff --git a/plugins/Skins/SkinLib/FieldState.h b/plugins/Skins/SkinLib/FieldState.h deleted file mode 100644 index d7c552105f..0000000000 --- a/plugins/Skins/SkinLib/FieldState.h +++ /dev/null @@ -1,108 +0,0 @@ -#ifndef __FIELD_STATE_H__ -# define __FIELD_STATE_H__ - -#include "Field.h" -#include "BorderState.h" - -class DialogState; - -enum HORIZONTAL_ALIGN -{ - HORIZONTAL_ALIGN_LEFT = 1, - HORIZONTAL_ALIGN_CENTER, - HORIZONTAL_ALIGN_RIGHT -}; - -enum VERTICAL_ALIGN -{ - VERTICAL_ALIGN_TOP = 1, - VERTICAL_ALIGN_CENTER, - VERTICAL_ALIGN_BOTTOM -}; - - -class FieldState -{ -public: - virtual ~FieldState(); - - virtual Field * getField() const; - virtual DialogState * getDialog() const; - - virtual Size getPreferedSize() const = 0; - - // Used inside script - - virtual int getX() const; - virtual void setX(int x); - - virtual int getY() const; - virtual void setY(int y); - - virtual int getWidth() const; - virtual void setWidth(int width); - - virtual int getHeight() const; - virtual void setHeight(int height); - - virtual int getLeft() const; - virtual void setLeft(int left); - - virtual int getTop() const; - virtual void setTop(int top); - - virtual int getRight() const; - virtual void setRight(int right); - - virtual int getBottom() const; - virtual void setBottom(int bottom); - - virtual bool isVisible() const; - virtual void setVisible(bool visible); - - virtual bool isEnabled() const; - - virtual const TCHAR * getToolTip() const; - virtual void setToolTip(const TCHAR *tooltip); - - virtual BorderState * getBorders(); - virtual const BorderState * getBorders() const; - - virtual HORIZONTAL_ALIGN getHAlign() const; - virtual void setHAlign(HORIZONTAL_ALIGN halign); - - virtual VERTICAL_ALIGN getVAlign() const; - virtual void setVAlign(VERTICAL_ALIGN valign); - - virtual bool isEmpty() const = 0; - - // Results - - virtual RECT getInsideRect(bool raw = false) const; - virtual RECT getRect(bool raw = false) const; - -protected: - FieldState(DialogState *dialog, Field *field); - - Field *field; - DialogState *dialog; - - Size size; - Position pos; - int usingX; - int usingY; - bool visible; - BorderState borders; - bool tooltipSet; - std::tstring tooltip; - HORIZONTAL_ALIGN halign; - VERTICAL_ALIGN valign; - - int getHorizontalBorders() const; - int getVerticalBorders() const; - - friend class Field; -}; - - -#endif // __FIELD_STATE_H__ diff --git a/plugins/Skins/SkinLib/FieldState.rec b/plugins/Skins/SkinLib/FieldState.rec deleted file mode 100644 index 7b9ffd890d..0000000000 --- a/plugins/Skins/SkinLib/FieldState.rec +++ /dev/null @@ -1,89 +0,0 @@ -struct DialogState -{ - Int32 width; - Int32 height; - const Int32 x; - const Int32 y; - const Int32 left; - const Int32 top; - const Int32 right; - const Int32 bottom; - BorderState borders [setter: if (!value.IsEmpty() && value->IsInt32())\n\ttmp->getBorders()->setAll(value->Int32Value()); ]; -}; - -struct FieldState -{ - Int32 x; - Int32 y; - Int32 width; - Int32 height; - Int32 left; - Int32 top; - Int32 right; - Int32 bottom; - Boolean visible; - const Boolean enabled; - Char toolTip[128]; - Int32 hAlign | HORIZONTAL_ALIGN_LEFT "LEFT" | HORIZONTAL_ALIGN_CENTER "CENTER" | HORIZONTAL_ALIGN_RIGHT "RIGHT"; - Int32 vAlign | VERTICAL_ALIGN_TOP "TOP" | VERTICAL_ALIGN_CENTER "CENTER" | VERTICAL_ALIGN_BOTTOM "BOTTOM"; - BorderState borders [setter: if (!value.IsEmpty() && value->IsInt32())\n\ttmp->getBorders()->setAll(value->Int32Value()); ]; -}; - -struct ControlFieldState : FieldState -{ - Char text[1024]; - FontState font; -}; - -struct LabelFieldState : ControlFieldState -{ -}; - -struct ButtonFieldState : ControlFieldState -{ -}; - -struct EditFieldState : ControlFieldState -{ -}; - -struct IconFieldState : FieldState -{ -}; - -struct ImageFieldState : FieldState -{ -}; - -struct TextFieldState : FieldState -{ - Char text[1024]; - FontState font; -}; - -struct FontState -{ - Char face[32]; - Int32 size; - Boolean italic; - Boolean bold; - Boolean underline; - Boolean strikeOut; - Int32 color; -}; - -struct BorderState -{ - Int32 left; - Int32 right; - Int32 top; - Int32 bottom; -}; - -struct SkinOption -{ - Char description[128]; - Int32 min; - Int32 max; - Int32 type | CHECKBOX | NUMBER | TEXT; -}; diff --git a/plugins/Skins/SkinLib/FieldState_v8_wrapper.cpp b/plugins/Skins/SkinLib/FieldState_v8_wrapper.cpp deleted file mode 100644 index 937ad69a58..0000000000 --- a/plugins/Skins/SkinLib/FieldState_v8_wrapper.cpp +++ /dev/null @@ -1,539 +0,0 @@ -#include "globals.h" -#include "FieldState_v8_wrapper.h" -#include -#include "FieldState.h" -#include - -using namespace v8; - - -#ifdef UNICODE -# define V8_TCHAR uint16_t -#else -# define V8_TCHAR char -#endif - - -static Handle Get_FieldState_x(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - FieldState *tmp = (FieldState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( Int32::New(tmp->getX()) ); -} - -static void Set_FieldState_x(Local property, Local value, const AccessorInfo& info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return; - - FieldState *tmp = (FieldState *) wrap->Value(); - if (tmp == NULL) - return; - - if (!value.IsEmpty() && value->IsNumber()) - tmp->setX(value->Int32Value()); -} - - -static Handle Get_FieldState_y(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - FieldState *tmp = (FieldState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( Int32::New(tmp->getY()) ); -} - -static void Set_FieldState_y(Local property, Local value, const AccessorInfo& info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return; - - FieldState *tmp = (FieldState *) wrap->Value(); - if (tmp == NULL) - return; - - if (!value.IsEmpty() && value->IsNumber()) - tmp->setY(value->Int32Value()); -} - - -static Handle Get_FieldState_width(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - FieldState *tmp = (FieldState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( Int32::New(tmp->getWidth()) ); -} - -static void Set_FieldState_width(Local property, Local value, const AccessorInfo& info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return; - - FieldState *tmp = (FieldState *) wrap->Value(); - if (tmp == NULL) - return; - - if (!value.IsEmpty() && value->IsNumber()) - tmp->setWidth(value->Int32Value()); -} - - -static Handle Get_FieldState_height(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - FieldState *tmp = (FieldState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( Int32::New(tmp->getHeight()) ); -} - -static void Set_FieldState_height(Local property, Local value, const AccessorInfo& info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return; - - FieldState *tmp = (FieldState *) wrap->Value(); - if (tmp == NULL) - return; - - if (!value.IsEmpty() && value->IsNumber()) - tmp->setHeight(value->Int32Value()); -} - - -static Handle Get_FieldState_left(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - FieldState *tmp = (FieldState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( Int32::New(tmp->getLeft()) ); -} - -static void Set_FieldState_left(Local property, Local value, const AccessorInfo& info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return; - - FieldState *tmp = (FieldState *) wrap->Value(); - if (tmp == NULL) - return; - - if (!value.IsEmpty() && value->IsNumber()) - tmp->setLeft(value->Int32Value()); -} - - -static Handle Get_FieldState_top(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - FieldState *tmp = (FieldState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( Int32::New(tmp->getTop()) ); -} - -static void Set_FieldState_top(Local property, Local value, const AccessorInfo& info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return; - - FieldState *tmp = (FieldState *) wrap->Value(); - if (tmp == NULL) - return; - - if (!value.IsEmpty() && value->IsNumber()) - tmp->setTop(value->Int32Value()); -} - - -static Handle Get_FieldState_right(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - FieldState *tmp = (FieldState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( Int32::New(tmp->getRight()) ); -} - -static void Set_FieldState_right(Local property, Local value, const AccessorInfo& info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return; - - FieldState *tmp = (FieldState *) wrap->Value(); - if (tmp == NULL) - return; - - if (!value.IsEmpty() && value->IsNumber()) - tmp->setRight(value->Int32Value()); -} - - -static Handle Get_FieldState_bottom(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - FieldState *tmp = (FieldState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( Int32::New(tmp->getBottom()) ); -} - -static void Set_FieldState_bottom(Local property, Local value, const AccessorInfo& info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return; - - FieldState *tmp = (FieldState *) wrap->Value(); - if (tmp == NULL) - return; - - if (!value.IsEmpty() && value->IsNumber()) - tmp->setBottom(value->Int32Value()); -} - - -static Handle Get_FieldState_visible(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - FieldState *tmp = (FieldState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( Boolean::New(tmp->isVisible()) ); -} - -static void Set_FieldState_visible(Local property, Local value, const AccessorInfo& info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return; - - FieldState *tmp = (FieldState *) wrap->Value(); - if (tmp == NULL) - return; - - if (!value.IsEmpty() && value->IsBoolean()) - tmp->setVisible(value->BooleanValue()); -} - - -static Handle Get_FieldState_enabled(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - FieldState *tmp = (FieldState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( Boolean::New(tmp->isEnabled()) ); -} - - -static Handle Get_FieldState_toolTip(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - FieldState *tmp = (FieldState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( String::New((const V8_TCHAR *) tmp->getToolTip()) ); -} - -static void Set_FieldState_toolTip(Local property, Local value, const AccessorInfo& info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return; - - FieldState *tmp = (FieldState *) wrap->Value(); - if (tmp == NULL) - return; - - if (!value.IsEmpty() && value->IsString()) - { - String::Utf8Value utf8_value(value); - tmp->setToolTip(Utf8ToTchar(*utf8_value)); - } -} - - -static Handle Get_FieldState_hAlign(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - FieldState *tmp = (FieldState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - switch(tmp->getHAlign()) - { - case HORIZONTAL_ALIGN_LEFT: return scope.Close( String::New((const V8_TCHAR *) _T("LEFT")) ); - case HORIZONTAL_ALIGN_CENTER: return scope.Close( String::New((const V8_TCHAR *) _T("CENTER")) ); - case HORIZONTAL_ALIGN_RIGHT: return scope.Close( String::New((const V8_TCHAR *) _T("RIGHT")) ); - } - return scope.Close( Undefined() ); -} - -static void Set_FieldState_hAlign(Local property, Local value, const AccessorInfo& info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return; - - FieldState *tmp = (FieldState *) wrap->Value(); - if (tmp == NULL) - return; - - if (!value.IsEmpty() && value->IsString()) - { - String::Utf8Value utf8_value(value); - Utf8ToTchar tval(*utf8_value); - if ( lstrcmpi(_T("HORIZONTAL_ALIGN_LEFT"), tval) == 0 ) - tmp->setHAlign(HORIZONTAL_ALIGN_LEFT); - else if ( lstrcmpi(_T("LEFT"), tval) == 0 ) - tmp->setHAlign(HORIZONTAL_ALIGN_LEFT); - else if ( lstrcmpi(_T("HORIZONTAL_ALIGN_CENTER"), tval) == 0 ) - tmp->setHAlign(HORIZONTAL_ALIGN_CENTER); - else if ( lstrcmpi(_T("CENTER"), tval) == 0 ) - tmp->setHAlign(HORIZONTAL_ALIGN_CENTER); - else if ( lstrcmpi(_T("HORIZONTAL_ALIGN_RIGHT"), tval) == 0 ) - tmp->setHAlign(HORIZONTAL_ALIGN_RIGHT); - else if ( lstrcmpi(_T("RIGHT"), tval) == 0 ) - tmp->setHAlign(HORIZONTAL_ALIGN_RIGHT); - } -} - - -static Handle Get_FieldState_vAlign(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - FieldState *tmp = (FieldState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - switch(tmp->getVAlign()) - { - case VERTICAL_ALIGN_TOP: return scope.Close( String::New((const V8_TCHAR *) _T("TOP")) ); - case VERTICAL_ALIGN_CENTER: return scope.Close( String::New((const V8_TCHAR *) _T("CENTER")) ); - case VERTICAL_ALIGN_BOTTOM: return scope.Close( String::New((const V8_TCHAR *) _T("BOTTOM")) ); - } - return scope.Close( Undefined() ); -} - -static void Set_FieldState_vAlign(Local property, Local value, const AccessorInfo& info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return; - - FieldState *tmp = (FieldState *) wrap->Value(); - if (tmp == NULL) - return; - - if (!value.IsEmpty() && value->IsString()) - { - String::Utf8Value utf8_value(value); - Utf8ToTchar tval(*utf8_value); - if ( lstrcmpi(_T("VERTICAL_ALIGN_TOP"), tval) == 0 ) - tmp->setVAlign(VERTICAL_ALIGN_TOP); - else if ( lstrcmpi(_T("TOP"), tval) == 0 ) - tmp->setVAlign(VERTICAL_ALIGN_TOP); - else if ( lstrcmpi(_T("VERTICAL_ALIGN_CENTER"), tval) == 0 ) - tmp->setVAlign(VERTICAL_ALIGN_CENTER); - else if ( lstrcmpi(_T("CENTER"), tval) == 0 ) - tmp->setVAlign(VERTICAL_ALIGN_CENTER); - else if ( lstrcmpi(_T("VERTICAL_ALIGN_BOTTOM"), tval) == 0 ) - tmp->setVAlign(VERTICAL_ALIGN_BOTTOM); - else if ( lstrcmpi(_T("BOTTOM"), tval) == 0 ) - tmp->setVAlign(VERTICAL_ALIGN_BOTTOM); - } -} - - -static Handle Get_FieldState_borders(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - FieldState *tmp = (FieldState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( self->Get(String::New("bordersRaw")) ); -} - -static void Set_FieldState_borders(Local property, Local value, const AccessorInfo& info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return; - - FieldState *tmp = (FieldState *) wrap->Value(); - if (tmp == NULL) - return; - - if (!value.IsEmpty() && value->IsInt32()) - tmp->getBorders()->setAll(value->Int32Value()); -} - - -void AddFieldStateAcessors(Handle &templ) -{ - HandleScope scope; - - templ->SetAccessor(String::New("x"), Get_FieldState_x, Set_FieldState_x); - templ->SetAccessor(String::New("y"), Get_FieldState_y, Set_FieldState_y); - templ->SetAccessor(String::New("width"), Get_FieldState_width, Set_FieldState_width); - templ->SetAccessor(String::New("height"), Get_FieldState_height, Set_FieldState_height); - templ->SetAccessor(String::New("left"), Get_FieldState_left, Set_FieldState_left); - templ->SetAccessor(String::New("top"), Get_FieldState_top, Set_FieldState_top); - templ->SetAccessor(String::New("right"), Get_FieldState_right, Set_FieldState_right); - templ->SetAccessor(String::New("bottom"), Get_FieldState_bottom, Set_FieldState_bottom); - templ->SetAccessor(String::New("visible"), Get_FieldState_visible, Set_FieldState_visible); - templ->SetAccessor(String::New("enabled"), Get_FieldState_enabled, NULL, Handle(), DEFAULT, ReadOnly); - templ->SetAccessor(String::New("toolTip"), Get_FieldState_toolTip, Set_FieldState_toolTip); - templ->SetAccessor(String::New("hAlign"), Get_FieldState_hAlign, Set_FieldState_hAlign); - templ->SetAccessor(String::New("vAlign"), Get_FieldState_vAlign, Set_FieldState_vAlign); - templ->SetAccessor(String::New("borders"), Get_FieldState_borders, Set_FieldState_borders); -} diff --git a/plugins/Skins/SkinLib/FieldState_v8_wrapper.h b/plugins/Skins/SkinLib/FieldState_v8_wrapper.h deleted file mode 100644 index 10c2a854b4..0000000000 --- a/plugins/Skins/SkinLib/FieldState_v8_wrapper.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef __FIELD_STATE_V8_WRAPPER_H__ -# define __FIELD_STATE_V8_WRAPPER_H__ - -#include - -void AddFieldStateAcessors(v8::Handle &templ); - - - -#endif // __FIELD_STATE_V8_WRAPPER_H__ diff --git a/plugins/Skins/SkinLib/FontState.cpp b/plugins/Skins/SkinLib/FontState.cpp deleted file mode 100644 index da9b4153d5..0000000000 --- a/plugins/Skins/SkinLib/FontState.cpp +++ /dev/null @@ -1,186 +0,0 @@ -#include "globals.h" -#include "FontState.h" - - -FontState::FontState(HFONT hFont, COLORREF aColor) : hFont(NULL), externalFont(false), color(aColor) -{ - setHFONT(hFont); -} - -FontState::~FontState() -{ - releaseHFONT(); -} - -void FontState::rebuildHFONT() -{ - releaseHFONT(); - buildHFONT(); -} - -void FontState::buildAttribs() -{ - LOGFONT lf = {0}; - if (hFont == NULL || GetObject(hFont, sizeof(lf), &lf) == 0) - { - face = _T("Tahoma"); - size = 9; - italic = false; - bold = false; - underline = false; - strikeout = false; - - rebuildHFONT(); - - return; - } - - face = lf.lfFaceName; - italic = (lf.lfItalic != 0); - bold = (lf.lfWeight > FW_NORMAL); - underline = (lf.lfUnderline != 0); - strikeout = (lf.lfStrikeOut != 0); - - HDC hdc = GetDC(NULL); - size = -MulDiv(lf.lfHeight, 72, GetDeviceCaps(hdc, LOGPIXELSY)); - ReleaseDC(NULL, hdc); -} - -void FontState::buildHFONT() -{ - if (hFont != NULL) - return; - - LOGFONT lf; - - _tcscpy(lf.lfFaceName, getFace()); - - lf.lfWidth = lf.lfEscapement = lf.lfOrientation = 0; - lf.lfWeight = isBold() ? FW_BOLD : FW_NORMAL; - lf.lfItalic = isItalic() ? 1 : 0; - lf.lfUnderline = isUnderline() ? 1 : 0; - lf.lfStrikeOut = isStrikeOut() ? 1 : 0; - lf.lfCharSet = DEFAULT_CHARSET; - lf.lfOutPrecision = OUT_DEFAULT_PRECIS; - lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; - lf.lfQuality = DEFAULT_QUALITY; - lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; - - HDC hdc = GetDC(NULL); - lf.lfHeight = -MulDiv(getSize(), GetDeviceCaps(hdc, LOGPIXELSY), 72); - ReleaseDC(NULL, hdc); - - hFont = CreateFontIndirect(&lf); - externalFont = false; -} - -void FontState::releaseHFONT() -{ - if (hFont == NULL) - return; - - if (!externalFont) - DeleteObject(hFont); - - hFont = NULL; -} - - -HFONT FontState::getHFONT() const -{ - return hFont; -} - - -HFONT FontState::createHFONT() const -{ - LOGFONT lf; - if (hFont == NULL || GetObject(hFont, sizeof(lf), &lf) == 0) - return NULL; - else - return CreateFontIndirect(&lf); -} - -void FontState::setHFONT(HFONT hFont) -{ - releaseHFONT(); - this->hFont = hFont; - externalFont = true; - buildAttribs(); -} - -const TCHAR * FontState::getFace() const -{ - return face.c_str(); -} - -void FontState::setFace(const TCHAR * face) -{ - this->face = face; - rebuildHFONT(); -} - -int FontState::getSize() const -{ - return size; -} - -void FontState::setSize(int size) -{ - this->size = size; - rebuildHFONT(); -} - -COLORREF FontState::getColor() const -{ - return color; -} - -void FontState::setColor(COLORREF color) -{ - this->color = color; -} - -bool FontState::isItalic() const -{ - return italic; -} - -void FontState::setItalic(bool italic) -{ - this->italic = italic; - rebuildHFONT(); -} - -bool FontState::isBold() const -{ - return bold; -} - -void FontState::setBold(bool bold) -{ - this->bold = bold; - rebuildHFONT(); -} - -bool FontState::isUnderline() const -{ - return underline; -} - -void FontState::setUnderline(bool underline) -{ - this->underline = underline; - rebuildHFONT(); -} - -bool FontState::isStrikeOut() const -{ - return strikeout; -} - -void FontState::setStrikeOut(bool strikeout) -{ - this->strikeout = strikeout; - rebuildHFONT(); -} diff --git a/plugins/Skins/SkinLib/FontState.h b/plugins/Skins/SkinLib/FontState.h deleted file mode 100644 index de32bcdfb3..0000000000 --- a/plugins/Skins/SkinLib/FontState.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef __FONT_STATE_H__ -# define __FONT_STATE_H__ - -#include "Field.h" - - -class FontState -{ -public: - FontState(HFONT hFont, COLORREF aColor); - ~FontState(); - - HFONT getHFONT() const; - void setHFONT(HFONT hFont); - HFONT createHFONT() const; /// Return a copy of the internal HFONT. The caller must free it - - const TCHAR * getFace() const; - void setFace(const TCHAR * face); - - int getSize() const; - void setSize(int size); - - COLORREF getColor() const; - void setColor(COLORREF color); - - bool isItalic() const; - void setItalic(bool italic); - - bool isBold() const; - void setBold(bool bold); - - bool isUnderline() const; - void setUnderline(bool underline); - - bool isStrikeOut() const; - void setStrikeOut(bool strikeout); - -private: - COLORREF color; - HFONT hFont; - bool externalFont; - std::tstring face; - int size; - bool italic; - bool bold; - bool underline; - bool strikeout; - - void rebuildHFONT(); - void buildHFONT(); - void releaseHFONT(); - void buildAttribs(); -}; - - - -#endif // __FONT_STATE_H__ diff --git a/plugins/Skins/SkinLib/FontState_v8_wrapper.cpp b/plugins/Skins/SkinLib/FontState_v8_wrapper.cpp deleted file mode 100644 index 5226736b24..0000000000 --- a/plugins/Skins/SkinLib/FontState_v8_wrapper.cpp +++ /dev/null @@ -1,269 +0,0 @@ -#include "globals.h" -#include "FontState_v8_wrapper.h" -#include -#include "FontState.h" -#include - -using namespace v8; - - -#ifdef UNICODE -# define V8_TCHAR uint16_t -#else -# define V8_TCHAR char -#endif - - -static Handle Get_FontState_face(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - FontState *tmp = (FontState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( String::New((const V8_TCHAR *) tmp->getFace()) ); -} - -static void Set_FontState_face(Local property, Local value, const AccessorInfo& info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return; - - FontState *tmp = (FontState *) wrap->Value(); - if (tmp == NULL) - return; - - if (!value.IsEmpty() && value->IsString()) - { - String::Utf8Value utf8_value(value); - tmp->setFace(Utf8ToTchar(*utf8_value)); - } -} - - -static Handle Get_FontState_size(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - FontState *tmp = (FontState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( Int32::New(tmp->getSize()) ); -} - -static void Set_FontState_size(Local property, Local value, const AccessorInfo& info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return; - - FontState *tmp = (FontState *) wrap->Value(); - if (tmp == NULL) - return; - - if (!value.IsEmpty() && value->IsNumber()) - tmp->setSize(value->Int32Value()); -} - - -static Handle Get_FontState_italic(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - FontState *tmp = (FontState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( Boolean::New(tmp->isItalic()) ); -} - -static void Set_FontState_italic(Local property, Local value, const AccessorInfo& info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return; - - FontState *tmp = (FontState *) wrap->Value(); - if (tmp == NULL) - return; - - if (!value.IsEmpty() && value->IsBoolean()) - tmp->setItalic(value->BooleanValue()); -} - - -static Handle Get_FontState_bold(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - FontState *tmp = (FontState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( Boolean::New(tmp->isBold()) ); -} - -static void Set_FontState_bold(Local property, Local value, const AccessorInfo& info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return; - - FontState *tmp = (FontState *) wrap->Value(); - if (tmp == NULL) - return; - - if (!value.IsEmpty() && value->IsBoolean()) - tmp->setBold(value->BooleanValue()); -} - - -static Handle Get_FontState_underline(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - FontState *tmp = (FontState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( Boolean::New(tmp->isUnderline()) ); -} - -static void Set_FontState_underline(Local property, Local value, const AccessorInfo& info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return; - - FontState *tmp = (FontState *) wrap->Value(); - if (tmp == NULL) - return; - - if (!value.IsEmpty() && value->IsBoolean()) - tmp->setUnderline(value->BooleanValue()); -} - - -static Handle Get_FontState_strikeOut(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - FontState *tmp = (FontState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( Boolean::New(tmp->isStrikeOut()) ); -} - -static void Set_FontState_strikeOut(Local property, Local value, const AccessorInfo& info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return; - - FontState *tmp = (FontState *) wrap->Value(); - if (tmp == NULL) - return; - - if (!value.IsEmpty() && value->IsBoolean()) - tmp->setStrikeOut(value->BooleanValue()); -} - - -static Handle Get_FontState_color(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - FontState *tmp = (FontState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( Int32::New(tmp->getColor()) ); -} - -static void Set_FontState_color(Local property, Local value, const AccessorInfo& info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return; - - FontState *tmp = (FontState *) wrap->Value(); - if (tmp == NULL) - return; - - if (!value.IsEmpty() && value->IsNumber()) - tmp->setColor(value->Int32Value()); -} - - -void AddFontStateAcessors(Handle &templ) -{ - HandleScope scope; - - templ->SetAccessor(String::New("face"), Get_FontState_face, Set_FontState_face); - templ->SetAccessor(String::New("size"), Get_FontState_size, Set_FontState_size); - templ->SetAccessor(String::New("italic"), Get_FontState_italic, Set_FontState_italic); - templ->SetAccessor(String::New("bold"), Get_FontState_bold, Set_FontState_bold); - templ->SetAccessor(String::New("underline"), Get_FontState_underline, Set_FontState_underline); - templ->SetAccessor(String::New("strikeOut"), Get_FontState_strikeOut, Set_FontState_strikeOut); - templ->SetAccessor(String::New("color"), Get_FontState_color, Set_FontState_color); -} diff --git a/plugins/Skins/SkinLib/FontState_v8_wrapper.h b/plugins/Skins/SkinLib/FontState_v8_wrapper.h deleted file mode 100644 index 4b0483ffd9..0000000000 --- a/plugins/Skins/SkinLib/FontState_v8_wrapper.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef __FONT_STATE_V8_WRAPPER_H__ -# define __FONT_STATE_V8_WRAPPER_H__ - -#include - -void AddFontStateAcessors(v8::Handle &templ); - - - -#endif // __FONT_STATE_V8_WRAPPER_H__ diff --git a/plugins/Skins/SkinLib/IconField.cpp b/plugins/Skins/SkinLib/IconField.cpp deleted file mode 100644 index 4cf1aaf532..0000000000 --- a/plugins/Skins/SkinLib/IconField.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "globals.h" -#include "IconField.h" -#include "IconFieldState.h" - - -IconField::IconField(Dialog *dlg, const char *name) - : Field(dlg, name), hIcon(NULL) -{ - -} - -IconField::~IconField() -{ -} - -FieldType IconField::getType() const -{ - return SIMPLE_ICON; -} - -HICON IconField::getIcon() const -{ - return hIcon; -} - -void IconField::setIcon(HICON hIcon) -{ - if (this->hIcon == hIcon) - return; - - this->hIcon = hIcon; - fireOnChange(); -} - -FieldState * IconField::createState(DialogState *dialogState) -{ - return new IconFieldState(dialogState, this); -} \ No newline at end of file diff --git a/plugins/Skins/SkinLib/IconField.h b/plugins/Skins/SkinLib/IconField.h deleted file mode 100644 index 984b36b984..0000000000 --- a/plugins/Skins/SkinLib/IconField.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef __ICON_FIELD_H__ -# define __ICON_FIELD_H__ - -#include "Field.h" - - -class IconField : public Field -{ -public: - IconField(Dialog *dlg, const char *name); - virtual ~IconField(); - - virtual FieldType getType() const; - - virtual HICON getIcon() const; - virtual void setIcon(HICON hIcon); - - virtual FieldState * createState(DialogState *dialogState); - -private: - HICON hIcon; - -}; - - - -#endif // __ICON_FIELD_H__ \ No newline at end of file diff --git a/plugins/Skins/SkinLib/IconFieldState.cpp b/plugins/Skins/SkinLib/IconFieldState.cpp deleted file mode 100644 index fad1d67084..0000000000 --- a/plugins/Skins/SkinLib/IconFieldState.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "globals.h" -#include "IconFieldState.h" - -#define ICON_SIZE 16 - - -IconFieldState::IconFieldState(DialogState *dialog, IconField *field) - : FieldState(dialog, field) -{ -} - -IconFieldState::~IconFieldState() -{ -} - -IconField * IconFieldState::getField() const -{ - return (IconField *) FieldState::getField(); -} - -Size IconFieldState::getPreferedSize() const -{ - if (getIcon() == NULL) - return Size(0, 0); - - return Size(ICON_SIZE, ICON_SIZE); -} - -HICON IconFieldState::getIcon() const -{ - return getField()->getIcon(); -} - -bool IconFieldState::isEmpty() const -{ - return getIcon() == NULL; -} \ No newline at end of file diff --git a/plugins/Skins/SkinLib/IconFieldState.h b/plugins/Skins/SkinLib/IconFieldState.h deleted file mode 100644 index b69e3fe01f..0000000000 --- a/plugins/Skins/SkinLib/IconFieldState.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef __ICON_FIELD_STATE_H__ -# define __ICON_FIELD_STATE_H__ - -#include "IconField.h" -#include "FieldState.h" - - -class IconFieldState : public FieldState -{ -public: - virtual ~IconFieldState(); - - virtual IconField * getField() const; - - virtual Size getPreferedSize() const; - - virtual HICON getIcon() const; - - virtual bool isEmpty() const; - -private: - IconFieldState(DialogState *dialog, IconField *field); - - friend class IconField; -}; - - -#endif // __ICON_FIELD_STATE_H__ \ No newline at end of file diff --git a/plugins/Skins/SkinLib/IconFieldState_v8_wrapper.cpp b/plugins/Skins/SkinLib/IconFieldState_v8_wrapper.cpp deleted file mode 100644 index a955653652..0000000000 --- a/plugins/Skins/SkinLib/IconFieldState_v8_wrapper.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "globals.h" -#include "IconFieldState_v8_wrapper.h" -#include -#include "IconFieldState.h" - -using namespace v8; - - -#ifdef UNICODE -# define V8_TCHAR uint16_t -#else -# define V8_TCHAR char -#endif - - -void AddIconFieldStateAcessors(Handle &templ) -{ - HandleScope scope; - -} diff --git a/plugins/Skins/SkinLib/IconFieldState_v8_wrapper.h b/plugins/Skins/SkinLib/IconFieldState_v8_wrapper.h deleted file mode 100644 index 7b63f801bc..0000000000 --- a/plugins/Skins/SkinLib/IconFieldState_v8_wrapper.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef __ICON_FIELD_STATE_V8_WRAPPER_H__ -# define __ICON_FIELD_STATE_V8_WRAPPER_H__ - -#include - -void AddIconFieldStateAcessors(v8::Handle &templ); - - - -#endif // __ICON_FIELD_STATE_V8_WRAPPER_H__ diff --git a/plugins/Skins/SkinLib/ImageField.cpp b/plugins/Skins/SkinLib/ImageField.cpp deleted file mode 100644 index c65cf99a0f..0000000000 --- a/plugins/Skins/SkinLib/ImageField.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "globals.h" -#include "ImageField.h" -#include "ImageFieldState.h" - - -ImageField::ImageField(Dialog *dlg, const char *name) - : Field(dlg, name), hBmp(NULL) -{ - -} - -ImageField::~ImageField() -{ -} - -FieldType ImageField::getType() const -{ - return SIMPLE_IMAGE; -} - -HBITMAP ImageField::getImage() const -{ - return hBmp; -} - -void ImageField::setImage(HBITMAP hBmp) -{ - if (this->hBmp == hBmp) - return; - - this->hBmp = hBmp; - fireOnChange(); -} - -FieldState * ImageField::createState(DialogState *dialogState) -{ - return new ImageFieldState(dialogState, this); -} \ No newline at end of file diff --git a/plugins/Skins/SkinLib/ImageField.h b/plugins/Skins/SkinLib/ImageField.h deleted file mode 100644 index e2f08665ca..0000000000 --- a/plugins/Skins/SkinLib/ImageField.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef __IMAGE_FIELD_H__ -# define __IMAGE_FIELD_H__ - -#include "Field.h" - -class ImageField : public Field -{ -public: - ImageField(Dialog *dlg, const char *name); - virtual ~ImageField(); - - virtual FieldType getType() const; - - virtual HBITMAP getImage() const; - virtual void setImage(HBITMAP hBmp); - - virtual FieldState * createState(DialogState *dialogState); - -private: - HBITMAP hBmp; - -}; - - - -#endif // __IMAGE_FIELD_H__ \ No newline at end of file diff --git a/plugins/Skins/SkinLib/ImageFieldState.cpp b/plugins/Skins/SkinLib/ImageFieldState.cpp deleted file mode 100644 index f74d77e0f3..0000000000 --- a/plugins/Skins/SkinLib/ImageFieldState.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "globals.h" -#include "ImageFieldState.h" - - -ImageFieldState::ImageFieldState(DialogState *dialog, ImageField *field) - : FieldState(dialog, field) -{ -} - -ImageFieldState::~ImageFieldState() -{ -} - -ImageField * ImageFieldState::getField() const -{ - return (ImageField *) FieldState::getField(); -} - -Size ImageFieldState::getPreferedSize() const -{ - HBITMAP hBmp = getImage(); - BITMAP bmp; - if (hBmp == NULL || GetObject(hBmp, sizeof(bmp), &bmp) == 0) - return Size(0, 0); - - return Size(bmp.bmWidth, bmp.bmHeight); -} - -HBITMAP ImageFieldState::getImage() const -{ - return getField()->getImage(); -} - -bool ImageFieldState::isEmpty() const -{ - return getImage() == NULL; -} \ No newline at end of file diff --git a/plugins/Skins/SkinLib/ImageFieldState.h b/plugins/Skins/SkinLib/ImageFieldState.h deleted file mode 100644 index 493c4db16d..0000000000 --- a/plugins/Skins/SkinLib/ImageFieldState.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef __IMAGE_FIELD_STATE_H__ -# define __IMAGE_FIELD_STATE_H__ - -#include "ImageField.h" -#include "FieldState.h" - - -class ImageFieldState : public FieldState -{ -public: - virtual ~ImageFieldState(); - - virtual ImageField * getField() const; - - virtual Size getPreferedSize() const; - - virtual HBITMAP getImage() const; - - virtual bool isEmpty() const; - -private: - ImageFieldState(DialogState *dialog, ImageField *field); - - friend class ImageField; -}; - - -#endif // __IMAGE_FIELD_STATE_H__ \ No newline at end of file diff --git a/plugins/Skins/SkinLib/ImageFieldState_v8_wrapper.cpp b/plugins/Skins/SkinLib/ImageFieldState_v8_wrapper.cpp deleted file mode 100644 index 1e4a9b6a54..0000000000 --- a/plugins/Skins/SkinLib/ImageFieldState_v8_wrapper.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "globals.h" -#include "ImageFieldState_v8_wrapper.h" -#include -#include "ImageFieldState.h" - -using namespace v8; - - -#ifdef UNICODE -# define V8_TCHAR uint16_t -#else -# define V8_TCHAR char -#endif - - -void AddImageFieldStateAcessors(Handle &templ) -{ - HandleScope scope; - -} diff --git a/plugins/Skins/SkinLib/ImageFieldState_v8_wrapper.h b/plugins/Skins/SkinLib/ImageFieldState_v8_wrapper.h deleted file mode 100644 index ea5f343e03..0000000000 --- a/plugins/Skins/SkinLib/ImageFieldState_v8_wrapper.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef __IMAGE_FIELD_STATE_V8_WRAPPER_H__ -# define __IMAGE_FIELD_STATE_V8_WRAPPER_H__ - -#include - -void AddImageFieldStateAcessors(v8::Handle &templ); - - - -#endif // __IMAGE_FIELD_STATE_V8_WRAPPER_H__ diff --git a/plugins/Skins/SkinLib/LabelField.cpp b/plugins/Skins/SkinLib/LabelField.cpp deleted file mode 100644 index 154ae2fce5..0000000000 --- a/plugins/Skins/SkinLib/LabelField.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "globals.h" -#include "LabelField.h" -#include "LabelFieldState.h" - - -LabelField::LabelField(Dialog *dlg, const char *name, HWND hwnd) - : ControlField(dlg, name, hwnd) -{ -} - -LabelField::~LabelField() -{ -} - -FieldType LabelField::getType() const -{ - return CONTROL_LABEL; -} - -FieldState * LabelField::createState(DialogState *dialogState) -{ - return new LabelFieldState(dialogState, this); -} \ No newline at end of file diff --git a/plugins/Skins/SkinLib/LabelField.h b/plugins/Skins/SkinLib/LabelField.h deleted file mode 100644 index 8c4cb04a03..0000000000 --- a/plugins/Skins/SkinLib/LabelField.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef __LABEL_FIELD_H__ -# define __LABEL_FIELD_H__ - -#include "ControlField.h" - - -class LabelField : public ControlField -{ -public: - LabelField(Dialog *dlg, const char *name, HWND hwnd); - virtual ~LabelField(); - - virtual FieldType getType() const; - - virtual FieldState * createState(DialogState *dialogState); -}; - - - -#endif // __LABEL_FIELD_H__ diff --git a/plugins/Skins/SkinLib/LabelFieldState.cpp b/plugins/Skins/SkinLib/LabelFieldState.cpp deleted file mode 100644 index 364611fbf7..0000000000 --- a/plugins/Skins/SkinLib/LabelFieldState.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "globals.h" -#include "LabelFieldState.h" - - -LabelFieldState::LabelFieldState(DialogState *dialog, LabelField *field) - : ControlFieldState(dialog, field) -{ -} - -LabelFieldState::~LabelFieldState() -{ -} - -Size LabelFieldState::getPreferedSize() const -{ - int style = GetWindowLong(getField()->getHWND(), GWL_STYLE); - - int format = DT_EXPANDTABS | DT_EDITCONTROL; - if ((style & SS_LEFTNOWORDWRAP) || (style & SS_SIMPLE)) - format |= DT_SINGLELINE; - if (style & SS_NOPREFIX) - format |= DT_NOPREFIX; - Size ret = getTextPreferedSize(format); - - int border = getField()->getBorderSize(); - ret.x += 2 * border; - ret.y += 2 * border; - - return ret; -} - -bool LabelFieldState::isEmpty() const -{ - return lstrlen(getText()) <= 0; -} \ No newline at end of file diff --git a/plugins/Skins/SkinLib/LabelFieldState.h b/plugins/Skins/SkinLib/LabelFieldState.h deleted file mode 100644 index dbbb3b04d3..0000000000 --- a/plugins/Skins/SkinLib/LabelFieldState.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __LABEL_FIELD_STATE_H__ -# define __LABEL_FIELD_STATE_H__ - -#include "ControlFieldState.h" -#include "LabelField.h" - - -class LabelFieldState : public ControlFieldState -{ -public: - virtual ~LabelFieldState(); - - virtual Size getPreferedSize() const; - - virtual bool isEmpty() const; - -private: - LabelFieldState(DialogState *dialog, LabelField *field); - - friend class LabelField; -}; - - - -#endif // __LABEL_FIELD_STATE_H__ diff --git a/plugins/Skins/SkinLib/LabelFieldState_v8_wrapper.cpp b/plugins/Skins/SkinLib/LabelFieldState_v8_wrapper.cpp deleted file mode 100644 index 9105a7d878..0000000000 --- a/plugins/Skins/SkinLib/LabelFieldState_v8_wrapper.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "globals.h" -#include "LabelFieldState_v8_wrapper.h" -#include -#include "LabelFieldState.h" - -using namespace v8; - - -#ifdef UNICODE -# define V8_TCHAR uint16_t -#else -# define V8_TCHAR char -#endif - - -void AddLabelFieldStateAcessors(Handle &templ) -{ - HandleScope scope; - -} diff --git a/plugins/Skins/SkinLib/LabelFieldState_v8_wrapper.h b/plugins/Skins/SkinLib/LabelFieldState_v8_wrapper.h deleted file mode 100644 index 7d40de5bc2..0000000000 --- a/plugins/Skins/SkinLib/LabelFieldState_v8_wrapper.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef __LABEL_FIELD_STATE_V8_WRAPPER_H__ -# define __LABEL_FIELD_STATE_V8_WRAPPER_H__ - -#include - -void AddLabelFieldStateAcessors(v8::Handle &templ); - - - -#endif // __LABEL_FIELD_STATE_V8_WRAPPER_H__ diff --git a/plugins/Skins/SkinLib/Position.cpp b/plugins/Skins/SkinLib/Position.cpp deleted file mode 100644 index 6c68881fce..0000000000 --- a/plugins/Skins/SkinLib/Position.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "Position.h" - -Position::Position() : x(0), y(0) -{ -} - -Position::Position(int aX, int aY) : x(aX), y(aY) -{ -} \ No newline at end of file diff --git a/plugins/Skins/SkinLib/Position.h b/plugins/Skins/SkinLib/Position.h deleted file mode 100644 index ed43a1ece3..0000000000 --- a/plugins/Skins/SkinLib/Position.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef __POSITION_H__ -# define __POSITION_H__ - - -struct Position -{ - int x; - int y; - - Position(); - Position(int x, int y); -}; - - - -#endif // __POSITION_H__ diff --git a/plugins/Skins/SkinLib/Size.cpp b/plugins/Skins/SkinLib/Size.cpp deleted file mode 100644 index 9c2eef5d5d..0000000000 --- a/plugins/Skins/SkinLib/Size.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include "globals.h" -#include "Size.h" - -Size::Size() : x(0), y(0) -{ -} - -Size::Size(int aX, int aY) : x(aX), y(aY) -{ - -} - -int Size::resizeTo(int newX, int newY) -{ - if (newX < 0 && newY < 0) - return -1; - - if (newY < 0) - { - if (x < 0 || y < 0) - return -2; - - y = (int) (y * (newX / (float) x)); - x = newX; - } - else if (newX < 0) - { - if (x < 0 || y < 0) - return -2; - - x = (int) (x * (newY / (float) y)); - y = newY; - } - else - { - x = newX; - y = newY; - } - return 0; -} - -int Size::fitInside(int maxSize) -{ - if (x < 0 || y < 0) - return -2; - if (x <= maxSize && y <= maxSize) - return 0; - - if (x >= y) - { - y = (int) (y * (maxSize / (float) x)); - x = maxSize; - } - else - { - x = (int) (x * (maxSize / (float) y)); - y = maxSize; - } - return 0; -} - -int Size::scaleTo(int size) -{ - if (x < 0 || y < 0) - return -2; - - if (x >= y) - { - y = (int) (y * (size / (float) x)); - x = size; - } - else - { - x = (int) (x * (size / (float) y)); - y = size; - } - - return 0; -} - -bool Size::operator==(const Size &other) const -{ - return x == other.x && y == other.y; -} \ No newline at end of file diff --git a/plugins/Skins/SkinLib/Size.h b/plugins/Skins/SkinLib/Size.h deleted file mode 100644 index 8c0a297aee..0000000000 --- a/plugins/Skins/SkinLib/Size.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef __SIZE_H__ -# define __SIZE_H__ - - -struct Size -{ - int x; - int y; - - Size(); - Size(int aX, int aY); - - /// @return 0 on success - int resizeTo(int x, int y); - - /// @return 0 on success - int fitInside(int maxSize); - - /// @return 0 on success - int scaleTo(int size); - - bool operator==(const Size &other) const; -}; - - - -#endif // __SIZE_H__ diff --git a/plugins/Skins/SkinLib/SkinOption.h b/plugins/Skins/SkinLib/SkinOption.h deleted file mode 100644 index 7812303327..0000000000 --- a/plugins/Skins/SkinLib/SkinOption.h +++ /dev/null @@ -1 +0,0 @@ -#include "SkinOptions.h" \ No newline at end of file diff --git a/plugins/Skins/SkinLib/SkinOption_v8_wrapper.cpp b/plugins/Skins/SkinLib/SkinOption_v8_wrapper.cpp deleted file mode 100644 index 11a401ad2e..0000000000 --- a/plugins/Skins/SkinLib/SkinOption_v8_wrapper.cpp +++ /dev/null @@ -1,179 +0,0 @@ -#include "globals.h" -#include "SkinOption_v8_wrapper.h" -#include -#include "SkinOption.h" -#include - -using namespace v8; - - -#ifdef UNICODE -# define V8_TCHAR uint16_t -#else -# define V8_TCHAR char -#endif - - -static Handle Get_SkinOption_description(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - SkinOption *tmp = (SkinOption *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( String::New((const V8_TCHAR *) tmp->getDescription()) ); -} - -static void Set_SkinOption_description(Local property, Local value, const AccessorInfo& info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return; - - SkinOption *tmp = (SkinOption *) wrap->Value(); - if (tmp == NULL) - return; - - if (!value.IsEmpty() && value->IsString()) - { - String::Utf8Value utf8_value(value); - tmp->setDescription(Utf8ToTchar(*utf8_value)); - } -} - - -static Handle Get_SkinOption_min(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - SkinOption *tmp = (SkinOption *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( Int32::New(tmp->getMin()) ); -} - -static void Set_SkinOption_min(Local property, Local value, const AccessorInfo& info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return; - - SkinOption *tmp = (SkinOption *) wrap->Value(); - if (tmp == NULL) - return; - - if (!value.IsEmpty() && value->IsNumber()) - tmp->setMin(value->Int32Value()); -} - - -static Handle Get_SkinOption_max(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - SkinOption *tmp = (SkinOption *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( Int32::New(tmp->getMax()) ); -} - -static void Set_SkinOption_max(Local property, Local value, const AccessorInfo& info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return; - - SkinOption *tmp = (SkinOption *) wrap->Value(); - if (tmp == NULL) - return; - - if (!value.IsEmpty() && value->IsNumber()) - tmp->setMax(value->Int32Value()); -} - - -static Handle Get_SkinOption_type(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - SkinOption *tmp = (SkinOption *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - switch(tmp->getType()) - { - case CHECKBOX: return scope.Close( String::New((const V8_TCHAR *) _T("CHECKBOX")) ); - case NUMBER: return scope.Close( String::New((const V8_TCHAR *) _T("NUMBER")) ); - case TEXT: return scope.Close( String::New((const V8_TCHAR *) _T("TEXT")) ); - } - return scope.Close( Undefined() ); -} - -static void Set_SkinOption_type(Local property, Local value, const AccessorInfo& info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return; - - SkinOption *tmp = (SkinOption *) wrap->Value(); - if (tmp == NULL) - return; - - if (!value.IsEmpty() && value->IsString()) - { - String::Utf8Value utf8_value(value); - Utf8ToTchar tval(*utf8_value); - if ( lstrcmpi(_T("CHECKBOX"), tval) == 0 ) - tmp->setType(CHECKBOX); - else if ( lstrcmpi(_T("NUMBER"), tval) == 0 ) - tmp->setType(NUMBER); - else if ( lstrcmpi(_T("TEXT"), tval) == 0 ) - tmp->setType(TEXT); - } -} - - -void AddSkinOptionAcessors(Handle &templ) -{ - HandleScope scope; - - templ->SetAccessor(String::New("description"), Get_SkinOption_description, Set_SkinOption_description); - templ->SetAccessor(String::New("min"), Get_SkinOption_min, Set_SkinOption_min); - templ->SetAccessor(String::New("max"), Get_SkinOption_max, Set_SkinOption_max); - templ->SetAccessor(String::New("type"), Get_SkinOption_type, Set_SkinOption_type); -} diff --git a/plugins/Skins/SkinLib/SkinOption_v8_wrapper.h b/plugins/Skins/SkinLib/SkinOption_v8_wrapper.h deleted file mode 100644 index 6aa05c2122..0000000000 --- a/plugins/Skins/SkinLib/SkinOption_v8_wrapper.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef __SKIN_OPTION_V8_WRAPPER_H__ -# define __SKIN_OPTION_V8_WRAPPER_H__ - -#include - -void AddSkinOptionAcessors(v8::Handle &templ); - - - -#endif // __SKIN_OPTION_V8_WRAPPER_H__ diff --git a/plugins/Skins/SkinLib/SkinOptions.cpp b/plugins/Skins/SkinLib/SkinOptions.cpp deleted file mode 100644 index 51fb96cbdb..0000000000 --- a/plugins/Skins/SkinLib/SkinOptions.cpp +++ /dev/null @@ -1,216 +0,0 @@ -#include "globals.h" -#include "SkinOptions.h" -#include - - -SkinOption::SkinOption(const char *aName) - : name(aName), type(CHECKBOX), valueCheckbox(false), valueNumber(0), - onChangeCallback(NULL), onChangeCallbackParam(NULL), - minValue(MININT), maxValue(MAXINT) -{ - description = Utf8ToTchar(aName); -} - -SkinOption::~SkinOption() -{ -} - -const char * SkinOption::getName() const -{ - return name.c_str(); -} - -SkinOptionType SkinOption::getType() const -{ - return type; -} - -void SkinOption::setType(SkinOptionType type) -{ - if (this->type == type) - return; - - this->type = type; - fireOnChange(); -} - -const TCHAR * SkinOption::getDescription() const -{ - return description.c_str(); -} - -void SkinOption::setDescription(const TCHAR * description) -{ - if (this->description == description) - return; - - this->description = description; - fireOnChange(); -} - -int SkinOption::getMax() const -{ - return maxValue; -} - -void SkinOption::setMax(int max) -{ - this->maxValue = max; - setValueNumber(valueNumber); -} - -int SkinOption::getMin() const -{ - return minValue; -} - -void SkinOption::setMin(int min) -{ - this->minValue = min; - setValueNumber(valueNumber); -} - -bool SkinOption::getValueCheckbox() const -{ - return valueCheckbox; -} - -void SkinOption::setValueCheckbox(bool value) -{ - if (valueCheckbox == value) - return; - - valueCheckbox = value; - fireOnChange(); -} - -int SkinOption::getValueNumber() const -{ - return max(minValue, min(maxValue, valueNumber)); -} - -void SkinOption::setValueNumber(int value) -{ - value = max(minValue, min(maxValue, value)); - - if (value == valueNumber) - return; - - valueNumber = value; - fireOnChange(); -} - -const TCHAR * SkinOption::getValueText() const -{ - return valueText.c_str(); -} - -void SkinOption::setValueText(const TCHAR * value) -{ - if (valueText == value) - return; - - valueText = value; - fireOnChange(); -} - -void SkinOption::setOnChangeCallback(SkinOptionCallback cb, void *param /*= NULL*/) -{ - onChangeCallback = cb; - onChangeCallbackParam = param; -} - -void SkinOption::fireOnChange() -{ - if (onChangeCallback != NULL) - onChangeCallback(onChangeCallbackParam, this); -} - - - -SkinOptions::SkinOptions() - : onAddRemoveCallback(NULL), onAddRemoveCallbackParam(NULL), - onChangeCallback(NULL), onChangeCallbackParam(NULL) -{ -} - -SkinOptions::~SkinOptions() -{ - for(unsigned int i = 0; i < options.size(); i++) - delete options[i]; - options.clear(); -} - -bool SkinOptions::addOption(SkinOption *opt) -{ - _ASSERT(opt != NULL); - _ASSERT(opt->getName() != NULL); - - if (getOption(opt->getName()) != NULL) - return false; - - opt->setOnChangeCallback(onChangeCallback, onChangeCallbackParam); - options.push_back(opt); - - fireOnAddRemove(opt); - return true; -} - -SkinOption * SkinOptions::getOption(const char *name) const -{ - _ASSERT(name != NULL); - - for(unsigned int i = 0; i < options.size(); i++) - { - SkinOption *opt = options[i]; - if (strcmp(opt->getName(), name) == 0) - return opt; - } - return NULL; -} - -SkinOption * SkinOptions::getOption(unsigned int pos) const -{ - if (pos >= options.size()) - return NULL; - return options[pos]; -} - -unsigned int SkinOptions::getNumOptions() const -{ - return options.size(); -} - -void SkinOptions::clearOptions() -{ - if (options.size() <= 0) - return; - - for(unsigned int i = 0; i < options.size(); i++) - { - fireOnAddRemove(options[i]); - delete options[i]; - } - options.clear(); -} - -void SkinOptions::setOnOptionAddRemoveCallback(SkinOptionCallback cb, void *param /*= NULL*/) -{ - onAddRemoveCallback = cb; - onAddRemoveCallbackParam = param; -} - -void SkinOptions::setOnOptionChangeCallback(SkinOptionCallback cb, void *param /*= NULL*/) -{ - onChangeCallback = cb; - onChangeCallbackParam = param; - - for(unsigned int i = 0; i < options.size(); i++) - options[i]->setOnChangeCallback(cb, param); -} - -void SkinOptions::fireOnAddRemove(SkinOption *opt) -{ - if (onAddRemoveCallback != NULL) - onAddRemoveCallback(onAddRemoveCallbackParam, opt); -} diff --git a/plugins/Skins/SkinLib/SkinOptions.h b/plugins/Skins/SkinLib/SkinOptions.h deleted file mode 100644 index 41d238a5a1..0000000000 --- a/plugins/Skins/SkinLib/SkinOptions.h +++ /dev/null @@ -1,98 +0,0 @@ -#ifndef __SKINNED_DIALOG_OPTIONS_H__ -# define __SKINNED_DIALOG_OPTIONS_H__ - -#include -#include "tstring.h" -#include - - -enum SkinOptionType -{ - CHECKBOX, - NUMBER, - TEXT -}; - -class SkinOption; - -typedef void (*SkinOptionCallback)(void *param, const SkinOption *opt); - - -class SkinOption -{ -public: - SkinOption(const char *name); - ~SkinOption(); - - const char * getName() const; - - SkinOptionType getType() const; - void setType(SkinOptionType type); - - const TCHAR * getDescription() const; - void setDescription(const TCHAR * description); - - int getMax() const; - void setMax(int max); - - int getMin() const; - void setMin(int min); - - bool getValueCheckbox() const; - void setValueCheckbox(bool value); - - int getValueNumber() const; - void setValueNumber(int value); - - const TCHAR * getValueText() const; - void setValueText(const TCHAR * value); - - void setOnChangeCallback(SkinOptionCallback cb, void *param = NULL); - -private: - std::string name; - SkinOptionType type; - std::tstring description; - bool valueCheckbox; - int valueNumber; - int minValue; - int maxValue; - std::tstring valueText; - - SkinOptionCallback onChangeCallback; - void * onChangeCallbackParam; - - void fireOnChange(); -}; - - -class SkinOptions -{ -public: - SkinOptions(); - ~SkinOptions(); - - bool addOption(SkinOption *opt); - SkinOption * getOption(const char *name) const; - SkinOption * getOption(unsigned int pos) const; - unsigned int getNumOptions() const; - void clearOptions(); - - void setOnOptionAddRemoveCallback(SkinOptionCallback cb, void *param = NULL); - void setOnOptionChangeCallback(SkinOptionCallback cb, void *param = NULL); - -private: - std::vector options; - - SkinOptionCallback onAddRemoveCallback; - void * onAddRemoveCallbackParam; - - SkinOptionCallback onChangeCallback; - void * onChangeCallbackParam; - - void fireOnAddRemove(SkinOption *opt); -}; - - - -#endif // __SKINNED_DIALOG_OPTIONS_H__ diff --git a/plugins/Skins/SkinLib/SkinnedDialog.cpp b/plugins/Skins/SkinLib/SkinnedDialog.cpp deleted file mode 100644 index 917193ad94..0000000000 --- a/plugins/Skins/SkinLib/SkinnedDialog.cpp +++ /dev/null @@ -1,235 +0,0 @@ -#include "globals.h" -#include "SkinnedDialog.h" - -#include -#include "V8Script.h" -#include -#include "SkinOptions.h" - - -SkinnedDialog::SkinnedDialog(const char *name) - : Dialog(name), fileChangedTime(0), - script(NULL), state(NULL), opts(NULL), defaultState(NULL), - errorCallback(NULL), errorCallbackParam(NULL), - traceCallback(NULL), traceCallbackParam(NULL) -{ - V8Script::initializeEngine(); -} - -SkinnedDialog::~SkinnedDialog() -{ - releaseState(); - releaseCompiledScript(); -} - -const TCHAR * SkinnedDialog::getFilename() const -{ - return filename.c_str(); -} - -void SkinnedDialog::setFilename(const TCHAR *filename) -{ - if (this->filename == filename) - return; - - this->filename = filename; - releaseState(); - releaseCompiledScript(); -} - -bool SkinnedDialog::addField(Field *field) -{ - if (Dialog::addField(field)) - { - releaseCompiledScript(); - releaseState(); - field->setOnChangeCallback(SkinnedDialog::staticOnFieldChange, this); - return true; - } - else - return false; -} - -void SkinnedDialog::setSize(const Size &size) -{ - if (getSize() == size) - return; - - Dialog::setSize(size); - releaseState(); -} - -int SkinnedDialog::compile() -{ - if (!fileChanged()) - return 1; - - releaseCompiledScript(); - - struct _stat st = {0}; - if (_tstat(filename.c_str(), &st) != 0) - return 0; - - std::tstring text; - readFile(text); - if (text.size() <= 0) - return 0; - - script = new V8Script(); - script->setExceptionCallback(errorCallback, errorCallbackParam); - - if (!script->compile(text.c_str(), this)) - { - releaseCompiledScript(); - return 0; - } - - std::pair pair = script->configure(this); - opts = pair.first; - defaultState = pair.second; - if (opts == NULL) - { - releaseCompiledScript(); - return 0; - } - - fileChangedTime = st.st_mtime; - - return 2; -} - -DialogState * SkinnedDialog::getState() -{ - if (state != NULL && !fileChanged()) - return state; - - releaseState(); - - if (filename.size() <= 0) - return NULL; - - if (!compile()) - return NULL; - - state = Dialog::createState(); - if (!script->run(state, opts, getInfo())) - { - releaseState(); - return NULL; - } - - return state; -} - -void SkinnedDialog::releaseCompiledScript() -{ - delete script; - script = NULL; - fileChangedTime = 0; - - delete opts; - opts = NULL; - - delete defaultState; - defaultState = NULL; -} - -void SkinnedDialog::releaseState() -{ - delete state; - state = NULL; -} - -bool SkinnedDialog::fileChanged() -{ - if (filename.size() <= 0) - return false; - - struct _stat st = {0}; - if (_tstat(filename.c_str(), &st) != 0) - return false; - - return st.st_mtime > fileChangedTime; -} - -void SkinnedDialog::readFile(std::tstring &ret) -{ - FILE* file = _tfopen(filename.c_str(), _T("rb")); - if (file == NULL) - return; - - fseek(file, 0, SEEK_END); - int size = ftell(file); - rewind(file); - - char* chars = new char[size + 1]; - chars[size] = '\0'; - for (int i = 0; i < size;) - { - int read = fread(&chars[i], 1, size - i, file); - i += read; - } - fclose(file); - - ret = Utf8ToTchar(chars); - - delete[] chars; -} - -void SkinnedDialog::onFieldChange(const Field *field) -{ - releaseState(); -} - - -void SkinnedDialog::staticOnFieldChange(void *param, const Field *field) -{ - _ASSERT(param != NULL); - _ASSERT(field != NULL); - - SkinnedDialog *skdlg = (SkinnedDialog *) param; - skdlg->onFieldChange(field); -} - -void SkinnedDialog::setErrorCallback(MessageCallback cb, void *param /*= NULL*/) -{ - errorCallback = cb; - errorCallbackParam = param; -} - -void SkinnedDialog::setTraceCallback(MessageCallback cb, void *param /*= NULL*/) -{ - traceCallback = cb; - traceCallbackParam = param; -} - -void SkinnedDialog::trace(TCHAR *msg, ...) -{ - if (traceCallback == NULL) - return; - - TCHAR buff[1024]; - memset(buff, 0, sizeof(buff)); - - va_list args; - va_start(args, msg); - - _vsntprintf(buff, MAX_REGS(buff) - 1, msg, args); - buff[MAX_REGS(buff) - 1] = 0; - - va_end(args); - - traceCallback(traceCallbackParam, buff); -} - -SkinOptions * SkinnedDialog::getOpts() -{ - compile(); - return opts; -} - -DialogState * SkinnedDialog::getDefaultState() -{ - compile(); - return defaultState; -} \ No newline at end of file diff --git a/plugins/Skins/SkinLib/SkinnedDialog.h b/plugins/Skins/SkinLib/SkinnedDialog.h deleted file mode 100644 index 1387082f44..0000000000 --- a/plugins/Skins/SkinLib/SkinnedDialog.h +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef __SKINNED_DIALOG_H__ -# define __SKINNED_DIALOG_H__ - -#include -#include -#include "tstring.h" - -#include "Dialog.h" -#include "ButtonField.h" -#include "EditField.h" -#include "IconField.h" -#include "ImageField.h" -#include "LabelField.h" -#include "TextField.h" - -#include "DialogState.h" -#include "BorderState.h" -#include "ButtonFieldState.h" -#include "EditFieldState.h" -#include "FontState.h" -#include "IconFieldState.h" -#include "ImageFieldState.h" -#include "LabelFieldState.h" -#include "TextFieldState.h" - -#include "SkinOptions.h" - -class V8Script; - - -typedef void (*MessageCallback)(void *param, const TCHAR *err); - - - -class SkinnedDialog : public Dialog -{ -public: - SkinnedDialog(const char *name); - virtual ~SkinnedDialog(); - - virtual const TCHAR * getFilename() const; - virtual void setFilename(const TCHAR *filename); - - virtual bool addField(Field *field); - - virtual void setSize(const Size &size); - - /// Return the cached state. Do not free the result. - /// Each call to this method can potentially create the state, so don't cache it. - virtual DialogState * getState(); - - virtual void setErrorCallback(MessageCallback cb, void *param = NULL); - virtual void setTraceCallback(MessageCallback cb, void *param = NULL); - - virtual SkinOptions * getOpts(); - virtual DialogState * getDefaultState(); - -protected: - virtual bool fileChanged(); - virtual int compile(); /// @return 0 error, 1 no change, 2 compiled - - virtual void trace(TCHAR *msg, ...); - - virtual void onFieldChange(const Field *field); - -private: - std::tstring filename; - __time64_t fileChangedTime; - V8Script *script; - DialogState *state; - SkinOptions *opts; - DialogState *defaultState; - - MessageCallback errorCallback; - void *errorCallbackParam; - MessageCallback traceCallback; - void *traceCallbackParam; - - void releaseCompiledScript(); - void releaseState(); - void readFile(std::tstring &ret); - - static void staticOnFieldChange(void *param, const Field *field); -}; - - - - -#endif // __SKINNED_DIALOG_H__ diff --git a/plugins/Skins/SkinLib/TextField.cpp b/plugins/Skins/SkinLib/TextField.cpp deleted file mode 100644 index d3841b98fd..0000000000 --- a/plugins/Skins/SkinLib/TextField.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#include "globals.h" -#include "TextField.h" -#include "TextFieldState.h" - - -TextField::TextField(Dialog *dlg, const char *name) - : Field(dlg, name), hFont(NULL), fontColor(RGB(0,0,0)) -{ -} - - -TextField::~TextField() -{ -} - - -FieldType TextField::getType() const -{ - return SIMPLE_TEXT; -} - - -void TextField::setText(const TCHAR *text) -{ - if (this->text == text) - return; - - this->text = text; - fireOnChange(); -} - - -const TCHAR * TextField::getText() const -{ - return text.c_str(); -} - - -void TextField::setFont(HFONT hFont) -{ - if (this->hFont == hFont) - return; - - this->hFont = hFont; - fireOnChange(); -} - - -HFONT TextField::getFont() const -{ - if (hFont != NULL) - return hFont; - - // The default is the GUI font - return (HFONT) GetStockObject(DEFAULT_GUI_FONT); -} - - -COLORREF TextField::getFontColor() const -{ - return fontColor; -} - - -void TextField::setFontColor(COLORREF color) -{ - if (fontColor == color) - return; - - fontColor = color; - fireOnChange(); -} - - -FieldState * TextField::createState(DialogState *dialogState) -{ - return new TextFieldState(dialogState, this); -} diff --git a/plugins/Skins/SkinLib/TextField.h b/plugins/Skins/SkinLib/TextField.h deleted file mode 100644 index 8d2291f876..0000000000 --- a/plugins/Skins/SkinLib/TextField.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef __TEXT_FIELD_H__ -# define __TEXT_FIELD_H__ - -#include "Field.h" - - -class TextField : public Field -{ -public: - TextField(Dialog *dlg, const char *name); - virtual ~TextField(); - - virtual FieldType getType() const; - - virtual const TCHAR * getText() const; - virtual void setText(const TCHAR *text); - - virtual HFONT getFont() const; - virtual void setFont(HFONT hFont); - - virtual COLORREF getFontColor() const; - virtual void setFontColor(COLORREF color); - - virtual FieldState * createState(DialogState *dialogState); - -private: - std::tstring text; - HFONT hFont; - COLORREF fontColor; - -}; - - - -#endif // __TEXT_FIELD_H__ diff --git a/plugins/Skins/SkinLib/TextFieldState.cpp b/plugins/Skins/SkinLib/TextFieldState.cpp deleted file mode 100644 index 8e295d01ee..0000000000 --- a/plugins/Skins/SkinLib/TextFieldState.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "globals.h" -#include "TextFieldState.h" - - -TextFieldState::TextFieldState(DialogState *dialog, TextField *field) - : FieldState(dialog, field), font(field->getFont(), field->getFontColor()), textSet(false) -{ -} - -TextFieldState::~TextFieldState() -{ -} - -TextField * TextFieldState::getField() const -{ - return (TextField *) FieldState::getField(); -} - - -Size TextFieldState::getPreferedSize() const -{ - HDC hdc = CreateCompatibleDC(NULL); - - HFONT newFont = getFont()->getHFONT(); - HFONT oldFont = (HFONT) SelectObject(hdc, newFont); - - RECT rc = {0}; - const TCHAR *text = getText(); - DrawText(hdc, text, -1, &rc, DT_CALCRECT | DT_NOPREFIX | DT_EXPANDTABS | DT_SINGLELINE); - - SelectObject(hdc, oldFont); - - DeleteDC(hdc); - - return Size(rc.right - rc.left, rc.bottom - rc.top); -} - -const TCHAR * TextFieldState::getText() const -{ - if (textSet) - return text.c_str(); - - return getField()->getText(); -} - -void TextFieldState::setText(const TCHAR *text) -{ - this->text = text; - textSet = true; -} - -FontState * TextFieldState::getFont() -{ - return &font; -} - -const FontState * TextFieldState::getFont() const -{ - return &font; -} - -bool TextFieldState::isEmpty() const -{ - return lstrlen(getText()) <= 0; -} diff --git a/plugins/Skins/SkinLib/TextFieldState.h b/plugins/Skins/SkinLib/TextFieldState.h deleted file mode 100644 index 9779cfa569..0000000000 --- a/plugins/Skins/SkinLib/TextFieldState.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef __TEXT_FIELD_STATE_H__ -# define __TEXT_FIELD_STATE_H__ - -#include "TextField.h" -#include "FieldState.h" -#include "FontState.h" - - -class TextFieldState : public FieldState -{ -public: - virtual ~TextFieldState(); - - virtual TextField * getField() const; - - virtual Size getPreferedSize() const; - - virtual const TCHAR * getText() const; - virtual void setText(const TCHAR *text); - - virtual FontState * getFont(); - virtual const FontState * getFont() const; - - virtual bool isEmpty() const; - -private: - TextFieldState(DialogState *dialog, TextField *field); - - FontState font; - BOOL textSet; - std::tstring text; - - - friend class TextField; -}; - - -#endif // __TEXT_FIELD_STATE_H__ \ No newline at end of file diff --git a/plugins/Skins/SkinLib/TextFieldState_v8_wrapper.cpp b/plugins/Skins/SkinLib/TextFieldState_v8_wrapper.cpp deleted file mode 100644 index cf11fdb01f..0000000000 --- a/plugins/Skins/SkinLib/TextFieldState_v8_wrapper.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "globals.h" -#include "TextFieldState_v8_wrapper.h" -#include -#include "TextFieldState.h" -#include - -using namespace v8; - - -#ifdef UNICODE -# define V8_TCHAR uint16_t -#else -# define V8_TCHAR char -#endif - - -static Handle Get_TextFieldState_text(Local property, const AccessorInfo &info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return scope.Close( Undefined() ); - - TextFieldState *tmp = (TextFieldState *) wrap->Value(); - if (tmp == NULL) - return scope.Close( Undefined() ); - - return scope.Close( String::New((const V8_TCHAR *) tmp->getText()) ); -} - -static void Set_TextFieldState_text(Local property, Local value, const AccessorInfo& info) -{ - HandleScope scope; - - Local self = info.Holder(); - Local wrap = Local::Cast(self->GetInternalField(0)); - if (wrap.IsEmpty()) - return; - - TextFieldState *tmp = (TextFieldState *) wrap->Value(); - if (tmp == NULL) - return; - - if (!value.IsEmpty() && value->IsString()) - { - String::Utf8Value utf8_value(value); - tmp->setText(Utf8ToTchar(*utf8_value)); - } -} - - -void AddTextFieldStateAcessors(Handle &templ) -{ - HandleScope scope; - - templ->SetAccessor(String::New("text"), Get_TextFieldState_text, Set_TextFieldState_text); -} diff --git a/plugins/Skins/SkinLib/TextFieldState_v8_wrapper.h b/plugins/Skins/SkinLib/TextFieldState_v8_wrapper.h deleted file mode 100644 index c5d9e48a80..0000000000 --- a/plugins/Skins/SkinLib/TextFieldState_v8_wrapper.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef __TEXT_FIELD_STATE_V8_WRAPPER_H__ -# define __TEXT_FIELD_STATE_V8_WRAPPER_H__ - -#include - -void AddTextFieldStateAcessors(v8::Handle &templ); - - - -#endif // __TEXT_FIELD_STATE_V8_WRAPPER_H__ diff --git a/plugins/Skins/SkinLib/V8Script.cpp b/plugins/Skins/SkinLib/V8Script.cpp deleted file mode 100644 index c7619187a5..0000000000 --- a/plugins/Skins/SkinLib/V8Script.cpp +++ /dev/null @@ -1,236 +0,0 @@ -#include "globals.h" -#include "V8Script.h" -#include "V8Wrappers.h" - -#include - -using namespace v8; - -#ifdef UNICODE -# define V8_TCHAR uint16_t -#else -# define V8_TCHAR char -#endif - - -V8Wrappers *wrappers = NULL; - - -void V8Script::initializeEngine() -{ - if (wrappers != NULL) - return; - - wrappers = new V8Wrappers(); -} - - -V8Script::V8Script() : exceptionCallback(NULL), exceptionCallbackParam(NULL) -{ -} - -V8Script::~V8Script() -{ - dispose(); -} - -bool V8Script::compile(const TCHAR *source, Dialog *dlg) -{ - dispose(); - - HandleScope handle_scope; - - context = Context::New(NULL, wrappers->getGlobalTemplate()); - - Context::Scope context_scope(context); - - context->Global()->Set(String::New("window"), wrappers->newDialogState(), ReadOnly); - context->Global()->Set(String::New("opts"), wrappers->newOptions(), ReadOnly); - context->Global()->Set(String::New("info"), wrappers->newDialogInfo(), ReadOnly); - for(unsigned int i = 0; i < dlg->getFieldCount(); i++) - { - Field *field = dlg->getField(i); - context->Global()->Set(String::New(field->getName()), wrappers->newState(field->getType()), ReadOnly); - } - - TryCatch try_catch; - Local