Merge branch 'Sankore-1.40' of github.com:Sankore/Sankore-3.1 into Sankore-1.40

preferencesAboutTextFull
Claudio Valerio 13 years ago
commit 7c2a22a5d0
  1. BIN
      resources/images/virtual.keyboard/29/capslock.png
  2. BIN
      resources/images/virtual.keyboard/29/shift.png
  3. BIN
      resources/images/virtual.keyboard/41/capslock.png
  4. BIN
      resources/images/virtual.keyboard/41/shift.png
  5. 420
      resources/library/interactivities/Selectionner.wgt/css/basic.css
  6. BIN
      resources/library/interactivities/Selectionner.wgt/img/add_block.png
  7. BIN
      resources/library/interactivities/Selectionner.wgt/img/circle.png
  8. BIN
      resources/library/interactivities/Selectionner.wgt/img/close_cont.png
  9. BIN
      resources/library/interactivities/Selectionner.wgt/img/green_point.png
  10. BIN
      resources/library/interactivities/Selectionner.wgt/img/play.png
  11. BIN
      resources/library/interactivities/Selectionner.wgt/img/red_point.png
  12. BIN
      resources/library/interactivities/Selectionner.wgt/img/replay.png
  13. BIN
      resources/library/interactivities/Selectionner.wgt/img/stop.png
  14. 457
      resources/library/interactivities/Selectionner.wgt/js/script.js
  15. 457
      resources/library/interactivities/Selectionner.wgt/locales/fr/js/script.js
  16. 457
      resources/library/interactivities/Selectionner.wgt/locales/ru/js/script.js
  17. 2
      resources/sankore.qrc
  18. 3
      src/frameworks/UBPlatformUtils.cpp
  19. 102
      src/frameworks/UBPlatformUtils.h
  20. 541
      src/frameworks/UBPlatformUtils_linux.cpp
  21. 383
      src/frameworks/UBPlatformUtils_mac.mm
  22. 527
      src/frameworks/UBPlatformUtils_win.cpp
  23. 121
      src/gui/UBKeyboardPalette.cpp
  24. 33
      src/gui/UBKeyboardPalette.h
  25. 174
      src/gui/UBKeyboardPalette_linux.cpp
  26. 36
      src/gui/UBKeyboardPalette_mac.cpp
  27. 19
      src/gui/UBKeyboardPalette_win.cpp

Binary file not shown.

Before

Width:  |  Height:  |  Size: 245 B

After

Width:  |  Height:  |  Size: 227 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 261 B

After

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 B

