summaryrefslogtreecommitdiff
path: root/beos/beos_window.cpp
diff options
context:
space:
mode:
authorFran├žois Revel <mmu_man@netsurf-browser.org>2008-10-10 21:43:25 +0000
committerFran├žois Revel <mmu_man@netsurf-browser.org>2008-10-10 21:43:25 +0000
commit4e79ee3d071df821f51f1a3f2d09bfedaa7af3b1 (patch)
tree75956bc92b844280da04395b9d80f2c4e6b324c7 /beos/beos_window.cpp
parente4fba7f577d44f3235b2c430191d96ddfc084827 (diff)
downloadnetsurf-4e79ee3d071df821f51f1a3f2d09bfedaa7af3b1.tar.gz
netsurf-4e79ee3d071df821f51f1a3f2d09bfedaa7af3b1.tar.bz2
- support BITMAP_CLEAR_MEMORY in create_bitmap()
- copying to clipboard now constructs a text_run_array for StyledEdit, that is added to the clipboard. In applications supporting it it pastes the text with the correct fonts and sizes, and the text colors. - tried to find which line in source code the selection starts to open the editor there, but it's not finished so it's disabled. svn path=/trunk/netsurf/; revision=5533
Diffstat (limited to 'beos/beos_window.cpp')
-rw-r--r--beos/beos_window.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/beos/beos_window.cpp b/beos/beos_window.cpp
index f51b5253b..32398a6e9 100644
--- a/beos/beos_window.cpp
+++ b/beos/beos_window.cpp
@@ -32,6 +32,7 @@ extern "C" {
#include "utils/utils.h"
}
#include "beos/beos_window.h"
+#include "beos/beos_font.h"
#include "beos/beos_gui.h"
#include "beos/beos_scaffolding.h"
#include "beos/beos_plotters.h"
@@ -46,6 +47,7 @@ extern "C" {
#include <ScrollBar.h>
#include <String.h>
#include <String.h>
+#include <TextView.h>
#include <View.h>
#include <Window.h>
@@ -104,6 +106,7 @@ static const rgb_color kWhiteColor = {255, 255, 255, 255};
static struct gui_window *window_list = 0; /**< first entry in win list*/
static BString current_selection;
+static BList current_selection_textruns;
static void nsbeos_gui_window_attach_child(struct gui_window *parent,
struct gui_window *child);
@@ -1744,6 +1747,10 @@ void gui_drag_save_selection(struct selection *s, struct gui_window *g)
void gui_start_selection(struct gui_window *g)
{
current_selection.Truncate(0);
+ while (current_selection_textruns.ItemAt(0)) {
+ text_run *run = (text_run *)current_selection_textruns.RemoveItem(0L);
+ delete run;
+ }
if (!g->view->LockLooper())
return;
@@ -1773,6 +1780,10 @@ void gui_paste_from_clipboard(struct gui_window *g, int x, int y)
bool gui_empty_clipboard(void)
{
current_selection.Truncate(0);
+ while (current_selection_textruns.ItemAt(0)) {
+ text_run *run = (text_run *)current_selection_textruns.RemoveItem(0L);
+ delete run;
+ }
return true;
}
@@ -1800,6 +1811,17 @@ bool gui_commit_clipboard(void)
clip->AddData("text/plain", B_MIME_TYPE,
current_selection.String(),
current_selection.Length());
+ int arraySize = sizeof(text_run_array) +
+ current_selection_textruns.CountItems() * sizeof(text_run);
+ text_run_array *array = (text_run_array *)malloc(arraySize);
+ array->count = current_selection_textruns.CountItems();
+ for (int i = 0; i < array->count; i++)
+ memcpy(&array->runs[i], current_selection_textruns.ItemAt(i),
+ sizeof(text_run));
+ clip->AddData("application/x-vnd.Be-text_run_array", B_MIME_TYPE,
+ array, arraySize);
+ free(array);
+
gui_empty_clipboard();
be_clipboard->Commit();
}
@@ -1812,6 +1834,7 @@ static bool copy_handler(const char *text, size_t length, struct box *box,
void *handle, const char *whitespace_text,
size_t whitespace_length)
{
+ //XXX: handle box->style to StyledEdit / RTF ?
/* add any whitespace which precedes the text from this box */
if (whitespace_text) {
if (!gui_add_to_clipboard(whitespace_text,
@@ -1819,6 +1842,18 @@ static bool copy_handler(const char *text, size_t length, struct box *box,
return false;
}
}
+
+ // add a text_run for StyledEdit-like text formating
+ if (box && box->style) {
+ text_run *run = new text_run;
+ BFont font;
+ nsbeos_style_to_font(font, box->style);
+ run->offset = current_selection.Length();
+ run->font = font;
+ run->color = nsbeos_rgb_colour(box->style->color);
+ current_selection_textruns.AddItem(run);
+ }
+
/* add the text from this box */
if (!gui_add_to_clipboard(text, length, box->space))
return false;