@ -1,420 +0,0 @@
html, body{
width: 100%;
height: 100%;
margin: 0;
padding: 0;
border-radius: 50px;
}
body{
background-image: url(../img/bg.png);
}
.toggle_mode{
width: 100%;
height: 25px;
border-bottom: 1px solid black;
background-color: #ccc;
position: fixed;
top: 0;
left: 0;
z-index: 2;
}
#display_img, #edit_img{
width: 15px;
height: 15px;
margin: 5px 10px;
}
.green_point{
background-image: url(../img/green_point.png);
}
.red_point{
background-image: url(../img/red_point.png);
}
#display_text, #edit_text{
height: 19px;
padding: 3px 0 0 0;
}
.selected{
}
#display:hover, #edit:hover{
background-color: #999;
}
.cont{
width: 100%;
border-bottom: 1px solid black;
margin: 0;
padding: 0;
position: relative;
}
.sub_cont{
width: 100%;
padding: 0;
margin: 20px 0 0 0;
min-height: 60px;
}
.imgs_cont{
width: 100%;
margin: 0;
}
.number_cont{
width: 40px;
height: 33px;
margin-left: 40px;
margin-right: 10px;
background-image: url(../img/circle.png);
background-repeat: no-repeat;
text-align: center;
float: left;
font-size: 130%;
padding-top: 7px;
font-weight: bold;
}
.text_cont{
width: 80%;
min-height: 40px;
float: right;
background-color: #ccc;
border-top-left-radius: 10px;
border-bottom-left-radius: 10px;
padding-left: 10px;
}
.close_cont{
width: 20px;
height: 20px;
background-image: url(../img/close_cont.png);
cursor: pointer;
position: absolute;
top: -15px;
left: 5px;
}
.add_img{
width: 120px;
height: 120px;
margin: 10px 20px;
background-image: url(../img/add_text.png);
background-position: center;
background-repeat: no-repeat;
cursor: pointer;
float: left;
display: inline-block;
}
.img_block{
display: inline-block;
}
.img_block, .text_block{
width: 120px;
height: 120px;
margin: 10px 20px;
cursor: pointer;
float: left;
position: relative;
border: 1px solid #ccc;
-moz-box-shadow: #ccc -1px 0 4px;
-webkit-box-shadow: #ccc -1px 0 4px;
box-shadow: #ccc -1px 0 4px;
background-color: white;
}
.text_block{
display: table;
text-align: center;
}
.audio_block{
width: 120px;
height: 30px;
margin: 44px 5px;
position: relative;
float: left;
display: inline-block;
}
.text_subblock{
display: table-cell;
vertical-align: middle;
font-size: 120%;
}
.close_img, .clear_img, .numb_img {
width: 30px;
height: 30px;
background-repeat: no-repeat;
position: absolute;
right: -15px;
cursor: pointer;
}
.close_img{
background-image: url(../img/close_img.png);
top: -15px;
}
.clear_img{
background-image: url(../img/clear_img.png);
top: 15px;
}
.numb_img{
background-image: url(../img/numb_img.png);
left: -15px;
top: -15px;
color: white;
font-weight: bold;
font-size: 130%;
}
.add_block{
margin: 20px 0 0 20px;
width: 110px;
height: 25px;
background-image: url(../img/add_block.png);
background-repeat: no-repeat;
padding-left: 40px;
padding-top: 5px;
cursor: pointer;
background-color: #ccc;
-webkit-border-radius: 15px;
border-radius: 15px;
}
.ch_box{
margin: 0;
padding: 0;
position: absolute;
bottom: 0;
right: 0;
}
.right{
background-color: #9f9;
}
.clear{
clear: both;
}
.over{
background-color: #ccc;
}
.play, .stop{
height: 30px;
width: 70px;
float: left;
cursor: pointer;
}
.play{
background-image: url(../img/play.png);
}
.stop{
background-image: url(../img/stop.png);
}
.replay{
height: 30px;
width: 32px;
margin-left: 10px;
float: left;
background-image: url(../img/replay.png);
background-repeat: no-repeat;
cursor: pointer;
}
/*new design*/
.body_table{
width: 100%;
height: 100%;
border-spacing: 0;
}
/*top*/
.b_top_left{
width: 54px;
background-image: url(../img/top_left.png);
background-repeat: no-repeat;
}
.b_top_right{
width: 54px;
background-image: url(../img/top_right.png);
background-repeat: no-repeat;
}
.b_top_center{
height: 54px;
background-image: url(../img/top.png);
background-repeat: repeat-x;
}
/*bottom*/
.b_bottom_left{
width: 54px;
background-image: url(../img/bottom_left.png);
background-repeat: no-repeat;
}
.b_bottom_right{
width: 54px;
background-image: url(../img/bottom_right.png);
background-repeat: no-repeat;
}
.b_bottom_center{
background-image: url(../img/bottom.png);
background-repeat: repeat-x;
}
/*center*/
.b_center_left{
width: 54px;
background-image: url(../img/left.png);
background-repeat: repeat-y;
}
.b_center_right{
width: 54px;
background-image: url(../img/right.png);
background-repeat: repeat-y;
}
#data{
width: 100%;
height: 100%;
min-height: 250px;
overflow: auto;
}
#wgt_name{
height: 44px;
width: 200px;
margin: 10px 10px 0 10px;
padding: 0;
float: left;
/*font-family: "Lobster13Regular";*/
font-size: 24px;
color: #8c5730;
}
#wgt_reload, #wgt_edit, #wgt_display{
cursor: pointer;
width: 80px;
height: 44px;
margin: 10px 10px 0 0;
float: right;
/*font-family: "Lobster13Regular";*/
font-size: 24px;
color: #8c5730;
}
#wgt_display{
width: 100px;
padding-left: 40px;
background-image: url(../img/slate-edit.png);
background-repeat: no-repeat;
background-position: top 0;
display: none;
}
#wgt_edit{
width: 100px;
padding-left: 40px;
background-image: url(../img/slate-edit.png);
background-repeat: no-repeat;
background-position: top 0;
}
#wgt_reload{
padding-left: 40px;
background-image: url(../img/slate-toolbar-reload.png);
background-repeat: no-repeat;
background-position: top 0;
}
.style_select{
width: 120px;
/*font-family: "Lobster13Regular";*/
font-size: 24px;
float: right;
margin: 10px 20px 0 0;
border-radius: 10px;
background-image: url(../img/ar_down.png);
background-color: #d4aa79;
color: #8c5730;
background-position: 105px 11px;
background-repeat: no-repeat;
-webkit-appearance: menulist-text;
display: none;
}
.btl_pad{
background-image: url(../img/pad-top-left.png) !important;
}
.btc_pad{
background-image: url(../img/pad-top.png) !important;
}
.btr_pad{
background-image: url(../img/pad-top-right.png) !important;
}
.bcl_pad{
background-image: url(../img/pad-left.png) !important;
}
.bcr_pad{
background-image: url(../img/pad-right.png) !important;
}
.bbl_pad{
background-image: url(../img/pad-bottom-left.png) !important;
}
.bbc_pad{
background-image: url(../img/pad-bottom.png) !important;
}
.bbr_pad{
background-image: url(../img/pad-bottom-right.png) !important;
}
.pad_color{
color: white !important;
}
.pad_reload{
background-image: url(../img/slate-toolbar-reload-white.png) !important;
}
.pad_edit{
background-image: url(../img/slate-display.png) !important;
}
.pad_select{
background-color: black !important;
color: white !important;
background-image: url(../img/ar_down_white.png) !important;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 772 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 721 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 740 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

@ -1,457 +0,0 @@
var sankoreLang = {
display: "Display",
edit: "Edit",
short_desc: "Select animals from the following list:",
add: "Add new block",
enter: "Enter your instruction here ...",
cat: "cat",
ball: "ball",
shovel: "shovel",
dog: "dog",
tree: "tree",
wgt_name: "Select the desired",
reload: "Reload",
slate: "Wood",
pad: "Pad"
};
//main function
function start(){
$("#wgt_display").text(sankoreLang.display);
$("#wgt_edit").text(sankoreLang.edit);
$("#wgt_name").text(sankoreLang.wgt_name);
$("#wgt_reload").text(sankoreLang.reload);
$(".style_select option[value='1']").text(sankoreLang.slate);
$(".style_select option[value='2']").text(sankoreLang.pad);
if(window.sankore){
if(sankore.preference("selectionner","")){
var data = jQuery.parseJSON(sankore.preference("selectionner",""));
importData(data);
} else
showExample();
if(sankore.preference("sel_style","")){
changeStyle(sankore.preference("sel_style",""));
$(".style_select").val(sankore.preference("sel_style",""));
} else
changeStyle(1)
}
else
showExample();
//events
if (window.widget) {
window.widget.onleave = function(){
exportData();
sankore.setPreference("sel_style", $(".style_select").find("option:selected").val());
}
}
$("#wgt_reload").click(function(){
window.location.reload();
});
$(".style_select").change(function (event){
changeStyle($(this).find("option:selected").val());
})
$("#wgt_display, #wgt_edit").click(function(event){
if(this.id == "wgt_display"){
if(!$(this).hasClass("selected")){
if(window.sankore)
sankore.enableDropOnWidget(false);
$(this).addClass("selected");
$("#wgt_edit").removeClass("selected");
$(".style_select").css("display","none");
$(".add_block").remove();
$(".cont").each(function(){
var container = $(this);
container.find(".text_cont").removeAttr("contenteditable");
container.find(".add_img").remove();
container.find(".close_cont").remove();
container.find(".imgs_cont").removeAttr("ondragenter")
.removeAttr("ondragleave")
.removeAttr("ondragover")
.removeAttr("ondrop");
container.find(".img_block, .text_block").each(function(){
$(this).find(".close_img").remove();
$(this).find(".text_subblock").removeAttr("contenteditable");
$(this).find("input:checkbox").removeAttr("checked")
});
});
$(this).css("display", "none");
$("#wgt_edit").css("display", "block");
}
} else {
if(!$(this).hasClass("selected")){
if(window.sankore)
sankore.enableDropOnWidget(true);
$(this).addClass("selected");
$("#wgt_display").removeClass("selected");
$(".style_select").css("display","block");
$(".cont").each(function(){
var container = $(this);
$("<div class='close_cont'>").appendTo(container);
container.find(".text_cont").attr("contenteditable","true");
container.find(".imgs_cont").removeClass("right")
.attr("ondragenter", "return false;")
.attr("ondragleave", "$(this).removeClass('over'); return false;")
.attr("ondragover", "$(this).addClass('over'); return false;")
.attr("ondrop", "$(this).removeClass('over'); return onDropTarget(this,event);");
var add_img = $("<div class='add_img'>");
container.find(".img_block, .text_block").each(function(){
$("<div class='close_img'>").appendTo($(this));
if($(this).find("input:hidden").val() == 0)
$(this).find("input:checkbox").attr('checked', false);
else
$(this).find("input:checkbox").attr('checked', true);
$(this).find(".text_subblock").attr("contenteditable","true");
});
add_img.insertBefore(container.find(".clear"));
});
$("<div class='add_block'>" + sankoreLang.add + "</div>").appendTo("#data");
$(this).css("display", "none");
$("#wgt_display").css("display", "block");
}
}
});
//add new block
$(".add_block").live("click", function(){
addContainer();
});
//checkbox events
$("input:checkbox").live("click", function(){
if($("#wgt_display").hasClass("selected")){
var flag = true;
var block = $(this).parent().parent();
block.find(".text_block, .img_block, .audio_block").each(function(){
if($(this).find("input:checkbox").is(':checked') && $(this).find("input:hidden").val() == 0)
flag = false;
else if(!$(this).find("input:checkbox").is(':checked') && $(this).find("input:hidden").val() == 1)
flag = false;
});
if(flag)
block.addClass("right");
else
block.removeClass("right");
} else {
if($(this).is(":checked"))
$(this).parent().find("input:hidden").val(1);
else
$(this).parent().find("input:hidden").val(0);
}
});
//play/pause event
$(".play, .stop").live("click", function(){
var tmp_audio = $(this);
var audio = tmp_audio.parent().find("audio").get(0);
if($(this).hasClass("play")){
if(tmp_audio.parent().find("source").attr("src")){
tmp_audio.removeClass("play").addClass("stop");
var id = setInterval(function(){
if(audio.currentTime == audio.duration){
clearInterval(id);
tmp_audio.removeClass("stop").addClass("play");
}
}, 10);
tmp_audio.parent().find("input").val(id);
audio.play();
}
} else {
$(this).removeClass("stop").addClass("play");
clearInterval( tmp_audio.parent().find("input").val())
audio.pause();
}
});
$(".replay").live("click", function(){
var tmp_audio = $(this).prev();
var audio = $(this).parent().find("audio").get(0);
if(tmp_audio.parent().find("source").attr("src")){
$(this).prev().removeClass("play").addClass("stop");
clearInterval($(this).parent().find("input").val());
var id = setInterval(function(){
if(audio.currentTime == audio.duration){
clearInterval(id);
tmp_audio.removeClass("stop").addClass("play");
}
}, 10);
tmp_audio.parent().find("input").val(id);
audio.currentTime = 0;
audio.play();
}
});
//adding new img
$(".add_img").live("click", function(){
addTextBlock($(this));
});
//deleting a block
$(".close_cont").live("click",function(){
$(this).parent().remove();
refreshBlockNumbers();
});
//deleting the img block
$(".close_img").live("click", function(){
$(this).parent().remove();
});
}
//export
function exportData(){
var array_to_export = [];
$(".cont").each(function(){
var cont_obj = new Object();
cont_obj.text = $(this).find(".text_cont").text();
cont_obj.blocks = [];
$(this).find(".img_block, .audio_block, .text_block").each(function(){
var tmp_block = new Object();
if($(this).hasClass("img_block")){
if($(this).find(".audio_block").size() == 0){
tmp_block.src = $(this).find("img").attr("src");
tmp_block.hidden = $(this).find("input:hidden").val();
tmp_block.h = $(this).find("img").height();
tmp_block.w = $(this).find("img").width();
tmp_block.type = "img";
}
}
if($(this).hasClass("audio_block")){
tmp_block.src = $(this).find("source").attr("src");
tmp_block.hidden = $(this).parent().find("input:hidden").val();
tmp_block.type = "audio";
}
if($(this).hasClass("text_block")){
tmp_block.text = $(this).find(".text_subblock").text();
tmp_block.hidden = $(this).find("input:hidden").val();
tmp_block.type = "text";
}
cont_obj.blocks.push(tmp_block);
});
array_to_export.push(cont_obj);
});
sankore.setPreference("selectionner", JSON.stringify(array_to_export));
}
//import
function importData(data){
var tmp = 0;
for(var i in data){
var container = $("<div class='cont'>").appendTo("#data");
var sub_container = $("<div class='sub_cont'>").appendTo(container);
var imgs_container = $("<div class='imgs_cont'>").appendTo(container);
$("<div class='clear'>").appendTo(imgs_container);
$("<div class='number_cont'>" + (++tmp) + "</div>").appendTo(sub_container);
$("<div class='text_cont'>" + data[i].text + "</div>").appendTo(sub_container);
for(var j in data[i].blocks){
switch(data[i].blocks[j].type){
case "text":
var text_block = $("<div class='text_block'>").insertBefore(imgs_container.find(".clear"));
$("<div class='text_subblock'>" + data[i].blocks[j].text + "</div>").appendTo(text_block);
$("<input type='hidden' value='" + data[i].blocks[j].hidden + "'/>").appendTo(text_block);
$("<input type='checkbox' class='ch_box'/>").appendTo(text_block);
break;
case "img":
var img_block = $("<div class='img_block' style='text-align: center;'></div>").insertBefore(imgs_container.find(".clear"));
$("<input type='hidden' value='" + data[i].blocks[j].hidden + "'/>").appendTo(img_block);
$("<input type='checkbox' class='ch_box'/>").appendTo(img_block)
$("<img src=\"" + data[i].blocks[j].src + "\" width='" + data[i].blocks[j].w + "' height='" + data[i].blocks[j].h + "' style=\"display: inline;\"/>").appendTo(img_block);
break;
case "audio":
var img_tmp = $("<div class='img_block'>").insertBefore(imgs_container.find(".clear"));
var audio_block = $("<div class='audio_block'>").appendTo(img_tmp);
$("<div class='close_img'>").appendTo(img_tmp);
$("<div class='play'>").appendTo(audio_block);
$("<div class='replay'>").appendTo(audio_block);
var source = $("<source/>").attr("src", data[i].blocks[j].src);
var audio = $("<audio>").appendTo(audio_block);
audio.append(source);
$("<input type='hidden' value='" + data[i].blocks[j].hidden + "'/>").appendTo(img_tmp);
$("<input type='checkbox' class='ch_box'/>").appendTo(img_tmp)
break;
}
}
}
}
//example
function showExample(){
var container = $("<div class='cont'>");
var sub_container = $("<div class='sub_cont'>").appendTo(container);
var imgs_container = $("<div class='imgs_cont'>").appendTo(container);
$("<div class='number_cont'>1</div>").appendTo(sub_container);
$("<div class='text_cont'>" + sankoreLang.short_desc + "</div>").appendTo(sub_container);
var tmp1 = $("<div class='text_block'>").appendTo(imgs_container);
$("<div class='text_subblock'>" + sankoreLang.cat + "</div>").appendTo(tmp1);
$("<input type='hidden' value='1'/>").appendTo(tmp1);
$("<input type='checkbox' class='ch_box'/>").appendTo(tmp1)
var tmp2 = $("<div class='text_block'>").appendTo(imgs_container);
$("<div class='text_subblock'>" + sankoreLang.ball + "</div>").appendTo(tmp2);
$("<input type='hidden' value='0'/>").appendTo(tmp2);
$("<input type='checkbox' class='ch_box'/>").appendTo(tmp2)
var tmp3 = $("<div class='text_block'>").appendTo(imgs_container);
$("<div class='text_subblock'>" + sankoreLang.shovel + "</div>").appendTo(tmp3);
$("<input type='hidden' value='0'/>").appendTo(tmp3);
$("<input type='checkbox' class='ch_box'/>").appendTo(tmp3)
var tmp4 = $("<div class='text_block'>").appendTo(imgs_container);
$("<div class='text_subblock'>" + sankoreLang.dog + "</div>").appendTo(tmp4);
$("<input type='hidden' value='1'/>").appendTo(tmp4);
$("<input type='checkbox' class='ch_box'/>").appendTo(tmp4)
var tmp5 = $("<div class='text_block'>").appendTo(imgs_container);
$("<div class='text_subblock'>" + sankoreLang.tree + "</div>").appendTo(tmp5);
$("<input type='hidden' value='0'/>").appendTo(tmp5);
$("<input type='checkbox' class='ch_box'/>").appendTo(tmp5)
$("<div class='clear'>").appendTo(imgs_container);
container.appendTo("#data")
}
//add new container
function addContainer(){
var container = $("<div class='cont'>");
var sub_container = $("<div class='sub_cont'>").appendTo(container);
var imgs_container = $("<div class='imgs_cont'>").appendTo(container);
imgs_container.attr("ondragenter", "return false;")
.attr("ondragleave", "$(this).removeClass('over'); return false;")
.attr("ondragover", "$(this).addClass('over'); return false;")
.attr("ondrop", "$(this).removeClass('over'); return onDropTarget(this,event);");
$("<div class='close_cont'>").appendTo(container);
$("<div class='number_cont'>"+ ($(".cont").size() + 1) +"</div>").appendTo(sub_container);
var text = $("<div class='text_cont' contenteditable>" + sankoreLang.enter + "</div>").appendTo(sub_container);
$("<div class='add_img'>").appendTo(imgs_container);
$("<div class='clear'>").appendTo(imgs_container);
container.insertBefore($(".add_block"));
}
//add new img block
function addTextBlock(dest){
var tmp = $("<div class='text_block'>").insertBefore(dest)
$("<div class='text_subblock' contenteditable='true'>" + sankoreLang.enter + "</div>").appendTo(tmp);
$("<input type='hidden' value='0'/>").appendTo(tmp);
$("<input type='checkbox' class='ch_box'/>").appendTo(tmp);
$("<div class='close_img'>").appendTo(tmp);
}
function refreshBlockNumbers(){
var i = 0;
$(".cont").each(function(){
$(this).find(".number_cont").text(++i);
})
}
function stringToXML(text){
if (window.ActiveXObject){
var doc=new ActiveXObject('Microsoft.XMLDOM');
doc.async='false';
doc.loadXML(text);
} else {
var parser=new DOMParser();
doc=parser.parseFromString(text,'text/xml');
}
return doc;
}
//changing the style
function changeStyle(val){
if(val == 1){
$(".b_top_left").removeClass("btl_pad");
$(".b_top_center").removeClass("btc_pad");
$(".b_top_right").removeClass("btr_pad");
$(".b_center_left").removeClass("bcl_pad");
$(".b_center_right").removeClass("bcr_pad");
$(".b_bottom_right").removeClass("bbr_pad");
$(".b_bottom_left").removeClass("bbl_pad");
$(".b_bottom_center").removeClass("bbc_pad");
$("#wgt_reload").removeClass("pad_color").removeClass("pad_reload");
$("#wgt_edit").removeClass("pad_color").removeClass("pad_edit");
$("#wgt_display").removeClass("pad_color").removeClass("pad_edit");
$("#wgt_name").removeClass("pad_color");
$(".style_select").removeClass("pad_select");
} else {
$(".b_top_left").addClass("btl_pad");
$(".b_top_center").addClass("btc_pad");
$(".b_top_right").addClass("btr_pad");
$(".b_center_left").addClass("bcl_pad");
$(".b_center_right").addClass("bcr_pad");
$(".b_bottom_right").addClass("bbr_pad");
$(".b_bottom_left").addClass("bbl_pad");
$(".b_bottom_center").addClass("bbc_pad");
$("#wgt_reload").addClass("pad_color").addClass("pad_reload");
$("#wgt_edit").addClass("pad_color").addClass("pad_edit");
$("#wgt_display").addClass("pad_color").addClass("pad_edit");
$("#wgt_name").addClass("pad_color");
$(".style_select").addClass("pad_select");
}
}
function onDropTarget(obj, event) {
if (event.dataTransfer) {
var format = "text/plain";
var textData = event.dataTransfer.getData(format);
if (!textData) {
alert(":(");
}
textData = stringToXML(textData);
var tmp = textData.getElementsByTagName("path")[0].firstChild.textContent;
var tmp_type = textData.getElementsByTagName("type")[0].firstChild.textContent;
if(tmp_type.substr(0, 5) == "audio"){
var img_tmp = $("<div class='img_block'>").insertBefore($(obj).find(".add_img"));
var audio_block = $("<div class='audio_block'>").appendTo(img_tmp)
$("<div class='close_img'>").appendTo(img_tmp);
$("<div class='play'>").appendTo(audio_block);
$("<div class='replay'>").appendTo(audio_block);
var source = $("<source/>").attr("src", tmp);
var audio = $("<audio>").appendTo(audio_block);
audio.append(source);
$("<input type='hidden' value='0'/>").appendTo(img_tmp);
$("<input type='checkbox' class='ch_box'/>").appendTo(img_tmp)
} else {
var img_block = $("<div class='img_block' style='text-align: center;'></div>").insertBefore($(obj).find(".add_img"));
$("<div class='close_img'>").appendTo(img_block);
$("<input type='hidden' value='0'/>").appendTo(img_block);
$("<input type='checkbox' class='ch_box'/>").appendTo(img_block)
var tmp_img = $("<img src=\"" + tmp + "\" style=\"display: inline;\"/>").appendTo(img_block);
setTimeout(function(){
if(tmp_img.height() >= tmp_img.width())
tmp_img.attr("height", "120");
else{
tmp_img.attr("width","120");
tmp_img.css("margin",(120 - tmp_img.height())/2 + "px 0");
}
}, 6);
}
}
else {
alert ("Your browser does not support the dataTransfer object.");
}
if (event.stopPropagation) {
event.stopPropagation ();
}
else {
event.cancelBubble = true;
}
return false;
}

@ -1,457 +0,0 @@
var sankoreLang = {
display: "Afficher",
edit: "Modifier",
short_desc: "Sélectionner les animaux dans la liste suivante:",
add: "Nouveau bloc",
enter: "Saisir votre consigne ici ...",
cat: "chat",
ball: "balle",
shovel: "pelle",
dog: "chien",
tree: "arbre",
wgt_name: "Sélectionner",
reload: "Recharger",
slate: "Bois",
pad: "Pad"
};
//main function
function start(){
$("#wgt_display").text(sankoreLang.display);
$("#wgt_edit").text(sankoreLang.edit);
$("#wgt_name").text(sankoreLang.wgt_name);
$("#wgt_reload").text(sankoreLang.reload);
$(".style_select option[value='1']").text(sankoreLang.slate);
$(".style_select option[value='2']").text(sankoreLang.pad);
if(window.sankore){
if(sankore.preference("selectionner","")){
var data = jQuery.parseJSON(sankore.preference("selectionner",""));
importData(data);
} else
showExample();
if(sankore.preference("sel_style","")){
changeStyle(sankore.preference("sel_style",""));
$(".style_select").val(sankore.preference("sel_style",""));
} else
changeStyle(1)
}
else
showExample();
//events
if (window.widget) {
window.widget.onleave = function(){
exportData();
sankore.setPreference("sel_style", $(".style_select").find("option:selected").val());
}
}
$("#wgt_reload").click(function(){
window.location.reload();
});
$(".style_select").change(function (event){
changeStyle($(this).find("option:selected").val());
})
$("#wgt_display, #wgt_edit").click(function(event){
if(this.id == "wgt_display"){
if(!$(this).hasClass("selected")){
if(window.sankore)
sankore.enableDropOnWidget(false);
$(this).addClass("selected");
$("#wgt_edit").removeClass("selected");
$(".style_select").css("display","none");
$(".add_block").remove();
$(".cont").each(function(){
var container = $(this);
container.find(".text_cont").removeAttr("contenteditable");
container.find(".add_img").remove();
container.find(".close_cont").remove();
container.find(".imgs_cont").removeAttr("ondragenter")
.removeAttr("ondragleave")
.removeAttr("ondragover")
.removeAttr("ondrop");
container.find(".img_block, .text_block").each(function(){
$(this).find(".close_img").remove();
$(this).find(".text_subblock").removeAttr("contenteditable");
$(this).find("input:checkbox").removeAttr("checked")
});
});
$(this).css("display", "none");
$("#wgt_edit").css("display", "block");
}
} else {
if(!$(this).hasClass("selected")){
if(window.sankore)
sankore.enableDropOnWidget(true);
$(this).addClass("selected");
$("#wgt_display").removeClass("selected");
$(".style_select").css("display","block");
$(".cont").each(function(){
var container = $(this);
$("<div class='close_cont'>").appendTo(container);
container.find(".text_cont").attr("contenteditable","true");
container.find(".imgs_cont").removeClass("right")
.attr("ondragenter", "return false;")
.attr("ondragleave", "$(this).removeClass('over'); return false;")
.attr("ondragover", "$(this).addClass('over'); return false;")
.attr("ondrop", "$(this).removeClass('over'); return onDropTarget(this,event);");
var add_img = $("<div class='add_img'>");
container.find(".img_block, .text_block").each(function(){
$("<div class='close_img'>").appendTo($(this));
if($(this).find("input:hidden").val() == 0)
$(this).find("input:checkbox").attr('checked', false);
else
$(this).find("input:checkbox").attr('checked', true);
$(this).find(".text_subblock").attr("contenteditable","true");
});
add_img.insertBefore(container.find(".clear"));
});
$("<div class='add_block'>" + sankoreLang.add + "</div>").appendTo("#data");
$(this).css("display", "none");
$("#wgt_display").css("display", "block");
}
}
});
//add new block
$(".add_block").live("click", function(){
addContainer();
});
//checkbox events
$("input:checkbox").live("click", function(){
if($("#wgt_display").hasClass("selected")){
var flag = true;
var block = $(this).parent().parent();
block.find(".text_block, .img_block, .audio_block").each(function(){
if($(this).find("input:checkbox").is(':checked') && $(this).find("input:hidden").val() == 0)
flag = false;
else if(!$(this).find("input:checkbox").is(':checked') && $(this).find("input:hidden").val() == 1)
flag = false;
});
if(flag)
block.addClass("right");
else
block.removeClass("right");
} else {
if($(this).is(":checked"))
$(this).parent().find("input:hidden").val(1);
else
$(this).parent().find("input:hidden").val(0);
}
});
//play/pause event
$(".play, .stop").live("click", function(){
var tmp_audio = $(this);
var audio = tmp_audio.parent().find("audio").get(0);
if($(this).hasClass("play")){
if(tmp_audio.parent().find("source").attr("src")){
tmp_audio.removeClass("play").addClass("stop");
var id = setInterval(function(){
if(audio.currentTime == audio.duration){
clearInterval(id);
tmp_audio.removeClass("stop").addClass("play");
}
}, 10);
tmp_audio.parent().find("input").val(id);
audio.play();
}
} else {
$(this).removeClass("stop").addClass("play");
clearInterval( tmp_audio.parent().find("input").val())
audio.pause();
}
});
$(".replay").live("click", function(){
var tmp_audio = $(this).prev();
var audio = $(this).parent().find("audio").get(0);
if(tmp_audio.parent().find("source").attr("src")){
$(this).prev().removeClass("play").addClass("stop");
clearInterval($(this).parent().find("input").val());
var id = setInterval(function(){
if(audio.currentTime == audio.duration){
clearInterval(id);
tmp_audio.removeClass("stop").addClass("play");
}
}, 10);
tmp_audio.parent().find("input").val(id);
audio.currentTime = 0;
audio.play();
}
});
//adding new img
$(".add_img").live("click", function(){
addTextBlock($(this));
});
//deleting a block
$(".close_cont").live("click",function(){
$(this).parent().remove();
refreshBlockNumbers();
});
//deleting the img block
$(".close_img").live("click", function(){
$(this).parent().remove();
});
}
//export
function exportData(){
var array_to_export = [];
$(".cont").each(function(){
var cont_obj = new Object();
cont_obj.text = $(this).find(".text_cont").text();
cont_obj.blocks = [];
$(this).find(".img_block, .audio_block, .text_block").each(function(){
var tmp_block = new Object();
if($(this).hasClass("img_block")){
if($(this).find(".audio_block").size() == 0){
tmp_block.src = $(this).find("img").attr("src").replace("../../","");
tmp_block.hidden = $(this).find("input:hidden").val();
tmp_block.h = $(this).find("img").height();
tmp_block.w = $(this).find("img").width();
tmp_block.type = "img";
}
}
if($(this).hasClass("audio_block")){
tmp_block.src = $(this).find("source").attr("src").replace("../../","");
tmp_block.hidden = $(this).parent().find("input:hidden").val();
tmp_block.type = "audio";
}
if($(this).hasClass("text_block")){
tmp_block.text = $(this).find(".text_subblock").text();
tmp_block.hidden = $(this).find("input:hidden").val();
tmp_block.type = "text";
}
cont_obj.blocks.push(tmp_block);
});
array_to_export.push(cont_obj);
});
sankore.setPreference("selectionner", JSON.stringify(array_to_export));
}
//import
function importData(data){
var tmp = 0;
for(var i in data){
var container = $("<div class='cont'>").appendTo("#data");
var sub_container = $("<div class='sub_cont'>").appendTo(container);
var imgs_container = $("<div class='imgs_cont'>").appendTo(container);
$("<div class='clear'>").appendTo(imgs_container);
$("<div class='number_cont'>" + (++tmp) + "</div>").appendTo(sub_container);
$("<div class='text_cont'>" + data[i].text + "</div>").appendTo(sub_container);
for(var j in data[i].blocks){
switch(data[i].blocks[j].type){
case "text":
var text_block = $("<div class='text_block'>").insertBefore(imgs_container.find(".clear"));
$("<div class='text_subblock'>" + data[i].blocks[j].text + "</div>").appendTo(text_block);
$("<input type='hidden' value='" + data[i].blocks[j].hidden + "'/>").appendTo(text_block);
$("<input type='checkbox' class='ch_box'/>").appendTo(text_block);
break;
case "img":
var img_block = $("<div class='img_block' style='text-align: center;'></div>").insertBefore(imgs_container.find(".clear"));
$("<input type='hidden' value='" + data[i].blocks[j].hidden + "'/>").appendTo(img_block);
$("<input type='checkbox' class='ch_box'/>").appendTo(img_block)
$("<img src=\"../../" + data[i].blocks[j].src + "\" width='" + data[i].blocks[j].w + "' height='" + data[i].blocks[j].h + "' style=\"display: inline;\"/>").appendTo(img_block);
break;
case "audio":
var img_tmp = $("<div class='img_block'>").insertBefore(imgs_container.find(".clear"));
var audio_block = $("<div class='audio_block'>").appendTo(img_tmp);
$("<div class='close_img'>").appendTo(img_tmp);
$("<div class='play'>").appendTo(audio_block);
$("<div class='replay'>").appendTo(audio_block);
var source = $("<source/>").attr("src", "../../" + data[i].blocks[j].src);
var audio = $("<audio>").appendTo(audio_block);
audio.append(source);
$("<input type='hidden' value='" + data[i].blocks[j].hidden + "'/>").appendTo(img_tmp);
$("<input type='checkbox' class='ch_box'/>").appendTo(img_tmp)
break;
}
}
}
}
//example
function showExample(){
var container = $("<div class='cont'>");
var sub_container = $("<div class='sub_cont'>").appendTo(container);
var imgs_container = $("<div class='imgs_cont'>").appendTo(container);
$("<div class='number_cont'>1</div>").appendTo(sub_container);
$("<div class='text_cont'>" + sankoreLang.short_desc + "</div>").appendTo(sub_container);
var tmp1 = $("<div class='text_block'>").appendTo(imgs_container);
$("<div class='text_subblock'>" + sankoreLang.cat + "</div>").appendTo(tmp1);
$("<input type='hidden' value='1'/>").appendTo(tmp1);
$("<input type='checkbox' class='ch_box'/>").appendTo(tmp1)
var tmp2 = $("<div class='text_block'>").appendTo(imgs_container);
$("<div class='text_subblock'>" + sankoreLang.ball + "</div>").appendTo(tmp2);
$("<input type='hidden' value='0'/>").appendTo(tmp2);
$("<input type='checkbox' class='ch_box'/>").appendTo(tmp2)
var tmp3 = $("<div class='text_block'>").appendTo(imgs_container);
$("<div class='text_subblock'>" + sankoreLang.shovel + "</div>").appendTo(tmp3);
$("<input type='hidden' value='0'/>").appendTo(tmp3);
$("<input type='checkbox' class='ch_box'/>").appendTo(tmp3)
var tmp4 = $("<div class='text_block'>").appendTo(imgs_container);
$("<div class='text_subblock'>" + sankoreLang.dog + "</div>").appendTo(tmp4);
$("<input type='hidden' value='1'/>").appendTo(tmp4);
$("<input type='checkbox' class='ch_box'/>").appendTo(tmp4)
var tmp5 = $("<div class='text_block'>").appendTo(imgs_container);
$("<div class='text_subblock'>" + sankoreLang.tree + "</div>").appendTo(tmp5);
$("<input type='hidden' value='0'/>").appendTo(tmp5);
$("<input type='checkbox' class='ch_box'/>").appendTo(tmp5)
$("<div class='clear'>").appendTo(imgs_container);
container.appendTo("#data")
}
//add new container
function addContainer(){
var container = $("<div class='cont'>");
var sub_container = $("<div class='sub_cont'>").appendTo(container);
var imgs_container = $("<div class='imgs_cont'>").appendTo(container);
imgs_container.attr("ondragenter", "return false;")
.attr("ondragleave", "$(this).removeClass('over'); return false;")
.attr("ondragover", "$(this).addClass('over'); return false;")
.attr("ondrop", "$(this).removeClass('over'); return onDropTarget(this,event);");
$("<div class='close_cont'>").appendTo(container);
$("<div class='number_cont'>"+ ($(".cont").size() + 1) +"</div>").appendTo(sub_container);
var text = $("<div class='text_cont' contenteditable>" + sankoreLang.enter + "</div>").appendTo(sub_container);
$("<div class='add_img'>").appendTo(imgs_container);
$("<div class='clear'>").appendTo(imgs_container);
container.insertBefore($(".add_block"));
}
//add new img block
function addTextBlock(dest){
var tmp = $("<div class='text_block'>").insertBefore(dest)
$("<div class='text_subblock' contenteditable='true'>" + sankoreLang.enter + "</div>").appendTo(tmp);
$("<input type='hidden' value='0'/>").appendTo(tmp);
$("<input type='checkbox' class='ch_box'/>").appendTo(tmp);
$("<div class='close_img'>").appendTo(tmp);
}
function refreshBlockNumbers(){
var i = 0;
$(".cont").each(function(){
$(this).find(".number_cont").text(++i);
})
}
function stringToXML(text){
if (window.ActiveXObject){
var doc=new ActiveXObject('Microsoft.XMLDOM');
doc.async='false';
doc.loadXML(text);
} else {
var parser=new DOMParser();
doc=parser.parseFromString(text,'text/xml');
}
return doc;
}
//changing the style
function changeStyle(val){
if(val == 1){
$(".b_top_left").removeClass("btl_pad");
$(".b_top_center").removeClass("btc_pad");
$(".b_top_right").removeClass("btr_pad");
$(".b_center_left").removeClass("bcl_pad");
$(".b_center_right").removeClass("bcr_pad");
$(".b_bottom_right").removeClass("bbr_pad");
$(".b_bottom_left").removeClass("bbl_pad");
$(".b_bottom_center").removeClass("bbc_pad");
$("#wgt_reload").removeClass("pad_color").removeClass("pad_reload");
$("#wgt_edit").removeClass("pad_color").removeClass("pad_edit");
$("#wgt_display").removeClass("pad_color").removeClass("pad_edit");
$("#wgt_name").removeClass("pad_color");
$(".style_select").removeClass("pad_select");
} else {
$(".b_top_left").addClass("btl_pad");
$(".b_top_center").addClass("btc_pad");
$(".b_top_right").addClass("btr_pad");
$(".b_center_left").addClass("bcl_pad");
$(".b_center_right").addClass("bcr_pad");
$(".b_bottom_right").addClass("bbr_pad");
$(".b_bottom_left").addClass("bbl_pad");
$(".b_bottom_center").addClass("bbc_pad");
$("#wgt_reload").addClass("pad_color").addClass("pad_reload");
$("#wgt_edit").addClass("pad_color").addClass("pad_edit");
$("#wgt_display").addClass("pad_color").addClass("pad_edit");
$("#wgt_name").addClass("pad_color");
$(".style_select").addClass("pad_select");
}
}
function onDropTarget(obj, event) {
if (event.dataTransfer) {
var format = "text/plain";
var textData = event.dataTransfer.getData(format);
if (!textData) {
alert(":(");
}
textData = stringToXML(textData);
var tmp = textData.getElementsByTagName("path")[0].firstChild.textContent;
var tmp_type = textData.getElementsByTagName("type")[0].firstChild.textContent;
if(tmp_type.substr(0, 5) == "audio"){
var img_tmp = $("<div class='img_block'>").insertBefore($(obj).find(".add_img"));
var audio_block = $("<div class='audio_block'>").appendTo(img_tmp)
$("<div class='close_img'>").appendTo(img_tmp);
$("<div class='play'>").appendTo(audio_block);
$("<div class='replay'>").appendTo(audio_block);
var source = $("<source/>").attr("src", "../../" + tmp);
var audio = $("<audio>").appendTo(audio_block);
audio.append(source);
$("<input type='hidden' value='0'/>").appendTo(img_tmp);
$("<input type='checkbox' class='ch_box'/>").appendTo(img_tmp)
} else {
var img_block = $("<div class='img_block' style='text-align: center;'></div>").insertBefore($(obj).find(".add_img"));
$("<div class='close_img'>").appendTo(img_block);
$("<input type='hidden' value='0'/>").appendTo(img_block);
$("<input type='checkbox' class='ch_box'/>").appendTo(img_block)
var tmp_img = $("<img src=\"../../" + tmp + "\" style=\"display: inline;\"/>").appendTo(img_block);
setTimeout(function(){
if(tmp_img.height() >= tmp_img.width())
tmp_img.attr("height", "120");
else{
tmp_img.attr("width","120");
tmp_img.css("margin",(120 - tmp_img.height())/2 + "px 0");
}
}, 6);
}
}
else {
alert ("Your browser does not support the dataTransfer object.");
}
if (event.stopPropagation) {
event.stopPropagation ();
}
else {
event.cancelBubble = true;
}
return false;
}

@ -1,457 +0,0 @@
var sankoreLang = {
display: "Показать",
edit: "Изменить",
short_desc: "Выберите животных из следующего списка:",
add: "Новый блок",
enter: "Введите текст ...",
cat: "кот",
ball: "мяч",
shovel: "лопата",
dog: "собака",
tree: "дерево",
wgt_name: "Выбрать верное",
reload: "Обновить",
slate: "Узор",
pad: "Планшет"
};
//main function
function start(){
$("#wgt_display").text(sankoreLang.display);
$("#wgt_edit").text(sankoreLang.edit);
$("#wgt_name").text(sankoreLang.wgt_name);
$("#wgt_reload").text(sankoreLang.reload);
$(".style_select option[value='1']").text(sankoreLang.slate);
$(".style_select option[value='2']").text(sankoreLang.pad);
if(window.sankore){
if(sankore.preference("selectionner","")){
var data = jQuery.parseJSON(sankore.preference("selectionner",""));
importData(data);
} else
showExample();
if(sankore.preference("sel_style","")){
changeStyle(sankore.preference("sel_style",""));
$(".style_select").val(sankore.preference("sel_style",""));
} else
changeStyle(1)
}
else
showExample();
//events
if (window.widget) {
window.widget.onleave = function(){
exportData();
sankore.setPreference("sel_style", $(".style_select").find("option:selected").val());
}
}
$("#wgt_reload").click(function(){
window.location.reload();
});
$(".style_select").change(function (event){
changeStyle($(this).find("option:selected").val());
})
$("#wgt_display, #wgt_edit").click(function(event){
if(this.id == "wgt_display"){
if(!$(this).hasClass("selected")){
if(window.sankore)
sankore.enableDropOnWidget(false);
$(this).addClass("selected");
$("#wgt_edit").removeClass("selected");
$(".style_select").css("display","none");
$(".add_block").remove();
$(".cont").each(function(){
var container = $(this);
container.find(".text_cont").removeAttr("contenteditable");
container.find(".add_img").remove();
container.find(".close_cont").remove();
container.find(".imgs_cont").removeAttr("ondragenter")
.removeAttr("ondragleave")
.removeAttr("ondragover")
.removeAttr("ondrop");
container.find(".img_block, .text_block").each(function(){
$(this).find(".close_img").remove();
$(this).find(".text_subblock").removeAttr("contenteditable");
$(this).find("input:checkbox").removeAttr("checked")
});
});
$(this).css("display", "none");
$("#wgt_edit").css("display", "block");
}
} else {
if(!$(this).hasClass("selected")){
if(window.sankore)
sankore.enableDropOnWidget(true);
$(this).addClass("selected");
$("#wgt_display").removeClass("selected");
$(".style_select").css("display","block");
$(".cont").each(function(){
var container = $(this);
$("<div class='close_cont'>").appendTo(container);
container.find(".text_cont").attr("contenteditable","true");
container.find(".imgs_cont").removeClass("right")
.attr("ondragenter", "return false;")
.attr("ondragleave", "$(this).removeClass('over'); return false;")
.attr("ondragover", "$(this).addClass('over'); return false;")
.attr("ondrop", "$(this).removeClass('over'); return onDropTarget(this,event);");
var add_img = $("<div class='add_img'>");
container.find(".img_block, .text_block").each(function(){
$("<div class='close_img'>").appendTo($(this));
if($(this).find("input:hidden").val() == 0)
$(this).find("input:checkbox").attr('checked', false);
else
$(this).find("input:checkbox").attr('checked', true);
$(this).find(".text_subblock").attr("contenteditable","true");
});
add_img.insertBefore(container.find(".clear"));
});
$("<div class='add_block'>" + sankoreLang.add + "</div>").appendTo("#data");
$(this).css("display", "none");
$("#wgt_display").css("display", "block");
}
}
});
//add new block
$(".add_block").live("click", function(){
addContainer();
});
//checkbox events
$("input:checkbox").live("click", function(){
if($("#wgt_display").hasClass("selected")){
var flag = true;
var block = $(this).parent().parent();
block.find(".text_block, .img_block, .audio_block").each(function(){
if($(this).find("input:checkbox").is(':checked') && $(this).find("input:hidden").val() == 0)
flag = false;
else if(!$(this).find("input:checkbox").is(':checked') && $(this).find("input:hidden").val() == 1)
flag = false;
});
if(flag)
block.addClass("right");
else
block.removeClass("right");
} else {
if($(this).is(":checked"))
$(this).parent().find("input:hidden").val(1);
else
$(this).parent().find("input:hidden").val(0);
}
});
//play/pause event
$(".play, .stop").live("click", function(){
var tmp_audio = $(this);
var audio = tmp_audio.parent().find("audio").get(0);
if($(this).hasClass("play")){
if(tmp_audio.parent().find("source").attr("src")){
tmp_audio.removeClass("play").addClass("stop");
var id = setInterval(function(){
if(audio.currentTime == audio.duration){
clearInterval(id);
tmp_audio.removeClass("stop").addClass("play");
}
}, 10);
tmp_audio.parent().find("input").val(id);
audio.play();
}
} else {
$(this).removeClass("stop").addClass("play");
clearInterval( tmp_audio.parent().find("input").val())
audio.pause();
}
});
$(".replay").live("click", function(){
var tmp_audio = $(this).prev();
var audio = $(this).parent().find("audio").get(0);
if(tmp_audio.parent().find("source").attr("src")){
$(this).prev().removeClass("play").addClass("stop");
clearInterval($(this).parent().find("input").val());
var id = setInterval(function(){
if(audio.currentTime == audio.duration){
clearInterval(id);
tmp_audio.removeClass("stop").addClass("play");
}
}, 10);
tmp_audio.parent().find("input").val(id);
audio.currentTime = 0;
audio.play();
}
});
//adding new img
$(".add_img").live("click", function(){
addTextBlock($(this));
});
//deleting a block
$(".close_cont").live("click",function(){
$(this).parent().remove();
refreshBlockNumbers();
});
//deleting the img block
$(".close_img").live("click", function(){
$(this).parent().remove();
});
}
//export
function exportData(){
var array_to_export = [];
$(".cont").each(function(){
var cont_obj = new Object();
cont_obj.text = $(this).find(".text_cont").text();
cont_obj.blocks = [];
$(this).find(".img_block, .audio_block, .text_block").each(function(){
var tmp_block = new Object();
if($(this).hasClass("img_block")){
if($(this).find(".audio_block").size() == 0){
tmp_block.src = $(this).find("img").attr("src").replace("../../","");
tmp_block.hidden = $(this).find("input:hidden").val();
tmp_block.h = $(this).find("img").height();
tmp_block.w = $(this).find("img").width();
tmp_block.type = "img";
}
}
if($(this).hasClass("audio_block")){
tmp_block.src = $(this).find("source").attr("src").replace("../../","");
tmp_block.hidden = $(this).parent().find("input:hidden").val();
tmp_block.type = "audio";
}
if($(this).hasClass("text_block")){
tmp_block.text = $(this).find(".text_subblock").text();
tmp_block.hidden = $(this).find("input:hidden").val();
tmp_block.type = "text";
}
cont_obj.blocks.push(tmp_block);
});
array_to_export.push(cont_obj);
});
sankore.setPreference("selectionner", JSON.stringify(array_to_export));
}
//import
function importData(data){
var tmp = 0;
for(var i in data){
var container = $("<div class='cont'>").appendTo("#data");
var sub_container = $("<div class='sub_cont'>").appendTo(container);
var imgs_container = $("<div class='imgs_cont'>").appendTo(container);
$("<div class='clear'>").appendTo(imgs_container);
$("<div class='number_cont'>" + (++tmp) + "</div>").appendTo(sub_container);
$("<div class='text_cont'>" + data[i].text + "</div>").appendTo(sub_container);
for(var j in data[i].blocks){
switch(data[i].blocks[j].type){
case "text":
var text_block = $("<div class='text_block'>").insertBefore(imgs_container.find(".clear"));
$("<div class='text_subblock'>" + data[i].blocks[j].text + "</div>").appendTo(text_block);
$("<input type='hidden' value='" + data[i].blocks[j].hidden + "'/>").appendTo(text_block);
$("<input type='checkbox' class='ch_box'/>").appendTo(text_block);
break;
case "img":
var img_block = $("<div class='img_block' style='text-align: center;'></div>").insertBefore(imgs_container.find(".clear"));
$("<input type='hidden' value='" + data[i].blocks[j].hidden + "'/>").appendTo(img_block);
$("<input type='checkbox' class='ch_box'/>").appendTo(img_block)
$("<img src=\"../../" + data[i].blocks[j].src + "\" width='" + data[i].blocks[j].w + "' height='" + data[i].blocks[j].h + "' style=\"display: inline;\"/>").appendTo(img_block);
break;
case "audio":
var img_tmp = $("<div class='img_block'>").insertBefore(imgs_container.find(".clear"));
var audio_block = $("<div class='audio_block'>").appendTo(img_tmp);
$("<div class='close_img'>").appendTo(img_tmp);
$("<div class='play'>").appendTo(audio_block);
$("<div class='replay'>").appendTo(audio_block);
var source = $("<source/>").attr("src", "../../" + data[i].blocks[j].src);
var audio = $("<audio>").appendTo(audio_block);
audio.append(source);
$("<input type='hidden' value='" + data[i].blocks[j].hidden + "'/>").appendTo(img_tmp);
$("<input type='checkbox' class='ch_box'/>").appendTo(img_tmp)
break;
}
}
}
}
//example
function showExample(){
var container = $("<div class='cont'>");
var sub_container = $("<div class='sub_cont'>").appendTo(container);
var imgs_container = $("<div class='imgs_cont'>").appendTo(container);
$("<div class='number_cont'>1</div>").appendTo(sub_container);
$("<div class='text_cont'>" + sankoreLang.short_desc + "</div>").appendTo(sub_container);
var tmp1 = $("<div class='text_block'>").appendTo(imgs_container);
$("<div class='text_subblock'>" + sankoreLang.cat + "</div>").appendTo(tmp1);
$("<input type='hidden' value='1'/>").appendTo(tmp1);
$("<input type='checkbox' class='ch_box'/>").appendTo(tmp1)
var tmp2 = $("<div class='text_block'>").appendTo(imgs_container);
$("<div class='text_subblock'>" + sankoreLang.ball + "</div>").appendTo(tmp2);
$("<input type='hidden' value='0'/>").appendTo(tmp2);
$("<input type='checkbox' class='ch_box'/>").appendTo(tmp2)
var tmp3 = $("<div class='text_block'>").appendTo(imgs_container);
$("<div class='text_subblock'>" + sankoreLang.shovel + "</div>").appendTo(tmp3);
$("<input type='hidden' value='0'/>").appendTo(tmp3);
$("<input type='checkbox' class='ch_box'/>").appendTo(tmp3)
var tmp4 = $("<div class='text_block'>").appendTo(imgs_container);
$("<div class='text_subblock'>" + sankoreLang.dog + "</div>").appendTo(tmp4);
$("<input type='hidden' value='1'/>").appendTo(tmp4);
$("<input type='checkbox' class='ch_box'/>").appendTo(tmp4)
var tmp5 = $("<div class='text_block'>").appendTo(imgs_container);
$("<div class='text_subblock'>" + sankoreLang.tree + "</div>").appendTo(tmp5);
$("<input type='hidden' value='0'/>").appendTo(tmp5);
$("<input type='checkbox' class='ch_box'/>").appendTo(tmp5)
$("<div class='clear'>").appendTo(imgs_container);
container.appendTo("#data")
}
//add new container
function addContainer(){
var container = $("<div class='cont'>");
var sub_container = $("<div class='sub_cont'>").appendTo(container);
var imgs_container = $("<div class='imgs_cont'>").appendTo(container);
imgs_container.attr("ondragenter", "return false;")
.attr("ondragleave", "$(this).removeClass('over'); return false;")
.attr("ondragover", "$(this).addClass('over'); return false;")
.attr("ondrop", "$(this).removeClass('over'); return onDropTarget(this,event);");
$("<div class='close_cont'>").appendTo(container);
$("<div class='number_cont'>"+ ($(".cont").size() + 1) +"</div>").appendTo(sub_container);
var text = $("<div class='text_cont' contenteditable>" + sankoreLang.enter + "</div>").appendTo(sub_container);
$("<div class='add_img'>").appendTo(imgs_container);
$("<div class='clear'>").appendTo(imgs_container);
container.insertBefore($(".add_block"));
}
//add new img block
function addTextBlock(dest){
var tmp = $("<div class='text_block'>").insertBefore(dest)
$("<div class='text_subblock' contenteditable='true'>" + sankoreLang.enter + "</div>").appendTo(tmp);
$("<input type='hidden' value='0'/>").appendTo(tmp);
$("<input type='checkbox' class='ch_box'/>").appendTo(tmp);
$("<div class='close_img'>").appendTo(tmp);
}
function refreshBlockNumbers(){
var i = 0;
$(".cont").each(function(){
$(this).find(".number_cont").text(++i);
})
}
function stringToXML(text){
if (window.ActiveXObject){
var doc=new ActiveXObject('Microsoft.XMLDOM');
doc.async='false';
doc.loadXML(text);
} else {
var parser=new DOMParser();
doc=parser.parseFromString(text,'text/xml');
}
return doc;
}
//changing the style
function changeStyle(val){
if(val == 1){
$(".b_top_left").removeClass("btl_pad");
$(".b_top_center").removeClass("btc_pad");
$(".b_top_right").removeClass("btr_pad");
$(".b_center_left").removeClass("bcl_pad");
$(".b_center_right").removeClass("bcr_pad");
$(".b_bottom_right").removeClass("bbr_pad");
$(".b_bottom_left").removeClass("bbl_pad");
$(".b_bottom_center").removeClass("bbc_pad");
$("#wgt_reload").removeClass("pad_color").removeClass("pad_reload");
$("#wgt_edit").removeClass("pad_color").removeClass("pad_edit");
$("#wgt_display").removeClass("pad_color").removeClass("pad_edit");
$("#wgt_name").removeClass("pad_color");
$(".style_select").removeClass("pad_select");
} else {
$(".b_top_left").addClass("btl_pad");
$(".b_top_center").addClass("btc_pad");
$(".b_top_right").addClass("btr_pad");
$(".b_center_left").addClass("bcl_pad");
$(".b_center_right").addClass("bcr_pad");
$(".b_bottom_right").addClass("bbr_pad");
$(".b_bottom_left").addClass("bbl_pad");
$(".b_bottom_center").addClass("bbc_pad");
$("#wgt_reload").addClass("pad_color").addClass("pad_reload");
$("#wgt_edit").addClass("pad_color").addClass("pad_edit");
$("#wgt_display").addClass("pad_color").addClass("pad_edit");
$("#wgt_name").addClass("pad_color");
$(".style_select").addClass("pad_select");
}
}
function onDropTarget(obj, event) {
if (event.dataTransfer) {
var format = "text/plain";
var textData = event.dataTransfer.getData(format);
if (!textData) {
alert(":(");
}
textData = stringToXML(textData);
var tmp = textData.getElementsByTagName("path")[0].firstChild.textContent;
var tmp_type = textData.getElementsByTagName("type")[0].firstChild.textContent;
if(tmp_type.substr(0, 5) == "audio"){
var img_tmp = $("<div class='img_block'>").insertBefore($(obj).find(".add_img"));
var audio_block = $("<div class='audio_block'>").appendTo(img_tmp)
$("<div class='close_img'>").appendTo(img_tmp);
$("<div class='play'>").appendTo(audio_block);
$("<div class='replay'>").appendTo(audio_block);
var source = $("<source/>").attr("src", "../../" + tmp);
var audio = $("<audio>").appendTo(audio_block);
audio.append(source);
$("<input type='hidden' value='0'/>").appendTo(img_tmp);
$("<input type='checkbox' class='ch_box'/>").appendTo(img_tmp)
} else {
var img_block = $("<div class='img_block' style='text-align: center;'></div>").insertBefore($(obj).find(".add_img"));
$("<div class='close_img'>").appendTo(img_block);
$("<input type='hidden' value='0'/>").appendTo(img_block);
$("<input type='checkbox' class='ch_box'/>").appendTo(img_block)
var tmp_img = $("<img src=\"../../" + tmp + "\" style=\"display: inline;\"/>").appendTo(img_block);
setTimeout(function(){
if(tmp_img.height() >= tmp_img.width())
tmp_img.attr("height", "120");
else{
tmp_img.attr("width","120");
tmp_img.css("margin",(120 - tmp_img.height())/2 + "px 0");
}
}, 6);
}
}
else {
alert ("Your browser does not support the dataTransfer object.");
}
if (event.stopPropagation) {
event.stopPropagation ();
}
else {
event.cancelBubble = true;
}
return false;
}

@ -299,6 +299,7 @@
<file>images/virtual.keyboard/41/right-active.png</file> <file>images/virtual.keyboard/41/right-active.png</file>
<file>images/virtual.keyboard/41/backspace.png</file> <file>images/virtual.keyboard/41/backspace.png</file>
<file>images/virtual.keyboard/41/capslock.png</file> <file>images/virtual.keyboard/41/capslock.png</file>
<file>images/virtual.keyboard/41/shift.png</file>
<file>images/virtual.keyboard/41/tab.png</file> <file>images/virtual.keyboard/41/tab.png</file>
<file>images/virtual.keyboard/29/centre-passive.png</file> <file>images/virtual.keyboard/29/centre-passive.png</file>
<file>images/virtual.keyboard/29/left-passive.png</file> <file>images/virtual.keyboard/29/left-passive.png</file>
@ -308,6 +309,7 @@
<file>images/virtual.keyboard/29/right-active.png</file> <file>images/virtual.keyboard/29/right-active.png</file>
<file>images/virtual.keyboard/29/backspace.png</file> <file>images/virtual.keyboard/29/backspace.png</file>
<file>images/virtual.keyboard/29/capslock.png</file> <file>images/virtual.keyboard/29/capslock.png</file>
<file>images/virtual.keyboard/29/shift.png</file>
<file>images/virtual.keyboard/29/tab.png</file> <file>images/virtual.keyboard/29/tab.png</file>
<file>images/toolPalette/cacheTool.png</file> <file>images/toolPalette/cacheTool.png</file>
<file>images/libpalette/FlashCategory.svg</file> <file>images/libpalette/FlashCategory.svg</file>

@ -57,4 +57,5 @@ UBKeyboardLocale** UBPlatformUtils::getKeyboardLayouts(int& nCount)
{ {
nCount = nKeyboardLayouts; nCount = nKeyboardLayouts;
return keyboardLayouts; return keyboardLayouts;
} }

@ -23,30 +23,82 @@ class QMainWindow;
#define SYMBOL_KEYS_COUNT 47 #define SYMBOL_KEYS_COUNT 47
struct KEYCODE{
KEYCODE()
:symbol(0)
,code(0)
,modifier(0)
{}
KEYCODE(int _symbol)
:symbol(_symbol)
,code(0)
,modifier(0)
{}
KEYCODE(int _symbol,
unsigned char _code,
int _modifier)
:symbol(_symbol)
,code(_code)
,modifier(_modifier)
{}
bool empty() const
{
return symbol == 0;
}
int symbol;
unsigned char code;
int modifier;
};
struct KEYBT struct KEYBT
{ {
const QChar symbol1; QChar symbol1;
const int code1; QChar symbol2;
const QChar symbol2; bool capsLockSwitch;
const int code2; int modifier1;
int modifier2;
KEYBT(unsigned int _symbol1, KEYCODE codes[8];
unsigned int _symbol2):
symbol1(_symbol1), KEYBT( QChar _symbol1,
code1(_symbol1), QChar _symbol2,
symbol2(_symbol2), bool _capsLockSwitch,
code2(_symbol2){} int _modifier1,
int _modifier2,
KEYCODE c1 = 0,
KEYBT(QChar _symbol1, KEYCODE c2 = 0,
int _code1, KEYCODE c3 = 0,
QChar _symbol2, KEYCODE c4 = 0,
int _code2): KEYCODE c5 = 0,
symbol1(_symbol1), KEYCODE c6 = 0,
code1(_code1), KEYCODE c7 = 0,
symbol2(_symbol2), KEYCODE c8 = 0)
code2(_code2){} :symbol1(_symbol1)
}; ,symbol2(_symbol2)
,capsLockSwitch(_capsLockSwitch)
,modifier1(_modifier1)
,modifier2(_modifier2)
{
codes[0] = c1;
codes[1] = c2;
codes[2] = c3;
codes[3] = c4;
codes[4] = c5;
codes[5] = c6;
codes[6] = c7;
codes[7] = c8;
}
~KEYBT()
{}
};
class UBKeyboardLocale class UBKeyboardLocale
{ {
@ -63,7 +115,7 @@ struct KEYBT
const QString& _name, const QString& _name,
const QString& _id, const QString& _id,
QIcon* _icon, QIcon* _icon,
const KEYBT _symbols[]) KEYBT _symbols[])
:fullName(_fullName),name(_name), id(_id), icon(_icon), :fullName(_fullName),name(_name), id(_id), icon(_icon),
constSymbols(_symbols), varSymbols(NULL) constSymbols(_symbols), varSymbols(NULL)
{} {}
@ -74,12 +126,12 @@ struct KEYBT
const QString name; const QString name;
const QString id; const QString id;
QIcon* icon; QIcon* icon;
const KEYBT* operator[] (int index) const KEYBT* operator[] (int index) const
{ {
return (varSymbols==NULL)? constSymbols + index : varSymbols[index]; return (varSymbols==NULL)? constSymbols + index : varSymbols[index];
} }
private: private:
const KEYBT* constSymbols; KEYBT* constSymbols;
KEYBT** varSymbols; KEYBT** varSymbols;
}; };

@ -104,283 +104,294 @@ void UBPlatformUtils::setDesktopMode(bool desktop)
Q_UNUSED(desktop); Q_UNUSED(desktop);
} }
const KEYBT ENGLISH_LOCALE[] = { #define KEYBTDECL(s1, s2, clSwitch, code) KEYBT(s1, s2, clSwitch, 0, 0, KEYCODE(s1, code, 0), KEYCODE(s2, code, 1))
/* ` ~ */ KEYBT(0x60, 0x7e),
/* 1 ! */ KEYBT(0x31, 0x21), #define KEYBTDECLEX1(s1, s2, clSwitch, code, cs1, cs2) KEYBT(s1, s2, clSwitch, 0, 0, KEYCODE(cs1, code, 0), KEYCODE(cs2, code, 1))
/* 2 @ */ KEYBT(0x32, 0x40), #define KEYBTDECLEX2(s1, s2, clSwitch, code, cs1, cs2) KEYBT(s1, s2, clSwitch, 0, 0, KEYCODE(cs1, code, 2), KEYCODE(cs2, code, 3))
/* 3 # */ KEYBT(0x33, 0x23),
/* 4 $ */ KEYBT(0x34, 0x24), #define KEYBTDECLEX6(s1, s2, clSwitch, code, cs1, cs2, cs3, cs4, cs5, cs6) KEYBT(s1, s2, clSwitch, 0, 0, KEYCODE(cs1, code, 0), KEYCODE(cs2, code, 1), KEYCODE(cs3, code, 2), KEYCODE(cs4, code, 3), KEYCODE(cs5, code, 4), KEYCODE(cs6, code, 5))
/* 5 % */ KEYBT(0x35, 0x25),
/* 6 ^ */ KEYBT(0x36, 0x88), #define KEYBTDECLEX8(s1, s2, clSwitch, code, cs1, cs2, cs3, cs4, cs5, cs6, cs7, cs8) KEYBT(s1, s2, clSwitch, 0, 0, KEYCODE(cs1, code, 0), KEYCODE(cs2, code, 1), KEYCODE(cs3, code, 2), KEYCODE(cs4, code, 3), KEYCODE(cs5, code, 4), KEYCODE(cs6, code, 5), KEYCODE(cs7, code, 6), KEYCODE(cs8, code, 7))
/* 7 & */ KEYBT(0x37, 0x26),
/* 8 * */ KEYBT(0x38, 0x2a),
/* 9 ( */ KEYBT(0x39, 0x28), KEYBT ENGLISH_LOCALE[] = {
/* 0 ) */ KEYBT(0x30, 0x29), /* ` ~ */ KEYBTDECL(0x60, 0x7e, false, 41),
/* - _ */ KEYBT(0x2d, 0x5f), /* 1 ! */ KEYBTDECL(0x31, 0x21, false, 2),
/* = + */ KEYBT(0x3d, 0x2b), /* 2 @ */ KEYBTDECL(0x32, 0x40, false, 3),
/* 3 # */ KEYBTDECL(0x33, 0x23, false, 4),
/* q Q */ KEYBT(0x71, 0x51), /* 4 $ */ KEYBTDECL(0x34, 0x24, false, 5),
/* w W */ KEYBT(0x77, 0x57), /* 5 % */ KEYBTDECL(0x35, 0x25, false, 6),
/* e E */ KEYBT(0x65, 0x45), /* 6 ^ */ KEYBTDECL(0x36, 0x88, false, 7),
/* r R */ KEYBT(0x72, 0x52), /* 7 & */ KEYBTDECL(0x37, 0x26, false, 8),
/* t T */ KEYBT(0x74, 0x54), /* 8 * */ KEYBTDECL(0x38, 0x2a, false, 9),
/* y Y */ KEYBT(0x79, 0x59), /* 9 ( */ KEYBTDECL(0x39, 0x28, false, 10),
/* u U */ KEYBT(0x75, 0x55), /* 0 ) */ KEYBTDECL(0x30, 0x29, false, 11),
/* i I */ KEYBT(0x69, 0x49), /* - _ */ KEYBTDECL(0x2d, 0x5f, false, 12),
/* o O */ KEYBT(0x6f, 0x4f), /* = + */ KEYBTDECL(0x3d, 0x2b, false, 13),
/* p P */ KEYBT(0x70, 0x50),
/* [ { */ KEYBT(0x5b, 0x7b), /* q Q */ KEYBTDECL(0x71, 0x51, true, 16),
/* ] } */ KEYBT(0x5d, 0x7d), /* w W */ KEYBTDECL(0x77, 0x57, true, 17),
/* e E */ KEYBTDECL(0x65, 0x45, true, 18),
/* a A */ KEYBT(0x61, 0x41), /* r R */ KEYBTDECL(0x72, 0x52, true, 19),
/* s S */ KEYBT(0x73, 0x53), /* t T */ KEYBTDECL(0x74, 0x54, true, 20),
/* d D */ KEYBT(0x64, 0x44), /* y Y */ KEYBTDECL(0x79, 0x59, true, 21),
/* f F */ KEYBT(0x66, 0x46), /* u U */ KEYBTDECL(0x75, 0x55, true, 22),
/* g G */ KEYBT(0x67, 0x47), /* i I */ KEYBTDECL(0x69, 0x49, true, 23),
/* h H */ KEYBT(0x68, 0x48), /* o O */ KEYBTDECL(0x6f, 0x4f, true, 24),
/* j J */ KEYBT(0x6a, 0x4a), /* p P */ KEYBTDECL(0x70, 0x50, true, 25),
/* k K */ KEYBT(0x6b, 0x4b), /* [ { */ KEYBTDECL(0x5b, 0x7b, false, 26),
/* l L */ KEYBT(0x6c, 0x4c), /* ] } */ KEYBTDECL(0x5d, 0x7d, false, 27),
/* ; : */ KEYBT(0x3b, 0x3a),
/* ' " */ KEYBT(0x27, 0x22), /* a A */ KEYBTDECL(0x61, 0x41, true, 30),
/* \ | */ KEYBT(0x5c, 0x7c), /* s S */ KEYBTDECL(0x73, 0x53, true, 31),
/* d D */ KEYBTDECL(0x64, 0x44, true, 32),
/* z Z */ KEYBT(0x7a, 0x5a), /* f F */ KEYBTDECL(0x66, 0x46, true, 33),
/* x X */ KEYBT(0x78, 0x58), /* g G */ KEYBTDECL(0x67, 0x47, true, 34),
/* c C */ KEYBT(0x63, 0x43), /* h H */ KEYBTDECL(0x68, 0x48, true, 35),
/* v V */ KEYBT(0x76, 0x56), /* j J */ KEYBTDECL(0x6a, 0x4a, true, 36),
/* b B */ KEYBT(0x62, 0x42), /* k K */ KEYBTDECL(0x6b, 0x4b, true, 37),
/* n N */ KEYBT(0x6e, 0x4e), /* l L */ KEYBTDECL(0x6c, 0x4c, true, 38),
/* m M */ KEYBT(0x6d, 0x4d), /* ; : */ KEYBTDECL(0x3b, 0x3a, false, 39),
/* , < */ KEYBT(0x2c, 0x3c), /* ' " */ KEYBTDECL(0x27, 0x22, false, 40),
/* . > */ KEYBT(0x2e, 0x3e), /* \ | */ KEYBTDECL(0x5c, 0x7c, false, 43),
/* / ? */ KEYBT(0x2f, 0x5f)};
/* z Z */ KEYBTDECL(0x7a, 0x5a, true, 44),
const KEYBT RUSSIAN_LOCALE [] = /* x X */ KEYBTDECL(0x78, 0x58, true, 45),
/* c C */ KEYBTDECL(0x63, 0x43, true, 46),
/* v V */ KEYBTDECL(0x76, 0x56, true, 47),
/* b B */ KEYBTDECL(0x62, 0x42, true, 48),
/* n N */ KEYBTDECL(0x6e, 0x4e, true, 49),
/* m M */ KEYBTDECL(0x6d, 0x4d, true, 50),
/* , < */ KEYBTDECL(0x2c, 0x3c, false, 51),
/* . > */ KEYBTDECL(0x2e, 0x3e, false, 52),
/* / ? */ KEYBTDECL(0x2f, 0x5f, false, 53)};
KEYBT RUSSIAN_LOCALE [] =
{ {
/* ё Ё */ KEYBT(0x451, XK_Cyrillic_io, 0x401, XK_Cyrillic_IO), /* ё Ё */ KEYBTDECLEX2(0x451, 0x401, true, 41, XK_Cyrillic_io, XK_Cyrillic_IO),
/* 1 ! */ KEYBT(0x31, 0x21), /* 1 ! */ KEYBTDECL(0x31, 0x21, false, 2),
/* 2 " */ KEYBT(0x32, 0x5c), /* 2 " */ KEYBTDECL(0x32, 0x5c, false, 3),
/* 3 № */ KEYBT(0x33, 0x33, 0x2116, XK_numerosign), /* 3 № */ KEYBTDECLEX1(0x33, 0x2116, false, 4, 0x33, XK_numerosign),
/* 4 ; */ KEYBT(0x34, 0x3b), /* 4 ; */ KEYBTDECL(0x34, 0x3b, false, 5),
/* 5 % */ KEYBT(0x35, 0x25), /* 5 % */ KEYBTDECL(0x35, 0x25, false, 6),
/* 6 : */ KEYBT(0x36, 0x3a), /* 6 : */ KEYBTDECL(0x36, 0x3a, false, 7),
/* 7 ? */ KEYBT(0x37, 0x3f), /* 7 ? */ KEYBTDECL(0x37, 0x3f, false, 8),
/* 8 * */ KEYBT(0x38, 0x2a), /* 8 * */ KEYBTDECL(0x38, 0x2a, false, 9),
/* 9 ( */ KEYBT(0x39, 0x28), /* 9 ( */ KEYBTDECL(0x39, 0x28, false, 10),
/* 0 ) */ KEYBT(0x30, 0x29), /* 0 ) */ KEYBTDECL(0x30, 0x29, false, 11),
/* - _ */ KEYBT(0x2d, 0x4f), /* - _ */ KEYBTDECL(0x2d, 0x4f, false, 12),
/* = + */ KEYBT(0x3d, 0x2b), /* = + */ KEYBTDECL(0x3d, 0x2b, false, 13),
/* й Й */ KEYBT(0x439, XK_Cyrillic_shorti, 0x419, XK_Cyrillic_SHORTI), /* й Й */ KEYBTDECLEX2(0x439, 0x419, true, 16, XK_Cyrillic_shorti, XK_Cyrillic_SHORTI),
/* ц Ц */ KEYBT(0x446, XK_Cyrillic_tse, 0x426, XK_Cyrillic_TSE), /* ц Ц */ KEYBTDECLEX2(0x446, 0x426, true, 17, XK_Cyrillic_tse, XK_Cyrillic_TSE),
/* у У */ KEYBT(0x443, XK_Cyrillic_u, 0x423, XK_Cyrillic_U), /* у У */ KEYBTDECLEX2(0x443, 0x423, true, 18, XK_Cyrillic_u, XK_Cyrillic_U),
/* к К */ KEYBT(0x43a, XK_Cyrillic_ka, 0x41a, XK_Cyrillic_KA), /* к К */ KEYBTDECLEX2(0x43a, 0x41a, true, 19, XK_Cyrillic_ka, XK_Cyrillic_KA),
/* е Е */ KEYBT(0x435, XK_Cyrillic_ie, 0x415, XK_Cyrillic_IE), /* е Е */ KEYBTDECLEX2(0x435, 0x415, true, 20, XK_Cyrillic_ie, XK_Cyrillic_IE),
/* н Н */ KEYBT(0x43d, XK_Cyrillic_en, 0x41d, XK_Cyrillic_EN), /* н Н */ KEYBTDECLEX2(0x43d, 0x41d, true, 21, XK_Cyrillic_en, XK_Cyrillic_EN),
/* г Г */ KEYBT(0x433, XK_Cyrillic_ghe, 0x413, XK_Cyrillic_GHE), /* г Г */ KEYBTDECLEX2(0x433, 0x413, true, 22, XK_Cyrillic_ghe, XK_Cyrillic_GHE),
/* ш Ш */ KEYBT(0x448, XK_Cyrillic_sha, 0x428, XK_Cyrillic_SHA), /* ш Ш */ KEYBTDECLEX2(0x448, 0x428, true, 23, XK_Cyrillic_sha, XK_Cyrillic_SHA),
/* щ Щ */ KEYBT(0x449, XK_Cyrillic_shcha, 0x429, XK_Cyrillic_SHCHA), /* щ Щ */ KEYBTDECLEX2(0x449, 0x429, true, 24, XK_Cyrillic_shcha, XK_Cyrillic_SHCHA),
/* з З */ KEYBT(0x437, XK_Cyrillic_ze, 0x417, XK_Cyrillic_ZE), /* з З */ KEYBTDECLEX2(0x437, 0x417, true, 25, XK_Cyrillic_ze, XK_Cyrillic_ZE),
/* х Х */ KEYBT(0x445, XK_Cyrillic_ha, 0x425, XK_Cyrillic_HA), /* х Х */ KEYBTDECLEX2(0x445, 0x425, true, 26, XK_Cyrillic_ha, XK_Cyrillic_HA),
/* ъ Ъ */ KEYBT(0x44a, XK_Cyrillic_hardsign, 0x42a, XK_Cyrillic_HARDSIGN), /* ъ Ъ */ KEYBTDECLEX2(0x44a, 0x42a, true, 27, XK_Cyrillic_hardsign, XK_Cyrillic_HARDSIGN),
/* ф Ф */ KEYBT(0x444, XK_Cyrillic_ef, 0x424, XK_Cyrillic_EF), /* ф Ф */ KEYBTDECLEX2(0x444, 0x424, true, 30, XK_Cyrillic_ef, XK_Cyrillic_EF),
/* ы Ы */ KEYBT(0x44b, XK_Cyrillic_yeru, 0x42b, XK_Cyrillic_YERU), /* ы Ы */ KEYBTDECLEX2(0x44b, 0x42b, true, 31, XK_Cyrillic_yeru, XK_Cyrillic_YERU),
/* в В */ KEYBT(0x432, XK_Cyrillic_ve, 0x412, XK_Cyrillic_VE), /* в В */ KEYBTDECLEX2(0x432, 0x412, true, 32, XK_Cyrillic_ve, XK_Cyrillic_VE),
/* а А */ KEYBT(0x430, XK_Cyrillic_a, 0x410, XK_Cyrillic_A), /* а А */ KEYBTDECLEX2(0x430, 0x410, true, 33, XK_Cyrillic_a, XK_Cyrillic_A),
/* п П */ KEYBT(0x43f, XK_Cyrillic_pe, 0x41f, XK_Cyrillic_PE), /* п П */ KEYBTDECLEX2(0x43f, 0x41f, true, 34, XK_Cyrillic_pe, XK_Cyrillic_PE),
/* р Р */ KEYBT(0x440, XK_Cyrillic_er, 0x420, XK_Cyrillic_ER), /* р Р */ KEYBTDECLEX2(0x440, 0x420, true, 35, XK_Cyrillic_er, XK_Cyrillic_ER),
/* о О */ KEYBT(0x43e, XK_Cyrillic_o, 0x41e, XK_Cyrillic_O), /* о О */ KEYBTDECLEX2(0x43e, 0x41e, true, 36, XK_Cyrillic_o, XK_Cyrillic_O),
/* л Л */ KEYBT(0x43b, XK_Cyrillic_el, 0x41b, XK_Cyrillic_EL), /* л Л */ KEYBTDECLEX2(0x43b, 0x41b, true, 37, XK_Cyrillic_el, XK_Cyrillic_EL),
/* д Д */ KEYBT(0x434, XK_Cyrillic_de, 0x414, XK_Cyrillic_DE), /* д Д */ KEYBTDECLEX2(0x434, 0x414, true, 38, XK_Cyrillic_de, XK_Cyrillic_DE),
/* ж Ж */ KEYBT(0x436, XK_Cyrillic_zhe, 0x416, XK_Cyrillic_ZHE), /* ж Ж */ KEYBTDECLEX2(0x436, 0x416, true, 39, XK_Cyrillic_zhe, XK_Cyrillic_ZHE),
/* э Э */ KEYBT(0x44d, XK_Cyrillic_e, 0x42d, XK_Cyrillic_E), /* э Э */ KEYBTDECLEX2(0x44d, 0x42d, true, 40, XK_Cyrillic_e, XK_Cyrillic_E),
/* \ / */ KEYBT(0x5c, 0x2f), /* \ / */ KEYBTDECL(0x5c, 0x2f, false, 43),
/* я Я */ KEYBT(0x44f, XK_Cyrillic_ya, 0x42f, XK_Cyrillic_YA), /* я Я */ KEYBTDECLEX2(0x44f, 0x42f, true, 44, XK_Cyrillic_ya, XK_Cyrillic_YA),
/* ч Ч */ KEYBT(0x447, XK_Cyrillic_che, 0x427, XK_Cyrillic_CHE), /* ч Ч */ KEYBTDECLEX2(0x447, 0x427, true, 45, XK_Cyrillic_che, XK_Cyrillic_CHE),
/* с С */ KEYBT(0x441, XK_Cyrillic_es, 0x421, XK_Cyrillic_ES), /* с С */ KEYBTDECLEX2(0x441, 0x421, true, 46, XK_Cyrillic_es, XK_Cyrillic_ES),
/* м М */ KEYBT(0x43c, XK_Cyrillic_em, 0x41c, XK_Cyrillic_EM), /* м М */ KEYBTDECLEX2(0x43c, 0x41c, true, 47, XK_Cyrillic_em, XK_Cyrillic_EM),
/* и И */ KEYBT(0x438, XK_Cyrillic_i, 0x418, XK_Cyrillic_I), /* и И */ KEYBTDECLEX2(0x438, 0x418, true, 48, XK_Cyrillic_i, XK_Cyrillic_I),
/* т Т */ KEYBT(0x442, XK_Cyrillic_te, 0x422, XK_Cyrillic_TE), /* т Т */ KEYBTDECLEX2(0x442, 0x422, true, 49, XK_Cyrillic_te, XK_Cyrillic_TE),
/* ь Ь */ KEYBT(0x44c, XK_Cyrillic_softsign, 0x42c, XK_Cyrillic_SOFTSIGN), /* ь Ь */ KEYBTDECLEX2(0x44c, 0x42c, true, 50, XK_Cyrillic_softsign, XK_Cyrillic_SOFTSIGN),
/* б Б */ KEYBT(0x431, XK_Cyrillic_be, 0x411, XK_Cyrillic_BE), /* б Б */ KEYBTDECLEX2(0x431, 0x411, true, 51, XK_Cyrillic_be, XK_Cyrillic_BE),
/* ю Ю */ KEYBT(0x44e, XK_Cyrillic_yu, 0x42e, XK_Cyrillic_YU), /* ю Ю */ KEYBTDECLEX2(0x44e, 0x42e, true, 52, XK_Cyrillic_yu, XK_Cyrillic_YU),
/* . , */ KEYBT(0x2e, 0x2c)}; /* . , */ KEYBTDECL(0x2e, 0x2c, false, 53)};
const KEYBT FRENCH_LOCALE[] = { KEYBT GERMAN_LOCALE[] = {
/* ? ? */ KEYBT(0xb2, XK_twosuperior, 0xb2, XK_twosuperior), /* ^ ? */ KEYBTDECL(0x5f, 0xb0, false, 41),
/* & 1 */ KEYBT(0x26, 0x31), /* 1 ! */ KEYBTDECL(0x31, 0x21, true, 2),
/* ? 2 */ KEYBT(0xe9, 0x32), /* 2 " */ KEYBTDECL(0x32, 0x22, true, 3),
/* " 3 */ KEYBT(0x22, 0x33), /* 3 */ KEYBTDECL(0x33, 0xa7, true, 4),
/* ' 4 */ KEYBT(0x27, 0x34), /* 4 $ */ KEYBTDECL(0x34, 0x24, true, 5),
/* ( 5 */ KEYBT(0x28, 0x35), /* 5 % */ KEYBTDECL(0x35, 0x25, true, 6),
/* - 6 */ KEYBT(0x2d, 0x36), /* 6 & */ KEYBTDECL(0x36, 0x26, true, 7),
/* ? 7 */ KEYBT(0xe8, XK_egrave, 0x37, 0x37), /* 7 / */ KEYBTDECL(0x37, 0x2f, true, 8),
/* _ 8 */ KEYBT(0x5f, 0x38), /* 8 ( */ KEYBTDECL(0x38, 0x28, true, 9),
/* ? 9 */ KEYBT(0xe7, XK_ccedilla, 0x39, 0x39), /* 9 ) */ KEYBTDECL(0x39, 0x29, true, 10),
/* ? 0 */ KEYBT(0xe0, 0x30), /* 0 = */ KEYBTDECL(0x30, 0x3d, true, 11),
/* ) ? */ KEYBT(0x29, 0xb0), /* ? ? */ KEYBTDECL(0xdf, 0x3f, true, 12),
/* = + */ KEYBT(0x3d, 0x2b), /* ` ? */ KEYBTDECL(0x60, 0xb4, true, 13),
/* a A */ KEYBT(0x61, 0x41), /* q Q */ KEYBTDECL(0x71, 0x51, true, 16),
/* z Z */ KEYBT(0x7a, 0x5a), /* w W */ KEYBTDECL(0x77, 0x57, true, 17),
/* e E */ KEYBT(0x65, 0x45), /* e E */ KEYBTDECL(0x65, 0x45, true, 18),
/* r R */ KEYBT(0x72, 0x52), /* r R */ KEYBTDECL(0x72, 0x52, true, 19),
/* t T */ KEYBT(0x74, 0x54), /* t T */ KEYBTDECL(0x74, 0x54, true, 20),
/* y Y */ KEYBT(0x79, 0x59), /* z Z */ KEYBTDECL(0x7a, 0x5a, true, 21),
/* u U */ KEYBT(0x75, 0x55), /* u U */ KEYBTDECL(0x75, 0x55, true, 22),
/* i I */ KEYBT(0x69, 0x49), /* i I */ KEYBTDECL(0x69, 0x49, true, 23),
/* o O */ KEYBT(0x6f, 0x4f), /* o O */ KEYBTDECL(0x6f, 0x4f, true, 24),
/* p P */ KEYBT(0x70, 0x50), /* p P */ KEYBTDECL(0x70, 0x50, true, 25),
/* ^ ? */ KEYBT(0x5e, 0xa8), /* ? ? */ KEYBTDECL(0xfc, 0xdc, true, 26),
/* $ ? } */ KEYBT(0x24, 0xa3), /* + * */ KEYBTDECL(0x2b, 0x2a, true, 27),
/* q Q */ KEYBT(0x71, 0x51), /* a A */ KEYBTDECL(0x61, 0x41, true, 30),
/* s S */ KEYBT(0x73, 0x53), /* s S */ KEYBTDECL(0x73, 0x53, true, 31),
/* d D */ KEYBT(0x64, 0x44), /* d D */ KEYBTDECL(0x64, 0x44, true, 32),
/* f F */ KEYBT(0x66, 0x46), /* f F */ KEYBTDECL(0x66, 0x46, true, 33),
/* g G */ KEYBT(0x67, 0x47), /* g G */ KEYBTDECL(0x67, 0x47, true, 34),
/* h H */ KEYBT(0x68, 0x48), /* h H */ KEYBTDECL(0x68, 0x48, true, 35),
/* j J */ KEYBT(0x6a, 0x4a), /* j J */ KEYBTDECL(0x6a, 0x4a, true, 36),
/* k K */ KEYBT(0x6b, 0x4b), /* k K */ KEYBTDECL(0x6b, 0x4b, true, 37),
/* l L */ KEYBT(0x6c, 0x4c), /* l L */ KEYBTDECL(0x6c, 0x4c, true, 38),
/* m M */ KEYBT(0x6d, 0x4d), /* ? ? */ KEYBTDECL(0xf6, 0xd6, true, 39),
/* ? % */ KEYBT(0xf9, 0x25), /* ? ? */ KEYBTDECL(0xe4, 0xc4, true, 40),
/* * ? */ KEYBT(0x2a, 0xb5), /* ' # */ KEYBTDECL(0x27, 0x23, true, 43),
/* w W */ KEYBT(0x77, 0x57), /* y Y */ KEYBTDECL(0x79, 0x59, true, 44),
/* x X */ KEYBT(0x78, 0x58), /* x X */ KEYBTDECL(0x78, 0x58, true, 45),
/* c C */ KEYBT(0x63, 0x43), /* c C */ KEYBTDECL(0x63, 0x43, true, 46),
/* v V */ KEYBT(0x76, 0x56), /* v V */ KEYBTDECL(0x76, 0x56, true, 47),
/* b B */ KEYBT(0x62, 0x42), /* b B */ KEYBTDECL(0x62, 0x42, true, 48),
/* n N */ KEYBT(0x6e, 0x4e), /* n N */ KEYBTDECL(0x6e, 0x4e, true, 49),
/* , ? */ KEYBT(0x2c, 0x3f), /* m M */ KEYBTDECL(0x6d, 0x4d, true, 50),
/* ; . */ KEYBT(0x3b, 0x2e), /* , ; */ KEYBTDECL(0x2c, 0x3b, true, 51),
/* : / */ KEYBT(0x3a, 0x2f), /* . : */ KEYBTDECL(0x2e, 0x3a, true, 52),
/* ! ? */ KEYBT(0x21, 0xa7)}; /* _ - */ KEYBTDECL(0x5f, 0x2d, true, 53)};
const KEYBT SWISS_FRENCH_LOCALE[] = { KEYBT FRENCH_LOCALE[] = {
/* § °*/ KEYBT(0xa7, 0xb0), /* ? ? */ KEYBTDECL(0xb2, 0xb2, true, 41),
/* 1 +*/ KEYBT(0x31, 0x2b), /* & 1 */ KEYBTDECL(0x26, 0x31, true, 2),
/* 2 "*/ KEYBT(0x32, 0x22), /* ? 2 */ KEYBTDECL(0xe9, 0x32, true, 3),
/* 3 **/ KEYBT(0x33, 0x2a), /* " 3 */ KEYBTDECL(0x22, 0x33, true, 4),
/* 4 ç*/ KEYBT(0x34, 0xe7), /* ' 4 */ KEYBTDECL(0x27, 0x34, true, 5),
/* 5 %*/ KEYBT(0x35, 0x25), /* ( 5 */ KEYBTDECL(0x28, 0x35, true, 6),
/* 6 &*/ KEYBT(0x36, 0x26), /* - 6 */ KEYBTDECL(0x2d, 0x36, true, 7),
/* 7 /*/ KEYBT(0x37, 0x2f), /* ? 7 */ KEYBTDECL(0xe8, 0x37, true, 8),
/* 8 (*/ KEYBT(0x38, 0x28), /* _ 8 */ KEYBTDECL(0x5f, 0x38, true, 9),
/* 9 )*/ KEYBT(0x39, 0x29), /* ? 9 */ KEYBTDECL(0xe7, 0x39, true, 10),
/* 0 =*/ KEYBT(0x30, 0x3d), /* ? 0 */ KEYBTDECL(0xe0, 0x29, true, 11),
/* ' ?*/ KEYBT(0x27, 0x5f), /* ) ? */ KEYBTDECL(0x29, 0xb0, true, 12),
/* ^ `*/ KEYBT(0x5e, 0x60), /* = + */ KEYBTDECL(0x3d, 0x2b, true, 13),
/* q Q*/ KEYBT(0x71, 0x51), /* a A */ KEYBTDECLEX6(0x61, 0x41, true, 16, 0x61, 0x41, 0xe0, 0xc0, 0xe4, 0xc4),
/* w W*/ KEYBT(0x77, 0x57), /* z Z */ KEYBTDECL(0x7a, 0x5a, true, 17),
/* e E*/ KEYBT(0x65, 0x45), /* e E */ KEYBTDECLEX6(0x65, 0x45, true, 18, 0x65, 0x45, 0xe8, 0xc8, 0xeb, 0xcb),
/* r R*/ KEYBT(0x72, 0x52), /* r R */ KEYBTDECL(0x72, 0x52, true, 19),
/* t T*/ KEYBT(0x74, 0x54), /* t T */ KEYBTDECL(0x74, 0x54, true, 20),
/* z Z*/ KEYBT(0x7a, 0x5a), /* y Y */ KEYBTDECLEX6(0x79, 0x59, true, 21, 0x79, 0x59, 0, 0, 0xff, 0),
/* u U*/ KEYBT(0x75, 0x55), /* u U */ KEYBTDECLEX6(0x75, 0x55, true, 22, 0x75, 0x55, 0xf9, 0xd9, 0xfc, 0xdc),
/* i I*/ KEYBT(0x69, 0x49), /* i I */ KEYBTDECLEX6(0x69, 0x49, true, 23, 0x69, 0x49, 0xec, 0xcc, 0xef, 0xcf),
/* o O*/ KEYBT(0x6f, 0x4f), /* o O */ KEYBTDECLEX6(0x6f, 0x4f, true, 24, 0x6f, 0x4f, 0xf2, 0xd2, 0xf6, 0xd6),
/* p P*/ KEYBT(0x70, 0x50), /* p P */ KEYBTDECL(0x70, 0x50, true, 25),
/* è ü*/ KEYBT(0xe8, 0xfa), /* ^ ? */ KEYBT(0x5e, 0xa8, true, 1, 2, KEYCODE(0x5e, 26, 0), KEYCODE(0xa8, 26, 1)),
/* ¨ !*/ KEYBT(0xa8 ,0x21), /* $ ? } */ KEYBTDECL(0x24, 0xa3, true, 27),
/* a A*/ KEYBT(0x61, 0x41), /* q Q */ KEYBTDECL(0x71, 0x51, true, 30),
/* s S*/ KEYBT(0x73, 0x53), /* s S */ KEYBTDECL(0x73, 0x53, true, 31),
/* d D*/ KEYBT(0x64, 0x44), /* d D */ KEYBTDECL(0x64, 0x44, true, 32),
/* f F*/ KEYBT(0x66, 0x46), /* f F */ KEYBTDECL(0x66, 0x46, true, 33),
/* g G*/ KEYBT(0x67, 0x47), /* g G */ KEYBTDECL(0x67, 0x47, true, 34),
/* h H*/ KEYBT(0x68, 0x48), /* h H */ KEYBTDECL(0x68, 0x48, true, 35),
/* j J*/ KEYBT(0x6a, 0x4a), /* j J */ KEYBTDECL(0x6a, 0x4a, true, 36),
/* k K*/ KEYBT(0x6b, 0x4b), /* k K */ KEYBTDECL(0x6b, 0x4b, true, 37),
/* l L*/ KEYBT(0x6c, 0x4c), /* l L */ KEYBTDECL(0x6c, 0x4c, true, 38),
/* é ö*/ KEYBT(0xe9, 0xf6), /* m M */ KEYBTDECL(0x6d, 0x4d, true, 39),
/* à ä*/ KEYBT(0xe0, 0xe4), /* ? % */ KEYBTDECL(0xf9, 0x25, true, 40),
/* $ £*/ KEYBT(0x24, 0xa3), /* * ? */ KEYBTDECL(0x2a, 0xb5, true, 43),
/* < >*/ KEYBT(0x3c, 0x3e), /* w W */ KEYBTDECL(0x77, 0x57, true, 44),
/* y Y*/ KEYBT(0x79, 0x59), /* x X */ KEYBTDECL(0x78, 0x58, true, 45),
/* x X*/ KEYBT(0x78, 0x58), /* c C */ KEYBTDECL(0x63, 0x43, true, 46),
/* c C*/ KEYBT(0x63, 0x43), /* v V */ KEYBTDECL(0x76, 0x56, true, 47),
/* v V*/ KEYBT(0x76, 0x56), /* b B */ KEYBTDECL(0x62, 0x42, true, 48),
/* b B*/ KEYBT(0x62, 0x42), /* n N */ KEYBTDECL(0x6e, 0x4e, true, 49),
/* n N*/ KEYBT(0x6e, 0x4e), /* , ? */ KEYBTDECL(0x2c, 0x3f, true, 50),
/* m M*/ KEYBT(0x6d, 0x4d), /* ; . */ KEYBTDECL(0x3b, 0x2e, true, 51),
/* , ;*/ KEYBT(0x2c, 0x3b), /* : / */ KEYBTDECL(0x3a, 0x2f, true, 52),
/* . :*/ KEYBT(0x2e, 0x3a), /* ! ? */ KEYBTDECL(0x21, 0xa7, true, 53)};
/* - _*/ KEYBT(0x2d, 0x5f)};
const KEYBT GERMAN_LOCALE[] = { KEYBT SWISS_FRENCH_LOCALE[] = {
/* ^ ? */ KEYBT(0x5f, 0xb0), /* § °*/ KEYBTDECL(0xa7, 0xb0, false, 41),
/* 1 ! */ KEYBT(0x31, 0x21), /* 1 +*/ KEYBTDECL(0x31, 0x2b, false, 2),
/* 2 " */ KEYBT(0x32, 0x22), /* 2 "*/ KEYBTDECL(0x32, 0x22, false, 3),
/* 3 */ KEYBT(0x33, 0xa7), /* 3 **/ KEYBTDECL(0x33, 0x2a, false, 4),
/* 4 $ */ KEYBT(0x34, 0x24), /* 4 ç*/ KEYBTDECL(0x34, 0xe7, false, 5),
/* 5 % */ KEYBT(0x35, 0x25), /* 5 %*/ KEYBTDECL(0x35, 0x25, false, 6),
/* 6 & */ KEYBT(0x36, 0x26), /* 6 &*/ KEYBTDECL(0x36, 0x26, false, 7),
/* 7 / */ KEYBT(0x37, 0x2f), /* 7 /*/ KEYBTDECL(0x37, 0x2f, false, 8),
/* 8 ( */ KEYBT(0x38, 0x28), /* 8 (*/ KEYBTDECL(0x38, 0x28, false, 9),
/* 9 ) */ KEYBT(0x39, 0x29), /* 9 )*/ KEYBTDECL(0x39, 0x29, false, 10),
/* 0 = */ KEYBT(0x30, 0x3d), /* 0 =*/ KEYBTDECL(0x30, 0x3d, false, 11),
/* ? ? */ KEYBT(0xdf, 0x3f), /* ' ?*/ KEYBTDECL(0x27, 0x5f, false, 12),
/* ` ? */ KEYBT(0x60, 0xb4), /* ^ `*/ KEYBT(0x5e, 0x60, false, 1, 2, KEYCODE(0x5e, 13, 0), KEYCODE(0x60, 13, 1)),
/* q Q */ KEYBT(0x71, 0x51), /* q Q*/ KEYBTDECL(0x71, 0x51, true, 16),
/* w W */ KEYBT(0x77, 0x57), /* w W*/ KEYBTDECL(0x77, 0x57, true, 17),
/* e E */ KEYBT(0x65, 0x45), /* e E*/ KEYBTDECLEX8(0x65, 0x45, true, 18, 0x65, 0x45, 0xea, 0xca, 0xe8, 0xc8, 0xeb, 0xcb),
/* r R */ KEYBT(0x72, 0x52), /* r R*/ KEYBTDECL(0x72, 0x52, true, 19),
/* t T */ KEYBT(0x74, 0x54), /* t T*/ KEYBTDECL(0x74, 0x54, true, 20),
/* z Z */ KEYBT(0x7a, 0x5a), /* z Z*/ KEYBTDECL(0x7a, 0x5a, true, 21),
/* u U */ KEYBT(0x75, 0x55), /* u U*/ KEYBTDECLEX8(0x75, 0x55, true, 22, 0x75, 0x55, 0xfb, 0xdb, 0xf9, 0xd9, 0xfc, 0xdc),
/* i I */ KEYBT(0x69, 0x49), /* i I*/ KEYBTDECLEX8(0x69, 0x49, true, 23, 0x69, 0x49, 0xee, 0xce, 0xec, 0xcc, 0xef, 0xcf),
/* o O */ KEYBT(0x6f, 0x4f), /* o O*/ KEYBTDECLEX8(0x6f, 0x4f, true, 24, 0x6f, 0x4f, 0xf4, 0xd4, 0xf2, 0xd2, 0xf6, 0xd6),
/* p P */ KEYBT(0x70, 0x50), /* p P*/ KEYBTDECL(0x70, 0x50, true, 25),
/* ? ? */ KEYBT(0xfc, 0xdc), /* è ü*/ KEYBTDECL(0xe8, 0xfa, false, 26),
/* + * */ KEYBT(0x2b, 0x2a), /* ¨ !*/ KEYBT(0xa8, 0x21, false, 3, 0, KEYCODE(0xa8, 27, 0), KEYCODE(0x21, 27, 1)),
/* a A */ KEYBT(0x61, 0x41), /* a A*/ KEYBTDECLEX8(0x61, 0x41, true, 30, 0x61, 0x41, 0xe2, 0xc2, 0xe0, 0xc0, 0xe4, 0xc4),
/* s S */ KEYBT(0x73, 0x53), /* s S*/ KEYBTDECL(0x73, 0x53, true, 31),
/* d D */ KEYBT(0x64, 0x44), /* d D*/ KEYBTDECL(0x64, 0x44, true, 32),
/* f F */ KEYBT(0x66, 0x46), /* f F*/ KEYBTDECL(0x66, 0x46, true, 33),
/* g G */ KEYBT(0x67, 0x47), /* g G*/ KEYBTDECL(0x67, 0x47, true, 34),
/* h H */ KEYBT(0x68, 0x48), /* h H*/ KEYBTDECL(0x68, 0x48, true, 35),
/* j J */ KEYBT(0x6a, 0x4a), /* j J*/ KEYBTDECL(0x6a, 0x4a, true, 36),
/* k K */ KEYBT(0x6b, 0x4b), /* k K*/ KEYBTDECL(0x6b, 0x4b, true, 37),
/* l L */ KEYBT(0x6c, 0x4c), /* l L*/ KEYBTDECL(0x6c, 0x4c, true, 38),
/* ? ? */ KEYBT(0xf6, 0xd6), /* é ö*/ KEYBTDECL(0xe9, 0xf6, false, 39),
/* ? ? */ KEYBT(0xe4, 0xc4), /* à ä*/ KEYBTDECL(0xe0, 0xe4, false, 40),
/* ' # */ KEYBT(0x27, 0x23), /* $ £*/ KEYBTDECL(0x24, 0xa3, false, 43),
/* y Y */ KEYBT(0x79, 0x59), /* < >*/ KEYBTDECL(0x3c, 0x3e, false, 44),
/* x X */ KEYBT(0x78, 0x58), /* y Y*/ KEYBTDECLEX8(0x79, 0x59, true, 45, 0x79, 0x59, 0, 0, 0, 0, 0xff, 0),
/* c C */ KEYBT(0x63, 0x43), /* x X*/ KEYBTDECL(0x78, 0x58, true, 46),
/* v V */ KEYBT(0x76, 0x56), /* c C*/ KEYBTDECL(0x63, 0x43, true, 47),
/* b B */ KEYBT(0x62, 0x42), /* v V*/ KEYBTDECL(0x76, 0x56, true, 48),
/* n N */ KEYBT(0x6e, 0x4e), /* b B*/ KEYBTDECL(0x62, 0x42, true, 49),
/* m M */ KEYBT(0x6d, 0x4d), /* n N*/ KEYBTDECL(0x6e, 0x4e, true, 50),
/* , ; */ KEYBT(0x2c, 0x3b), /* m M*/ KEYBTDECL(0x6d, 0x4d, true, 51),
/* . : */ KEYBT(0x2e, 0x3a), /* , ;*/ KEYBTDECL(0x2c, 0x3b, false, 52),
/* _ - */ KEYBT(0x5f, 0x2d)}; /* . :*/ KEYBTDECL(0x2e, 0x3a, false, 53),
/* - _*/ KEYBTDECL(0x2d, 0x5f, false, 54)};
void UBPlatformUtils::initializeKeyboardLayouts() void UBPlatformUtils::initializeKeyboardLayouts()
{ {
nKeyboardLayouts = 4; nKeyboardLayouts = 5;
keyboardLayouts = new UBKeyboardLocale*[nKeyboardLayouts]; keyboardLayouts = new UBKeyboardLocale*[nKeyboardLayouts];
keyboardLayouts[0] = new UBKeyboardLocale("English", "en", "", new QIcon(":/images/flags/en.png"), ENGLISH_LOCALE); keyboardLayouts[0] = new UBKeyboardLocale("English", "en", "", new QIcon(":/images/flags/en.png"), ENGLISH_LOCALE);
keyboardLayouts[1] = new UBKeyboardLocale("Russian", "ru", "", new QIcon(":/images/flags/ru.png"),RUSSIAN_LOCALE); keyboardLayouts[1] = new UBKeyboardLocale("Russian", "ru", "", new QIcon(":/images/flags/ru.png"),RUSSIAN_LOCALE);
keyboardLayouts[2] = new UBKeyboardLocale("French", "fr", "", new QIcon(":/images/flags/fr.png"), FRENCH_LOCALE); keyboardLayouts[2] = new UBKeyboardLocale("German", "de", "", new QIcon(":/images/flags/de.png"), GERMAN_LOCALE);
keyboardLayouts[3] = new UBKeyboardLocale("Swiss French", "fr", "", new QIcon(":/images/flags/fr.png"), SWISS_FRENCH_LOCALE); keyboardLayouts[3] = new UBKeyboardLocale("French", "fr", "", new QIcon(":/images/flags/fr.png"), FRENCH_LOCALE);
keyboardLayouts[4] = new UBKeyboardLocale("German", "de", "", new QIcon(":/images/flags/de.png"), GERMAN_LOCALE); keyboardLayouts[4] = new UBKeyboardLocale("Swiss French", "fr", "", new QIcon(":/images/flags/fr.png"), SWISS_FRENCH_LOCALE);
} }
void UBPlatformUtils::destroyKeyboardLayouts() void UBPlatformUtils::destroyKeyboardLayouts()
{ {
for(int i=0; i<4; i++) for(int i=0; i<nKeyboardLayouts; i++)
delete keyboardLayouts[i]; delete keyboardLayouts[i];
delete [] keyboardLayouts; delete [] keyboardLayouts;
keyboardLayouts = NULL; keyboardLayouts = NULL;

@ -10,8 +10,12 @@
#import <Foundation/NSAutoreleasePool.h> #import <Foundation/NSAutoreleasePool.h>
#import <Carbon/Carbon.h> #import <Carbon/Carbon.h>
#import <APELite.h> #import <APELite.h>
/*
// commented because Sankore crashes on Java Script. It seems to backends dependencies.
#import <WebKit/WebKit.h> #import <WebKit/WebKit.h>
#import <AppKit/AppKit.h> #import <AppKit/AppKit.h>
*/
NSString* bundleShortVersion(NSBundle *bundle) NSString* bundleShortVersion(NSBundle *bundle)
@ -20,8 +24,8 @@ NSString* bundleShortVersion(NSBundle *bundle)
} }
OSStatus emptySetSystemUIMode ( OSStatus emptySetSystemUIMode (
SystemUIMode inMode, SystemUIMode inMode,
SystemUIOptions inOptions) SystemUIOptions inOptions)
{ {
Q_UNUSED(inMode); Q_UNUSED(inMode);
Q_UNUSED(inOptions); Q_UNUSED(inOptions);
@ -33,7 +37,7 @@ void *originalSetSystemUIMode = 0;
void UBPlatformUtils::init() void UBPlatformUtils::init()
{ {
initializeKeyboardLayouts(); initializeKeyboardLayouts();
// qwidget_mac.mm qt_mac_set_fullscreen_mode uses kUIModeAllSuppressed which is unfortunate in our case // qwidget_mac.mm qt_mac_set_fullscreen_mode uses kUIModeAllSuppressed which is unfortunate in our case
// //
@ -252,7 +256,7 @@ void UBPlatformUtils::runInstaller(const QString &installerFilePath)
bool success = process.startDetached(escaped); bool success = process.startDetached(escaped);
if(success) if(success)
return; return;
} }
// did not work .. lets load the dmg ... // did not work .. lets load the dmg ...
@ -336,206 +340,206 @@ void UBPlatformUtils::setWindowNonActivableFlag(QWidget* widget, bool nonAcivabl
} }
QPixmap qpixmapFromIconRef(IconRef iconRef, int size) { QPixmap qpixmapFromIconRef(IconRef iconRef, int size) {
OSErr result; OSErr result;
int iconSize; int iconSize;
OSType elementType; OSType elementType;
// Determine elementType and iconSize // Determine elementType and iconSize
if (size <= 16) { if (size <= 16) {
elementType = kSmall32BitData; elementType = kSmall32BitData;
iconSize = 16; iconSize = 16;
} else if (size <= 32) { } else if (size <= 32) {
elementType = kLarge32BitData; elementType = kLarge32BitData;
iconSize = 32; iconSize = 32;
} else { } else {
elementType = kThumbnail32BitData; elementType = kThumbnail32BitData;
iconSize = 128; iconSize = 128;
} }
// Get icon into an IconFamily // Get icon into an IconFamily
IconFamilyHandle hIconFamily = 0; IconFamilyHandle hIconFamily = 0;
IconRefToIconFamily(iconRef, kSelectorAllAvailableData, &hIconFamily); IconRefToIconFamily(iconRef, kSelectorAllAvailableData, &hIconFamily);
// Extract data // Extract data
Handle hRawBitmapData = NewHandle(iconSize * iconSize * 4); Handle hRawBitmapData = NewHandle(iconSize * iconSize * 4);
result = GetIconFamilyData( hIconFamily, elementType, hRawBitmapData ); result = GetIconFamilyData( hIconFamily, elementType, hRawBitmapData );
if (result != noErr) { if (result != noErr) {
DisposeHandle(hRawBitmapData); DisposeHandle(hRawBitmapData);
return QPixmap(); return QPixmap();
} }
// Convert data to QImage // Convert data to QImage
QImage image(iconSize, iconSize, QImage::Format_ARGB32); QImage image(iconSize, iconSize, QImage::Format_ARGB32);
HLock(hRawBitmapData); HLock(hRawBitmapData);
unsigned long* data = (unsigned long*) *hRawBitmapData; unsigned long* data = (unsigned long*) *hRawBitmapData;
for (int posy=0; posy<iconSize; ++posy, data+=iconSize) { for (int posy=0; posy<iconSize; ++posy, data+=iconSize) {
#ifdef __BIG_ENDIAN__ #ifdef __BIG_ENDIAN__
uchar* line = image.scanLine(posy); uchar* line = image.scanLine(posy);
memcpy(line, data, iconSize * 4); memcpy(line, data, iconSize * 4);
#else #else
uchar* src = (uchar*) data; uchar* src = (uchar*) data;
uchar* dst = image.scanLine(posy); uchar* dst = image.scanLine(posy);
for (int posx=0; posx<iconSize; src+=4, dst+=4, ++posx) { for (int posx=0; posx<iconSize; src+=4, dst+=4, ++posx) {
dst[0] = src[3]; dst[0] = src[3];
dst[1] = src[2]; dst[1] = src[2];
dst[2] = src[1]; dst[2] = src[1];
dst[3] = src[0]; dst[3] = src[0];
} }
#endif #endif
} }
HUnlock(hRawBitmapData); HUnlock(hRawBitmapData);
DisposeHandle( hRawBitmapData ); DisposeHandle( hRawBitmapData );
// Scale to wanted size // Scale to wanted size
image = image.scaled(size, size, Qt::KeepAspectRatio, Qt::SmoothTransformation); image = image.scaled(size, size, Qt::KeepAspectRatio, Qt::SmoothTransformation);
return QPixmap::fromImage(image); return QPixmap::fromImage(image);
} }
QString QStringFromStringRef(CFStringRef stringRef) QString QStringFromStringRef(CFStringRef stringRef)
{ {
if (stringRef!=NULL) if (stringRef!=NULL)
{ {
char tmp[1024]; char tmp[1024];
CFStringGetCString(stringRef, tmp, 1024, 0); CFStringGetCString(stringRef, tmp, 1024, 0);
return QString(tmp); return QString(tmp);
} }
else else
return QString(); return QString();
} }
KEYBT* createKeyBt(const UCKeyboardLayout* keyLayout, int vkk) KEYBT* createKeyBt(const UCKeyboardLayout* keyLayout, int vkk)
{ {
UInt32 deadKeyState = 0L; UInt32 deadKeyState = 0L;
UInt32 kbdType = kKeyboardISO; UInt32 kbdType = kKeyboardISO;
UniCharCount cnt1, cnt2; UniCharCount cnt1, cnt2, cnt3;
UniChar unicodeString1[100], unicodeString2[100]; UniChar unicodeString1[100], unicodeString2[100], unicodeString3[100];
UCKeyTranslate(keyLayout, vkk, kUCKeyActionDisplay, 0, kbdType, kUCKeyTranslateNoDeadKeysBit, &deadKeyState, 100, &cnt1, unicodeString1); UCKeyTranslate(keyLayout, vkk, kUCKeyActionDisplay, 0, kbdType, kUCKeyTranslateNoDeadKeysBit, &deadKeyState, 100, &cnt1, unicodeString1);
UCKeyTranslate(keyLayout, vkk, kUCKeyActionDisplay, (shiftKey >> 8) & 0xff, kbdType, kUCKeyTranslateNoDeadKeysBit, &deadKeyState, 100, &cnt2, unicodeString2); UCKeyTranslate(keyLayout, vkk, kUCKeyActionDisplay, (shiftKey >> 8) & 0xff, kbdType, kUCKeyTranslateNoDeadKeysBit, &deadKeyState, 100, &cnt2, unicodeString2);
UCKeyTranslate(keyLayout, vkk, kUCKeyActionDisplay, (alphaLock >> 8) & 0xff, kbdType, kUCKeyTranslateNoDeadKeysBit, &deadKeyState, 100, &cnt2, unicodeString3);
return new KEYBT(unicodeString1[0], vkk, unicodeString2[0], vkk); return new KEYBT(unicodeString1[0], unicodeString2[0], unicodeString1[0] != unicodeString3[0], 0,0, KEYCODE(0, vkk, 0), KEYCODE(0, vkk, 1));
} }
void UBPlatformUtils::initializeKeyboardLayouts() void UBPlatformUtils::initializeKeyboardLayouts()
{ {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; CFStringRef keys[] = { kTISPropertyInputSourceCategory, kTISPropertyInputSourceIsEnableCapable, kTISPropertyInputSourceIsSelectCapable };
CFStringRef keys[] = { kTISPropertyInputSourceCategory, kTISPropertyInputSourceIsEnableCapable, kTISPropertyInputSourceIsSelectCapable }; const void* values[] = { kTISCategoryKeyboardInputSource, kCFBooleanTrue, kCFBooleanTrue };
const void* values[] = { kTISCategoryKeyboardInputSource, kCFBooleanTrue, kCFBooleanTrue }; CFDictionaryRef dict = CFDictionaryCreate(NULL, (const void **)keys, (const void **)values, 3, NULL, NULL);
CFDictionaryRef dict = CFDictionaryCreate(NULL, (const void **)keys, (const void **)values, 3, NULL, NULL); CFArrayRef kbds = TISCreateInputSourceList(dict, false);
CFArrayRef kbds = TISCreateInputSourceList(dict, false);
int count = CFArrayGetCount(kbds);
int count = CFArrayGetCount(kbds); QList<UBKeyboardLocale*> result;
QList<UBKeyboardLocale*> result;
for(int i=0; i<count; i++)
{
TISInputSourceRef keyLayoutRef = (TISInputSourceRef)CFArrayGetValueAtIndex(kbds, i);
if (keyLayoutRef==NULL)
continue;
CFDataRef ref = (CFDataRef) TISGetInputSourceProperty(keyLayoutRef,
kTISPropertyUnicodeKeyLayoutData);
if (ref==NULL)
continue;
const UCKeyboardLayout* keyLayout = (const UCKeyboardLayout*) CFDataGetBytePtr(ref);
if (keyLayoutRef==NULL)
continue;
KEYBT** keybt = new KEYBT*[SYMBOL_KEYS_COUNT];
keybt[0] = createKeyBt(keyLayout, 10);
keybt[1] = createKeyBt(keyLayout, 18);
keybt[2] = createKeyBt(keyLayout, 19);
keybt[3] = createKeyBt(keyLayout, 20);
keybt[4] = createKeyBt(keyLayout, 21);
keybt[5] = createKeyBt(keyLayout, 23);
keybt[6] = createKeyBt(keyLayout, 22);
keybt[7] = createKeyBt(keyLayout, 26);
keybt[8] = createKeyBt(keyLayout, 28);
keybt[9] = createKeyBt(keyLayout, 25);
keybt[10] = createKeyBt(keyLayout, 29);
keybt[11] = createKeyBt(keyLayout, 27);
keybt[12] = createKeyBt(keyLayout, 24);
keybt[13] = createKeyBt(keyLayout, 12);
keybt[14] = createKeyBt(keyLayout, 13);
keybt[15] = createKeyBt(keyLayout, 14);
keybt[16] = createKeyBt(keyLayout, 15);
keybt[17] = createKeyBt(keyLayout, 17);
keybt[18] = createKeyBt(keyLayout, 16);
keybt[19] = createKeyBt(keyLayout, 32);
keybt[20] = createKeyBt(keyLayout, 34);
keybt[21] = createKeyBt(keyLayout, 31);
keybt[22] = createKeyBt(keyLayout, 35);
keybt[23] = createKeyBt(keyLayout, 33);
keybt[24] = createKeyBt(keyLayout, 30);
keybt[25] = createKeyBt(keyLayout, 0);
keybt[26] = createKeyBt(keyLayout, 1);
keybt[27] = createKeyBt(keyLayout, 2);
keybt[28] = createKeyBt(keyLayout, 3);
keybt[29] = createKeyBt(keyLayout, 5);
keybt[30] = createKeyBt(keyLayout, 4);
keybt[31] = createKeyBt(keyLayout, 38);
keybt[32] = createKeyBt(keyLayout, 40);
keybt[33] = createKeyBt(keyLayout, 37);
keybt[34] = createKeyBt(keyLayout, 41);
keybt[35] = createKeyBt(keyLayout, 39);
keybt[36] = createKeyBt(keyLayout, 42);
keybt[37] = createKeyBt(keyLayout, 6);
keybt[38] = createKeyBt(keyLayout, 7);
keybt[39] = createKeyBt(keyLayout, 8);
keybt[40] = createKeyBt(keyLayout, 9);
keybt[41] = createKeyBt(keyLayout, 11);
keybt[42] = createKeyBt(keyLayout, 45);
keybt[43] = createKeyBt(keyLayout, 46);
keybt[44] = createKeyBt(keyLayout, 43);
keybt[45] = createKeyBt(keyLayout, 47);
keybt[46] = createKeyBt(keyLayout, 44);
CFStringRef sr = (CFStringRef) TISGetInputSourceProperty(keyLayoutRef, kTISPropertyInputSourceID);
QString ID = QStringFromStringRef(sr);
sr = (CFStringRef) TISGetInputSourceProperty(keyLayoutRef, kTISPropertyLocalizedName);
QString fullName = QStringFromStringRef(sr);
CFArrayRef langs = (CFArrayRef) TISGetInputSourceProperty(keyLayoutRef, kTISPropertyInputSourceLanguages);
QString name = "??";
if (CFArrayGetCount(langs)>0)
{
CFStringRef langRef = (CFStringRef)CFArrayGetValueAtIndex(langs, 0);
name = QStringFromStringRef(langRef);
qDebug() << "name is " + name;
}
//IconRef iconRef = (IconRef)TISGetInputSourceProperty(kTISPropertyIconRef, kTISPropertyInputSourceLanguages);
const QString resName = ":/images/flags/" + name + ".png";
QIcon *iconLang = new QIcon(resName);
result.append(new UBKeyboardLocale(fullName, name, ID, iconLang, keybt));
}
if (result.size()==0)
{
nKeyboardLayouts = 0;
keyboardLayouts = NULL;
}
else
{
nKeyboardLayouts = result.size();
keyboardLayouts = new UBKeyboardLocale*[nKeyboardLayouts];
for(int i=0; i<nKeyboardLayouts; i++)
keyboardLayouts[i] = result[i];
}
for(int i=0; i<count; i++)
{
TISInputSourceRef keyLayoutRef = (TISInputSourceRef)CFArrayGetValueAtIndex(kbds, i);
if (keyLayoutRef==NULL)
continue;
CFDataRef ref = (CFDataRef) TISGetInputSourceProperty(keyLayoutRef,
kTISPropertyUnicodeKeyLayoutData);
if (ref==NULL)
continue;
const UCKeyboardLayout* keyLayout = (const UCKeyboardLayout*) CFDataGetBytePtr(ref);
if (keyLayoutRef==NULL)
continue;
KEYBT** keybt = new KEYBT*[SYMBOL_KEYS_COUNT];
keybt[0] = createKeyBt(keyLayout, 10);
keybt[1] = createKeyBt(keyLayout, 18);
keybt[2] = createKeyBt(keyLayout, 19);
keybt[3] = createKeyBt(keyLayout, 20);
keybt[4] = createKeyBt(keyLayout, 21);
keybt[5] = createKeyBt(keyLayout, 23);
keybt[6] = createKeyBt(keyLayout, 22);
keybt[7] = createKeyBt(keyLayout, 26);
keybt[8] = createKeyBt(keyLayout, 28);
keybt[9] = createKeyBt(keyLayout, 25);
keybt[10] = createKeyBt(keyLayout, 29);
keybt[11] = createKeyBt(keyLayout, 27);
keybt[12] = createKeyBt(keyLayout, 24);
keybt[13] = createKeyBt(keyLayout, 12);
keybt[14] = createKeyBt(keyLayout, 13);
keybt[15] = createKeyBt(keyLayout, 14);
keybt[16] = createKeyBt(keyLayout, 15);
keybt[17] = createKeyBt(keyLayout, 17);
keybt[18] = createKeyBt(keyLayout, 16);
keybt[19] = createKeyBt(keyLayout, 32);
keybt[20] = createKeyBt(keyLayout, 34);
keybt[21] = createKeyBt(keyLayout, 31);
keybt[22] = createKeyBt(keyLayout, 35);
keybt[23] = createKeyBt(keyLayout, 33);
keybt[24] = createKeyBt(keyLayout, 30);
keybt[25] = createKeyBt(keyLayout, 0);
keybt[26] = createKeyBt(keyLayout, 1);
keybt[27] = createKeyBt(keyLayout, 2);
keybt[28] = createKeyBt(keyLayout, 3);
keybt[29] = createKeyBt(keyLayout, 5);
keybt[30] = createKeyBt(keyLayout, 4);
keybt[31] = createKeyBt(keyLayout, 38);
keybt[32] = createKeyBt(keyLayout, 40);
keybt[33] = createKeyBt(keyLayout, 37);
keybt[34] = createKeyBt(keyLayout, 41);
keybt[35] = createKeyBt(keyLayout, 39);
keybt[36] = createKeyBt(keyLayout, 42);
keybt[37] = createKeyBt(keyLayout, 6);
keybt[38] = createKeyBt(keyLayout, 7);
keybt[39] = createKeyBt(keyLayout, 8);
keybt[40] = createKeyBt(keyLayout, 9);
keybt[41] = createKeyBt(keyLayout, 11);
keybt[42] = createKeyBt(keyLayout, 45);
keybt[43] = createKeyBt(keyLayout, 46);
keybt[44] = createKeyBt(keyLayout, 43);
keybt[45] = createKeyBt(keyLayout, 47);
keybt[46] = createKeyBt(keyLayout, 44);
CFStringRef sr = (CFStringRef) TISGetInputSourceProperty(keyLayoutRef, kTISPropertyInputSourceID);
QString ID = QStringFromStringRef(sr);
sr = (CFStringRef) TISGetInputSourceProperty(keyLayoutRef, kTISPropertyLocalizedName);
QString fullName = QString::fromUtf8([sr UTF8String], strlen([sr UTF8String]));
CFArrayRef langs = (CFArrayRef) TISGetInputSourceProperty(keyLayoutRef, kTISPropertyInputSourceLanguages);
QString name = "??";
if (CFArrayGetCount(langs)>0)
{
CFStringRef langRef = (CFStringRef)CFArrayGetValueAtIndex(langs, 0);
name = QStringFromStringRef(langRef);
qDebug() << "name is " + name;
}
//IconRef iconRef = (IconRef)TISGetInputSourceProperty(kTISPropertyIconRef, kTISPropertyInputSourceLanguages);
const QString resName = ":/images/flags/" + name + ".png";
QIcon *iconLang = new QIcon(resName);
result.append(new UBKeyboardLocale(fullName, name, ID, iconLang, keybt));
}
if (result.size()==0)
{
nKeyboardLayouts = 0;
keyboardLayouts = NULL;
}
else
{
nKeyboardLayouts = result.size();
keyboardLayouts = new UBKeyboardLocale*[nKeyboardLayouts];
for(int i=0; i<nKeyboardLayouts; i++)
keyboardLayouts[i] = result[i];
}
[pool drain];
} }
void UBPlatformUtils::destroyKeyboardLayouts() void UBPlatformUtils::destroyKeyboardLayouts()
@ -544,13 +548,14 @@ void UBPlatformUtils::destroyKeyboardLayouts()
QString UBPlatformUtils::urlFromClipboard() QString UBPlatformUtils::urlFromClipboard()
{ {
QString qsRet; QString qsRet;
/*
// commented because Sankore crashes on Java Script. It seems to backends dependencies.
NSPasteboard* pPasteboard = [NSPasteboard pasteboardWithName:@"Apple CFPasteboard drag"]; NSPasteboard* pPasteboard = [NSPasteboard pasteboardWithName:@"Apple CFPasteboard drag"];
WebArchive* pArchive = [[WebArchive alloc] initWithData:[pPasteboard dataForType:@"com.apple.webarchive"]]; WebArchive* pArchive = [[WebArchive alloc] initWithData:[pPasteboard dataForType:@"com.apple.webarchive"]];
qsRet = [[[[pArchive mainResource] URL] absoluteString] UTF8String]; qsRet = [[[[pArchive mainResource] URL] absoluteString] UTF8String];
[pArchive release]; [pArchive release];
*/
return qsRet; return qsRet;
} }

@ -128,272 +128,271 @@ void UBPlatformUtils::setWindowNonActivableFlag(QWidget* widget, bool nonAcivabl
SetWindowLong(widget->winId(), GWL_EXSTYLE, exStyle); SetWindowLong(widget->winId(), GWL_EXSTYLE, exStyle);
} }
#define KEYBTDECL(s1, s2, clSwitch) KEYBT(s1, s2, clSwitch, 0, 0, KEYCODE(s1), KEYCODE(s2))
KEYBT RUSSIAN_LOCALE [] =
const KEYBT RUSSIAN_LOCALE [] =
{ {
/* Ј і */ KEYBT(0x451, 0x401), /* Ј і */ KEYBTDECL(0x451, 0x401, true),
/* 1 ! */ KEYBT(0x31, 0x21), /* 1 ! */ KEYBTDECL(0x31, 0x21, false),
/* 2 " */ KEYBT(0x32, 0x5c), /* 2 " */ KEYBTDECL(0x32, 0x5c, false),
/* 3 ? */ KEYBT(0x33, 0x2116), /* 3 ? */ KEYBTDECL(0x33, 0x2116, false),
/* 4 ; */ KEYBT(0x34, 0x3b), /* 4 ; */ KEYBTDECL(0x34, 0x3b, false),
/* 5 % */ KEYBT(0x35, 0x25), /* 5 % */ KEYBTDECL(0x35, 0x25, false),
/* 6 : */ KEYBT(0x36, 0x3a), /* 6 : */ KEYBTDECL(0x36, 0x3a, false),
/* 7 ? */ KEYBT(0x37, 0x3f), /* 7 ? */ KEYBTDECL(0x37, 0x3f, false),
/* 8 * */ KEYBT(0x38, 0x2a), /* 8 * */ KEYBTDECL(0x38, 0x2a, false),
/* 9 ( */ KEYBT(0x39, 0x28), /* 9 ( */ KEYBTDECL(0x39, 0x28, false),
/* 0 ) */ KEYBT(0x30, 0x29), /* 0 ) */ KEYBTDECL(0x30, 0x29, false),
/* - _ */ KEYBT(0x2d, 0x4f), /* - _ */ KEYBTDECL(0x2d, 0x4f, false),
/* = + */ KEYBT(0x3d, 0x2b), /* = + */ KEYBTDECL(0x3d, 0x2b, false),
/* К к */ KEYBT(0x439, 0x419), /* К к */ KEYBTDECL(0x439, 0x419, true),
/* Г г */ KEYBT(0x446, 0x426), /* Г г */ KEYBTDECL(0x446, 0x426, true),
/* Х х */ KEYBT(0x443, 0x423), /* Х х */ KEYBTDECL(0x443, 0x423, true),
/* Л л */ KEYBT(0x43a, 0x41a), /* Л л */ KEYBTDECL(0x43a, 0x41a, true),
/* Е е */ KEYBT(0x435, 0x415), /* Е е */ KEYBTDECL(0x435, 0x415, true),
/* О о */ KEYBT(0x43d, 0x41d), /* О о */ KEYBTDECL(0x43d, 0x41d, true),
/* З з */ KEYBT(0x433, 0x413), /* З з */ KEYBTDECL(0x433, 0x413, true),
/* Ы ы */ KEYBT(0x448, 0x428), /* Ы ы */ KEYBTDECL(0x448, 0x428, true),
/* Э э */ KEYBT(0x449, 0x429), /* Э э */ KEYBTDECL(0x449, 0x429, true),
/* Ъ ъ */ KEYBT(0x437, 0x417), /* Ъ ъ */ KEYBTDECL(0x437, 0x417, true),
/* И и */ KEYBT(0x445, 0x425), /* И и */ KEYBTDECL(0x445, 0x425, true),
/* Я я */ KEYBT(0x44a, 0x42a), /* Я я */ KEYBTDECL(0x44a, 0x42a, true),
/* Ж ж */ KEYBT(0x444, 0x424), /* Ж ж */ KEYBTDECL(0x444, 0x424, true),
/* Щ щ */ KEYBT(0x44b, 0x42b), /* Щ щ */ KEYBTDECL(0x44b, 0x42b, true),
/* Ч ч */ KEYBT(0x432, 0x412), /* Ч ч */ KEYBTDECL(0x432, 0x412, true),
/* Б б */ KEYBT(0x430, 0x410), /* Б б */ KEYBTDECL(0x430, 0x410, true),
/* Р р */ KEYBT(0x43f, 0x41f), /* Р р */ KEYBTDECL(0x43f, 0x41f, true),
/* Т т */ KEYBT(0x440, 0x420), /* Т т */ KEYBTDECL(0x440, 0x420, true),
/* П п */ KEYBT(0x43e, 0x41e), /* П п */ KEYBTDECL(0x43e, 0x41e, true),
/* М м */ KEYBT(0x43b, 0x41b), /* М м */ KEYBTDECL(0x43b, 0x41b, true),
/* Д д */ KEYBT(0x434, 0x414), /* Д д */ KEYBTDECL(0x434, 0x414, true),
/* Ц ц */ KEYBT(0x436, 0x416), /* Ц ц */ KEYBTDECL(0x436, 0x416, true),
/* Ь ь */ KEYBT(0x44d, 0x42d), /* Ь ь */ KEYBTDECL(0x44d, 0x42d, true),
/* \ / */ KEYBT(0x5c, 0x2f), /* \ / */ KEYBTDECL(0x5c, 0x2f, false),
/* С с */ KEYBT(0x44f, 0x42f), /* С с */ KEYBTDECL(0x44f, 0x42f, true),
/* Ю ю */ KEYBT(0x447, 0x427), /* Ю ю */ KEYBTDECL(0x447, 0x427, true),
/* У у */ KEYBT(0x441, 0x421), /* У у */ KEYBTDECL(0x441, 0x421, true),
/* Н н */ KEYBT(0x43c, 0x41c), /* Н н */ KEYBTDECL(0x43c, 0x41c, true),
/* Й й */ KEYBT(0x438, 0x418), /* Й й */ KEYBTDECL(0x438, 0x418, true),
/* Ф ф */ KEYBT(0x442, 0x422), /* Ф ф */ KEYBTDECL(0x442, 0x422, true),
/* Ш ш */ KEYBT(0x44c, 0x42c), /* Ш ш */ KEYBTDECL(0x44c, 0x42c, true),
/* В в */ KEYBT(0x431, 0x411), /* В в */ KEYBTDECL(0x431, 0x411, true),
/* А а */ KEYBT(0x44e, 0x42e), /* А а */ KEYBTDECL(0x44e, 0x42e, true),
/* . , */ KEYBT(0x2e, 0x2c)}; /* . , */ KEYBTDECL(0x2e, 0x2c, false)};
const KEYBT ENGLISH_LOCALE[] = { KEYBT ENGLISH_LOCALE[] = {
/* ` ~ */ KEYBT(0x60, 0x7e), /* ` ~ */ KEYBTDECL(0x60, 0x7e, false),
/* 1 ! */ KEYBT(0x31, 0x21), /* 1 ! */ KEYBTDECL(0x31, 0x21, false),
/* 2 @ */ KEYBT(0x32, 0x40), /* 2 @ */ KEYBTDECL(0x32, 0x40, false),
/* 3 # */ KEYBT(0x33, 0x23), /* 3 # */ KEYBTDECL(0x33, 0x23, false),
/* 4 $ */ KEYBT(0x34, 0x24), /* 4 $ */ KEYBTDECL(0x34, 0x24, false),
/* 5 % */ KEYBT(0x35, 0x25), /* 5 % */ KEYBTDECL(0x35, 0x25, false),
/* 6 ^ */ KEYBT(0x36, 0x5e), /* 6 ^ */ KEYBTDECL(0x36, 0x5e, false),
/* 7 & */ KEYBT(0x37, 0x26), /* 7 & */ KEYBTDECL(0x37, 0x26, false),
/* 8 * */ KEYBT(0x38, 0x2a), /* 8 * */ KEYBTDECL(0x38, 0x2a, false),
/* 9 ( */ KEYBT(0x39, 0x28), /* 9 ( */ KEYBTDECL(0x39, 0x28, false),
/* 0 ) */ KEYBT(0x30, 0x29), /* 0 ) */ KEYBTDECL(0x30, 0x29, false),
/* - _ */ KEYBT(0x2d, 0x5f), /* - _ */ KEYBTDECL(0x2d, 0x5f, false),
/* = + */ KEYBT(0x3d, 0x2b), /* = + */ KEYBTDECL(0x3d, 0x2b, false),
/* q Q */ KEYBT(0x71, 0x51), /* q Q */ KEYBTDECL(0x71, 0x51, true),
/* w W */ KEYBT(0x77, 0x57), /* w W */ KEYBTDECL(0x77, 0x57, true),
/* e E */ KEYBT(0x65, 0x45), /* e E */ KEYBTDECL(0x65, 0x45, true),
/* r R */ KEYBT(0x72, 0x52), /* r R */ KEYBTDECL(0x72, 0x52, true),
/* t T */ KEYBT(0x74, 0x54), /* t T */ KEYBTDECL(0x74, 0x54, true),
/* y Y */ KEYBT(0x79, 0x59), /* y Y */ KEYBTDECL(0x79, 0x59, true),
/* u U */ KEYBT(0x75, 0x55), /* u U */ KEYBTDECL(0x75, 0x55, true),
/* i I */ KEYBT(0x69, 0x49), /* i I */ KEYBTDECL(0x69, 0x49, true),
/* o O */ KEYBT(0x6f, 0x4f), /* o O */ KEYBTDECL(0x6f, 0x4f, true),
/* p P */ KEYBT(0x70, 0x50), /* p P */ KEYBTDECL(0x70, 0x50, true),
/* [ { */ KEYBT(0x5b, 0x7b), /* [ { */ KEYBTDECL(0x5b, 0x7b, false),
/* ] } */ KEYBT(0x5d, 0x7d), /* ] } */ KEYBTDECL(0x5d, 0x7d, false),
/* a A */ KEYBT(0x61, 0x41), /* a A */ KEYBTDECL(0x61, 0x41, true),
/* s S */ KEYBT(0x73, 0x53), /* s S */ KEYBTDECL(0x73, 0x53, true),
/* d D */ KEYBT(0x64, 0x44), /* d D */ KEYBTDECL(0x64, 0x44, true),
/* f F */ KEYBT(0x66, 0x46), /* f F */ KEYBTDECL(0x66, 0x46, true),
/* g G */ KEYBT(0x67, 0x47), /* g G */ KEYBTDECL(0x67, 0x47, true),
/* h H */ KEYBT(0x68, 0x48), /* h H */ KEYBTDECL(0x68, 0x48, true),
/* j J */ KEYBT(0x6a, 0x4a), /* j J */ KEYBTDECL(0x6a, 0x4a, true),
/* k K */ KEYBT(0x6b, 0x4b), /* k K */ KEYBTDECL(0x6b, 0x4b, true),
/* l L */ KEYBT(0x6c, 0x4c), /* l L */ KEYBTDECL(0x6c, 0x4c, true),
/* ; : */ KEYBT(0x3b, 0x3a), /* ; : */ KEYBTDECL(0x3b, 0x3a, false),
/* ' " */ KEYBT(0x27, 0x22), /* ' " */ KEYBTDECL(0x27, 0x22, false),
/* \ | */ KEYBT(0x5c, 0x7c), /* \ | */ KEYBTDECL(0x5c, 0x7c, false),
/* z Z */ KEYBT(0x7a, 0x5a), /* z Z */ KEYBTDECL(0x7a, 0x5a, true),
/* x X */ KEYBT(0x78, 0x58), /* x X */ KEYBTDECL(0x78, 0x58, true),
/* c C */ KEYBT(0x63, 0x43), /* c C */ KEYBTDECL(0x63, 0x43, true),
/* v V */ KEYBT(0x76, 0x56), /* v V */ KEYBTDECL(0x76, 0x56, true),
/* b B */ KEYBT(0x62, 0x42), /* b B */ KEYBTDECL(0x62, 0x42, true),
/* n N */ KEYBT(0x6e, 0x4e), /* n N */ KEYBTDECL(0x6e, 0x4e, true),
/* m M */ KEYBT(0x6d, 0x4d), /* m M */ KEYBTDECL(0x6d, 0x4d, true),
/* , < */ KEYBT(0x2c, 0x3c), /* , < */ KEYBTDECL(0x2c, 0x3c, false),
/* . > */ KEYBT(0x2e, 0x3e), /* . > */ KEYBTDECL(0x2e, 0x3e, false),
/* / ? */ KEYBT(0x2f, 0x5f)}; /* / ? */ KEYBTDECL(0x2f, 0x5f, false)};
const KEYBT FRENCH_LOCALE[] = { KEYBT FRENCH_LOCALE[] = {
/* ? ? */ KEYBT(0xb2, 0xb2), /* ? ? */ KEYBTDECL(0xb2, 0xb2, true),
/* & 1 */ KEYBT(0x26, 0x31), /* & 1 */ KEYBTDECL(0x26, 0x31, true),
/* ? 2 */ KEYBT(0xe9, 0x32), /* ? 2 */ KEYBTDECL(0xe9, 0x32, true),
/* " 3 */ KEYBT(0x22, 0x33), /* " 3 */ KEYBTDECL(0x22, 0x33, true),
/* ' 4 */ KEYBT(0x27, 0x34), /* ' 4 */ KEYBTDECL(0x27, 0x34, true),
/* ( 5 */ KEYBT(0x28, 0x35), /* ( 5 */ KEYBTDECL(0x28, 0x35, true),
/* - 6 */ KEYBT(0x2d, 0x36), /* - 6 */ KEYBTDECL(0x2d, 0x36, true),
/* ? 7 */ KEYBT(0xe8, 0x37), /* ? 7 */ KEYBTDECL(0xe8, 0x37, true),
/* _ 8 */ KEYBT(0x5f, 0x38), /* _ 8 */ KEYBTDECL(0x5f, 0x38, true),
/* ? 9 */ KEYBT(0xe7, 0x39), /* ? 9 */ KEYBTDECL(0xe7, 0x39, true),
/* ? 0 */ KEYBT(0xe0, 0x30), /* ? 0 */ KEYBTDECL(0xe0, 0x29, true),
/* ) ? */ KEYBT(0x29, 0xb0), /* ) ? */ KEYBTDECL(0x29, 0xb0, true),
/* = + */ KEYBT(0x3d, 0x2b), /* = + */ KEYBTDECL(0x3d, 0x2b, true),
/* a A */ KEYBT(0x61, 0x41), /* a A */ KEYBT(0x61, 0x41, true, 0, 0, 0x61, 0x41, 0xe0, 0xc0, 0xe4, 0xc4),
/* z Z */ KEYBT(0x7a, 0x5a), /* z Z */ KEYBTDECL(0x7a, 0x5a, true),
/* e E */ KEYBT(0x65, 0x45), /* e E */ KEYBT(0x65, 0x45, true, 0, 0, 0x65, 0x45, 0xe8, 0xc8, 0xeb, 0xcb),
/* r R */ KEYBT(0x72, 0x52), /* r R */ KEYBTDECL(0x72, 0x52, true),
/* t T */ KEYBT(0x74, 0x54), /* t T */ KEYBTDECL(0x74, 0x54, true),
/* y Y */ KEYBT(0x79, 0x59), /* y Y */ KEYBT(0x79, 0x59, true, 0, 0, 0x79, 0x59, 0, 0, 0xff),
/* u U */ KEYBT(0x75, 0x55), /* u U */ KEYBT(0x75, 0x55, true, 0, 0, 0x75, 0x55, 0xf9, 0xd9, 0xfc, 0xdc),
/* i I */ KEYBT(0x69, 0x49), /* i I */ KEYBT(0x69, 0x49, true, 0, 0, 0x69, 0x49, 0xec, 0xcc, 0xef, 0xcf),
/* o O */ KEYBT(0x6f, 0x4f), /* o O */ KEYBT(0x6f, 0x4f, true, 0, 0, 0x6f, 0x4f, 0xf2, 0xd2, 0xf6, 0xd6),
/* p P */ KEYBT(0x70, 0x50), /* p P */ KEYBTDECL(0x70, 0x50, true),
/* ^ ? */ KEYBT(0x5e, 0xa8), /* ^ ? */ KEYBT(0x5e, 0xa8, true, 1, 2, 0x5e, 0xa8),
/* $ ? } */ KEYBT(0x24, 0xa3), /* $ ? } */ KEYBTDECL(0x24, 0xa3, true),
/* q Q */ KEYBT(0x71, 0x51), /* q Q */ KEYBTDECL(0x71, 0x51, true),
/* s S */ KEYBT(0x73, 0x53), /* s S */ KEYBTDECL(0x73, 0x53, true),
/* d D */ KEYBT(0x64, 0x44), /* d D */ KEYBTDECL(0x64, 0x44, true),
/* f F */ KEYBT(0x66, 0x46), /* f F */ KEYBTDECL(0x66, 0x46, true),
/* g G */ KEYBT(0x67, 0x47), /* g G */ KEYBTDECL(0x67, 0x47, true),
/* h H */ KEYBT(0x68, 0x48), /* h H */ KEYBTDECL(0x68, 0x48, true),
/* j J */ KEYBT(0x6a, 0x4a), /* j J */ KEYBTDECL(0x6a, 0x4a, true),
/* k K */ KEYBT(0x6b, 0x4b), /* k K */ KEYBTDECL(0x6b, 0x4b, true),
/* l L */ KEYBT(0x6c, 0x4c), /* l L */ KEYBTDECL(0x6c, 0x4c, true),
/* m M */ KEYBT(0x6d, 0x4d), /* m M */ KEYBTDECL(0x6d, 0x4d, true),
/* ? % */ KEYBT(0xf9, 0x25), /* ? % */ KEYBTDECL(0xf9, 0x25, true),
/* * ? */ KEYBT(0x2a, 0xb5), /* * ? */ KEYBTDECL(0x2a, 0xb5, true),
/* w W */ KEYBT(0x77, 0x57), /* w W */ KEYBTDECL(0x77, 0x57, true),
/* x X */ KEYBT(0x78, 0x58), /* x X */ KEYBTDECL(0x78, 0x58, true),
/* c C */ KEYBT(0x63, 0x43), /* c C */ KEYBTDECL(0x63, 0x43, true),
/* v V */ KEYBT(0x76, 0x56), /* v V */ KEYBTDECL(0x76, 0x56, true),
/* b B */ KEYBT(0x62, 0x42), /* b B */ KEYBTDECL(0x62, 0x42, true),
/* n N */ KEYBT(0x6e, 0x4e), /* n N */ KEYBTDECL(0x6e, 0x4e, true),
/* , ? */ KEYBT(0x2c, 0x3f), /* , ? */ KEYBTDECL(0x2c, 0x3f, true),
/* ; . */ KEYBT(0x3b, 0x2e), /* ; . */ KEYBTDECL(0x3b, 0x2e, true),
/* : / */ KEYBT(0x3a, 0x2f), /* : / */ KEYBTDECL(0x3a, 0x2f, true),
/* ! ? */ KEYBT(0x21, 0xa7)}; /* ! ? */ KEYBTDECL(0x21, 0xa7, true)};
const KEYBT SWISS_FRENCH_LOCALE[] = { KEYBT SWISS_FRENCH_LOCALE[] = {
/* § °*/ KEYBT(0xa7, 0xb0), /* § °*/ KEYBTDECL(0xa7, 0xb0, false),
/* 1 +*/ KEYBT(0x31, 0x2b), /* 1 +*/ KEYBTDECL(0x31, 0x2b, false),
/* 2 "*/ KEYBT(0x32, 0x22), /* 2 "*/ KEYBTDECL(0x32, 0x22, false),
/* 3 **/ KEYBT(0x33, 0x2a), /* 3 **/ KEYBTDECL(0x33, 0x2a, false),
/* 4 ç*/ KEYBT(0x34, 0xe7), /* 4 ç*/ KEYBTDECL(0x34, 0xe7, false),
/* 5 %*/ KEYBT(0x35, 0x25), /* 5 %*/ KEYBTDECL(0x35, 0x25, false),
/* 6 &*/ KEYBT(0x36, 0x26), /* 6 &*/ KEYBTDECL(0x36, 0x26, false),
/* 7 /*/ KEYBT(0x37, 0x2f), /* 7 /*/ KEYBTDECL(0x37, 0x2f, false),
/* 8 (*/ KEYBT(0x38, 0x28), /* 8 (*/ KEYBTDECL(0x38, 0x28, false),
/* 9 )*/ KEYBT(0x39, 0x29), /* 9 )*/ KEYBTDECL(0x39, 0x29, false),
/* 0 =*/ KEYBT(0x30, 0x3d), /* 0 =*/ KEYBTDECL(0x30, 0x3d, false),
/* ' ?*/ KEYBT(0x27, 0x5f), /* ' ?*/ KEYBTDECL(0x27, 0x5f, false),
/* ^ `*/ KEYBT(0x5e, 0x60), /* ^ `*/ KEYBT(0x5e, 0x60, false, 1, 2, 0x5e, 0x60),
/* q Q*/ KEYBT(0x71, 0x51), /* q Q*/ KEYBTDECL(0x71, 0x51, true),
/* w W*/ KEYBT(0x77, 0x57), /* w W*/ KEYBTDECL(0x77, 0x57, true),
/* e E*/ KEYBT(0x65, 0x45), /* e E*/ KEYBT(0x65, 0x45, true, 0, 0, 0x65, 0x45, 0xea, 0xca, 0xe8, 0xc8, 0xeb, 0xcb),
/* r R*/ KEYBT(0x72, 0x52), /* r R*/ KEYBTDECL(0x72, 0x52, true),
/* t T*/ KEYBT(0x74, 0x54), /* t T*/ KEYBTDECL(0x74, 0x54, true),
/* z Z*/ KEYBT(0x7a, 0x5a), /* z Z*/ KEYBTDECL(0x7a, 0x5a, true),
/* u U*/ KEYBT(0x75, 0x55), /* u U*/ KEYBT(0x75, 0x55, true, 0, 0, 0x75, 0x55, 0xfb, 0xdb, 0xf9, 0xd9, 0xfc, 0xdc),
/* i I*/ KEYBT(0x69, 0x49), /* i I*/ KEYBT(0x69, 0x49, true, 0, 0, 0x69, 0x49, 0xee, 0xce, 0xec, 0xcc, 0xef, 0xcf),
/* o O*/ KEYBT(0x6f, 0x4f), /* o O*/ KEYBT(0x6f, 0x4f, true, 0, 0, 0x6f, 0x4f, 0xf4, 0xd4, 0xf2, 0xd2, 0xf6, 0xd6),
/* p P*/ KEYBT(0x70, 0x50), /* p P*/ KEYBTDECL(0x70, 0x50, true),
/* è ü*/ KEYBT(0xe8, 0xfa), /* è ü*/ KEYBTDECL(0xe8, 0xfa, false),
/* ¨ !*/ KEYBT(0xa8 ,0x21), /* ¨ !*/ KEYBT(0xa8, 0x21, false, 3, 0, 0xa8, 0x21),
/* a A*/ KEYBT(0x61, 0x41), /* a A*/ KEYBT(0x61, 0x41, true, 0, 0, 0x61, 0x41, 0xe2, 0xc2, 0xe0, 0xc0, 0xe4, 0xc4),
/* s S*/ KEYBT(0x73, 0x53), /* s S*/ KEYBTDECL(0x73, 0x53, true),
/* d D*/ KEYBT(0x64, 0x44), /* d D*/ KEYBTDECL(0x64, 0x44, true),
/* f F*/ KEYBT(0x66, 0x46), /* f F*/ KEYBTDECL(0x66, 0x46, true),
/* g G*/ KEYBT(0x67, 0x47), /* g G*/ KEYBTDECL(0x67, 0x47, true),
/* h H*/ KEYBT(0x68, 0x48), /* h H*/ KEYBTDECL(0x68, 0x48, true),
/* j J*/ KEYBT(0x6a, 0x4a), /* j J*/ KEYBTDECL(0x6a, 0x4a, true),
/* k K*/ KEYBT(0x6b, 0x4b), /* k K*/ KEYBTDECL(0x6b, 0x4b, true),
/* l L*/ KEYBT(0x6c, 0x4c), /* l L*/ KEYBTDECL(0x6c, 0x4c, true),
/* é ö*/ KEYBT(0xe9, 0xf6), /* é ö*/ KEYBTDECL(0xe9, 0xf6, false),
/* à ä*/ KEYBT(0xe0, 0xe4), /* à ä*/ KEYBTDECL(0xe0, 0xe4, false),
/* $ £*/ KEYBT(0x24, 0xa3), /* $ £*/ KEYBTDECL(0x24, 0xa3, false),
/* < >*/ KEYBT(0x3c, 0x3e), /* < >*/ KEYBTDECL(0x3c, 0x3e, false),
/* y Y*/ KEYBT(0x79, 0x59), /* y Y*/ KEYBT(0x79, 0x59, true, 0, 0, 0x79, 0x59, 0, 0, 0, 0, 0xff),
/* x X*/ KEYBT(0x78, 0x58), /* x X*/ KEYBTDECL(0x78, 0x58, true),
/* c C*/ KEYBT(0x63, 0x43), /* c C*/ KEYBTDECL(0x63, 0x43, true),
/* v V*/ KEYBT(0x76, 0x56), /* v V*/ KEYBTDECL(0x76, 0x56, true),
/* b B*/ KEYBT(0x62, 0x42), /* b B*/ KEYBTDECL(0x62, 0x42, true),
/* n N*/ KEYBT(0x6e, 0x4e), /* n N*/ KEYBTDECL(0x6e, 0x4e, true),
/* m M*/ KEYBT(0x6d, 0x4d), /* m M*/ KEYBTDECL(0x6d, 0x4d, true),
/* , ;*/ KEYBT(0x2c, 0x3b), /* , ;*/ KEYBTDECL(0x2c, 0x3b, false),
/* . :*/ KEYBT(0x2e, 0x3a), /* . :*/ KEYBTDECL(0x2e, 0x3a, false),
/* - _*/ KEYBT(0x2d, 0x5f)}; /* - _*/ KEYBTDECL(0x2d, 0x5f, false)};
const KEYBT GERMAN_LOCALE[] = {
/* ^ ? */ KEYBT(0x5f, 0xb0), KEYBT GERMAN_LOCALE[] = {
/* 1 ! */ KEYBT(0x31, 0x21), /* ^ ? */ KEYBTDECL(0x5f, 0xb0, false),
/* 2 " */ KEYBT(0x32, 0x22), /* 1 ! */ KEYBTDECL(0x31, 0x21, true),
/* 3 § */ KEYBT(0x33, 0xa7), /* 2 " */ KEYBTDECL(0x32, 0x22, true),
/* 4 $ */ KEYBT(0x34, 0x24), /* 3 § */ KEYBTDECL(0x33, 0xa7, true),
/* 5 % */ KEYBT(0x35, 0x25), /* 4 $ */ KEYBTDECL(0x34, 0x24, true),
/* 6 & */ KEYBT(0x36, 0x26), /* 5 % */ KEYBTDECL(0x35, 0x25, true),
/* 7 / */ KEYBT(0x37, 0x2f), /* 6 & */ KEYBTDECL(0x36, 0x26, true),
/* 8 ( */ KEYBT(0x38, 0x28), /* 7 / */ KEYBTDECL(0x37, 0x2f, true),
/* 9 ) */ KEYBT(0x39, 0x29), /* 8 ( */ KEYBTDECL(0x38, 0x28, true),
/* 0 = */ KEYBT(0x30, 0x3d), /* 9 ) */ KEYBTDECL(0x39, 0x29, true),
/* ? ? */ KEYBT(0xdf, 0x3f), /* 0 = */ KEYBTDECL(0x30, 0x3d, true),
/* ` ? */ KEYBT(0x60, 0xb4), /* ? ? */ KEYBTDECL(0xdf, 0x3f, true),
/* ` ? */ KEYBTDECL(0x60, 0xb4, false),
/* q Q */ KEYBT(0x71, 0x51),
/* w W */ KEYBT(0x77, 0x57), /* q Q */ KEYBTDECL(0x71, 0x51, true),
/* e E */ KEYBT(0x65, 0x45), /* w W */ KEYBTDECL(0x77, 0x57, true),
/* r R */ KEYBT(0x72, 0x52), /* e E */ KEYBTDECL(0x65, 0x45, true),
/* t T */ KEYBT(0x74, 0x54), /* r R */ KEYBTDECL(0x72, 0x52, true),
/* z Z */ KEYBT(0x7a, 0x5a), /* t T */ KEYBTDECL(0x74, 0x54, true),
/* u U */ KEYBT(0x75, 0x55), /* z Z */ KEYBTDECL(0x7a, 0x5a, true),
/* i I */ KEYBT(0x69, 0x49), /* u U */ KEYBTDECL(0x75, 0x55, true),
/* o O */ KEYBT(0x6f, 0x4f), /* i I */ KEYBTDECL(0x69, 0x49, true),
/* p P */ KEYBT(0x70, 0x50), /* o O */ KEYBTDECL(0x6f, 0x4f, true),
/* ? ? */ KEYBT(0xfc, 0xdc), /* p P */ KEYBTDECL(0x70, 0x50, true),
/* + * */ KEYBT(0x2b, 0x2a), /* ? ? */ KEYBTDECL(0xfc, 0xdc, true),
/* + * */ KEYBTDECL(0x2b, 0x2a, true),
/* a A */ KEYBT(0x61, 0x41),
/* s S */ KEYBT(0x73, 0x53), /* a A */ KEYBTDECL(0x61, 0x41, true),
/* d D */ KEYBT(0x64, 0x44), /* s S */ KEYBTDECL(0x73, 0x53, true),
/* f F */ KEYBT(0x66, 0x46), /* d D */ KEYBTDECL(0x64, 0x44, true),
/* g G */ KEYBT(0x67, 0x47), /* f F */ KEYBTDECL(0x66, 0x46, true),
/* h H */ KEYBT(0x68, 0x48), /* g G */ KEYBTDECL(0x67, 0x47, true),
/* j J */ KEYBT(0x6a, 0x4a), /* h H */ KEYBTDECL(0x68, 0x48, true),
/* k K */ KEYBT(0x6b, 0x4b), /* j J */ KEYBTDECL(0x6a, 0x4a, true),
/* l L */ KEYBT(0x6c, 0x4c), /* k K */ KEYBTDECL(0x6b, 0x4b, true),
/* ? ? */ KEYBT(0xf6, 0xd6), /* l L */ KEYBTDECL(0x6c, 0x4c, true),
/* ? ? */ KEYBT(0xe4, 0xc4), /* ? ? */ KEYBTDECL(0xf6, 0xd6, true),
/* ' # */ KEYBT(0x27, 0x23), /* ? ? */ KEYBTDECL(0xe4, 0xc4, true),
/* ' # */ KEYBTDECL(0x27, 0x23, true),
/* y Y */ KEYBT(0x79, 0x59),
/* x X */ KEYBT(0x78, 0x58), /* y Y */ KEYBTDECL(0x79, 0x59, true),
/* c C */ KEYBT(0x63, 0x43), /* x X */ KEYBTDECL(0x78, 0x58, true),
/* v V */ KEYBT(0x76, 0x56), /* c C */ KEYBTDECL(0x63, 0x43, true),
/* b B */ KEYBT(0x62, 0x42), /* v V */ KEYBTDECL(0x76, 0x56, true),
/* n N */ KEYBT(0x6e, 0x4e), /* b B */ KEYBTDECL(0x62, 0x42, true),
/* m M */ KEYBT(0x6d, 0x4d), /* n N */ KEYBTDECL(0x6e, 0x4e, true),
/* , ; */ KEYBT(0x2c, 0x3b), /* m M */ KEYBTDECL(0x6d, 0x4d, true),
/* . : */ KEYBT(0x2e, 0x3a), /* , ; */ KEYBTDECL(0x2c, 0x3b, true),
/* _ - */ KEYBT(0x5f, 0x2d)}; /* . : */ KEYBTDECL(0x2e, 0x3a, true),
/* _ - */ KEYBTDECL(0x5f, 0x2d, false)};
void UBPlatformUtils::initializeKeyboardLayouts() void UBPlatformUtils::initializeKeyboardLayouts()
{ {

@ -38,11 +38,16 @@ UBKeyboardPalette::UBKeyboardPalette(QWidget *parent)
setGrip(false); setGrip(false);
capsLock = false; capsLock = false;
shift = false;
languagePopupActive = false; languagePopupActive = false;
keyboardActive = false; keyboardActive = false;
nSpecialModifierIndex = 0;
specialModifier = 0;
btnWidth = btnHeight = 16; btnWidth = btnHeight = 16;
strSize = "16x16"; strSize = "16x16";
currBtnImages = new BTNImages("16", btnWidth, btnHeight); currBtnImages = new BTNImages("16", btnWidth, btnHeight);
storage = NULL;
buttons = new UBKeyButton*[47]; buttons = new UBKeyButton*[47];
for (int i=0; i<47; i++) for (int i=0; i<47; i++)
@ -77,7 +82,7 @@ void UBKeyboardPalette::init()
//------------------------------// //------------------------------//
UBPlatformUtils::setWindowNonActivableFlag(this, true); UBPlatformUtils::setWindowNonActivableFlag(this, true);
} }
void UBKeyboardPalette::showKeyboard(bool show) void UBKeyboardPalette::showKeyboard(bool show)
@ -143,6 +148,8 @@ UBKeyboardPalette::~UBKeyboardPalette()
delete currBtnImages; delete currBtnImages;
currBtnImages = NULL; currBtnImages = NULL;
} }
onActivated(false);
} }
QSize UBKeyboardPalette::sizeHint () const QSize UBKeyboardPalette::sizeHint () const
@ -302,8 +309,10 @@ void UBKeyboardPalette::paintEvent( QPaintEvent* event)
//------------------- //-------------------
// // Row 3 Stub // // Row 3 Stub
// ctrlButtons[ctrlButtonsId++]->setGeometry(offX, offY, btnWidth, btnHeight);
// offX += btnWidth; // button Enter
ctrlButtons[ctrlButtonsId++]->setGeometry(offX, offY, btnWidth * 1, btnHeight);
offX += btnWidth*1;
// buttons [a]..[\] // buttons [a]..[\]
for (int i = 0; i < 12; i++) for (int i = 0; i < 12; i++)
@ -313,8 +322,8 @@ void UBKeyboardPalette::paintEvent( QPaintEvent* event)
} }
// button Enter // button Enter
ctrlButtons[ctrlButtonsId++]->setGeometry(offX, offY, btnWidth * 3, btnHeight); ctrlButtons[ctrlButtonsId++]->setGeometry(offX, offY, btnWidth * 2, btnHeight);
offX += btnWidth*3; offX += btnWidth*2;
//------------------------------------------------ //------------------------------------------------
// set geometry (position) for row 4 // set geometry (position) for row 4
@ -353,6 +362,11 @@ void UBKeyboardPalette::paintEvent( QPaintEvent* event)
//------------------------------------------------ //------------------------------------------------
} }
void UBKeyboardPalette::onDeactivated()
{
onActivated(false);
}
//-----------------------------------------------------------------------// //-----------------------------------------------------------------------//
// BTNImages Class // BTNImages Class
@ -415,6 +429,11 @@ UBKeyboardButton::~UBKeyboardButton()
} }
} }
bool UBKeyboardButton::isPressed()
{
return bPressed;
}
void UBKeyboardButton::paintEvent(QPaintEvent*) void UBKeyboardButton::paintEvent(QPaintEvent*)
{ {
@ -437,7 +456,7 @@ void UBKeyboardButton::paintEvent(QPaintEvent*)
//-------------------------- //--------------------------
if (bPressed) if (isPressed())
{ {
painter.drawImage( 0,0, m_parent->currBtnImages->m_btnLeftActive, 0,0, m_parent->currBtnImages->m_btnLeftActive.width(), m_parent->currBtnImages->m_btnLeftActive.height() ); painter.drawImage( 0,0, m_parent->currBtnImages->m_btnLeftActive, 0,0, m_parent->currBtnImages->m_btnLeftActive.width(), m_parent->currBtnImages->m_btnLeftActive.height() );
painter.drawImage( QRect(m_parent->currBtnImages->m_btnLeftActive.width(), 0, width() - m_parent->currBtnImages->m_btnLeftActive.width() - m_parent->currBtnImages->m_btnRightActive.width(), height()), m_parent->currBtnImages->m_btnCenterActive ); painter.drawImage( QRect(m_parent->currBtnImages->m_btnLeftActive.width(), 0, width() - m_parent->currBtnImages->m_btnLeftActive.width() - m_parent->currBtnImages->m_btnRightActive.width(), height()), m_parent->currBtnImages->m_btnCenterActive );
@ -471,7 +490,7 @@ void UBKeyboardButton::leaveEvent ( QEvent*)
void UBKeyboardButton::mousePressEvent ( QMouseEvent * event) void UBKeyboardButton::mousePressEvent ( QMouseEvent * event)
{ {
event->accept(); event->accept();
bPressed = true; bPressed = true;
update(); update();
this->onPress(); this->onPress();
@ -492,10 +511,55 @@ UBKeyButton::UBKeyButton(UBKeyboardPalette* parent)
UBKeyButton::~UBKeyButton() UBKeyButton::~UBKeyButton()
{} {}
bool UBKeyButton::shifted()
{
bool b = keyboard->shift;
if (keybt->capsLockSwitch && keyboard->capsLock)
b = !b;
return b;
}
void UBKeyButton::onPress() void UBKeyButton::onPress()
{ {
if (keybt!=NULL) if (keybt!=NULL)
sendUnicodeSymbol(keybt->code1, keybt->code2, capsLock()); {
int codeIndex = keyboard->nSpecialModifierIndex * 2 + shifted();
if (keyboard->nSpecialModifierIndex)
{
if (keybt->codes[codeIndex].empty())
{
sendUnicodeSymbol(keyboard->specialModifier);
sendUnicodeSymbol(keybt->codes[shifted()]);
}
else
{
sendUnicodeSymbol(keybt->codes[codeIndex]);
}
keyboard->nSpecialModifierIndex = 0;
}
else
{
int nSpecialModifierIndex = shifted()? keybt->modifier2 : keybt->modifier1;
if (nSpecialModifierIndex)
{
keyboard->nSpecialModifierIndex = nSpecialModifierIndex;
keyboard->specialModifier = keybt->codes[codeIndex];
}
else
{
sendUnicodeSymbol(keybt->codes[codeIndex]);
}
}
}
if (keyboard->shift)
{
keyboard->shift = false;
keyboard->update();
}
} }
void UBKeyButton::onRelease() void UBKeyButton::onRelease()
@ -505,7 +569,7 @@ void UBKeyButton::paintContent(QPainter& painter)
{ {
if (keybt) if (keybt)
{ {
QString text(QChar(capsLock() ? keybt->symbol2 : keybt->symbol1)); QString text(QChar(shifted() ? keybt->symbol2 : keybt->symbol1));
QRect textRect(rect().x()+2, rect().y()+2, rect().width()-4, rect().height()-4); QRect textRect(rect().x()+2, rect().y()+2, rect().width()-4, rect().height()-4);
painter.drawText(textRect, Qt::AlignCenter, text); painter.drawText(textRect, Qt::AlignCenter, text);
} }
@ -565,6 +629,11 @@ void UBCapsLockButton::onPress()
void UBCapsLockButton::onRelease() void UBCapsLockButton::onRelease()
{} {}
bool UBCapsLockButton::isPressed()
{
return keyboard->capsLock;
}
void UBCapsLockButton::paintContent(QPainter& painter) void UBCapsLockButton::paintContent(QPainter& painter)
{ {
if(imgContent != NULL) if(imgContent != NULL)
@ -576,6 +645,40 @@ void UBCapsLockButton::paintContent(QPainter& painter)
painter.drawText(rect(), Qt::AlignCenter, "^"); painter.drawText(rect(), Qt::AlignCenter, "^");
} }
UBShiftButton::UBShiftButton(UBKeyboardPalette* parent, const QString _contentImagePath)
:UBKeyboardButton(parent, _contentImagePath)
{}
UBShiftButton::~UBShiftButton()
{}
void UBShiftButton::onPress()
{
keyboard->shift = !keyboard->shift;
keyboard->update();
}
void UBShiftButton::onRelease()
{}
bool UBShiftButton::isPressed()
{
return keyboard->shift;
}
void UBShiftButton::paintContent(QPainter& painter)
{
if(imgContent != NULL)
{
painter.drawImage(( rect().width() - imgContent->m_btnContent.width() ) / 2, ( rect().height() - imgContent->m_btnContent.height() ) / 2,
imgContent->m_btnContent, 0,0, imgContent->m_btnContent.width(), imgContent->m_btnContent.height());
}
else
painter.drawText(rect(), Qt::AlignCenter, "^");
}
UBLocaleButton::UBLocaleButton(UBKeyboardPalette* parent) UBLocaleButton::UBLocaleButton(UBKeyboardPalette* parent)
:UBKeyboardButton(parent) :UBKeyboardButton(parent)

@ -64,7 +64,9 @@ class UBKeyboardPalette : public UBActionPalette
friend class UBKeyboardButton; friend class UBKeyboardButton;
friend class UBCapsLockButton; friend class UBCapsLockButton;
friend class UBShiftButton;
friend class UBLocaleButton; friend class UBLocaleButton;
friend class UBKeyButton;
public: public:
UBKeyboardPalette(QWidget *parent); UBKeyboardPalette(QWidget *parent);
@ -97,10 +99,14 @@ private slots:
protected: protected:
bool capsLock; bool capsLock;
bool shift;
int nCurrentLocale; int nCurrentLocale;
int nLocalesCount; int nLocalesCount;
UBKeyboardLocale** locales; UBKeyboardLocale** locales;
int nSpecialModifierIndex;
KEYCODE specialModifier;
QString strSize; QString strSize;
int btnWidth; int btnWidth;
int btnHeight; int btnHeight;
@ -113,7 +119,7 @@ protected:
virtual void paintEvent(QPaintEvent *event); virtual void paintEvent(QPaintEvent *event);
virtual void moveEvent ( QMoveEvent * event ); virtual void moveEvent ( QMoveEvent * event );
void sendKeyEvent(const KEYBT& keybt); void sendKeyEvent(KEYCODE keyCode);
void setLocale(int nLocale); void setLocale(int nLocale);
@ -170,11 +176,11 @@ protected:
virtual void onRelease() = 0; virtual void onRelease() = 0;
virtual void paintContent(QPainter& painter) = 0; virtual void paintContent(QPainter& painter) = 0;
bool capsLock(){return keyboard->capsLock;} virtual bool isPressed();
UBKeyboardPalette* keyboard; UBKeyboardPalette* keyboard;
void sendUnicodeSymbol(unsigned int nSymbol1, unsigned int nSymbol2, bool shift); void sendUnicodeSymbol(KEYCODE keycode);
void sendControlSymbol(int nSymbol); void sendControlSymbol(int nSymbol);
private: private:
@ -197,6 +203,7 @@ public:
virtual void paintContent(QPainter& painter); virtual void paintContent(QPainter& painter);
private: private:
bool shifted();
const KEYBT* keybt; const KEYBT* keybt;
}; };
@ -229,8 +236,28 @@ public:
virtual void onPress(); virtual void onPress();
virtual void onRelease(); virtual void onRelease();
virtual void paintContent(QPainter& painter); virtual void paintContent(QPainter& painter);
protected:
virtual bool isPressed();
};
class UBShiftButton : public UBKeyboardButton
{
Q_OBJECT
public:
UBShiftButton(UBKeyboardPalette* parent, const QString _contentImagePath);
~UBShiftButton();
virtual void onPress();
virtual void onRelease();
virtual void paintContent(QPainter& painter);
protected:
virtual bool isPressed();
}; };
class UBLocaleButton : public UBKeyboardButton class UBLocaleButton : public UBKeyboardButton
{ {
Q_OBJECT Q_OBJECT

@ -70,22 +70,61 @@ void x11SendKey(Display *display, int keyCode, int modifiers)
// Send a fake key release event to the window. // Send a fake key release event to the window.
event = createKeyEvent(display, winFocus, winRoot, false, keyCode, modifiers); event = createKeyEvent(display, winFocus, winRoot, false, keyCode, modifiers);
XSendEvent(event.display, event.window, True, KeyPressMask, (XEvent *)&event); XSendEvent(event.display, event.window, True, KeyPressMask, (XEvent *)&event);
} }
void UBKeyboardButton::sendUnicodeSymbol(unsigned int nSymbol1, unsigned int nSymbol2, bool shift) /*
void traceKeyCodes()
{ {
unsigned int nSymbol = shift ? nSymbol2 : nSymbol1; Display *display = XOpenDisplay(0);
if(display == NULL)
return;
int min_keycodes, max_keycodes, byte_per_code;
XDisplayKeycodes(display, &min_keycodes, &max_keycodes);
KeySym* keySyms = XGetKeyboardMapping(display, min_keycodes,
max_keycodes - min_keycodes, &byte_per_code);
qDebug() << "Codes table, min_keycodes: " << min_keycodes << ", max_keycodes: "
<< max_keycodes << ", bytes_per_code:" << byte_per_code;
for(int i=0; i<max_keycodes - min_keycodes; i++)
{
QString str;
for(int j=0; j<byte_per_code;j++)
{
str += QString::number(keySyms[i*byte_per_code + j], 16);
str += ":";
}
qDebug() << i << ":" << str;
}
XFree(keySyms);
XCloseDisplay(display);
}
*/
void UBKeyboardButton::sendUnicodeSymbol(KEYCODE keycode)
{
// Obtain the X11 display. // Obtain the X11 display.
Display *display = XOpenDisplay(0); Display *display = XOpenDisplay(0);
if(display == NULL) if(display == NULL)
return; return;
KeyCode keyCode = XKeysymToKeycode(display, nSymbol); if (!keycode.empty())
if (keyCode != NoSymbol)
{ {
x11SendKey(display, keyCode, shift); int modifier = keycode.modifier;
if (keycode.modifier==2) modifier = 0x2000;
if (keycode.modifier==3) modifier = 0x2001;
if (keycode.modifier==4) modifier = 0x4000;
if (keycode.modifier==5) modifier = 0x4001;
//modifiers 6 and 7 seems are not available.... They are reassigned in layout creationtime
//if (keycode.modifier==6) modifier = 0x6000;
//if (keycode.modifier==7) modifier = 0x6001;
x11SendKey(display, keycode.code + keyboard->min_keycodes , modifier);
} }
XCloseDisplay(display); XCloseDisplay(display);
@ -111,16 +150,17 @@ void UBKeyboardButton::sendControlSymbol(int nSymbol)
void UBKeyboardPalette::createCtrlButtons() void UBKeyboardPalette::createCtrlButtons()
{ {
ctrlButtons = new UBKeyboardButton*[8]; ctrlButtons = new UBKeyboardButton*[9];
ctrlButtons[0] = new UBCntrlButton(this, "<-", XK_BackSpace); ctrlButtons[0] = new UBCntrlButton(this, XK_BackSpace, "backspace");
ctrlButtons[1] = new UBCntrlButton(this, "<->", XK_Tab); ctrlButtons[1] = new UBCntrlButton(this, XK_Tab, "tab");
ctrlButtons[2] = new UBCntrlButton(this, tr("Enter"), XK_Return); ctrlButtons[2] = new UBCapsLockButton(this, "capslock");
ctrlButtons[3] = new UBCapsLockButton(this, "capslock"); ctrlButtons[3] = new UBCntrlButton(this, tr("Enter"), XK_Return);
ctrlButtons[4] = new UBCapsLockButton(this, "capslock"); ctrlButtons[4] = new UBShiftButton(this, "shift");
ctrlButtons[5] = new UBLocaleButton(this); ctrlButtons[5] = new UBShiftButton(this, "shift");
ctrlButtons[6] = new UBCntrlButton(this, "", XK_space); ctrlButtons[6] = new UBLocaleButton(this);
ctrlButtons[7] = new UBLocaleButton(this); ctrlButtons[7] = new UBCntrlButton(this, "", XK_space);
ctrlButtons[8] = new UBLocaleButton(this);
} }
@ -128,90 +168,106 @@ void UBKeyboardPalette::onActivated(bool activated)
{ {
if (activated) if (activated)
{ {
if (storage)
{
qDebug() << "Keybard already activated....";
return;
}
Display *display = XOpenDisplay(0); Display *display = XOpenDisplay(0);
if(display == NULL) if(display == NULL)
return; return;
XDisplayKeycodes(display, &this->min_keycodes, &this->max_keycodes); XDisplayKeycodes(display, &this->min_keycodes, &this->max_keycodes);
KeySym* keySyms = XGetKeyboardMapping(display, min_keycodes, KeySym* keySyms = XGetKeyboardMapping(display, min_keycodes,
max_keycodes - min_keycodes, &this->byte_per_code); max_keycodes - min_keycodes, &byte_per_code);
storage = keySyms; storage = keySyms;
XCloseDisplay(display); XCloseDisplay(display);
onLocaleChanged(locales[nCurrentLocale]); onLocaleChanged(locales[nCurrentLocale]);
} }
else else
{ {
Display *display = XOpenDisplay(0); Display *display = XOpenDisplay(0);
if(display == NULL) if(display == NULL)
return; {
qDebug() << "Keybard not activated....";
return;
}
KeySym* keySyms = (KeySym*)storage; KeySym* keySyms = (KeySym*)storage;
if (keySyms!=NULL) if (keySyms!=NULL)
{ {
qDebug() << "Default key table restored.....";
XChangeKeyboardMapping(display, min_keycodes, byte_per_code, XChangeKeyboardMapping(display, min_keycodes, byte_per_code,
keySyms, max_keycodes - min_keycodes); keySyms, max_keycodes - min_keycodes);
XFree(keySyms); XFree(keySyms);
} storage = NULL;
}
XCloseDisplay(display); XCloseDisplay(display);
} }
} }
void UBKeyboardPalette::onDeactivated()
void UBKeyboardPalette::onLocaleChanged(UBKeyboardLocale* locale)
{ {
Display *display = XOpenDisplay(0); Display *display = XOpenDisplay(0);
if(display == NULL) if(display == NULL)
return; return;
KeySym* keySyms = (KeySym*)storage; int byte_per_code;
if (keySyms!=NULL) { KeySym* keySyms = XGetKeyboardMapping(display, min_keycodes,
XChangeKeyboardMapping(display, min_keycodes, byte_per_code, max_keycodes - min_keycodes, &byte_per_code);
keySyms, max_keycodes - min_keycodes);
}
XCloseDisplay(display);
}
void setSymbolsFromButton(Display *display, for(int i=0; i<SYMBOL_KEYS_COUNT; i++)
const UBKeyboardLocale& locale,
int byte_per_code,
int nFromSymbol,
int nFromButton,
int count)
{
KeySym* keySyms = new KeySym[count * byte_per_code];
for(int i = 0; i < count; i++)
{ {
keySyms[byte_per_code * i + 0] = // loop by keybt
keySyms[byte_per_code * i + 2] = locale[nFromButton + i]->code1; for(int j=0; j<8; j++)
{
keySyms[byte_per_code * i + 1] = KEYCODE& kc = (*locale)[i]->codes[j];
keySyms[byte_per_code * i + 3] = locale[nFromButton + i]->code2; if (!kc.empty())
{
for(int j=4; j<byte_per_code; j++) if (kc.modifier <= 5)
keySyms[byte_per_code * i + j] = NoSymbol; keySyms[kc.code * byte_per_code + kc.modifier] = kc.symbol;
}
}
} }
XChangeKeyboardMapping(display, nFromSymbol, byte_per_code, keySyms, count); //Now look for modifiers > 5 and reassign them to free places
delete [] keySyms; for(int i=0; i<SYMBOL_KEYS_COUNT; i++)
} {
// loop by keybt
for(int j=0; j<8; j++)
{
KEYCODE& kc = (*locale)[i]->codes[j];
if (!kc.empty())
{
if (kc.modifier > 5)
{
for(int i1=0; i1<SYMBOL_KEYS_COUNT; i1++)
for(int j1=0; j1<=5; j1++)
if (keySyms[i1 * byte_per_code + j1]==NoSymbol)
{
kc.code =i1;
kc.modifier =j1;
break;
}
}
keySyms[kc.code * byte_per_code + kc.modifier] = kc.symbol;
}
}
}
void UBKeyboardPalette::onLocaleChanged(UBKeyboardLocale* locale)
{
Display *display = XOpenDisplay(0);
if(display == NULL)
return;
setSymbolsFromButton(display, *locale, byte_per_code, min_keycodes + 41, 0, 1); XChangeKeyboardMapping(display, min_keycodes, byte_per_code, keySyms, max_keycodes - min_keycodes);
setSymbolsFromButton(display, *locale, byte_per_code, min_keycodes + 2, 1, 12); XFree(keySyms);
setSymbolsFromButton(display, *locale, byte_per_code, min_keycodes + 16, 13, 12);
setSymbolsFromButton(display, *locale, byte_per_code, min_keycodes + 30, 25, 11);
setSymbolsFromButton(display, *locale, byte_per_code, min_keycodes + 44, 37, 10);
XCloseDisplay(display); XCloseDisplay(display);
} }

@ -22,15 +22,13 @@
#include <QMap> #include <QMap>
#include <QString> #include <QString>
void UBKeyboardButton::sendUnicodeSymbol(unsigned int nSymbol1, unsigned int nSymbol2, bool shift) void UBKeyboardButton::sendUnicodeSymbol(KEYCODE keycode)
{ {
unsigned int nSymbol = (shift)? nSymbol2 : nSymbol1; if (keycode.modifier)
if (shift)
CGEventPost(kCGSessionEventTap, CGEventCreateKeyboardEvent(NULL, 56, true)); CGEventPost(kCGSessionEventTap, CGEventCreateKeyboardEvent(NULL, 56, true));
CGEventPost(kCGSessionEventTap, CGEventCreateKeyboardEvent(NULL, nSymbol, true)); CGEventPost(kCGSessionEventTap, CGEventCreateKeyboardEvent(NULL, keycode.code, true));
CGEventPost(kCGSessionEventTap, CGEventCreateKeyboardEvent(NULL, nSymbol, false)); CGEventPost(kCGSessionEventTap, CGEventCreateKeyboardEvent(NULL, keycode.code, false));
if (shift) if (keycode.modifier)
CGEventPost(kCGSessionEventTap, CGEventCreateKeyboardEvent(NULL, 56, false)); CGEventPost(kCGSessionEventTap, CGEventCreateKeyboardEvent(NULL, 56, false));
} }
@ -46,16 +44,17 @@ void UBKeyboardButton::sendControlSymbol(int nSymbol)
void UBKeyboardPalette::createCtrlButtons() void UBKeyboardPalette::createCtrlButtons()
{ {
ctrlButtons = new UBKeyboardButton*[7]; ctrlButtons = new UBKeyboardButton*[9];
ctrlButtons[0] = new UBCntrlButton(this, "<-", 51); ctrlButtons[0] = new UBCntrlButton(this, 51, "backspace");
ctrlButtons[1] = new UBCntrlButton(this, "<->", 48); ctrlButtons[1] = new UBCntrlButton(this, 48, "tab");
ctrlButtons[2] = new UBCntrlButton(this, tr("Enter"), 76); ctrlButtons[2] = new UBCapsLockButton(this, "capslock");
ctrlButtons[3] = new UBCapsLockButton(this, "capslock"); ctrlButtons[3] = new UBCntrlButton(this, tr("Enter"), 76);
ctrlButtons[4] = new UBCapsLockButton(this, "capslock"); ctrlButtons[4] = new UBShiftButton(this, "shift");
ctrlButtons[5] = new UBLocaleButton(this); ctrlButtons[5] = new UBShiftButton(this, "shift");
ctrlButtons[6] = new UBCntrlButton(this, "", 49); ctrlButtons[6] = new UBLocaleButton(this);
ctrlButtons[7] = new UBLocaleButton(this); ctrlButtons[7] = new UBCntrlButton(this, "", 49);
ctrlButtons[8] = new UBLocaleButton(this);
} }
void SetMacLocaleByIdentifier(const QString& id) void SetMacLocaleByIdentifier(const QString& id)
@ -102,10 +101,7 @@ void UBKeyboardPalette::onActivated(bool activated)
SetMacLocaleByIdentifier(activeLocale); SetMacLocaleByIdentifier(activeLocale);
} }
} }
void UBKeyboardPalette::onDeactivated()
{
SetMacLocaleByIdentifier(activeLocale);
}
void UBKeyboardPalette::onLocaleChanged(UBKeyboardLocale* locale) void UBKeyboardPalette::onLocaleChanged(UBKeyboardLocale* locale)
{ {
SetMacLocaleByIdentifier(locale->id); SetMacLocaleByIdentifier(locale->id);

@ -8,21 +8,19 @@
#include "core/memcheck.h" #include "core/memcheck.h"
void UBKeyboardButton::sendUnicodeSymbol(unsigned int nSymbol1, unsigned int nSymbol2, bool shift) void UBKeyboardButton::sendUnicodeSymbol(KEYCODE keycode)
{ {
unsigned int nSymbol = shift? nSymbol2 : nSymbol1;
INPUT input[2]; INPUT input[2];
input[0].type = INPUT_KEYBOARD; input[0].type = INPUT_KEYBOARD;
input[0].ki.wVk = 0; input[0].ki.wVk = 0;
input[0].ki.wScan = nSymbol; input[0].ki.wScan = keycode.symbol;
input[0].ki.dwFlags = KEYEVENTF_UNICODE; input[0].ki.dwFlags = KEYEVENTF_UNICODE;
input[0].ki.time = 0; input[0].ki.time = 0;
input[0].ki.dwExtraInfo = 0; input[0].ki.dwExtraInfo = 0;
input[1].type = INPUT_KEYBOARD; input[1].type = INPUT_KEYBOARD;
input[1].ki.wVk = 0; input[1].ki.wVk = 0;
input[1].ki.wScan = nSymbol; input[1].ki.wScan = keycode.symbol;
input[1].ki.dwFlags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP; input[1].ki.dwFlags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP;
input[1].ki.time = 0; input[1].ki.time = 0;
input[1].ki.dwExtraInfo = 0; input[1].ki.dwExtraInfo = 0;
@ -57,11 +55,10 @@ void UBKeyboardPalette::createCtrlButtons()
ctrlButtons[ctrlID++] = new UBCntrlButton(this, 0x08, "backspace");// Backspace ctrlButtons[ctrlID++] = new UBCntrlButton(this, 0x08, "backspace");// Backspace
ctrlButtons[ctrlID++] = new UBCntrlButton(this, 0x09, "tab"); // Tab ctrlButtons[ctrlID++] = new UBCntrlButton(this, 0x09, "tab"); // Tab
// ctrlButtons[ctrlID++] = new UBKeyButton(this); // Row 2 Stub ctrlButtons[ctrlID++] = new UBCapsLockButton(this, "capslock"); // Shift
// ctrlButtons[ctrlID++] = new UBKeyButton(this); // Row 3 Stub
ctrlButtons[ctrlID++] = new UBCntrlButton(this, tr("Enter"), 0x0d); // Enter ctrlButtons[ctrlID++] = new UBCntrlButton(this, tr("Enter"), 0x0d); // Enter
ctrlButtons[ctrlID++] = new UBCapsLockButton(this, "capslock"); // Caps Lock ctrlButtons[ctrlID++] = new UBShiftButton(this, "shift"); // Shift
ctrlButtons[ctrlID++] = new UBCapsLockButton(this, "capslock"); // Caps Lock ctrlButtons[ctrlID++] = new UBShiftButton(this, "shift"); // Shift
ctrlButtons[ctrlID++] = new UBLocaleButton(this); // Language Switch ctrlButtons[ctrlID++] = new UBLocaleButton(this); // Language Switch
ctrlButtons[ctrlID++] = new UBCntrlButton(this, "", 0x20); // Space ctrlButtons[ctrlID++] = new UBCntrlButton(this, "", 0x20); // Space
ctrlButtons[ctrlID++] = new UBLocaleButton(this); // Language Switch ctrlButtons[ctrlID++] = new UBLocaleButton(this); // Language Switch
@ -69,10 +66,6 @@ void UBKeyboardPalette::createCtrlButtons()
void UBKeyboardPalette::onActivated(bool) void UBKeyboardPalette::onActivated(bool)
{ {
}
void UBKeyboardPalette::onDeactivated()
{
} }
void UBKeyboardPalette::onLocaleChanged(UBKeyboardLocale* ) void UBKeyboardPalette::onLocaleChanged(UBKeyboardLocale* )
{} {}

Loading…
Cancel
Save